summaryrefslogtreecommitdiffstats
path: root/sys/net
diff options
context:
space:
mode:
authormdodd <mdodd@FreeBSD.org>2003-03-16 00:17:44 +0000
committermdodd <mdodd@FreeBSD.org>2003-03-16 00:17:44 +0000
commit41e5cea4996d19999044c79f425bc54395d7e396 (patch)
treeb08c38a278251a18b1953072e658c913107e240e /sys/net
parent6284f56b71dc65af96ac046fbc03f4e4ac47710a (diff)
downloadFreeBSD-src-41e5cea4996d19999044c79f425bc54395d7e396.zip
FreeBSD-src-41e5cea4996d19999044c79f425bc54395d7e396.tar.gz
- Use IFP2AC().
- Support IFF_MONITOR. - Borrow some consistency for if_input() routines from if_ethersubr.c. - Correct comments regarding fddi_input() that no longer apply.
Diffstat (limited to 'sys/net')
-rw-r--r--sys/net/if_fddisubr.c42
-rw-r--r--sys/net/if_iso88025subr.c36
2 files changed, 73 insertions, 5 deletions
diff --git a/sys/net/if_fddisubr.c b/sys/net/if_fddisubr.c
index cf0caf7..5d00620 100644
--- a/sys/net/if_fddisubr.c
+++ b/sys/net/if_fddisubr.c
@@ -128,6 +128,8 @@ fddi_output(ifp, m, dst, rt0)
senderr(error);
#endif
+ if (ifp->if_flags & IFF_MONITOR)
+ senderr(ENETDOWN);
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
senderr(ENETDOWN);
getmicrotime(&ifp->if_lastchange);
@@ -324,9 +326,7 @@ bad:
}
/*
- * Process a received FDDI packet;
- * the packet is in the mbuf chain m without
- * the fddi header, which is provided separately.
+ * Process a received FDDI packet.
*/
static void
fddi_input(ifp, m)
@@ -337,7 +337,30 @@ fddi_input(ifp, m)
struct llc *l;
struct fddi_header *fh;
+ /*
+ * Do consistency checks to verify assumptions
+ * made by code past this point.
+ */
+ if ((m->m_flags & M_PKTHDR) == 0) {
+ if_printf(ifp, "discard frame w/o packet header\n");
+ ifp->if_ierrors++;
+ m_freem(m);
+ return;
+ }
+ if (m->m_pkthdr.rcvif == NULL) {
+ if_printf(ifp, "discard frame w/o interface pointer\n");
+ ifp->if_ierrors++;
+ m_freem(m);
+ return;
+ }
+
+ m = m_pullup(m, FDDI_HDR_LEN);
+ if (m == NULL) {
+ ifp->if_ierrors++;
+ goto dropanyway;
+ }
fh = mtod(m, struct fddi_header *);
+ m->m_pkthdr.header = (void *)fh;
/*
* Discard packet if interface is not up.
@@ -345,6 +368,19 @@ fddi_input(ifp, m)
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
goto dropanyway;
+ /*
+ * Give bpf a chance at the packet.
+ */
+ BPF_MTAP(ifp, m);
+
+ /*
+ * Interface marked for monitoring; discard packet.
+ */
+ if (ifp->if_flags & IFF_MONITOR) {
+ m_freem(m);
+ return;
+ }
+
#ifdef MAC
mac_create_mbuf_from_ifnet(ifp, m);
#endif
diff --git a/sys/net/if_iso88025subr.c b/sys/net/if_iso88025subr.c
index 0062f83..f6ef3f0 100644
--- a/sys/net/if_iso88025subr.c
+++ b/sys/net/if_iso88025subr.c
@@ -246,7 +246,7 @@ iso88025_output(ifp, m, dst, rt0)
struct iso88025_header gen_th;
struct sockaddr_dl *sdl = NULL;
struct rtentry *rt;
- struct arpcom *ac = (struct arpcom *)ifp;
+ struct arpcom *ac = IFP2AC(ifp);
#ifdef MAC
error = mac_check_ifnet_transmit(ifp, m);
@@ -254,6 +254,8 @@ iso88025_output(ifp, m, dst, rt0)
senderr(error);
#endif
+ if (ifp->if_flags & IFF_MONITOR)
+ senderr(ENETDOWN);
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
senderr(ENETDOWN);
getmicrotime(&ifp->if_lastchange);
@@ -429,6 +431,23 @@ iso88025_input(ifp, m)
int isr;
int mac_hdr_len;
+ /*
+ * Do consistency checks to verify assumptions
+ * made by code past this point.
+ */
+ if ((m->m_flags & M_PKTHDR) == 0) {
+ if_printf(ifp, "discard frame w/o packet header\n");
+ ifp->if_ierrors++;
+ m_freem(m);
+ return;
+ }
+ if (m->m_pkthdr.rcvif == NULL) {
+ if_printf(ifp, "discard frame w/o interface pointer\n");
+ ifp->if_ierrors++;
+ m_freem(m);
+ return;
+ }
+
m = m_pullup(m, ISO88025_HDR_LEN);
if (m == NULL) {
ifp->if_ierrors++;
@@ -443,6 +462,19 @@ iso88025_input(ifp, m)
if ((ifp->if_flags & (IFF_UP|IFF_RUNNING)) != (IFF_UP|IFF_RUNNING))
goto dropanyway;
+ /*
+ * Give bpf a chance at the packet.
+ */
+ BPF_MTAP(ifp, m);
+
+ /*
+ * Interface marked for monitoring; discard packet.
+ */
+ if (ifp->if_flags & IFF_MONITOR) {
+ m_freem(m);
+ return;
+ }
+
#ifdef MAC
mac_create_mbuf_from_ifnet(ifp, m);
#endif
@@ -582,7 +614,7 @@ iso88025_input(ifp, m)
int i;
u_char c;
- ac = (struct arpcom *)ifp;
+ ac = IFP2AC(ifp);
c = l->llc_dsap;
if (th->iso88025_shost[0] & TR_RII) { /* XXX */
OpenPOWER on IntegriCloud