net/sched: avoid indirect act functions on retpoline kernels
authorPedro Tammela <pctammela@mojatatu.com>
Tue, 6 Dec 2022 13:55:12 +0000 (10:55 -0300)
committerDavid S. Miller <davem@davemloft.net>
Fri, 9 Dec 2022 09:18:07 +0000 (09:18 +0000)
Expose the necessary tc act functions and wire up act_api to use
direct calls in retpoline kernels.

Signed-off-by: Pedro Tammela <pctammela@mojatatu.com>
Reviewed-by: Jamal Hadi Salim <jhs@mojatatu.com>
Reviewed-by: Victor Nogueira <victor@mojatatu.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
21 files changed:
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_gate.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 9b31a10cc63997f8a38c916d7bdf49ddf2f61c36..5b3c0ac495bee955344fdae53eea20e78ad29194 100644 (file)
@@ -23,6 +23,7 @@
 #include <net/act_api.h>
 #include <net/netlink.h>
 #include <net/flow_offload.h>
+#include <net/tc_wrapper.h>
 
 #ifdef CONFIG_INET
 DEFINE_STATIC_KEY_FALSE(tcf_frag_xmit_count);
@@ -1080,7 +1081,7 @@ restart_act_graph:
 
                repeat_ttl = 32;
 repeat:
