flow_dissector: Add flag to stop parsing at L3
authorTom Herbert <tom@herbertland.com>
Tue, 1 Sep 2015 16:24:30 +0000 (09:24 -0700)
committerDavid S. Miller <davem@davemloft.net>
Tue, 1 Sep 2015 22:06:23 +0000 (15:06 -0700)
Add an input flag to flow dissector on rather dissection should be
stopped when an L3 packet is encountered. This would be useful if a
caller just wanted to get IP addresses of the outermost header (e.g.
to do an L3 hash).

Signed-off-by: Tom Herbert <tom@herbertland.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/flow_dissector.h
net/core/flow_dissector.c

index 34102270b0862af9fffd3f4a8b92b3179681931c..bb81e3b576e709272a40efd0948de44915f7bce3 100644 (file)
@@ -125,6 +125,7 @@ enum flow_dissector_key_id {
 };
 
 #define FLOW_DISSECTOR_F_PARSE_1ST_FRAG                BIT(0)
+#define FLOW_DISSECTOR_F_STOP_AT_L3            BIT(1)
 
 struct flow_dissector_key {
        enum flow_dissector_key_id key_id;
index 907de2f68b1fca7dc4b298f8f55f7b7570548d0c..94fd841f341f16fd0d4476ee52f28bfde29909dc 100644 (file)
@@ -200,6 +200,9 @@ ip:
                        }
                }
 
+               if (flags & FLOW_DISSECTOR_F_STOP_AT_L3)
+                       goto out_good;
+
                break;
        }
        case htons(ETH_P_IPV6): {
@@ -238,6 +241,9 @@ ipv6:
                        }
                }
 
+               if (flags & FLOW_DISSECTOR_F_STOP_AT_L3)
+                       goto out_good;
+
                break;
        }
        case htons(ETH_P_8021AD):