summaryrefslogtreecommitdiffstats
path: root/usr.sbin/httpd/server.c
diff options
context:
space:
mode:
authorjca <jca@openbsd.org>2016-11-10 13:21:58 +0000
committerjca <jca@openbsd.org>2016-11-10 13:21:58 +0000
commit829b7945696f500b830cba7bead14f3cf0a75b36 (patch)
tree67ab13ba70a83b737ec21d6f6d2817dcfd6ac2b5 /usr.sbin/httpd/server.c
parentTypo in the guard (diff)
downloadwireguard-openbsd-829b7945696f500b830cba7bead14f3cf0a75b36.tar.xz
wireguard-openbsd-829b7945696f500b830cba7bead14f3cf0a75b36.zip
Fix tcp ip ttl / minttl on IPv6 sockets.
ok florian@
Diffstat (limited to 'usr.sbin/httpd/server.c')
-rw-r--r--usr.sbin/httpd/server.c32
1 files changed, 25 insertions, 7 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;
+ }
}
/*