From 5be9a825e285a775406a93f6ca2c342d8c17655c Mon Sep 17 00:00:00 2001 From: Hartmut Brandt Date: Thu, 24 Jul 2003 08:15:20 +0000 Subject: [PATCH] Add BPF support to HARP network interfaces. This allows one to see the traffic on LLC multiplexed connections (like CLIP). PR: kern/51831 Submitted by: Vincent Jardin MFC after: 2 weeks --- sys/netatm/atm_cm.c | 12 ++++++++++++ sys/netatm/atm_device.c | 12 ++++++++++++ sys/netatm/atm_if.c | 13 +++++++++++++ 3 files changed, 37 insertions(+) diff --git a/sys/netatm/atm_cm.c b/sys/netatm/atm_cm.c index 8ca491fbeded..f21db37214ba 100644 --- a/sys/netatm/atm_cm.c +++ b/sys/netatm/atm_cm.c @@ -41,6 +41,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -2899,6 +2900,17 @@ atm_cm_cpcs_upper(cmd, tok, arg1, arg2) break; case ATM_ENC_LLC: + /* + * Send the packet to the interface's bpf if this + * vc has one. + */ + if (cvp->cvc_vcc != NULL && + cvp->cvc_vcc->vc_nif != NULL) { + struct ifnet *ifp = + (struct ifnet *)cvp->cvc_vcc->vc_nif; + + BPF_MTAP(ifp, m); + } /* * Find connection with matching LLC header */ diff --git a/sys/netatm/atm_device.c b/sys/netatm/atm_device.c index d3bc45bc61c5..cbfdaa6c8c7d 100644 --- a/sys/netatm/atm_device.c +++ b/sys/netatm/atm_device.c @@ -42,6 +42,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -370,6 +371,17 @@ atm_dev_lower(cmd, tok, arg1, arg2) break; } + /* + * Send the packet to the interface's bpf if this vc has one. + */ + if (cvcp->cvc_conn->co_mpx == ATM_ENC_LLC && + cvcp->cvc_vcc && cvcp->cvc_vcc->vc_nif) { + struct ifnet *ifp = + (struct ifnet *)cvcp->cvc_vcc->vc_nif; + + BPF_MTAP(ifp, (KBuffer *)arg1); + } + /* * Hand the data off to the device */ diff --git a/sys/netatm/atm_if.c b/sys/netatm/atm_if.c index cc0b657f56b5..52e236282900 100644 --- a/sys/netatm/atm_if.c +++ b/sys/netatm/atm_if.c @@ -44,6 +44,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -776,6 +777,13 @@ atm_nif_attach(nip) */ if_attach(ifp); + /* + * Add to BPF interface list + * DLT_ATM_RFC_1483 cannot be used because both NULL and LLC/SNAP could + * be provisioned + */ + bpfattach(ifp, DLT_ATM_CLIP, T_ATM_LLC_MAX_LEN); + /* * Add to physical interface list */ @@ -838,6 +846,11 @@ atm_nif_detach(nip) (void) (*ncp->ncm_stat)(NCM_DETACH, nip, 0); } + /* + * Remove from BPF interface list + */ + bpfdetach(ifp); + /* * Mark interface down */