net/sched: act_api: Add extack to offload_act_setup() callback
authorIdo Schimmel <idosch@nvidia.com>
Thu, 7 Apr 2022 07:35:22 +0000 (10:35 +0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 8 Apr 2022 12:45:43 +0000 (13:45 +0100)
The callback is used by various actions to populate the flow action
structure prior to offload. Pass extack to this callback so that the
various actions will be able to report accurate error messages to user
space.

Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Reviewed-by: Petr Machata <petrm@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
18 files changed:
include/net/act_api.h
include/net/pkt_cls.h
net/sched/act_api.c
net/sched/act_csum.c
net/sched/act_ct.c
net/sched/act_gact.c
net/sched/act_gate.c
net/sched/act_mirred.c
net/sched/act_mpls.c
net/sched/act_pedit.c
net/sched/act_police.c
net/sched/act_sample.c
net/sched/act_skbedit.c
net/sched/act_tunnel_key.c
net/sched/act_vlan.c
net/sched/cls_api.c
net/sched/cls_flower.c
net/sched/cls_matchall.c

index 3049cb69c0252bea18159fc490990050449e1949..9cf6870b526eb2a54bd8c8d11706588667e68a20 100644 (file)
@@ -134,7 +134,8 @@ struct tc_action_ops {
        (*get_psample_group)(const struct tc_action *a,
                             tc_action_priv_destructor *destructor);
        int     (*offload_act_setup)(struct tc_action *act, void *entry_data,
-                                    u32 *index_inc, bool bind);
+                                    u32 *index_inc, bool bind,
+                                    struct netlink_ext_ack *extack);
 };
 
 struct tc_action_net {
index a3b57a93228a7f9d1f85596c6252489e1dd2066d..8cf001aed858dc47cc296201ffa15494c46e5f52 100644 (file)
@@ -547,10 +547,12 @@ tcf_match_indev(struct sk_buff *skb, int ifindex)
 }
 
 int tc_setup_offload_action(struct flow_action *flow_action,
-                           const struct tcf_exts *exts);
+                           const struct tcf_exts *exts,
+                           struct netlink_ext_ack *extack);
 void tc_cleanup_offload_action(struct flow_action *flow_action);
 int tc_setup_action(struct flow_action *flow_action,
-                   struct tc_action *actions[]);
+                   struct tc_action *actions[],
+                   struct netlink_ext_ack *extack);
 
 int tc_setup_cb_call(struct tcf_block *block, enum tc_setup_type type,
                     void *type_data, bool err_stop, bool rtnl_held);
index 4f51094da9dab75d882b43bc8aa013266e55ccfd..da9733da9868ff38e073cb4dec41cc66dc848fef 100644 (file)
@@ -195,7 +195,7 @@ static int offload_action_init(struct flow_offload_action *fl_action,
        if (act->ops->offload_act_setup) {
                spin_lock_bh(&act->tcfa_lock);
                err = act->ops->offload_act_setup(act, fl_action, NULL,
-                                                 false);
+                                                 false, extack);
                spin_unlock_bh(&act->tcfa_lock);
                return err;
        }
