]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
net: sched: remove tcf_proto from ematch calls
authorJohn Fastabend <john.fastabend@gmail.com>
Mon, 6 Oct 2014 04:27:53 +0000 (21:27 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 6 Oct 2014 22:02:32 +0000 (18:02 -0400)
This removes the tcf_proto argument from the ematch code paths that
only need it to reference the net namespace. This allows simplifying
qdisc code paths especially when we need to tear down the ematch
from an RCU callback. In this case we can not guarentee that the
tcf_proto structure is still valid.

Signed-off-by: John Fastabend <john.r.fastabend@intel.com>
Acked-by: Cong Wang <cwang@twopensource.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/pkt_cls.h
net/sched/cls_basic.c
net/sched/cls_cgroup.c
net/sched/cls_flow.c
net/sched/em_canid.c
net/sched/em_ipset.c
net/sched/em_meta.c
net/sched/em_nbyte.c
net/sched/em_text.c
net/sched/ematch.c

index ef44ad9a6426345018633ef2fca24049c1b017bb..bc49967e1a68b933f0a7cd5a66a9f9395f76be00 100644 (file)
@@ -166,6 +166,7 @@ struct tcf_ematch {
        unsigned int            datalen;
        u16                     matchid;
        u16                     flags;
+       struct net              *net;
 };
 
 static inline int tcf_em_is_container(struct tcf_ematch *em)
@@ -229,12 +230,11 @@ struct tcf_ematch_tree {
 struct tcf_ematch_ops {
        int                     kind;
        int                     datalen;
-       int                     (*change)(struct tcf_proto *, void *,
+       int                     (*change)(struct net *net, void *,
                                          int, struct tcf_ematch *);
        int                     (*match)(struct sk_buff *, struct tcf_ematch *,
                                         struct tcf_pkt_info *);
-       void                    (*destroy)(struct tcf_proto *,
-                                          struct tcf_ematch *);
+       void                    (*destroy)(struct tcf_ematch *);
        int                     (*dump)(struct sk_buff *, struct tcf_ematch *);
        struct module           *owner;
        struct list_head        link;
@@ -244,7 +244,7 @@ int tcf_em_register(struct tcf_ematch_ops *);
 void tcf_em_unregister(struct tcf_ematch_ops *);
 int tcf_em_tree_validate(struct tcf_proto *, struct nlattr *,
                         struct tcf_ematch_tree *);
-void tcf_em_tree_destroy(struct tcf_proto *, struct tcf_ematch_tree *);
+void tcf_em_tree_destroy(struct tcf_ematch_tree *);
 int tcf_em_tree_dump(struct sk_buff *, struct tcf_ematch_tree *, int);
 int __tcf_em_tree_match(struct sk_buff *, struct tcf_ematch_tree *,
                        struct tcf_pkt_info *);
@@ -301,7 +301,7 @@ struct tcf_ematch_tree {
 };
 
 #define tcf_em_tree_validate(tp, tb, t) ((void)(t), 0)
-#define tcf_em_tree_destroy(tp, t) do { (void)(t); } while(0)
+#define tcf_em_tree_destroy(t) do { (void)(t); } while(0)
 #define tcf_em_tree_dump(skb, t, tlv) (0)
 #define tcf_em_tree_change(tp, dst, src) do { } while(0)
 #define tcf_em_tree_match(skb, t, info) ((void)(info), 1)
index fe20826a79e743a9a18de5d3568d0ea3d27d8f71..90647a8af8caae9256693634e01a54b1a8640037 100644 (file)
@@ -95,7 +95,7 @@ static void basic_delete_filter(struct rcu_head *head)
 
        tcf_unbind_filter(tp, &f->res);
        tcf_exts_destroy(&f->exts);
-       tcf_em_tree_destroy(tp, &f->ematches);
+       tcf_em_tree_destroy(&f->ematches);
        kfree(f);
 }
 
index 3409f168225f93e37b5303068809aaba1980ce2c..2f77a89655dcdd2bffba27640af7d7c3318a027f 100644 (file)
@@ -87,7 +87,7 @@ static void cls_cgroup_destroy_rcu(struct rcu_head *root)
                                                    rcu);
 
        tcf_exts_destroy(&head->exts);
-       tcf_em_tree_destroy(head->tp, &head->ematches);
+       tcf_em_tree_destroy(&head->ematches);
        kfree(head);
 }
 
@@ -157,7 +157,7 @@ static void cls_cgroup_destroy(struct tcf_proto *tp)
 
        if (head) {
                tcf_exts_destroy(&head->exts);
-               tcf_em_tree_destroy(tp, &head->ematches);
+               tcf_em_tree_destroy(&head->ematches);
                RCU_INIT_POINTER(tp->root, NULL);
                kfree_rcu(head, rcu);
        }
index f18d27f7b5f2c0200d6c42150fa509798fd68143..a5d2b20db5606bea3ef5794ba9a6663010ff4589 100644 (file)
@@ -355,7 +355,7 @@ static void flow_destroy_filter(struct rcu_head *head)
 
        del_timer_sync(&f->perturb_timer);
        tcf_exts_destroy(&f->exts);
-       tcf_em_tree_destroy(f->tp, &f->ematches);
+       tcf_em_tree_destroy(&f->ematches);
        kfree(f);
 }
 
