From: Govindarajulu Varadarajan <gvaradar@cisco.com>
To: benve@cisco.com, davem@davemloft.net, netdev@vger.kernel.org,
govind.varadar@gmail.com
Cc: Govindarajulu Varadarajan <gvaradar@cisco.com>
Subject: [PATCH net] net: handle 802.1P vlan 0 packets properly
Date: Mon, 10 Jun 2019 07:27:02 -0700 [thread overview]
Message-ID: <20190610142702.2698-1-gvaradar@cisco.com> (raw)
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.
Signed-off-by: Govindarajulu Varadarajan <gvaradar@cisco.com>
---
net/8021q/vlan_core.c | 24 +++++++++++++++++++++---
1 file changed, 21 insertions(+), 3 deletions(-)
diff --git a/net/8021q/vlan_core.c b/net/8021q/vlan_core.c
index a313165e7a67..0cde54c02c3f 100644
--- a/net/8021q/vlan_core.c
+++ b/net/8021q/vlan_core.c
@@ -9,14 +9,32 @@
bool vlan_do_receive(struct sk_buff **skbp)
{
struct sk_buff *skb = *skbp;
- __be16 vlan_proto = skb->vlan_proto;
- u16 vlan_id = skb_vlan_tag_get_id(skb);
+ __be16 vlan_proto;
+ u16 vlan_id;
struct net_device *vlan_dev;
struct vlan_pcpu_stats *rx_stats;
+again:
+ vlan_proto = skb->vlan_proto;
+ vlan_id = skb_vlan_tag_get_id(skb);
vlan_dev = vlan_find_dev(skb->dev, vlan_proto, vlan_id);
- if (!vlan_dev)
+ if (!vlan_dev) {
+ /* Incase of 802.1P header with vlan id 0, continue if
+ * vlan_dev is not found.
+ */
+ if (unlikely(!vlan_id)) {
+ __vlan_hwaccel_clear_tag(skb);
+ if (skb->protocol == cpu_to_be16(ETH_P_8021Q) ||
+ skb->protocol == cpu_to_be16(ETH_P_8021AD)) {
+ skb = skb_vlan_untag(skb);
+ *skbp = skb;
+ if (unlikely(!skb))
+ return false;
+ goto again;
+ }
+ }
return false;
+ }
skb = *skbp = skb_share_check(skb, GFP_ATOMIC);
if (unlikely(!skb))
--
2.22.0
next reply other threads:[~2019-06-10 21:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-10 14:27 Govindarajulu Varadarajan [this message]
2019-06-10 21:28 ` [PATCH net] net: handle 802.1P vlan 0 packets properly David Miller
2019-06-10 23:08 ` Stephen Suryaputra
2019-06-11 0:35 ` Christian Benvenuti (benve)
2019-06-11 1:20 ` David Miller
2019-06-10 23:09 ` Govindarajulu Varadarajan (gvaradar)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190610142702.2698-1-gvaradar@cisco.com \
--to=gvaradar@cisco.com \
--cc=benve@cisco.com \
--cc=davem@davemloft.net \
--cc=govind.varadar@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).