net: sched: remove some tp->q usage
Subsystems (3)
Jiri Pirko
maintainercover net: sched: remove some tp->q usage
From: Jiri Pirko <[email protected]>
In order to prepare for block sharing, tcf_proto instances need to be independent on particular qdisc instances. This patchset takes care of removal of couple occurrences of tp->q usage.
Jiri Pirko (9):
net: sched: store Qdisc pointer in struct block
net: sched: store net pointer in block and introduce qdisc_net helper
net: sched: introduce tcf_block_q and tcf_block_dev helpers
net: sched: teach tcf_bind/unbind_filter to use block->q
net: sched: ematch: obtain net pointer from blocks
net: sched: cls_u32: use block instead of q in tc_u_common
net: sched: tcindex, fw, flow: use tcf_block_q helper to get struct
Qdisc
net: sched: use tcf_block_q helper to get q pointer for sch_tree_lock
net: sched: propagate q and parent from caller down to tcf_fill_node
include/net/pkt_cls.h | 52 +++++++++++++++++++++++++++++++---------- include/net/pkt_sched.h | 7 ++++++ include/net/sch_generic.h | 5 ++-- net/sched/cls_api.c | 59 ++++++++++++++++++++++++++++++----------------- net/sched/cls_flow.c | 7 ++++-- net/sched/cls_fw.c | 5 +++- net/sched/cls_tcindex.c | 5 +++- net/sched/cls_u32.c | 12 ++++------ net/sched/ematch.c | 2 +- net/sched/sch_api.c | 6 +++-- net/sched/sch_atm.c | 4 ++-- net/sched/sch_cbq.c | 2 +- net/sched/sch_drr.c | 2 +- net/sched/sch_dsmark.c | 2 +- net/sched/sch_fq_codel.c | 2 +- net/sched/sch_hfsc.c | 4 ++-- net/sched/sch_htb.c | 4 ++-- net/sched/sch_ingress.c | 6 ++--- net/sched/sch_multiq.c | 2 +- net/sched/sch_prio.c | 2 +- net/sched/sch_qfq.c | 2 +- net/sched/sch_sfb.c | 2 +- net/sched/sch_sfq.c | 2 +- 23 files changed, 127 insertions(+), 69 deletions(-)
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 1/9 net: sched: store Qdisc pointer in struct block
From: Jiri Pirko <[email protected]>
Prepare for removal of tp->q and store Qdisc pointer in the block structure.
--- include/net/pkt_cls.h | 4 ++-- include/net/sch_generic.h | 1 + net/sched/cls_api.c | 3 ++- net/sched/sch_atm.c | 4 ++-- net/sched/sch_cbq.c | 2 +- net/sched/sch_drr.c | 2 +- net/sched/sch_dsmark.c | 2 +- net/sched/sch_fq_codel.c | 2 +- net/sched/sch_hfsc.c | 4 ++-- net/sched/sch_htb.c | 4 ++-- net/sched/sch_ingress.c | 6 +++--- net/sched/sch_multiq.c | 2 +- net/sched/sch_prio.c | 2 +- net/sched/sch_qfq.c | 2 +- net/sched/sch_sfb.c | 2 +- net/sched/sch_sfq.c | 2 +- 16 files changed, 23 insertions(+), 21 deletions(-)
include/net/pkt_cls.h +2 -2
@@ -22,7 +22,7 @@ struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index, bool create);void tcf_chain_put (struct tcf_chain *chain);int tcf_block_get (struct tcf_block **p_block, -struct tcf_proto __rcu **p_filter_chain); +struct tcf_proto __rcu **p_filter_chain,struct Qdisc *q);void tcf_block_put (struct tcf_block *block);int tcf_classify (struct sk_buff *skb,const struct tcf_proto *tp,struct tcf_result *res,bool compat_mode);
@@ -30,7 +30,7 @@ int tcf_classify(struct sk_buff *skb, const struct tcf_proto *tp,#else static inline int tcf_block_get (struct tcf_block **p_block, -struct tcf_proto __rcu **p_filter_chain) +struct tcf_proto __rcu **p_filter_chain,struct Qdisc *q) {return 0 ; }
include/net/sch_generic.h +1 -0
@@ -270,6 +270,7 @@ struct tcf_chain {struct tcf_block {struct list_head chain_list; +struct Qdisc *q; };static inline void qdisc_cb_private_validate (const struct sk_buff *skb,int sz)
net/sched/cls_api.c +2 -1
@@ -241,7 +241,7 @@ tcf_chain_filter_chain_ptr_set(struct tcf_chain *chain, }int tcf_block_get (struct tcf_block **p_block, -struct tcf_proto __rcu **p_filter_chain) +struct tcf_proto __rcu **p_filter_chain,struct Qdisc *q) {struct tcf_block *block =kzalloc (sizeof (*block),GFP_KERNEL );struct tcf_chain *chain;
@@ -257,6 +257,7 @@ int tcf_block_get(struct tcf_block **p_block, goto err_chain_create; }tcf_chain_filter_chain_ptr_set (chain, p_filter_chain); + block->q = q; *p_block = block;return 0 ;
net/sched/sch_atm.c +2 -2
@@ -281,7 +281,7 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent, goto err_out; } - error =tcf_block_get (&flow->block, &flow->filter_list); + error =tcf_block_get (&flow->block, &flow->filter_list, sch);if (error) {kfree (flow); goto err_out;
@@ -546,7 +546,7 @@ static int atm_tc_init(struct Qdisc *sch, struct nlattr *opt) p->link.q = &noop_qdisc;pr_debug ("atm_tc_init: link (%p) qdisc %p\n" , &p->link, p->link.q); - err =tcf_block_get (&p->link.block, &p->link.filter_list); + err =tcf_block_get (&p->link.block, &p->link.filter_list, sch);if (err)return err;
net/sched/sch_cbq.c +1 -1
@@ -1566,7 +1566,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **tif (cl ==NULL ) goto failure; - err =tcf_block_get (&cl->block, &cl->filter_list); + err =tcf_block_get (&cl->block, &cl->filter_list, sch);if (err) {kfree (cl);return err;
net/sched/sch_drr.c +1 -1
@@ -412,7 +412,7 @@ static int drr_init_qdisc(struct Qdisc *sch, struct nlattr *opt)struct drr_sched *q =qdisc_priv (sch);int err; - err =tcf_block_get (&q->block, &q->filter_list); + err =tcf_block_get (&q->block, &q->filter_list, sch);if (err)return err; err =qdisc_class_hash_init (&q->clhash);
net/sched/sch_dsmark.c +1 -1
@@ -344,7 +344,7 @@ static int dsmark_init(struct Qdisc *sch, struct nlattr *opt)if (!opt) goto errout; - err =tcf_block_get (&p->block, &p->filter_list); + err =tcf_block_get (&p->block, &p->filter_list, sch);if (err)return err;
net/sched/sch_fq_codel.c +1 -1
@@ -481,7 +481,7 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt)return err; } - err =tcf_block_get (&q->block, &q->filter_list); + err =tcf_block_get (&q->block, &q->filter_list, sch);if (err)return err;
net/sched/sch_hfsc.c +2 -2
@@ -1033,7 +1033,7 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,if (cl ==NULL )return -ENOBUFS ; - err =tcf_block_get (&cl->block, &cl->filter_list); + err =tcf_block_get (&cl->block, &cl->filter_list, sch);if (err) {kfree (cl);return err;
@@ -1405,7 +1405,7 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt)return err; q->eligible =RB_ROOT ; - err =tcf_block_get (&q->root.block, &q->root.filter_list); + err =tcf_block_get (&q->root.block, &q->root.filter_list, sch);if (err)return err;
net/sched/sch_htb.c +2 -2
@@ -1030,7 +1030,7 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt)if (!opt)return -EINVAL ; - err =tcf_block_get (&q->block, &q->filter_list); + err =tcf_block_get (&q->block, &q->filter_list, sch);if (err)return err;
@@ -1393,7 +1393,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,if (!cl) goto failure; - err =tcf_block_get (&cl->block, &cl->filter_list); + err =tcf_block_get (&cl->block, &cl->filter_list, sch);if (err) {kfree (cl); goto failure;
net/sched/sch_ingress.c +3 -3
@@ -59,7 +59,7 @@ static int ingress_init(struct Qdisc *sch, struct nlattr *opt)struct net_device *dev =qdisc_dev (sch);int err; - err =tcf_block_get (&q->block, &dev->ingress_cl_list); + err =tcf_block_get (&q->block, &dev->ingress_cl_list, sch);if (err)return err;
@@ -153,11 +153,11 @@ static int clsact_init(struct Qdisc *sch, struct nlattr *opt)struct net_device *dev =qdisc_dev (sch);int err; - err =tcf_block_get (&q->ingress_block, &dev->ingress_cl_list); + err =tcf_block_get (&q->ingress_block, &dev->ingress_cl_list, sch);if (err)return err; - err =tcf_block_get (&q->egress_block, &dev->egress_cl_list); + err =tcf_block_get (&q->egress_block, &dev->egress_cl_list, sch);if (err)return err;
net/sched/sch_multiq.c +1 -1
@@ -245,7 +245,7 @@ static int multiq_init(struct Qdisc *sch, struct nlattr *opt)if (opt ==NULL )return -EINVAL ; - err =tcf_block_get (&q->block, &q->filter_list); + err =tcf_block_get (&q->block, &q->filter_list, sch);if (err)return err;
net/sched/sch_prio.c +1 -1
@@ -212,7 +212,7 @@ static int prio_init(struct Qdisc *sch, struct nlattr *opt)if (!opt)return -EINVAL ; - err =tcf_block_get (&q->block, &q->filter_list); + err =tcf_block_get (&q->block, &q->filter_list, sch);if (err)return err;
net/sched/sch_qfq.c +1 -1
@@ -1419,7 +1419,7 @@ static int qfq_init_qdisc(struct Qdisc *sch, struct nlattr *opt)int i, j, err;u32 max_cl_shift, maxbudg_shift, max_classes; - err =tcf_block_get (&q->block, &q->filter_list); + err =tcf_block_get (&q->block, &q->filter_list, sch);if (err)return err;
net/sched/sch_sfb.c +1 -1
@@ -553,7 +553,7 @@ static int sfb_init(struct Qdisc *sch, struct nlattr *opt)struct sfb_sched_data *q =qdisc_priv (sch);int err; - err =tcf_block_get (&q->block, &q->filter_list); + err =tcf_block_get (&q->block, &q->filter_list, sch);if (err)return err;
net/sched/sch_sfq.c +1 -1
@@ -725,7 +725,7 @@ static int sfq_init(struct Qdisc *sch, struct nlattr *opt)setup_deferrable_timer (&q->perturb_timer, sfq_perturbation, (unsigned long )sch); - err =tcf_block_get (&q->block, &q->filter_list); + err =tcf_block_get (&q->block, &q->filter_list, sch);if (err)return err;
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 2/9 net: sched: store net pointer in block and introduce qdisc_net helper
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Store net pointer in the block structure. Along the way, introduce qdisc_net helper which allows to easily obtain net pointer for qdisc instance.
--- include/net/pkt_sched.h | 7 +++++++ include/net/sch_generic.h | 1 + net/sched/cls_api.c | 1 + 3 files changed, 9 insertions(+)
include/net/pkt_sched.h +7 -0
@@ -4,7 +4,9 @@#include <linux/jiffies.h> #include <linux/ktime.h> #include <linux/if_vlan.h> +#include <linux/netdevice.h> #include <net/sch_generic.h> +#include <net/net_namespace.h> #include <uapi/linux/pkt_sched.h> #define DEFAULT_TX_QUEUE_LEN 1000
@@ -146,4 +148,9 @@ static inline bool is_classid_clsact_egress(u32 classid) TC_H_MIN(classid) == TC_H_MIN(TC_H_MIN_EGRESS); } +static inline struct net *qdisc_net (struct Qdisc *q) +{ +return dev_net (q->dev_queue->dev); +} +#endif
include/net/sch_generic.h +1 -0
@@ -270,6 +270,7 @@ struct tcf_chain {struct tcf_block {struct list_head chain_list; +struct net *net;struct Qdisc *q; };
net/sched/cls_api.c +1 -0
@@ -257,6 +257,7 @@ int tcf_block_get(struct tcf_block **p_block, goto err_chain_create; }tcf_chain_filter_chain_ptr_set (chain, p_filter_chain); + block->net =qdisc_net (q); block->q = q; *p_block = block;return 0 ;
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 3/9 net: sched: introduce tcf_block_q and tcf_block_dev helpers
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
These helpers allows to get a q and netdev pointers for given block easily.
--- include/net/pkt_cls.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)
include/net/pkt_cls.h +21 -0
@@ -24,6 +24,17 @@ void tcf_chain_put(struct tcf_chain *chain);int tcf_block_get (struct tcf_block **p_block,struct tcf_proto __rcu **p_filter_chain,struct Qdisc *q);void tcf_block_put (struct tcf_block *block); + +static inline struct Qdisc *tcf_block_q (struct tcf_block *block) +{ +return block->q; +} + +static inline struct net_device *tcf_block_dev (struct tcf_block *block) +{ +return tcf_block_q (block)->dev_queue->dev; +} +int tcf_classify (struct sk_buff *skb,const struct tcf_proto *tp,struct tcf_result *res,bool compat_mode);
@@ -39,6 +50,16 @@ static inline void tcf_block_put(struct tcf_block *block) { } +static inline struct Qdisc *tcf_block_q (struct tcf_block *block) +{ +return NULL ; +} + +static inline struct net_device *tcf_block_dev (struct tcf_block *block) +{ +return NULL ; +} +static inline int tcf_classify (struct sk_buff *skb,const struct tcf_proto *tp,struct tcf_result *res,bool compat_mode) {
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 4/9 net: sched: teach tcf_bind/unbind_filter to use block->q
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Whenever the block->q is set, it can be used instead of tp->q as it contains the same value. When it is not set, which can't happen now but it might happen with the follow-up shared blocks introduction, the class is not set in the result. That would lead to a class lookup instead of direct class pointer use for classful qdiscs. However, it is not planned to support classful qdisqs sharing filter blocks, so that may never happen.
--- include/net/pkt_cls.h | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-)
include/net/pkt_cls.h +17 -10
@@ -74,36 +74,43 @@ __cls_set_class(unsigned long *clp, unsigned long cl) }static inline unsigned long -cls_set_class (struct tcf_proto *tp,unsigned long *clp, -unsigned long cl) +cls_set_class (struct Qdisc *q,unsigned long *clp,unsigned long cl) {unsigned long old_cl; - -tcf_tree_lock (tp); + +sch_tree_lock (q); old_cl =__cls_set_class (clp, cl); -tcf_tree_unlock (tp); - +sch_tree_unlock (q);return old_cl; }static inline void tcf_bind_filter (struct tcf_proto *tp,struct tcf_result *r,unsigned long base) { +struct Qdisc *q = tp->chain->block->q;unsigned long cl; - cl = tp->q->ops->cl_ops->bind_tcf (tp->q, base, r->classid); - cl =cls_set_class (tp, &r->class, cl); +/* Check q as it is not set for shared blocks. In that case, +* setting class is not supported. +*/ +if (!q) +return ; + cl = q->ops->cl_ops->bind_tcf (q, base, r->classid); + cl =cls_set_class (q, &r->class, cl);if (cl) - tp->q->ops->cl_ops->unbind_tcf (tp->q, cl); + q->ops->cl_ops->unbind_tcf (q, cl); }static inline void tcf_unbind_filter (struct tcf_proto *tp,struct tcf_result *r) { +struct Qdisc *q = tp->chain->block->q;unsigned long cl; +if (!q) +return ;if ((cl =__cls_set_class (&r->class,0 )) !=0 ) - tp->q->ops->cl_ops->unbind_tcf (tp->q, cl); + q->ops->cl_ops->unbind_tcf (q, cl); }struct tcf_exts {
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 5/9 net: sched: ematch: obtain net pointer from blocks
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Instead of using tp->q, use block to get the net pointer.
--- net/sched/ematch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
net/sched/ematch.c +1 -1
@@ -178,7 +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)); +struct net *net = tp->chain->block->net;if (!TCF_EM_REL_VALID (em_hdr->flags)) goto errout;
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 6/9 net: sched: cls_u32: use block instead of q in tc_u_common
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
tc_u_common is now per-q. With blocks, it has to be converted to be per-block.
--- net/sched/cls_u32.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
net/sched/cls_u32.c +4 -8
@@ -93,7 +93,7 @@ struct tc_u_hnode {struct tc_u_common {struct tc_u_hnode __rcu *hlist; -struct Qdisc *q; +struct tcf_block *block;int refcnt;struct idr handle_idr;struct hlist_node hnode;
@@ -335,11 +335,7 @@ static struct hlist_head *tc_u_common_hash;static unsigned int tc_u_hash (const struct tcf_proto *tp) { -struct net_device *dev = tp->q->dev_queue->dev; -u32 qhandle = tp->q->handle; -int ifindex = dev->ifindex; - -return hash_64 ((u64 )ifindex <<32 | qhandle,U32_HASH_SHIFT ); +return hash_64 ((u64 ) tp->chain->block,U32_HASH_SHIFT ); }static struct tc_u_common *tc_u_common_find (const struct tcf_proto *tp)
@@ -349,7 +345,7 @@ static struct tc_u_common *tc_u_common_find(const struct tcf_proto *tp) h =tc_u_hash (tp);hlist_for_each_entry (tc, &tc_u_common_hash[h], hnode) { -if (tc->q == tp->q) +if (tc->block == tp->chain->block)return tc; }return NULL ;
@@ -378,7 +374,7 @@ static int u32_init(struct tcf_proto *tp)kfree (root_ht);return -ENOBUFS ; } - tp_c->q = tp->q; + tp_c->block = tp->chain->block;INIT_HLIST_NODE (&tp_c->hnode);idr_init (&tp_c->handle_idr);
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 7/9 net: sched: tcindex, fw, flow: use tcf_block_q helper to get struct Qdisc
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Use helper to get q pointer per block.
--- net/sched/cls_flow.c | 7 +++++-- net/sched/cls_fw.c | 5 ++++- net/sched/cls_tcindex.c | 5 ++++- 3 files changed, 13 insertions(+), 4 deletions(-)
net/sched/cls_flow.c +5 -2
@@ -491,8 +491,11 @@ static int flow_change(struct net *net, struct sk_buff *in_skb, perturb_period =nla_get_u32 (tb[TCA_FLOW_PERTURB ]) *HZ ; } -if (TC_H_MAJ (baseclass) ==0 ) - baseclass =TC_H_MAKE (tp->q->handle, baseclass); +if (TC_H_MAJ (baseclass) ==0 ) { +struct Qdisc *q =tcf_block_q (tp->chain->block); + + baseclass =TC_H_MAKE (q->handle, baseclass); + }if (TC_H_MIN (baseclass) ==0 ) baseclass =TC_H_MAKE (baseclass,1 );
net/sched/cls_fw.c +4 -1
@@ -28,6 +28,7 @@#include <net/netlink.h> #include <net/act_api.h> #include <net/pkt_cls.h> +#include <net/sch_generic.h> #define HTSIZE 256
@@ -83,9 +84,11 @@ static int fw_classify(struct sk_buff *skb, const struct tcf_proto *tp, } } }else { +struct Qdisc *q =tcf_block_q (tp->chain->block); +/* Old method: classify the packet using its skb mark. */ if (id && (TC_H_MAJ (id) ==0 || - !(TC_H_MAJ (id ^ tp->q->handle)))) { + !(TC_H_MAJ (id ^ q->handle)))) { res->classid = id; res->class =0 ;return 0 ;
net/sched/cls_tcindex.c +4 -1
@@ -13,6 +13,7 @@#include <net/act_api.h> #include <net/netlink.h> #include <net/pkt_cls.h> +#include <net/sch_generic.h> /* * Passing parameters to the root seems to be done more awkwardly than really
@@ -90,9 +91,11 @@ static int tcindex_classify(struct sk_buff *skb, const struct tcf_proto *tp, f =tcindex_lookup (p, key);if (!f) { +struct Qdisc *q =tcf_block_q (tp->chain->block); +if (!p->fall_through)return -1 ; - res->classid =TC_H_MAKE (TC_H_MAJ (tp->q->handle), key); + res->classid =TC_H_MAKE (TC_H_MAJ (q->handle), key); res->class =0 ;pr_debug ("alg 0x%x\n" , res->classid);return 0 ;
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 8/9 net: sched: use tcf_block_q helper to get q pointer for sch_tree_lock
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
Use tcf_block_q helper to get q pointer to be used for direct call of sch_tree_lock/unlock instead of tcf_tree_lock/unlock.
--- include/net/sch_generic.h | 3 --- net/sched/sch_api.c | 6 ++++-- 2 files changed, 4 insertions(+), 5 deletions(-)
include/net/sch_generic.h +0 -3
@@ -359,9 +359,6 @@ static inline void sch_tree_unlock(const struct Qdisc *q)spin_unlock_bh (qdisc_root_sleeping_lock (q)); } -#define tcf_tree_lock (tp) sch_tree_lock((tp)->q) -#define tcf_tree_unlock (tp) sch_tree_unlock((tp)->q) -extern struct Qdisc noop_qdisc;extern struct Qdisc_ops noop_qdisc_ops;extern struct Qdisc_ops pfifo_fast_ops;
net/sched/sch_api.c +4 -2
@@ -1661,9 +1661,11 @@ static int tcf_node_bind(struct tcf_proto *tp, void *n, struct tcf_walker *arg)struct tcf_bind_args *a = (void *)arg;if (tp->ops->bind_class) { -tcf_tree_lock (tp); +struct Qdisc *q =tcf_block_q (tp->chain->block); + +sch_tree_lock (q); tp->ops->bind_class (n, a->classid, a->cl); -tcf_tree_unlock (tp); +sch_tree_unlock (q); }return 0 ; }
Signature · 1 line
2.9.5
Jiri Pirko
maintainerPATCH 9/9 net: sched: propagate q and parent from caller down to tcf_fill_node
In reply to Jiri PirkoFrom: Jiri Pirko <[email protected]>
The callers have this info, they will pass it down to tcf_fill_node.
--- net/sched/cls_api.c | 55 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 35 insertions(+), 20 deletions(-)
net/sched/cls_api.c +35 -20
@@ -420,8 +420,8 @@ static struct tcf_proto *tcf_chain_tp_find(struct tcf_chain *chain, }static int tcf_fill_node (struct net *net,struct sk_buff *skb, -struct tcf_proto *tp,void *fh,u32 portid, -u32 seq,u16 flags,int event) +struct tcf_proto *tp,struct Qdisc *q,u32 parent, +void *fh,u32 portid,u32 seq,u16 flags,int event) {struct tcmsg *tcm;struct nlmsghdr *nlh;
@@ -434,8 +434,8 @@ static int tcf_fill_node(struct net *net, struct sk_buff *skb, tcm->tcm_family =AF_UNSPEC ; tcm->tcm__pad1 =0 ; tcm->tcm__pad2 =0 ; - tcm->tcm_ifindex =qdisc_dev (tp->q)->ifindex; - tcm->tcm_parent = tp->classid; + tcm->tcm_ifindex =qdisc_dev (q)->ifindex; + tcm->tcm_parent = parent; tcm->tcm_info =TC_H_MAKE (tp->prio, tp->protocol);if (nla_put_string (skb,TCA_KIND , tp->ops->kind)) goto nla_put_failure;
@@ -458,6 +458,7 @@ static int tcf_fill_node(struct net *net, struct sk_buff *skb,static int tfilter_notify (struct net *net,struct sk_buff *oskb,struct nlmsghdr *n,struct tcf_proto *tp, +struct Qdisc *q,u32 parent,void *fh,int event,bool unicast) {struct sk_buff *skb;
@@ -467,7 +468,7 @@ static int tfilter_notify(struct net *net, struct sk_buff *oskb,if (!skb)return -ENOBUFS ; -if (tcf_fill_node (net, skb, tp, fh, portid, n->nlmsg_seq, +if (tcf_fill_node (net, skb, tp, q, parent, fh, portid, n->nlmsg_seq, n->nlmsg_flags, event) <=0 ) {kfree_skb (skb);return -EINVAL ;
@@ -482,6 +483,7 @@ static int tfilter_notify(struct net *net, struct sk_buff *oskb,static int tfilter_del_notify (struct net *net,struct sk_buff *oskb,struct nlmsghdr *n,struct tcf_proto *tp, +struct Qdisc *q,u32 parent,void *fh,bool unicast,bool *last) {struct sk_buff *skb;
@@ -492,7 +494,7 @@ static int tfilter_del_notify(struct net *net, struct sk_buff *oskb,if (!skb)return -ENOBUFS ; -if (tcf_fill_node (net, skb, tp, fh, portid, n->nlmsg_seq, +if (tcf_fill_node (net, skb, tp, q, parent, fh, portid, n->nlmsg_seq, n->nlmsg_flags,RTM_DELTFILTER ) <=0 ) {kfree_skb (skb);return -EINVAL ;
@@ -512,6 +514,7 @@ static int tfilter_del_notify(struct net *net, struct sk_buff *oskb, }static void tfilter_notify_chain (struct net *net,struct sk_buff *oskb, +struct Qdisc *q,u32 parent,struct nlmsghdr *n,struct tcf_chain *chain,int event) {
@@ -519,7 +522,7 @@ static void tfilter_notify_chain(struct net *net, struct sk_buff *oskb,for (tp =rtnl_dereference (chain->filter_chain); tp; tp =rtnl_dereference (tp->next)) -tfilter_notify (net, oskb, n, tp,0 , event, false); +tfilter_notify (net, oskb, n, tp, q, parent,0 , event, false); }/* Add/change/delete/get a filter node */
@@ -638,7 +641,8 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, }if (n->nlmsg_type ==RTM_DELTFILTER && prio ==0 ) { -tfilter_notify_chain (net, skb, n, chain,RTM_DELTFILTER ); +tfilter_notify_chain (net, skb, q, parent, n, + chain,RTM_DELTFILTER );tcf_chain_flush (chain); err =0 ; goto errout;
@@ -685,7 +689,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,if (!fh) {if (n->nlmsg_type ==RTM_DELTFILTER && t->tcm_handle ==0 ) {tcf_chain_tp_remove (chain, &chain_info, tp); -tfilter_notify (net, skb, n, tp, fh, +tfilter_notify (net, skb, n, tp, q, parent, fh,RTM_DELTFILTER , false);tcf_proto_destroy (tp); err =0 ;
@@ -710,8 +714,8 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, }break ;case RTM_DELTFILTER : - err =tfilter_del_notify (net, skb, n, tp, fh, false, - &last); + err =tfilter_del_notify (net, skb, n, tp, q, parent, + fh, false, &last);if (err) goto errout;if (last) {
@@ -720,7 +724,7 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n, } goto errout;case RTM_GETTFILTER : - err =tfilter_notify (net, skb, n, tp, fh, + err =tfilter_notify (net, skb, n, tp, q, parent, fh,RTM_NEWTFILTER , true); goto errout;default :
@@ -734,7 +738,8 @@ static int tc_ctl_tfilter(struct sk_buff *skb, struct nlmsghdr *n,if (err ==0 ) {if (tp_created)tcf_chain_tp_insert (chain, &chain_info, tp); -tfilter_notify (net, skb, n, tp, fh,RTM_NEWTFILTER , false); +tfilter_notify (net, skb, n, tp, q, parent, fh, +RTM_NEWTFILTER , false); }else {if (tp_created)tcf_proto_destroy (tp);
@@ -753,6 +758,8 @@ struct tcf_dump_args {struct tcf_walker w;struct sk_buff *skb;struct netlink_callback *cb; +struct Qdisc *q; +u32 parent; };static int tcf_node_dump (struct tcf_proto *tp,void *n,struct tcf_walker *arg)
@@ -760,13 +767,14 @@ static int tcf_node_dump(struct tcf_proto *tp, void *n, struct tcf_walker *arg)struct tcf_dump_args *a = (void *)arg;struct net *net =sock_net (a->skb->sk); -return tcf_fill_node (net, a->skb, tp, n,NETLINK_CB (a->cb->skb).portid, +return tcf_fill_node (net, a->skb, tp, a->q, a->parent, + n,NETLINK_CB (a->cb->skb).portid, a->cb->nlh->nlmsg_seq,NLM_F_MULTI ,RTM_NEWTFILTER ); } -static bool tcf_chain_dump (struct tcf_chain *chain,struct sk_buff *skb, -struct netlink_callback *cb, +static bool tcf_chain_dump (struct tcf_chain *chain,struct Qdisc *q,u32 parent, +struct sk_buff *skb,struct netlink_callback *cb,long index_start,long *p_index) {struct net *net =sock_net (skb->sk);
@@ -788,7 +796,7 @@ static bool tcf_chain_dump(struct tcf_chain *chain, struct sk_buff *skb,memset (&cb->args[1 ],0 ,sizeof (cb->args) -sizeof (cb->args[0 ]));if (cb->args[1 ] ==0 ) { -if (tcf_fill_node (net, skb, tp,0 , +if (tcf_fill_node (net, skb, tp, q, parent,0 ,NETLINK_CB (cb->skb).portid, cb->nlh->nlmsg_seq,NLM_F_MULTI ,RTM_NEWTFILTER ) <=0 )
@@ -801,6 +809,8 @@ static bool tcf_chain_dump(struct tcf_chain *chain, struct sk_buff *skb, arg.w.fn = tcf_node_dump; arg.skb = skb; arg.cb = cb; + arg.q = q; + arg.parent = parent; arg.w.stop =0 ; arg.w.skip = cb->args[1 ] -1 ; arg.w.count =0 ;
@@ -826,6 +836,7 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)const struct Qdisc_class_ops *cops;long index_start;long index; +u32 parent;int err;if (nlmsg_len (cb->nlh) <sizeof (*tcm))
@@ -839,10 +850,13 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)if (!dev)return skb->len; -if (!tcm->tcm_parent) + parent = tcm->tcm_parent; +if (!parent) { q = dev->qdisc; -else + parent = q->handle; + }else { q =qdisc_lookup (dev,TC_H_MAJ (tcm->tcm_parent)); + }if (!q) goto out; cops = q->ops->cl_ops;
@@ -866,7 +880,8 @@ static int tc_dump_tfilter(struct sk_buff *skb, struct netlink_callback *cb)if (tca[TCA_CHAIN ] &&nla_get_u32 (tca[TCA_CHAIN ]) != chain->index)continue ; -if (!tcf_chain_dump (chain, skb, cb, index_start, &index)) +if (!tcf_chain_dump (chain, q, parent, skb, cb, + index_start, &index))break ; }
Signature · 1 line
2.9.5
David Miller
maintainerFrom: Jiri Pirko <[email protected]>
Date: Fri, 13 Oct 2017 14:00:56 +0200
Quoted 5 lines
From: Jiri Pirko <[email protected]>
In order to prepare for block sharing,
tcf_protoinstances need to be independent on particular qdisc instances. This patchset takes care of removal of couple occurrences oftp->qusage.
Series applied, thanks Jiri.