Commit f6a66927 authored by Hadar Hen Zion's avatar Hadar Hen Zion Committed by David S. Miller

flow_dissector: Get vlan priority in addition to vlan id

Add vlan priority check to the flow dissector by adding new flow
dissector struct, flow_dissector_key_vlan which includes vlan tag
fields.

vlan_id and flow_label fields were under the same struct
(flow_dissector_key_tags). It was a convenient setting since struct
flow_dissector_key_tags is used by struct flow_keys and by setting
vlan_id and flow_label under the same struct, we get precisely 24 or 48
bytes in flow_keys from flow_dissector_key_basic.

Now, when adding vlan priority support, the code will be cleaner if
flow_label and vlan tag won't be under the same struct anymore.
Signed-off-by: default avatarHadar Hen Zion <hadarh@mellanox.com>
Acked-by: default avatarJiri Pirko <jiri@mellanox.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d5709f7a
...@@ -81,6 +81,7 @@ static inline bool is_vlan_dev(const struct net_device *dev) ...@@ -81,6 +81,7 @@ static inline bool is_vlan_dev(const struct net_device *dev)
#define skb_vlan_tag_present(__skb) ((__skb)->vlan_tci & VLAN_TAG_PRESENT) #define skb_vlan_tag_present(__skb) ((__skb)->vlan_tci & VLAN_TAG_PRESENT)
#define skb_vlan_tag_get(__skb) ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT) #define skb_vlan_tag_get(__skb) ((__skb)->vlan_tci & ~VLAN_TAG_PRESENT)
#define skb_vlan_tag_get_id(__skb) ((__skb)->vlan_tci & VLAN_VID_MASK) #define skb_vlan_tag_get_id(__skb) ((__skb)->vlan_tci & VLAN_VID_MASK)
#define skb_vlan_tag_get_prio(__skb) ((__skb)->vlan_tci & VLAN_PRIO_MASK)
/** /**
* struct vlan_pcpu_stats - VLAN percpu rx/tx stats * struct vlan_pcpu_stats - VLAN percpu rx/tx stats
......
...@@ -32,8 +32,13 @@ struct flow_dissector_key_basic { ...@@ -32,8 +32,13 @@ struct flow_dissector_key_basic {
}; };
struct flow_dissector_key_tags { struct flow_dissector_key_tags {
u32 vlan_id:12, u32 flow_label;
flow_label:20; };
struct flow_dissector_key_vlan {
u16 vlan_id:12,
vlan_priority:3;
u16 padding;
}; };
struct flow_dissector_key_keyid { struct flow_dissector_key_keyid {
...@@ -119,7 +124,7 @@ enum flow_dissector_key_id { ...@@ -119,7 +124,7 @@ enum flow_dissector_key_id {
FLOW_DISSECTOR_KEY_PORTS, /* struct flow_dissector_key_ports */ FLOW_DISSECTOR_KEY_PORTS, /* struct flow_dissector_key_ports */
FLOW_DISSECTOR_KEY_ETH_ADDRS, /* struct flow_dissector_key_eth_addrs */ FLOW_DISSECTOR_KEY_ETH_ADDRS, /* struct flow_dissector_key_eth_addrs */
FLOW_DISSECTOR_KEY_TIPC_ADDRS, /* struct flow_dissector_key_tipc_addrs */ FLOW_DISSECTOR_KEY_TIPC_ADDRS, /* struct flow_dissector_key_tipc_addrs */
FLOW_DISSECTOR_KEY_VLANID, /* struct flow_dissector_key_flow_tags */ FLOW_DISSECTOR_KEY_VLAN, /* struct flow_dissector_key_flow_vlan */
FLOW_DISSECTOR_KEY_FLOW_LABEL, /* struct flow_dissector_key_flow_tags */ FLOW_DISSECTOR_KEY_FLOW_LABEL, /* struct flow_dissector_key_flow_tags */
FLOW_DISSECTOR_KEY_GRE_KEYID, /* struct flow_dissector_key_keyid */ FLOW_DISSECTOR_KEY_GRE_KEYID, /* struct flow_dissector_key_keyid */
FLOW_DISSECTOR_KEY_MPLS_ENTROPY, /* struct flow_dissector_key_keyid */ FLOW_DISSECTOR_KEY_MPLS_ENTROPY, /* struct flow_dissector_key_keyid */
...@@ -148,6 +153,7 @@ struct flow_keys { ...@@ -148,6 +153,7 @@ struct flow_keys {
#define FLOW_KEYS_HASH_START_FIELD basic #define FLOW_KEYS_HASH_START_FIELD basic
struct flow_dissector_key_basic basic; struct flow_dissector_key_basic basic;
struct flow_dissector_key_tags tags; struct flow_dissector_key_tags tags;
struct flow_dissector_key_vlan vlan;
struct flow_dissector_key_keyid keyid; struct flow_dissector_key_keyid keyid;
struct flow_dissector_key_ports ports; struct flow_dissector_key_ports ports;
struct flow_dissector_key_addrs addrs; struct flow_dissector_key_addrs addrs;
......
...@@ -118,6 +118,7 @@ bool __skb_flow_dissect(const struct sk_buff *skb, ...@@ -118,6 +118,7 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
struct flow_dissector_key_addrs *key_addrs; struct flow_dissector_key_addrs *key_addrs;
struct flow_dissector_key_ports *key_ports; struct flow_dissector_key_ports *key_ports;
struct flow_dissector_key_tags *key_tags; struct flow_dissector_key_tags *key_tags;
struct flow_dissector_key_vlan *key_vlan;
struct flow_dissector_key_keyid *key_keyid; struct flow_dissector_key_keyid *key_keyid;
bool skip_vlan = false; bool skip_vlan = false;
u8 ip_proto = 0; u8 ip_proto = 0;
...@@ -266,16 +267,22 @@ bool __skb_flow_dissect(const struct sk_buff *skb, ...@@ -266,16 +267,22 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
skip_vlan = true; skip_vlan = true;
if (dissector_uses_key(flow_dissector, if (dissector_uses_key(flow_dissector,
FLOW_DISSECTOR_KEY_VLANID)) { FLOW_DISSECTOR_KEY_VLAN)) {
key_tags = skb_flow_dissector_target(flow_dissector, key_vlan = skb_flow_dissector_target(flow_dissector,
FLOW_DISSECTOR_KEY_VLANID, FLOW_DISSECTOR_KEY_VLAN,
target_container); target_container);
if (skb_vlan_tag_present(skb)) if (skb_vlan_tag_present(skb)) {
key_tags->vlan_id = skb_vlan_tag_get_id(skb); key_vlan->vlan_id = skb_vlan_tag_get_id(skb);
else key_vlan->vlan_priority =
key_tags->vlan_id = ntohs(vlan->h_vlan_TCI) & (skb_vlan_tag_get_prio(skb) >> VLAN_PRIO_SHIFT);
} else {
key_vlan->vlan_id = ntohs(vlan->h_vlan_TCI) &
VLAN_VID_MASK; VLAN_VID_MASK;
key_vlan->vlan_priority =
(ntohs(vlan->h_vlan_TCI) &
VLAN_PRIO_MASK) >> VLAN_PRIO_SHIFT;
}
} }
goto again; goto again;
...@@ -935,8 +942,8 @@ static const struct flow_dissector_key flow_keys_dissector_keys[] = { ...@@ -935,8 +942,8 @@ static const struct flow_dissector_key flow_keys_dissector_keys[] = {
.offset = offsetof(struct flow_keys, ports), .offset = offsetof(struct flow_keys, ports),
}, },
{ {
.key_id = FLOW_DISSECTOR_KEY_VLANID, .key_id = FLOW_DISSECTOR_KEY_VLAN,
.offset = offsetof(struct flow_keys, tags), .offset = offsetof(struct flow_keys, vlan),
}, },
{ {
.key_id = FLOW_DISSECTOR_KEY_FLOW_LABEL, .key_id = FLOW_DISSECTOR_KEY_FLOW_LABEL,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment