mirror of
https://passt.top/passt
synced 2025-06-13 02: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:
parent
5cada56186
commit
57de44a4bc
3 changed files with 7 additions and 16 deletions
15
icmp.c
15
icmp.c
|
@ -187,12 +187,8 @@ int icmp_tap_handler(const struct ctx *c, uint8_t pif, int af,
|
|||
iref.id = id = ntohs(ih->un.echo.id);
|
||||
|
||||
if ((s = icmp_id_map[V4][id].sock) <= 0) {
|
||||
const char *bind_if;
|
||||
|
||||
bind_if = *c->ip4.ifname_out ? c->ip4.ifname_out : NULL;
|
||||
|
||||
s = sock_l4(c, AF_INET, IPPROTO_ICMP,
|
||||
&c->ip4.addr_out, bind_if, id, iref.u32);
|
||||
s = sock_l4(c, AF_INET, IPPROTO_ICMP, &c->ip4.addr_out,
|
||||
c->ip4.ifname_out, id, iref.u32);
|
||||
if (s < 0)
|
||||
goto fail_sock;
|
||||
if (s > FD_REF_MAX) {
|
||||
|
@ -237,12 +233,9 @@ int icmp_tap_handler(const struct ctx *c, uint8_t pif, int af,
|
|||
|
||||
iref.id = id = ntohs(ih->icmp6_identifier);
|
||||
if ((s = icmp_id_map[V6][id].sock) <= 0) {
|
||||
const char *bind_if;
|
||||
|
||||
bind_if = *c->ip6.ifname_out ? c->ip6.ifname_out : NULL;
|
||||
|
||||
s = sock_l4(c, AF_INET6, IPPROTO_ICMPV6,
|
||||
&c->ip6.addr_out, bind_if, id, iref.u32);
|
||||
&c->ip6.addr_out,
|
||||
c->ip6.ifname_out, id, iref.u32);
|
||||
if (s < 0)
|
||||
goto fail_sock;
|
||||
if (s > FD_REF_MAX) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue