summaryrefslogtreecommitdiff
path: root/usr.sbin/relayd
diff options
context:
space:
mode:
authorJeremie Courreges-Anglas <jca@cvs.openbsd.org>2016-11-10 13:21:59 +0000
committerJeremie Courreges-Anglas <jca@cvs.openbsd.org>2016-11-10 13:21:59 +0000
commitcc13987d08aa82c57e89ecba96d622e9efdc4992 (patch)
treef9929a94843ca421599e7b8f17f53912b1949878 /usr.sbin/relayd
parentc255f5e09a07a3aa4fcca3dff9e80f7d6e8cd380 (diff)
Fix tcp ip ttl / minttl on IPv6 sockets.
ok florian@
Diffstat (limited to 'usr.sbin/relayd')
-rw-r--r--usr.sbin/relayd/relay.c32
-rw-r--r--usr.sbin/relayd/relay_udp.c32
2 files changed, 50 insertions, 14 deletions
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);