diff options
author | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-09-12 20:26:08 +0000 |
---|---|---|
committer | Martin Pieuchot <mpi@cvs.openbsd.org> | 2015-09-12 20:26:08 +0000 |
commit | 62488894e357cef741a48eeff848f58431ce07ed (patch) | |
tree | f70491c5141d8697d0b27819c26bbca957b26bf1 | |
parent | d4533dcdd79582de2b7d8682334227be2c589776 (diff) |
Stop overwriting the rt_ifp pointer of RTF_LOCAL routes with lo0ifp.
Use instead the RTF_LOCAL flag to loop local traffic back to the
corresponding protocol queue.
With this change rt_ifp is now always the same as rt_ifa->ifa_ifp.
ok claudio@
-rw-r--r-- | sys/net/bpf.c | 4 | ||||
-rw-r--r-- | sys/net/if.c | 13 | ||||
-rw-r--r-- | sys/net/if_pppoe.c | 6 | ||||
-rw-r--r-- | sys/net/if_var.h | 4 | ||||
-rw-r--r-- | sys/net/pf.c | 7 | ||||
-rw-r--r-- | sys/net/pipex.c | 5 | ||||
-rw-r--r-- | sys/net/ppp_tty.c | 4 | ||||
-rw-r--r-- | sys/netinet/if_ether.c | 17 | ||||
-rw-r--r-- | sys/netinet/ip_output.c | 11 | ||||
-rw-r--r-- | sys/netinet6/ip6_mroute.c | 3 | ||||
-rw-r--r-- | sys/netinet6/ip6_output.c | 6 | ||||
-rw-r--r-- | sys/netinet6/nd6.c | 11 | ||||
-rw-r--r-- | sys/netmpls/mpls_input.c | 4 | ||||
-rw-r--r-- | sys/netmpls/mpls_output.c | 4 |
14 files changed, 44 insertions, 55 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 0af1d15b9e3..a541aaa87ef 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.125 2015/09/11 08:59:48 mpi Exp $ */ +/* $OpenBSD: bpf.c,v 1.126 2015/09/12 20:26:06 mpi Exp $ */ /* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* @@ -556,7 +556,7 @@ bpfwrite(dev_t dev, struct uio *uio, int ioflag) dst.ss_family = pseudo_AF_HDRCMPLT; s = splsoftnet(); - error = (*ifp->if_output)(ifp, m, (struct sockaddr *)&dst, NULL); + error = if_output(ifp, m, (struct sockaddr *)&dst, NULL); splx(s); /* * The driver frees the mbuf. diff --git a/sys/net/if.c b/sys/net/if.c index 31f2145db46..5cf7b55d862 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.375 2015/09/12 19:36:37 dlg Exp $ */ +/* $OpenBSD: if.c,v 1.376 2015/09/12 20:26:06 mpi Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -682,6 +682,16 @@ if_input_local(struct ifnet *ifp, struct mbuf *m, sa_family_t af) return (0); } +int +if_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, + struct rtentry *rt) +{ + if (rt != NULL && ISSET(rt->rt_flags, RTF_LOCAL)) + return (if_input_local(lo0ifp, m, dst->sa_family)); + + return (ifp->if_output(ifp, m, dst, rt)); +} + struct ifih { struct srpl_entry ifih_next; int (*ifih_input)(struct ifnet *, struct mbuf *, @@ -1345,7 +1355,6 @@ p2p_rtrequest(int req, struct rtentry *rt) if (lo0ifa == NULL) break; - rt->rt_ifp = lo0ifp; rt->rt_flags &= ~RTF_LLINFO; /* diff --git a/sys/net/if_pppoe.c b/sys/net/if_pppoe.c index ed492b0e80e..718b2630dfc 100644 --- a/sys/net/if_pppoe.c +++ b/sys/net/if_pppoe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pppoe.c,v 1.46 2015/06/16 11:09:39 mpi Exp $ */ +/* $OpenBSD: if_pppoe.c,v 1.47 2015/09/12 20:26:06 mpi Exp $ */ /* $NetBSD: if_pppoe.c,v 1.51 2003/11/28 08:56:48 keihan Exp $ */ /* @@ -883,7 +883,7 @@ pppoe_output(struct pppoe_softc *sc, struct mbuf *m) m->m_pkthdr.ph_rtableid = sc->sc_eth_if->if_rdomain; sc->sc_sppp.pp_if.if_opackets++; - return (sc->sc_eth_if->if_output(sc->sc_eth_if, m, &dst, NULL)); + return if_output(sc->sc_eth_if, m, &dst, NULL); } /* The ioctl routine. */ @@ -1383,7 +1383,7 @@ pppoe_send_padt(struct ifnet *outgoing_if, u_int session, const u_int8_t *dest) /* encapsulated packet is forced into rdomain of physical interface */ m0->m_pkthdr.ph_rtableid = outgoing_if->if_rdomain; - return (outgoing_if->if_output(outgoing_if, m0, &dst, NULL)); + return if_output(outgoing_if, m0, &dst, NULL); } #ifdef PPPOE_SERVER diff --git a/sys/net/if_var.h b/sys/net/if_var.h index 3b4d545b42e..4c326496f19 100644 --- a/sys/net/if_var.h +++ b/sys/net/if_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_var.h,v 1.40 2015/09/12 13:34:12 mpi Exp $ */ +/* $OpenBSD: if_var.h,v 1.41 2015/09/12 20:26:06 mpi Exp $ */ /* $NetBSD: if.h,v 1.23 1996/05/07 02:40:27 thorpej Exp $ */ /* @@ -406,6 +406,8 @@ void if_start(struct ifnet *); int if_enqueue(struct ifnet *, struct mbuf *); void if_input(struct ifnet *, struct mbuf_list *); int if_input_local(struct ifnet *, struct mbuf *, sa_family_t); +int if_output(struct ifnet *, struct mbuf *, struct sockaddr *, + struct rtentry *); void ether_ifattach(struct ifnet *); void ether_ifdetach(struct ifnet *); diff --git a/sys/net/pf.c b/sys/net/pf.c index 4bfece73ca5..b44193ccdf4 100644 --- a/sys/net/pf.c +++ b/sys/net/pf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf.c,v 1.942 2015/09/12 16:32:27 bluhm Exp $ */ +/* $OpenBSD: pf.c,v 1.943 2015/09/12 20:26:06 mpi Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -5575,7 +5575,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp, ipstat.ips_outswcsum++; ip->ip_sum = in_cksum(m0, ip->ip_hl << 2); } - error = (*ifp->if_output)(ifp, m0, sintosa(dst), NULL); + error = if_output(ifp, m0, sintosa(dst), NULL); goto done; } @@ -5604,8 +5604,7 @@ pf_route(struct mbuf **m, struct pf_rule *r, int dir, struct ifnet *oifp, m1 = m0->m_nextpkt; m0->m_nextpkt = 0; if (error == 0) - error = (*ifp->if_output)(ifp, m0, sintosa(dst), - NULL); + error = if_output(ifp, m0, sintosa(dst), NULL); else m_freem(m0); } diff --git a/sys/net/pipex.c b/sys/net/pipex.c index e700f9bc5eb..7cab82bb64e 100644 --- a/sys/net/pipex.c +++ b/sys/net/pipex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pipex.c,v 1.78 2015/09/11 08:17:06 claudio Exp $ */ +/* $OpenBSD: pipex.c,v 1.79 2015/09/12 20:26:07 mpi Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -1431,8 +1431,7 @@ pipex_pppoe_output(struct mbuf *m0, struct pipex_session *session) session->stat.opackets++; session->stat.obytes += len; - over_ifp->if_output(over_ifp, m0, (struct sockaddr *)&session->peer, - NULL); + if_output(over_ifp, m0, (struct sockaddr *)&session->peer, NULL); } #endif /* PIPEX_PPPOE */ diff --git a/sys/net/ppp_tty.c b/sys/net/ppp_tty.c index 3d7d70cbb8a..c44b8c3f818 100644 --- a/sys/net/ppp_tty.c +++ b/sys/net/ppp_tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ppp_tty.c,v 1.36 2015/07/15 22:16:42 deraadt Exp $ */ +/* $OpenBSD: ppp_tty.c,v 1.37 2015/09/12 20:26:07 mpi Exp $ */ /* $NetBSD: ppp_tty.c,v 1.12 1997/03/24 21:23:10 christos Exp $ */ /* @@ -381,7 +381,7 @@ pppwrite(struct tty *tp, struct uio *uio, int flag) bcopy(mtod(m0, u_char *), dst.sa_data, PPP_HDRLEN); m0->m_data += PPP_HDRLEN; m0->m_len -= PPP_HDRLEN; - return ((*sc->sc_if.if_output)(&sc->sc_if, m0, &dst, (struct rtentry *)0)); + return if_output(&sc->sc_if, m0, &dst, NULL); } /* diff --git a/sys/netinet/if_ether.c b/sys/netinet/if_ether.c index 38ba38b7554..5ef7b373cf9 100644 --- a/sys/netinet/if_ether.c +++ b/sys/netinet/if_ether.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ether.c,v 1.165 2015/09/10 13:21:41 dlg Exp $ */ +/* $OpenBSD: if_ether.c,v 1.166 2015/09/12 20:26:07 mpi Exp $ */ /* $NetBSD: if_ether.c,v 1.31 1996/05/11 12:59:58 mycroft Exp $ */ /* @@ -242,13 +242,6 @@ arp_rtrequest(int req, struct rtentry *rt) if (ifa) { rt->rt_expire = 0; /* - * XXX Since lo0 is in the default rdomain we - * should not (ab)use it for any route related - * to an interface of a different rdomain. - */ - rt->rt_ifp = lo0ifp; - - /* * make sure to set rt->rt_ifa to the interface * address we are using, otherwise we will have trouble * with source address selection. @@ -313,7 +306,7 @@ arprequest(struct ifnet *ifp, u_int32_t *sip, u_int32_t *tip, u_int8_t *enaddr) sa.sa_family = pseudo_AF_HDRCMPLT; sa.sa_len = sizeof(sa); m->m_flags |= M_BCAST; - (*ifp->if_output)(ifp, m, &sa, (struct rtentry *)0); + if_output(ifp, m, &sa, NULL); } /* @@ -710,7 +703,7 @@ in_arpinput(struct mbuf *m) mh = ml_dequeue(&la->la_ml); la_hold_total--; - (*ifp->if_output)(ifp, mh, rt_key(rt), rt); + if_output(ifp, mh, rt_key(rt), rt); if (ml_len(&la->la_ml) == len) { /* mbuf is back in queue. Discard. */ @@ -760,7 +753,7 @@ out: eh->ether_type = htons(ETHERTYPE_ARP); sa.sa_family = pseudo_AF_HDRCMPLT; sa.sa_len = sizeof(sa); - (*ifp->if_output)(ifp, m, &sa, NULL); + if_output(ifp, m, &sa, NULL); if_put(ifp); return; } @@ -975,7 +968,7 @@ revarprequest(struct ifnet *ifp) sa.sa_family = pseudo_AF_HDRCMPLT; sa.sa_len = sizeof(sa); m->m_flags |= M_BCAST; - ifp->if_output(ifp, m, &sa, (struct rtentry *)0); + if_output(ifp, m, &sa, NULL); } #ifdef NFSCLIENT diff --git a/sys/netinet/ip_output.c b/sys/netinet/ip_output.c index d33392c4d8e..805c3776eb6 100644 --- a/sys/netinet/ip_output.c +++ b/sys/netinet/ip_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip_output.c,v 1.295 2015/09/12 13:34:12 mpi Exp $ */ +/* $OpenBSD: ip_output.c,v 1.296 2015/09/12 20:26:07 mpi Exp $ */ /* $NetBSD: ip_output.c,v 1.28 1996/02/13 23:43:07 christos Exp $ */ /* @@ -566,7 +566,7 @@ sendit: ip->ip_sum = in_cksum(m, hlen); } - error = (*ifp->if_output)(ifp, m, sintosa(dst), ro->ro_rt); + error = if_output(ifp, m, sintosa(dst), ro->ro_rt); goto done; } @@ -606,8 +606,7 @@ sendit: m0 = m->m_nextpkt; m->m_nextpkt = 0; if (error == 0) - error = (*ifp->if_output)(ifp, m, sintosa(dst), - ro->ro_rt); + error = if_output(ifp, m, sintosa(dst), ro->ro_rt); else m_freem(m); } @@ -1660,9 +1659,7 @@ ip_freemoptions(struct ip_moptions *imo) /* * Routine called from ip_output() to loop back a copy of an IP multicast - * packet to the input queue of a specified interface. Note that this - * calls the output routine of the loopback "driver", but with an interface - * pointer that might NOT be &loif -- easier than replicating that code here. + * packet to the input queue of a specified interface. */ void ip_mloopback(struct ifnet *ifp, struct mbuf *m, struct sockaddr_in *dst) diff --git a/sys/netinet6/ip6_mroute.c b/sys/netinet6/ip6_mroute.c index c0a30cdbc75..f3ace76f084 100644 --- a/sys/netinet6/ip6_mroute.c +++ b/sys/netinet6/ip6_mroute.c @@ -1581,8 +1581,7 @@ phyint_send6(struct ip6_hdr *ip6, struct mif6 *mifp, struct mbuf *m) * We just call if_output instead of nd6_output here, since * we need no ND for a multicast forwarded packet...right? */ - error = (*ifp->if_output)(ifp, mb_copy, - sin6tosa(&ro.ro_dst), NULL); + error = if_output(ifp, mb_copy, sin6tosa(&ro.ro_dst), NULL); #ifdef MRT6DEBUG if (mrt6debug & DEBUG_XMIT) log(LOG_DEBUG, "phyint_send6 on mif %d err %d\n", diff --git a/sys/netinet6/ip6_output.c b/sys/netinet6/ip6_output.c index af8ba3d0e10..076cd409dbd 100644 --- a/sys/netinet6/ip6_output.c +++ b/sys/netinet6/ip6_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ip6_output.c,v 1.186 2015/09/12 13:34:12 mpi Exp $ */ +/* $OpenBSD: ip6_output.c,v 1.187 2015/09/12 20:26:07 mpi Exp $ */ /* $KAME: ip6_output.c,v 1.172 2001/03/25 09:55:56 itojun Exp $ */ /* @@ -3028,9 +3028,7 @@ ip6_setpktopt(int optname, u_char *buf, int len, struct ip6_pktopts *opt, /* * Routine called from ip6_output() to loop back a copy of an IP6 multicast - * packet to the input queue of a specified interface. Note that this - * calls the output routine of the loopback "driver", but with an interface - * pointer that might NOT be lo0ifp -- easier than replicating that code here. + * packet to the input queue of a specified interface. */ void ip6_mloopback(struct ifnet *ifp, struct mbuf *m, struct sockaddr_in6 *dst) diff --git a/sys/netinet6/nd6.c b/sys/netinet6/nd6.c index ba57ab46438..b37a5cc09df 100644 --- a/sys/netinet6/nd6.c +++ b/sys/netinet6/nd6.c @@ -1,4 +1,4 @@ -/* $OpenBSD: nd6.c,v 1.150 2015/09/10 17:52:05 claudio Exp $ */ +/* $OpenBSD: nd6.c,v 1.151 2015/09/12 20:26:07 mpi Exp $ */ /* $KAME: nd6.c,v 1.280 2002/06/08 19:52:07 itojun Exp $ */ /* @@ -1113,13 +1113,6 @@ nd6_rtrequest(int req, struct rtentry *rt) ln->ln_byhint = 0; /* - * XXX Since lo0 is in the default rdomain we - * should not (ab)use it for any route related - * to an interface of a different rdomain. - */ - rt->rt_ifp = lo0ifp; - - /* * Make sure rt_ifa be equal to the ifaddr * corresponding to the address. * We need this because when we refer @@ -1699,7 +1692,7 @@ nd6_output(struct ifnet *ifp, struct mbuf *m0, struct sockaddr_in6 *dst, return (0); sendpkt: - return ((*ifp->if_output)(ifp, m, sin6tosa(dst), rt)); + return (if_output(ifp, m, sin6tosa(dst), rt)); bad: m_freem(m); diff --git a/sys/netmpls/mpls_input.c b/sys/netmpls/mpls_input.c index 2ae6cb7b9fc..1b8243ec991 100644 --- a/sys/netmpls/mpls_input.c +++ b/sys/netmpls/mpls_input.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpls_input.c,v 1.47 2015/07/29 00:04:03 rzalamena Exp $ */ +/* $OpenBSD: mpls_input.c,v 1.48 2015/09/12 20:26:07 mpi Exp $ */ /* * Copyright (c) 2008 Claudio Jeker <claudio@openbsd.org> @@ -240,7 +240,7 @@ do_v6: } #endif if (ifp->if_type == IFT_MPLSTUNNEL) { - ifp->if_output(ifp, m, rt_key(rt), rt); + if_output(ifp, m, rt_key(rt), rt); goto done; } diff --git a/sys/netmpls/mpls_output.c b/sys/netmpls/mpls_output.c index 07bc343afc5..6d21a76b86f 100644 --- a/sys/netmpls/mpls_output.c +++ b/sys/netmpls/mpls_output.c @@ -1,4 +1,4 @@ -/* $OpenBSD: mpls_output.c,v 1.22 2015/09/12 14:21:04 claudio Exp $ */ +/* $OpenBSD: mpls_output.c,v 1.23 2015/09/12 20:26:07 mpi Exp $ */ /* * Copyright (c) 2008 Claudio Jeker <claudio@openbsd.org> @@ -58,7 +58,7 @@ mpls_output(struct ifnet *ifp0, struct mbuf *m, struct sockaddr *dst, if (rt0 == NULL || (dst->sa_family != AF_INET && dst->sa_family != AF_INET6 && dst->sa_family != AF_MPLS)) { if (!ISSET(ifp->if_xflags, IFXF_MPLS)) - return (ifp->if_output(ifp, m, dst, rt0)); + return (if_output(ifp, m, dst, rt0)); else return (ifp->if_ll_output(ifp, m, dst, rt0)); } |