mirror of
https://passt.top/passt
synced 2025-06-09 09:05:35 +02:00
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>
This commit is contained in:
parent
c0426ff10b
commit
480aa4a108
3 changed files with 23 additions and 5 deletions
1
conf.c
1
conf.c
|
@ -1675,6 +1675,7 @@ void conf(struct ctx *c, int argc, char **argv)
|
|||
c->no_map_gw = 1;
|
||||
|
||||
/* Inbound port options can be parsed now (after IPv4/IPv6 settings) */
|
||||
udp_portmap_clear();
|
||||
optind = 1;
|
||||
do {
|
||||
name = getopt_long(argc, argv, optstring, options, NULL);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue