diff options
author | Stefano Brivio <sbrivio@redhat.com> | 2023-03-08 12:14:29 +0100 |
---|---|---|
committer | Stefano Brivio <sbrivio@redhat.com> | 2023-03-09 03:44:21 +0100 |
commit | 73992c42cea0df56f6ba0a3bef0f4a939f26ebad (patch) | |
tree | 0ea4292ab62f4c23fd6399e174147b2687b1890d /udp.c | |
parent | 50687616e4a99eabb2f22de8651817746c0abda1 (diff) | |
download | passt-73992c42cea0df56f6ba0a3bef0f4a939f26ebad.tar passt-73992c42cea0df56f6ba0a3bef0f4a939f26ebad.tar.gz passt-73992c42cea0df56f6ba0a3bef0f4a939f26ebad.tar.bz2 passt-73992c42cea0df56f6ba0a3bef0f4a939f26ebad.tar.lz passt-73992c42cea0df56f6ba0a3bef0f4a939f26ebad.tar.xz passt-73992c42cea0df56f6ba0a3bef0f4a939f26ebad.tar.zst passt-73992c42cea0df56f6ba0a3bef0f4a939f26ebad.zip |
tcp, udp, util: Pass socket creation errors all the way up
...starting from sock_l4(), pass negative error (errno) codes instead
of -1. They will only be used in two commits from now, no functional
changes intended here.
Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'udp.c')
-rw-r--r-- | udp.c | 18 |
1 files changed, 9 insertions, 9 deletions
@@ -977,7 +977,7 @@ int udp_tap_handler(struct ctx *c, int af, const void *addr, * @ifname: Name of interface to bind to, NULL if not configured * @port: Port, host order * - * Return: 0 on (partial) success, -1 on (complete) failure + * Return: 0 on (partial) success, negative error code on (complete) failure */ int udp_sock_init(const struct ctx *c, int ns, sa_family_t af, const void *addr, const char *ifname, in_port_t port) @@ -1002,19 +1002,19 @@ int udp_sock_init(const struct ctx *c, int ns, sa_family_t af, s = sock_l4(c, AF_INET, IPPROTO_UDP, addr, ifname, port, uref.u32); - udp_tap_map[V4][uref.udp.port].sock = s; - udp_splice_init[V4][port].sock = s; + udp_tap_map[V4][uref.udp.port].sock = s < 0 ? -1 : s; + udp_splice_init[V4][port].sock = s < 0 ? -1 : s; } else { struct in_addr loopback = { htonl(INADDR_LOOPBACK) }; uref.udp.ns = true; s = sock_l4(c, AF_INET, IPPROTO_UDP, &loopback, ifname, port, uref.u32); - udp_splice_ns[V4][port].sock = s; + udp_splice_ns[V4][port].sock = s < 0 ? -1 : s; } if (s < 0) - ret = -1; + ret = s; } if ((af == AF_INET6 || af == AF_UNSPEC) && c->ifi6) { @@ -1026,18 +1026,18 @@ int udp_sock_init(const struct ctx *c, int ns, sa_family_t af, s = sock_l4(c, AF_INET6, IPPROTO_UDP, addr, ifname, port, uref.u32); - udp_tap_map[V6][uref.udp.port].sock = s; - udp_splice_init[V6][port].sock = s; + udp_tap_map[V6][uref.udp.port].sock = s < 0 ? -1 : s; + udp_splice_init[V6][port].sock = s < 0 ? -1 : s; } else { uref.udp.ns = true; s = sock_l4(c, AF_INET6, IPPROTO_UDP, &in6addr_loopback, ifname, port, uref.u32); - udp_splice_ns[V6][port].sock = s; + udp_splice_ns[V6][port].sock = s < 0 ? -1 : s; } if (s < 0) - ret = -1; + ret = s; } return ret; |