Skip to content

Commit b362014

Browse files
Alexander Aringdavem330
authored andcommitted
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: Alexander Aring <aring@mojatatu.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 4178010 commit b362014

File tree

18 files changed

+23
-20
lines changed

18 files changed

+23
-20
lines changed

include/net/act_api.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ static inline void tc_action_net_exit(struct list_head *net_list,
140140

141141
int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb,
142142
struct netlink_callback *cb, int type,
143-
const struct tc_action_ops *ops);
143+
const struct tc_action_ops *ops,
144+
struct netlink_ext_ack *extack);
144145
int tcf_idr_search(struct tc_action_net *tn, struct tc_action **a, u32 index);
145146
bool tcf_idr_check(struct tc_action_net *tn, u32 index, struct tc_action **a,
146147
int bind);

net/sched/act_api.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,8 @@ static int tcf_del_walker(struct tcf_idrinfo *idrinfo, struct sk_buff *skb,
202202

203203
int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb,
204204
struct netlink_callback *cb, int type,
205-
const struct tc_action_ops *ops)
205+
const struct tc_action_ops *ops,
206+
struct netlink_ext_ack *extack)
206207
{
207208
struct tcf_idrinfo *idrinfo = tn->idrinfo;
208209

@@ -211,7 +212,8 @@ int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb,
211212
} else if (type == RTM_GETACTION) {
212213
return tcf_dump_walker(idrinfo, skb, cb);
213214
} else {
214-
WARN(1, "tcf_generic_walker: unknown action %d\n", type);
215+
WARN(1, "tcf_generic_walker: unknown command %d\n", type);
216+
NL_SET_ERR_MSG(extack, "tcf_generic_walker: unknown command");
215217
return -EINVAL;
216218
}
217219
}

net/sched/act_bpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ static int tcf_bpf_walker(struct net *net, struct sk_buff *skb,
372372
{
373373
struct tc_action_net *tn = net_generic(net, bpf_net_id);
374374

375-
return tcf_generic_walker(tn, skb, cb, type, ops);
375+
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
376376
}
377377

378378
static int tcf_bpf_search(struct net *net, struct tc_action **a, u32 index,

net/sched/act_connmark.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ static int tcf_connmark_walker(struct net *net, struct sk_buff *skb,
182182
{
183183
struct tc_action_net *tn = net_generic(net, connmark_net_id);
184184

185-
return tcf_generic_walker(tn, skb, cb, type, ops);
185+
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
186186
}
187187

188188
static int tcf_connmark_search(struct net *net, struct tc_action **a, u32 index,

net/sched/act_csum.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ static int tcf_csum_walker(struct net *net, struct sk_buff *skb,
636636
{
637637
struct tc_action_net *tn = net_generic(net, csum_net_id);
638638

639-
return tcf_generic_walker(tn, skb, cb, type, ops);
639+
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
640640
}
641641

642642
static int tcf_csum_search(struct net *net, struct tc_action **a, u32 index,

net/sched/act_gact.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ static int tcf_gact_walker(struct net *net, struct sk_buff *skb,
206206
{
207207
struct tc_action_net *tn = net_generic(net, gact_net_id);
208208

209-
return tcf_generic_walker(tn, skb, cb, type, ops);
209+
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
210210
}
211211

212212
static int tcf_gact_search(struct net *net, struct tc_action **a, u32 index,

net/sched/act_ife.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ static int tcf_ife_walker(struct net *net, struct sk_buff *skb,
829829
{
830830
struct tc_action_net *tn = net_generic(net, ife_net_id);
831831

832-
return tcf_generic_walker(tn, skb, cb, type, ops);
832+
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
833833
}
834834

835835
static int tcf_ife_search(struct net *net, struct tc_action **a, u32 index,

net/sched/act_ipt.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ static int tcf_ipt_walker(struct net *net, struct sk_buff *skb,
308308
{
309309
struct tc_action_net *tn = net_generic(net, ipt_net_id);
310310

311-
return tcf_generic_walker(tn, skb, cb, type, ops);
311+
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
312312
}
313313

314314
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,
358358
{
359359
struct tc_action_net *tn = net_generic(net, xt_net_id);
360360

361-
return tcf_generic_walker(tn, skb, cb, type, ops);
361+
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
362362
}
363363

364364
static int tcf_xt_search(struct net *net, struct tc_action **a, u32 index,

net/sched/act_mirred.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -270,7 +270,7 @@ static int tcf_mirred_walker(struct net *net, struct sk_buff *skb,
270270
{
271271
struct tc_action_net *tn = net_generic(net, mirred_net_id);
272272

273-
return tcf_generic_walker(tn, skb, cb, type, ops);
273+
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
274274
}
275275

276276
static int tcf_mirred_search(struct net *net, struct tc_action **a, u32 index,

net/sched/act_nat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ static int tcf_nat_walker(struct net *net, struct sk_buff *skb,
283283
{
284284
struct tc_action_net *tn = net_generic(net, nat_net_id);
285285

286-
return tcf_generic_walker(tn, skb, cb, type, ops);
286+
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
287287
}
288288

289289
static int tcf_nat_search(struct net *net, struct tc_action **a, u32 index,

0 commit comments

Comments
 (0)