diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-07-22 11:14:42 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2016-07-22 11:14:42 +0000 |
commit | b2e0866d3715193b0c977023837a02259a3a8086 (patch) | |
tree | 8b114e0d56cd57d96e97a4032b734a43f9b5f7e4 | |
parent | 29f635e12de98be359f90d690acfc1b708999d72 (diff) |
Revert in_selectsrc() refactoring, it breaks IPv6.
Reported by Heiko on bugs@.
ok stsp@, claudio@
-rw-r--r-- | sys/netinet/in_pcb.c | 15 | ||||
-rw-r--r-- | sys/netinet/in_pcb.h | 5 | ||||
-rw-r--r-- | sys/netinet/udp_usrreq.c | 5 | ||||
-rw-r--r-- | sys/netinet6/icmp6.c | 4 | ||||
-rw-r--r-- | sys/netinet6/in6_pcb.c | 6 | ||||
-rw-r--r-- | sys/netinet6/in6_src.c | 34 | ||||
-rw-r--r-- | sys/netinet6/ip6_var.h | 7 | ||||
-rw-r--r-- | sys/netinet6/nd6_nbr.c | 8 | ||||
-rw-r--r-- | sys/netinet6/raw_ip6.c | 10 | ||||
-rw-r--r-- | sys/netinet6/udp6_output.c | 6 |
10 files changed, 43 insertions, 57 deletions
diff --git a/sys/netinet/in_pcb.c b/sys/netinet/in_pcb.c index d25c04d2293..ecdd24f21bf 100644 --- a/sys/netinet/in_pcb.c +++ b/sys/netinet/in_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.c,v 1.211 2016/07/20 18:51:50 vgross Exp $ */ +/* $OpenBSD: in_pcb.c,v 1.212 2016/07/22 11:14:41 mpi Exp $ */ /* $NetBSD: in_pcb.c,v 1.25 1996/02/13 23:41:53 christos Exp $ */ /* @@ -525,7 +525,8 @@ in_pcbconnect(struct inpcb *inp, struct mbuf *nam) if (sin->sin_port == 0) return (EADDRNOTAVAIL); - error = in_pcbselsrc(&ina, sin, inp); + error = in_selectsrc(&ina, sin, inp->inp_moptions, &inp->inp_route, + &inp->inp_laddr, inp->inp_rtableid); if (error) return (error); @@ -875,14 +876,10 @@ in_pcbrtentry(struct inpcb *inp) * an entry to the caller for later use. */ int -in_pcbselsrc(struct in_addr **insrc, struct sockaddr_in *sin, - struct inpcb *inp) +in_selectsrc(struct in_addr **insrc, struct sockaddr_in *sin, + struct ip_moptions *mopts, struct route *ro, struct in_addr *laddr, + u_int rtableid) { - struct ip_moptions *mopts = inp->inp_moptions; - struct route *ro = &inp->inp_route; - struct in_addr *laddr = &inp->inp_laddr; - u_int rtableid = inp->inp_rtableid; - struct sockaddr_in *sin2; struct in_ifaddr *ia = NULL; diff --git a/sys/netinet/in_pcb.h b/sys/netinet/in_pcb.h index 0a67d11746d..756cb6f159a 100644 --- a/sys/netinet/in_pcb.h +++ b/sys/netinet/in_pcb.h @@ -1,4 +1,4 @@ -/* $OpenBSD: in_pcb.h,v 1.101 2016/07/20 18:51:50 vgross Exp $ */ +/* $OpenBSD: in_pcb.h,v 1.102 2016/07/22 11:14:41 mpi Exp $ */ /* $NetBSD: in_pcb.h,v 1.14 1996/02/13 23:42:00 christos Exp $ */ /* @@ -289,7 +289,8 @@ void in_setpeeraddr(struct inpcb *, struct mbuf *); void in_setsockaddr(struct inpcb *, struct mbuf *); int in_baddynamic(u_int16_t, u_int16_t); int in_rootonly(u_int16_t, u_int16_t); -int in_pcbselsrc(struct in_addr **, struct sockaddr_in *, struct inpcb *); +int in_selectsrc(struct in_addr **, struct sockaddr_in *, + struct ip_moptions *, struct route *, struct in_addr *, u_int); struct rtentry * in_pcbrtentry(struct inpcb *); diff --git a/sys/netinet/udp_usrreq.c b/sys/netinet/udp_usrreq.c index f8cd2c950f2..c8559de7a88 100644 --- a/sys/netinet/udp_usrreq.c +++ b/sys/netinet/udp_usrreq.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp_usrreq.c,v 1.215 2016/07/20 18:51:50 vgross Exp $ */ +/* $OpenBSD: udp_usrreq.c,v 1.216 2016/07/22 11:14:41 mpi Exp $ */ /* $NetBSD: udp_usrreq.c,v 1.28 1996/03/16 23:54:03 christos Exp $ */ /* @@ -989,7 +989,8 @@ udp_output(struct inpcb *inp, struct mbuf *m, struct mbuf *addr, goto release; } - error = in_pcbselsrc(&laddr, sin, inp); + error = in_selectsrc(&laddr, sin, inp->inp_moptions, + &inp->inp_route, &inp->inp_laddr, inp->inp_rtableid); if (error) goto release; diff --git a/sys/netinet6/icmp6.c b/sys/netinet6/icmp6.c index 1bfd67f5ada..22731d2337f 100644 --- a/sys/netinet6/icmp6.c +++ b/sys/netinet6/icmp6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: icmp6.c,v 1.187 2016/07/20 18:51:50 vgross Exp $ */ +/* $OpenBSD: icmp6.c,v 1.188 2016/07/22 11:14:41 mpi Exp $ */ /* $KAME: icmp6.c,v 1.217 2001/06/20 15:03:29 jinmei Exp $ */ /* @@ -1259,7 +1259,7 @@ icmp6_reflect(struct mbuf *m, size_t off) * source address of the erroneous packet. */ bzero(&ro, sizeof(ro)); - error = in6_selectsrc(&src, &sa6_src, NULL, &ro, + error = in6_selectsrc(&src, &sa6_src, NULL, NULL, &ro, NULL, m->m_pkthdr.ph_rtableid); if (ro.ro_rt) rtfree(ro.ro_rt); /* XXX: we could use this */ diff --git a/sys/netinet6/in6_pcb.c b/sys/netinet6/in6_pcb.c index c6bdb0b988b..2eb66c9483e 100644 --- a/sys/netinet6/in6_pcb.c +++ b/sys/netinet6/in6_pcb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_pcb.c,v 1.94 2016/07/20 18:51:50 vgross Exp $ */ +/* $OpenBSD: in6_pcb.c,v 1.95 2016/07/22 11:14:41 mpi Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. @@ -281,7 +281,9 @@ in6_pcbconnect(struct inpcb *inp, struct mbuf *nam) * with the address specified by setsockopt(IPV6_PKTINFO). * Is it the intended behavior? */ - error = in6_pcbselsrc(&in6a, sin6, inp, inp->inp_outputopts6); + error = in6_selectsrc(&in6a, sin6, inp->inp_outputopts6, + inp->inp_moptions6, &inp->inp_route6, &inp->inp_laddr6, + inp->inp_rtableid); if (error) return (error); diff --git a/sys/netinet6/in6_src.c b/sys/netinet6/in6_src.c index 26d7df7c5c7..864724109da 100644 --- a/sys/netinet6/in6_src.c +++ b/sys/netinet6/in6_src.c @@ -1,4 +1,4 @@ -/* $OpenBSD: in6_src.c,v 1.77 2016/07/20 18:51:50 vgross Exp $ */ +/* $OpenBSD: in6_src.c,v 1.78 2016/07/22 11:14:41 mpi Exp $ */ /* $KAME: in6_src.c,v 1.36 2001/02/06 04:08:17 itojun Exp $ */ /* @@ -88,18 +88,15 @@ int in6_selectif(struct sockaddr_in6 *, struct ip6_pktopts *, /* * Return an IPv6 address, which is the most appropriate for a given - * destination and pcb. We need the additional opt parameter because - * the values set at pcb level can be overriden via cmsg. + * destination and user specified options. + * If necessary, this function lookups the routing table and returns + * an entry to the caller for later use. */ int -in6_pcbselsrc(struct in6_addr **in6src, struct sockaddr_in6 *dstsock, - struct inpcb *inp, struct ip6_pktopts *opts) +in6_selectsrc(struct in6_addr **in6src, struct sockaddr_in6 *dstsock, + struct ip6_pktopts *opts, struct ip6_moptions *mopts, + struct route_in6 *ro, struct in6_addr *laddr, u_int rtableid) { - struct ip6_moptions *mopts = inp->inp_moptions6; - struct route_in6 *ro = &inp->inp_route6; - struct in6_addr *laddr = &inp->inp_laddr6; - u_int rtableid = inp->inp_rtableid; - struct ifnet *ifp = NULL; struct in6_addr *dst; struct in6_ifaddr *ia6 = NULL; @@ -172,23 +169,6 @@ in6_pcbselsrc(struct in6_addr **in6src, struct sockaddr_in6 *dstsock, return (0); } - return in6_selectsrc(in6src, dstsock, mopts, ro, rtableid); -} - -/* - * Return an IPv6 address, which is the most appropriate for a given - * destination and multicast options. - * If necessary, this function lookups the routing table and returns - * an entry to the caller for later use. - */ -int -in6_selectsrc(struct in6_addr **in6src, struct sockaddr_in6 *dstsock, - struct ip6_moptions *mopts, struct route_in6 *ro, u_int rtableid) -{ - struct ifnet *ifp = NULL; - struct in6_addr *dst; - struct in6_ifaddr *ia6 = NULL; - /* * If the destination address is a link-local unicast address or * a link/interface-local multicast address, and if the outgoing diff --git a/sys/netinet6/ip6_var.h b/sys/netinet6/ip6_var.h index 064221e6275..119ca5457af 100644 --- a/sys/netinet6/ip6_var.h +++ b/sys/netinet6/ip6_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_var.h,v 1.61 2016/07/20 18:51:50 vgross Exp $ */ +/* $OpenBSD: ip6_var.h,v 1.62 2016/07/22 11:14:41 mpi Exp $ */ /* $KAME: ip6_var.h,v 1.33 2000/06/11 14:59:20 jinmei Exp $ */ /* @@ -294,10 +294,9 @@ int rip6_sysctl(int *, u_int, void *, size_t *, void *, size_t); int dest6_input(struct mbuf **, int *, int); int none_input(struct mbuf **, int *, int); -int in6_pcbselsrc(struct in6_addr **, struct sockaddr_in6 *, - struct inpcb *, struct ip6_pktopts *); int in6_selectsrc(struct in6_addr **, struct sockaddr_in6 *, - struct ip6_moptions *, struct route_in6 *, u_int); + struct ip6_pktopts *, struct ip6_moptions *, struct route_in6 *, + struct in6_addr *, u_int); struct rtentry *in6_selectroute(struct sockaddr_in6 *, struct ip6_pktopts *, struct route_in6 *, unsigned int rtableid); diff --git a/sys/netinet6/nd6_nbr.c b/sys/netinet6/nd6_nbr.c index f701aa4b514..0a8ea1a07ea 100644 --- a/sys/netinet6/nd6_nbr.c +++ b/sys/netinet6/nd6_nbr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6_nbr.c,v 1.106 2016/07/20 18:51:50 vgross Exp $ */ +/* $OpenBSD: nd6_nbr.c,v 1.107 2016/07/22 11:14:41 mpi Exp $ */ /* $KAME: nd6_nbr.c,v 1.61 2001/02/10 16:06:14 jinmei Exp $ */ /* @@ -471,8 +471,8 @@ nd6_ns_output(struct ifnet *ifp, struct in6_addr *daddr6, int error; bcopy(&dst_sa, &ro.ro_dst, sizeof(dst_sa)); - error = in6_selectsrc(&src0, &dst_sa, NULL, &ro, - m->m_pkthdr.ph_rtableid); + error = in6_selectsrc(&src0, &dst_sa, NULL, NULL, &ro, + NULL, m->m_pkthdr.ph_rtableid); if (error) { char addr[INET6_ADDRSTRLEN]; @@ -990,7 +990,7 @@ nd6_na_output(struct ifnet *ifp, struct in6_addr *daddr6, * Select a source whose scope is the same as that of the dest. */ bcopy(&dst_sa, &ro.ro_dst, sizeof(dst_sa)); - error = in6_selectsrc(&src0, &dst_sa, NULL, &ro, + error = in6_selectsrc(&src0, &dst_sa, NULL, NULL, &ro, NULL, m->m_pkthdr.ph_rtableid); if (error) { char addr[INET6_ADDRSTRLEN]; diff --git a/sys/netinet6/raw_ip6.c b/sys/netinet6/raw_ip6.c index da8cd22922a..ee18013fc4b 100644 --- a/sys/netinet6/raw_ip6.c +++ b/sys/netinet6/raw_ip6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: raw_ip6.c,v 1.92 2016/07/20 18:51:50 vgross Exp $ */ +/* $OpenBSD: raw_ip6.c,v 1.93 2016/07/22 11:14:41 mpi Exp $ */ /* $KAME: raw_ip6.c,v 1.69 2001/03/04 15:55:44 itojun Exp $ */ /* @@ -396,7 +396,9 @@ rip6_output(struct mbuf *m, ...) { struct in6_addr *in6a; - error = in6_pcbselsrc(&in6a, dstsock, in6p, optp); + error = in6_selectsrc(&in6a, dstsock, optp, + in6p->inp_moptions6, &in6p->inp_route6, &in6p->inp_laddr6, + in6p->inp_rtableid); if (error) goto bad; @@ -698,7 +700,9 @@ rip6_usrreq(struct socket *so, int req, struct mbuf *m, struct mbuf *nam, } /* Source address selection. XXX: need pcblookup? */ - error = in6_pcbselsrc(&in6a, addr, in6p, in6p->inp_outputopts6); + error = in6_selectsrc(&in6a, addr, in6p->inp_outputopts6, + in6p->inp_moptions6, &in6p->inp_route6, + &in6p->inp_laddr6, in6p->inp_rtableid); if (error) break; in6p->inp_laddr6 = *in6a; diff --git a/sys/netinet6/udp6_output.c b/sys/netinet6/udp6_output.c index 61f3b3a4833..2764a977ee5 100644 --- a/sys/netinet6/udp6_output.c +++ b/sys/netinet6/udp6_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: udp6_output.c,v 1.49 2016/07/20 18:51:50 vgross Exp $ */ +/* $OpenBSD: udp6_output.c,v 1.50 2016/07/22 11:14:41 mpi Exp $ */ /* $KAME: udp6_output.c,v 1.21 2001/02/07 11:51:54 itojun Exp $ */ /* @@ -154,7 +154,9 @@ udp6_output(struct inpcb *in6p, struct mbuf *m, struct mbuf *addr6, goto release; } - error = in6_pcbselsrc(&laddr, sin6, in6p, optp); + error = in6_selectsrc(&laddr, sin6, optp, + in6p->inp_moptions6, &in6p->inp_route6, + &in6p->inp_laddr6, in6p->inp_rtableid); if (error) goto release; |