aboutgitcodebugslistschat
path: root/util.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-12-08 01:31:40 +1100
committerStefano Brivio <sbrivio@redhat.com>2023-12-27 19:29:45 +0100
commit57de44a4bc36a7034b2a90f44db0696f3099f75a (patch)
tree3736b8eb23a6724421d37f70d5e255cb77644727 /util.c
parent5cada561863bb2bf95ef9bad6c18d6c306b82662 (diff)
downloadpasst-57de44a4bc36a7034b2a90f44db0696f3099f75a.tar
passt-57de44a4bc36a7034b2a90f44db0696f3099f75a.tar.gz
passt-57de44a4bc36a7034b2a90f44db0696f3099f75a.tar.bz2
passt-57de44a4bc36a7034b2a90f44db0696f3099f75a.tar.lz
passt-57de44a4bc36a7034b2a90f44db0696f3099f75a.tar.xz
passt-57de44a4bc36a7034b2a90f44db0696f3099f75a.tar.zst
passt-57de44a4bc36a7034b2a90f44db0696f3099f75a.zip
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>
Diffstat (limited to 'util.c')
-rw-r--r--util.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/util.c b/util.c
index 6e90371..d51f50f 100644
--- a/util.c
+++ b/util.c
@@ -187,7 +187,7 @@ int sock_l4(const struct ctx *c, int af, uint8_t proto,
if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &y, sizeof(y)))
debug("Failed to set SO_REUSEADDR on socket %i", fd);
- if (ifname) {
+ if (ifname && *ifname) {
/* Supported since kernel version 5.7, commit c427bfec18f2
* ("net: core: enable SO_BINDTODEVICE for non-root users"). If
* it's unsupported, don't bind the socket at all, because the