forked from Minki/linux
net_sched: flower: Avoid dissection of unmasked keys
The current flower implementation checks the mask range and set all the
keys included in that range as "used_keys", even if a specific key in
the range has a zero mask.
This behavior can cause a false positive return value of
dissector_uses_key function and unnecessary dissection in
__skb_flow_dissect.
This patch checks explicitly the mask of each key and "used_keys" will
be set accordingly.
Fixes: 77b9900ef5
('tc: introduce Flower classifier')
Signed-off-by: Hadar Hen Zion <hadarh@mellanox.com>
Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
f6a6692769
commit
339ba878cf
@ -404,12 +404,10 @@ static int fl_init_hashtable(struct cls_fl_head *head,
|
|||||||
|
|
||||||
#define FL_KEY_MEMBER_OFFSET(member) offsetof(struct fl_flow_key, member)
|
#define FL_KEY_MEMBER_OFFSET(member) offsetof(struct fl_flow_key, member)
|
||||||
#define FL_KEY_MEMBER_SIZE(member) (sizeof(((struct fl_flow_key *) 0)->member))
|
#define FL_KEY_MEMBER_SIZE(member) (sizeof(((struct fl_flow_key *) 0)->member))
|
||||||
#define FL_KEY_MEMBER_END_OFFSET(member) \
|
|
||||||
(FL_KEY_MEMBER_OFFSET(member) + FL_KEY_MEMBER_SIZE(member))
|
|
||||||
|
|
||||||
#define FL_KEY_IN_RANGE(mask, member) \
|
#define FL_KEY_IS_MASKED(mask, member) \
|
||||||
(FL_KEY_MEMBER_OFFSET(member) <= (mask)->range.end && \
|
memchr_inv(((char *)mask) + FL_KEY_MEMBER_OFFSET(member), \
|
||||||
FL_KEY_MEMBER_END_OFFSET(member) >= (mask)->range.start)
|
0, FL_KEY_MEMBER_SIZE(member)) \
|
||||||
|
|
||||||
#define FL_KEY_SET(keys, cnt, id, member) \
|
#define FL_KEY_SET(keys, cnt, id, member) \
|
||||||
do { \
|
do { \
|
||||||
@ -418,9 +416,9 @@ static int fl_init_hashtable(struct cls_fl_head *head,
|
|||||||
cnt++; \
|
cnt++; \
|
||||||
} while(0);
|
} while(0);
|
||||||
|
|
||||||
#define FL_KEY_SET_IF_IN_RANGE(mask, keys, cnt, id, member) \
|
#define FL_KEY_SET_IF_MASKED(mask, keys, cnt, id, member) \
|
||||||
do { \
|
do { \
|
||||||
if (FL_KEY_IN_RANGE(mask, member)) \
|
if (FL_KEY_IS_MASKED(mask, member)) \
|
||||||
FL_KEY_SET(keys, cnt, id, member); \
|
FL_KEY_SET(keys, cnt, id, member); \
|
||||||
} while(0);
|
} while(0);
|
||||||
|
|
||||||
@ -432,14 +430,14 @@ static void fl_init_dissector(struct cls_fl_head *head,
|
|||||||
|
|
||||||
FL_KEY_SET(keys, cnt, FLOW_DISSECTOR_KEY_CONTROL, control);
|
FL_KEY_SET(keys, cnt, FLOW_DISSECTOR_KEY_CONTROL, control);
|
||||||
FL_KEY_SET(keys, cnt, FLOW_DISSECTOR_KEY_BASIC, basic);
|
FL_KEY_SET(keys, cnt, FLOW_DISSECTOR_KEY_BASIC, basic);
|
||||||
FL_KEY_SET_IF_IN_RANGE(mask, keys, cnt,
|
FL_KEY_SET_IF_MASKED(&mask->key, keys, cnt,
|
||||||
FLOW_DISSECTOR_KEY_ETH_ADDRS, eth);
|
FLOW_DISSECTOR_KEY_ETH_ADDRS, eth);
|
||||||
FL_KEY_SET_IF_IN_RANGE(mask, keys, cnt,
|
FL_KEY_SET_IF_MASKED(&mask->key, keys, cnt,
|
||||||
FLOW_DISSECTOR_KEY_IPV4_ADDRS, ipv4);
|
FLOW_DISSECTOR_KEY_IPV4_ADDRS, ipv4);
|
||||||
FL_KEY_SET_IF_IN_RANGE(mask, keys, cnt,
|
FL_KEY_SET_IF_MASKED(&mask->key, keys, cnt,
|
||||||
FLOW_DISSECTOR_KEY_IPV6_ADDRS, ipv6);
|
FLOW_DISSECTOR_KEY_IPV6_ADDRS, ipv6);
|
||||||
FL_KEY_SET_IF_IN_RANGE(mask, keys, cnt,
|
FL_KEY_SET_IF_MASKED(&mask->key, keys, cnt,
|
||||||
FLOW_DISSECTOR_KEY_PORTS, tp);
|
FLOW_DISSECTOR_KEY_PORTS, tp);
|
||||||
|
|
||||||
skb_flow_dissector_init(&head->dissector, keys, cnt);
|
skb_flow_dissector_init(&head->dissector, keys, cnt);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user