Skip to content

Commit

Permalink
flow_dissector: Add control/reporting of fragmentation
Browse files Browse the repository at this point in the history
Add an input flag to flow dissector on rather dissection should be
attempted on a first fragment. Also add key_control flags to indicate
that a packet is a fragment or first fragment.

Signed-off-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
tomratbert authored and davem330 committed Sep 1, 2015
1 parent cd79a23 commit 807e165
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 4 additions & 0 deletions include/net/flow_dissector.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
struct flow_dissector_key_control {
u16 thoff;
u16 addr_type;
u32 is_fragment:1;
u32 first_frag:1;
};

/**
Expand Down Expand Up @@ -122,6 +124,8 @@ enum flow_dissector_key_id {
FLOW_DISSECTOR_KEY_MAX,
};

#define FLOW_DISSECTOR_F_PARSE_1ST_FRAG BIT(0)

struct flow_dissector_key {
enum flow_dissector_key_id key_id;
size_t offset; /* offset of struct flow_dissector_key_*
Expand Down
15 changes: 13 additions & 2 deletions net/core/flow_dissector.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
nhoff += iph->ihl * 4;

ip_proto = iph->protocol;
if (ip_is_fragment(iph))
ip_proto = 0;

if (!skb_flow_dissector_uses_key(flow_dissector,
FLOW_DISSECTOR_KEY_IPV4_ADDRS))
Expand All @@ -189,6 +187,19 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
memcpy(&key_addrs->v4addrs, &iph->saddr,
sizeof(key_addrs->v4addrs));
key_control->addr_type = FLOW_DISSECTOR_KEY_IPV4_ADDRS;

if (ip_is_fragment(iph)) {
key_control->is_fragment = 1;

if (iph->frag_off & htons(IP_OFFSET)) {
goto out_good;
} else {
key_control->first_frag = 1;
if (!(flags & FLOW_DISSECTOR_F_PARSE_1ST_FRAG))
goto out_good;
}
}

break;
}
case htons(ETH_P_IPV6): {
Expand Down

0 comments on commit 807e165

Please sign in to comment.