summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/contrib/dev/oltr/if_oltr.c13
-rw-r--r--sys/i386/isa/if_cx.c6
-rw-r--r--sys/i386/isa/if_el.c26
-rw-r--r--sys/i386/isa/if_le.c37
-rw-r--r--sys/i386/isa/if_rdp.c35
-rw-r--r--sys/i4b/driver/i4b_ipr.c4
-rw-r--r--sys/i4b/driver/i4b_isppp.c6
-rw-r--r--sys/net/bridge.h3
-rw-r--r--sys/net/fddi.h1
-rw-r--r--sys/net/if_arcsubr.c6
-rw-r--r--sys/net/if_atmsubr.c3
-rw-r--r--sys/net/if_disc.c2
-rw-r--r--sys/net/if_ef.c31
-rw-r--r--sys/net/if_faith.c2
-rw-r--r--sys/net/if_fddisubr.c25
-rw-r--r--sys/net/if_gif.c4
-rw-r--r--sys/net/if_gre.c2
-rw-r--r--sys/net/if_loop.c2
-rw-r--r--sys/net/if_ppp.c6
-rw-r--r--sys/net/if_sl.c4
-rw-r--r--sys/net/if_stf.c4
-rw-r--r--sys/net/if_tap.c35
-rw-r--r--sys/net/if_tun.c6
23 files changed, 102 insertions, 161 deletions
diff --git a/sys/contrib/dev/oltr/if_oltr.c b/sys/contrib/dev/oltr/if_oltr.c
index 21c36e1..a4b1a82 100644
--- a/sys/contrib/dev/oltr/if_oltr.c
+++ b/sys/contrib/dev/oltr/if_oltr.c
@@ -56,6 +56,13 @@
#if (NBPFILTER > 0) || (__FreeBSD_version > 400000)
#include <net/bpf.h>
+
+#ifndef BPF_MTAP
+#define BPF_MTAP(_ifp, _m) do { \
+ if ((_ifp)->if_bpf) \
+ bpf_mtap((_ifp), (_m)); \
+} while (0)
+#endif
#endif
#include <vm/vm.h> /* for vtophys */
@@ -760,8 +767,7 @@ outloop:
sc->tx_frame++;
#if (NBPFILTER > 0) || (__FreeBSD_version > 400000)
- if (ifp->if_bpf)
- bpf_mtap(ifp, m0);
+ BPF_MTAP(ifp, m0);
#endif
/*ifp->if_opackets++;*/
@@ -1465,8 +1471,7 @@ DriverReceiveFrameCompleted(void *DriverHandle, int ByteCount, int FragmentCount
}
}
#if (NBPFILTER > 0) || (__FreeBSD_version > 400000)
- if (ifp->if_bpf)
- bpf_mtap(ifp, m0);
+ BPF_MTAP(ifp, m0);
#endif
/*if (ifp->if_flags & IFF_PROMISC) {*/
diff --git a/sys/i386/isa/if_cx.c b/sys/i386/isa/if_cx.c
index 392c9a2..b64f978 100644
--- a/sys/i386/isa/if_cx.c
+++ b/sys/i386/isa/if_cx.c
@@ -476,8 +476,7 @@ cxput (cx_chan_t *c, char b)
return;
}
m_copydata (m, 0, len, buf);
- if (c->ifp->if_bpf)
- bpf_mtap (c->ifp, m);
+ BPF_MTAP (c->ifp, m);
m_freem (m);
/* Start transmitter. */
@@ -802,8 +801,7 @@ cxinput (cx_chan_t *c, void *buf, unsigned len)
* Check if there's a BPF listener on this interface.
* If so, hand off the raw packet to bpf.
*/
- if (c->ifp->if_bpf)
- bpf_tap (c->ifp, buf, len);
+ BPF_TAP (c->ifp, buf, len);
/* Count the received bytes to the subchannel, not the master. */
c->master->if_ibytes -= len + 3;
diff --git a/sys/i386/isa/if_el.c b/sys/i386/isa/if_el.c
index b13f71a..6096549 100644
--- a/sys/i386/isa/if_el.c
+++ b/sys/i386/isa/if_el.c
@@ -265,7 +265,6 @@ el_attach(device_t dev)
ifp->if_unit = device_get_unit(dev);;
ifp->if_name = "el";
ifp->if_mtu = ETHERMTU;
- ifp->if_output = ether_output;
ifp->if_start = el_start;
ifp->if_ioctl = el_ioctl;
ifp->if_watchdog = el_watchdog;
@@ -275,7 +274,7 @@ el_attach(device_t dev)
/* Now we can attach the interface */
dprintf(("Attaching interface...\n"));
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->arpcom.ac_enaddr);
/* Print out some information for the user */
device_printf(dev, "3c501 address %6D\n",
@@ -296,7 +295,7 @@ static int el_detach(dev)
el_stop(sc);
EL_LOCK(sc);
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
bus_teardown_intr(dev, sc->el_irq, sc->el_intrhand);
bus_release_resource(dev, SYS_RES_IRQ, 0, sc->el_irq);
bus_release_resource(dev, SYS_RES_IOPORT, 0, sc->el_res);
@@ -444,8 +443,7 @@ el_start(struct ifnet *ifp)
len = max(len,ETHER_MIN_LEN);
/* Give the packet to the bpf, if any */
- if(sc->arpcom.ac_if.if_bpf)
- bpf_tap(&sc->arpcom.ac_if, sc->el_pktbuf, len);
+ BPF_TAP(&sc->arpcom.ac_if, sc->el_pktbuf, len);
/* Transfer datagram to board */
dprintf(("el: xfr pkt length=%d...\n",len));
@@ -528,19 +526,17 @@ el_xmit(struct el_softc *sc,int len)
static __inline void
elread(struct el_softc *sc,caddr_t buf,int len)
{
- register struct ether_header *eh;
+ struct ifnet *ifp = &sc->arpcom.ac_if;
struct mbuf *m;
- eh = (struct ether_header *)buf;
-
/*
* Put packet into an mbuf chain
*/
- m = elget(buf,len,&sc->arpcom.ac_if);
+ m = elget(buf,len,ifp);
if(m == 0)
return;
- ether_input(&sc->arpcom.ac_if,eh,m);
+ (*ifp->if_input)(ifp,m);
}
/* controller interrupt */
@@ -638,7 +634,6 @@ elintr(void *xsc)
dprintf(("%6D\n",sc->el_pktbuf,":"));
/* Pass data up to upper levels */
- len -= sizeof(struct ether_header);
elread(sc,(caddr_t)(sc->el_pktbuf),len);
/* Is there another packet? */
@@ -739,12 +734,6 @@ el_ioctl(ifp, command, data)
EL_LOCK(sc);
switch (command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, command, data);
- break;
-
case SIOCSIFFLAGS:
/*
* If interface is marked down and it is running, then stop it
@@ -763,7 +752,8 @@ el_ioctl(ifp, command, data)
}
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
+ break;
}
EL_UNLOCK(sc);
return (error);
diff --git a/sys/i386/isa/if_le.c b/sys/i386/isa/if_le.c
index ed4bdc9..3ed6a96 100644
--- a/sys/i386/isa/if_le.c
+++ b/sys/i386/isa/if_le.c
@@ -351,13 +351,12 @@ le_attach(
sc->le_ac.ac_enaddr, ":");
ifp->if_flags = IFF_BROADCAST | IFF_SIMPLEX | IFF_MULTICAST;
- ifp->if_output = ether_output;
ifp->if_ioctl = le_ioctl;
ifp->if_type = IFT_ETHER;
ifp->if_addrlen = 6;
ifp->if_hdrlen = 14;
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->le_ac.ac_enaddr);
return 1;
}
@@ -384,37 +383,28 @@ le_input(
size_t len1,
caddr_t seg2)
{
- struct ether_header eh;
+ struct ifnet *ifp = &sc->le_if;
struct mbuf *m;
- if (total_len - sizeof(eh) > ETHERMTU
- || total_len - sizeof(eh) < ETHERMIN) {
- sc->le_if.if_ierrors++;
- return;
- }
- MEMCPY(&eh, seg1, sizeof(eh));
-
- seg1 += sizeof(eh); total_len -= sizeof(eh); len1 -= sizeof(eh);
-
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL) {
- sc->le_if.if_ierrors++;
+ ifp->if_ierrors++;
return;
}
m->m_pkthdr.len = total_len;
- m->m_pkthdr.rcvif = &sc->le_if;
+ m->m_pkthdr.rcvif = ifp;
if (total_len + LE_XTRA > MHLEN /* >= MINCLSIZE */) {
MCLGET(m, M_DONTWAIT);
if ((m->m_flags & M_EXT) == 0) {
m_free(m);
- sc->le_if.if_ierrors++;
+ ifp->if_ierrors++;
return;
}
} else if (total_len + LE_XTRA > MHLEN && MINCLSIZE == (MHLEN+MLEN)) {
MGET(m->m_next, M_DONTWAIT, MT_DATA);
if (m->m_next == NULL) {
m_free(m);
- sc->le_if.if_ierrors++;
+ ifp->if_ierrors++;
return;
}
m->m_next->m_len = total_len - MHLEN - LE_XTRA;
@@ -428,7 +418,8 @@ le_input(
MEMCPY(mtod(m, caddr_t), seg1, len1);
if (seg2 != NULL)
MEMCPY(mtod(m, caddr_t) + len1, seg2, total_len - len1);
- ether_input(&sc->le_if, &eh, m);
+
+ (*ifp->if_input)(ifp, m);
}
static int
@@ -446,12 +437,6 @@ le_ioctl(
s = splimp();
switch (cmd) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, cmd, data);
- break;
-
case SIOCSIFFLAGS: {
sc->if_init(sc);
break;
@@ -467,7 +452,8 @@ le_ioctl(
break;
default: {
- error = EINVAL;
+ error = ether_ioctl(ifp, cmd, data);
+ break;
}
}
@@ -1016,8 +1002,7 @@ lemac_start(
LE_OUTB(sc, LEMAC_REG_TQ, tx_pg); /* tell chip to transmit this packet */
- if (sc->le_if.if_bpf)
- bpf_mtap(&sc->le_if, m);
+ BPF_MTAP(&sc->le_if, m);
m_freem(m); /* free the mbuf */
}
diff --git a/sys/i386/isa/if_rdp.c b/sys/i386/isa/if_rdp.c
index 45eccf1..574d3e7 100644
--- a/sys/i386/isa/if_rdp.c
+++ b/sys/i386/isa/if_rdp.c
@@ -602,7 +602,6 @@ rdp_attach(struct isa_device *isa_dev)
ifp->if_softc = sc;
ifp->if_unit = unit;
ifp->if_name = "rdp";
- ifp->if_output = ether_output;
ifp->if_start = rdp_start;
ifp->if_ioctl = rdp_ioctl;
ifp->if_watchdog = rdp_watchdog;
@@ -613,7 +612,7 @@ rdp_attach(struct isa_device *isa_dev)
/*
* Attach the interface
*/
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, sc->arpcom.ac_enaddr);
}
/*
@@ -807,9 +806,7 @@ outloop:
/*
* Tap off here if there is a bpf listener.
*/
- if (ifp->if_bpf) {
- bpf_mtap(ifp, m);
- }
+ BPF_MTAP(ifp, m);
m_freem(m);
@@ -832,12 +829,6 @@ rdp_ioctl(struct ifnet *ifp, IOCTL_CMD_T command, caddr_t data)
switch (command) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- error = ether_ioctl(ifp, command, data);
- break;
-
case SIOCSIFFLAGS:
/*
* If the interface is marked up and stopped, then start it.
@@ -873,7 +864,8 @@ rdp_ioctl(struct ifnet *ifp, IOCTL_CMD_T command, caddr_t data)
break;
default:
- error = EINVAL;
+ error = ether_ioctl(ifp, command, data);
+ break;
}
(void) splx(s);
return (error);
@@ -1097,7 +1089,7 @@ rdp_rint(struct rdp_softc *sc)
static void
rdp_get_packet(struct rdp_softc *sc, unsigned len)
{
- struct ether_header *eh;
+ struct ifnet *ifp = &sc->arpcom.ac_if;
struct mbuf *m;
u_char *packet_ptr;
size_t s;
@@ -1106,7 +1098,7 @@ rdp_get_packet(struct rdp_softc *sc, unsigned len)
MGETHDR(m, M_DONTWAIT, MT_DATA);
if (m == NULL)
return;
- m->m_pkthdr.rcvif = &sc->arpcom.ac_if;
+ m->m_pkthdr.rcvif = ifp;
m->m_pkthdr.len = m->m_len = len;
/*
@@ -1115,7 +1107,7 @@ rdp_get_packet(struct rdp_softc *sc, unsigned len)
* to the header. The +2 is to compensate for the alignment
* fixup below.
*/
- if ((len + 2) > MHLEN) {
+ if ((len + ETHER_ALIGN) > MHLEN) {
/* Attach an mbuf cluster */
MCLGET(m, M_DONTWAIT);
@@ -1130,8 +1122,7 @@ rdp_get_packet(struct rdp_softc *sc, unsigned len)
* The +2 is to longword align the start of the real packet.
* This is important for NFS.
*/
- m->m_data += 2;
- eh = mtod(m, struct ether_header *);
+ m->m_data += ETHER_ALIGN;
/*
* Get packet, including link layer address, from interface.
@@ -1139,7 +1130,7 @@ rdp_get_packet(struct rdp_softc *sc, unsigned len)
outb(sc->baseaddr + lpt_control, Ctrl_LNibRead);
outb(sc->baseaddr + lpt_data, RdAddr + MAR);
- packet_ptr = (u_char *)eh;
+ packet_ptr = mtod(m, u_char *);
if (sc->slow)
for (s = 0; s < len; s++, packet_ptr++)
*packet_ptr = RdByteA2(sc);
@@ -1151,13 +1142,7 @@ rdp_get_packet(struct rdp_softc *sc, unsigned len)
outb(sc->baseaddr + lpt_control, Ctrl_SelData);
WrNib(sc, CMR1, CMR1_RDPAC);
- /*
- * Remove link layer address.
- */
- m->m_pkthdr.len = m->m_len = len - sizeof(struct ether_header);
- m->m_data += sizeof(struct ether_header);
-
- ether_input(&sc->arpcom.ac_if, eh, m);
+ (*ifp->if_input)(ifp, m);
}
/*
diff --git a/sys/i4b/driver/i4b_ipr.c b/sys/i4b/driver/i4b_ipr.c
index 92c0e98..33033d2 100644
--- a/sys/i4b/driver/i4b_ipr.c
+++ b/sys/i4b/driver/i4b_ipr.c
@@ -876,7 +876,7 @@ error:
mm.m_next = m;
mm.m_len = 4;
mm.m_data = (char *)&af;
- bpf_mtap(&sc->sc_if, &mm);
+ BPF_MTAP(&sc->sc_if, &mm);
}
if(! IF_HANDOFF(&ipintrq, m, NULL))
@@ -934,7 +934,7 @@ ipr_tx_queue_empty(int unit)
mm.m_next = m;
mm.m_len = 4;
mm.m_data = (char *)&af;
- bpf_mtap(&sc->sc_if, &mm);
+ BPF_MTAP(&sc->sc_if, &mm);
}
#if I4BIPRACCT
diff --git a/sys/i4b/driver/i4b_isppp.c b/sys/i4b/driver/i4b_isppp.c
index 54d100d..a3f32a7 100644
--- a/sys/i4b/driver/i4b_isppp.c
+++ b/sys/i4b/driver/i4b_isppp.c
@@ -289,8 +289,7 @@ i4bisppp_start(struct ifnet *ifp)
while ((m = sppp_dequeue(&sc->sc_if)) != NULL)
{
- if (ifp->if_bpf)
- bpf_mtap(ifp, m);
+ BPF_MTAP(ifp, m);
microtime(&ifp->if_lastchange);
@@ -581,8 +580,7 @@ i4bisppp_rx_data_rdy(int unit)
printf("i4bisppp_rx_data_ready: received packet!\n");
#endif
- if(sc->sc_if.if_bpf)
- bpf_mtap(&sc->sc_if, m);
+ BPF_MTAP(&sc->sc_if, m);
s = splimp();
diff --git a/sys/net/bridge.h b/sys/net/bridge.h
index 37dcb5d..de30210 100644
--- a/sys/net/bridge.h
+++ b/sys/net/bridge.h
@@ -103,8 +103,7 @@ struct bdg_stats {
#ifdef _KERNEL
typedef struct ifnet *bridge_in_t(struct ifnet *, struct ether_header *);
/* bdg_forward frees the mbuf if necessary, returning null */
-typedef struct mbuf *bdg_forward_t(struct mbuf *, struct ether_header *const,
- struct ifnet *);
+typedef struct mbuf *bdg_forward_t(struct mbuf *, struct ifnet *);
typedef void bdgtakeifaces_t(void);
extern bridge_in_t *bridge_in_ptr;
extern bdg_forward_t *bdg_forward_ptr;
diff --git a/sys/net/fddi.h b/sys/net/fddi.h
index 82c1a13..5415027 100644
--- a/sys/net/fddi.h
+++ b/sys/net/fddi.h
@@ -99,7 +99,6 @@ struct fddi_header {
void fddi_ifattach(struct ifnet *, int);
void fddi_ifdetach(struct ifnet *, int);
-void fddi_input(struct ifnet *, struct fddi_header *, struct mbuf *);
int fddi_ioctl(struct ifnet *, int, caddr_t);
#endif /* _KERNEL */
diff --git a/sys/net/if_arcsubr.c b/sys/net/if_arcsubr.c
index a11dc44..df01b74 100644
--- a/sys/net/if_arcsubr.c
+++ b/sys/net/if_arcsubr.c
@@ -211,8 +211,7 @@ arc_output(ifp, m, dst, rt0)
ah->arc_dhost = adst;
ah->arc_shost = *IF_LLADDR(ifp);
- if (ifp->if_bpf)
- bpf_mtap(ifp, m);
+ BPF_MTAP(ifp, m);
#if __FreeBSD_version < 500000
s = splimp();
@@ -541,8 +540,7 @@ arc_input(ifp, m)
if (m == NULL)
return;
- if (ifp->if_bpf)
- bpf_mtap(ifp, m);
+ BPF_MTAP(ifp, m);
ah = mtod(m, struct arc_header *);
diff --git a/sys/net/if_atmsubr.c b/sys/net/if_atmsubr.c
index a6c71b5..3ec3894 100644
--- a/sys/net/if_atmsubr.c
+++ b/sys/net/if_atmsubr.c
@@ -321,6 +321,9 @@ atm_ifattach(ifp)
ifp->if_hdrlen = 0;
ifp->if_mtu = ATMMTU;
ifp->if_output = atm_output;
+#if 0
+ ifp->if_input = atm_input;
+#endif
ifp->if_snd.ifq_maxlen = 50; /* dummy */
#if defined(__NetBSD__) || defined(__OpenBSD__)
diff --git a/sys/net/if_disc.c b/sys/net/if_disc.c
index 6e30668..79775f1 100644
--- a/sys/net/if_disc.c
+++ b/sys/net/if_disc.c
@@ -180,7 +180,7 @@ discoutput(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
m0.m_len = 4;
m0.m_data = (char *)&af;
- bpf_mtap(ifp, &m0);
+ BPF_MTAP(ifp, &m0);
}
m->m_pkthdr.rcvif = ifp;
diff --git a/sys/net/if_ef.c b/sys/net/if_ef.c
index 710536c..d297faf 100644
--- a/sys/net/if_ef.c
+++ b/sys/net/if_ef.c
@@ -116,8 +116,8 @@ static int
ef_attach(struct efnet *sc)
{
struct ifnet *ifp = (struct ifnet*)&sc->ef_ac.ac_if;
- struct ifaddr *ifa1, *ifa2;
- struct sockaddr_dl *sdl1, *sdl2;
+ struct ifaddr *ifa2;
+ struct sockaddr_dl *sdl2;
ifp->if_output = ether_output;
ifp->if_start = ef_start;
@@ -128,19 +128,14 @@ ef_attach(struct efnet *sc)
/*
* Attach the interface
*/
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ifa2 = ifaddr_byindex(sc->ef_ifp->if_index);
+ sdl2 = (struct sockaddr_dl *)ifa2->ifa_addr;
+ ether_ifattach(ifp, LLADDR(sdl2));
ifp->if_resolvemulti = 0;
ifp->if_type = IFT_XETHER;
ifp->if_flags |= IFF_RUNNING;
- ifa1 = ifaddr_byindex(ifp->if_index);
- ifa2 = ifaddr_byindex(sc->ef_ifp->if_index);
- sdl1 = (struct sockaddr_dl *)ifa1->ifa_addr;
- sdl2 = (struct sockaddr_dl *)ifa2->ifa_addr;
- sdl1->sdl_type = IFT_ETHER;
- sdl1->sdl_alen = ETHER_ADDR_LEN;
- bcopy(LLADDR(sdl2), LLADDR(sdl1), ETHER_ADDR_LEN);
bcopy(LLADDR(sdl2), sc->ef_ac.ac_enaddr, ETHER_ADDR_LEN);
EFDEBUG("%s%d: attached\n", ifp->if_name, ifp->if_unit);
@@ -190,6 +185,9 @@ ef_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
error = 0;
s = splimp();
switch (cmd) {
+ case SIOCSIFFLAGS:
+ error = 0;
+ break;
case SIOCSIFADDR:
if (ifp->if_unit == ETHER_FT_8023 &&
ifa->ifa_addr->sa_family != AF_IPX) {
@@ -198,15 +196,9 @@ ef_ioctl(struct ifnet *ifp, u_long cmd, caddr_t data)
}
ifp->if_flags |= IFF_UP;
/* FALL THROUGH */
- case SIOCGIFADDR:
- case SIOCSIFMTU:
+ default:
error = ether_ioctl(ifp, cmd, data);
break;
- case SIOCSIFFLAGS:
- error = 0;
- break;
- default:
- error = EINVAL;
}
splx(s);
return error;
@@ -231,8 +223,7 @@ ef_start(struct ifnet *ifp)
IF_DEQUEUE(&ifp->if_snd, m);
if (m == 0)
break;
- if (ifp->if_bpf)
- bpf_mtap(ifp, m);
+ BPF_MTAP(ifp, m);
if (! IF_HANDOFF(&p->if_snd, m, p)) {
ifp->if_oerrors++;
continue;
@@ -380,7 +371,7 @@ ef_input(struct ifnet *ifp, struct ether_header *eh, struct mbuf *m)
m0.m_next = m;
m0.m_len = sizeof(struct ether_header);
m0.m_data = (char *)eh;
- bpf_mtap(eifp, &m0);
+ BPF_MTAP(eifp, &m0);
}
/*
* Now we ready to adjust mbufs and pass them to protocol intr's
diff --git a/sys/net/if_faith.c b/sys/net/if_faith.c
index 3173383..280a041 100644
--- a/sys/net/if_faith.c
+++ b/sys/net/if_faith.c
@@ -230,7 +230,7 @@ faithoutput(ifp, m, dst, rt)
m0.m_len = 4;
m0.m_data = (char *)&af;
- bpf_mtap(ifp, &m0);
+ BPF_MTAP(ifp, &m0);
}
if (rt && rt->rt_flags & (RTF_REJECT|RTF_BLACKHOLE)) {
diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c
index b1c6fce..49a5f21 100644
--- a/sys/net/if_fddisubr.c
+++ b/sys/net/if_fddisubr.c
@@ -100,6 +100,7 @@ static int fddi_resolvemulti(struct ifnet *, struct sockaddr **,
struct sockaddr *);
static int fddi_output(struct ifnet *, struct mbuf *, struct sockaddr *,
struct rtentry *);
+static void fddi_input(struct ifnet *ifp, struct mbuf *m);
#define IFP2AC(IFP) ((struct arpcom *)IFP)
@@ -356,14 +357,22 @@ bad:
* the packet is in the mbuf chain m without
* the fddi header, which is provided separately.
*/
-void
-fddi_input(ifp, fh, m)
+static void
+fddi_input(ifp, m)
struct ifnet *ifp;
- struct fddi_header *fh;
struct mbuf *m;
{
struct ifqueue *inq;
struct llc *l;
+ struct fddi_header *fh;
+
+ fh = mtod(m, struct fddi_header *);
+
+ /*
+ * Update interface statistics.
+ */
+ ifp->if_ibytes += m->m_pkthdr.len;
+ getmicrotime(&ifp->if_lastchange);
/*
* Discard packet if interface is not up.
@@ -396,12 +405,6 @@ fddi_input(ifp, fh, m)
ifp->if_imcasts++;
}
- /*
- * Update interface statistics.
- */
- getmicrotime(&ifp->if_lastchange);
- ifp->if_ibytes += (m->m_pkthdr.len + FDDI_HDR_LEN);
-
#ifdef M_LINK0
/*
* If this has a LLC priority of 0, then mark it so upper
@@ -412,6 +415,9 @@ fddi_input(ifp, fh, m)
m->m_flags |= M_LINK0;
#endif
+ /* Strip off FDDI header. */
+ m_adj(m, sizeof(struct fddi_header));
+
m = m_pullup(m, sizeof(struct llc));
if (m == 0) {
ifp->if_ierrors++;
@@ -548,6 +554,7 @@ fddi_ifattach(ifp, bpf)
ifp->if_mtu = FDDIMTU;
ifp->if_output = fddi_output;
+ ifp->if_input = fddi_input;
ifp->if_resolvemulti = fddi_resolvemulti;
ifp->if_broadcastaddr = fddibroadcastaddr;
ifp->if_baudrate = 100000000;
diff --git a/sys/net/if_gif.c b/sys/net/if_gif.c
index b3abb63..1cb4463 100644
--- a/sys/net/if_gif.c
+++ b/sys/net/if_gif.c
@@ -364,7 +364,7 @@ gif_output(ifp, m, dst, rt)
m0.m_len = 4;
m0.m_data = (char *)&af;
- bpf_mtap(ifp, &m0);
+ BPF_MTAP(ifp, &m0);
}
ifp->if_opackets++;
ifp->if_obytes += m->m_pkthdr.len;
@@ -434,7 +434,7 @@ gif_input(m, af, ifp)
m0.m_len = 4;
m0.m_data = (char *)&af1;
- bpf_mtap(ifp, &m0);
+ BPF_MTAP(ifp, &m0);
}
if (ng_gif_input_p != NULL) {
diff --git a/sys/net/if_gre.c b/sys/net/if_gre.c
index c66a101..6585396 100644
--- a/sys/net/if_gre.c
+++ b/sys/net/if_gre.c
@@ -249,7 +249,7 @@ gre_output(struct ifnet *ifp, struct mbuf *m, struct sockaddr *dst,
m0.m_len = 4;
m0.m_data = (char *)&af;
- bpf_mtap(ifp, &m0);
+ BPF_MTAP(ifp, &m0);
}
m->m_flags &= ~(M_BCAST|M_MCAST);
diff --git a/sys/net/if_loop.c b/sys/net/if_loop.c
index 57571a8..b4fc8b5 100644
--- a/sys/net/if_loop.c
+++ b/sys/net/if_loop.c
@@ -302,7 +302,7 @@ if_simloop(ifp, m, af, hlen)
m0.m_data = (char *)&af;
n = &m0;
}
- bpf_mtap(ifp, n);
+ BPF_MTAP(ifp, n);
}
/* Strip away media header */
diff --git a/sys/net/if_ppp.c b/sys/net/if_ppp.c
index 0ad0b74..aab5377 100644
--- a/sys/net/if_ppp.c
+++ b/sys/net/if_ppp.c
@@ -887,8 +887,7 @@ pppoutput(ifp, m0, dst, rtp)
/*
* See if bpf wants to look at the packet.
*/
- if (ifp->if_bpf)
- bpf_mtap(ifp, m0);
+ BPF_MTAP(ifp, m0);
/*
* Put the packet on the appropriate queue.
@@ -1519,8 +1518,7 @@ ppp_inproc(sc, m)
}
/* See if bpf wants to look at the packet. */
- if (sc->sc_if.if_bpf)
- bpf_mtap(&sc->sc_if, m);
+ BPF_MTAP(&sc->sc_if, m);
rv = 0;
switch (proto) {
diff --git a/sys/net/if_sl.c b/sys/net/if_sl.c
index 2a350f6..b57eb93 100644
--- a/sys/net/if_sl.c
+++ b/sys/net/if_sl.c
@@ -685,7 +685,7 @@ slstart(tp)
*/
sc->bpfbuf[SLX_DIR] = SLIPDIR_OUT;
bcopy(mtod(m, caddr_t), &sc->bpfbuf[SLX_CHDR], CHDR_LEN);
- bpf_tap(&sc->sc_if, sc->bpfbuf, len + SLIP_HDRLEN);
+ BPF_TAP(&sc->sc_if, sc->bpfbuf, len + SLIP_HDRLEN);
}
/*
@@ -957,7 +957,7 @@ slinput(c, tp)
hp[SLX_DIR] = SLIPDIR_IN;
bcopy(chdr, &hp[SLX_CHDR], CHDR_LEN);
- bpf_tap(&sc->sc_if, hp, len + SLIP_HDRLEN);
+ BPF_TAP(&sc->sc_if, hp, len + SLIP_HDRLEN);
}
m = sl_btom(sc, len);
if (m == NULL)
diff --git a/sys/net/if_stf.c b/sys/net/if_stf.c
index 88d9d07..16e0ee5 100644
--- a/sys/net/if_stf.c
+++ b/sys/net/if_stf.c
@@ -430,7 +430,7 @@ stf_output(ifp, m, dst, rt)
m0.m_data = (char *)&af;
#ifdef HAVE_OLD_BPF
- bpf_mtap(ifp, &m0);
+ BPF_MTAP(ifp, &m0);
#else
bpf_mtap(ifp->if_bpf, &m0);
#endif
@@ -684,7 +684,7 @@ in_stf_input(m, off)
m0.m_data = (char *)&af;
#ifdef HAVE_OLD_BPF
- bpf_mtap(ifp, &m0);
+ BPF_MTAP(ifp, &m0);
#else
bpf_mtap(ifp->if_bpf, &m0);
#endif
diff --git a/sys/net/if_tap.c b/sys/net/if_tap.c
index 5b2f8f0..d84d2b4 100644
--- a/sys/net/if_tap.c
+++ b/sys/net/if_tap.c
@@ -220,7 +220,7 @@ bail:
/* XXX makedev check? nah.. not right now :) */
s = splimp();
- ether_ifdetach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifdetach(ifp);
splx(s);
free(tp, M_TAP);
@@ -363,7 +363,6 @@ tapcreate(dev)
ifp->if_unit = unit;
ifp->if_name = name;
ifp->if_init = tapifinit;
- ifp->if_output = ether_output;
ifp->if_start = tapifstart;
ifp->if_ioctl = tapifioctl;
ifp->if_mtu = ETHERMTU;
@@ -373,7 +372,7 @@ tapcreate(dev)
dev->si_drv1 = tp;
s = splimp();
- ether_ifattach(ifp, ETHER_BPF_SUPPORTED);
+ ether_ifattach(ifp, tp->arpcom.ac_enaddr);
splx(s);
tp->tap_flags |= TAP_INITED;
@@ -546,14 +545,6 @@ tapifioctl(ifp, cmd, data)
int s, dummy;
switch (cmd) {
- case SIOCSIFADDR:
- case SIOCGIFADDR:
- case SIOCSIFMTU:
- s = splimp();
- dummy = ether_ioctl(ifp, cmd, data);
- splx(s);
- return (dummy);
-
case SIOCSIFFLAGS: /* XXX -- just like vmnet does */
case SIOCADDMULTI:
case SIOCDELMULTI:
@@ -571,7 +562,10 @@ tapifioctl(ifp, cmd, data)
break;
default:
- return (EINVAL);
+ s = splimp();
+ dummy = ether_ioctl(ifp, cmd, data);
+ splx(s);
+ return (dummy);
}
return (0);
@@ -801,8 +795,7 @@ tapread(dev, uio, flag)
} while (m == NULL);
/* feed packet to bpf */
- if (ifp->if_bpf != NULL)
- bpf_mtap(ifp, m);
+ BPF_MTAP(ifp, m);
/* xfer packet to user space */
while ((m != NULL) && (uio->uio_resid > 0) && (error == 0)) {
@@ -838,7 +831,6 @@ tapwrite(dev, uio, flag)
struct tap_softc *tp = dev->si_drv1;
struct ifnet *ifp = &tp->tap_if;
struct mbuf *top = NULL, **mp = NULL, *m = NULL;
- struct ether_header *eh = NULL;
int error = 0, tlen, mlen;
TAPDEBUG("%s%d writting, minor = %#x\n",
@@ -887,16 +879,9 @@ tapwrite(dev, uio, flag)
top->m_pkthdr.len = tlen;
top->m_pkthdr.rcvif = ifp;
- /*
- * Ethernet bridge and bpf are handled in ether_input
- *
- * adjust mbuf and give packet to the ether_input
- */
-
- eh = mtod(top, struct ether_header *);
- m_adj(top, sizeof(struct ether_header));
- ether_input(ifp, eh, top);
- ifp->if_ipackets ++; /* ibytes are counted in ether_input */
+ /* Pass packet up to parent. */
+ (*ifp->if_input)(ifp, top);
+ ifp->if_ipackets ++; /* ibytes are counted in parent */
return (0);
} /* tapwrite */
diff --git a/sys/net/if_tun.c b/sys/net/if_tun.c
index 400cf05..719191b 100644
--- a/sys/net/if_tun.c
+++ b/sys/net/if_tun.c
@@ -487,7 +487,7 @@ tunoutput(
m.m_len = 4;
m.m_data = (char *)&af;
- bpf_mtap(ifp, &m);
+ BPF_MTAP(ifp, &m);
}
/* prepend sockaddr? this may abort if the mbuf allocation fails */
@@ -772,7 +772,7 @@ tunwrite(dev_t dev, struct uio *uio, int flag)
return (ENOBUFS);
*mtod(top, u_int32_t *) =
ntohl(*mtod(top, u_int32_t *));
- bpf_mtap(ifp, top);
+ BPF_MTAP(ifp, top);
*mtod(top, u_int32_t *) =
htonl(*mtod(top, u_int32_t *));
} else {
@@ -790,7 +790,7 @@ tunwrite(dev_t dev, struct uio *uio, int flag)
m.m_len = 4;
m.m_data = (char *)&af;
- bpf_mtap(ifp, &m);
+ BPF_MTAP(ifp, &m);
}
}
OpenPOWER on IntegriCloud