diff options
-rw-r--r-- | usr.sbin/httpd/server.c | 32 | ||||
-rw-r--r-- | usr.sbin/relayd/relay.c | 32 | ||||
-rw-r--r-- | usr.sbin/relayd/relay_udp.c | 32 |
3 files changed, 75 insertions, 21 deletions
diff --git a/usr.sbin/httpd/server.c b/usr.sbin/httpd/server.c index 81fc8c0dd1f..64af4933725 100644 --- a/usr.sbin/httpd/server.c +++ b/usr.sbin/httpd/server.c @@ -1,4 +1,4 @@ -/* $OpenBSD: server.c,v 1.97 2016/11/06 16:05:02 beck Exp $ */ +/* $OpenBSD: server.c,v 1.98 2016/11/10 13:21:58 jca Exp $ */ /* * Copyright (c) 2006 - 2015 Reyk Floeter <reyk@openbsd.org> @@ -569,15 +569,33 @@ server_socket(struct sockaddr_storage *ss, in_port_t port, */ if (srv_conf->tcpflags & TCPFLAG_IPTTL) { val = (int)srv_conf->tcpipttl; - if (setsockopt(s, IPPROTO_IP, IP_TTL, - &val, sizeof(val)) == -1) - goto bad; + switch (ss->ss_family) { + case AF_INET: + if (setsockopt(s, IPPROTO_IP, IP_TTL, + &val, sizeof(val)) == -1) + goto bad; + break; + case AF_INET6: + if (setsockopt(s, IPPROTO_IPV6, IPV6_UNICAST_HOPS, + &val, sizeof(val)) == -1) + goto bad; + break; + } } if (srv_conf->tcpflags & TCPFLAG_IPMINTTL) { val = (int)srv_conf->tcpipminttl; - if (setsockopt(s, IPPROTO_IP, IP_MINTTL, - &val, sizeof(val)) == -1) - goto bad; + switch (ss->ss_family) { + case AF_INET: + if (setsockopt(s, IPPROTO_IP, IP_MINTTL, + &val, sizeof(val)) == -1) + goto bad; + break; + case AF_INET6: + if (setsockopt(s, IPPROTO_IPV6, IPV6_MINHOPCOUNT, + &val, sizeof(val)) == -1) + goto bad; + break; + } } /* diff --git a/usr.sbin/relayd/relay.c b/usr.sbin/relayd/relay.c index 54ad2ff1310..e0a0a87483c 100644 --- a/usr.sbin/relayd/relay.c +++ b/usr.sbin/relayd/relay.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay.c,v 1.216 2016/09/29 22:04:28 benno Exp $ */ +/* $OpenBSD: relay.c,v 1.217 2016/11/10 13:21:58 jca Exp $ */ /* * Copyright (c) 2006 - 2014 Reyk Floeter <reyk@openbsd.org> @@ -562,15 +562,33 @@ relay_socket(struct sockaddr_storage *ss, in_port_t port, */ if (proto->tcpflags & TCPFLAG_IPTTL) { val = (int)proto->tcpipttl; - if (setsockopt(s, IPPROTO_IP, IP_TTL, - &val, sizeof(val)) == -1) - goto bad; + switch (ss->ss_family) { + case AF_INET: + if (setsockopt(s, IPPROTO_IP, IP_TTL, + &val, sizeof(val)) == -1) + goto bad; + break; + case AF_INET6: + if (setsockopt(s, IPPROTO_IPV6, IPV6_UNICAST_HOPS, + &val, sizeof(val)) == -1) + goto bad; + break; + } } if (proto->tcpflags & TCPFLAG_IPMINTTL) { val = (int)proto->tcpipminttl; - if (setsockopt(s, IPPROTO_IP, IP_MINTTL, - &val, sizeof(val)) == -1) - goto bad; + switch (ss->ss_family) { + case AF_INET: + if (setsockopt(s, IPPROTO_IP, IP_MINTTL, + &val, sizeof(val)) == -1) + goto bad; + break; + case AF_INET6: + if (setsockopt(s, IPPROTO_IPV6, IPV6_MINHOPCOUNT, + &val, sizeof(val)) == -1) + goto bad; + break; + } } /* diff --git a/usr.sbin/relayd/relay_udp.c b/usr.sbin/relayd/relay_udp.c index 9d4a4e159d4..754bdf9f564 100644 --- a/usr.sbin/relayd/relay_udp.c +++ b/usr.sbin/relayd/relay_udp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: relay_udp.c,v 1.43 2016/09/02 14:31:47 reyk Exp $ */ +/* $OpenBSD: relay_udp.c,v 1.44 2016/11/10 13:21:58 jca Exp $ */ /* * Copyright (c) 2007 - 2013 Reyk Floeter <reyk@openbsd.org> @@ -138,15 +138,33 @@ relay_udp_socket(struct sockaddr_storage *ss, in_port_t port, */ if (proto->tcpflags & TCPFLAG_IPTTL) { val = (int)proto->tcpipttl; - if (setsockopt(s, IPPROTO_IP, IP_TTL, - &val, sizeof(val)) == -1) - goto bad; + switch (ss->ss_family) { + case AF_INET: + if (setsockopt(s, IPPROTO_IP, IP_TTL, + &val, sizeof(val)) == -1) + goto bad; + break; + case AF_INET6: + if (setsockopt(s, IPPROTO_IPV6, IPV6_UNICAST_HOPS, + &val, sizeof(val)) == -1) + goto bad; + break; + } } if (proto->tcpflags & TCPFLAG_IPMINTTL) { val = (int)proto->tcpipminttl; - if (setsockopt(s, IPPROTO_IP, IP_MINTTL, - &val, sizeof(val)) == -1) - goto bad; + switch (ss->ss_family) { + case AF_INET: + if (setsockopt(s, IPPROTO_IP, IP_MINTTL, + &val, sizeof(val)) == -1) + goto bad; + break; + case AF_INET6: + if (setsockopt(s, IPPROTO_IPV6, IPV6_MINHOPCOUNT, + &val, sizeof(val)) == -1) + goto bad; + break; + } } return (s); |