net: handle 802.1P vlan 0 packets properly
Subsystems (2)
PATCH v2 1/1 net: handle 802.1P vlan 0 packets properly
When stack receives pkt: [802.1P vlan 0][802.1AD vlan 100][IPv4], vlan_do_receive() returns false if it does not find vlan_dev. Later __netif_receive_skb_core() fails to find packet type handler for skb->protocol 801.1AD and drops the packet.
801.1P header with vlan id 0 should be handled as untagged packets. This patch fixes it by checking if vlan_id is 0 and processes next vlan header.
---
v2: Move the check out of vlan_do_receive() to
__netif_receive_skb_core(). This way, we do not change the behaviour when rx_handler is registered. i.e do not strip off 802.1P header when bridge (or rx_handler) is registered.
Previous discussions:
http://patchwork.ozlabs.org/patch/1113413/
http://patchwork.ozlabs.org/patch/1113347/
net/core/dev.c | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-)
net/core/dev.c +29 -1
@@ -4923,8 +4923,36 @@ static int __netif_receive_skb_core(struct sk_buff *skb, bool pfmemalloc, }if (unlikely (skb_vlan_tag_present (skb))) { -if (skb_vlan_tag_get_id (skb)) +check_vlan_id: +if (skb_vlan_tag_get_id (skb)) { +/* Vlan id is non 0 and vlan_do_receive() above couldn't +* find vlan device. +*/ skb->pkt_type =PACKET_OTHERHOST ; + }else if (skb->protocol ==cpu_to_be16 (ETH_P_8021Q ) || + skb->protocol ==cpu_to_be16 (ETH_P_8021AD )) { +/* Outer header is 802.1P with vlan 0, inner header is +* 802.1Q or 802.1AD and vlan_do_receive() above could +* not find vlan dev for vlan id 0. +*/ +__vlan_hwaccel_clear_tag (skb); + skb =skb_vlan_untag (skb); +if (unlikely (!skb)) + goto out; +if (vlan_do_receive (&skb)) +/* After stripping off 802.1P header with vlan 0 +* vlan dev is found for inner header. +*/ + goto another_round; +else if (unlikely (!skb)) + goto out; +else +/* We have stripped outer 802.1P vlan 0 header. +* But could not find vlan dev. +* check again for vlan id to set OTHERHOST. +*/ + goto check_vlan_id; + }/* Note: we might in the future use prio bits * and set skb->priority like in vlan_do_receive() * For the time being, just ignore Priority Code Point
Signature · 1 line
2.22.0
David Miller
maintainerFrom: Govindarajulu Varadarajan <[email protected]>
Date: Fri, 14 Jun 2019 06:13:54 -0700
Quoted 16 lines
When stack receives pkt: [802.1P vlan 0][802.1AD vlan 100][IPv4],
vlan_do_receive()returns false if it does not findvlan_dev. Later__netif_receive_skb_core()fails to find packet type handler forskb->protocol801.1AD and drops the packet.801.1P header with vlan id 0 should be handled as untagged packets. This patch fixes it by checking if
vlan_idis 0 and processes next vlan header.Signed-off-by Govindarajulu Varadarajan <[email protected]>---
v2: Move the check out ofvlan_do_receive()to
__netif_receive_skb_core(). This way, we do not change the behaviour whenrx_handleris registered. i.e do not strip off 802.1P header when bridge (orrx_handler) is registered.
Quoted 3 lines
Previous discussions:
http://patchwork.ozlabs.org/patch/1113413/
http://patchwork.ozlabs.org/patch/1113347/
Looks good, applied, thanks.