net: sched: cls_flower: use flow_dissector for ingress ifindex
authorJiri Pirko <jiri@mellanox.com>
Wed, 19 Jun 2019 06:41:03 +0000 (09:41 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 19 Jun 2019 14:09:22 +0000 (10:09 -0400)
Use previously introduced infra to obtain and store ingress ifindex
instead doing it locally.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: Ido Schimmel <idosch@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/sched/cls_flower.c

index bd1767da83535859a686ba1d08ef1d65a312c21c..ce2e9b1c985034d1565029626bee286014a052f4 100644 (file)
@@ -27,7 +27,7 @@
 #include <net/dst_metadata.h>
 
 struct fl_flow_key {
-       int     indev_ifindex;
+       struct flow_dissector_key_meta meta;
        struct flow_dissector_key_control control;
        struct flow_dissector_key_control enc_control;
        struct flow_dissector_key_basic basic;
@@ -284,7 +284,7 @@ static int fl_classify(struct sk_buff *skb, const struct tcf_proto *tp,
        list_for_each_entry_rcu(mask, &head->masks, list) {
                fl_clear_masked_range(&skb_key, mask);
 
-               skb_key.indev_ifindex = skb->skb_iif;
+               skb_flow_dissect_meta(skb, &mask->dissector, &skb_key);
                /* skb_flow_dissect() does not set n_proto in case an unknown
                 * protocol, so do it rather here.
                 */
@@ -1026,8 +1026,8 @@ static int fl_set_key(struct net *net, struct nlattr **tb,
                int err = tcf_change_indev(net, tb[TCA_FLOWER_INDEV], extack);
                if (err < 0)
                        return err;
-               key->indev_ifindex = err;
-               mask->indev_ifindex = 0xffffffff;
+               key->meta.ingress_ifindex = err;
+               mask->meta.ingress_ifindex = 0xffffffff;
        }
 
        fl_set_key_val(tb, key->eth.dst, TCA_FLOWER_KEY_ETH_DST,
@@ -1281,6 +1281,8 @@ static void fl_init_dissector(struct flow_dissector *dissector,
        struct flow_dissector_key keys[FLOW_DISSECTOR_KEY_MAX];
        size_t cnt = 0;
 
+       FL_KEY_SET_IF_MASKED(mask, keys, cnt,
+                            FLOW_DISSECTOR_KEY_META, meta);
        FL_KEY_SET(keys, cnt, FLOW_DISSECTOR_KEY_CONTROL, control);
        FL_KEY_SET(keys, cnt, FLOW_DISSECTOR_KEY_BASIC, basic);
        FL_KEY_SET_IF_MASKED(mask, keys, cnt,
@@ -2122,10 +2124,10 @@ static int fl_dump_key_enc_opt(struct sk_buff *skb,
 static int fl_dump_key(struct sk_buff *skb, struct net *net,
                       struct fl_flow_key *key, struct fl_flow_key *mask)
 {
-       if (mask->indev_ifindex) {
+       if (mask->meta.ingress_ifindex) {
                struct net_device *dev;
 
-               dev = __dev_get_by_index(net, key->indev_ifindex);
+               dev = __dev_get_by_index(net, key->meta.ingress_ifindex);
                if (dev && nla_put_string(skb, TCA_FLOWER_INDEV, dev->name))
                        goto nla_put_failure;
        }