On 12/07/17 22:00, Jeremie Courreges-Anglas wrote:
The tweak I had in mind: consistently use "ttl" for all the
get/setsockopt calls.
ok?
nice,
you can also replace sizeof(int) to sizeof(ttl) on the else{} block of
case AF_INET6
G
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 {