linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fengtiantian <fengtiantian@huawei.com>
To: "David S. Miller" <davem@davemloft.net>,
	"open list:NETWORKING [GENERAL" <netdev@vger.kernel.org>,
	"open list" <linux-kernel@vger.kernel.org>,
	"Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
	"Daniel Borkmann" <daniel@iogearbox.net>,
	"Stanislav Fomichev" <sdf@google.com>,
	"Jiri Pirko" <jiri@mellanox.com>, "Arnd Bergmann" <arnd@arndb.de>,
	"Hadar Hen Zion" <hadarh@mellanox.com>
Cc: "Huangweidong (C)" <weidong.huang@huawei.com>,
	yuehaibing <yuehaibing@huawei.com>
Subject: [patch] flow_dissector:  Fix wrong vlan header offset in __skb_flow_dissect
Date: Wed, 27 May 2020 12:59:52 +0000	[thread overview]
Message-ID: <2A6E6328DF026B458DBF90B38941F981871A42F1@DGGEML523-MBX.china.huawei.com> (raw)

We use the openvswitch 2.7.0 and find the issue when ovs use the skb_get_hash() to get the hash of QinQ skb. Because the
__skb_flow_dissect() get the wrong vlan protocol headers.

Someone report bonding driver has the same issue use the
__skb_flow_dissect() to count hash in bond_xmit_hash:
https://lore.kernel.org/netdev/00a5d09f-a23e-661f-60c0-
75fba6227451@huawei.com/T/.

Because in netif_receive_skb, the skb_network_header points to vlan head, but in dev_hard_start_xmit, the skb_network_header points to IP header. So use the skb_network_offset to get the vlan head is not reliable.

Should we use the skb_mac_offset instead the skb_network_offset to get the vlan head when proto is ETH_P_8021AD or ETH_P_8021Q?

Signed-off-by: Feng tiantian <fengtiantian@huawei.com>
---
 net/core/flow_dissector.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index 415b95f..9a77d5d 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -629,6 +629,13 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
 			 skb->vlan_proto : skb->protocol;
 		nhoff = skb_network_offset(skb);
 		hlen = skb_headlen(skb);
+
+		if (proto == htons(ETH_P_8021AD) ||
+		    proto == htons(ETH_P_8021Q)) {
+			if (skb_mac_header_was_set(skb))
+				nhoff = skb_mac_offset(skb) + ETH_HLEN;
+		}
+
 #if IS_ENABLED(CONFIG_NET_DSA)
 		if (unlikely(skb->dev && netdev_uses_dsa(skb->dev))) {
 			const struct dsa_device_ops *ops;
--
1.8.3.1


                 reply	other threads:[~2020-05-27 13:00 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=2A6E6328DF026B458DBF90B38941F981871A42F1@DGGEML523-MBX.china.huawei.com \
    --to=fengtiantian@huawei.com \
    --cc=arnd@arndb.de \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=hadarh@mellanox.com \
    --cc=jiri@mellanox.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mirq-linux@rere.qmqm.pl \
    --cc=netdev@vger.kernel.org \
    --cc=sdf@google.com \
    --cc=weidong.huang@huawei.com \
    --cc=yuehaibing@huawei.com \
    /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).