netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tom Herbert <tom@herbertland.com>
To: <davem@davemloft.net>, <netdev@vger.kernel.org>
Cc: <kernel-team@fb.com>
Subject: [PATCH net-next 06/11] flow_dissector: Add control/reporting of fragmentation
Date: Tue, 1 Sep 2015 09:24:28 -0700	[thread overview]
Message-ID: <1441124673-3438470-7-git-send-email-tom@herbertland.com> (raw)
In-Reply-To: <1441124673-3438470-1-git-send-email-tom@herbertland.com>

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>
---
 include/net/flow_dissector.h |  4 ++++
 net/core/flow_dissector.c    | 15 +++++++++++++--
 2 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/include/net/flow_dissector.h b/include/net/flow_dissector.h
index 74fe160..3410227 100644
--- a/include/net/flow_dissector.h
+++ b/include/net/flow_dissector.h
@@ -12,6 +12,8 @@
 struct flow_dissector_key_control {
 	u16	thoff;
 	u16	addr_type;
+	u32	is_fragment:1;
+	u32	first_frag:1;
 };
 
 /**
@@ -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_*
diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c
index c3d9807..7536a46 100644
--- a/net/core/flow_dissector.c
+++ b/net/core/flow_dissector.c
@@ -177,8 +177,6 @@ ip:
 		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))
@@ -189,6 +187,19 @@ ip:
 		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): {
-- 
1.8.1

  parent reply	other threads:[~2015-09-01 16:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-01 16:24 [PATCH net-next 00/11] flow_dissector: Paramterize dissection and other features Tom Herbert
2015-09-01 16:24 ` [PATCH net-next 01/11] flow_dissector: Move skb related functions to skbuff.h Tom Herbert
2015-09-01 16:24 ` [PATCH net-next 02/11] skbuff: Make __skb_set_sw_hash a general function Tom Herbert
2015-09-01 16:24 ` [PATCH net-next 03/11] flowi: Abstract out functions to get flow hash based on flowi Tom Herbert
2015-09-01 16:24 ` [PATCH net-next 04/11] flow_dissector: Jump to exit code in __skb_flow_dissect Tom Herbert
2015-09-01 16:24 ` [PATCH net-next 05/11] flow_dissector: Add flags argument to skb_flow_dissector functions Tom Herbert
2015-09-01 16:24 ` Tom Herbert [this message]
2015-09-01 16:24 ` [PATCH net-next 07/11] flow_dissector: Support IPv6 fragment header Tom Herbert
2015-09-01 16:24 ` [PATCH net-next 08/11] flow_dissector: Add flag to stop parsing at L3 Tom Herbert
2015-09-01 16:24 ` [PATCH net-next 09/11] flow_dissector: Add flag to stop parsing when an IPv6 flow label is seen Tom Herbert
2015-09-01 16:24 ` [PATCH net-next 10/11] flow_dissector: Add control/reporting of encapsulation Tom Herbert
2015-09-01 16:24 ` [PATCH net-next 11/11] flow_dissector: Ignore flow dissector return value from ___skb_get_hash Tom Herbert
2015-09-01 22:22 ` [PATCH net-next 00/11] flow_dissector: Paramterize dissection and other features David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1441124673-3438470-7-git-send-email-tom@herbertland.com \
    --to=tom@herbertland.com \
    --cc=davem@davemloft.net \
    --cc=kernel-team@fb.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).