From: Hadar Hen Zion <hadarh@mellanox.com>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Jiri Pirko <jiri@mellanox.com>,
Amir Vadai <amirva@mellanox.com>,
Or Gerlitz <ogerlitz@mellanox.com>,
Tom Herbert <tom@herbertland.com>,
Hadar Hen Zion <hadarh@mellanox.com>
Subject: [PATCH net-next V2 1/5] flow_dissector: For stripped vlan, get vlan info from skb->vlan_tci
Date: Wed, 17 Aug 2016 13:36:10 +0300 [thread overview]
Message-ID: <1471430174-27740-2-git-send-email-hadarh@mellanox.com> (raw)
In-Reply-To: <1471430174-27740-1-git-send-email-hadarh@mellanox.com>
Early in the datapath skb_vlan_untag function is called, stripped
the vlan from the skb and set skb->vlan_tci and skb->vlan_proto fields.
The current dissection doesn't handle stripped vlan packets correctly.
In some flows, vlan doesn't exist in skb->data anymore when applying
flow dissection on the skb, fix that.
In case vlan info wasn't stripped before applying flow_dissector (RPS
flow for example), or in case of skb with multiple vlans (e.g. 802.1ad),
get the vlan info from skb->data. The flow_dissector correctly skips
any number of vlans and stores only the first level vlan.
Fixes: 0744dd00c1b1 ('net: introduce skb_flow_dissect()')
Signed-off-by: Hadar Hen Zion <hadarh@mellanox.com>
---
net/core/flow_dissector.c | 34 ++++++++++++++++++++++++++--------
1 file changed, 26 insertions(+), 8 deletions(-)
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index 91028ae..362d693 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -119,12 +119,14 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
struct flow_dissector_key_ports *key_ports;
struct flow_dissector_key_tags *key_tags;
struct flow_dissector_key_keyid *key_keyid;
+ bool skip_vlan = false;
u8 ip_proto = 0;
bool ret = false;
if (!data) {
data = skb->data;
- proto = skb->protocol;
+ proto = skb_vlan_tag_present(skb) ?
+ skb->vlan_proto : skb->protocol;
nhoff = skb_network_offset(skb);
hlen = skb_headlen(skb);
}
@@ -243,23 +245,39 @@ ipv6:
case htons(ETH_P_8021AD):
case htons(ETH_P_8021Q): {
const struct vlan_hdr *vlan;
- struct vlan_hdr _vlan;
- vlan = __skb_header_pointer(skb, nhoff, sizeof(_vlan), data, hlen, &_vlan);
- if (!vlan)
- goto out_bad;
+ if (skb_vlan_tag_present(skb))
+ proto = skb->protocol;
+
+ if (!skb_vlan_tag_present(skb) ||
+ proto == cpu_to_be16(ETH_P_8021Q) ||
+ proto == cpu_to_be16(ETH_P_8021AD)) {
+ struct vlan_hdr _vlan;
+
+ vlan = __skb_header_pointer(skb, nhoff, sizeof(_vlan),
+ data, hlen, &_vlan);
+ if (!vlan)
+ goto out_bad;
+ proto = vlan->h_vlan_encapsulated_proto;
+ nhoff += sizeof(*vlan);
+ if (skip_vlan)
+ goto again;
+ }
+ skip_vlan = true;
if (dissector_uses_key(flow_dissector,
FLOW_DISSECTOR_KEY_VLANID)) {
key_tags = skb_flow_dissector_target(flow_dissector,
FLOW_DISSECTOR_KEY_VLANID,
target_container);
- key_tags->vlan_id = skb_vlan_tag_get_id(skb);
+ if (skb_vlan_tag_present(skb))
+ key_tags->vlan_id = skb_vlan_tag_get_id(skb);
+ else
+ key_tags->vlan_id = ntohs(vlan->h_vlan_TCI) &
+ VLAN_VID_MASK;
}
- proto = vlan->h_vlan_encapsulated_proto;
- nhoff += sizeof(*vlan);
goto again;
}
case htons(ETH_P_PPP_SES): {
--
1.8.3.1
next prev parent reply other threads:[~2016-08-17 10:37 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-17 10:36 [PATCH net-next V2 0/5] net_sched, flow_dissector, flower: Introduce vlan tag support Hadar Hen Zion
2016-08-17 10:36 ` Hadar Hen Zion [this message]
2016-08-17 10:46 ` [PATCH net-next V2 1/5] flow_dissector: For stripped vlan, get vlan info from skb->vlan_tci Jiri Pirko
2016-08-17 11:05 ` Hadar Hen Zion
2016-08-17 13:02 ` Jiri Pirko
2016-08-18 6:22 ` Hadar Hen Zion
2016-08-18 6:46 ` Jiri Pirko
2016-08-18 7:24 ` Jiri Pirko
2016-08-17 10:36 ` [PATCH net-next V2 2/5] flow_dissector: Get vlan priority in addition to vlan id Hadar Hen Zion
2016-08-18 7:25 ` Jiri Pirko
2016-08-17 10:36 ` [PATCH net-next V2 3/5] net_sched: flower: Avoid dissection of unmasked keys Hadar Hen Zion
2016-08-17 10:36 ` [PATCH net-next V2 4/5] net_sched: flower: Add vlan support Hadar Hen Zion
2016-08-17 10:36 ` [PATCH net-next V2 5/5] net_sched: act_vlan: Add priority option Hadar Hen Zion
2016-08-19 6:14 ` [PATCH net-next V2 0/5] net_sched, flow_dissector, flower: Introduce vlan tag support David Miller
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=1471430174-27740-2-git-send-email-hadarh@mellanox.com \
--to=hadarh@mellanox.com \
--cc=amirva@mellanox.com \
--cc=davem@davemloft.net \
--cc=jiri@mellanox.com \
--cc=netdev@vger.kernel.org \
--cc=ogerlitz@mellanox.com \
--cc=tom@herbertland.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.