1
0
Fork 0
mirror of https://passt.top/passt synced 2025-06-15 11:55:34 +02:00

util: Make sock_l4() treat empty string ifname like NULL

sock_l4() takes NULL for ifname if you don't want to bind the socket to a
particular interface.  However, for a number of the callers, it's more
natural to use an empty string for that case.  Change sock_l4() to accept
either NULL or an empty string equivalently, and simplify some callers
using that change.

Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
This commit is contained in:
David Gibson 2023-12-08 01:31:40 +11:00 committed by Stefano Brivio
parent 5cada56186
commit 57de44a4bc
3 changed files with 7 additions and 16 deletions

6
udp.c
View file

@ -870,8 +870,7 @@ int udp_tap_handler(struct ctx *c, uint8_t pif,
union udp_epoll_ref uref = { .port = src };
const char *bind_if = NULL;
if (!IN6_IS_ADDR_LOOPBACK(&s_in.sin_addr) &&
*c->ip6.ifname_out)
if (!IN6_IS_ADDR_LOOPBACK(&s_in.sin_addr))
bind_if = c->ip6.ifname_out;
if (!IN4_IS_ADDR_UNSPECIFIED(&c->ip4.addr_out) &&
@ -919,8 +918,7 @@ int udp_tap_handler(struct ctx *c, uint8_t pif,
union udp_epoll_ref uref = { .v6 = 1, .port = src };
const char *bind_if = NULL;
if (!IN6_IS_ADDR_LOOPBACK(&s_in6.sin6_addr) &&
*c->ip6.ifname_out)
if (!IN6_IS_ADDR_LOOPBACK(&s_in6.sin6_addr))
bind_if = c->ip6.ifname_out;
if (!IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addr_out) &&