diff options
author | Jason Wright <jason@cvs.openbsd.org> | 2001-06-24 22:52:09 +0000 |
---|---|---|
committer | Jason Wright <jason@cvs.openbsd.org> | 2001-06-24 22:52:09 +0000 |
commit | a65ab643786f0d374a6dc37a8ed701315960beef (patch) | |
tree | 6ba4298014dd5feeb78ef104bc47139873ae1b13 /sys | |
parent | 8694dfe4271b2e2e3e075c56f7d864f2339ac3f2 (diff) |
- redefine vlan_input_tag to take mbuf * and tag only
- call ether_input_mbuf() instead of ether_input()
- most work done by fgsch
Diffstat (limited to 'sys')
-rw-r--r-- | sys/net/if_vlan.c | 38 | ||||
-rw-r--r-- | sys/net/if_vlan_var.h | 5 |
2 files changed, 15 insertions, 28 deletions
diff --git a/sys/net/if_vlan.c b/sys/net/if_vlan.c index 09a68426664..efe5d2c35aa 100644 --- a/sys/net/if_vlan.c +++ b/sys/net/if_vlan.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan.c,v 1.20 2001/06/23 23:01:26 jason Exp $ */ +/* $OpenBSD: if_vlan.c,v 1.21 2001/06/24 22:52:07 jason Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology * @@ -294,10 +294,11 @@ vlan_start(struct ifnet *ifp) } int -vlan_input_tag(struct ether_header *eh, struct mbuf *m, u_int16_t t) +vlan_input_tag(struct mbuf *m, u_int16_t t) { int i; struct ifvlan *ifv; + struct ether_vlan_header vh; for (i = 0; i < NVLAN; i++) { ifv = &ifv_softc[i]; @@ -306,26 +307,17 @@ vlan_input_tag(struct ether_header *eh, struct mbuf *m, u_int16_t t) } if (i >= NVLAN) { - struct ether_header neh; - u_int16_t ntype, *np; - - /* - * Reinsert tag and pass it up to ether_input(). - * This allows bridging to continue to work with - * cards that do automatic vlan tagging. NOTE: - * we're very careful to not disturb possibly - * overlapping memory. - */ - bcopy(eh, &neh, sizeof(neh)); - ntype = neh.ether_type; - neh.ether_type = htons(ETHERTYPE_8021Q); + if (m->m_pkthdr.len < sizeof(struct ether_header)) + return (-1); + m_copydata(m, 0, sizeof(struct ether_header), (caddr_t)&vh); + vh.evl_proto = vh.evl_encap_proto; + vh.evl_tag = htons(t); + vh.evl_encap_proto = htons(ETHERTYPE_8021Q); M_PREPEND(m, EVL_ENCAPLEN, M_DONTWAIT); if (m == NULL) return (-1); - np = mtod(m, u_int16_t *); - np[0] = htons(t); - np[1] = ntype; - ether_input(m->m_pkthdr.rcvif, &neh, m); + m_copyback(m, 0, sizeof(struct ether_vlan_header), (caddr_t)&vh); + ether_input_mbuf(m->m_pkthdr.rcvif, m); return (-1); } @@ -350,15 +342,11 @@ vlan_input_tag(struct ether_header *eh, struct mbuf *m, u_int16_t t) * drivers to know about VLANs and we're not ready for * that yet. */ - struct mbuf m0; - m0.m_next = m; - m0.m_len = sizeof(struct ether_header); - m0.m_data = (char *)eh; - bpf_mtap(ifv->ifv_if.if_bpf, &m0); + bpf_mtap(ifv->ifv_if.if_bpf, m); } #endif ifv->ifv_if.if_ipackets++; - ether_input(&ifv->ifv_if, eh, m); + ether_input_mbuf(&ifv->ifv_if, m); return 0; } diff --git a/sys/net/if_vlan_var.h b/sys/net/if_vlan_var.h index 4677abac096..0bab632113b 100644 --- a/sys/net/if_vlan_var.h +++ b/sys/net/if_vlan_var.h @@ -1,4 +1,4 @@ -/* $OpenBSD: if_vlan_var.h,v 1.6 2001/06/09 06:17:48 angelos Exp $ */ +/* $OpenBSD: if_vlan_var.h,v 1.7 2001/06/24 22:52:08 jason Exp $ */ /* * Copyright 1998 Massachusetts Institute of Technology @@ -87,7 +87,6 @@ struct vlanreq { #ifdef _KERNEL extern int vlan_input(register struct ether_header *eh, struct mbuf *m); -extern int vlan_input_tag(struct ether_header *eh, - struct mbuf *m, u_int16_t t); +extern int vlan_input_tag(struct mbuf *m, u_int16_t t); #endif /* _KERNEL */ #endif /* _NET_IF_VLAN_VAR_H_ */ |