802.1q with 0 tag

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

802.1q with 0 tag

Rivo Nurges-2
Hi!

In theory 802.1q header with vlan tag 0 can be used to just signal
priority. Now I'm seeing this in the wild. On a untagged port some
packets are coming with dotq header and some without. Currently we drop
all the packets with dotq header and vlan tag 0.

Following patch fixes this by recording the priority and removing the
header, so existing code to handle the packet. At least NetBSD does
something similar.

Rivo

diff --git sys/net/if_ethersubr.c sys/net/if_ethersubr.c
index 76f6c3147e0..68f5b03b4f4 100644
--- sys/net/if_ethersubr.c
+++ sys/net/if_ethersubr.c
@@ -362,6 +362,22 @@ ether_input(struct ifnet *ifp, struct mbuf *m, void *cookie)
 
  etype = ntohs(eh->ether_type);
 
+ /*
+ * 802.1Q header with a tag of 0 can be used to store priority.
+ */
+ if (etype == ETHERTYPE_VLAN) {
+ struct ether_vlan_header *evl = (void *)eh;
+ if (EVL_VLANOFTAG(evl->evl_tag) == EVL_VLID_NULL) {
+ etype = ntohs(evl->evl_proto);
+ m->m_pkthdr.pf.prio = EVL_PRIOFTAG(evl->evl_tag);
+ /* IEEE 802.1p has prio 0 and 1 swapped */
+ if (m->m_pkthdr.pf.prio <= 1)
+ m->m_pkthdr.pf.prio = !m->m_pkthdr.pf.prio;
+ memmove((char *)eh + EVL_ENCAPLEN, eh, sizeof(*eh));
+ m_adj(m, EVL_ENCAPLEN);
+ }
+ }
+
  switch (etype) {
  case ETHERTYPE_IP:
  input = ipv4_input;

Reply | Threaded
Open this post in threaded view
|

Re: 802.1q with 0 tag

David Gwynne-5
Hi Rivo,

vlan(4) can be configured to receive (and send) packets with 0 as the tag on the wire, which this diff will break.

I'm pretty confident you can leave an IP configured on the physical network interface, and create and configure a vlan interface on it without setting a VLAN id. The untagged frames should be received as normal on the parent, and the tagged frames with the priority will come in on the vlan interface but still get accepted for IP on the parent.

Note that the default priority of packets in the OpenBSD kernel is 3, which might be higher than what you expect an untagged packets priority to be. The default 802.1q priority is 1 iirc.

I'm curious as to where you see both tagged and untagged frames at the same time.

dlg

> On 11 Oct 2018, at 7:20 pm, Rivo Nurges <[hidden email]> wrote:
>
> Hi!
>
> In theory 802.1q header with vlan tag 0 can be used to just signal
> priority. Now I'm seeing this in the wild. On a untagged port some
> packets are coming with dotq header and some without. Currently we drop
> all the packets with dotq header and vlan tag 0.
>
> Following patch fixes this by recording the priority and removing the
> header, so existing code to handle the packet. At least NetBSD does
> something similar.
>
> Rivo
>
> diff --git sys/net/if_ethersubr.c sys/net/if_ethersubr.c
> index 76f6c3147e0..68f5b03b4f4 100644
> --- sys/net/if_ethersubr.c
> +++ sys/net/if_ethersubr.c
> @@ -362,6 +362,22 @@ ether_input(struct ifnet *ifp, struct mbuf *m, void *cookie)
>
> etype = ntohs(eh->ether_type);
>
> + /*
> + * 802.1Q header with a tag of 0 can be used to store priority.
> + */
> + if (etype == ETHERTYPE_VLAN) {
> + struct ether_vlan_header *evl = (void *)eh;
> + if (EVL_VLANOFTAG(evl->evl_tag) == EVL_VLID_NULL) {
> + etype = ntohs(evl->evl_proto);
> + m->m_pkthdr.pf.prio = EVL_PRIOFTAG(evl->evl_tag);
> + /* IEEE 802.1p has prio 0 and 1 swapped */
> + if (m->m_pkthdr.pf.prio <= 1)
> + m->m_pkthdr.pf.prio = !m->m_pkthdr.pf.prio;
> + memmove((char *)eh + EVL_ENCAPLEN, eh, sizeof(*eh));
> + m_adj(m, EVL_ENCAPLEN);
> + }
> + }
> +
> switch (etype) {
> case ETHERTYPE_IP:
> input = ipv4_input;
>

Reply | Threaded
Open this post in threaded view
|

Re: 802.1q with 0 tag

Rivo Nurges-2
Hi!

I'll look into the problems(vlan interface with 0 tag and issues
priority differeces) you mentioned. I tested your idea of having vlan
interface without tag and IP on top of physical interface, but IP
traffic doesn't get picked up by parent.

Extreme(Brocade) SLX does it. Depending on the ingress port
configuration packets on egress can be with or without dot1q header.
Seems, it doesn't cause issues with other operating systems.

Rivo

On Fri, 2018-10-12 at 13:38 +1000, David Gwynne wrote:

> Hi Rivo,
>
> vlan(4) can be configured to receive (and send) packets with 0 as the
> tag on the wire, which this diff will break.
>
> I'm pretty confident you can leave an IP configured on the physical
> network interface, and create and configure a vlan interface on it
> without setting a VLAN id. The untagged frames should be received as
> normal on the parent, and the tagged frames with the priority will
> come in on the vlan interface but still get accepted for IP on the
> parent.
>
> Note that the default priority of packets in the OpenBSD kernel is 3,
> which might be higher than what you expect an untagged packets
> priority to be. The default 802.1q priority is 1 iirc.
>
> I'm curious as to where you see both tagged and untagged frames at
> the same time.
>
> dlg
>
> > On 11 Oct 2018, at 7:20 pm, Rivo Nurges <[hidden email]>
> > wrote:
> >
> > Hi!
> >
> > In theory 802.1q header with vlan tag 0 can be used to just signal
> > priority. Now I'm seeing this in the wild. On a untagged port some
> > packets are coming with dotq header and some without. Currently we
> > drop
> > all the packets with dotq header and vlan tag 0.
> >
> > Following patch fixes this by recording the priority and removing
> > the
> > header, so existing code to handle the packet. At least NetBSD does
> > something similar.
> >
> > Rivo
> >
> > diff --git sys/net/if_ethersubr.c sys/net/if_ethersubr.c
> > index 76f6c3147e0..68f5b03b4f4 100644
> > --- sys/net/if_ethersubr.c
> > +++ sys/net/if_ethersubr.c
> > @@ -362,6 +362,22 @@ ether_input(struct ifnet *ifp, struct mbuf *m,
> > void *cookie)
> >
> > etype = ntohs(eh->ether_type);
> >
> > + /*
> > + * 802.1Q header with a tag of 0 can be used to store priority.
> > + */
> > + if (etype == ETHERTYPE_VLAN) {
> > + struct ether_vlan_header *evl = (void *)eh;
> > + if (EVL_VLANOFTAG(evl->evl_tag) == EVL_VLID_NULL) {
> > + etype = ntohs(evl->evl_proto);
> > + m->m_pkthdr.pf.prio = EVL_PRIOFTAG(evl-
> > >evl_tag);
> > + /* IEEE 802.1p has prio 0 and 1 swapped */
> > + if (m->m_pkthdr.pf.prio <= 1)
> > + m->m_pkthdr.pf.prio = !m-
> > >m_pkthdr.pf.prio;
> > + memmove((char *)eh + EVL_ENCAPLEN, eh,
> > sizeof(*eh));
> > + m_adj(m, EVL_ENCAPLEN);
> > + }
> > + }
> > +
> > switch (etype) {
> > case ETHERTYPE_IP:
> > input = ipv4_input;
> >

Reply | Threaded
Open this post in threaded view
|

Re: 802.1q with 0 tag

Tom Smyth
Hello Rivo,

Im not sure what benefit if any this would be,
I have seen both tagged and untagged frames on ports in"general" mode

would it not be better to have the priority set on the DSCP / TOS
ie determining the priority against a field that you know exists...as opposed
as opposed to making priority decisions from a phantom vlan tag with
an id of 0  which may
or may not exist,

when the os / sys admin managing the host  is probably not expecting
this behaviour ?
correct me if im wrong, but are vlan priorities usualy set from reading DSCP
/TOS.
also once the traffic is leaving the switch on an untagged / accessport
would the vlan prioirty be irrelevant, and the IP TOS / DSCP priority be read
by the os just as easily ?

I just dont get the benefit of this

Tom Smyth

On Fri, 12 Oct 2018 at 17:49, Rivo Nurges <[hidden email]> wrote:

>
> Hi!
>
> I'll look into the problems(vlan interface with 0 tag and issues
> priority differeces) you mentioned. I tested your idea of having vlan
> interface without tag and IP on top of physical interface, but IP
> traffic doesn't get picked up by parent.
>
> Extreme(Brocade) SLX does it. Depending on the ingress port
> configuration packets on egress can be with or without dot1q header.
> Seems, it doesn't cause issues with other operating systems.
>
> Rivo
>
> On Fri, 2018-10-12 at 13:38 +1000, David Gwynne wrote:
> > Hi Rivo,
> >
> > vlan(4) can be configured to receive (and send) packets with 0 as the
> > tag on the wire, which this diff will break.
> >
> > I'm pretty confident you can leave an IP configured on the physical
> > network interface, and create and configure a vlan interface on it
> > without setting a VLAN id. The untagged frames should be received as
> > normal on the parent, and the tagged frames with the priority will
> > come in on the vlan interface but still get accepted for IP on the
> > parent.
> >
> > Note that the default priority of packets in the OpenBSD kernel is 3,
> > which might be higher than what you expect an untagged packets
> > priority to be. The default 802.1q priority is 1 iirc.
> >
> > I'm curious as to where you see both tagged and untagged frames at
> > the same time.
> >
> > dlg
> >
> > > On 11 Oct 2018, at 7:20 pm, Rivo Nurges <[hidden email]>
> > > wrote:
> > >
> > > Hi!
> > >
> > > In theory 802.1q header with vlan tag 0 can be used to just signal
> > > priority. Now I'm seeing this in the wild. On a untagged port some
> > > packets are coming with dotq header and some without. Currently we
> > > drop
> > > all the packets with dotq header and vlan tag 0.
> > >
> > > Following patch fixes this by recording the priority and removing
> > > the
> > > header, so existing code to handle the packet. At least NetBSD does
> > > something similar.
> > >
> > > Rivo
> > >
> > > diff --git sys/net/if_ethersubr.c sys/net/if_ethersubr.c
> > > index 76f6c3147e0..68f5b03b4f4 100644
> > > --- sys/net/if_ethersubr.c
> > > +++ sys/net/if_ethersubr.c
> > > @@ -362,6 +362,22 @@ ether_input(struct ifnet *ifp, struct mbuf *m,
> > > void *cookie)
> > >
> > >     etype = ntohs(eh->ether_type);
> > >
> > > +   /*
> > > +    * 802.1Q header with a tag of 0 can be used to store priority.
> > > +    */
> > > +   if (etype == ETHERTYPE_VLAN) {
> > > +           struct ether_vlan_header *evl = (void *)eh;
> > > +           if (EVL_VLANOFTAG(evl->evl_tag) == EVL_VLID_NULL) {
> > > +                   etype = ntohs(evl->evl_proto);
> > > +                   m->m_pkthdr.pf.prio = EVL_PRIOFTAG(evl-
> > > >evl_tag);
> > > +                   /* IEEE 802.1p has prio 0 and 1 swapped */
> > > +                   if (m->m_pkthdr.pf.prio <= 1)
> > > +                           m->m_pkthdr.pf.prio = !m-
> > > >m_pkthdr.pf.prio;
> > > +                   memmove((char *)eh + EVL_ENCAPLEN, eh,
> > > sizeof(*eh));
> > > +                   m_adj(m, EVL_ENCAPLEN);
> > > +           }
> > > +   }
> > > +
> > >     switch (etype) {
> > >     case ETHERTYPE_IP:
> > >             input = ipv4_input;
> > >
>


--
Kindest regards,
Tom Smyth

Mobile: +353 87 6193172
The information contained in this E-mail is intended only for the
confidential use of the named recipient. If the reader of this message
is not the intended recipient or the person responsible for
delivering it to the recipient, you are hereby notified that you have
received this communication in error and that any review,
dissemination or copying of this communication is strictly prohibited.
If you have received this in error, please notify the sender
immediately by telephone at the number above and erase the message
You are requested to carry out your own virus check before
opening any attachment.