-               ret = a->ops->act(skb, a, res);
+               ret = tc_act(skb, a, res);
                if (unlikely(ret == TC_ACT_REPEAT)) {
                        if (--repeat_ttl != 0)
                                goto repeat;
index b79eee44e24eb4bddf456ad82fdd905c4d8cfd5f..b0455fda7d0bafdb7ec0e587301e3a4b5df472d8 100644 (file)
@@ -18,6 +18,7 @@
 
 #include <linux/tc_act/tc_bpf.h>
 #include <net/tc_act/tc_bpf.h>
+#include <net/tc_wrapper.h>
 
 #define ACT_BPF_NAME_LEN       256
 
@@ -31,8 +32,9 @@ struct tcf_bpf_cfg {
 
 static struct tc_action_ops act_bpf_ops;
 
-static int tcf_bpf_act(struct sk_buff *skb, const struct tc_action *act,
-                      struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_bpf_act(struct sk_buff *skb,
+                                 const struct tc_action *act,
+                                 struct tcf_result *res)
 {
        bool at_ingress = skb_at_tc_ingress(skb);
        struct tcf_bpf *prog = to_bpf(act);
index d41002e4613ff339925d56538f47d44ff4466b11..7e63ff7e3ed7a37608c124263e2c8c9708985a71 100644 (file)
@@ -20,6 +20,7 @@
 #include <net/pkt_cls.h>
 #include <uapi/linux/tc_act/tc_connmark.h>
 #include <net/tc_act/tc_connmark.h>
+#include <net/tc_wrapper.h>
 
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_core.h>
@@ -27,8 +28,9 @@
 
 static struct tc_action_ops act_connmark_ops;
 
-static int tcf_connmark_act(struct sk_buff *skb, const struct tc_action *a,
-                           struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_connmark_act(struct sk_buff *skb,
+                                      const struct tc_action *a,
+                                      struct tcf_result *res)
 {
        const struct nf_conntrack_tuple_hash *thash;
        struct nf_conntrack_tuple tuple;
index 1366adf9b9091ae0429c6d6581e6a38cbbe06335..95e9304024b7db3902a16bccaee8a18ee937e9a9 100644 (file)
@@ -32,6 +32,7 @@
 
 #include <linux/tc_act/tc_csum.h>
 #include <net/tc_act/tc_csum.h>
+#include <net/tc_wrapper.h>
 
 static const struct nla_policy csum_policy[TCA_CSUM_MAX + 1] = {
        [TCA_CSUM_PARMS] = { .len = sizeof(struct tc_csum), },
@@ -563,8 +564,9 @@ fail:
        return 0;
 }
 
-static int tcf_csum_act(struct sk_buff *skb, const struct tc_action *a,
-                       struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_csum_act(struct sk_buff *skb,
+                                  const struct tc_action *a,
+                                  struct tcf_result *res)
 {
        struct tcf_csum *p = to_tcf_csum(a);
        bool orig_vlan_tag_present = false;
index dd5ae755195601b44652eb32016ffdf64bf45beb..f6df0168c91f0c59cac540a4e797e0a643a40133 100644 (file)
@@ -24,6 +24,7 @@
 #include <net/ipv6_frag.h>
 #include <uapi/linux/tc_act/tc_ct.h>
 #include <net/tc_act/tc_ct.h>
+#include <net/tc_wrapper.h>
 
 #include <net/netfilter/nf_flow_table.h>
 #include <net/netfilter/nf_conntrack.h>
@@ -1038,8 +1039,8 @@ static int tcf_ct_act_nat(struct sk_buff *skb,
 #endif
 }
 
-static int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a,
-                     struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_ct_act(struct sk_buff *skb, const struct tc_action *a,
+                                struct tcf_result *res)
 {
        struct net *net = dev_net(skb->dev);
        enum ip_conntrack_info ctinfo;
index eaa02f098d1c308c9d72bc53d701e83b04122adb..4b1b59da5c0b9131df8c10fbf25db7603ac78d1e 100644 (file)
@@ -18,6 +18,7 @@
 #include <net/pkt_cls.h>
 #include <uapi/linux/tc_act/tc_ctinfo.h>
 #include <net/tc_act/tc_ctinfo.h>
+#include <net/tc_wrapper.h>
 
 #include <net/netfilter/nf_conntrack.h>
 #include <net/netfilter/nf_conntrack_core.h>
@@ -75,8 +76,9 @@ static void tcf_ctinfo_cpmark_set(struct nf_conn *ct, struct tcf_ctinfo *ca,
        skb->mark = READ_ONCE(ct->mark) & cp->cpmarkmask;
 }
 
-static int tcf_ctinfo_act(struct sk_buff *skb, const struct tc_action *a,
-                         struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_ctinfo_act(struct sk_buff *skb,
+                                    const struct tc_action *a,
+                                    struct tcf_result *res)
 {
        const struct nf_conntrack_tuple_hash *thash = NULL;
        struct tcf_ctinfo *ca = to_ctinfo(a);
index 62d682b96b88527314387c9180df2ffc9371d160..54f1b13b2360ba1ff9306b8086de18c1973a88df 100644 (file)
@@ -18,6 +18,7 @@
 #include <net/pkt_cls.h>
 #include <linux/tc_act/tc_gact.h>
 #include <net/tc_act/tc_gact.h>
+#include <net/tc_wrapper.h>
 
 static struct tc_action_ops act_gact_ops;
 
@@ -145,8 +146,9 @@ release_idr:
        return err;
 }
 
-static int tcf_gact_act(struct sk_buff *skb, const struct tc_action *a,
-                       struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_gact_act(struct sk_buff *skb,
+                                  const struct tc_action *a,
+                                  struct tcf_result *res)
 {
        struct tcf_gact *gact = to_gact(a);
        int action = READ_ONCE(gact->tcf_action);
index 3049878e731538408142c26041fc423453ba6126..9b8def0be41e998c1f61942068e56f80410d77af 100644 (file)
@@ -14,6 +14,7 @@
 #include <net/netlink.h>
 #include <net/pkt_cls.h>
 #include <net/tc_act/tc_gate.h>
+#include <net/tc_wrapper.h>
 
 static struct tc_action_ops act_gate_ops;
 
@@ -113,8 +114,9 @@ static enum hrtimer_restart gate_timer_func(struct hrtimer *timer)
        return HRTIMER_RESTART;
 }
 
-static int tcf_gate_act(struct sk_buff *skb, const struct tc_action *a,
-                       struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_gate_act(struct sk_buff *skb,
+                                  const struct tc_action *a,
+                                  struct tcf_result *res)
 {
        struct tcf_gate *gact = to_gate(a);
 
index 41d63b33461dc9242009832d5cf37143fafb4a63..bc7611b0744c41c7ec26b3b1ae4ee8743bcdfbd5 100644 (file)
@@ -29,6 +29,7 @@
 #include <net/tc_act/tc_ife.h>
 #include <linux/etherdevice.h>
 #include <net/ife.h>
+#include <net/tc_wrapper.h>
 
 static int max_metacnt = IFE_META_MAX + 1;
 static struct tc_action_ops act_ife_ops;
@@ -861,8 +862,9 @@ static int tcf_ife_encode(struct sk_buff *skb, const struct tc_action *a,
        return action;
 }
 
-static int tcf_ife_act(struct sk_buff *skb, const struct tc_action *a,
-                      struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_ife_act(struct sk_buff *skb,
+                                 const struct tc_action *a,
+                                 struct tcf_result *res)
 {
        struct tcf_ife_info *ife = to_ife(a);
        struct tcf_ife_params *p;
index 1625e103741614d6d2b871a862108ceab3f5a22a..5d96ffebd40f0aaf6db7fc521924ea3700d81d19 100644 (file)
@@ -20,6 +20,7 @@
 #include <net/pkt_sched.h>
 #include <linux/tc_act/tc_ipt.h>
 #include <net/tc_act/tc_ipt.h>
+#include <net/tc_wrapper.h>
 
 #include <linux/netfilter_ipv4/ip_tables.h>
 
@@ -216,8 +217,9 @@ static int tcf_xt_init(struct net *net, struct nlattr *nla,
                              a, &act_xt_ops, tp, flags);
 }
 
-static int tcf_ipt_act(struct sk_buff *skb, const struct tc_action *a,
-                      struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_ipt_act(struct sk_buff *skb,
+                                 const struct tc_action *a,
+                                 struct tcf_result *res)
 {
        int ret = 0, result = 0;
        struct tcf_ipt *ipt = to_ipt(a);
index b8ad6ae282c02f2c194ffa3d1e3064963d695367..7284bcea7b0b1c462a061818c133f00174f41f3c 100644 (file)
@@ -24,6 +24,7 @@
 #include <net/pkt_cls.h>
 #include <linux/tc_act/tc_mirred.h>
 #include <net/tc_act/tc_mirred.h>
+#include <net/tc_wrapper.h>
 
 static LIST_HEAD(mirred_list);
 static DEFINE_SPINLOCK(mirred_list_lock);
@@ -217,8 +218,9 @@ static int tcf_mirred_forward(bool want_ingress, struct sk_buff *skb)
        return err;
 }
 
-static int tcf_mirred_act(struct sk_buff *skb, const struct tc_action *a,
-                         struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_mirred_act(struct sk_buff *skb,
+                                    const struct tc_action *a,
+                                    struct tcf_result *res)
 {
        struct tcf_mirred *m = to_mirred(a);
        struct sk_buff *skb2 = skb;
index 8ad25cc8ccd55dcbe80dfe47fb18f04e197d94d6..ff47ce4d3968540d8830801632edc7a61c8ec871 100644 (file)
@@ -14,6 +14,7 @@
 #include <net/pkt_sched.h>
 #include <net/pkt_cls.h>
 #include <net/tc_act/tc_mpls.h>
+#include <net/tc_wrapper.h>
 
 static struct tc_action_ops act_mpls_ops;
 
@@ -49,8 +50,9 @@ static __be32 tcf_mpls_get_lse(struct mpls_shim_hdr *lse,
        return cpu_to_be32(new_lse);
 }
 
-static int tcf_mpls_act(struct sk_buff *skb, const struct tc_action *a,
-                       struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_mpls_act(struct sk_buff *skb,
+                                  const struct tc_action *a,
+                                  struct tcf_result *res)
 {
        struct tcf_mpls *m = to_mpls(a);
        struct tcf_mpls_params *p;
index 9265145f104046e419db00d66f741232e4a0f2b5..74c74be33048442ac2ee566e5f790950b4253979 100644 (file)
@@ -24,7 +24,7 @@
 #include <net/tc_act/tc_nat.h>
 #include <net/tcp.h>
 #include <net/udp.h>
-
+#include <net/tc_wrapper.h>
 
 static struct tc_action_ops act_nat_ops;
 
@@ -98,8 +98,9 @@ release_idr:
        return err;
 }
 
-static int tcf_nat_act(struct sk_buff *skb, const struct tc_action *a,
-                      struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_nat_act(struct sk_buff *skb,
+                                 const struct tc_action *a,
+                                 struct tcf_result *res)
 {
        struct tcf_nat *p = to_tcf_nat(a);
        struct iphdr *iph;
index 94ed5857ce678419c48028c6c7704a0ec6eb5d9c..a0378e9f01213e73a9e84a2db2dc7f94662ef4a3 100644 (file)
@@ -20,6 +20,7 @@
 #include <net/tc_act/tc_pedit.h>
 #include <uapi/linux/tc_act/tc_pedit.h>
 #include <net/pkt_cls.h>
+#include <net/tc_wrapper.h>
 
 static struct tc_action_ops act_pedit_ops;
 
@@ -319,8 +320,9 @@ static int pedit_skb_hdr_offset(struct sk_buff *skb,
        return ret;
 }
 
-static int tcf_pedit_act(struct sk_buff *skb, const struct tc_action *a,
-                        struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_pedit_act(struct sk_buff *skb,
+                                   const struct tc_action *a,
+                                   struct tcf_result *res)
 {
        struct tcf_pedit *p = to_pedit(a);
        u32 max_offset;
index 0adb26e366a7be8058e6a169511f53d71bd26e78..227cba58ce9f30539ead12d1ca5258cbc69dc340 100644 (file)
@@ -19,6 +19,7 @@
 #include <net/netlink.h>
 #include <net/pkt_cls.h>
 #include <net/tc_act/tc_police.h>
+#include <net/tc_wrapper.h>
 
 /* Each policer is serialized by its individual spinlock */
 
@@ -242,8 +243,9 @@ static bool tcf_police_mtu_check(struct sk_buff *skb, u32 limit)
        return len <= limit;
 }
 
-static int tcf_police_act(struct sk_buff *skb, const struct tc_action *a,
-                         struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_police_act(struct sk_buff *skb,
+                                    const struct tc_action *a,
+                                    struct tcf_result *res)
 {
        struct tcf_police *police = to_police(a);
        s64 now, toks, ppstoks = 0, ptoks = 0;
index 7a25477f5d996aa633c15f5f82a65ef45aae7203..98dea08c1764064e9153c0178af511275d006d7a 100644 (file)
@@ -20,6 +20,7 @@
 #include <net/tc_act/tc_sample.h>
 #include <net/psample.h>
 #include <net/pkt_cls.h>
+#include <net/tc_wrapper.h>
 
 #include <linux/if_arp.h>
 
@@ -153,8 +154,9 @@ static bool tcf_sample_dev_ok_push(struct net_device *dev)
        }
 }
 
-static int tcf_sample_act(struct sk_buff *skb, const struct tc_action *a,
-                         struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_sample_act(struct sk_buff *skb,
+                                    const struct tc_action *a,
+                                    struct tcf_result *res)
 {
        struct tcf_sample *s = to_sample(a);
        struct psample_group *psample_group;
index 18d3761354611a6eda6d1fac376e04e67910bdc3..4b84514534f39ae19f51363be9ab6a1de61bbaff 100644 (file)
@@ -14,6 +14,7 @@
 #include <net/netlink.h>
 #include <net/pkt_sched.h>
 #include <net/pkt_cls.h>
+#include <net/tc_wrapper.h>
 
 #include <linux/tc_act/tc_defact.h>
 #include <net/tc_act/tc_defact.h>
@@ -21,8 +22,9 @@
 static struct tc_action_ops act_simp_ops;
 
 #define SIMP_MAX_DATA  32
-static int tcf_simp_act(struct sk_buff *skb, const struct tc_action *a,
-                       struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_simp_act(struct sk_buff *skb,
+                                  const struct tc_action *a,
+                                  struct tcf_result *res)
 {
        struct tcf_defact *d = to_defact(a);
 
index 1710780c908a34035e643beab71a7c7a75e3c7d5..ce7008cf291c3f531fc1aa27cc07f58aa62e563c 100644 (file)
@@ -16,6 +16,7 @@
 #include <net/ipv6.h>
 #include <net/dsfield.h>
 #include <net/pkt_cls.h>
+#include <net/tc_wrapper.h>
 
 #include <linux/tc_act/tc_skbedit.h>
 #include <net/tc_act/tc_skbedit.h>
@@ -36,8 +37,9 @@ static u16 tcf_skbedit_hash(struct tcf_skbedit_params *params,
        return netdev_cap_txqueue(skb->dev, queue_mapping);
 }
 
-static int tcf_skbedit_act(struct sk_buff *skb, const struct tc_action *a,
-                          struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_skbedit_act(struct sk_buff *skb,
+                                     const struct tc_action *a,
+                                     struct tcf_result *res)
 {
        struct tcf_skbedit *d = to_skbedit(a);
        struct tcf_skbedit_params *params;
index d98758a639340517aa6a40e20e76156cffd26178..dffa990a9629f0ca3d04c4667534908968f7a8d2 100644 (file)
 #include <net/netlink.h>
 #include <net/pkt_sched.h>
 #include <net/pkt_cls.h>
+#include <net/tc_wrapper.h>
 
 #include <linux/tc_act/tc_skbmod.h>
 #include <net/tc_act/tc_skbmod.h>
 
 static struct tc_action_ops act_skbmod_ops;
 
-static int tcf_skbmod_act(struct sk_buff *skb, const struct tc_action *a,
-                         struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_skbmod_act(struct sk_buff *skb,
+                                    const struct tc_action *a,
+                                    struct tcf_result *res)
 {
        struct tcf_skbmod *d = to_skbmod(a);
        int action, max_edit_len, err;
index 2691a3d8e4511de5058553e7b4465c8cc83d0c8a..2d12d2626415333fe223e50128dab637b9a678ce 100644 (file)
 #include <net/pkt_sched.h>
 #include <net/dst.h>
 #include <net/pkt_cls.h>
+#include <net/tc_wrapper.h>
 
 #include <linux/tc_act/tc_tunnel_key.h>
 #include <net/tc_act/tc_tunnel_key.h>
 
 static struct tc_action_ops act_tunnel_key_ops;
 
-static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a,
-                         struct tcf_result *res)
+TC_INDIRECT_SCOPE int tunnel_key_act(struct sk_buff *skb,
+                                    const struct tc_action *a,
+                                    struct tcf_result *res)
 {
        struct tcf_tunnel_key *t = to_tunnel_key(a);
        struct tcf_tunnel_key_params *params;
index 7b24e898a3e6b6b803659c36ee20721681bfbf16..0251442f5f29d0796e82daab833bd1922c16c030 100644 (file)
 #include <net/netlink.h>
 #include <net/pkt_sched.h>
 #include <net/pkt_cls.h>
+#include <net/tc_wrapper.h>
 
 #include <linux/tc_act/tc_vlan.h>
 #include <net/tc_act/tc_vlan.h>
 
 static struct tc_action_ops act_vlan_ops;
 
-static int tcf_vlan_act(struct sk_buff *skb, const struct tc_action *a,
-                       struct tcf_result *res)
+TC_INDIRECT_SCOPE int tcf_vlan_act(struct sk_buff *skb,
+                                  const struct tc_action *a,
+                                  struct tcf_result *res)
 {
        struct tcf_vlan *v = to_vlan(a);
        struct tcf_vlan_params *p;