-/* $OpenBSD: if_ethersubr.c,v 1.275 2021/07/07 20:19:01 sashan Exp $ */
+/* $OpenBSD: if_ethersubr.c,v 1.276 2021/08/19 10:22:00 dlg Exp $ */
/* $NetBSD: if_ethersubr.c,v 1.19 1996/05/07 02:40:30 thorpej Exp $ */
/*
if (ISSET(m->m_flags, M_VLANTAG) ||
etype == ETHERTYPE_VLAN || etype == ETHERTYPE_QINQ) {
#if NVLAN > 0
- m = vlan_input(ifp, m);
+ m = vlan_input(ifp, m, &sdelim);
if (m == NULL)
return;
-#endif /* NVLAN > 0 */
-
+#else
sdelim = 1;
+#endif
}
/*
* At this point it is known that the packet is destined
* for layer 3 protocol handling on the local port.
*/
+ etype = ntohs(eh->ether_type);
switch (etype) {
case ETHERTYPE_IP:
-/* $OpenBSD: if_vlan.c,v 1.207 2021/06/09 03:24:54 dlg Exp $ */
+/* $OpenBSD: if_vlan.c,v 1.208 2021/08/19 10:22:00 dlg Exp $ */
/*
* Copyright 1998 Massachusetts Institute of Technology
if_put(ifp0);
}
+struct mbuf *
+vlan_strip(struct mbuf *m)
+{
+ if (ISSET(m->m_flags, M_VLANTAG)) {
+ CLR(m->m_flags, M_VLANTAG);
+ } else {
+ struct ether_vlan_header *evl;
+
+ evl = mtod(m, struct ether_vlan_header *);
+ memmove((caddr_t)evl + EVL_ENCAPLEN, evl,
+ offsetof(struct ether_vlan_header, evl_encap_proto));
+ m_adj(m, EVL_ENCAPLEN);
+ }
+
+ return (m);
+}
+
struct mbuf *
vlan_inject(struct mbuf *m, uint16_t type, uint16_t tag)
{
}
struct mbuf *
-vlan_input(struct ifnet *ifp0, struct mbuf *m)
+vlan_input(struct ifnet *ifp0, struct mbuf *m, unsigned int *sdelim)
{
struct vlan_softc *sc;
struct ifnet *ifp;
}
smr_read_leave();
- if (sc == NULL)
- return (m); /* decline, let bridge have a go */
+ if (sc == NULL) {
+ /* VLAN 0 Priority Tagging */
+ if (tag == 0 && etype == ETHERTYPE_VLAN) {
+ struct ether_header *eh;
+
+ /* XXX we should actually use the prio value? */
+ m = vlan_strip(m);
+
+ eh = mtod(m, struct ether_header *);
+ if (eh->ether_type == htons(ETHERTYPE_VLAN) ||
+ eh->ether_type == htons(ETHERTYPE_QINQ)) {
+ m_freem(m);
+ return (NULL);
+ }
+ } else
+ *sdelim = 1;
+
+ return (m); /* decline */
+ }
ifp = &sc->sc_if;
if (!ISSET(ifp->if_flags, IFF_RUNNING)) {
* the given source interface and vlan tag, remove the
* encapsulation.
*/
- if (ISSET(m->m_flags, M_VLANTAG)) {
- CLR(m->m_flags, M_VLANTAG);
- } else {
- memmove((caddr_t)evl + EVL_ENCAPLEN, evl,
- offsetof(struct ether_vlan_header, evl_encap_proto));
- m_adj(m, EVL_ENCAPLEN);
- }
+ m = vlan_strip(m);
rxprio = sc->sc_rxprio;
switch (rxprio) {
-/* $OpenBSD: if_vlan_var.h,v 1.42 2020/07/22 01:30:54 dlg Exp $ */
+/* $OpenBSD: if_vlan_var.h,v 1.43 2021/08/19 10:22:00 dlg Exp $ */
/*
* Copyright 1998 Massachusetts Institute of Technology
};
#ifdef _KERNEL
-struct mbuf *vlan_input(struct ifnet *, struct mbuf *);
+struct mbuf *vlan_input(struct ifnet *, struct mbuf *, unsigned int *);
struct mbuf *vlan_inject(struct mbuf *, uint16_t, uint16_t);
#endif /* _KERNEL */