diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-10-24 16:08:49 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-10-24 16:08:49 +0000 |
commit | e0c077b4ae2af1033ae68483240bcafd270f6d43 (patch) | |
tree | c5e206311f93d050ccc52d43dd956c670f2c0f01 /sys | |
parent | ba6eab9902faa98bef56bd0329c5174b2be42a06 (diff) |
Ignore Router Advertisment's current hop limit.
Appart from the usual inet6 axe murdering exercise to keep you fit, this
allows us to get rid of a lot of layer violation due to the use of per-
ifp variables to store the current hop limit.
Imputs from bluhm@, ok phessler@, florian@, bluhm@
Diffstat (limited to 'sys')
-rw-r--r-- | sys/netinet/in_pcb.h | 4 | ||||
-rw-r--r-- | sys/netinet/tcp_input.c | 5 | ||||
-rw-r--r-- | sys/netinet/tcp_output.c | 4 | ||||
-rw-r--r-- | sys/netinet/tcp_subr.c | 6 | ||||
-rw-r--r-- | sys/netinet6/in6_pcb.c | 8 | ||||
-rw-r--r-- | sys/netinet6/in6_src.c | 10 | ||||
-rw-r--r-- | sys/netinet6/nd6.c | 3 | ||||
-rw-r--r-- | sys/netinet6/nd6.h | 3 | ||||
-rw-r--r-- | sys/netinet6/nd6_rtr.c | 10 | ||||
-rw-r--r-- | sys/netinet6/raw_ip6.c | 7 | ||||
-rw-r--r-- | sys/netinet6/udp6_output.c | 8 |
11 files changed, 28 insertions, 40 deletions
diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 8d351cf6802..9ac0f5bd0fe 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.h,v 1.90 2015/09/22 09:34:39 vgross Exp $ */ +/* $OpenBSD: in_pcb.h,v 1.91 2015/10/24 16:08:48 mpi Exp $ */ /* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */ /* @@ -287,7 +287,7 @@ struct rtentry * int in6_pcbnotify(struct inpcbtable *, struct sockaddr_in6 *, u_int, const struct sockaddr_in6 *, u_int, u_int, int, void *, void (*)(struct inpcb *, int)); -int in6_selecthlim(struct inpcb *, struct ifnet *); +int in6_selecthlim(struct inpcb *); int in6_pcbsetport(struct in6_addr *, struct inpcb *, struct proc *); #endif /* _KERNEL */ #endif /* _NETINET_IN_PCB_H_ */ diff --git a/sys/netinet/tcp_input.c b/sys/netinet/tcp_input.c index f7c98b7f756..a77cc639190 100644 --- a/sys/netinet/tcp_input.c +++ b/sys/netinet/tcp_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_input.c,v 1.305 2015/09/11 08:17:06 claudio Exp $ */ +/* $OpenBSD: tcp_input.c,v 1.306 2015/10/24 16:08:48 mpi Exp $ */ /* $NetBSD: tcp_input.c,v 1.23 1996/02/13 23:43:44 christos Exp $ */ /* @@ -4363,8 +4363,7 @@ syn_cache_respond(struct syn_cache *sc, struct mbuf *m) break; #ifdef INET6 case AF_INET6: - ip6->ip6_hlim = in6_selecthlim(NULL, - ro->ro_rt ? ro->ro_rt->rt_ifp : NULL); + ip6->ip6_hlim = in6_selecthlim(NULL); error = ip6_output(m, NULL /*XXX*/, (struct route_in6 *)ro, 0, NULL, NULL); diff --git a/sys/netinet/tcp_output.c b/sys/netinet/tcp_output.c index aa320da5cd9..7aa2690e21e 100644 --- a/sys/netinet/tcp_output.c +++ b/sys/netinet/tcp_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_output.c,v 1.114 2015/09/11 08:17:06 claudio Exp $ */ +/* $OpenBSD: tcp_output.c,v 1.115 2015/10/24 16:08:48 mpi Exp $ */ /* $NetBSD: tcp_output.c,v 1.16 1997/06/03 16:17:09 kml Exp $ */ /* @@ -1108,7 +1108,7 @@ send: sizeof(struct ip6_hdr); packetlen = m->m_pkthdr.len; ip6->ip6_nxt = IPPROTO_TCP; - ip6->ip6_hlim = in6_selecthlim(tp->t_inpcb, NULL); + ip6->ip6_hlim = in6_selecthlim(tp->t_inpcb); #ifdef TCP_ECN if (needect) ip6->ip6_flow |= htonl(IPTOS_ECN_ECT0 << 20); diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 52744c32012..e79fcd2df1c 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tcp_subr.c,v 1.149 2015/10/02 09:51:54 tedu Exp $ */ +/* $OpenBSD: tcp_subr.c,v 1.150 2015/10/24 16:08:48 mpi Exp $ */ /* $NetBSD: tcp_subr.c,v 1.22 1996/02/13 23:44:00 christos Exp $ */ /* @@ -254,7 +254,7 @@ tcp_template(tp) ip6->ip6_nxt = IPPROTO_TCP; ip6->ip6_plen = htons(sizeof(struct tcphdr)); /*XXX*/ - ip6->ip6_hlim = in6_selecthlim(inp, NULL); /*XXX*/ + ip6->ip6_hlim = in6_selecthlim(inp); /*XXX*/ th = (struct tcphdr *)(mtod(m, caddr_t) + sizeof(struct ip6_hdr)); @@ -400,7 +400,7 @@ tcp_respond(struct tcpcb *tp, caddr_t template, struct tcphdr *th0, case AF_INET6: ip6->ip6_flow = htonl(0x60000000); ip6->ip6_nxt = IPPROTO_TCP; - ip6->ip6_hlim = in6_selecthlim(tp ? tp->t_inpcb : NULL, NULL); /*XXX*/ + ip6->ip6_hlim = in6_selecthlim(tp ? tp->t_inpcb : NULL); /*XXX*/ ip6->ip6_plen = tlen - sizeof(struct ip6_hdr); ip6->ip6_plen = htons(ip6->ip6_plen); ip6_output(m, tp ? tp->t_inpcb->inp_outputopts6 : NULL, diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index 95ae08f8a90..4e5e1c72e22 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_pcb.c,v 1.81 2015/10/20 18:04:03 deraadt Exp $ */ +/* $OpenBSD: in6_pcb.c,v 1.82 2015/10/24 16:08:48 mpi Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -369,7 +369,6 @@ in6_pcbconnect(struct inpcb *inp, struct mbuf *nam) { struct in6_addr *in6a = NULL; struct sockaddr_in6 *sin6 = mtod(nam, struct sockaddr_in6 *); - struct ifnet *ifp = NULL; /* outgoing interface */ int error = 0; struct sockaddr_in6 tmp; @@ -412,10 +411,7 @@ in6_pcbconnect(struct inpcb *inp, struct mbuf *nam) if (error) return (error); - if (rtisvalid(inp->inp_route6.ro_rt)) - ifp = inp->inp_route6.ro_rt->rt_ifp; - - inp->inp_ipv6.ip6_hlim = (u_int8_t)in6_selecthlim(inp, ifp); + inp->inp_ipv6.ip6_hlim = (u_int8_t)in6_selecthlim(inp); if (in_pcblookup(inp->inp_table, &sin6->sin6_addr, sin6->sin6_port, IN6_IS_ADDR_UNSPECIFIED(&inp->inp_laddr6) ? in6a : &inp->inp_laddr6, diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c index dfe5791948f..045a4e38fb8 100644 --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_src.c,v 1.66 2015/10/24 12:33:16 mpi Exp $ */ +/* $OpenBSD: in6_src.c,v 1.67 2015/10/24 16:08:48 mpi Exp $ */ /* $KAME: in6_src.c,v 1.36 2001/02/06 04:08:17 itojun Exp $ */ /* @@ -470,14 +470,12 @@ in6_selectif(struct sockaddr_in6 *dstsock, struct ip6_pktopts *opts, * 3. The system default hoplimit. */ int -in6_selecthlim(struct inpcb *in6p, struct ifnet *ifp) +in6_selecthlim(struct inpcb *in6p) { if (in6p && in6p->inp_hops >= 0) return (in6p->inp_hops); - else if (ifp) - return (ND_IFINFO(ifp)->chlim); - else - return (ip6_defhlim); + + return (ip6_defhlim); } /* diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index 3cb55ede1f2..1d30d63a979 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.c,v 1.158 2015/10/22 16:44:54 mpi Exp $ */ +/* $OpenBSD: nd6.c,v 1.159 2015/10/24 16:08:48 mpi Exp $ */ /* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */ /* @@ -147,7 +147,6 @@ nd6_ifattach(struct ifnet *ifp) nd->initialized = 1; - nd->chlim = IPV6_DEFHLIM; nd->basereachable = REACHABLE_TIME; nd->reachable = ND_COMPUTE_RTIME(nd->basereachable); nd->retrans = RETRANS_TIMER; diff --git a/sys/netinet6/nd6.h b/sys/netinet6/nd6.h index f1b3098f590..162dec320a9 100644 --- a/sys/netinet6/nd6.h +++ b/sys/netinet6/nd6.h @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.h,v 1.49 2015/08/31 10:03:47 mpi Exp $ */ +/* $OpenBSD: nd6.h,v 1.50 2015/10/24 16:08:48 mpi Exp $ */ /* $KAME: nd6.h,v 1.95 2002/06/08 11:31:06 itojun Exp $ */ /* @@ -56,7 +56,6 @@ struct nd_ifinfo { u_int32_t retrans; /* Retrans Timer */ u_int32_t flags; /* Flags */ int recalctm; /* BaseReacable re-calculation timer */ - u_int8_t chlim; /* CurHopLimit */ u_int8_t initialized; /* Flag to see the entry is initialized */ /* the following 3 members are for privacy extension for addrconf */ u_int8_t randomseed0[8]; /* upper 64 bits of MD5 digest */ diff --git a/sys/netinet6/nd6_rtr.c b/sys/netinet6/nd6_rtr.c index 6e85e6c3893..025372d55a6 100644 --- a/sys/netinet6/nd6_rtr.c +++ b/sys/netinet6/nd6_rtr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6_rtr.c,v 1.126 2015/10/22 15:37:47 bluhm Exp $ */ +/* $OpenBSD: nd6_rtr.c,v 1.127 2015/10/24 16:08:48 mpi Exp $ */ /* $KAME: nd6_rtr.c,v 1.97 2001/02/07 11:09:13 itojun Exp $ */ /* @@ -435,8 +435,12 @@ nd6_ra_input(struct mbuf *m, int off, int icmp6len) } if (nd_ra->nd_ra_retransmit) ndi->retrans = ntohl(nd_ra->nd_ra_retransmit); - if (nd_ra->nd_ra_curhoplimit) - ndi->chlim = nd_ra->nd_ra_curhoplimit; + if (nd_ra->nd_ra_curhoplimit) { + /* + * Ignore it. The router doesn't know the diameter of + * the Internet better than this source code. + */ + } dr = defrtrlist_update(&dr0); } diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index 9727c64aa6e..75e52bc40b8 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip6.c,v 1.85 2015/10/19 12:11:28 mpi Exp $ */ +/* $OpenBSD: raw_ip6.c,v 1.86 2015/10/24 16:08:48 mpi Exp $ */ /* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */ /* @@ -344,7 +344,6 @@ rip6_output(struct mbuf *m, ...) u_int plen = m->m_pkthdr.len; int error = 0; struct ip6_pktopts opt, *optp = NULL, *origoptp; - struct ifnet *oifp = NULL; int type, code; /* for ICMPv6 output statistics only */ int priv = 0; va_list ap; @@ -421,8 +420,6 @@ rip6_output(struct mbuf *m, ...) goto bad; ip6->ip6_src = *in6a; - if (rtisvalid(in6p->inp_route6.ro_rt)) - oifp = in6p->inp_route6.ro_rt->rt_ifp; } ip6->ip6_flow = in6p->inp_flowinfo & IPV6_FLOWINFO_MASK; @@ -432,7 +429,7 @@ rip6_output(struct mbuf *m, ...) ip6->ip6_plen = htons((u_short)plen); #endif ip6->ip6_nxt = in6p->inp_ipv6.ip6_nxt; - ip6->ip6_hlim = in6_selecthlim(in6p, oifp); + ip6->ip6_hlim = in6_selecthlim(in6p); if (so->so_proto->pr_protocol == IPPROTO_ICMPV6 || in6p->inp_cksum6 != -1) { diff --git a/sys/netinet6/udp6_output.c b/sys/netinet6/udp6_output.c index 61144b81bfc..1d0b3f5b64b 100644 --- a/sys/netinet6/udp6_output.c +++ b/sys/netinet6/udp6_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp6_output.c,v 1.38 2015/10/19 12:11:28 mpi Exp $ */ +/* $OpenBSD: udp6_output.c,v 1.39 2015/10/24 16:08:48 mpi Exp $ */ /* $KAME: udp6_output.c,v 1.21 2001/02/07 11:51:54 itojun Exp $ */ /* @@ -105,7 +105,6 @@ udp6_output(struct inpcb *in6p, struct mbuf *m, struct mbuf *addr6, struct ip6_pktopts *optp, opt; struct sockaddr_in6 tmp; struct proc *p = curproc; /* XXX */ - struct ifnet *ifp; u_short fport; if ((in6p->inp_socket->so_state & SS_PRIV) != 0) @@ -207,10 +206,7 @@ udp6_output(struct inpcb *in6p, struct mbuf *m, struct mbuf *addr6, ip6->ip6_plen = htons((u_short)plen); #endif ip6->ip6_nxt = IPPROTO_UDP; - ifp = NULL; - if (rtisvalid(in6p->inp_route6.ro_rt)) - ifp = in6p->inp_route6.ro_rt->rt_ifp; - ip6->ip6_hlim = in6_selecthlim(in6p, ifp); + ip6->ip6_hlim = in6_selecthlim(in6p); ip6->ip6_src = *laddr; ip6->ip6_dst = *faddr; |