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 3049cb6..9cf6870 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 a3b57a9..8cf001a 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 4f51094..da9733d 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 e0f515b..22847ee 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 b1f502f..8af9d6e 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 bde6a6c..db84a04 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 d56e738..fd51552 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 39acd1d..70a6a44 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 b9ff345..23fcfa5 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 31fcd27..dc12d50 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 f4d9177..77c17e9 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 9a22cdd..2f7f5e4 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 ceba11b..8cd8e50 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 23aba03..3c6f404 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 883454c..8c89bce 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 2957f8f..dd711ae 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 70e95ce..acf827b 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 37283b3..7553443 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,