net: sched: change action API to use array of pointers to actions
Act API used linked list to pass set of actions to functions. It is intrusive data structure that stores list nodes inside action structure itself, which means it is not safe to modify such list concurrently. However, action API doesn't use any linked list specific operations on this set of actions, so it can be safely refactored into plain pointer array. Refactor action API to use array of pointers to tc_actions instead of linked list. Change argument 'actions' type of exported action init, destroy and dump functions. Acked-by: Jiri Pirko <jiri@mellanox.com> Signed-off-by: Vlad Buslov <vladbu@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
0190c1d452
commit
90b73b77d0
@@ -1609,10 +1609,7 @@ out:
|
||||
void tcf_exts_destroy(struct tcf_exts *exts)
|
||||
{
|
||||
#ifdef CONFIG_NET_CLS_ACT
|
||||
LIST_HEAD(actions);
|
||||
|
||||
tcf_exts_to_list(exts, &actions);
|
||||
tcf_action_destroy(&actions, TCA_ACT_UNBIND);
|
||||
tcf_action_destroy(exts->actions, TCA_ACT_UNBIND);
|
||||
kfree(exts->actions);
|
||||
exts->nr_actions = 0;
|
||||
#endif
|
||||
@@ -1639,18 +1636,15 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,
|
||||
exts->actions[0] = act;
|
||||
exts->nr_actions = 1;
|
||||
} else if (exts->action && tb[exts->action]) {
|
||||
LIST_HEAD(actions);
|
||||
int err, i = 0;
|
||||
int err;
|
||||
|
||||
err = tcf_action_init(net, tp, tb[exts->action],
|
||||
rate_tlv, NULL, ovr, TCA_ACT_BIND,
|
||||
&actions, &attr_size, true,
|
||||
exts->actions, &attr_size, true,
|
||||
extack);
|
||||
if (err)
|
||||
if (err < 0)
|
||||
return err;
|
||||
list_for_each_entry(act, &actions, list)
|
||||
exts->actions[i++] = act;
|
||||
exts->nr_actions = i;
|
||||
exts->nr_actions = err;
|
||||
}
|
||||
exts->net = net;
|
||||
}
|
||||
@@ -1699,14 +1693,11 @@ int tcf_exts_dump(struct sk_buff *skb, struct tcf_exts *exts)
|
||||
* tc data even if iproute2 was newer - jhs
|
||||
*/
|
||||
if (exts->type != TCA_OLD_COMPAT) {
|
||||
LIST_HEAD(actions);
|
||||
|
||||
nest = nla_nest_start(skb, exts->action);
|
||||
if (nest == NULL)
|
||||
goto nla_put_failure;
|
||||
|
||||
tcf_exts_to_list(exts, &actions);
|
||||
if (tcf_action_dump(skb, &actions, 0, 0) < 0)
|
||||
if (tcf_action_dump(skb, exts->actions, 0, 0) < 0)
|
||||
goto nla_put_failure;
|
||||
nla_nest_end(skb, nest);
|
||||
} else if (exts->police) {
|
||||
|
Reference in New Issue
Block a user