diff options
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/bpf.c | 4 | ||||
-rw-r--r-- | sys/net/bpf.h | 4 | ||||
-rw-r--r-- | sys/net/bridgestp.c | 6 | ||||
-rw-r--r-- | sys/net/if.c | 13 | ||||
-rw-r--r-- | sys/net/if_bridge.c | 13 | ||||
-rw-r--r-- | sys/net/if_ethersubr.c | 8 | ||||
-rw-r--r-- | sys/net/if_loop.c | 4 | ||||
-rw-r--r-- | sys/net/if_mpe.c | 8 | ||||
-rw-r--r-- | sys/net/if_pflow.c | 4 | ||||
-rw-r--r-- | sys/net/if_pfsync.c | 4 | ||||
-rw-r--r-- | sys/net/if_ppp.c | 4 | ||||
-rw-r--r-- | sys/net/if_pppoe.c | 24 | ||||
-rw-r--r-- | sys/net/if_spppsubr.c | 8 | ||||
-rw-r--r-- | sys/net/if_trunk.c | 11 | ||||
-rw-r--r-- | sys/net/if_tun.c | 4 | ||||
-rw-r--r-- | sys/net/if_vlan.c | 11 | ||||
-rw-r--r-- | sys/net/pf.c | 7 | ||||
-rw-r--r-- | sys/net/pipex.c | 16 | ||||
-rw-r--r-- | sys/net/ppp_tty.c | 4 | ||||
-rw-r--r-- | sys/net/rtsock.c | 4 |
20 files changed, 94 insertions, 67 deletions
diff --git a/sys/net/bpf.c b/sys/net/bpf.c index 5626c73fef0..ecf59a8f0af 100644 --- a/sys/net/bpf.c +++ b/sys/net/bpf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.c,v 1.119 2015/05/13 10:42:46 jsg Exp $ */ +/* $OpenBSD: bpf.c,v 1.120 2015/06/16 11:09:39 mpi Exp $ */ /* $NetBSD: bpf.c,v 1.33 1997/02/21 23:59:35 thorpej Exp $ */ /* @@ -180,7 +180,7 @@ bpf_movein(struct uio *uio, u_int linktype, struct mbuf **mp, len = uio->uio_resid; MGETHDR(m, M_WAIT, MT_DATA); - m->m_pkthdr.rcvif = NULL; + m->m_pkthdr.ph_ifidx = 0; m->m_pkthdr.len = len - hlen; if (len > MHLEN) { diff --git a/sys/net/bpf.h b/sys/net/bpf.h index 188bb79e4e1..0be8dab461e 100644 --- a/sys/net/bpf.h +++ b/sys/net/bpf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bpf.h,v 1.48 2015/02/10 00:53:55 pelikan Exp $ */ +/* $OpenBSD: bpf.h,v 1.49 2015/06/16 11:09:39 mpi Exp $ */ /* $NetBSD: bpf.h,v 1.15 1996/12/13 07:57:33 mikel Exp $ */ /* @@ -271,6 +271,8 @@ struct bpf_dltlist { #define BPF_JUMP(code, k, jt, jf) { (u_int16_t)(code), jt, jf, k } #ifdef _KERNEL +struct ifnet; + int bpf_validate(struct bpf_insn *, int); int bpf_tap(caddr_t, u_char *, u_int, u_int); void bpf_mtap(caddr_t, struct mbuf *, u_int); diff --git a/sys/net/bridgestp.c b/sys/net/bridgestp.c index 74504acd6ba..0318144d0a2 100644 --- a/sys/net/bridgestp.c +++ b/sys/net/bridgestp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bridgestp.c,v 1.55 2015/05/15 10:15:13 mpi Exp $ */ +/* $OpenBSD: bridgestp.c,v 1.56 2015/06/16 11:09:39 mpi Exp $ */ /* * Copyright (c) 2000 Jason L. Wright (jason@thought.net) @@ -360,7 +360,7 @@ bstp_transmit_tcn(struct bstp_state *bs, struct bstp_port *bp) MGETHDR(m, M_DONTWAIT, MT_DATA); if (m == NULL) return; - m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.ph_ifidx = ifp->if_index; m->m_pkthdr.len = sizeof(*eh) + sizeof(bpdu); m->m_pkthdr.pf.prio = BSTP_IFQ_PRIO; m->m_len = m->m_pkthdr.len; @@ -503,7 +503,7 @@ bstp_send_bpdu(struct bstp_state *bs, struct bstp_port *bp, default: panic("not implemented"); } - m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.ph_ifidx = ifp->if_index; m->m_len = m->m_pkthdr.len; m->m_pkthdr.pf.prio = BSTP_IFQ_PRIO; diff --git a/sys/net/if.c b/sys/net/if.c index 21031279f00..a9180400ba3 100644 --- a/sys/net/if.c +++ b/sys/net/if.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if.c,v 1.339 2015/06/09 14:57:30 mpi Exp $ */ +/* $OpenBSD: if.c,v 1.340 2015/06/16 11:09:39 mpi Exp $ */ /* $NetBSD: if.c,v 1.35 1996/05/07 05:26:04 thorpej Exp $ */ /* @@ -486,7 +486,7 @@ if_input(struct ifnet *ifp, struct mbuf_list *ml) splassert(IPL_NET); MBUF_LIST_FOREACH(ml, m) { - m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.ph_ifidx = ifp->if_index; m->m_pkthdr.ph_rtableid = ifp->if_rdomain; } @@ -524,11 +524,16 @@ if_input_process(void *xmq) while ((m = ml_dequeue(&ml)) != NULL) { sched_pause(); + ifp = if_get(m->m_pkthdr.ph_ifidx); + if (ifp == NULL) { + m_freem(m); + continue; + } + /* * Pass this mbuf to all input handlers of its * interface until it is consumed. */ - ifp = m->m_pkthdr.rcvif; SLIST_FOREACH(ifih, &ifp->if_inputs, ifih_next) { if ((*ifih->ifih_input)(m)) break; @@ -699,7 +704,7 @@ if_detach_filter(void *ctx, const struct mbuf *m) return (0); #endif - return (m->m_pkthdr.rcvif == ifp); + return (m->m_pkthdr.ph_ifidx == ifp->if_index); } void diff --git a/sys/net/if_bridge.c b/sys/net/if_bridge.c index 8f66923843e..15d77b216cc 100644 --- a/sys/net/if_bridge.c +++ b/sys/net/if_bridge.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_bridge.c,v 1.243 2015/06/12 15:40:06 mpi Exp $ */ +/* $OpenBSD: if_bridge.c,v 1.244 2015/06/16 11:09:39 mpi Exp $ */ /* * Copyright (c) 1999, 2000 Jason L. Wright (jason@thought.net) @@ -1143,7 +1143,11 @@ bridgeintr_frame(struct bridge_softc *sc, struct mbuf *m) return; } - src_if = m->m_pkthdr.rcvif; + src_if = if_get(m->m_pkthdr.ph_ifidx); + if (src_if == NULL) { + m_freem(m); + return; + } sc->sc_if.if_ipackets++; sc->sc_if.if_ibytes += m->m_pkthdr.len; @@ -2464,8 +2468,11 @@ bridge_ip(struct bridge_softc *sc, int dir, struct ifnet *ifp, ip6 = mtod(m, struct ip6_hdr *); if ((ip6->ip6_vfc & IPV6_VERSION_MASK) != IPV6_VERSION) { + struct ifnet *ifp; ip6stat.ip6s_badvers++; - in6_ifstat_inc(m->m_pkthdr.rcvif, ifs6_in_hdrerr); + ifp = if_get(m->m_pkthdr.ph_ifidx); + if (ifp != NULL) + in6_ifstat_inc(ifp, ifs6_in_hdrerr); goto dropit; } diff --git a/sys/net/if_ethersubr.c b/sys/net/if_ethersubr.c index 61b303b3ea5..c6ae0229045 100644 --- a/sys/net/if_ethersubr.c +++ b/sys/net/if_ethersubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ethersubr.c,v 1.204 2015/06/08 13:44:08 mpi Exp $ */ +/* $OpenBSD: if_ethersubr.c,v 1.205 2015/06/16 11:09:39 mpi Exp $ */ /* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */ /* @@ -344,7 +344,8 @@ ether_input(struct mbuf *m) struct ether_header *eh_tmp; #endif - ifp = m->m_pkthdr.rcvif; + ifp = if_get(m->m_pkthdr.ph_ifidx); + KASSERT(ifp != NULL); if ((ifp->if_flags & IFF_UP) == 0) { m_freem(m); return (1); @@ -393,7 +394,8 @@ ether_input(struct mbuf *m) if (m == NULL) return (1); /* The bridge has determined it's for us. */ - ifp = m->m_pkthdr.rcvif; + ifp = if_get(m->m_pkthdr.ph_ifidx); + KASSERT(ifp != NULL); m_adj(m, ETHER_HDR_LEN); } } diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c index 356d353df2e..d7cd01898f8 100644 --- a/sys/net/if_loop.c +++ b/sys/net/if_loop.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_loop.c,v 1.65 2015/04/10 13:58:20 dlg Exp $ */ +/* $OpenBSD: if_loop.c,v 1.66 2015/06/16 11:09:39 mpi Exp $ */ /* $NetBSD: if_loop.c,v 1.15 1996/05/07 02:40:33 thorpej Exp $ */ /* @@ -216,7 +216,7 @@ looutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, if (ifp->if_bpf && (ifp->if_flags & IFF_LOOPBACK)) bpf_mtap_af(ifp->if_bpf, dst->sa_family, m, BPF_DIRECTION_OUT); #endif - m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.ph_ifidx = ifp->if_index; if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) { m_freem(m); diff --git a/sys/net/if_mpe.c b/sys/net/if_mpe.c index f2a7bde7d6d..9565273ba3e 100644 --- a/sys/net/if_mpe.c +++ b/sys/net/if_mpe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_mpe.c,v 1.44 2015/05/15 10:15:13 mpi Exp $ */ +/* $OpenBSD: if_mpe.c,v 1.45 2015/06/16 11:09:39 mpi Exp $ */ /* * Copyright (c) 2008 Pierre-Yves Ritschard <pyr@spootnik.org> @@ -214,7 +214,7 @@ mpeoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst, ifp->if_rdomain, rtable_l2(m->m_pkthdr.ph_rtableid)); } #endif - m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.ph_ifidx = ifp->if_index; /* XXX assumes MPLS is always in rdomain 0 */ m->m_pkthdr.ph_rtableid = 0; @@ -391,7 +391,7 @@ mpe_input(struct mbuf *m, struct ifnet *ifp, struct sockaddr_mpls *smpls, } /* new receive if and move into correct rtable */ - m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.ph_ifidx = ifp->if_index; m->m_pkthdr.ph_rtableid = ifp->if_rdomain; #if NBPFILTER > 0 @@ -423,7 +423,7 @@ mpe_input6(struct mbuf *m, struct ifnet *ifp, struct sockaddr_mpls *smpls, } /* new receive if and move into correct rtable */ - m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.ph_ifidx = ifp->if_index; m->m_pkthdr.ph_rtableid = ifp->if_rdomain; #if NBPFILTER > 0 diff --git a/sys/net/if_pflow.c b/sys/net/if_pflow.c index 6ff2adebd00..322c5b2d47c 100644 --- a/sys/net/if_pflow.c +++ b/sys/net/if_pflow.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pflow.c,v 1.50 2015/06/07 12:02:28 jsg Exp $ */ +/* $OpenBSD: if_pflow.c,v 1.51 2015/06/16 11:09:39 mpi Exp $ */ /* * Copyright (c) 2011 Florian Obser <florian@narrans.de> @@ -506,7 +506,7 @@ pflow_get_mbuf(struct pflow_softc *sc, u_int16_t set_id) } m->m_len = m->m_pkthdr.len = 0; - m->m_pkthdr.rcvif = NULL; + m->m_pkthdr.ph_ifidx = 0; if (sc == NULL) /* get only a new empty mbuf */ return (m); diff --git a/sys/net/if_pfsync.c b/sys/net/if_pfsync.c index 77c63ce0d74..998a7dfff4f 100644 --- a/sys/net/if_pfsync.c +++ b/sys/net/if_pfsync.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pfsync.c,v 1.218 2015/03/14 03:38:51 jsg Exp $ */ +/* $OpenBSD: if_pfsync.c,v 1.219 2015/06/16 11:09:39 mpi Exp $ */ /* * Copyright (c) 2002 Michael Shalayeff @@ -672,7 +672,7 @@ pfsync_input(struct mbuf *m, ...) goto done; /* verify that the packet came in on the right interface */ - if (sc->sc_sync_if != m->m_pkthdr.rcvif) { + if (sc->sc_sync_if->if_index != m->m_pkthdr.ph_ifidx) { pfsyncstats.pfsyncs_badif++; goto done; } diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c index 89f4482c177..2dcc8c096bc 100644 --- a/sys/net/if_ppp.c +++ b/sys/net/if_ppp.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_ppp.c,v 1.84 2015/06/03 00:50:09 dlg Exp $ */ +/* $OpenBSD: if_ppp.c,v 1.85 2015/06/16 11:09:39 mpi Exp $ */ /* $NetBSD: if_ppp.c,v 1.39 1997/05/17 21:11:59 christos Exp $ */ /* @@ -1372,7 +1372,7 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m) #endif /* VJC */ m->m_pkthdr.len = ilen; - m->m_pkthdr.rcvif = ifp; + m->m_pkthdr.ph_ifidx = ifp->if_index; /* mark incoming routing table */ m->m_pkthdr.ph_rtableid = ifp->if_rdomain; diff --git a/sys/net/if_pppoe.c b/sys/net/if_pppoe.c index ebfe565b31c..ed492b0e80e 100644 --- a/sys/net/if_pppoe.c +++ b/sys/net/if_pppoe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_pppoe.c,v 1.45 2015/04/10 13:58:20 dlg Exp $ */ +/* $OpenBSD: if_pppoe.c,v 1.46 2015/06/16 11:09:39 mpi Exp $ */ /* $NetBSD: if_pppoe.c,v 1.51 2003/11/28 08:56:48 keihan Exp $ */ /* @@ -181,8 +181,8 @@ static int pppoe_send_padt(struct ifnet *, u_int, const u_int8_t *); static int pppoe_output(struct pppoe_softc *, struct mbuf *); /* internal helper functions */ -static struct pppoe_softc *pppoe_find_softc_by_session(u_int, struct ifnet *); -static struct pppoe_softc *pppoe_find_softc_by_hunique(u_int8_t *, size_t, struct ifnet *); +static struct pppoe_softc *pppoe_find_softc_by_session(u_int, u_int); +static struct pppoe_softc *pppoe_find_softc_by_hunique(u_int8_t *, size_t, u_int); static struct mbuf *pppoe_get_mbuf(size_t len); LIST_HEAD(pppoe_softc_head, pppoe_softc) pppoe_softc_list; @@ -295,7 +295,7 @@ pppoe_clone_destroy(struct ifnet *ifp) * be 1. */ static struct pppoe_softc * -pppoe_find_softc_by_session(u_int session, struct ifnet *rcvif) +pppoe_find_softc_by_session(u_int session, u_int ifidx) { struct pppoe_softc *sc; @@ -305,7 +305,7 @@ pppoe_find_softc_by_session(u_int session, struct ifnet *rcvif) LIST_FOREACH(sc, &pppoe_softc_list, sc_list) { if (sc->sc_state == PPPOE_STATE_SESSION && sc->sc_session == session - && sc->sc_eth_if == rcvif) { + && sc->sc_eth_if->if_index == ifidx) { return (sc); } } @@ -317,7 +317,7 @@ pppoe_find_softc_by_session(u_int session, struct ifnet *rcvif) * or NULL if token is bogus. */ static struct pppoe_softc * -pppoe_find_softc_by_hunique(u_int8_t *token, size_t len, struct ifnet *rcvif) +pppoe_find_softc_by_hunique(u_int8_t *token, size_t len, u_int ifidx) { struct pppoe_softc *sc; u_int32_t hunique; @@ -344,7 +344,7 @@ pppoe_find_softc_by_hunique(u_int8_t *token, size_t len, struct ifnet *rcvif) sc->sc_sppp.pp_if.if_xname, sc->sc_state); return (NULL); } - if (sc->sc_eth_if != rcvif) { + if (sc->sc_eth_if->if_index != ifidx) { printf("%s: wrong interface, not accepting host unique\n", sc->sc_sppp.pp_if.if_xname); return (NULL); @@ -484,7 +484,7 @@ static void pppoe_dispatch_disc_pkt(struct mbuf *m, int off) hunique_len = len; #endif sc = pppoe_find_softc_by_hunique(mtod(n, caddr_t) + noff, - len, m->m_pkthdr.rcvif); + len, m->m_pkthdr.ph_ifidx); if (sc != NULL) devname = sc->sc_sppp.pp_if.if_xname; break; @@ -610,7 +610,7 @@ breakbreak: sc = pppoe_find_softc_by_hunique(ac_cookie, ac_cookie_len, - m->m_pkthdr.rcvif); + m->m_pkthdr.ph_ifidx); if (sc == NULL) { /* be quiet if there is not a single pppoe instance */ if (!LIST_EMPTY(&pppoe_softc_list)) @@ -798,7 +798,7 @@ pppoe_data_input(struct mbuf *m) goto drop; session = ntohs(ph->session); - sc = pppoe_find_softc_by_session(session, m->m_pkthdr.rcvif); + sc = pppoe_find_softc_by_session(session, m->m_pkthdr.ph_ifidx); if (sc == NULL) { #ifdef PPPOE_TERM_UNKNOWN_SESSIONS printf("pppoe (data): input for unknown session 0x%x, sending PADT\n", @@ -837,7 +837,7 @@ pppoe_data_input(struct mbuf *m) goto drop; /* fix incoming interface pointer (not the raw ethernet interface anymore) */ - m->m_pkthdr.rcvif = &sc->sc_sppp.pp_if; + m->m_pkthdr.ph_ifidx = sc->sc_sppp.pp_if.if_index; /* pass packet up and account for it */ sc->sc_sppp.pp_if.if_ipackets++; @@ -1043,7 +1043,7 @@ pppoe_get_mbuf(size_t len) m->m_data += sizeof(struct ether_header); m->m_len = len; m->m_pkthdr.len = len; - m->m_pkthdr.rcvif = NULL; + m->m_pkthdr.ph_ifidx = 0; return (m); } diff --git a/sys/net/if_spppsubr.c b/sys/net/if_spppsubr.c index ea4cf3a9106..145805319ff 100644 --- a/sys/net/if_spppsubr.c +++ b/sys/net/if_spppsubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_spppsubr.c,v 1.133 2015/05/15 10:15:13 mpi Exp $ */ +/* $OpenBSD: if_spppsubr.c,v 1.134 2015/06/16 11:09:39 mpi Exp $ */ /* * Synchronous PPP/Cisco link level subroutines. * Keepalive protocol implemented in both Cisco and PPP modes. @@ -1155,7 +1155,7 @@ sppp_cisco_send(struct sppp *sp, u_int32_t type, u_int32_t par1, u_int32_t par2) if (! m) return; m->m_pkthdr.len = m->m_len = PPP_HEADER_LEN + CISCO_PACKET_LEN; - m->m_pkthdr.rcvif = 0; + m->m_pkthdr.ph_ifidx = 0; h = mtod (m, struct ppp_header*); h->address = CISCO_MULTICAST; @@ -1214,7 +1214,7 @@ sppp_cp_send(struct sppp *sp, u_short proto, u_char type, if (! m) return; m->m_pkthdr.len = m->m_len = pkthdrlen + LCP_HEADER_LEN + len; - m->m_pkthdr.rcvif = 0; + m->m_pkthdr.ph_ifidx = 0; if (sp->pp_flags & PP_NOFRAMING) { *mtod(m, u_int16_t *) = htons(proto); @@ -4317,7 +4317,7 @@ sppp_auth_send(const struct cp *cp, struct sppp *sp, MGETHDR (m, M_DONTWAIT, MT_DATA); if (! m) return; - m->m_pkthdr.rcvif = 0; + m->m_pkthdr.ph_ifidx = 0; if (sp->pp_flags & PP_NOFRAMING) { *mtod(m, u_int16_t *) = htons(cp->proto); diff --git a/sys/net/if_trunk.c b/sys/net/if_trunk.c index 5de66dd6e3e..ba3887168db 100644 --- a/sys/net/if_trunk.c +++ b/sys/net/if_trunk.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_trunk.c,v 1.102 2015/06/15 15:55:08 mpi Exp $ */ +/* $OpenBSD: if_trunk.c,v 1.103 2015/06/16 11:09:39 mpi Exp $ */ /* * Copyright (c) 2005, 2006, 2007 Reyk Floeter <reyk@openbsd.org> @@ -1090,9 +1090,14 @@ trunk_input(struct mbuf *m) struct mbuf_list ml = MBUF_LIST_INITIALIZER(); int error; - ifp = m->m_pkthdr.rcvif; - eh = mtod(m, struct ether_header *); + ifp = if_get(m->m_pkthdr.ph_ifidx); + KASSERT(ifp != NULL); + if ((ifp->if_flags & IFF_UP) == 0) { + m_freem(m); + return (1); + } + eh = mtod(m, struct ether_header *); if (ETHER_IS_MULTICAST(eh->ether_dhost)) ifp->if_imcasts++; diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c index 4600a8cfa6c..41ef1053770 100644 --- a/sys/net/if_tun.c +++ b/sys/net/if_tun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_tun.c,v 1.145 2015/06/01 07:48:04 mpi Exp $ */ +/* $OpenBSD: if_tun.c,v 1.146 2015/06/16 11:09:39 mpi Exp $ */ /* $NetBSD: if_tun.c,v 1.24 1996/05/07 02:40:48 thorpej Exp $ */ /* @@ -898,7 +898,7 @@ tunwrite(dev_t dev, struct uio *uio, int ioflag) top->m_len -= sizeof(*th); top->m_pkthdr.len -= sizeof(*th); top->m_pkthdr.ph_rtableid = ifp->if_rdomain; - top->m_pkthdr.rcvif = ifp; + top->m_pkthdr.ph_ifidx = ifp->if_index; switch (ntohl(*th)) { case AF_INET: diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 632ace29c6d..6371b96536b 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan.c,v 1.128 2015/06/08 13:44:08 mpi Exp $ */ +/* $OpenBSD: if_vlan.c,v 1.129 2015/06/16 11:09:39 mpi Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology @@ -259,9 +259,14 @@ vlan_input(struct mbuf *m) struct mbuf_list ml = MBUF_LIST_INITIALIZER(); u_int16_t etype; - ifp = m->m_pkthdr.rcvif; - eh = mtod(m, struct ether_header *); + ifp = if_get(m->m_pkthdr.ph_ifidx); + KASSERT(ifp != NULL); + if ((ifp->if_flags & IFF_UP) == 0) { + m_freem(m); + return (1); + } + eh = mtod(m, struct ether_header *); etype = ntohs(eh->ether_type); if (m->m_flags & M_VLANTAG) { diff --git a/sys/net/pf.c b/sys/net/pf.c index 0fcbd5f4289..1069f647888 100644 --- a/sys/net/pf.c +++ b/sys/net/pf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pf.c,v 1.918 2015/06/07 12:02:28 jsg Exp $ */ +/* $OpenBSD: pf.c,v 1.919 2015/06/16 11:09:39 mpi Exp $ */ /* * Copyright (c) 2001 Daniel Hartmeier @@ -2350,7 +2350,7 @@ pf_send_tcp(const struct pf_rule *r, sa_family_t af, m->m_pkthdr.pf.qid = r->qid; m->m_data += max_linkhdr; m->m_pkthdr.len = m->m_len = len; - m->m_pkthdr.rcvif = NULL; + m->m_pkthdr.ph_ifidx = 0; m->m_pkthdr.csum_flags |= M_TCP_CSUM_OUT; bzero(m->m_data, len); switch (af) { @@ -2605,9 +2605,10 @@ pf_match_tag(struct mbuf *m, struct pf_rule *r, int *tag) int pf_match_rcvif(struct mbuf *m, struct pf_rule *r) { - struct ifnet *ifp = m->m_pkthdr.rcvif; + struct ifnet *ifp; struct pfi_kif *kif; + ifp = if_get(m->m_pkthdr.ph_ifidx); if (ifp == NULL) return (0); diff --git a/sys/net/pipex.c b/sys/net/pipex.c index 7c93ab6fbdc..5c52cbfbbfa 100644 --- a/sys/net/pipex.c +++ b/sys/net/pipex.c @@ -1,4 +1,4 @@ -/* $OpenBSD: pipex.c,v 1.69 2015/04/23 09:45:24 dlg Exp $ */ +/* $OpenBSD: pipex.c,v 1.70 2015/06/16 11:09:40 mpi Exp $ */ /*- * Copyright (c) 2009 Internet Initiative Japan Inc. @@ -1095,8 +1095,8 @@ pipex_ip_input(struct mbuf *m0, struct pipex_session *session) int is_idle; /* change recvif */ - m0->m_pkthdr.rcvif = session->pipex_iface->ifnet_this; - ifp = m0->m_pkthdr.rcvif; + ifp = session->pipex_iface->ifnet_this; + m0->m_pkthdr.ph_ifidx = ifp->if_index; PIPEX_PULLUP(m0, sizeof(struct ip)); if (m0 == NULL) @@ -1180,8 +1180,8 @@ pipex_ip6_input(struct mbuf *m0, struct pipex_session *session) int len; /* change recvif */ - m0->m_pkthdr.rcvif = session->pipex_iface->ifnet_this; - ifp = m0->m_pkthdr.rcvif; + ifp = session->pipex_iface->ifnet_this; + m0->m_pkthdr.ph_ifidx = ifp->if_index; #if 0 /* XXX: alignment */ PIPEX_PULLUP(m0, sizeof(struct ip6_hdr)); @@ -1431,7 +1431,7 @@ pipex_pppoe_output(struct mbuf *m0, struct pipex_session *session) pppoe->session_id = htons(session->session_id); pppoe->length = htons(len); - m0->m_pkthdr.rcvif = ifp; + m0->m_pkthdr.ph_ifidx = ifp->if_index; m0->m_flags &= ~(M_BCAST|M_MCAST); session->stat.opackets++; @@ -1516,7 +1516,7 @@ pipex_pptp_output(struct mbuf *m0, struct pipex_session *session, } gre->flags = htons(gre->flags); - m0->m_pkthdr.rcvif = session->pipex_iface->ifnet_this; + m0->m_pkthdr.ph_ifidx = session->pipex_iface->ifnet_this->if_index; if (ip_output(m0, NULL, NULL, 0, NULL, NULL, 0) != 0) { PIPEX_DBG((session, LOG_DEBUG, "ip_output failed.")); goto drop; @@ -1948,7 +1948,7 @@ pipex_l2tp_output(struct mbuf *m0, struct pipex_session *session) udp->uh_sum = 0; m0->m_pkthdr.csum_flags |= M_UDP_CSUM_OUT; - m0->m_pkthdr.rcvif = session->pipex_iface->ifnet_this; + m0->m_pkthdr.ph_ifidx = session->pipex_iface->ifnet_this->if_index; #if NPF > 0 pf_pkt_addr_changed(m0); #endif diff --git a/sys/net/ppp_tty.c b/sys/net/ppp_tty.c index 590b531e372..24af0237be4 100644 --- a/sys/net/ppp_tty.c +++ b/sys/net/ppp_tty.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ppp_tty.c,v 1.33 2015/06/03 00:50:09 dlg Exp $ */ +/* $OpenBSD: ppp_tty.c,v 1.34 2015/06/16 11:09:40 mpi Exp $ */ /* $NetBSD: ppp_tty.c,v 1.12 1997/03/24 21:23:10 christos Exp $ */ /* @@ -362,7 +362,7 @@ pppwrite(struct tty *tp, struct uio *uio, int flag) if (mp == &m0) { MGETHDR(m, M_WAIT, MT_DATA); m->m_pkthdr.len = uio->uio_resid - PPP_HDRLEN; - m->m_pkthdr.rcvif = NULL; + m->m_pkthdr.ph_ifidx = 0; } else MGET(m, M_WAIT, MT_DATA); *mp = m; diff --git a/sys/net/rtsock.c b/sys/net/rtsock.c index eb221a75b6b..48e5ae4d7f6 100644 --- a/sys/net/rtsock.c +++ b/sys/net/rtsock.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rtsock.c,v 1.159 2015/05/13 10:42:46 jsg Exp $ */ +/* $OpenBSD: rtsock.c,v 1.160 2015/06/16 11:09:40 mpi Exp $ */ /* $NetBSD: rtsock.c,v 1.18 1996/03/29 00:32:10 cgd Exp $ */ /* @@ -981,7 +981,7 @@ rt_msg1(int type, struct rt_addrinfo *rtinfo) if (m == NULL) return (m); m->m_pkthdr.len = m->m_len = hlen = len; - m->m_pkthdr.rcvif = NULL; + m->m_pkthdr.ph_ifidx = 0; rtm = mtod(m, struct rt_msghdr *); bzero(rtm, len); for (i = 0; i < RTAX_MAX; i++) { |