diff options
author | sam <sam@FreeBSD.org> | 2002-11-15 00:00:15 +0000 |
---|---|---|
committer | sam <sam@FreeBSD.org> | 2002-11-15 00:00:15 +0000 |
commit | 6a05792540ffa00713f4b3a1521864f7dddc1f39 (patch) | |
tree | 2a5611d45149f91e7ddfd0e32391f1ef7d8590e1 /sys/net | |
parent | 36661cddf10b1ee6cf5c6ca63413f6f860242c8e (diff) | |
download | FreeBSD-src-6a05792540ffa00713f4b3a1521864f7dddc1f39.zip FreeBSD-src-6a05792540ffa00713f4b3a1521864f7dddc1f39.tar.gz |
network interface and link layer changes:
o on input don't strip the Ethernet header from packets
o input packet handling is now done with if_input
o track changes to ether_ifattach/ether_ifdetach API
o track changes to bpf tapping
o call ether_ioctl for default handling of ioctl's
o use constants from net/ethernet.h where possible
Reviewed by: many
Approved by: re
Diffstat (limited to 'sys/net')
-rw-r--r-- | sys/net/bridge.h | 3 | ||||
-rw-r--r-- | sys/net/fddi.h | 1 | ||||
-rw-r--r-- | sys/net/if_arcsubr.c | 6 | ||||
-rw-r--r-- | sys/net/if_atmsubr.c | 3 | ||||
-rw-r--r-- | sys/net/if_disc.c | 2 | ||||
-rw-r--r-- | sys/net/if_ef.c | 31 | ||||
-rw-r--r-- | sys/net/if_faith.c | 2 | ||||
-rw-r--r-- | sys/net/if_fddisubr.c | 25 | ||||
-rw-r--r-- | sys/net/if_gif.c | 4 | ||||
-rw-r--r-- | sys/net/if_gre.c | 2 | ||||
-rw-r--r-- | sys/net/if_loop.c | 2 | ||||
-rw-r--r-- | sys/net/if_ppp.c | 6 | ||||
-rw-r--r-- | sys/net/if_sl.c | 4 | ||||
-rw-r--r-- | sys/net/if_stf.c | 4 | ||||
-rw-r--r-- | sys/net/if_tap.c | 35 | ||||
-rw-r--r-- | sys/net/if_tun.c | 6 |
16 files changed, 58 insertions, 78 deletions
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 *)⁡ - 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 *)⁡ - 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 *)⁡ - 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 *)⁡ - 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 *)⁡ 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 *)⁡ #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 *)⁡ #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 *)⁡ - 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 *)⁡ - bpf_mtap(ifp, &m); + BPF_MTAP(ifp, &m); } } |