net: ethernet: Properly handle VLAN tag 0
Packets are forwarded to the native interface or in other words, the vlan header is simply stripped and ignored. This feature is called 'priority tagging'. Signed-off-by: Cla Mattia Galliard <cla-mattia.galliard@zuehlke.com> Signed-off-by: Jukka Rissanen <jukka.rissanen@nordicsemi.no>
This commit is contained in:
parent
638a696b7b
commit
594fa24199
3 changed files with 17 additions and 8 deletions
|
|
@ -31,6 +31,9 @@ extern "C" {
|
|||
/** Unspecified VLAN tag value */
|
||||
#define NET_VLAN_TAG_UNSPEC 0x0fff
|
||||
|
||||
/** VLAN ID for forwarding to the native interface (priority tagging) */
|
||||
#define NET_VLAN_TAG_PRIORITY 0x0000
|
||||
|
||||
/**
|
||||
* @brief Get VLAN identifier from TCI.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -298,14 +298,16 @@ static enum net_verdict ethernet_recv(struct net_if *iface,
|
|||
goto drop;
|
||||
}
|
||||
|
||||
/* We could call VLAN interface directly but then the
|
||||
* interface statistics would not get updated so route
|
||||
* the call via Virtual L2 layer.
|
||||
*/
|
||||
if (net_if_l2(net_pkt_iface(pkt))->recv != NULL) {
|
||||
verdict = net_if_l2(net_pkt_iface(pkt))->recv(iface, pkt);
|
||||
if (verdict == NET_DROP) {
|
||||
goto drop;
|
||||
if (net_pkt_vlan_tag(pkt) != NET_VLAN_TAG_PRIORITY) {
|
||||
/* We could call VLAN interface directly but then the
|
||||
* interface statistics would not get updated so route
|
||||
* the call via Virtual L2 layer.
|
||||
*/
|
||||
if (net_if_l2(net_pkt_iface(pkt))->recv != NULL) {
|
||||
verdict = net_if_l2(net_pkt_iface(pkt))->recv(iface, pkt);
|
||||
if (verdict == NET_DROP) {
|
||||
goto drop;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,6 +214,10 @@ struct net_if *net_eth_get_vlan_iface(struct net_if *iface, uint16_t tag)
|
|||
|
||||
ctx = get_vlan(iface, tag);
|
||||
if (ctx == NULL) {
|
||||
if (tag == NET_VLAN_TAG_PRIORITY) {
|
||||
return iface;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue