diff options
author | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2016-06-28 11:22:54 +0000 |
---|---|---|
committer | Jeremie Courreges-Anglas <jca@cvs.openbsd.org> | 2016-06-28 11:22:54 +0000 |
commit | 5515910e2880e33c3a6c5a404898ecda79590451 (patch) | |
tree | e631a427bdf30218b2cf0cbddd6f900f4809f7d8 | |
parent | 56d5f1d22c64b111190f7f95d138de48d50d4d37 (diff) |
Add UDP unicast and multicast support for IP_MINTTL/IPV6_MINHOPCOUNT
Requested by renato@, ok blumh@
-rw-r--r-- | sys/netinet/udp_usrreq.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index fb64c11dc4e..38c54fe434a 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.213 2016/06/18 10:36:13 vgross Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.214 2016/06/28 11:22:53 jca Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -425,15 +425,25 @@ udp_input(struct mbuf *m, ...) continue; #ifdef INET6 if (ip6) { + if (inp->inp_ip6_minhlim && + inp->inp_ip6_minhlim > ip6->ip6_hlim) + continue; if (!IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6)) if (!IN6_ARE_ADDR_EQUAL(&inp->inp_laddr6, &ip6->ip6_dst)) continue; } else #endif /* INET6 */ - if (inp->inp_laddr.s_addr != INADDR_ANY) { - if (inp->inp_laddr.s_addr != ip->ip_dst.s_addr) + { + if (inp->inp_ip_minttl && + inp->inp_ip_minttl > ip->ip_ttl) continue; + + if (inp->inp_laddr.s_addr != INADDR_ANY) { + if (inp->inp_laddr.s_addr != + ip->ip_dst.s_addr) + continue; + } } #ifdef INET6 if (ip6) { @@ -580,6 +590,17 @@ udp_input(struct mbuf *m, ...) } KASSERT(sotoinpcb(inp->inp_socket) == inp); +#ifdef INET6 + if (ip6 && inp->inp_ip6_minhlim && + inp->inp_ip6_minhlim > ip6->ip6_hlim) { + goto bad; + } else +#endif + if (ip && inp->inp_ip_minttl && + inp->inp_ip_minttl > ip->ip_ttl) { + goto bad; + } + #if NPF > 0 if (inp->inp_socket->so_state & SS_ISCONNECTED) pf_inp_link(m, inp); |