aboutgitcodebugslistschat
path: root/icmp.c
diff options
context:
space:
mode:
authorDavid Gibson <david@gibson.dropbear.id.au>2023-12-08 01:31:38 +1100
committerStefano Brivio <sbrivio@redhat.com>2023-12-27 19:29:45 +0100
commit24d1f6570b0b4ca09535d15d07511addc1e9c40f (patch)
tree116d66c79cfb8c600ffbc3189ee347639429bcb9 /icmp.c
parentb9f4314ef9e7dc8b2852430f6923cbedda46ae38 (diff)
downloadpasst-24d1f6570b0b4ca09535d15d07511addc1e9c40f.tar
passt-24d1f6570b0b4ca09535d15d07511addc1e9c40f.tar.gz
passt-24d1f6570b0b4ca09535d15d07511addc1e9c40f.tar.bz2
passt-24d1f6570b0b4ca09535d15d07511addc1e9c40f.tar.lz
passt-24d1f6570b0b4ca09535d15d07511addc1e9c40f.tar.xz
passt-24d1f6570b0b4ca09535d15d07511addc1e9c40f.tar.zst
passt-24d1f6570b0b4ca09535d15d07511addc1e9c40f.zip
icmp: Avoid unnecessary handling of unspecified bind address
We go to some trouble, if the configured output address is unspecified, to pass NULL to sock_l4(). But while passing NULL is one way to get sock_l4() not to specify a bind address, passing the "any" address explicitly works too. Use this to simplify icmp_tap_handler(). Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Stefano Brivio <sbrivio@redhat.com>
Diffstat (limited to 'icmp.c')
-rw-r--r--icmp.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/icmp.c b/icmp.c
index 2a15d25..d982fda 100644
--- a/icmp.c
+++ b/icmp.c
@@ -187,16 +187,12 @@ 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 struct in_addr *bind_addr = NULL;
const char *bind_if;
bind_if = *c->ip4.ifname_out ? c->ip4.ifname_out : NULL;
- if (!IN4_IS_ADDR_UNSPECIFIED(&c->ip4.addr_out))
- bind_addr = &c->ip4.addr_out;
-
- s = sock_l4(c, AF_INET, IPPROTO_ICMP, bind_addr,
- bind_if, id, iref.u32);
+ s = sock_l4(c, AF_INET, IPPROTO_ICMP,
+ &c->ip4.addr_out, bind_if, id, iref.u32);
if (s < 0)
goto fail_sock;
if (s > FD_REF_MAX) {
@@ -241,16 +237,12 @@ 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 struct in6_addr *bind_addr = NULL;
const char *bind_if;
bind_if = *c->ip6.ifname_out ? c->ip6.ifname_out : NULL;
- if (!IN6_IS_ADDR_UNSPECIFIED(&c->ip6.addr_out))
- bind_addr = &c->ip6.addr_out;
-
- s = sock_l4(c, AF_INET6, IPPROTO_ICMPV6, bind_addr,
- bind_if, id, iref.u32);
+ s = sock_l4(c, AF_INET6, IPPROTO_ICMPV6,
+ &c->ip6.addr_out, bind_if, id, iref.u32);
if (s < 0)
goto fail_sock;
if (s > FD_REF_MAX) {