Make sure that the entire header is in the first mbuf before we

attempt to copy the ethernet header forward and otherwise encapsulate
a packet for output.

This fixes the panic when using VLAN devices on hardware that doesn't
do 802.1Q tagging onboard.  (That is to say, all drivers except the Tigon.)

My tests consisted of telnet, ttcp, and a pingflood of packets
between 1 and 1600 (plus headers) bytes.

MFC to follow in 1 week.

Approved by:	jkh
This commit is contained in:
Matthew N. Dodd 2000-02-03 07:44:39 +00:00
parent 3ca9ee77a9
commit 4af90a4da4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=56970

View file

@ -193,7 +193,7 @@ vlan_start(struct ifnet *ifp)
struct ifvlan *ifv;
struct ifnet *p;
struct ether_vlan_header *evl;
struct mbuf *m;
struct mbuf *m, *m0;
ifv = ifp->if_softc;
p = ifv->ifv_p;
@ -229,10 +229,22 @@ vlan_start(struct ifnet *ifp)
m->m_flags |= M_PROTO1;
} else {
M_PREPEND(m, EVL_ENCAPLEN, M_DONTWAIT);
if (m == 0)
if (m == NULL) {
printf("vlan%d: M_PREPEND failed", ifp->if_unit);
ifp->if_ierrors++;
continue;
}
/* M_PREPEND takes care of m_len, m_pkthdr.len for us */
m0 = m_pullup(m, ETHER_HDR_LEN + EVL_ENCAPLEN);
if (m0 == NULL) {
printf("vlan%d: m_pullup failed", ifp->if_unit);
ifp->if_ierrors++;
m_freem(m);
continue;
}
m = m0;
/*
* Transform the Ethernet header into an Ethernet header
* with 802.1Q encapsulation.