aboutgitcodebugslistschat
path: root/fwd.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2024-08-29 19:58:45 +1000
committerStefano Brivio <sbrivio@redhat.com>2024-08-29 22:25:51 +0200
commit1daf6f4615226a2cdd9523a80d70736af4a9f3c0 (patch)
tree12df1676a4627a91cf80fe5833f59b7ea08cb77d /fwd.h
parent712ca3235329b049bf9a4e481ba38a4c64768e8b (diff)
downloadpasst-1daf6f4615226a2cdd9523a80d70736af4a9f3c0.tar
passt-1daf6f4615226a2cdd9523a80d70736af4a9f3c0.tar.gz
passt-1daf6f4615226a2cdd9523a80d70736af4a9f3c0.tar.bz2
passt-1daf6f4615226a2cdd9523a80d70736af4a9f3c0.tar.lz
passt-1daf6f4615226a2cdd9523a80d70736af4a9f3c0.tar.xz
passt-1daf6f4615226a2cdd9523a80d70736af4a9f3c0.tar.zst
passt-1daf6f4615226a2cdd9523a80d70736af4a9f3c0.zip
conf, fwd: Make ephemeral port logic more flexible
"Ephemeral" ports are those which the kernel may allocate as local port numbers for outgoing connections or datagrams. Because of that, they're generally not good choices for listening servers to bind to. Thefore when using -t all, -u all or exclude-only ranges, we map only non-ephemeral ports. Our logic for this is a bit rigid though: we assume the ephemeral ports are always a fixed range at the top of the port number space. We also assume PORT_EPHEMERAL_MIN is a multiple of 8, or we won't set the forward bitmap correctly. Make the logic in conf.c more flexible, using a helper moved into fwd.[ch], although we don't change which ports we consider ephemeral (yet). The new handling is undoubtedly more computationally expensive, but since it's a once-off operation at start off, I don't think it really matters. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'fwd.h')
-rw-r--r--fwd.h2
1 files changed, 2 insertions, 0 deletions
diff --git a/fwd.h b/fwd.h
index b4aa8d5..99dd66c 100644
--- a/fwd.h
+++ b/fwd.h
@@ -12,6 +12,8 @@ struct flowside;
/* Number of ports for both TCP and UDP */
#define NUM_PORTS (1U << 16)
+bool fwd_port_is_ephemeral(in_port_t port);
+
enum fwd_ports_mode {
FWD_UNSET = 0,
FWD_SPEC = 1,