summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjca <jca@openbsd.org>2016-07-01 18:37:15 +0000
committerjca <jca@openbsd.org>2016-07-01 18:37:15 +0000
commit502cfe9407e8bf16b8f49301f05c88d69c188714 (patch)
tree99df9866b851e62c2ace13e1d9f9c9ee7c24783c
parentAllow resetting the IP_TTL and IP_MINTTL sockopts (diff)
downloadwireguard-openbsd-502cfe9407e8bf16b8f49301f05c88d69c188714.tar.xz
wireguard-openbsd-502cfe9407e8bf16b8f49301f05c88d69c188714.zip
Make accepted sockets inherit IP_TTL from the listening socket.
This is consistent with the IPV6_UNICAST_HOPS behavior, and is the only way to allow applications to completely control the TTL of outgoing packets (else an application could temporariy send packets with the default TTL, until it sets again IP_TTL ; this is harmful eg for GTSM). ok bluhm@
-rw-r--r--sys/netinet/tcp_input.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c
index cb700eca3da..7807968b380 100644
--- a/sys/netinet/tcp_input.c
+++ b/sys/netinet/tcp_input.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tcp_input.c,v 1.323 2016/06/27 20:57:41 jca Exp $ */
+/* $OpenBSD: tcp_input.c,v 1.324 2016/07/01 18:37:15 jca Exp $ */
/* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */
/*
@@ -3702,8 +3702,11 @@ syn_cache_get(struct sockaddr *src, struct sockaddr *dst, struct tcphdr *th,
if (inp->inp_flags & INP_IPV6) {
inp->inp_ipv6.ip6_hlim = oldinp->inp_ipv6.ip6_hlim;
inp->inp_hops = oldinp->inp_hops;
- }
+ } else
#endif /* INET6 */
+ {
+ inp->inp_ip.ip_ttl = oldinp->inp_ip.ip_ttl;
+ }
#if NPF > 0
if (m && m->m_pkthdr.pf.flags & PF_TAG_DIVERTED &&