]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: sched: extend TCA_ACT space with TCA_ACT_FLAGS
authorVlad Buslov <vladbu@mellanox.com>
Wed, 30 Oct 2019 14:09:05 +0000 (16:09 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 31 Oct 2019 01:07:50 +0000 (18:07 -0700)
Extend TCA_ACT space with nla_bitfield32 flags. Add
TCA_ACT_FLAGS_NO_PERCPU_STATS as the only allowed flag. Parse the flags in
tcf_action_init_1() and pass resulting value as additional argument to
a_o->init().

Signed-off-by: Vlad Buslov <vladbu@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
22 files changed:
include/net/act_api.h
include/uapi/linux/pkt_cls.h
net/sched/act_api.c
net/sched/act_bpf.c
net/sched/act_connmark.c
net/sched/act_csum.c
net/sched/act_ct.c
net/sched/act_ctinfo.c
net/sched/act_gact.c
net/sched/act_ife.c
net/sched/act_ipt.c
net/sched/act_mirred.c
net/sched/act_mpls.c
net/sched/act_nat.c
net/sched/act_pedit.c
net/sched/act_police.c
net/sched/act_sample.c
net/sched/act_simple.c
net/sched/act_skbedit.c
net/sched/act_skbmod.c
net/sched/act_tunnel_key.c
net/sched/act_vlan.c

index a56477051dae55d4c37752365dd83d428a148cbb..85e95c44c7f9e008ce969d6020918ff2683c8209 100644 (file)
@@ -94,7 +94,7 @@ struct tc_action_ops {
        int     (*init)(struct net *net, struct nlattr *nla,
                        struct nlattr *est, struct tc_action **act, int ovr,
                        int bind, bool rtnl_held, struct tcf_proto *tp,
-                       struct netlink_ext_ack *extack);
+                       u32 flags, struct netlink_ext_ack *extack);
        int     (*walk)(struct net *, struct sk_buff *,
                        struct netlink_callback *, int,
                        const struct tc_action_ops *,
index a6aa466fac9e85b2acde80d21ff1e00db89169f6..c6ad22f76edeec3464b99ea91eb226e9d3f5393e 100644 (file)
@@ -16,9 +16,14 @@ enum {
        TCA_ACT_STATS,
        TCA_ACT_PAD,
        TCA_ACT_COOKIE,
+       TCA_ACT_FLAGS,
        __TCA_ACT_MAX
 };
 
+#define TCA_ACT_FLAGS_NO_PERCPU_STATS 1 /* Don't use percpu allocator for
+                                        * actions stats.
+                                        */
+
 #define TCA_ACT_MAX __TCA_ACT_MAX
 #define TCA_OLD_COMPAT (TCA_ACT_MAX+1)
 #define TCA_ACT_MAX_PRIO 32
index f85b88da5216e59138779b6085eb073e5b29d58b..92c00207d5a122f6184e833f4053856f1f24484c 100644 (file)
@@ -831,12 +831,15 @@ static struct tc_cookie *nla_memdup_cookie(struct nlattr **tb)
        return c;
 }
 
+static const u32 tca_act_flags_allowed = TCA_ACT_FLAGS_NO_PERCPU_STATS;
 static const struct nla_policy tcf_action_policy[TCA_ACT_MAX + 1] = {
        [TCA_ACT_KIND]          = { .type = NLA_STRING },
        [TCA_ACT_INDEX]         = { .type = NLA_U32 },
        [TCA_ACT_COOKIE]        = { .type = NLA_BINARY,
                                    .len = TC_COOKIE_MAX_SIZE },
        [TCA_ACT_OPTIONS]       = { .type = NLA_NESTED },
+       [TCA_ACT_FLAGS]         = { .type = NLA_BITFIELD32,
+                                   .validation_data = &tca_act_flags_allowed },
 };
 
 struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
@@ -845,6 +848,7 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
                                    bool rtnl_held,
                                    struct netlink_ext_ack *extack)
 {
+       struct nla_bitfield32 flags = { 0, 0 };
        struct tc_action *a;
        struct tc_action_ops *a_o;
        struct tc_cookie *cookie = NULL;
@@ -876,6 +880,8 @@ struct tc_action *tcf_action_init_1(struct net *net, struct tcf_proto *tp,
                                goto err_out;
                        }
                }
