Commit b3620145 authored by Alexander Aring's avatar Alexander Aring Committed by David S. Miller

net: sched: act: handle extack in tcf_generic_walker

This patch adds extack handling for a common used TC act function
"tcf_generic_walker()" to add an extack message on failures.
The tcf_generic_walker() function can fail if get a invalid command
different than DEL and GET. The naming "action" here is wrong, the
correct naming would be command.

Cc: David Ahern <dsahern@gmail.com>
Signed-off-by: default avatarAlexander Aring <aring@mojatatu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 41780105
...@@ -140,7 +140,8 @@ static inline void tc_action_net_exit(struct list_head *net_list, ...@@ -140,7 +140,8 @@ static inline void tc_action_net_exit(struct list_head *net_list,
int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb, int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb,
struct netlink_callback *cb, int type, struct netlink_callback *cb, int type,
const struct tc_action_ops *ops); const struct tc_action_ops *ops,
struct netlink_ext_ack *extack);
int tcf_idr_search(struct tc_action_net *tn, struct tc_action **a, u32 index); int tcf_idr_search(struct tc_action_net *tn, struct tc_action **a, u32 index);
bool tcf_idr_check(struct tc_action_net *tn, u32 index, struct tc_action **a, bool tcf_idr_check(struct tc_action_net *tn, u32 index, struct tc_action **a,
int bind); int bind);
......
...@@ -202,7 +202,8 @@ static int tcf_del_walker(struct tcf_idrinfo *idrinfo, struct sk_buff *skb, ...@@ -202,7 +202,8 @@ static int tcf_del_walker(struct tcf_idrinfo *idrinfo, struct sk_buff *skb,
int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb, int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb,
struct netlink_callback *cb, int type, struct netlink_callback *cb, int type,
const struct tc_action_ops *ops) const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{ {
struct tcf_idrinfo *idrinfo = tn->idrinfo; struct tcf_idrinfo *idrinfo = tn->idrinfo;
...@@ -211,7 +212,8 @@ int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb, ...@@ -211,7 +212,8 @@ int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb,
} else if (type == RTM_GETACTION) { } else if (type == RTM_GETACTION) {
return tcf_dump_walker(idrinfo, skb, cb); return tcf_dump_walker(idrinfo, skb, cb);
} else { } else {
WARN(1, "tcf_generic_walker: unknown action %d\n", type); WARN(1, "tcf_generic_walker: unknown command %d\n", type);
NL_SET_ERR_MSG(extack, "tcf_generic_walker: unknown command");
return -EINVAL; return -EINVAL;
} }
} }
......
...@@ -372,7 +372,7 @@ static int tcf_bpf_walker(struct net *net, struct sk_buff *skb, ...@@ -372,7 +372,7 @@ static int tcf_bpf_walker(struct net *net, struct sk_buff *skb,
{ {
struct tc_action_net *tn = net_generic(net, bpf_net_id); struct tc_action_net *tn = net_generic(net, bpf_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops); return tcf_generic_walker(tn, skb, cb, type, ops, extack);
} }
static int tcf_bpf_search(struct net *net, struct tc_action **a, u32 index, static int tcf_bpf_search(struct net *net, struct tc_action **a, u32 index,
......
...@@ -182,7 +182,7 @@ static int tcf_connmark_walker(struct net *net, struct sk_buff *skb, ...@@ -182,7 +182,7 @@ static int tcf_connmark_walker(struct net *net, struct sk_buff *skb,
{ {
struct tc_action_net *tn = net_generic(net, connmark_net_id); struct tc_action_net *tn = net_generic(net, connmark_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops); return tcf_generic_walker(tn, skb, cb, type, ops, extack);
} }
static int tcf_connmark_search(struct net *net, struct tc_action **a, u32 index, static int tcf_connmark_search(struct net *net, struct tc_action **a, u32 index,
......
...@@ -636,7 +636,7 @@ static int tcf_csum_walker(struct net *net, struct sk_buff *skb, ...@@ -636,7 +636,7 @@ static int tcf_csum_walker(struct net *net, struct sk_buff *skb,
{ {
struct tc_action_net *tn = net_generic(net, csum_net_id); struct tc_action_net *tn = net_generic(net, csum_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops); return tcf_generic_walker(tn, skb, cb, type, ops, extack);
} }
static int tcf_csum_search(struct net *net, struct tc_action **a, u32 index, static int tcf_csum_search(struct net *net, struct tc_action **a, u32 index,
......
...@@ -206,7 +206,7 @@ static int tcf_gact_walker(struct net *net, struct sk_buff *skb, ...@@ -206,7 +206,7 @@ static int tcf_gact_walker(struct net *net, struct sk_buff *skb,
{ {
struct tc_action_net *tn = net_generic(net, gact_net_id); struct tc_action_net *tn = net_generic(net, gact_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops); return tcf_generic_walker(tn, skb, cb, type, ops, extack);
} }
static int tcf_gact_search(struct net *net, struct tc_action **a, u32 index, static int tcf_gact_search(struct net *net, struct tc_action **a, u32 index,
......
...@@ -829,7 +829,7 @@ static int tcf_ife_walker(struct net *net, struct sk_buff *skb, ...@@ -829,7 +829,7 @@ static int tcf_ife_walker(struct net *net, struct sk_buff *skb,
{ {
struct tc_action_net *tn = net_generic(net, ife_net_id); struct tc_action_net *tn = net_generic(net, ife_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops); return tcf_generic_walker(tn, skb, cb, type, ops, extack);
} }
static int tcf_ife_search(struct net *net, struct tc_action **a, u32 index, static int tcf_ife_search(struct net *net, struct tc_action **a, u32 index,
......
...@@ -308,7 +308,7 @@ static int tcf_ipt_walker(struct net *net, struct sk_buff *skb, ...@@ -308,7 +308,7 @@ static int tcf_ipt_walker(struct net *net, struct sk_buff *skb,
{ {
struct tc_action_net *tn = net_generic(net, ipt_net_id); struct tc_action_net *tn = net_generic(net, ipt_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops); return tcf_generic_walker(tn, skb, cb, type, ops, extack);
} }
static int tcf_ipt_search(struct net *net, struct tc_action **a, u32 index, static int tcf_ipt_search(struct net *net, struct tc_action **a, u32 index,
...@@ -358,7 +358,7 @@ static int tcf_xt_walker(struct net *net, struct sk_buff *skb, ...@@ -358,7 +358,7 @@ static int tcf_xt_walker(struct net *net, struct sk_buff *skb,
{ {
struct tc_action_net *tn = net_generic(net, xt_net_id); struct tc_action_net *tn = net_generic(net, xt_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops); return tcf_generic_walker(tn, skb, cb, type, ops, extack);
} }
static int tcf_xt_search(struct net *net, struct tc_action **a, u32 index, static int tcf_xt_search(struct net *net, struct tc_action **a, u32 index,
......
...@@ -270,7 +270,7 @@ static int tcf_mirred_walker(struct net *net, struct sk_buff *skb, ...@@ -270,7 +270,7 @@ static int tcf_mirred_walker(struct net *net, struct sk_buff *skb,
{ {
struct tc_action_net *tn = net_generic(net, mirred_net_id); struct tc_action_net *tn = net_generic(net, mirred_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops); return tcf_generic_walker(tn, skb, cb, type, ops, extack);
} }
static int tcf_mirred_search(struct net *net, struct tc_action **a, u32 index, static int tcf_mirred_search(struct net *net, struct tc_action **a, u32 index,
......
...@@ -283,7 +283,7 @@ static int tcf_nat_walker(struct net *net, struct sk_buff *skb, ...@@ -283,7 +283,7 @@ static int tcf_nat_walker(struct net *net, struct sk_buff *skb,
{ {
struct tc_action_net *tn = net_generic(net, nat_net_id); struct tc_action_net *tn = net_generic(net, nat_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops); return tcf_generic_walker(tn, skb, cb, type, ops, extack);
} }
static int tcf_nat_search(struct net *net, struct tc_action **a, u32 index, static int tcf_nat_search(struct net *net, struct tc_action **a, u32 index,
......
...@@ -424,7 +424,7 @@ static int tcf_pedit_walker(struct net *net, struct sk_buff *skb, ...@@ -424,7 +424,7 @@ static int tcf_pedit_walker(struct net *net, struct sk_buff *skb,
{ {
struct tc_action_net *tn = net_generic(net, pedit_net_id); struct tc_action_net *tn = net_generic(net, pedit_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops); return tcf_generic_walker(tn, skb, cb, type, ops, extack);
} }
static int tcf_pedit_search(struct net *net, struct tc_action **a, u32 index, static int tcf_pedit_search(struct net *net, struct tc_action **a, u32 index,
......
...@@ -63,7 +63,7 @@ static int tcf_act_police_walker(struct net *net, struct sk_buff *skb, ...@@ -63,7 +63,7 @@ static int tcf_act_police_walker(struct net *net, struct sk_buff *skb,
{ {
struct tc_action_net *tn = net_generic(net, police_net_id); struct tc_action_net *tn = net_generic(net, police_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops); return tcf_generic_walker(tn, skb, cb, type, ops, extack);
} }
static const struct nla_policy police_policy[TCA_POLICE_MAX + 1] = { static const struct nla_policy police_policy[TCA_POLICE_MAX + 1] = {
......
...@@ -207,7 +207,7 @@ static int tcf_sample_walker(struct net *net, struct sk_buff *skb, ...@@ -207,7 +207,7 @@ static int tcf_sample_walker(struct net *net, struct sk_buff *skb,
{ {
struct tc_action_net *tn = net_generic(net, sample_net_id); struct tc_action_net *tn = net_generic(net, sample_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops); return tcf_generic_walker(tn, skb, cb, type, ops, extack);
} }
static int tcf_sample_search(struct net *net, struct tc_action **a, u32 index, static int tcf_sample_search(struct net *net, struct tc_action **a, u32 index,
......
...@@ -175,7 +175,7 @@ static int tcf_simp_walker(struct net *net, struct sk_buff *skb, ...@@ -175,7 +175,7 @@ static int tcf_simp_walker(struct net *net, struct sk_buff *skb,
{ {
struct tc_action_net *tn = net_generic(net, simp_net_id); struct tc_action_net *tn = net_generic(net, simp_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops); return tcf_generic_walker(tn, skb, cb, type, ops, extack);
} }
static int tcf_simp_search(struct net *net, struct tc_action **a, u32 index, static int tcf_simp_search(struct net *net, struct tc_action **a, u32 index,
......
...@@ -213,7 +213,7 @@ static int tcf_skbedit_walker(struct net *net, struct sk_buff *skb, ...@@ -213,7 +213,7 @@ static int tcf_skbedit_walker(struct net *net, struct sk_buff *skb,
{ {
struct tc_action_net *tn = net_generic(net, skbedit_net_id); struct tc_action_net *tn = net_generic(net, skbedit_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops); return tcf_generic_walker(tn, skb, cb, type, ops, extack);
} }
static int tcf_skbedit_search(struct net *net, struct tc_action **a, u32 index, static int tcf_skbedit_search(struct net *net, struct tc_action **a, u32 index,
......
...@@ -237,7 +237,7 @@ static int tcf_skbmod_walker(struct net *net, struct sk_buff *skb, ...@@ -237,7 +237,7 @@ static int tcf_skbmod_walker(struct net *net, struct sk_buff *skb,
{ {
struct tc_action_net *tn = net_generic(net, skbmod_net_id); struct tc_action_net *tn = net_generic(net, skbmod_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops); return tcf_generic_walker(tn, skb, cb, type, ops, extack);
} }
static int tcf_skbmod_search(struct net *net, struct tc_action **a, u32 index, static int tcf_skbmod_search(struct net *net, struct tc_action **a, u32 index,
......
...@@ -296,7 +296,7 @@ static int tunnel_key_walker(struct net *net, struct sk_buff *skb, ...@@ -296,7 +296,7 @@ static int tunnel_key_walker(struct net *net, struct sk_buff *skb,
{ {
struct tc_action_net *tn = net_generic(net, tunnel_key_net_id); struct tc_action_net *tn = net_generic(net, tunnel_key_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops); return tcf_generic_walker(tn, skb, cb, type, ops, extack);
} }
static int tunnel_key_search(struct net *net, struct tc_action **a, u32 index, static int tunnel_key_search(struct net *net, struct tc_action **a, u32 index,
......
...@@ -272,7 +272,7 @@ static int tcf_vlan_walker(struct net *net, struct sk_buff *skb, ...@@ -272,7 +272,7 @@ static int tcf_vlan_walker(struct net *net, struct sk_buff *skb,
{ {
struct tc_action_net *tn = net_generic(net, vlan_net_id); struct tc_action_net *tn = net_generic(net, vlan_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops); return tcf_generic_walker(tn, skb, cb, type, ops, extack);
} }
static int tcf_vlan_search(struct net *net, struct tc_action **a, u32 index, static int tcf_vlan_search(struct net *net, struct tc_action **a, u32 index,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment