net: sched: act: add extack support
Subsystems (5)
v2 cover net: sched: act: add extack support
Hi,
this patch series adds extack support for the TC action subsystem. As example I for the extack support in a TC action I choosed mirred action.
- Alex
changes since v2:
- remove newline in extack of generic walker handling Thanks to Davide Caratti
- add [email protected] in cc
Alexander Aring (8):
net: sched: act: fix code style
net: sched: act: add extack to init
net: sched: act: handle generic action errors
net: sched: act: add extack to init callback
net: sched: act: add extack for lookup callback
net: sched: act: add extack for walk callback
net: sched: act: handle extack in tcf_generic_walker
net: sched: act: mirred: add extack support
include/net/act_api.h | 17 ++++-- net/sched/act_api.c | 135 +++++++++++++++++++++++++++++---------------- net/sched/act_bpf.c | 10 ++-- net/sched/act_connmark.c | 11 ++-- net/sched/act_csum.c | 10 ++-- net/sched/act_gact.c | 10 ++-- net/sched/act_ife.c | 10 ++-- net/sched/act_ipt.c | 20 ++++--- net/sched/act_mirred.c | 25 ++++++--- net/sched/act_nat.c | 11 ++-- net/sched/act_pedit.c | 10 ++-- net/sched/act_police.c | 11 ++-- net/sched/act_sample.c | 10 ++-- net/sched/act_simple.c | 10 ++-- net/sched/act_skbedit.c | 10 ++-- net/sched/act_skbmod.c | 10 ++-- net/sched/act_tunnel_key.c | 10 ++-- net/sched/act_vlan.c | 10 ++-- net/sched/cls_api.c | 4 +- 19 files changed, 215 insertions(+), 129 deletions(-)
Signature · 1 line
2.11.0
PATCH v2 1/8 net: sched: act: fix code style
This patch is used by subsequent patches. It fixes code style issues caught by checkpatch.
--- include/net/act_api.h | 5 +++-- net/sched/act_api.c | 12 ++++++------ net/sched/act_mirred.c | 6 +++--- 3 files changed, 12 insertions(+), 11 deletions(-)
include/net/act_api.h +3 -2
@@ -87,12 +87,13 @@ struct tc_action_ops { struct tcf_result *);int (*dump)(struct sk_buff *,struct tc_action *,int ,int );void (*cleanup)(struct tc_action *); -int (*lookup)(struct net *,struct tc_action **,u32 ); +int (*lookup)(struct net *net,struct tc_action **a,u32 index);int (*init)(struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **act,int ovr,int bind);int (*walk)(struct net *,struct sk_buff *, -struct netlink_callback *,int ,const struct tc_action_ops *); +struct netlink_callback *,int , +const struct tc_action_ops *);void (*stats_update)(struct tc_action *,u64 ,u32 ,u64 );struct net_device *(*get_dev)(const struct tc_action *a); };
net/sched/act_api.c +6 -6
@@ -621,7 +621,7 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, goto err_out; err = -EINVAL ; kind = tb[TCA_ACT_KIND ]; -if (kind ==NULL ) +if (!kind) goto err_out;if (nla_strlcpy (act_name, kind,IFNAMSIZ ) >=IFNAMSIZ ) goto err_out;
@@ -822,7 +822,7 @@ static int tca_get_fill(struct sk_buff *skb, struct list_head *actions, t->tca__pad2 =0 ; nest =nla_nest_start (skb,TCA_ACT_TAB ); -if (nest ==NULL ) +if (!nest) goto out_nlmsg_trim;if (tcf_action_dump (skb, actions, bind, ref) <0 )
@@ -934,7 +934,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla, t->tca__pad2 =0 ; nest =nla_nest_start (skb,TCA_ACT_TAB ); -if (nest ==NULL ) +if (!nest) goto out_module_put; err = ops->walk (net, skb, &dcb,RTM_DELACTION , ops);
@@ -1005,10 +1005,10 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n,return ret;if (event ==RTM_DELACTION && n->nlmsg_flags &NLM_F_ROOT ) { -if (tb[1 ] !=NULL ) +if (tb[1 ])return tca_action_flush (net, tb[1 ], n, portid); -else -return -EINVAL ; + +return -EINVAL ; }for (i =1 ; i <=TCA_ACT_MAX_PRIO && tb[i]; i++) {
net/sched/act_mirred.c +3 -3
@@ -80,12 +80,12 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,bool exists = false;int ret; -if (nla ==NULL ) +if (!nla)return -EINVAL ; ret =nla_parse_nested (tb,TCA_MIRRED_MAX , nla, mirred_policy,NULL );if (ret <0 )return ret; -if (tb[TCA_MIRRED_PARMS ] ==NULL ) +if (!tb[TCA_MIRRED_PARMS ])return -EINVAL ; parm =nla_data (tb[TCA_MIRRED_PARMS ]);
@@ -117,7 +117,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, }if (!exists) { -if (dev ==NULL ) +if (!dev)return -EINVAL ; ret =tcf_idr_create (tn, parm->index, est, a, &act_mirred_ops, bind, true);
Signature · 1 line
2.11.0
PATCH v2 2/8 net: sched: act: add extack to init
In reply to Alexander AringThis patch adds extack to tcf_action_init and tcf_action_init_1 functions. These are necessary to make individual extack handling in each act implementation.
Based on work by David Ahern <[email protected]>
--- include/net/act_api.h | 5 +++-- net/sched/act_api.c | 17 +++++++++++------ net/sched/cls_api.c | 4 ++-- 3 files changed, 16 insertions(+), 10 deletions(-)
include/net/act_api.h +3 -2
@@ -163,10 +163,11 @@ int tcf_action_exec(struct sk_buff *skb, struct tc_action **actions, int nr_actions, struct tcf_result *res);int tcf_action_init (struct net *net,struct tcf_proto *tp,struct nlattr *nla,struct nlattr *est,char *name,int ovr,int bind, -struct list_head *actions); +struct list_head *actions,struct netlink_ext_ack *extack);struct tc_action *tcf_action_init_1 (struct net *net,struct tcf_proto *tp,struct nlattr *nla,struct nlattr *est, -char *name,int ovr,int bind); +char *name,int ovr,int bind, +struct netlink_ext_ack *extack);int tcf_action_dump (struct sk_buff *skb,struct list_head *,int ,int );int tcf_action_dump_old (struct sk_buff *skb,struct tc_action *a,int ,int );int tcf_action_dump_1 (struct sk_buff *skb,struct tc_action *a,int ,int );
net/sched/act_api.c +11 -6
@@ -605,7 +605,8 @@ static struct tc_cookie *nla_memdup_cookie(struct nlattr **tb)struct tc_action *tcf_action_init_1 (struct net *net,struct tcf_proto *tp,struct nlattr *nla,struct nlattr *est, -char *name,int ovr,int bind) +char *name,int ovr,int bind, +struct netlink_ext_ack *extack) {struct tc_action *a;struct tc_action_ops *a_o;
@@ -726,7 +727,7 @@ static void cleanup_a(struct list_head *actions, int ovr)int tcf_action_init (struct net *net,struct tcf_proto *tp,struct nlattr *nla,struct nlattr *est,char *name,int ovr,int bind, -struct list_head *actions) +struct list_head *actions,struct netlink_ext_ack *extack) {struct nlattr *tb[TCA_ACT_MAX_PRIO +1 ];struct tc_action *act;
@@ -738,7 +739,8 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,return err;for (i =1 ; i <=TCA_ACT_MAX_PRIO && tb[i]; i++) { - act =tcf_action_init_1 (net, tp, tb[i], est, name, ovr, bind); + act =tcf_action_init_1 (net, tp, tb[i], est, name, ovr, bind, + extack);if (IS_ERR (act)) { err =PTR_ERR (act); goto err;
@@ -1060,12 +1062,14 @@ tcf_add_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions, }static int tcf_action_add (struct net *net,struct nlattr *nla, -struct nlmsghdr *n,u32 portid,int ovr) +struct nlmsghdr *n,u32 portid,int ovr, +struct netlink_ext_ack *extack) {int ret =0 ;LIST_HEAD (actions); - ret =tcf_action_init (net,NULL , nla,NULL ,NULL , ovr,0 , &actions); + ret =tcf_action_init (net,NULL , nla,NULL ,NULL , ovr,0 , &actions, + extack);if (ret)return ret;
@@ -1113,7 +1117,8 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n,if (n->nlmsg_flags &NLM_F_REPLACE ) ovr =1 ; replay: - ret =tcf_action_add (net, tca[TCA_ACT_TAB ], n, portid, ovr); + ret =tcf_action_add (net, tca[TCA_ACT_TAB ], n, portid, ovr, + extack);if (ret == -EAGAIN ) goto replay;break ;
net/sched/cls_api.c +2 -2
@@ -1434,7 +1434,7 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb,if (exts->police && tb[exts->police]) { act =tcf_action_init_1 (net, tp, tb[exts->police], rate_tlv,"police" , ovr, -TCA_ACT_BIND ); +TCA_ACT_BIND , extack);if (IS_ERR (act))return PTR_ERR (act);
@@ -1447,7 +1447,7 @@ int tcf_exts_validate(struct net *net, struct tcf_proto *tp, struct nlattr **tb, err =tcf_action_init (net, tp, tb[exts->action], rate_tlv,NULL , ovr,TCA_ACT_BIND , - &actions); + &actions, extack);if (err)return err;list_for_each_entry (act, &actions, list)
Signature · 1 line
2.11.0
PATCH v2 3/8 net: sched: act: handle generic action errors
In reply to Alexander AringThis patch adds extack support for generic act handling. The extack will be set deeper to each called function which is not part of netdev core api.
Based on work by David Ahern <[email protected]>
--- net/sched/act_api.c | 93 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 32 deletions(-)
net/sched/act_api.c +61 -32
@@ -617,31 +617,40 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,int err;if (name ==NULL ) { - err =nla_parse_nested (tb,TCA_ACT_MAX , nla,NULL ,NULL ); + err =nla_parse_nested (tb,TCA_ACT_MAX , nla,NULL , extack);if (err <0 ) goto err_out; err = -EINVAL ; kind = tb[TCA_ACT_KIND ]; -if (!kind) +if (!kind) { +NL_SET_ERR_MSG (extack,"TC action kind must be specified" ); goto err_out; -if (nla_strlcpy (act_name, kind,IFNAMSIZ ) >=IFNAMSIZ ) + } +if (nla_strlcpy (act_name, kind,IFNAMSIZ ) >=IFNAMSIZ ) { +NL_SET_ERR_MSG (extack,"TC action name too long" ); goto err_out; + }if (tb[TCA_ACT_COOKIE ]) {int cklen =nla_len (tb[TCA_ACT_COOKIE ]); -if (cklen >TC_COOKIE_MAX_SIZE ) +if (cklen >TC_COOKIE_MAX_SIZE ) { +NL_SET_ERR_MSG (extack,"TC cookie size above the maximum" ); goto err_out; + } cookie =nla_memdup_cookie (tb);if (!cookie) { +NL_SET_ERR_MSG (extack,"No memory to generate TC cookie" ); err = -ENOMEM ; goto err_out; } } }else { - err = -EINVAL ; -if (strlcpy (act_name, name,IFNAMSIZ ) >=IFNAMSIZ ) +if (strlcpy (act_name, name,IFNAMSIZ ) >=IFNAMSIZ ) { +NL_SET_ERR_MSG (extack,"TC action name too long" ); + err = -EINVAL ; goto err_out; + } } a_o =tc_lookup_action_n (act_name);
@@ -664,6 +673,7 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, goto err_mod; }#endif +NL_SET_ERR_MSG (extack,"Failed to load TC action module" ); err = -ENOENT ; goto err_out; }
@@ -698,6 +708,7 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,list_add_tail (&a->list, &actions);tcf_action_destroy (&actions, bind); +NL_SET_ERR_MSG (extack,"Failed to init action chain" );return ERR_PTR (err); } }
@@ -734,7 +745,7 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,int err;int i; - err =nla_parse_nested (tb,TCA_ACT_MAX_PRIO , nla,NULL ,NULL ); + err =nla_parse_nested (tb,TCA_ACT_MAX_PRIO , nla,NULL , extack);if (err <0 )return err;
@@ -842,7 +853,8 @@ static int tca_get_fill(struct sk_buff *skb, struct list_head *actions,static int tcf_get_notify (struct net *net,u32 portid,struct nlmsghdr *n, -struct list_head *actions,int event) +struct list_head *actions,int event, +struct netlink_ext_ack *extack) {struct sk_buff *skb;
@@ -851,6 +863,7 @@ tcf_get_notify(struct net *net, u32 portid, struct nlmsghdr *n,return -ENOBUFS ;if (tca_get_fill (skb, actions, portid, n->nlmsg_seq,0 , event,0 ,0 ) <=0 ) { +NL_SET_ERR_MSG (extack,"Failed to fill netlink tc action attributes" );kfree_skb (skb);return -EINVAL ; }
@@ -859,7 +872,8 @@ tcf_get_notify(struct net *net, u32 portid, struct nlmsghdr *n, }static struct tc_action *tcf_action_get_1 (struct net *net,struct nlattr *nla, -struct nlmsghdr *n,u32 portid) +struct nlmsghdr *n,u32 portid, +struct netlink_ext_ack *extack) {struct nlattr *tb[TCA_ACT_MAX +1 ];const struct tc_action_ops *ops;
@@ -867,20 +881,24 @@ static struct tc_action *tcf_action_get_1(struct net *net, struct nlattr *nla,int index;int err; - err =nla_parse_nested (tb,TCA_ACT_MAX , nla,NULL ,NULL ); + err =nla_parse_nested (tb,TCA_ACT_MAX , nla,NULL , extack);if (err <0 ) goto err_out; err = -EINVAL ;if (tb[TCA_ACT_INDEX ] ==NULL || -nla_len (tb[TCA_ACT_INDEX ]) <sizeof (index)) +nla_len (tb[TCA_ACT_INDEX ]) <sizeof (index)) { +NL_SET_ERR_MSG (extack,"Invalid TC action index value" ); goto err_out; + } index =nla_get_u32 (tb[TCA_ACT_INDEX ]); err = -EINVAL ; ops =tc_lookup_action (tb[TCA_ACT_KIND ]); -if (!ops)/* could happen in batch of actions */ +if (!ops) {/* could happen in batch of actions */ +NL_SET_ERR_MSG (extack,"Specified TC action not found" ); goto err_out; + } err = -ENOENT ;if (ops->lookup (net, &a, index) ==0 ) goto err_mod;
@@ -895,7 +913,8 @@ static struct tc_action *tcf_action_get_1(struct net *net, struct nlattr *nla, }static int tca_action_flush (struct net *net,struct nlattr *nla, -struct nlmsghdr *n,u32 portid) +struct nlmsghdr *n,u32 portid, +struct netlink_ext_ack *extack) {struct sk_buff *skb;unsigned char *b;
@@ -909,35 +928,39 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,int err = -ENOMEM ; skb =alloc_skb (NLMSG_GOODSIZE ,GFP_KERNEL ); -if (!skb) { -pr_debug ("tca_action_flush: failed skb alloc\n" ); +if (!skb)return err; - } b =skb_tail_pointer (skb); - err =nla_parse_nested (tb,TCA_ACT_MAX , nla,NULL ,NULL ); + err =nla_parse_nested (tb,TCA_ACT_MAX , nla,NULL , extack);if (err <0 ) goto err_out; err = -EINVAL ; kind = tb[TCA_ACT_KIND ]; ops =tc_lookup_action (kind); -if (!ops)/*some idjot trying to flush unknown action */ +if (!ops) {/*some idjot trying to flush unknown action */ +NL_SET_ERR_MSG (extack,"Aborted Flush. Cannot flush unknown TC action" ); goto err_out; + } nlh =nlmsg_put (skb, portid, n->nlmsg_seq,RTM_DELACTION ,sizeof (*t),0 ); -if (!nlh) +if (!nlh) { +NL_SET_ERR_MSG (extack,"Aborted Flush. Failed to create flush netlink notification" ); goto out_module_put; + } t =nlmsg_data (nlh); t->tca_family =AF_UNSPEC ; t->tca__pad1 =0 ; t->tca__pad2 =0 ; nest =nla_nest_start (skb,TCA_ACT_TAB ); -if (!nest) +if (!nest) { +NL_SET_ERR_MSG (extack,"Failed to add new netlink message" ); goto out_module_put; + } err = ops->walk (net, skb, &dcb,RTM_DELACTION , ops);if (err <=0 )
@@ -952,6 +975,8 @@ static int tca_action_flush(struct net *net, struct nlattr *nla, n->nlmsg_flags & NLM_F_ECHO);if (err >0 )return 0 ; +if (err <0 ) +NL_SET_ERR_MSG (extack,"Failed to send flush notification" );return err;
@@ -964,7 +989,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,static int tcf_del_notify (struct net *net,struct nlmsghdr *n,struct list_head *actions, -u32 portid) +u32 portid,struct netlink_ext_ack *extack) {int ret;struct sk_buff *skb;
@@ -975,6 +1000,7 @@ tcf_del_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,if (tca_get_fill (skb, actions, portid, n->nlmsg_seq,0 ,RTM_DELACTION ,0 ,1 ) <=0 ) { +NL_SET_ERR_MSG (extack,"Failed to fill netlink tc action attributes" );kfree_skb (skb);return -EINVAL ; }
@@ -982,6 +1008,7 @@ tcf_del_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,/* now do the delete */ ret =tcf_action_destroy (actions,0 );if (ret <0 ) { +NL_SET_ERR_MSG (extack,"Failed to delete TC action" );kfree_skb (skb);return ret; }
@@ -995,26 +1022,27 @@ tcf_del_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,static int tca_action_gd (struct net *net,struct nlattr *nla,struct nlmsghdr *n, -u32 portid,int event) +u32 portid,int event,struct netlink_ext_ack *extack) {int i, ret;struct nlattr *tb[TCA_ACT_MAX_PRIO +1 ];struct tc_action *act;LIST_HEAD (actions); - ret =nla_parse_nested (tb,TCA_ACT_MAX_PRIO , nla,NULL ,NULL ); + ret =nla_parse_nested (tb,TCA_ACT_MAX_PRIO , nla,NULL , extack);if (ret <0 )return ret;if (event ==RTM_DELACTION && n->nlmsg_flags &NLM_F_ROOT ) {if (tb[1 ]) -return tca_action_flush (net, tb[1 ], n, portid); +return tca_action_flush (net, tb[1 ], n, portid, extack); +NL_SET_ERR_MSG (extack,"Invalid netlink attributes to flush actions" );return -EINVAL ; }for (i =1 ; i <=TCA_ACT_MAX_PRIO && tb[i]; i++) { - act =tcf_action_get_1 (net, tb[i], n, portid); + act =tcf_action_get_1 (net, tb[i], n, portid, extack);if (IS_ERR (act)) { ret =PTR_ERR (act); goto err;
@@ -1024,9 +1052,9 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, }if (event ==RTM_GETACTION ) - ret =tcf_get_notify (net, portid, n, &actions, event); + ret =tcf_get_notify (net, portid, n, &actions, event, extack);else {/* delete */ - ret =tcf_del_notify (net, n, &actions, portid); + ret =tcf_del_notify (net, n, &actions, portid, extack);if (ret) goto err;return ret;
@@ -1039,7 +1067,7 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n,static int tcf_add_notify (struct net *net,struct nlmsghdr *n,struct list_head *actions, -u32 portid) +u32 portid,struct netlink_ext_ack *extack) {struct sk_buff *skb;int err =0 ;
@@ -1050,6 +1078,7 @@ tcf_add_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,if (tca_get_fill (skb, actions, portid, n->nlmsg_seq, n->nlmsg_flags,RTM_NEWACTION ,0 ,0 ) <=0 ) { +NL_SET_ERR_MSG (extack,"Failed to fill netlink tc action attributes" );kfree_skb (skb);return -EINVAL ; }
@@ -1073,7 +1102,7 @@ static int tcf_action_add(struct net *net, struct nlattr *nla,if (ret)return ret; -return tcf_add_notify (net, n, &actions, portid); +return tcf_add_notify (net, n, &actions, portid, extack); }static u32 tcaa_root_flags_allowed =TCA_FLAG_LARGE_DUMP_ON ;
@@ -1101,7 +1130,7 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n,return ret;if (tca[TCA_ACT_TAB ] ==NULL ) { -pr_notice ("tc_ctl_action: received NO action attribs\n" ); +NL_SET_ERR_MSG (extack,"Netlink Action attributes missing" );return -EINVAL ; }
@@ -1124,11 +1153,11 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n,break ;case RTM_DELACTION : ret =tca_action_gd (net, tca[TCA_ACT_TAB ], n, - portid,RTM_DELACTION ); + portid,RTM_DELACTION , extack);break ;case RTM_GETACTION : ret =tca_action_gd (net, tca[TCA_ACT_TAB ], n, - portid,RTM_GETACTION ); + portid,RTM_GETACTION , extack);break ;default :BUG ();
Signature · 1 line
2.11.0
Re: [PATCHv2 net-next 3/8] net: sched: act: handle generic action errors
Quoted 5 lines · Alexander Aring
This patch adds extack support for generic act handling. The extack will be set deeper to each called function which is not part of netdev core api.
Based on work by David Ahern <[email protected]>
hello Alexander,
after looking at the code more closely, I think there is margin for some more improvement here (i.e make the message contents easier to grep from a log). Please let me know if the comments below make sense for you.
thank you in advance!
Signature · 1 line
davide
Quoted 66 lines
Cc David Ahern <[email protected]>Signed-off-by Alexander Aring <[email protected]>--- net/sched/act_api.c | 93 +++++++++++++++++++++++++++++++++++------------------ 1 file changed, 61 insertions(+), 32 deletions(-)net/sched/act_api.c +16
-6@@ -617,31 +617,40 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,int err;if (name ==NULL ) { - err =nla_parse_nested (tb,TCA_ACT_MAX , nla,NULL ,NULL ); + err =nla_parse_nested (tb,TCA_ACT_MAX , nla,NULL , extack);if (err <0 ) goto err_out; err = -EINVAL ; kind = tb[TCA_ACT_KIND ]; -if (!kind) +if (!kind) { +NL_SET_ERR_MSG (extack,"TC action kind must be specified" ); goto err_out; -if (nla_strlcpy (act_name, kind,IFNAMSIZ ) >=IFNAMSIZ ) + } +if (nla_strlcpy (act_name, kind,IFNAMSIZ ) >=IFNAMSIZ ) { +NL_SET_ERR_MSG (extack,"TC action name too long" ); goto err_out; + }if (tb[TCA_ACT_COOKIE ]) {int cklen =nla_len (tb[TCA_ACT_COOKIE ]); -if (cklen >TC_COOKIE_MAX_SIZE ) +if (cklen >TC_COOKIE_MAX_SIZE ) { +NL_SET_ERR_MSG (extack,"TC cookie size above the maximum" ); goto err_out; + } cookie =nla_memdup_cookie (tb);if (!cookie) { +NL_SET_ERR_MSG (extack,"No memory to generate TC cookie" ); err = -ENOMEM ; goto err_out; } } }else { - err = -EINVAL ; -if (strlcpy (act_name, name,IFNAMSIZ ) >=IFNAMSIZ ) +if (strlcpy (act_name, name,IFNAMSIZ ) >=IFNAMSIZ ) { +NL_SET_ERR_MSG (extack,"TC action name too long" ); + err = -EINVAL ; goto err_out; + } } a_o =tc_lookup_action_n (act_name);@@ -664,6 +673,7 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, goto err_mod; }#endif +NL_SET_ERR_MSG (extack,"Failed to load TC action module" ); err = -ENOENT ; goto err_out; }
net/sched/act_api.c struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp, · line 711
Quoted 4 lines
net/sched/act_api.c +1
-0@@ -698,6 +708,7 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,list_add_tail (&a->list, &actions);tcf_action_destroy (&actions, bind); +NL_SET_ERR_MSG (extack,"Failed to init action chain" );
most of the times, the word 'action' is prepended by the word 'TC'. Proposal:
"Failed to init TC action chain"
Quoted 23 lines
net/sched/act_api.c +3
-2return ERR_PTR (err); } }@@ -734,7 +745,7 @@ int tcf_action_init(struct net *net, struct tcf_proto *tp, struct nlattr *nla,int err;int i; - err =nla_parse_nested (tb,TCA_ACT_MAX_PRIO , nla,NULL ,NULL ); + err =nla_parse_nested (tb,TCA_ACT_MAX_PRIO , nla,NULL , extack);if (err <0 )return err;@@ -842,7 +853,8 @@ static int tca_get_fill(struct sk_buff *skb, struct list_head *actions,static int tcf_get_notify (struct net *net,u32 portid,struct nlmsghdr *n, -struct list_head *actions,int event) +struct list_head *actions,int event, +struct netlink_ext_ack *extack) {struct sk_buff *skb;
net/sched/act_api.c tcf_get_notify(struct net *net, u32 portid, struct nlmsghdr *n, · line 866
Quoted 4 lines
net/sched/act_api.c +1
-0@@ -851,6 +863,7 @@ tcf_get_notify(struct net *net, u32 portid, struct nlmsghdr *n,return -ENOBUFS ;if (tca_get_fill (skb, actions, portid, n->nlmsg_seq,0 , event,0 ,0 ) <=0 ) { +NL_SET_ERR_MSG (extack,"Failed to fill netlink tc action attributes" );
see also @@ -975,6 +1000,7 @@ and @@ -975,6 +1000,7 @@:
this is the same message you get in case tcf_add_notify() fails, and it's very similar to what you get when tcf_del_notify() fails: the only difference is uppercase/lowercase 'tc' word.
Proposal:
"Failed to fill netlink attributes while getting TC action"
Quoted 63 lines
net/sched/act_api.c +12
-8kfree_skb (skb);return -EINVAL ; }@@ -859,7 +872,8 @@ tcf_get_notify(struct net *net, u32 portid, struct nlmsghdr *n, }static struct tc_action *tcf_action_get_1 (struct net *net,struct nlattr *nla, -struct nlmsghdr *n,u32 portid) +struct nlmsghdr *n,u32 portid, +struct netlink_ext_ack *extack) {struct nlattr *tb[TCA_ACT_MAX +1 ];const struct tc_action_ops *ops;@@ -867,20 +881,24 @@ static struct tc_action *tcf_action_get_1(struct net *net, struct nlattr *nla,int index;int err; - err =nla_parse_nested (tb,TCA_ACT_MAX , nla,NULL ,NULL ); + err =nla_parse_nested (tb,TCA_ACT_MAX , nla,NULL , extack);if (err <0 ) goto err_out; err = -EINVAL ;if (tb[TCA_ACT_INDEX ] ==NULL || -nla_len (tb[TCA_ACT_INDEX ]) <sizeof (index)) +nla_len (tb[TCA_ACT_INDEX ]) <sizeof (index)) { +NL_SET_ERR_MSG (extack,"Invalid TC action index value" ); goto err_out; + } index =nla_get_u32 (tb[TCA_ACT_INDEX ]); err = -EINVAL ; ops =tc_lookup_action (tb[TCA_ACT_KIND ]); -if (!ops)/* could happen in batch of actions */ +if (!ops) {/* could happen in batch of actions */ +NL_SET_ERR_MSG (extack,"Specified TC action not found" ); goto err_out; + } err = -ENOENT ;if (ops->lookup (net, &a, index) ==0 ) goto err_mod;@@ -895,7 +913,8 @@ static struct tc_action *tcf_action_get_1(struct net *net, struct nlattr *nla, }static int tca_action_flush (struct net *net,struct nlattr *nla, -struct nlmsghdr *n,u32 portid) +struct nlmsghdr *n,u32 portid, +struct netlink_ext_ack *extack) {struct sk_buff *skb;unsigned char *b;@@ -909,35 +928,39 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,int err = -ENOMEM ; skb =alloc_skb (NLMSG_GOODSIZE ,GFP_KERNEL ); -if (!skb) { -pr_debug ("tca_action_flush: failed skb alloc\n" ); +if (!skb)return err; - } b =skb_tail_pointer (skb);
net/sched/act_api.c static int tca_action_flush(struct net *net, struct nlattr *nla, · line 943
Quoted 10 lines
net/sched/act_api.c +2
-2- err =nla_parse_nested (tb,TCA_ACT_MAX , nla,NULL ,NULL ); + err =nla_parse_nested (tb,TCA_ACT_MAX , nla,NULL , extack);if (err <0 ) goto err_out; err = -EINVAL ; kind = tb[TCA_ACT_KIND ]; ops =tc_lookup_action (kind); -if (!ops)/*some idjot trying to flush unknown action */ +if (!ops) {/*some idjot trying to flush unknown action */
the above comment was already there before your patch. I think that it can be removed, now that we have an error message for this situation; it's also funny (and harmless) to leave it - but then maybe it becomes more clear if the word 'idiot' is spelled correctly :)
net/sched/act_api.c static int tca_action_flush(struct net *net, struct nlattr *nla, · line 944
Quoted 1 line
net/sched/act_api.c +1
-0+NL_SET_ERR_MSG (extack,"Aborted Flush. Cannot flush unknown TC action" );
Also the tests below result in an aborted flush when they fail. So, 'Aborted Flush' can probably be omitted. Proposal:
"Cannot flush unknown TC action"
net/sched/act_api.c static int tca_action_flush(struct net *net, struct nlattr *nla, · line 951
Quoted 8 lines
net/sched/act_api.c +3
-1goto err_out; + } nlh =nlmsg_put (skb, portid, n->nlmsg_seq,RTM_DELACTION ,sizeof (*t),0 ); -if (!nlh) +if (!nlh) { +NL_SET_ERR_MSG (extack,"Aborted Flush. Failed to create flush netlink notification" );
Proposal:
"Failed to create netlink notification while flushing TC action". But I'm not sure that these kind of errors deserve an extended ACK (see below).
net/sched/act_api.c static int tca_action_flush(struct net *net, struct nlattr *nla, · line 961
Quoted 11 lines
net/sched/act_api.c +3
-1goto out_module_put; + } t =nlmsg_data (nlh); t->tca_family =AF_UNSPEC ; t->tca__pad1 =0 ; t->tca__pad2 =0 ; nest =nla_nest_start (skb,TCA_ACT_TAB ); -if (!nest) +if (!nest) { +NL_SET_ERR_MSG (extack,"Failed to add new netlink message" );
"Failed to set nested attribute while flushing TC action". But I'm not sure that this kind of errors deserve an extended ACK. Probaly a good compromise is to do a single message in the error path of the function (i.e. below the "out_module_put" label).
net/sched/act_api.c static int tca_action_flush(struct net *net, struct nlattr *nla, · line 966
Quoted 5 lines
net/sched/act_api.c +1
-0goto out_module_put; + } err = ops->walk (net, skb, &dcb,RTM_DELACTION , ops);if (err <=0 )
here the action flush is aborted because walk() failed. Is it worth adding a message here? (I'm also ok if there is a single error below "out_module_put" label).
(and, for the record, I think we miss a nla_nest_cancel() here. I will post a patch targeting 'net' today.)
net/sched/act_api.c static int tca_action_flush(struct net *net, struct nlattr *nla, · line 979
Quoted 6 lines
net/sched/act_api.c +2
-0@@ -952,6 +975,8 @@ static int tca_action_flush(struct net *net, struct nlattr *nla, n->nlmsg_flags & NLM_F_ECHO);if (err >0 )return 0 ; +if (err <0 ) +NL_SET_ERR_MSG (extack,"Failed to send flush notification" );
Proposal:
"Failed to send TC action flush notification"
Quoted 13 lines
net/sched/act_api.c +1
-1return err;@@ -964,7 +989,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,static int tcf_del_notify (struct net *net,struct nlmsghdr *n,struct list_head *actions, -u32 portid) +u32 portid,struct netlink_ext_ack *extack) {int ret;struct sk_buff *skb;
net/sched/act_api.c tcf_del_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions, · line 1003
Quoted 4 lines
net/sched/act_api.c +1
-0@@ -975,6 +1000,7 @@ tcf_del_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,if (tca_get_fill (skb, actions, portid, n->nlmsg_seq,0 ,RTM_DELACTION ,0 ,1 ) <=0 ) { +NL_SET_ERR_MSG (extack,"Failed to fill netlink tc action attributes" );
see also @@ -1039,7 +1067,7 @@:
this error message is almost the same as the one we get in case of failing tca_get_fill(..., RTM_NEWACTION, ...) in tcf_add_notify(). The only difference is the word 'tc' lowercase here, and uppercase word 'TC' in tcf_add_notify(). So, if these message must be different, it's better to specify better what went wrong _ something like:
"Failed to fill netlink attributes while deleting TC action"
Quoted 24 lines
net/sched/act_api.c +2
-2kfree_skb (skb);return -EINVAL ; }@@ -982,6 +1008,7 @@ tcf_del_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,/* now do the delete */ ret =tcf_action_destroy (actions,0 );if (ret <0 ) { +NL_SET_ERR_MSG (extack,"Failed to delete TC action" );kfree_skb (skb);return ret; }@@ -995,26 +1022,27 @@ tcf_del_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,static int tca_action_gd (struct net *net,struct nlattr *nla,struct nlmsghdr *n, -u32 portid,int event) +u32 portid,int event,struct netlink_ext_ack *extack) {int i, ret;struct nlattr *tb[TCA_ACT_MAX_PRIO +1 ];struct tc_action *act;LIST_HEAD (actions); - ret =nla_parse_nested (tb,TCA_ACT_MAX_PRIO , nla,NULL ,NULL );
net/sched/act_api.c tcf_del_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions, · line 1040
Quoted 10 lines
net/sched/act_api.c +3
-1+ ret =nla_parse_nested (tb,TCA_ACT_MAX_PRIO , nla,NULL , extack);if (ret <0 )return ret;if (event ==RTM_DELACTION && n->nlmsg_flags &NLM_F_ROOT ) {if (tb[1 ]) -return tca_action_flush (net, tb[1 ], n, portid); +return tca_action_flush (net, tb[1 ], n, portid, extack); +NL_SET_ERR_MSG (extack,"Invalid netlink attributes to flush actions" );
"Invalid netlink attributes while flushing TC action"
Quoted 31 lines
net/sched/act_api.c +4
-4return -EINVAL ; }for (i =1 ; i <=TCA_ACT_MAX_PRIO && tb[i]; i++) { - act =tcf_action_get_1 (net, tb[i], n, portid); + act =tcf_action_get_1 (net, tb[i], n, portid, extack);if (IS_ERR (act)) { ret =PTR_ERR (act); goto err;@@ -1024,9 +1052,9 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n, }if (event ==RTM_GETACTION ) - ret =tcf_get_notify (net, portid, n, &actions, event); + ret =tcf_get_notify (net, portid, n, &actions, event, extack);else {/* delete */ - ret =tcf_del_notify (net, n, &actions, portid); + ret =tcf_del_notify (net, n, &actions, portid, extack);if (ret) goto err;return ret;@@ -1039,7 +1067,7 @@ tca_action_gd(struct net *net, struct nlattr *nla, struct nlmsghdr *n,static int tcf_add_notify (struct net *net,struct nlmsghdr *n,struct list_head *actions, -u32 portid) +u32 portid,struct netlink_ext_ack *extack) {struct sk_buff *skb;int err =0 ;
net/sched/act_api.c tcf_add_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions, · line 1081
Quoted 4 lines
net/sched/act_api.c +1
-0@@ -1050,6 +1078,7 @@ tcf_add_notify(struct net *net, struct nlmsghdr *n, struct list_head *actions,if (tca_get_fill (skb, actions, portid, n->nlmsg_seq, n->nlmsg_flags,RTM_NEWACTION ,0 ,0 ) <=0 ) { +NL_SET_ERR_MSG (extack,"Failed to fill netlink tc action attributes" );
see comment at @@ -975,6 +1000,7 @@
"Failed to fill netlink attributes while adding TC action"
Quoted 13 lines
net/sched/act_api.c +1
-1kfree_skb (skb);return -EINVAL ; }@@ -1073,7 +1102,7 @@ static int tcf_action_add(struct net *net, struct nlattr *nla,if (ret)return ret; -return tcf_add_notify (net, n, &actions, portid); +return tcf_add_notify (net, n, &actions, portid, extack); }static u32 tcaa_root_flags_allowed =TCA_FLAG_LARGE_DUMP_ON ;
net/sched/act_api.c static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n, · line 1133
Quoted 5 lines
net/sched/act_api.c +1
-1@@ -1101,7 +1130,7 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n,return ret;if (tca[TCA_ACT_TAB ] ==NULL ) { -pr_notice ("tc_ctl_action: received NO action attribs\n" ); +NL_SET_ERR_MSG (extack,"Netlink Action attributes missing" );
"action" is lowercase in almost all messages, and tipically prepended by 'TC' keyword:
"Missing netlink attributes for TC action"
Quoted 17 lines
net/sched/act_api.c +2
-2return -EINVAL ; }@@ -1124,11 +1153,11 @@ static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n,break ;case RTM_DELACTION : ret =tca_action_gd (net, tca[TCA_ACT_TAB ], n, - portid,RTM_DELACTION ); + portid,RTM_DELACTION , extack);break ;case RTM_GETACTION : ret =tca_action_gd (net, tca[TCA_ACT_TAB ], n, - portid,RTM_GETACTION ); + portid,RTM_GETACTION , extack);break ;default :BUG ();
Re: [PATCHv2 net-next 3/8] net: sched: act: handle generic action errors
Hi,
Quoted 5 lines · Davide Caratti
Quoted 4 lines · Alexander Aring
This patch adds extack support for generic act handling. The extack will be set deeper to each called function which is not part of netdev core api.
Quoted 8 lines
Quoted 1 line
Based on work by David Ahern <[email protected]>
hello Alexander,
after looking at the code more closely, I think there is margin for some more improvement here (i.e make the message contents easier to grep from a log). Please let me know if the comments below make sense for you.
I will send v3 with your changes. But not with one error handling in label, the most whole point is to get some messages when somebody throw a -EINVAL to the userspace and TC subsystem has a lot of places with that.
- Alex
Re: [PATCHv2 net-next 3/8] net: sched: act: handle generic action errors
Quoted 4 lines · Alexander Aring
I will send v3 with your changes. But not with one error handling in label, the most whole point is to get some messages when somebody throw a
-EINVALto the userspace and TC subsystem has a lot of places with that.
that's ok for me.
thanks!
Signature · 1 line
davide
PATCH v2 4/8 net: sched: act: add extack to init callback
In reply to Alexander AringThis patch adds extack support for act init callback api. This prepares to handle extack support inside each specific act implementation.
Based on work by David Ahern <[email protected]>
--- include/net/act_api.h | 2 +- net/sched/act_api.c | 5 +++-- net/sched/act_bpf.c | 2 +- net/sched/act_connmark.c | 3 ++- net/sched/act_csum.c | 2 +- net/sched/act_gact.c | 2 +- net/sched/act_ife.c | 2 +- net/sched/act_ipt.c | 4 ++-- net/sched/act_mirred.c | 2 +- net/sched/act_nat.c | 3 ++- net/sched/act_pedit.c | 2 +- net/sched/act_police.c | 3 ++- net/sched/act_sample.c | 2 +- net/sched/act_simple.c | 2 +- net/sched/act_skbedit.c | 2 +- net/sched/act_skbmod.c | 2 +- net/sched/act_tunnel_key.c | 2 +- net/sched/act_vlan.c | 2 +- 18 files changed, 24 insertions(+), 20 deletions(-)
include/net/act_api.h +1 -1
@@ -90,7 +90,7 @@ struct tc_action_ops {int (*lookup)(struct net *net,struct tc_action **a,u32 index);int (*init)(struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **act,int ovr, -int bind); +int bind,struct netlink_ext_ack *extack);int (*walk)(struct net *,struct sk_buff *,struct netlink_callback *,int ,const struct tc_action_ops *);
net/sched/act_api.c +3 -2
@@ -680,9 +680,10 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,/* backward compatibility for policer */ if (name ==NULL ) - err = a_o->init (net, tb[TCA_ACT_OPTIONS ], est, &a, ovr, bind); + err = a_o->init (net, tb[TCA_ACT_OPTIONS ], est, &a, ovr, bind, + extack);else - err = a_o->init (net, nla, est, &a, ovr, bind); + err = a_o->init (net, nla, est, &a, ovr, bind, extack);if (err <0 ) goto err_mod;
net/sched/act_bpf.c +1 -1
@@ -272,7 +272,7 @@ static void tcf_bpf_prog_fill_cfg(const struct tcf_bpf *prog,static int tcf_bpf_init (struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **act, -int replace,int bind) +int replace,int bind,struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, bpf_net_id);struct nlattr *tb[TCA_ACT_BPF_MAX +1 ];
net/sched/act_connmark.c +2 -1
@@ -96,7 +96,8 @@ static const struct nla_policy connmark_policy[TCA_CONNMARK_MAX + 1] = {static int tcf_connmark_init (struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **a, -int ovr,int bind) +int ovr,int bind, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, connmark_net_id);struct nlattr *tb[TCA_CONNMARK_MAX +1 ];
net/sched/act_csum.c +1 -1
@@ -46,7 +46,7 @@ static struct tc_action_ops act_csum_ops;static int tcf_csum_init (struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **a,int ovr, -int bind) +int bind,struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, csum_net_id);struct tcf_csum_params *params_old, *params_new;
net/sched/act_gact.c +1 -1
@@ -56,7 +56,7 @@ static const struct nla_policy gact_policy[TCA_GACT_MAX + 1] = {static int tcf_gact_init (struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **a, -int ovr,int bind) +int ovr,int bind,struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, gact_net_id);struct nlattr *tb[TCA_GACT_MAX +1 ];
net/sched/act_ife.c +1 -1
@@ -447,7 +447,7 @@ static int populate_metalist(struct tcf_ife_info *ife, struct nlattr **tb,static int tcf_ife_init (struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **a, -int ovr,int bind) +int ovr,int bind,struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, ife_net_id);struct nlattr *tb[TCA_IFE_MAX +1 ];
net/sched/act_ipt.c +2 -2
@@ -193,7 +193,7 @@ static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla,static int tcf_ipt_init (struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **a,int ovr, -int bind) +int bind,struct netlink_ext_ack *extack) {return __tcf_ipt_init (net, ipt_net_id, nla, est, a, &act_ipt_ops, ovr, bind);
@@ -201,7 +201,7 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla,static int tcf_xt_init (struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **a,int ovr, -int bind) +int bind,struct netlink_ext_ack *extack) {return __tcf_ipt_init (net, xt_net_id, nla, est, a, &act_xt_ops, ovr, bind);
net/sched/act_mirred.c +1 -1
@@ -69,7 +69,7 @@ static struct tc_action_ops act_mirred_ops;static int tcf_mirred_init (struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **a,int ovr, -int bind) +int bind,struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, mirred_net_id);struct nlattr *tb[TCA_MIRRED_MAX +1 ];
net/sched/act_nat.c +2 -1
@@ -37,7 +37,8 @@ static const struct nla_policy nat_policy[TCA_NAT_MAX + 1] = { };static int tcf_nat_init (struct net *net,struct nlattr *nla,struct nlattr *est, -struct tc_action **a,int ovr,int bind) +struct tc_action **a,int ovr,int bind, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, nat_net_id);struct nlattr *tb[TCA_NAT_MAX +1 ];
net/sched/act_pedit.c +1 -1
@@ -132,7 +132,7 @@ static int tcf_pedit_key_ex_dump(struct sk_buff *skb,static int tcf_pedit_init (struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **a, -int ovr,int bind) +int ovr,int bind,struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, pedit_net_id);struct nlattr *tb[TCA_PEDIT_MAX +1 ];
net/sched/act_police.c +2 -1
@@ -74,7 +74,8 @@ static const struct nla_policy police_policy[TCA_POLICE_MAX + 1] = {static int tcf_act_police_init (struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **a, -int ovr,int bind) +int ovr,int bind, +struct netlink_ext_ack *extack) {int ret =0 , err;struct nlattr *tb[TCA_POLICE_MAX +1 ];
net/sched/act_sample.c +1 -1
@@ -37,7 +37,7 @@ static const struct nla_policy sample_policy[TCA_SAMPLE_MAX + 1] = {static int tcf_sample_init (struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **a,int ovr, -int bind) +int bind,struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, sample_net_id);struct nlattr *tb[TCA_SAMPLE_MAX +1 ];
net/sched/act_simple.c +1 -1
@@ -79,7 +79,7 @@ static const struct nla_policy simple_policy[TCA_DEF_MAX + 1] = {static int tcf_simp_init (struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **a, -int ovr,int bind) +int ovr,int bind,struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, simp_net_id);struct nlattr *tb[TCA_DEF_MAX +1 ];
net/sched/act_skbedit.c +1 -1
@@ -66,7 +66,7 @@ static const struct nla_policy skbedit_policy[TCA_SKBEDIT_MAX + 1] = {static int tcf_skbedit_init (struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **a, -int ovr,int bind) +int ovr,int bind,struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, skbedit_net_id);struct nlattr *tb[TCA_SKBEDIT_MAX +1 ];
net/sched/act_skbmod.c +1 -1
@@ -84,7 +84,7 @@ static const struct nla_policy skbmod_policy[TCA_SKBMOD_MAX + 1] = {static int tcf_skbmod_init (struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **a, -int ovr,int bind) +int ovr,int bind,struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, skbmod_net_id);struct nlattr *tb[TCA_SKBMOD_MAX +1 ];
net/sched/act_tunnel_key.c +1 -1
@@ -70,7 +70,7 @@ static const struct nla_policy tunnel_key_policy[TCA_TUNNEL_KEY_MAX + 1] = {static int tunnel_key_init (struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **a, -int ovr,int bind) +int ovr,int bind,struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, tunnel_key_net_id);struct nlattr *tb[TCA_TUNNEL_KEY_MAX +1 ];
net/sched/act_vlan.c +1 -1
@@ -109,7 +109,7 @@ static const struct nla_policy vlan_policy[TCA_VLAN_MAX + 1] = {static int tcf_vlan_init (struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **a, -int ovr,int bind) +int ovr,int bind,struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, vlan_net_id);struct nlattr *tb[TCA_VLAN_MAX +1 ];
Signature · 1 line
2.11.0
PATCH v2 5/8 net: sched: act: add extack for lookup callback
In reply to Alexander AringThis patch adds extack support for act lookup callback api. This prepares to handle extack support inside each specific act implementation.
--- include/net/act_api.h | 3 ++- net/sched/act_api.c | 2 +- net/sched/act_bpf.c | 3 ++- net/sched/act_connmark.c | 3 ++- net/sched/act_csum.c | 3 ++- net/sched/act_gact.c | 3 ++- net/sched/act_ife.c | 3 ++- net/sched/act_ipt.c | 6 ++++-- net/sched/act_mirred.c | 3 ++- net/sched/act_nat.c | 3 ++- net/sched/act_pedit.c | 3 ++- net/sched/act_police.c | 3 ++- net/sched/act_sample.c | 3 ++- net/sched/act_simple.c | 3 ++- net/sched/act_skbedit.c | 3 ++- net/sched/act_skbmod.c | 3 ++- net/sched/act_tunnel_key.c | 3 ++- net/sched/act_vlan.c | 3 ++- 18 files changed, 37 insertions(+), 19 deletions(-)
include/net/act_api.h +2 -1
@@ -87,7 +87,8 @@ struct tc_action_ops { struct tcf_result *);int (*dump)(struct sk_buff *,struct tc_action *,int ,int );void (*cleanup)(struct tc_action *); -int (*lookup)(struct net *net,struct tc_action **a,u32 index); +int (*lookup)(struct net *net,struct tc_action **a,u32 index, +struct netlink_ext_ack *extack);int (*init)(struct net *net,struct nlattr *nla,struct nlattr *est,struct tc_action **act,int ovr,int bind,struct netlink_ext_ack *extack);
net/sched/act_api.c +1 -1
@@ -901,7 +901,7 @@ static struct tc_action *tcf_action_get_1(struct net *net, struct nlattr *nla, goto err_out; } err = -ENOENT ; -if (ops->lookup (net, &a, index) ==0 ) +if (ops->lookup (net, &a, index, extack) ==0 ) goto err_mod;module_put (ops->owner);
net/sched/act_bpf.c +2 -1
@@ -374,7 +374,8 @@ static int tcf_bpf_walker(struct net *net, struct sk_buff *skb,return tcf_generic_walker (tn, skb, cb, type, ops); } -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, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, bpf_net_id);
net/sched/act_connmark.c +2 -1
@@ -184,7 +184,8 @@ static int tcf_connmark_walker(struct net *net, struct sk_buff *skb,return tcf_generic_walker (tn, skb, cb, type, ops); } -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, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, connmark_net_id);
net/sched/act_csum.c +2 -1
@@ -638,7 +638,8 @@ static int tcf_csum_walker(struct net *net, struct sk_buff *skb,return tcf_generic_walker (tn, skb, cb, type, ops); } -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, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, csum_net_id);
net/sched/act_gact.c +2 -1
@@ -208,7 +208,8 @@ static int tcf_gact_walker(struct net *net, struct sk_buff *skb,return tcf_generic_walker (tn, skb, cb, type, ops); } -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, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, gact_net_id);
net/sched/act_ife.c +2 -1
@@ -831,7 +831,8 @@ static int tcf_ife_walker(struct net *net, struct sk_buff *skb,return tcf_generic_walker (tn, skb, cb, type, ops); } -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, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, ife_net_id);
net/sched/act_ipt.c +4 -2
@@ -310,7 +310,8 @@ static int tcf_ipt_walker(struct net *net, struct sk_buff *skb,return tcf_generic_walker (tn, skb, cb, type, ops); } -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, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, ipt_net_id);
@@ -358,7 +359,8 @@ static int tcf_xt_walker(struct net *net, struct sk_buff *skb,return tcf_generic_walker (tn, skb, cb, type, ops); } -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, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, xt_net_id);
net/sched/act_mirred.c +2 -1
@@ -272,7 +272,8 @@ static int tcf_mirred_walker(struct net *net, struct sk_buff *skb,return tcf_generic_walker (tn, skb, cb, type, ops); } -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, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, mirred_net_id);
net/sched/act_nat.c +2 -1
@@ -285,7 +285,8 @@ static int tcf_nat_walker(struct net *net, struct sk_buff *skb,return tcf_generic_walker (tn, skb, cb, type, ops); } -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, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, nat_net_id);
net/sched/act_pedit.c +2 -1
@@ -426,7 +426,8 @@ static int tcf_pedit_walker(struct net *net, struct sk_buff *skb,return tcf_generic_walker (tn, skb, cb, type, ops); } -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, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, pedit_net_id);
net/sched/act_police.c +2 -1
@@ -305,7 +305,8 @@ static int tcf_act_police_dump(struct sk_buff *skb, struct tc_action *a,return -1 ; } -static int tcf_police_search (struct net *net,struct tc_action **a,u32 index) +static int tcf_police_search (struct net *net,struct tc_action **a,u32 index, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, police_net_id);
net/sched/act_sample.c +2 -1
@@ -209,7 +209,8 @@ static int tcf_sample_walker(struct net *net, struct sk_buff *skb,return tcf_generic_walker (tn, skb, cb, type, ops); } -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, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, sample_net_id);
net/sched/act_simple.c +2 -1
@@ -177,7 +177,8 @@ static int tcf_simp_walker(struct net *net, struct sk_buff *skb,return tcf_generic_walker (tn, skb, cb, type, ops); } -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, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, simp_net_id);
net/sched/act_skbedit.c +2 -1
@@ -215,7 +215,8 @@ static int tcf_skbedit_walker(struct net *net, struct sk_buff *skb,return tcf_generic_walker (tn, skb, cb, type, ops); } -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, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, skbedit_net_id);
net/sched/act_skbmod.c +2 -1
@@ -239,7 +239,8 @@ static int tcf_skbmod_walker(struct net *net, struct sk_buff *skb,return tcf_generic_walker (tn, skb, cb, type, ops); } -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, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, skbmod_net_id);
net/sched/act_tunnel_key.c +2 -1
@@ -298,7 +298,8 @@ static int tunnel_key_walker(struct net *net, struct sk_buff *skb,return tcf_generic_walker (tn, skb, cb, type, ops); } -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, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, tunnel_key_net_id);
net/sched/act_vlan.c +2 -1
@@ -274,7 +274,8 @@ static int tcf_vlan_walker(struct net *net, struct sk_buff *skb,return tcf_generic_walker (tn, skb, cb, type, ops); } -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, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, vlan_net_id);
Signature · 1 line
2.11.0
PATCH v2 6/8 net: sched: act: add extack for walk callback
In reply to Alexander AringThis patch adds extack support for act walker callback api. This prepares to handle extack support inside each specific act implementation.
--- include/net/act_api.h | 3 ++- net/sched/act_api.c | 4 ++-- net/sched/act_bpf.c | 3 ++- net/sched/act_connmark.c | 3 ++- net/sched/act_csum.c | 3 ++- net/sched/act_gact.c | 3 ++- net/sched/act_ife.c | 3 ++- net/sched/act_ipt.c | 6 ++++-- net/sched/act_mirred.c | 3 ++- net/sched/act_nat.c | 3 ++- net/sched/act_pedit.c | 3 ++- net/sched/act_police.c | 3 ++- net/sched/act_sample.c | 3 ++- net/sched/act_simple.c | 3 ++- net/sched/act_skbedit.c | 3 ++- net/sched/act_skbmod.c | 3 ++- net/sched/act_tunnel_key.c | 3 ++- net/sched/act_vlan.c | 3 ++- 18 files changed, 38 insertions(+), 20 deletions(-)
include/net/act_api.h +2 -1
@@ -94,7 +94,8 @@ struct tc_action_ops { int bind, struct netlink_ext_ack *extack);int (*walk)(struct net *,struct sk_buff *,struct netlink_callback *,int , -const struct tc_action_ops *); +const struct tc_action_ops *, +struct netlink_ext_ack *);void (*stats_update)(struct tc_action *,u64 ,u32 ,u64 );struct net_device *(*get_dev)(const struct tc_action *a); };
net/sched/act_api.c +2 -2
@@ -963,7 +963,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla, goto out_module_put; } - err = ops->walk (net, skb, &dcb,RTM_DELACTION , ops); + err = ops->walk (net, skb, &dcb,RTM_DELACTION , ops, extack);if (err <=0 ) goto out_module_put;
@@ -1253,7 +1253,7 @@ static int tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)if (nest ==NULL ) goto out_module_put; - ret = a_o->walk (net, skb, cb,RTM_GETACTION , a_o); + ret = a_o->walk (net, skb, cb,RTM_GETACTION , a_o,NULL );if (ret <0 ) goto out_module_put;
net/sched/act_bpf.c +2 -1
@@ -367,7 +367,8 @@ static void tcf_bpf_cleanup(struct tc_action *act)static int tcf_bpf_walker (struct net *net,struct sk_buff *skb,struct netlink_callback *cb,int type, -const struct tc_action_ops *ops) +const struct tc_action_ops *ops, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, bpf_net_id);
net/sched/act_connmark.c +2 -1
@@ -177,7 +177,8 @@ static inline int tcf_connmark_dump(struct sk_buff *skb, struct tc_action *a,static int tcf_connmark_walker (struct net *net,struct sk_buff *skb,struct netlink_callback *cb,int type, -const struct tc_action_ops *ops) +const struct tc_action_ops *ops, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, connmark_net_id);
net/sched/act_csum.c +2 -1
@@ -631,7 +631,8 @@ static void tcf_csum_cleanup(struct tc_action *a)static int tcf_csum_walker (struct net *net,struct sk_buff *skb,struct netlink_callback *cb,int type, -const struct tc_action_ops *ops) +const struct tc_action_ops *ops, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, csum_net_id);
net/sched/act_gact.c +2 -1
@@ -201,7 +201,8 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a,static int tcf_gact_walker (struct net *net,struct sk_buff *skb,struct netlink_callback *cb,int type, -const struct tc_action_ops *ops) +const struct tc_action_ops *ops, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, gact_net_id);
net/sched/act_ife.c +2 -1
@@ -824,7 +824,8 @@ static int tcf_ife_act(struct sk_buff *skb, const struct tc_action *a,static int tcf_ife_walker (struct net *net,struct sk_buff *skb,struct netlink_callback *cb,int type, -const struct tc_action_ops *ops) +const struct tc_action_ops *ops, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, ife_net_id);
net/sched/act_ipt.c +4 -2
@@ -303,7 +303,8 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind,static int tcf_ipt_walker (struct net *net,struct sk_buff *skb,struct netlink_callback *cb,int type, -const struct tc_action_ops *ops) +const struct tc_action_ops *ops, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, ipt_net_id);
@@ -352,7 +353,8 @@ static struct pernet_operations ipt_net_ops = {static int tcf_xt_walker (struct net *net,struct sk_buff *skb,struct netlink_callback *cb,int type, -const struct tc_action_ops *ops) +const struct tc_action_ops *ops, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, xt_net_id);
net/sched/act_mirred.c +2 -1
@@ -265,7 +265,8 @@ static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind,static int tcf_mirred_walker (struct net *net,struct sk_buff *skb,struct netlink_callback *cb,int type, -const struct tc_action_ops *ops) +const struct tc_action_ops *ops, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, mirred_net_id);
net/sched/act_nat.c +2 -1
@@ -278,7 +278,8 @@ static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a,static int tcf_nat_walker (struct net *net,struct sk_buff *skb,struct netlink_callback *cb,int type, -const struct tc_action_ops *ops) +const struct tc_action_ops *ops, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, nat_net_id);
net/sched/act_pedit.c +2 -1
@@ -419,7 +419,8 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,static int tcf_pedit_walker (struct net *net,struct sk_buff *skb,struct netlink_callback *cb,int type, -const struct tc_action_ops *ops) +const struct tc_action_ops *ops, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, pedit_net_id);
net/sched/act_police.c +2 -1
@@ -58,7 +58,8 @@ static struct tc_action_ops act_police_ops;static int tcf_act_police_walker (struct net *net,struct sk_buff *skb,struct netlink_callback *cb,int type, -const struct tc_action_ops *ops) +const struct tc_action_ops *ops, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, police_net_id);
net/sched/act_sample.c +2 -1
@@ -202,7 +202,8 @@ static int tcf_sample_dump(struct sk_buff *skb, struct tc_action *a,static int tcf_sample_walker (struct net *net,struct sk_buff *skb,struct netlink_callback *cb,int type, -const struct tc_action_ops *ops) +const struct tc_action_ops *ops, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, sample_net_id);
net/sched/act_simple.c +2 -1
@@ -170,7 +170,8 @@ static int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a,static int tcf_simp_walker (struct net *net,struct sk_buff *skb,struct netlink_callback *cb,int type, -const struct tc_action_ops *ops) +const struct tc_action_ops *ops, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, simp_net_id);
net/sched/act_skbedit.c +2 -1
@@ -208,7 +208,8 @@ static int tcf_skbedit_dump(struct sk_buff *skb, struct tc_action *a,static int tcf_skbedit_walker (struct net *net,struct sk_buff *skb,struct netlink_callback *cb,int type, -const struct tc_action_ops *ops) +const struct tc_action_ops *ops, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, skbedit_net_id);
net/sched/act_skbmod.c +2 -1
@@ -232,7 +232,8 @@ static int tcf_skbmod_dump(struct sk_buff *skb, struct tc_action *a,static int tcf_skbmod_walker (struct net *net,struct sk_buff *skb,struct netlink_callback *cb,int type, -const struct tc_action_ops *ops) +const struct tc_action_ops *ops, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, skbmod_net_id);
net/sched/act_tunnel_key.c +2 -1
@@ -291,7 +291,8 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,static int tunnel_key_walker (struct net *net,struct sk_buff *skb,struct netlink_callback *cb,int type, -const struct tc_action_ops *ops) +const struct tc_action_ops *ops, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, tunnel_key_net_id);
net/sched/act_vlan.c +2 -1
@@ -267,7 +267,8 @@ static int tcf_vlan_dump(struct sk_buff *skb, struct tc_action *a,static int tcf_vlan_walker (struct net *net,struct sk_buff *skb,struct netlink_callback *cb,int type, -const struct tc_action_ops *ops) +const struct tc_action_ops *ops, +struct netlink_ext_ack *extack) {struct tc_action_net *tn =net_generic (net, vlan_net_id);
Signature · 1 line
2.11.0
PATCH v2 7/8 net: sched: act: handle extack in tcf_generic_walker
In reply to Alexander AringThis 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.
--- include/net/act_api.h | 3 ++- net/sched/act_api.c | 6 ++++-- net/sched/act_bpf.c | 2 +- net/sched/act_connmark.c | 2 +- net/sched/act_csum.c | 2 +- net/sched/act_gact.c | 2 +- net/sched/act_ife.c | 2 +- net/sched/act_ipt.c | 4 ++-- net/sched/act_mirred.c | 2 +- net/sched/act_nat.c | 2 +- net/sched/act_pedit.c | 2 +- net/sched/act_police.c | 2 +- net/sched/act_sample.c | 2 +- net/sched/act_simple.c | 2 +- net/sched/act_skbedit.c | 2 +- net/sched/act_skbmod.c | 2 +- net/sched/act_tunnel_key.c | 2 +- net/sched/act_vlan.c | 2 +- 18 files changed, 23 insertions(+), 20 deletions(-)
include/net/act_api.h +2 -1
@@ -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,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);bool tcf_idr_check (struct tc_action_net *tn,u32 index,struct tc_action **a,int bind);
net/sched/act_api.c +4 -2
@@ -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,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;
@@ -211,7 +212,8 @@ int tcf_generic_walker(struct tc_action_net *tn, struct sk_buff *skb, }else if (type ==RTM_GETACTION ) {return tcf_dump_walker (idrinfo, skb, cb); }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 ; } }
net/sched/act_bpf.c +1 -1
@@ -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); -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,
net/sched/act_connmark.c +1 -1
@@ -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); -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,
net/sched/act_csum.c +1 -1
@@ -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); -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,
net/sched/act_gact.c +1 -1
@@ -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); -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,
net/sched/act_ife.c +1 -1
@@ -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); -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,
net/sched/act_ipt.c +2 -2
@@ -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); -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,
@@ -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); -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,
net/sched/act_mirred.c +1 -1
@@ -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); -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,
net/sched/act_nat.c +1 -1
@@ -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); -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,
net/sched/act_pedit.c +1 -1
@@ -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); -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,
net/sched/act_police.c +1 -1
@@ -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); -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 ] = {
net/sched/act_sample.c +1 -1
@@ -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); -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,
net/sched/act_simple.c +1 -1
@@ -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); -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,
net/sched/act_skbedit.c +1 -1
@@ -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); -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,
net/sched/act_skbmod.c +1 -1
@@ -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); -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,
net/sched/act_tunnel_key.c +1 -1
@@ -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); -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,
net/sched/act_vlan.c +1 -1
@@ -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); -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,
Signature · 1 line
2.11.0
PATCH v2 8/8 net: sched: act: mirred: add extack support
In reply to Alexander AringThis patch adds extack support for TC mirred action.
--- net/sched/act_mirred.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-)
net/sched/act_mirred.c +11 -4
@@ -80,13 +80,17 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,bool exists = false;int ret; -if (!nla) +if (!nla) { +NL_SET_ERR_MSG_MOD (extack,"Mirred requires attributes to be passed" );return -EINVAL ; - ret =nla_parse_nested (tb,TCA_MIRRED_MAX , nla, mirred_policy,NULL ); + } + ret =nla_parse_nested (tb,TCA_MIRRED_MAX , nla, mirred_policy, extack);if (ret <0 )return ret; -if (!tb[TCA_MIRRED_PARMS ]) +if (!tb[TCA_MIRRED_PARMS ]) { +NL_SET_ERR_MSG_MOD (extack,"Missing required mirred parameters" );return -EINVAL ; + } parm =nla_data (tb[TCA_MIRRED_PARMS ]); exists =tcf_idr_check (tn, parm->index, a, bind);
@@ -102,6 +106,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,default :if (exists)tcf_idr_release (*a, bind); +NL_SET_ERR_MSG_MOD (extack,"Unknown mirred option" );return -EINVAL ; }if (parm->ifindex) {
@@ -117,8 +122,10 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, }if (!exists) { -if (!dev) +if (!dev) { +NL_SET_ERR_MSG_MOD (extack,"Specified device does not exist" );return -EINVAL ; + } ret =tcf_idr_create (tn, parm->index, est, a, &act_mirred_ops, bind, true);if (ret)
Signature · 1 line
2.11.0