@@ -530,7 +530,7 @@ static int flow_change(struct net *net, struct sk_buff *in_skb,
        return 0;
 
 err2:
-       tcf_em_tree_destroy(tp, &t);
+       tcf_em_tree_destroy(&t);
        kfree(fnew);
 err1:
        tcf_exts_destroy(&e);
index 7c292d474f47861f3d9e293a1e7c55da7f38c5ca..ddd883ca55b2c1f18bd24500d6af457db5b0cd4a 100644 (file)
@@ -120,7 +120,7 @@ static int em_canid_match(struct sk_buff *skb, struct tcf_ematch *m,
        return match;
 }
 
-static int em_canid_change(struct tcf_proto *tp, void *data, int len,
+static int em_canid_change(struct net *net, void *data, int len,
                          struct tcf_ematch *m)
 {
        struct can_filter *conf = data; /* Array with rules */
@@ -183,7 +183,7 @@ static int em_canid_change(struct tcf_proto *tp, void *data, int len,
        return 0;
 }
 
-static void em_canid_destroy(struct tcf_proto *tp, struct tcf_ematch *m)
+static void em_canid_destroy(struct tcf_ematch *m)
 {
        struct canid_match *cm = em_canid_priv(m);
 
index 527aeb7a3ff0b3b558873d0c7d93fc2c26e100b8..5b4a4efe468c927a33fe24e187f5f42ff09c770f 100644 (file)
 #include <net/ip.h>
 #include <net/pkt_cls.h>
 
-static int em_ipset_change(struct tcf_proto *tp, void *data, int data_len,
+static int em_ipset_change(struct net *net, void *data, int data_len,
                           struct tcf_ematch *em)
 {
        struct xt_set_info *set = data;
        ip_set_id_t index;
-       struct net *net = dev_net(qdisc_dev(tp->q));
 
        if (data_len != sizeof(*set))
                return -EINVAL;
@@ -42,11 +41,11 @@ static int em_ipset_change(struct tcf_proto *tp, void *data, int data_len,
        return -ENOMEM;
 }
 
-static void em_ipset_destroy(struct tcf_proto *p, struct tcf_ematch *em)
+static void em_ipset_destroy(struct tcf_ematch *em)
 {
        const struct xt_set_info *set = (const void *) em->data;
        if (set) {
-               ip_set_nfnl_put(dev_net(qdisc_dev(p->q)), set->index);
+               ip_set_nfnl_put(em->net, set->index);
                kfree((void *) em->data);
        }
 }
index 9b8c0b0e60d7dbc34260ae8fc010844eeda4e8ad..c8f8c399b99a356835e5713d6b846fe814d0157b 100644 (file)
@@ -856,7 +856,7 @@ static const struct nla_policy meta_policy[TCA_EM_META_MAX + 1] = {
        [TCA_EM_META_HDR]       = { .len = sizeof(struct tcf_meta_hdr) },
 };
 
-static int em_meta_change(struct tcf_proto *tp, void *data, int len,
+static int em_meta_change(struct net *net, void *data, int len,
                          struct tcf_ematch *m)
 {
        int err;
@@ -908,7 +908,7 @@ errout:
        return err;
 }
 
-static void em_meta_destroy(struct tcf_proto *tp, struct tcf_ematch *m)
+static void em_meta_destroy(struct tcf_ematch *m)
 {
        if (m)
                meta_delete((struct meta_match *) m->data);
index a3bed07a008b2f746376ce0970cd4f15196adbdb..df3110d695857e672f1a50f83399a7f63959dd00 100644 (file)
@@ -23,7 +23,7 @@ struct nbyte_data {
        char                    pattern[0];
 };
 
-static int em_nbyte_change(struct tcf_proto *tp, void *data, int data_len,
+static int em_nbyte_change(struct net *net, void *data, int data_len,
                           struct tcf_ematch *em)
 {
        struct tcf_em_nbyte *nbyte = data;
index 15d353d2e4be0791859f533c8b816a584713fbcd..f03c3de16c274f3152f4ef701339d20158609b51 100644 (file)
@@ -45,7 +45,7 @@ static int em_text_match(struct sk_buff *skb, struct tcf_ematch *m,
        return skb_find_text(skb, from, to, tm->config, &state) != UINT_MAX;
 }
 
-static int em_text_change(struct tcf_proto *tp, void *data, int len,
+static int em_text_change(struct net *net, void *data, int len,
                          struct tcf_ematch *m)
 {
        struct text_match *tm;
@@ -100,7 +100,7 @@ retry:
        return 0;
 }
 
-static void em_text_destroy(struct tcf_proto *tp, struct tcf_ematch *m)
+static void em_text_destroy(struct tcf_ematch *m)
 {
        if (EM_TEXT_PRIV(m) && EM_TEXT_PRIV(m)->config)
                textsearch_destroy(EM_TEXT_PRIV(m)->config);
index ad57f4444b9c65cdc7abe6eb588868c4e2b65cd2..8250c36543d893c2fd4c38732f3a3f7c12bfb6a5 100644 (file)
@@ -178,6 +178,7 @@ static int tcf_em_validate(struct tcf_proto *tp,
        struct tcf_ematch_hdr *em_hdr = nla_data(nla);
        int data_len = nla_len(nla) - sizeof(*em_hdr);
        void *data = (void *) em_hdr + sizeof(*em_hdr);
+       struct net *net = dev_net(qdisc_dev(tp->q));
 
        if (!TCF_EM_REL_VALID(em_hdr->flags))
                goto errout;
@@ -240,7 +241,7 @@ static int tcf_em_validate(struct tcf_proto *tp,
                        goto errout;
 
                if (em->ops->change) {
-                       err = em->ops->change(tp, data, data_len, em);
+                       err = em->ops->change(net, data, data_len, em);
                        if (err < 0)
                                goto errout;
                } else if (data_len > 0) {
@@ -271,6 +272,7 @@ static int tcf_em_validate(struct tcf_proto *tp,
        em->matchid = em_hdr->matchid;
        em->flags = em_hdr->flags;
        em->datalen = data_len;
+       em->net = net;
 
        err = 0;
 errout:
@@ -378,7 +380,7 @@ errout:
        return err;
 
 errout_abort:
-       tcf_em_tree_destroy(tp, tree);
+       tcf_em_tree_destroy(tree);
        return err;
 }
 EXPORT_SYMBOL(tcf_em_tree_validate);
@@ -393,7 +395,7 @@ EXPORT_SYMBOL(tcf_em_tree_validate);
  * tcf_em_tree_validate()/tcf_em_tree_change(). You must ensure that
  * the ematch tree is not in use before calling this function.
  */
-void tcf_em_tree_destroy(struct tcf_proto *tp, struct tcf_ematch_tree *tree)
+void tcf_em_tree_destroy(struct tcf_ematch_tree *tree)
 {
        int i;
 
@@ -405,7 +407,7 @@ void tcf_em_tree_destroy(struct tcf_proto *tp, struct tcf_ematch_tree *tree)
 
                if (em->ops) {
                        if (em->ops->destroy)
-                               em->ops->destroy(tp, em);
+                               em->ops->destroy(em);
                        else if (!tcf_em_is_simple(em))
                                kfree((void *) em->data);
                        module_put(em->ops->owner);