aboutgitcodebugslistschat
path: root/fwd.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-07-18 15:26:52 +1000
committerStefano Brivio <sbrivio@redhat.com>2024-07-19 18:33:57 +0200
commitd29fa0856e75816431e78552821ec77c59e25b3e (patch)
tree9117d52ad3ed4159cdf821d95509979d005dd688 /fwd.c
parentd89b3aa097a6777e981a4eb537a0b37f08a5b3a7 (diff)
downloadpasst-d29fa0856e75816431e78552821ec77c59e25b3e.tar
passt-d29fa0856e75816431e78552821ec77c59e25b3e.tar.gz
passt-d29fa0856e75816431e78552821ec77c59e25b3e.tar.bz2
passt-d29fa0856e75816431e78552821ec77c59e25b3e.tar.lz
passt-d29fa0856e75816431e78552821ec77c59e25b3e.tar.xz
passt-d29fa0856e75816431e78552821ec77c59e25b3e.tar.zst
passt-d29fa0856e75816431e78552821ec77c59e25b3e.zip
udp: Remove rdelta port forwarding maps
In addition to the struct fwd_ports used by both UDP and TCP to track port forwarding, UDP also included an 'rdelta' field, which contained the reverse mapping of the main port map. This was used so that we could properly direct reply packets to a forwarded packet where we change the destination port. This has now been taken over by the flow table: reply packets will match the flow of the originating packet, and that gives the correct ports on the originating side. So, eliminate the rdelta field, and with it struct udp_fwd_ports, which now has no additional information over struct fwd_ports. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'fwd.c')
-rw-r--r--fwd.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/fwd.c b/fwd.c
index a70ebfd..8c1f3d9 100644
--- a/fwd.c
+++ b/fwd.c
@@ -129,18 +129,18 @@ void fwd_scan_ports_init(struct ctx *c)
c->tcp.fwd_in.scan4 = c->tcp.fwd_in.scan6 = -1;
c->tcp.fwd_out.scan4 = c->tcp.fwd_out.scan6 = -1;
- c->udp.fwd_in.f.scan4 = c->udp.fwd_in.f.scan6 = -1;
- c->udp.fwd_out.f.scan4 = c->udp.fwd_out.f.scan6 = -1;
+ c->udp.fwd_in.scan4 = c->udp.fwd_in.scan6 = -1;
+ c->udp.fwd_out.scan4 = c->udp.fwd_out.scan6 = -1;
if (c->tcp.fwd_in.mode == FWD_AUTO) {
c->tcp.fwd_in.scan4 = open_in_ns(c, "/proc/net/tcp", flags);
c->tcp.fwd_in.scan6 = open_in_ns(c, "/proc/net/tcp6", flags);
fwd_scan_ports_tcp(&c->tcp.fwd_in, &c->tcp.fwd_out);
}
- if (c->udp.fwd_in.f.mode == FWD_AUTO) {
- c->udp.fwd_in.f.scan4 = open_in_ns(c, "/proc/net/udp", flags);
- c->udp.fwd_in.f.scan6 = open_in_ns(c, "/proc/net/udp6", flags);
- fwd_scan_ports_udp(&c->udp.fwd_in.f, &c->udp.fwd_out.f,
+ if (c->udp.fwd_in.mode == FWD_AUTO) {
+ c->udp.fwd_in.scan4 = open_in_ns(c, "/proc/net/udp", flags);
+ c->udp.fwd_in.scan6 = open_in_ns(c, "/proc/net/udp6", flags);
+ fwd_scan_ports_udp(&c->udp.fwd_in, &c->udp.fwd_out,
&c->tcp.fwd_in, &c->tcp.fwd_out);
}
if (c->tcp.fwd_out.mode == FWD_AUTO) {
@@ -148,10 +148,10 @@ void fwd_scan_ports_init(struct ctx *c)
c->tcp.fwd_out.scan6 = open("/proc/net/tcp6", flags);
fwd_scan_ports_tcp(&c->tcp.fwd_out, &c->tcp.fwd_in);
}
- if (c->udp.fwd_out.f.mode == FWD_AUTO) {
- c->udp.fwd_out.f.scan4 = open("/proc/net/udp", flags);
- c->udp.fwd_out.f.scan6 = open("/proc/net/udp6", flags);
- fwd_scan_ports_udp(&c->udp.fwd_out.f, &c->udp.fwd_in.f,
+ if (c->udp.fwd_out.mode == FWD_AUTO) {
+ c->udp.fwd_out.scan4 = open("/proc/net/udp", flags);
+ c->udp.fwd_out.scan6 = open("/proc/net/udp6", flags);
+ fwd_scan_ports_udp(&c->udp.fwd_out, &c->udp.fwd_in,
&c->tcp.fwd_out, &c->tcp.fwd_in);
}
}
@@ -242,7 +242,7 @@ uint8_t fwd_nat_from_splice(const struct ctx *c, uint8_t proto,
if (proto == IPPROTO_TCP)
tgt->eport += c->tcp.fwd_out.delta[tgt->eport];
else if (proto == IPPROTO_UDP)
- tgt->eport += c->udp.fwd_out.f.delta[tgt->eport];
+ tgt->eport += c->udp.fwd_out.delta[tgt->eport];
/* Let the kernel pick a host side source port */
tgt->fport = 0;
@@ -271,7 +271,7 @@ uint8_t fwd_nat_from_host(const struct ctx *c, uint8_t proto,
if (proto == IPPROTO_TCP)
tgt->eport += c->tcp.fwd_in.delta[tgt->eport];
else if (proto == IPPROTO_UDP)
- tgt->eport += c->udp.fwd_in.f.delta[tgt->eport];
+ tgt->eport += c->udp.fwd_in.delta[tgt->eport];
if (c->mode == MODE_PASTA && inany_is_loopback(&ini->eaddr) &&
(proto == IPPROTO_TCP || proto == IPPROTO_UDP)) {