mirror of
https://passt.top/passt
synced 2025-06-16 12:25:34 +02:00
tcp: Improve handling of fallback if socket pool is empty on new splice
When creating a new spliced connection, we need to get a socket in the other ns from the originating one. To avoid excessive ns switches we usually get these from a pool refilled on a timer. However, if the pool runs out we need a fallback. Currently that's done by passing -1 as the socket to tcp_splice_connnect() and running it in the target ns. This means that tcp_splice_connect() itself needs to have different cases depending on whether it's given an existing socket or not, which is a separate concern from what it's mostly doing. We change it to require a suitable open socket to be passed in, and ensuring in the caller that we have one. This requires adding the fallback paths to the caller, tcp_splice_new(). We use slightly different approaches for a socket in the init ns versus the guest ns. This also means that we no longer need to run tcp_splice_connect() itself in the guest ns, which allows us to remove a bunch of boilerplate code. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
parent
dc467d526f
commit
6ccab72d9b
3 changed files with 31 additions and 59 deletions
2
tcp.c
2
tcp.c
|
@ -1882,7 +1882,7 @@ int tcp_conn_pool_sock(int pool[])
|
|||
*
|
||||
* Return: socket number on success, negative code if socket creation failed
|
||||
*/
|
||||
static int tcp_conn_new_sock(const struct ctx *c, sa_family_t af)
|
||||
int tcp_conn_new_sock(const struct ctx *c, sa_family_t af)
|
||||
{
|
||||
int s;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue