aboutgitcodebugslistschat
path: root/udp.h
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-11-06 13:17:08 +1100
committerStefano Brivio <sbrivio@redhat.com>2023-11-07 09:55:03 +0100
commit480aa4a10818ee25d739af2f9f156dcbbbcb64dd (patch)
tree1706ca7f9f6678232d9af647d2bc251e156620b6 /udp.h
parentc0426ff10bc9dbc9c64f3d32995feb9262c82148 (diff)
downloadpasst-480aa4a10818ee25d739af2f9f156dcbbbcb64dd.tar
passt-480aa4a10818ee25d739af2f9f156dcbbbcb64dd.tar.gz
passt-480aa4a10818ee25d739af2f9f156dcbbbcb64dd.tar.bz2
passt-480aa4a10818ee25d739af2f9f156dcbbbcb64dd.tar.lz
passt-480aa4a10818ee25d739af2f9f156dcbbbcb64dd.tar.xz
passt-480aa4a10818ee25d739af2f9f156dcbbbcb64dd.tar.zst
passt-480aa4a10818ee25d739af2f9f156dcbbbcb64dd.zip
udp: Consistently use -1 to indicate un-opened sockets in maps
udp uses the udp_tap_map, udp_splice_ns and udp_splice_init tables to keep track of already opened sockets bound to specific ports. We need a way to indicate entries where a socket hasn't been opened, but the code isn't consistent if this is indicated by a 0 or a -1: * udp_splice_sendfrom() and udp_tap_handler() assume that 0 indicates an unopened socket * udp_sock_init() fills in -1 for a failure to open a socket * udp_timer_one() is somewhere in between, treating only strictly positive fds as valid -1 (or, at least, negative) is really the correct choice here, since 0 is a theoretically valid fd value (if very unlikely in practice). Change to use that consistently throughout. The table does need to be initialised to all -1 values before any calls to udp_sock_init() which can happen from conf_ports(). Because C doesn't make it easy to statically initialise non zero values in large tables, this does require a somewhat awkward call to initialise the table from conf(). This is the best approach I could see for the short term, with any luck it will go away at some point when those socket tables are replaced by a unified flow table. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'udp.h')
-rw-r--r--udp.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/udp.h b/udp.h
index 4e45919..85ebaaa 100644
--- a/udp.h
+++ b/udp.h
@@ -8,6 +8,7 @@
#define UDP_TIMER_INTERVAL 1000 /* ms */
+void udp_portmap_clear(void);
void udp_sock_handler(const struct ctx *c, union epoll_ref ref, uint32_t events,
const struct timespec *now);
int udp_tap_handler(struct ctx *c, uint8_t pif, int af,