mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	net: sch: api: add extack support in tcf_block_get
This patch adds extack support for the function tcf_block_get which is a common used function in the tc subsystem. Callers which are interested in the receiving error can assign extack to get a more detailed information why tcf_block_get failed. Cc: David Ahern <dsahern@gmail.com> Acked-by: Jamal Hadi Salim <jhs@mojatatu.com> Signed-off-by: Alexander Aring <aring@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
		
							parent
							
								
									e9bc3fa28b
								
							
						
					
					
						commit
						8d1a77f974
					
				
					 15 changed files with 36 additions and 25 deletions
				
			
		| 
						 | 
					@ -39,9 +39,11 @@ struct tcf_chain *tcf_chain_get(struct tcf_block *block, u32 chain_index,
 | 
				
			||||||
				bool create);
 | 
									bool create);
 | 
				
			||||||
void tcf_chain_put(struct tcf_chain *chain);
 | 
					void tcf_chain_put(struct tcf_chain *chain);
 | 
				
			||||||
int tcf_block_get(struct tcf_block **p_block,
 | 
					int tcf_block_get(struct tcf_block **p_block,
 | 
				
			||||||
		  struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q);
 | 
							  struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q,
 | 
				
			||||||
 | 
							  struct netlink_ext_ack *extack);
 | 
				
			||||||
int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,
 | 
					int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,
 | 
				
			||||||
		      struct tcf_block_ext_info *ei);
 | 
							      struct tcf_block_ext_info *ei,
 | 
				
			||||||
 | 
							      struct netlink_ext_ack *extack);
 | 
				
			||||||
void tcf_block_put(struct tcf_block *block);
 | 
					void tcf_block_put(struct tcf_block *block);
 | 
				
			||||||
