1
0
mirror of https://passt.top/passt synced 2024-12-22 05:35:23 +00:00

pasta: make it possible to disable socket splicing

During testing it is sometimes useful to force traffic which would
normally be forwared by socket splicing through the tap interface.

In this commit, we add a command switch enabling such funtionality
for inbound local traffic.

For outbound local traffic this is much trickier, if even possible,
so leave that for a later commit.

Suggested-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Jon Maloy <jmaloy@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
Jon Maloy 2024-12-10 13:36:45 -05:00 committed by Stefano Brivio
parent 947f5cdb93
commit e24f026222
4 changed files with 14 additions and 2 deletions

7
conf.c
View File

@ -977,7 +977,8 @@ pasta_opts:
" Don't copy all routes to namespace\n" " Don't copy all routes to namespace\n"
" --no-copy-addrs DEPRECATED:\n" " --no-copy-addrs DEPRECATED:\n"
" Don't copy all addresses to namespace\n" " Don't copy all addresses to namespace\n"
" --ns-mac-addr ADDR Set MAC address on tap interface\n"); " --ns-mac-addr ADDR Set MAC address on tap interface\n"
" --no-splice Disable inbound socket splicing\n");
exit(status); exit(status);
} }
@ -1319,6 +1320,7 @@ void conf(struct ctx *c, int argc, char **argv)
{"no-dhcpv6", no_argument, &c->no_dhcpv6, 1 }, {"no-dhcpv6", no_argument, &c->no_dhcpv6, 1 },
{"no-ndp", no_argument, &c->no_ndp, 1 }, {"no-ndp", no_argument, &c->no_ndp, 1 },
{"no-ra", no_argument, &c->no_ra, 1 }, {"no-ra", no_argument, &c->no_ra, 1 },
{"no-splice", no_argument, &c->no_splice, 1 },
{"freebind", no_argument, &c->freebind, 1 }, {"freebind", no_argument, &c->freebind, 1 },
{"no-map-gw", no_argument, &no_map_gw, 1 }, {"no-map-gw", no_argument, &no_map_gw, 1 },
{"ipv4-only", no_argument, NULL, '4' }, {"ipv4-only", no_argument, NULL, '4' },
@ -1756,6 +1758,9 @@ void conf(struct ctx *c, int argc, char **argv)
} }
} while (name != -1); } while (name != -1);
if (c->mode != MODE_PASTA)
c->no_splice = 1;
if (c->mode == MODE_PASTA && !c->pasta_conf_ns) { if (c->mode == MODE_PASTA && !c->pasta_conf_ns) {
if (copy_routes_opt) if (copy_routes_opt)
die("--no-copy-routes needs --config-net"); die("--no-copy-routes needs --config-net");

2
fwd.c
View File

@ -443,7 +443,7 @@ uint8_t fwd_nat_from_host(const struct ctx *c, uint8_t proto,
else if (proto == IPPROTO_UDP) else if (proto == IPPROTO_UDP)
tgt->eport += c->udp.fwd_in.delta[tgt->eport]; tgt->eport += c->udp.fwd_in.delta[tgt->eport];
if (c->mode == MODE_PASTA && inany_is_loopback(&ini->eaddr) && if (!c->no_splice && inany_is_loopback(&ini->eaddr) &&
(proto == IPPROTO_TCP || proto == IPPROTO_UDP)) { (proto == IPPROTO_TCP || proto == IPPROTO_UDP)) {
/* spliceable */ /* spliceable */

View File

@ -695,6 +695,11 @@ Configure MAC address \fIaddr\fR on the tap interface in the namespace.
Default is to let the tap driver build a pseudorandom hardware address. Default is to let the tap driver build a pseudorandom hardware address.
.TP
.BR \-\-no-splice
Disable the bypass path for inbound, local traffic. See the section \fBHandling
of local traffic in pasta\fR in the \fBNOTES\fR for more details.
.SH EXAMPLES .SH EXAMPLES
.SS \fBpasta .SS \fBpasta

View File

@ -229,6 +229,7 @@ struct ip6_ctx {
* @no_dhcpv6: Disable DHCPv6 server * @no_dhcpv6: Disable DHCPv6 server
* @no_ndp: Disable NDP handler altogether * @no_ndp: Disable NDP handler altogether
* @no_ra: Disable router advertisements * @no_ra: Disable router advertisements
* @no_splice: Disable socket splicing for inbound traffic
* @host_lo_to_ns_lo: Map host loopback addresses to ns loopback addresses * @host_lo_to_ns_lo: Map host loopback addresses to ns loopback addresses
* @freebind: Allow binding of non-local addresses for forwarding * @freebind: Allow binding of non-local addresses for forwarding
* @low_wmem: Low probed net.core.wmem_max * @low_wmem: Low probed net.core.wmem_max
@ -291,6 +292,7 @@ struct ctx {
int no_dhcpv6; int no_dhcpv6;
int no_ndp; int no_ndp;
int no_ra; int no_ra;
int no_splice;
int host_lo_to_ns_lo; int host_lo_to_ns_lo;
int freebind; int freebind;