Use bpf filter hook from the common interface structure. This simplifies
the code by unifying it and prepare ppp(4) for pipex(4) support.
Ok?
---
sys/net/if_ppp.c | 16 ++++++++--------
sys/net/if_pppvar.h | 1 -
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git sys/net/if_ppp.c sys/net/if_ppp.c
index 192ec7c91e0..4cba9a8778c 100644
--- sys/net/if_ppp.c
+++ sys/net/if_ppp.c
@@ -204,9 +204,11 @@ int
ppp_clone_create(struct if_clone *ifc, int unit)
{
struct ppp_softc *sc;
+ struct ifnet *ifp;
sc = malloc(sizeof(*sc), M_DEVBUF, M_WAITOK|M_ZERO);
sc->sc_unit = unit;
+ ifp = &sc->sc_if;
snprintf(sc->sc_if.if_xname, sizeof sc->sc_if.if_xname, "%s%d",
ifc->ifc_name, unit);
sc->sc_if.if_softc = sc;
@@ -224,7 +226,7 @@ ppp_clone_create(struct if_clone *ifc, int unit)
if_attach(&sc->sc_if);
if_alloc_sadl(&sc->sc_if);
#if NBPFILTER > 0
- bpfattach(&sc->sc_bpf, &sc->sc_if, DLT_PPP, PPP_HDRLEN);
+ bpfattach(&ifp->if_bpf, ifp, DLT_PPP, PPP_HDRLEN);
#endif
NET_LOCK();
LIST_INSERT_HEAD(&ppp_softc_list, sc, sc_list);
@@ -754,11 +756,9 @@ pppoutput(struct ifnet *ifp, struct mbuf *m0, struct
sockaddr *dst,
}
#if NBPFILTER > 0
- /*
- * See if bpf wants to look at the packet.
- */
- if (sc->sc_bpf)
- bpf_mtap(sc->sc_bpf, m0, BPF_DIRECTION_OUT);
+ /* See if bpf wants to look at the packet. */
+ if (ifp->if_bpf)
+ bpf_mtap(ifp->if_bpf, m0, BPF_DIRECTION_OUT);
#endif
/*
@@ -1369,8 +1369,8 @@ ppp_inproc(struct ppp_softc *sc, struct mbuf *m)
#if NBPFILTER > 0
/* See if bpf wants to look at the packet. */
- if (sc->sc_bpf)
- bpf_mtap(sc->sc_bpf, m, BPF_DIRECTION_IN);
+ if (ifp->if_bpf)
+ bpf_mtap(ifp->if_bpf, m, BPF_DIRECTION_IN);
#endif
rv = 0;
diff --git sys/net/if_pppvar.h sys/net/if_pppvar.h
index 87f7d1798bb..9dc774a0515 100644
--- sys/net/if_pppvar.h
+++ sys/net/if_pppvar.h
@@ -113,7 +113,6 @@ struct ppp_softc {
struct mbuf *sc_togo; /* output packet ready to go */
struct mbuf_list sc_npqueue; /* output packets not to be sent yet */
struct pppstat sc_stats; /* count of bytes/pkts sent/rcvd */
- caddr_t sc_bpf; /* hook for BPF */
enum NPmode sc_npmode[NUM_NP]; /* what to do with each NP */
struct compressor *sc_xcomp; /* transmit compressor */
void *sc_xc_state; /* transmit compressor state */
--
2.26.0