+               if (tb[TCA_ACT_FLAGS])
+                       flags = nla_get_bitfield32(tb[TCA_ACT_FLAGS]);
        } else {
                if (strlcpy(act_name, name, IFNAMSIZ) >= IFNAMSIZ) {
                        NL_SET_ERR_MSG(extack, "TC action name too long");
@@ -914,10 +920,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,
-                               rtnl_held, tp, extack);
+                               rtnl_held, tp, flags.value, extack);
        else
                err = a_o->init(net, nla, est, &a, ovr, bind, rtnl_held,
-                               tp, extack);
+                               tp, flags.value, extack);
        if (err < 0)
                goto err_mod;
 
index 04b7bd4ec7513c2388275ee5ed1af18b8585a32b..9e8cb43bc3fe581087fe5871c190cdd0b4fc5ef8 100644 (file)
@@ -275,7 +275,8 @@ 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, bool rtnl_held,
-                       struct tcf_proto *tp, struct netlink_ext_ack *extack)
+                       struct tcf_proto *tp, u32 flags,
+                       struct netlink_ext_ack *extack)
 {
        struct tc_action_net *tn = net_generic(net, bpf_net_id);
        struct nlattr *tb[TCA_ACT_BPF_MAX + 1];
index 2b43cacf82af4aeaefdc41bf97651d832b1e31f1..2e0ec6f80458499a4b1d7260f5477f71c84da28f 100644 (file)
@@ -94,7 +94,7 @@ 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, bool rtnl_held,
-                            struct tcf_proto *tp,
+                            struct tcf_proto *tp, u32 flags,
                             struct netlink_ext_ack *extack)
 {
        struct tc_action_net *tn = net_generic(net, connmark_net_id);
index bc909cf72257278e81cf535b7583166b410899ef..66e54fada44c1f2c320e59e286d2aa6f2bb960c0 100644 (file)
@@ -43,7 +43,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, bool rtnl_held, struct tcf_proto *tp,
-                        struct netlink_ext_ack *extack)
+                        u32 flags, struct netlink_ext_ack *extack)
 {
        struct tc_action_net *tn = net_generic(net, csum_net_id);
        struct tcf_csum_params *params_new;
index eabae2227e13f0b0d3baa04a0088209200730d06..92ec0bdb0547ae00feae9950372f58c1026478c3 100644 (file)
@@ -656,7 +656,7 @@ static int tcf_ct_fill_params(struct net *net,
 static int tcf_ct_init(struct net *net, struct nlattr *nla,
                       struct nlattr *est, struct tc_action **a,
                       int replace, int bind, bool rtnl_held,
-                      struct tcf_proto *tp,
+                      struct tcf_proto *tp, u32 flags,
                       struct netlink_ext_ack *extack)
 {
        struct tc_action_net *tn = net_generic(net, ct_net_id);
index 0dbcfd1dca7bf354a51892adeed5a5fc3b4889fd..2205b2a934cc954f8de9507c0b2da1353abb6a48 100644 (file)
@@ -153,7 +153,7 @@ static const struct nla_policy ctinfo_policy[TCA_CTINFO_MAX + 1] = {
 static int tcf_ctinfo_init(struct net *net, struct nlattr *nla,
                           struct nlattr *est, struct tc_action **a,
                           int ovr, int bind, bool rtnl_held,
-                          struct tcf_proto *tp,
+                          struct tcf_proto *tp, u32 flags,
                           struct netlink_ext_ack *extack)
 {
        struct tc_action_net *tn = net_generic(net, ctinfo_net_id);
index 221f0c2e26b111009ee38cd29933f9b1e9d004a2..c3dc89160f3ab1308e1c5dcef51dcb1bbb9758fe 100644 (file)
@@ -53,7 +53,8 @@ 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, bool rtnl_held,
-                        struct tcf_proto *tp, struct netlink_ext_ack *extack)
+                        struct tcf_proto *tp, u32 flags,
+                        struct netlink_ext_ack *extack)
 {
        struct tc_action_net *tn = net_generic(net, gact_net_id);
        struct nlattr *tb[TCA_GACT_MAX + 1];
index 3a31e241c6472b42d37414f68ba18c16bd1a9f19..f38d2a5fd608884d21c816988da392aa853c6934 100644 (file)
@@ -465,7 +465,8 @@ 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, bool rtnl_held,
-                       struct tcf_proto *tp, struct netlink_ext_ack *extack)
+                       struct tcf_proto *tp, u32 flags,
+                       struct netlink_ext_ack *extack)
 {
        struct tc_action_net *tn = net_generic(net, ife_net_id);
        struct nlattr *tb[TCA_IFE_MAX + 1];
index 214a03d405cf9bb546903a12262a03a7d1843d0c..fbab7078747790f54452004685bbcb507ad931f3 100644 (file)
@@ -95,7 +95,7 @@ static const struct nla_policy ipt_policy[TCA_IPT_MAX + 1] = {
 static int __tcf_ipt_init(struct net *net, unsigned int id, struct nlattr *nla,
                          struct nlattr *est, struct tc_action **a,
                          const struct tc_action_ops *ops, int ovr, int bind,
-                         struct tcf_proto *tp)
+                         struct tcf_proto *tp, u32 flags)
 {
        struct tc_action_net *tn = net_generic(net, id);
        struct nlattr *tb[TCA_IPT_MAX + 1];
@@ -205,19 +205,19 @@ err1:
 static int tcf_ipt_init(struct net *net, struct nlattr *nla,
                        struct nlattr *est, struct tc_action **a, int ovr,
                        int bind, bool rtnl_held, struct tcf_proto *tp,
-                       struct netlink_ext_ack *extack)
+                       u32 flags, struct netlink_ext_ack *extack)
 {
        return __tcf_ipt_init(net, ipt_net_id, nla, est, a, &act_ipt_ops, ovr,
-                             bind, tp);
+                             bind, tp, flags);
 }
 
 static int tcf_xt_init(struct net *net, struct nlattr *nla,
                       struct nlattr *est, struct tc_action **a, int ovr,
                       int bind, bool unlocked, struct tcf_proto *tp,
-                      struct netlink_ext_ack *extack)
+                      u32 flags, struct netlink_ext_ack *extack)
 {
        return __tcf_ipt_init(net, xt_net_id, nla, est, a, &act_xt_ops, ovr,
-                             bind, tp);
+                             bind, tp, flags);
 }
 
 static int tcf_ipt_act(struct sk_buff *skb, const struct tc_action *a,
index ae1129aaf3c0ec7439e602ddc7175f02df436594..17ed19d6dff4f0588354fa8037629a97d76a54fe 100644 (file)
@@ -93,7 +93,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
                           struct nlattr *est, struct tc_action **a,
                           int ovr, int bind, bool rtnl_held,
                           struct tcf_proto *tp,
-                          struct netlink_ext_ack *extack)
+                          u32 flags, struct netlink_ext_ack *extack)
 {
        struct tc_action_net *tn = net_generic(net, mirred_net_id);
        struct nlattr *tb[TCA_MIRRED_MAX + 1];
index 4cf6c553bb0bbf06376d4068c25775c1948cf065..efd7fe07141b5ceafc88f0536ecb5b9f124e6e44 100644 (file)
@@ -131,7 +131,8 @@ static const struct nla_policy mpls_policy[TCA_MPLS_MAX + 1] = {
 static int tcf_mpls_init(struct net *net, struct nlattr *nla,
                         struct nlattr *est, struct tc_action **a,
                         int ovr, int bind, bool rtnl_held,
-                        struct tcf_proto *tp, struct netlink_ext_ack *extack)
+                        struct tcf_proto *tp, u32 flags,
+                        struct netlink_ext_ack *extack)
 {
        struct tc_action_net *tn = net_generic(net, mpls_net_id);
        struct nlattr *tb[TCA_MPLS_MAX + 1];
index ea4c5359e7dfb5668dfc23ac4dfb95672f61304e..51d631cef92c5213116dc142aed925c55e3b3853 100644 (file)
@@ -36,7 +36,7 @@ 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,
                        bool rtnl_held, struct tcf_proto *tp,
-                       struct netlink_ext_ack *extack)
+                       u32 flags, struct netlink_ext_ack *extack)
 {
        struct tc_action_net *tn = net_generic(net, nat_net_id);
        struct nlattr *tb[TCA_NAT_MAX + 1];
index cdfaa79382a22c63761cdb7507296946aac3cb12..adf1cbd6ae46e7cdf635d3a5409a2ea356b37f64 100644 (file)
@@ -137,7 +137,8 @@ nla_failure:
 static int tcf_pedit_init(struct net *net, struct nlattr *nla,
                          struct nlattr *est, struct tc_action **a,
                          int ovr, int bind, bool rtnl_held,
-                         struct tcf_proto *tp, struct netlink_ext_ack *extack)
+                         struct tcf_proto *tp, u32 flags,
+                         struct netlink_ext_ack *extack)
 {
        struct tc_action_net *tn = net_generic(net, pedit_net_id);
        struct nlattr *tb[TCA_PEDIT_MAX + 1];
index 51d34b1a61d52715e1da5fe76642ffae25a32a57..7437b001f493027eaeeeb193a39543c18f16a62c 100644 (file)
@@ -47,7 +47,7 @@ static const struct nla_policy police_policy[TCA_POLICE_MAX + 1] = {
 static int tcf_police_init(struct net *net, struct nlattr *nla,
                               struct nlattr *est, struct tc_action **a,
                               int ovr, int bind, bool rtnl_held,
-                              struct tcf_proto *tp,
+                              struct tcf_proto *tp, u32 flags,
                               struct netlink_ext_ack *extack)
 {
        int ret = 0, tcfp_result = TC_ACT_OK, err, size;
index 514456a0b9a83204142e3422dc5d8e7469343eb4..6f9a745c309595798468cbd5eea730389fad6cdd 100644 (file)
@@ -36,7 +36,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, bool rtnl_held, struct tcf_proto *tp,
-                          struct netlink_ext_ack *extack)
+                          u32 flags, struct netlink_ext_ack *extack)
 {
        struct tc_action_net *tn = net_generic(net, sample_net_id);
        struct nlattr *tb[TCA_SAMPLE_MAX + 1];
index 6120e56117ca14d2abeb855e20beb33ae7cd9896..b18890f3eb6774edf03b0f8009653c9d7be8c155 100644 (file)
@@ -86,7 +86,8 @@ 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, bool rtnl_held,
-                        struct tcf_proto *tp, struct netlink_ext_ack *extack)
+                        struct tcf_proto *tp, u32 flags,
+                        struct netlink_ext_ack *extack)
 {
        struct tc_action_net *tn = net_generic(net, simp_net_id);
        struct nlattr *tb[TCA_DEF_MAX + 1];
index 6a8d3337c577493dc9dcc2b70e7946abbc165cfa..25f3b7b56beaf1ca81ddb1ca29a0a278bc8ae13e 100644 (file)
@@ -86,7 +86,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, bool rtnl_held,
-                           struct tcf_proto *tp,
+                           struct tcf_proto *tp, u32 act_flags,
                            struct netlink_ext_ack *extack)
 {
        struct tc_action_net *tn = net_generic(net, skbedit_net_id);
index 888437f97ba62087992a6b19de615e859fd63563..8e1dc0d6b4b0cc384f804f461ae29bed5e974ce0 100644 (file)
@@ -79,7 +79,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, bool rtnl_held,
-                          struct tcf_proto *tp,
+                          struct tcf_proto *tp, u32 flags,
                           struct netlink_ext_ack *extack)
 {
        struct tc_action_net *tn = net_generic(net, skbmod_net_id);
index 9ab2d3b4a9fcd9edda57742986bb9bae449a363b..b25e5124f571b2207dfce77d6f598454678e3694 100644 (file)
@@ -208,7 +208,7 @@ static void tunnel_key_release_params(struct tcf_tunnel_key_params *p)
 static int tunnel_key_init(struct net *net, struct nlattr *nla,
                           struct nlattr *est, struct tc_action **a,
                           int ovr, int bind, bool rtnl_held,
-                          struct tcf_proto *tp,
+                          struct tcf_proto *tp, u32 act_flags,
                           struct netlink_ext_ack *extack)
 {
        struct tc_action_net *tn = net_generic(net, tunnel_key_net_id);
index ffa0f431aa8485178eb1a09599fac8e5b4ffe1bc..4b4000338a0974e9536b63131be13923b49d3880 100644 (file)
@@ -102,7 +102,8 @@ 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, bool rtnl_held,
-                        struct tcf_proto *tp, struct netlink_ext_ack *extack)
+                        struct tcf_proto *tp, u32 flags,
+                        struct netlink_ext_ack *extack)
 {
        struct tc_action_net *tn = net_generic(net, vlan_net_id);
        struct nlattr *tb[TCA_VLAN_MAX + 1];