Jeremie Courreges-Anglas <j...@wxcvbn.org> writes: > Kapetanakis Giannis <bil...@edu.physics.uoc.gr> writes: > >> On 10/07/17 17:22, Jeremie Courreges-Anglas wrote: >>> Using -1 for IPV6_UNICAST_HOPS is correct. >>> >>> Note that you can also use -1 for IP_TTL on OpenBSD, sadly some systems >>> out there don't support it. >>> >>>> comments? >>> >>> ok jca@ with the nits below. >>> >>> It would be nice to factor this out in a helper function and use it >>> elsewhere in relayd. >> >> Thanks for the comments. >> >> My guess is that the helper function should go outside of relayd so it can >> be used by others as well? >> I leave that to a more competent programmer. >> >> Would you like me to set -1 to IP_TTL as well and drop the call to >> getsockopt(2)? > > I'm not sure about this. Maybe it should be discussed separately? > >> updated diff bellow (in case not) with jca@ recommendations. > > I have tweaks, but this already looks fine to me. ok jca@
The tweak I had in mind: consistently use "ttl" for all the get/setsockopt calls. ok? Index: check_icmp.c =================================================================== RCS file: /d/cvs/src/usr.sbin/relayd/check_icmp.c,v retrieving revision 1.46 diff -u -p -p -u -r1.46 check_icmp.c --- check_icmp.c 11 Jul 2017 19:41:30 -0000 1.46 +++ check_icmp.c 12 Jul 2017 18:57:52 -0000 @@ -220,11 +220,12 @@ send_icmp(int s, short event, void *arg) sizeof(packet)); } + ttl = host->conf.ttl; switch(cie->af) { case AF_INET: - if ((ttl = host->conf.ttl) > 0) { + if (ttl > 0) { if (setsockopt(s, IPPROTO_IP, IP_TTL, - &host->conf.ttl, sizeof(int)) == -1) + &ttl, sizeof(ttl)) == -1) log_warn("%s: setsockopt", __func__); } else { @@ -243,10 +244,10 @@ send_icmp(int s, short event, void *arg) } break; case AF_INET6: - if ((ttl = host->conf.ttl) > 0) { + if (ttl > 0) { if (setsockopt(s, IPPROTO_IPV6, - IPV6_UNICAST_HOPS, &host->conf.ttl, - sizeof(int)) == -1) + IPV6_UNICAST_HOPS, &ttl, + sizeof(ttl)) == -1) log_warn("%s: setsockopt", __func__); } else { -- jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF DDCC 0DFA 74AE 1524 E7EE