diff options
Diffstat (limited to 'net/sched/act_api.c')
| -rw-r--r-- | net/sched/act_api.c | 57 | 
1 files changed, 27 insertions, 30 deletions
diff --git a/net/sched/act_api.c b/net/sched/act_api.c index 5b3c0ac495be..34c508675041 100644 --- a/net/sched/act_api.c +++ b/net/sched/act_api.c @@ -125,7 +125,7 @@ static void free_tcf(struct tc_action *p)  	free_percpu(p->cpu_bstats_hw);  	free_percpu(p->cpu_qstats); -	tcf_set_action_cookie(&p->act_cookie, NULL); +	tcf_set_action_cookie(&p->user_cookie, NULL);  	if (chain)  		tcf_chain_put_by_act(chain); @@ -169,11 +169,6 @@ static bool tc_act_skip_sw(u32 flags)  	return (flags & TCA_ACT_FLAGS_SKIP_SW) ? true : false;  } -static bool tc_act_in_hw(struct tc_action *act) -{ -	return !!act->in_hw_count; -} -  /* SKIP_HW and SKIP_SW are mutually exclusive flags. */  static bool tc_act_flags_valid(u32 flags)  { @@ -192,6 +187,7 @@ static int offload_action_init(struct flow_offload_action *fl_action,  	fl_action->extack = extack;  	fl_action->command = cmd;  	fl_action->index = act->tcfa_index; +	fl_action->cookie = (unsigned long)act;  	if (act->ops->offload_act_setup) {  		spin_lock_bh(&act->tcfa_lock); @@ -272,7 +268,7 @@ static int tcf_action_offload_add_ex(struct tc_action *action,  	if (err)  		goto fl_err; -	err = tc_setup_action(&fl_action->action, actions, extack); +	err = tc_setup_action(&fl_action->action, actions, 0, extack);  	if (err) {  		NL_SET_ERR_MSG_MOD(extack,  				   "Failed to setup tc actions for offload"); @@ -307,9 +303,6 @@ int tcf_action_update_hw_stats(struct tc_action *action)  	struct flow_offload_action fl_act = {};  	int err; -	if (!tc_act_in_hw(action)) -		return -EOPNOTSUPP; -  	err = offload_action_init(&fl_act, action, FLOW_ACT_STATS, NULL);  	if (err)  		return err; @@ -438,14 +431,14 @@ EXPORT_SYMBOL(tcf_idr_release);  static size_t tcf_action_shared_attrs_size(const struct tc_action *act)  { -	struct tc_cookie *act_cookie; +	struct tc_cookie *user_cookie;  	u32 cookie_len = 0;  	rcu_read_lock(); -	act_cookie = rcu_dereference(act->act_cookie); +	user_cookie = rcu_dereference(act->user_cookie); -	if (act_cookie) -		cookie_len = nla_total_size(act_cookie->len); +	if (user_cookie) +		cookie_len = nla_total_size(user_cookie->len);  	rcu_read_unlock();  	return  nla_total_size(0) /* action number nested */ @@ -495,7 +488,7 @@ tcf_action_dump_terse(struct sk_buff *skb, struct tc_action *a, bool from_act)  		goto nla_put_failure;  	rcu_read_lock(); -	cookie = rcu_dereference(a->act_cookie); +	cookie = rcu_dereference(a->user_cookie);  	if (cookie) {  		if (nla_put(skb, TCA_ACT_COOKIE, cookie->len, cookie->data)) {  			rcu_read_unlock(); @@ -539,6 +532,8 @@ static int tcf_dump_walker(struct tcf_idrinfo *idrinfo, struct sk_buff *skb,  			       (unsigned long)p->tcfa_tm.lastuse))  			continue; +		tcf_action_update_hw_stats(p); +  		nest = nla_nest_start_noflag(skb, n_i);  		if (!nest) {  			index--; @@ -1367,9 +1362,9 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,  {  	bool police = flags & TCA_ACT_FLAGS_POLICE;  	struct nla_bitfield32 userflags = { 0, 0 }; +	struct tc_cookie *user_cookie = NULL;  	u8 hw_stats = TCA_ACT_HW_STATS_ANY;  	struct nlattr *tb[TCA_ACT_MAX + 1]; -	struct tc_cookie *cookie = NULL;  	struct tc_action *a;  	int err; @@ -1380,8 +1375,8 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,  		if (err < 0)  			return ERR_PTR(err);  		if (tb[TCA_ACT_COOKIE]) { -			cookie = nla_memdup_cookie(tb); -			if (!cookie) { +			user_cookie = nla_memdup_cookie(tb); +			if (!user_cookie) {  				NL_SET_ERR_MSG(extack, "No memory to generate TC cookie");  				err = -ENOMEM;  				goto err_out; @@ -1407,7 +1402,7 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,  	*init_res = err;  	if (!police && tb[TCA_ACT_COOKIE]) -		tcf_set_action_cookie(&a->act_cookie, cookie); +		tcf_set_action_cookie(&a->user_cookie, user_cookie);  	if (!police)  		a->hw_stats = hw_stats; @@ -1415,9 +1410,9 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,  	return a;  err_out: -	if (cookie) { -		kfree(cookie->data); -		kfree(cookie); +	if (user_cookie) { +		kfree(user_cookie->data); +		kfree(user_cookie);  	}  	return ERR_PTR(err);  } @@ -1539,9 +1534,6 @@ int tcf_action_copy_stats(struct sk_buff *skb, struct tc_action *p,  	if (p == NULL)  		goto errout; -	/* update hw stats for this action */ -	tcf_action_update_hw_stats(p); -  	/* compat_mode being true specifies a call that is supposed  	 * to add additional backward compatibility statistic TLVs.  	 */ @@ -1582,7 +1574,7 @@ errout:  static int tca_get_fill(struct sk_buff *skb, struct tc_action *actions[],  			u32 portid, u32 seq, u16 flags, int event, int bind, -			int ref) +			int ref, struct netlink_ext_ack *extack)  {  	struct tcamsg *t;  	struct nlmsghdr *nlh; @@ -1604,9 +1596,14 @@ static int tca_get_fill(struct sk_buff *skb, struct tc_action *actions[],  	if (tcf_action_dump(skb, actions, bind, ref, false) < 0)  		goto out_nlmsg_trim; +	if (extack && extack->_msg && +	    nla_put_string(skb, TCA_EXT_WARN_MSG, extack->_msg)) +		goto out_nlmsg_trim; +  	nla_nest_end(skb, nest);  	nlh->nlmsg_len = skb_tail_pointer(skb) - b; +  	return skb->len;  out_nlmsg_trim: @@ -1625,7 +1622,7 @@ tcf_get_notify(struct net *net, u32 portid, struct nlmsghdr *n,  	if (!skb)  		return -ENOBUFS;  	if (tca_get_fill(skb, actions, portid, n->nlmsg_seq, 0, event, -			 0, 1) <= 0) { +			 0, 1, NULL) <= 0) {  		NL_SET_ERR_MSG(extack, "Failed to fill netlink attributes while adding TC action");  		kfree_skb(skb);  		return -EINVAL; @@ -1799,7 +1796,7 @@ tcf_reoffload_del_notify(struct net *net, struct tc_action *action)  	if (!skb)  		return -ENOBUFS; -	if (tca_get_fill(skb, actions, 0, 0, 0, RTM_DELACTION, 0, 1) <= 0) { +	if (tca_get_fill(skb, actions, 0, 0, 0, RTM_DELACTION, 0, 1, NULL) <= 0) {  		kfree_skb(skb);  		return -EINVAL;  	} @@ -1886,7 +1883,7 @@ tcf_del_notify(struct net *net, struct nlmsghdr *n, struct tc_action *actions[],  		return -ENOBUFS;  	if (tca_get_fill(skb, actions, portid, n->nlmsg_seq, 0, RTM_DELACTION, -			 0, 2) <= 0) { +			 0, 2, extack) <= 0) {  		NL_SET_ERR_MSG(extack, "Failed to fill netlink TC action attributes");  		kfree_skb(skb);  		return -EINVAL; @@ -1965,7 +1962,7 @@ tcf_add_notify(struct net *net, struct nlmsghdr *n, struct tc_action *actions[],  		return -ENOBUFS;  	if (tca_get_fill(skb, actions, portid, n->nlmsg_seq, n->nlmsg_flags, -			 RTM_NEWACTION, 0, 0) <= 0) { +			 RTM_NEWACTION, 0, 0, extack) <= 0) {  		NL_SET_ERR_MSG(extack, "Failed to fill netlink attributes while adding TC action");  		kfree_skb(skb);  		return -EINVAL;  |