flow_dissector: dissect tunnel info outside __skb_flow_dissect()
authorSimon Horman <simon.horman@netronome.com>
Mon, 4 Dec 2017 10:31:48 +0000 (11:31 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 5 Dec 2017 17:09:18 +0000 (12:09 -0500)
Move dissection of tunnel info to outside of the main flow dissection
function, __skb_flow_dissect(). The sole user of this feature, the flower
classifier, is updated to call tunnel info dissection directly, using
skb_flow_dissect_tunnel_info().

This results in a slightly less complex implementation of
__skb_flow_dissect(), in particular removing logic from that call path
which is not used by the majority of users. The expense of this is borne by
the flower classifier which now has to make an extra call for tunnel info
dissection.

This patch should not result in any behavioural change.

Signed-off-by: Simon Horman <simon.horman@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/linux/skbuff.h
net/core/flow_dissector.c
net/sched/cls_flower.c

index a38c80e9f91efee011f22bc4e6755f3e4d85ff69..b8e0da6c27d6a48d4489992e26ab54cce8482830 100644 (file)
@@ -1211,6 +1211,11 @@ static inline bool skb_flow_dissect_flow_keys_buf(struct flow_keys *flow,
                                  data, proto, nhoff, hlen, flags);
 }
 
+void
+skb_flow_dissect_tunnel_info(const struct sk_buff *skb,
+                            struct flow_dissector *flow_dissector,
+                            void *target_container);
+
 static inline __u32 skb_get_hash(struct sk_buff *skb)
 {
        if (!skb->l4_hash && !skb->sw_hash)
index 15ce300637650e17fcab7e378b20fe7972686d46..cc75488d3653710894ba6ce3846d9ca4e4712298 100644 (file)
@@ -133,10 +133,10 @@ skb_flow_dissect_set_enc_addr_type(enum flow_dissector_key_id type,
        ctrl->addr_type = type;
 }
 
-static void
-__skb_flow_dissect_tunnel_info(const struct sk_buff *skb,
-                              struct flow_dissector *flow_dissector,
-                              void *target_container)
+void
+skb_flow_dissect_tunnel_info(const struct sk_buff *skb,
+                            struct flow_dissector *flow_dissector,
+                            void *target_container)
 {
        struct ip_tunnel_info *info;
        struct ip_tunnel_key *key;
@@ -212,6 +212,7 @@ __skb_flow_dissect_tunnel_info(const struct sk_buff *skb,
                tp->dst = key->tp_dst;
        }
 }
+EXPORT_SYMBOL(skb_flow_dissect_tunnel_info);
 
 static enum flow_dissect_ret
 __skb_flow_dissect_mpls(const struct sk_buff *skb,
@@ -576,9 +577,6 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
                                              FLOW_DISSECTOR_KEY_BASIC,
                                              target_container);
 
-       __skb_flow_dissect_tunnel_info(skb, flow_dissector,
-                                      target_container);
-
        if (dissector_uses_key(flow_dissector,
                               FLOW_DISSECTOR_KEY_ETH_ADDRS)) {
                struct ethhdr *eth = eth_hdr(skb);
index 543a3e875d05b17814d8cffa3276d0809b2da1b2..6132a7317efafd8ce6dbf7735f126207eeeaa241 100644 (file)
@@ -166,6 +166,7 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp,
         * so do it rather here.
         */
        skb_key.basic.n_proto = skb->protocol;
+       skb_flow_dissect_tunnel_info(skb, &head->dissector, &skb_key);
        skb_flow_dissect(skb, &head->dissector, &skb_key, 0);
 
        fl_set_masked_key(&skb_mkey, &skb_key, &head->mask);