@@ -271,7 +271,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);
+       err = tc_setup_action(&fl_action->action, actions, extack);
        if (err) {
                NL_SET_ERR_MSG_MOD(extack,
                                   "Failed to setup tc actions for offload");
index e0f515b774cad280f13c776a89e0fd0d818b912c..22847ee009efaf36967a29b1f19ae6ab232614bc 100644 (file)
@@ -696,7 +696,8 @@ static size_t tcf_csum_get_fill_size(const struct tc_action *act)
 }
 
 static int tcf_csum_offload_act_setup(struct tc_action *act, void *entry_data,
-                                     u32 *index_inc, bool bind)
+                                     u32 *index_inc, bool bind,
+                                     struct netlink_ext_ack *extack)
 {
        if (bind) {
                struct flow_action_entry *entry = entry_data;
index b1f502fce595667ab66eab85bc66bf88eba3bc5e..8af9d6e5ba61d552ca6c02588ec08a99733a4c76 100644 (file)
@@ -1584,7 +1584,8 @@ static void tcf_stats_update(struct tc_action *a, u64 bytes, u64 packets,
 }
 
 static int tcf_ct_offload_act_setup(struct tc_action *act, void *entry_data,
-                                   u32 *index_inc, bool bind)
+                                   u32 *index_inc, bool bind,
+                                   struct netlink_ext_ack *extack)
 {
        if (bind) {
                struct flow_action_entry *entry = entry_data;
index bde6a6c01e64cb92567bfcde1e3eb7241ee57594..db84a0473cc1317fcd07f997038d74c2dfb9f893 100644 (file)
@@ -253,7 +253,8 @@ static size_t tcf_gact_get_fill_size(const struct tc_action *act)
 }
 
 static int tcf_gact_offload_act_setup(struct tc_action *act, void *entry_data,
-                                     u32 *index_inc, bool bind)
+                                     u32 *index_inc, bool bind,
+                                     struct netlink_ext_ack *extack)
 {
        if (bind) {
                struct flow_action_entry *entry = entry_data;
index d56e73843a4b7fe0bd9dfc0aa84960a59c2d1de2..fd515527473324085781385a087d5e0f6bbd22c1 100644 (file)
@@ -619,7 +619,8 @@ static int tcf_gate_get_entries(struct flow_action_entry *entry,
 }
 
 static int tcf_gate_offload_act_setup(struct tc_action *act, void *entry_data,
-                                     u32 *index_inc, bool bind)
+                                     u32 *index_inc, bool bind,
+                                     struct netlink_ext_ack *extack)
 {
        int err;
 
index 39acd1d186098bbb958822f3c087276ee0ea84e4..70a6a4447e6bd67ed6e04d9deb0b587bd41aef34 100644 (file)
@@ -460,7 +460,8 @@ static void tcf_offload_mirred_get_dev(struct flow_action_entry *entry,
 }
 
 static int tcf_mirred_offload_act_setup(struct tc_action *act, void *entry_data,
-                                       u32 *index_inc, bool bind)
+                                       u32 *index_inc, bool bind,
+                                       struct netlink_ext_ack *extack)
 {
        if (bind) {
                struct flow_action_entry *entry = entry_data;
index b9ff3459fdab97381f059d8c476e5c214c5d58a4..23fcfa5605dfa48a00685911bf9a6d4f602b9e7f 100644 (file)
@@ -385,7 +385,8 @@ static int tcf_mpls_search(struct net *net, struct tc_action **a, u32 index)
 }
 
 static int tcf_mpls_offload_act_setup(struct tc_action *act, void *entry_data,
-                                     u32 *index_inc, bool bind)
+                                     u32 *index_inc, bool bind,
+                                     struct netlink_ext_ack *extack)
 {
        if (bind) {
                struct flow_action_entry *entry = entry_data;
index 31fcd279c17767a57f6190f623f3cef25f33cf99..dc12d502c4fec2a6c3f5545e331243783d301628 100644 (file)
@@ -488,7 +488,8 @@ static int tcf_pedit_search(struct net *net, struct tc_action **a, u32 index)
 }
 
 static int tcf_pedit_offload_act_setup(struct tc_action *act, void *entry_data,
-                                      u32 *index_inc, bool bind)
+                                      u32 *index_inc, bool bind,
+                                      struct netlink_ext_ack *extack)
 {
        if (bind) {
                struct flow_action_entry *entry = entry_data;
index f4d91770526390f2fa2b46157573b4f5fb2a0f66..77c17e9b46d112322ae03493aa7c120ac305f720 100644 (file)
@@ -442,7 +442,8 @@ static int tcf_police_act_to_flow_act(int tc_act, u32 *extval)
 }
 
 static int tcf_police_offload_act_setup(struct tc_action *act, void *entry_data,
-                                       u32 *index_inc, bool bind)
+                                       u32 *index_inc, bool bind,
+                                       struct netlink_ext_ack *extack)
 {
        if (bind) {
                struct flow_action_entry *entry = entry_data;
index 9a22cdda6bbdcd38abc0d0c4d5365fad2f4088dd..2f7f5e44d28c9875f397aa0eaec946222c3042a0 100644 (file)
@@ -291,7 +291,8 @@ static void tcf_offload_sample_get_group(struct flow_action_entry *entry,
 }
 
 static int tcf_sample_offload_act_setup(struct tc_action *act, void *entry_data,
-                                       u32 *index_inc, bool bind)
+                                       u32 *index_inc, bool bind,
+                                       struct netlink_ext_ack *extack)
 {
        if (bind) {
                struct flow_action_entry *entry = entry_data;
index ceba11b198bbab11f9d648d155f618a664c16923..8cd8e506c9c9b8f83b4e43e905ed8a20bd17059c 100644 (file)
@@ -328,7 +328,8 @@ static size_t tcf_skbedit_get_fill_size(const struct tc_action *act)
 }
 
 static int tcf_skbedit_offload_act_setup(struct tc_action *act, void *entry_data,
-                                        u32 *index_inc, bool bind)
+                                        u32 *index_inc, bool bind,
+                                        struct netlink_ext_ack *extack)
 {
        if (bind) {
                struct flow_action_entry *entry = entry_data;
index 23aba03d26a8d1a0e3e393bc78df3e71a18c27d1..3c6f40478c81358d7537623f2183ffca71d4c152 100644 (file)
@@ -808,7 +808,8 @@ static int tcf_tunnel_encap_get_tunnel(struct flow_action_entry *entry,
 static int tcf_tunnel_key_offload_act_setup(struct tc_action *act,
                                            void *entry_data,
                                            u32 *index_inc,
-                                           bool bind)
+                                           bool bind,
+                                           struct netlink_ext_ack *extack)
 {
        int err;
 
index 883454c4f9219498eeecd36942dbece1d491876e..8c89bce99cbd17d8d2d26ea580d873de854a5280 100644 (file)
@@ -369,7 +369,8 @@ static size_t tcf_vlan_get_fill_size(const struct tc_action *act)
 }
 
 static int tcf_vlan_offload_act_setup(struct tc_action *act, void *entry_data,
-                                     u32 *index_inc, bool bind)
+                                     u32 *index_inc, bool bind,
+                                     struct netlink_ext_ack *extack)
 {
        if (bind) {
                struct flow_action_entry *entry = entry_data;
index 2957f8f5cea759315463d5e61fa1db745746e6f7..dd711ae048ff456d4e15da6c3d3a17f8e6d123b9 100644 (file)
@@ -3513,11 +3513,13 @@ EXPORT_SYMBOL(tc_cleanup_offload_action);
 
 static int tc_setup_offload_act(struct tc_action *act,
                                struct flow_action_entry *entry,
-                               u32 *index_inc)
+                               u32 *index_inc,
+                               struct netlink_ext_ack *extack)
 {
 #ifdef CONFIG_NET_CLS_ACT
        if (act->ops->offload_act_setup)
-               return act->ops->offload_act_setup(act, entry, index_inc, true);
+               return act->ops->offload_act_setup(act, entry, index_inc, true,
+                                                  extack);
        else
                return -EOPNOTSUPP;
 #else
@@ -3526,7 +3528,8 @@ static int tc_setup_offload_act(struct tc_action *act,
 }
 
 int tc_setup_action(struct flow_action *flow_action,
-                   struct tc_action *actions[])
+                   struct tc_action *actions[],
+                   struct netlink_ext_ack *extack)
 {
        int i, j, index, err = 0;
        struct tc_action *act;
@@ -3551,7 +3554,7 @@ int tc_setup_action(struct flow_action *flow_action,
                entry->hw_stats = tc_act_hw_stats(act->hw_stats);
                entry->hw_index = act->tcfa_index;
                index = 0;
-               err = tc_setup_offload_act(act, entry, &index);
+               err = tc_setup_offload_act(act, entry, &index, extack);
                if (!err)
                        j += index;
                else
@@ -3570,13 +3573,14 @@ err_out_locked:
 }
 
 int tc_setup_offload_action(struct flow_action *flow_action,
-                           const struct tcf_exts *exts)
+                           const struct tcf_exts *exts,
+                           struct netlink_ext_ack *extack)
 {
 #ifdef CONFIG_NET_CLS_ACT
        if (!exts)
                return 0;
 
-       return tc_setup_action(flow_action, exts->actions);
+       return tc_setup_action(flow_action, exts->actions, extack);
 #else
        return 0;
 #endif
index 70e95ce28ffdd14aec8aeab73c289740dd2ca1e5..acf827b0e30a6e6511dcaba8242defc723d7897c 100644 (file)
@@ -464,7 +464,8 @@ static int fl_hw_replace_filter(struct tcf_proto *tp,
        cls_flower.rule->match.key = &f->mkey;
        cls_flower.classid = f->res.classid;
 
-       err = tc_setup_offload_action(&cls_flower.rule->action, &f->exts);
+       err = tc_setup_offload_action(&cls_flower.rule->action, &f->exts,
+                                     cls_flower.common.extack);
        if (err) {
                kfree(cls_flower.rule);
                NL_SET_ERR_MSG_MOD(cls_flower.common.extack,
@@ -2353,7 +2354,8 @@ static int fl_reoffload(struct tcf_proto *tp, bool add, flow_setup_cb_t *cb,
                cls_flower.rule->match.mask = &f->mask->key;
                cls_flower.rule->match.key = &f->mkey;
 
-               err = tc_setup_offload_action(&cls_flower.rule->action, &f->exts);
+               err = tc_setup_offload_action(&cls_flower.rule->action, &f->exts,
+                                             cls_flower.common.extack);
                if (err) {
                        kfree(cls_flower.rule);
                        NL_SET_ERR_MSG_MOD(cls_flower.common.extack,
index 37283b30692451ebfaf4516cf7cb6669159f4df5..7553443e1ae7e040e08f708d82b00b47a13d0e80 100644 (file)
@@ -97,7 +97,8 @@ static int mall_replace_hw_filter(struct tcf_proto *tp,
        cls_mall.command = TC_CLSMATCHALL_REPLACE;
        cls_mall.cookie = cookie;
 
-       err = tc_setup_offload_action(&cls_mall.rule->action, &head->exts);
+       err = tc_setup_offload_action(&cls_mall.rule->action, &head->exts,
+                                     cls_mall.common.extack);
        if (err) {
                kfree(cls_mall.rule);
                mall_destroy_hw_filter(tp, head, cookie, NULL);
@@ -300,7 +301,8 @@ static int mall_reoffload(struct tcf_proto *tp, bool add, flow_setup_cb_t *cb,
                TC_CLSMATCHALL_REPLACE : TC_CLSMATCHALL_DESTROY;
        cls_mall.cookie = (unsigned long)head;
 
-       err = tc_setup_offload_action(&cls_mall.rule->action, &head->exts);
+       err = tc_setup_offload_action(&cls_mall.rule->action, &head->exts,
+                                     cls_mall.common.extack);
        if (err) {
                kfree(cls_mall.rule);
                NL_SET_ERR_MSG_MOD(cls_mall.common.extack,