summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2021-02-20 05:03:38 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2021-02-20 05:03:38 +0000
commit489d3b6b19e18ab7066848d68fb4aa7fc7940fb0 (patch)
treec04728dd909ac20591d9415d1152d7bee46b90eb /sys
parentfbecb2a235a07ab0c7fbfbf12d4c0988a745b27b (diff)
move from calling l3 protocol input handlers to using if_vinput.
if_vinput requires mpsafe interface counters, so add those in. this factors out some more code between drivers. monitor mode will work on these interfaces now too.
Diffstat (limited to 'sys')
-rw-r--r--sys/net/if_mpe.c27
-rw-r--r--sys/net/if_mpip.c27
2 files changed, 14 insertions, 40 deletions
diff --git a/sys/net/if_mpe.c b/sys/net/if_mpe.c
index 514633e7e28..f6b39406671 100644
--- a/sys/net/if_mpe.c
+++ b/sys/net/if_mpe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_mpe.c,v 1.97 2020/08/21 22:59:27 kn Exp $ */
+/* $OpenBSD: if_mpe.c,v 1.98 2021/02/20 05:03:37 dlg Exp $ */
/*
* Copyright (c) 2008 Pierre-Yves Ritschard <pyr@spootnik.org>
@@ -108,6 +108,8 @@ mpe_clone_create(struct if_clone *ifc, int unit)
ifp->if_softc = sc;
ifp->if_mtu = MPE_MTU;
ifp->if_ioctl = mpe_ioctl;
+ ifp->if_bpf_mtap = p2p_bpf_mtap;
+ ifp->if_input = p2p_input;
ifp->if_output = mpe_output;
ifp->if_start = mpe_start;
ifp->if_type = IFT_MPLS;
@@ -117,6 +119,8 @@ mpe_clone_create(struct if_clone *ifc, int unit)
if_attach(ifp);
if_alloc_sadl(ifp);
+ if_counters_alloc(ifp);
+
#if NBPFILTER > 0
bpfattach(&ifp->if_bpf, ifp, DLT_LOOP, sizeof(u_int32_t));
#endif
@@ -454,7 +458,6 @@ mpe_input(struct ifnet *ifp, struct mbuf *m)
struct mbuf *n;
uint8_t ttl, tos;
uint32_t exp;
- void (*input)(struct ifnet *, struct mbuf *);
int rxprio = sc->sc_rxhprio;
shim = mtod(m, struct shim_hdr *);
@@ -488,7 +491,7 @@ mpe_input(struct ifnet *ifp, struct mbuf *m)
if (m == NULL)
return;
}
- input = ipv4_input;
+
m->m_pkthdr.ph_family = AF_INET;
break;
}
@@ -510,7 +513,7 @@ mpe_input(struct ifnet *ifp, struct mbuf *m)
if (m == NULL)
return;
}
- input = ipv6_input;
+
m->m_pkthdr.ph_family = AF_INET6;
break;
}
@@ -534,21 +537,7 @@ mpe_input(struct ifnet *ifp, struct mbuf *m)
break;
}
- /* new receive if and move into correct rtable */
- m->m_pkthdr.ph_ifidx = ifp->if_index;
- m->m_pkthdr.ph_rtableid = ifp->if_rdomain;
-
- /* packet has not been processed by PF yet. */
- KASSERT(m->m_pkthdr.pf.statekey == NULL);
-
-#if NBPFILTER > 0
- if (ifp->if_bpf) {
- bpf_mtap_af(ifp->if_bpf, m->m_pkthdr.ph_family,
- m, BPF_DIRECTION_IN);
- }
-#endif
-
- (*input)(ifp, m);
+ if_vinput(ifp, m);
return;
drop:
m_freem(m);
diff --git a/sys/net/if_mpip.c b/sys/net/if_mpip.c
index baedf2e3c1c..cc2a46dae29 100644
--- a/sys/net/if_mpip.c
+++ b/sys/net/if_mpip.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: if_mpip.c,v 1.12 2020/08/21 22:59:27 kn Exp $ */
+/* $OpenBSD: if_mpip.c,v 1.13 2021/02/20 05:03:37 dlg Exp $ */
/*
* Copyright (c) 2015 Rafael Zalamena <rzalamena@openbsd.org>
@@ -112,6 +112,8 @@ mpip_clone_create(struct if_clone *ifc, int unit)
ifp->if_flags = IFF_POINTOPOINT | IFF_MULTICAST;
ifp->if_xflags = IFXF_CLONED;
ifp->if_ioctl = mpip_ioctl;
+ ifp->if_bpf_mtap = p2p_bpf_mtap;
+ ifp->if_input = p2p_input;
ifp->if_output = mpip_output;
ifp->if_start = mpip_start;
ifp->if_rtrequest = p2p_rtrequest;
@@ -460,7 +462,6 @@ mpip_input(struct mpip_softc *sc, struct mbuf *m)
uint32_t shim, exp;
struct mbuf *n;
uint8_t ttl, tos;
- void (*input)(struct ifnet *, struct mbuf *);
if (!ISSET(ifp->if_flags, IFF_RUNNING))
goto drop;
@@ -552,7 +553,7 @@ mpip_input(struct mpip_softc *sc, struct mbuf *m)
if (m == NULL)
return;
}
- input = ipv4_input;
+
m->m_pkthdr.ph_family = AF_INET;
break;
}
@@ -574,7 +575,7 @@ mpip_input(struct mpip_softc *sc, struct mbuf *m)
if (m == NULL)
return;
}
- input = ipv6_input;
+
m->m_pkthdr.ph_family = AF_INET6;
break;
}
@@ -599,23 +600,7 @@ mpip_input(struct mpip_softc *sc, struct mbuf *m)
break;
}
- m->m_pkthdr.ph_ifidx = ifp->if_index;
- m->m_pkthdr.ph_rtableid = ifp->if_rdomain;
-
- /* packet has not been processed by PF yet. */
- KASSERT(m->m_pkthdr.pf.statekey == NULL);
-
-#if NBPFILTER > 0
- {
- caddr_t if_bpf = ifp->if_bpf;
- if (if_bpf) {
- bpf_mtap_af(if_bpf, m->m_pkthdr.ph_family,
- m, BPF_DIRECTION_IN);
- }
- }
-#endif
-
- (*input)(ifp, m);
+ if_vinput(ifp, m);
return;
drop:
m_freem(m);