Skip to content

Commit

Permalink
flow_dissector: Add control/reporting of encapsulation
Browse files Browse the repository at this point in the history
Add an input flag to flow dissector on rather dissection should stop
when encapsulation is detected (IP/IP or GRE). Also, add a key_control
flag that indicates encapsulation was encountered during the
dissection.

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 872b1ab commit 823b969
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
2 changes: 2 additions & 0 deletions include/net/flow_dissector.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ struct flow_dissector_key_control {
u16 addr_type;
u32 is_fragment:1;
u32 first_frag:1;
u32 encapsulation:1;
};

/**
Expand Down Expand Up @@ -127,6 +128,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)
#define FLOW_DISSECTOR_F_STOP_AT_ENCAP BIT(3)

struct flow_dissector_key {
enum flow_dissector_key_id key_id;
Expand Down
15 changes: 15 additions & 0 deletions net/core/flow_dissector.c
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,11 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
proto = eth->h_proto;
nhoff += sizeof(*eth);
}

key_control->encapsulation = 1;
if (flags & FLOW_DISSECTOR_F_STOP_AT_ENCAP)
goto out_good;

goto again;
}
case NEXTHDR_HOP:
Expand Down Expand Up @@ -444,9 +449,19 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
}
case IPPROTO_IPIP:
proto = htons(ETH_P_IP);

key_control->encapsulation = 1;
if (flags & FLOW_DISSECTOR_F_STOP_AT_ENCAP)
goto out_good;

goto ip;
case IPPROTO_IPV6:
proto = htons(ETH_P_IPV6);

key_control->encapsulation = 1;
if (flags & FLOW_DISSECTOR_F_STOP_AT_ENCAP)
goto out_good;

goto ipv6;
case IPPROTO_MPLS:
proto = htons(ETH_P_MPLS_UC);
Expand Down

0 comments on commit 823b969

Please sign in to comment.