Skip to content

Commit

Permalink
flow_dissector: Add flag to stop parsing when an IPv6 flow label is seen
Browse files Browse the repository at this point in the history
Add an input flag to flow dissector on rather dissection should be
stopped when a flow label is encountered. Presumably, the flow label
is derived from a sufficient hash of an inner transport packet so
further dissection is not needed (that is ports are not included in
the flow hash). Using the flow label instead of ports has the additional
benefit that packet fragments should hash to same value as non-fragments
for a flow (assuming that the same flow label is used).

We set this flag by default in for skb_get_hash.

Signed-off-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Tom Herbert authored and David S. Miller committed Sep 1, 2015
1 parent 8306b68 commit 872b1ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions include/net/flow_dissector.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ enum flow_dissector_key_id {

#define FLOW_DISSECTOR_F_PARSE_1ST_FRAG BIT(0)
#define FLOW_DISSECTOR_F_STOP_AT_L3 BIT(1)
#define FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL BIT(2)

struct flow_dissector_key {
enum flow_dissector_key_id key_id;
Expand Down
5 changes: 4 additions & 1 deletion net/core/flow_dissector.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
target_container);
key_tags->flow_label = ntohl(flow_label);
}
if (flags & FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL)
goto out_good;
}

if (flags & FLOW_DISSECTOR_F_STOP_AT_L3)
Expand Down Expand Up @@ -599,7 +601,8 @@ EXPORT_SYMBOL(flow_hash_from_keys);
static inline u32 ___skb_get_hash(const struct sk_buff *skb,
struct flow_keys *keys, u32 keyval)
{
if (!skb_flow_dissect_flow_keys(skb, keys, 0))
if (!skb_flow_dissect_flow_keys(skb, keys,
FLOW_DISSECTOR_F_STOP_AT_FLOW_LABEL))
return 0;

return __flow_hash_from_keys(keys, keyval);
Expand Down

0 comments on commit 872b1ab

Please sign in to comment.