void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q,
 | 
					void tcf_block_put_ext(struct tcf_block *block, struct Qdisc *q,
 | 
				
			||||||
		       struct tcf_block_ext_info *ei);
 | 
							       struct tcf_block_ext_info *ei);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -281,20 +281,24 @@ static void tcf_block_offload_unbind(struct tcf_block *block, struct Qdisc *q,
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,
 | 
					int tcf_block_get_ext(struct tcf_block **p_block, struct Qdisc *q,
 | 
				
			||||||
		      struct tcf_block_ext_info *ei)
 | 
							      struct tcf_block_ext_info *ei,
 | 
				
			||||||
 | 
							      struct netlink_ext_ack *extack)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct tcf_block *block = kzalloc(sizeof(*block), GFP_KERNEL);
 | 
						struct tcf_block *block = kzalloc(sizeof(*block), GFP_KERNEL);
 | 
				
			||||||
	struct tcf_chain *chain;
 | 
						struct tcf_chain *chain;
 | 
				
			||||||
	int err;
 | 
						int err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!block)
 | 
						if (!block) {
 | 
				
			||||||
 | 
							NL_SET_ERR_MSG(extack, "Memory allocation for block failed");
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	INIT_LIST_HEAD(&block->chain_list);
 | 
						INIT_LIST_HEAD(&block->chain_list);
 | 
				
			||||||
	INIT_LIST_HEAD(&block->cb_list);
 | 
						INIT_LIST_HEAD(&block->cb_list);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* Create chain 0 by default, it has to be always present. */
 | 
						/* Create chain 0 by default, it has to be always present. */
 | 
				
			||||||
	chain = tcf_chain_create(block, 0);
 | 
						chain = tcf_chain_create(block, 0);
 | 
				
			||||||
	if (!chain) {
 | 
						if (!chain) {
 | 
				
			||||||
 | 
							NL_SET_ERR_MSG(extack, "Failed to create new tcf chain");
 | 
				
			||||||
		err = -ENOMEM;
 | 
							err = -ENOMEM;
 | 
				
			||||||
		goto err_chain_create;
 | 
							goto err_chain_create;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -321,7 +325,8 @@ static void tcf_chain_head_change_dflt(struct tcf_proto *tp_head, void *priv)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
int tcf_block_get(struct tcf_block **p_block,
 | 
					int tcf_block_get(struct tcf_block **p_block,
 | 
				
			||||||
		  struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q)
 | 
							  struct tcf_proto __rcu **p_filter_chain, struct Qdisc *q,
 | 
				
			||||||
 | 
							  struct netlink_ext_ack *extack)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	struct tcf_block_ext_info ei = {
 | 
						struct tcf_block_ext_info ei = {
 | 
				
			||||||
		.chain_head_change = tcf_chain_head_change_dflt,
 | 
							.chain_head_change = tcf_chain_head_change_dflt,
 | 
				
			||||||
| 
						 | 
					@ -329,7 +334,7 @@ int tcf_block_get(struct tcf_block **p_block,
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	WARN_ON(!p_filter_chain);
 | 
						WARN_ON(!p_filter_chain);
 | 
				
			||||||
	return tcf_block_get_ext(p_block, q, &ei);
 | 
						return tcf_block_get_ext(p_block, q, &ei, extack);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
EXPORT_SYMBOL(tcf_block_get);
 | 
					EXPORT_SYMBOL(tcf_block_get);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -283,7 +283,8 @@ static int atm_tc_change(struct Qdisc *sch, u32 classid, u32 parent,
 | 
				
			||||||
		goto err_out;
 | 
							goto err_out;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	error = tcf_block_get(&flow->block, &flow->filter_list, sch);
 | 
						error = tcf_block_get(&flow->block, &flow->filter_list, sch,
 | 
				
			||||||
 | 
								      extack);
 | 
				
			||||||
	if (error) {
 | 
						if (error) {
 | 
				
			||||||
		kfree(flow);
 | 
							kfree(flow);
 | 
				
			||||||
		goto err_out;
 | 
							goto err_out;
 | 
				
			||||||
| 
						 | 
					@ -550,7 +551,8 @@ static int atm_tc_init(struct Qdisc *sch, struct nlattr *opt,
 | 
				
			||||||
		p->link.q = &noop_qdisc;
 | 
							p->link.q = &noop_qdisc;
 | 
				
			||||||
	pr_debug("atm_tc_init: link (%p) qdisc %p\n", &p->link, p->link.q);
 | 
						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, sch);
 | 
						err = tcf_block_get(&p->link.block, &p->link.filter_list, sch,
 | 
				
			||||||
 | 
								    extack);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1160,7 +1160,7 @@ static int cbq_init(struct Qdisc *sch, struct nlattr *opt,
 | 
				
			||||||
	if (!q->link.R_tab)
 | 
						if (!q->link.R_tab)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tcf_block_get(&q->link.block, &q->link.filter_list, sch);
 | 
						err = tcf_block_get(&q->link.block, &q->link.filter_list, sch, extack);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		goto put_rtab;
 | 
							goto put_rtab;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1576,7 +1576,7 @@ cbq_change_class(struct Qdisc *sch, u32 classid, u32 parentid, struct nlattr **t
 | 
				
			||||||
	if (cl == NULL)
 | 
						if (cl == NULL)
 | 
				
			||||||
		goto failure;
 | 
							goto failure;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tcf_block_get(&cl->block, &cl->filter_list, sch);
 | 
						err = tcf_block_get(&cl->block, &cl->filter_list, sch, extack);
 | 
				
			||||||
	if (err) {
 | 
						if (err) {
 | 
				
			||||||
		kfree(cl);
 | 
							kfree(cl);
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -417,7 +417,7 @@ static int drr_init_qdisc(struct Qdisc *sch, struct nlattr *opt,
 | 
				
			||||||
	struct drr_sched *q = qdisc_priv(sch);
 | 
						struct drr_sched *q = qdisc_priv(sch);
 | 
				
			||||||
	int err;
 | 
						int err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tcf_block_get(&q->block, &q->filter_list, sch);
 | 
						err = tcf_block_get(&q->block, &q->filter_list, sch, extack);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
	err = qdisc_class_hash_init(&q->clhash);
 | 
						err = qdisc_class_hash_init(&q->clhash);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -348,7 +348,7 @@ static int dsmark_init(struct Qdisc *sch, struct nlattr *opt,
 | 
				
			||||||
	if (!opt)
 | 
						if (!opt)
 | 
				
			||||||
		goto errout;
 | 
							goto errout;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tcf_block_get(&p->block, &p->filter_list, sch);
 | 
						err = tcf_block_get(&p->block, &p->filter_list, sch, extack);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -484,7 +484,7 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt,
 | 
				
			||||||
			return err;
 | 
								return err;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tcf_block_get(&q->block, &q->filter_list, sch);
 | 
						err = tcf_block_get(&q->block, &q->filter_list, sch, extack);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1034,7 +1034,7 @@ hfsc_change_class(struct Qdisc *sch, u32 classid, u32 parentid,
 | 
				
			||||||
	if (cl == NULL)
 | 
						if (cl == NULL)
 | 
				
			||||||
		return -ENOBUFS;
 | 
							return -ENOBUFS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tcf_block_get(&cl->block, &cl->filter_list, sch);
 | 
						err = tcf_block_get(&cl->block, &cl->filter_list, sch, extack);
 | 
				
			||||||
	if (err) {
 | 
						if (err) {
 | 
				
			||||||
		kfree(cl);
 | 
							kfree(cl);
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
| 
						 | 
					@ -1409,7 +1409,7 @@ hfsc_init_qdisc(struct Qdisc *sch, struct nlattr *opt,
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
	q->eligible = RB_ROOT;
 | 
						q->eligible = RB_ROOT;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tcf_block_get(&q->root.block, &q->root.filter_list, sch);
 | 
						err = tcf_block_get(&q->root.block, &q->root.filter_list, sch, extack);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1032,7 +1032,7 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt,
 | 
				
			||||||
	if (!opt)
 | 
						if (!opt)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tcf_block_get(&q->block, &q->filter_list, sch);
 | 
						err = tcf_block_get(&q->block, &q->filter_list, sch, extack);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1397,7 +1397,7 @@ static int htb_change_class(struct Qdisc *sch, u32 classid,
 | 
				
			||||||
		if (!cl)
 | 
							if (!cl)
 | 
				
			||||||
			goto failure;
 | 
								goto failure;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		err = tcf_block_get(&cl->block, &cl->filter_list, sch);
 | 
							err = tcf_block_get(&cl->block, &cl->filter_list, sch, extack);
 | 
				
			||||||
		if (err) {
 | 
							if (err) {
 | 
				
			||||||
			kfree(cl);
 | 
								kfree(cl);
 | 
				
			||||||
			goto failure;
 | 
								goto failure;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -78,7 +78,7 @@ static int ingress_init(struct Qdisc *sch, struct nlattr *opt,
 | 
				
			||||||
	q->block_info.chain_head_change = clsact_chain_head_change;
 | 
						q->block_info.chain_head_change = clsact_chain_head_change;
 | 
				
			||||||
	q->block_info.chain_head_change_priv = &q->miniqp;
 | 
						q->block_info.chain_head_change_priv = &q->miniqp;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tcf_block_get_ext(&q->block, sch, &q->block_info);
 | 
						err = tcf_block_get_ext(&q->block, sch, &q->block_info, extack);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -186,7 +186,8 @@ static int clsact_init(struct Qdisc *sch, struct nlattr *opt,
 | 
				
			||||||
	q->ingress_block_info.chain_head_change = clsact_chain_head_change;
 | 
						q->ingress_block_info.chain_head_change = clsact_chain_head_change;
 | 
				
			||||||
	q->ingress_block_info.chain_head_change_priv = &q->miniqp_ingress;
 | 
						q->ingress_block_info.chain_head_change_priv = &q->miniqp_ingress;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tcf_block_get_ext(&q->ingress_block, sch, &q->ingress_block_info);
 | 
						err = tcf_block_get_ext(&q->ingress_block, sch, &q->ingress_block_info,
 | 
				
			||||||
 | 
									extack);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -196,7 +197,8 @@ static int clsact_init(struct Qdisc *sch, struct nlattr *opt,
 | 
				
			||||||
	q->egress_block_info.chain_head_change = clsact_chain_head_change;
 | 
						q->egress_block_info.chain_head_change = clsact_chain_head_change;
 | 
				
			||||||
	q->egress_block_info.chain_head_change_priv = &q->miniqp_egress;
 | 
						q->egress_block_info.chain_head_change_priv = &q->miniqp_egress;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tcf_block_get_ext(&q->egress_block, sch, &q->egress_block_info);
 | 
						err = tcf_block_get_ext(&q->egress_block, sch, &q->egress_block_info,
 | 
				
			||||||
 | 
									extack);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -248,7 +248,7 @@ static int multiq_init(struct Qdisc *sch, struct nlattr *opt,
 | 
				
			||||||
	if (!opt)
 | 
						if (!opt)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tcf_block_get(&q->block, &q->filter_list, sch);
 | 
						err = tcf_block_get(&q->block, &q->filter_list, sch, extack);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -215,7 +215,7 @@ static int prio_init(struct Qdisc *sch, struct nlattr *opt,
 | 
				
			||||||
	if (!opt)
 | 
						if (!opt)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tcf_block_get(&q->block, &q->filter_list, sch);
 | 
						err = tcf_block_get(&q->block, &q->filter_list, sch, extack);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1424,7 +1424,7 @@ static int qfq_init_qdisc(struct Qdisc *sch, struct nlattr *opt,
 | 
				
			||||||
	int i, j, err;
 | 
						int i, j, err;
 | 
				
			||||||
	u32 max_cl_shift, maxbudg_shift, max_classes;
 | 
						u32 max_cl_shift, maxbudg_shift, max_classes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tcf_block_get(&q->block, &q->filter_list, sch);
 | 
						err = tcf_block_get(&q->block, &q->filter_list, sch, extack);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -556,7 +556,7 @@ static int sfb_init(struct Qdisc *sch, struct nlattr *opt,
 | 
				
			||||||
	struct sfb_sched_data *q = qdisc_priv(sch);
 | 
						struct sfb_sched_data *q = qdisc_priv(sch);
 | 
				
			||||||
	int err;
 | 
						int err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tcf_block_get(&q->block, &q->filter_list, sch);
 | 
						err = tcf_block_get(&q->block, &q->filter_list, sch, extack);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -731,7 +731,7 @@ static int sfq_init(struct Qdisc *sch, struct nlattr *opt,
 | 
				
			||||||
	q->sch = sch;
 | 
						q->sch = sch;
 | 
				
			||||||
	timer_setup(&q->perturb_timer, sfq_perturbation, TIMER_DEFERRABLE);
 | 
						timer_setup(&q->perturb_timer, sfq_perturbation, TIMER_DEFERRABLE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	err = tcf_block_get(&q->block, &q->filter_list, sch);
 | 
						err = tcf_block_get(&q->block, &q->filter_list, sch, extack);
 | 
				
			||||||
	if (err)
 | 
						if (err)
 | 
				
			||||||
		return err;
 | 
							return err;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue