Commit 34df6a8a authored by David S. Miller's avatar David S. Miller

Merge branch 'tc_action_ops-refactor'

Zhengchao Shao says:

====================
net: refactor the walk and lookup hook functions in tc_action_ops

The implementation logic of the walk/lookup hook function in each action
module is the same. Therefore, the two functions can be reconstructed.
When registering tc_action_ops of each action module, the corresponding
net_id is saved to tc_action_ops. In this way, the net_id of the
corresponding module can be directly obtained in act_api without executing
the specific walk and lookup hook functions. Then, generic functions can
be added to replace the walk and lookup hook functions of each action
module. Last, modify each action module in alphabetical order.

Reserve the walk and lookup interfaces and delete them when they are no
longer used.

This patchset has been tested by using TDC, and I will add selftest in
other patchset.

Last, thanks to Jamal Hadi Salim and Cong Wang for their advice.
---
v3: remove hole from the structure tc_action_ops
v2: save the net_id of each TC action module to the tc_action_ops structure
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents dd14043a 6d13a65d
...@@ -111,6 +111,7 @@ struct tc_action_ops { ...@@ -111,6 +111,7 @@ struct tc_action_ops {
struct list_head head; struct list_head head;
char kind[IFNAMSIZ]; char kind[IFNAMSIZ];
enum tca_id id; /* identifier should match kind */ enum tca_id id; /* identifier should match kind */
unsigned int net_id;
size_t size; size_t size;
struct module *owner; struct module *owner;
int (*act)(struct sk_buff *, const struct tc_action *, int (*act)(struct sk_buff *, const struct tc_action *,
......
...@@ -676,6 +676,31 @@ int tcf_idr_search(struct tc_action_net *tn, struct tc_action **a, u32 index) ...@@ -676,6 +676,31 @@ int tcf_idr_search(struct tc_action_net *tn, struct tc_action **a, u32 index)
} }
EXPORT_SYMBOL(tcf_idr_search); EXPORT_SYMBOL(tcf_idr_search);
static int __tcf_generic_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, ops->net_id);
if (unlikely(ops->walk))
return ops->walk(net, skb, cb, type, ops, extack);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int __tcf_idr_search(struct net *net,
const struct tc_action_ops *ops,
struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, ops->net_id);
if (unlikely(ops->lookup))
return ops->lookup(net, a, index);
return tcf_idr_search(tn, a, index);
}
static int tcf_idr_delete_index(struct tcf_idrinfo *idrinfo, u32 index) static int tcf_idr_delete_index(struct tcf_idrinfo *idrinfo, u32 index)
{ {
struct tc_action *p; struct tc_action *p;
...@@ -926,7 +951,7 @@ int tcf_register_action(struct tc_action_ops *act, ...@@ -926,7 +951,7 @@ int tcf_register_action(struct tc_action_ops *act,
struct tc_action_ops *a; struct tc_action_ops *a;
int ret; int ret;
if (!act->act || !act->dump || !act->init || !act->walk || !act->lookup) if (!act->act || !act->dump || !act->init)
return -EINVAL; return -EINVAL;
/* We have to register pernet ops before making the action ops visible, /* We have to register pernet ops before making the action ops visible,
...@@ -1638,7 +1663,7 @@ static struct tc_action *tcf_action_get_1(struct net *net, struct nlattr *nla, ...@@ -1638,7 +1663,7 @@ static struct tc_action *tcf_action_get_1(struct net *net, struct nlattr *nla,
goto err_out; goto err_out;
} }
err = -ENOENT; err = -ENOENT;
if (ops->lookup(net, &a, index) == 0) { if (__tcf_idr_search(net, ops, &a, index) == 0) {
NL_SET_ERR_MSG(extack, "TC action with specified index not found"); NL_SET_ERR_MSG(extack, "TC action with specified index not found");
goto err_mod; goto err_mod;
} }
...@@ -1703,7 +1728,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla, ...@@ -1703,7 +1728,7 @@ static int tca_action_flush(struct net *net, struct nlattr *nla,
goto out_module_put; goto out_module_put;
} }
err = ops->walk(net, skb, &dcb, RTM_DELACTION, ops, extack); err = __tcf_generic_walker(net, skb, &dcb, RTM_DELACTION, ops, extack);
if (err <= 0) { if (err <= 0) {
nla_nest_cancel(skb, nest); nla_nest_cancel(skb, nest);
goto out_module_put; goto out_module_put;
...@@ -2121,7 +2146,7 @@ static int tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb) ...@@ -2121,7 +2146,7 @@ static int tc_dump_action(struct sk_buff *skb, struct netlink_callback *cb)
if (nest == NULL) if (nest == NULL)
goto out_module_put; goto out_module_put;
ret = a_o->walk(net, skb, cb, RTM_GETACTION, a_o, NULL); ret = __tcf_generic_walker(net, skb, cb, RTM_GETACTION, a_o, NULL);
if (ret < 0) if (ret < 0)
goto out_module_put; goto out_module_put;
......
...@@ -29,7 +29,6 @@ struct tcf_bpf_cfg { ...@@ -29,7 +29,6 @@ struct tcf_bpf_cfg {
bool is_ebpf; bool is_ebpf;
}; };
static unsigned int bpf_net_id;
static struct tc_action_ops act_bpf_ops; static struct tc_action_ops act_bpf_ops;
static int tcf_bpf_act(struct sk_buff *skb, const struct tc_action *act, static int tcf_bpf_act(struct sk_buff *skb, const struct tc_action *act,
...@@ -280,7 +279,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla, ...@@ -280,7 +279,7 @@ static int tcf_bpf_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, u32 flags, struct tcf_proto *tp, u32 flags,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, bpf_net_id); struct tc_action_net *tn = net_generic(net, act_bpf_ops.net_id);
bool bind = flags & TCA_ACT_FLAGS_BIND; bool bind = flags & TCA_ACT_FLAGS_BIND;
struct nlattr *tb[TCA_ACT_BPF_MAX + 1]; struct nlattr *tb[TCA_ACT_BPF_MAX + 1];
struct tcf_chain *goto_ch = NULL; struct tcf_chain *goto_ch = NULL;
...@@ -390,23 +389,6 @@ static void tcf_bpf_cleanup(struct tc_action *act) ...@@ -390,23 +389,6 @@ static void tcf_bpf_cleanup(struct tc_action *act)
tcf_bpf_cfg_cleanup(&tmp); tcf_bpf_cfg_cleanup(&tmp);
} }
static int tcf_bpf_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, bpf_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tcf_bpf_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, bpf_net_id);
return tcf_idr_search(tn, a, index);
}
static struct tc_action_ops act_bpf_ops __read_mostly = { static struct tc_action_ops act_bpf_ops __read_mostly = {
.kind = "bpf", .kind = "bpf",
.id = TCA_ID_BPF, .id = TCA_ID_BPF,
...@@ -415,27 +397,25 @@ static struct tc_action_ops act_bpf_ops __read_mostly = { ...@@ -415,27 +397,25 @@ static struct tc_action_ops act_bpf_ops __read_mostly = {
.dump = tcf_bpf_dump, .dump = tcf_bpf_dump,
.cleanup = tcf_bpf_cleanup, .cleanup = tcf_bpf_cleanup,
.init = tcf_bpf_init, .init = tcf_bpf_init,
.walk = tcf_bpf_walker,
.lookup = tcf_bpf_search,
.size = sizeof(struct tcf_bpf), .size = sizeof(struct tcf_bpf),
}; };
static __net_init int bpf_init_net(struct net *net) static __net_init int bpf_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, bpf_net_id); struct tc_action_net *tn = net_generic(net, act_bpf_ops.net_id);
return tc_action_net_init(net, tn, &act_bpf_ops); return tc_action_net_init(net, tn, &act_bpf_ops);
} }
static void __net_exit bpf_exit_net(struct list_head *net_list) static void __net_exit bpf_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, bpf_net_id); tc_action_net_exit(net_list, act_bpf_ops.net_id);
} }
static struct pernet_operations bpf_net_ops = { static struct pernet_operations bpf_net_ops = {
.init = bpf_init_net, .init = bpf_init_net,
.exit_batch = bpf_exit_net, .exit_batch = bpf_exit_net,
.id = &bpf_net_id, .id = &act_bpf_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include <net/netfilter/nf_conntrack_core.h> #include <net/netfilter/nf_conntrack_core.h>
#include <net/netfilter/nf_conntrack_zones.h> #include <net/netfilter/nf_conntrack_zones.h>
static unsigned int connmark_net_id;
static struct tc_action_ops act_connmark_ops; static struct tc_action_ops act_connmark_ops;
static int tcf_connmark_act(struct sk_buff *skb, const struct tc_action *a, static int tcf_connmark_act(struct sk_buff *skb, const struct tc_action *a,
...@@ -99,7 +98,7 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla, ...@@ -99,7 +98,7 @@ static int tcf_connmark_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, u32 flags, struct tcf_proto *tp, u32 flags,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, connmark_net_id); struct tc_action_net *tn = net_generic(net, act_connmark_ops.net_id);
struct nlattr *tb[TCA_CONNMARK_MAX + 1]; struct nlattr *tb[TCA_CONNMARK_MAX + 1];
bool bind = flags & TCA_ACT_FLAGS_BIND; bool bind = flags & TCA_ACT_FLAGS_BIND;
struct tcf_chain *goto_ch = NULL; struct tcf_chain *goto_ch = NULL;
...@@ -200,23 +199,6 @@ static inline int tcf_connmark_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -200,23 +199,6 @@ static inline int tcf_connmark_dump(struct sk_buff *skb, struct tc_action *a,
return -1; return -1;
} }
static int tcf_connmark_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, connmark_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tcf_connmark_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, connmark_net_id);
return tcf_idr_search(tn, a, index);
}
static struct tc_action_ops act_connmark_ops = { static struct tc_action_ops act_connmark_ops = {
.kind = "connmark", .kind = "connmark",
.id = TCA_ID_CONNMARK, .id = TCA_ID_CONNMARK,
...@@ -224,27 +206,25 @@ static struct tc_action_ops act_connmark_ops = { ...@@ -224,27 +206,25 @@ static struct tc_action_ops act_connmark_ops = {
.act = tcf_connmark_act, .act = tcf_connmark_act,
.dump = tcf_connmark_dump, .dump = tcf_connmark_dump,
.init = tcf_connmark_init, .init = tcf_connmark_init,
.walk = tcf_connmark_walker,
.lookup = tcf_connmark_search,
.size = sizeof(struct tcf_connmark_info), .size = sizeof(struct tcf_connmark_info),
}; };
static __net_init int connmark_init_net(struct net *net) static __net_init int connmark_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, connmark_net_id); struct tc_action_net *tn = net_generic(net, act_connmark_ops.net_id);
return tc_action_net_init(net, tn, &act_connmark_ops); return tc_action_net_init(net, tn, &act_connmark_ops);
} }
static void __net_exit connmark_exit_net(struct list_head *net_list) static void __net_exit connmark_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, connmark_net_id); tc_action_net_exit(net_list, act_connmark_ops.net_id);
} }
static struct pernet_operations connmark_net_ops = { static struct pernet_operations connmark_net_ops = {
.init = connmark_init_net, .init = connmark_init_net,
.exit_batch = connmark_exit_net, .exit_batch = connmark_exit_net,
.id = &connmark_net_id, .id = &act_connmark_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -37,7 +37,6 @@ static const struct nla_policy csum_policy[TCA_CSUM_MAX + 1] = { ...@@ -37,7 +37,6 @@ static const struct nla_policy csum_policy[TCA_CSUM_MAX + 1] = {
[TCA_CSUM_PARMS] = { .len = sizeof(struct tc_csum), }, [TCA_CSUM_PARMS] = { .len = sizeof(struct tc_csum), },
}; };
static unsigned int csum_net_id;
static struct tc_action_ops act_csum_ops; static struct tc_action_ops act_csum_ops;
static int tcf_csum_init(struct net *net, struct nlattr *nla, static int tcf_csum_init(struct net *net, struct nlattr *nla,
...@@ -45,7 +44,7 @@ static int tcf_csum_init(struct net *net, struct nlattr *nla, ...@@ -45,7 +44,7 @@ static int tcf_csum_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, struct tcf_proto *tp,
u32 flags, struct netlink_ext_ack *extack) u32 flags, struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, csum_net_id); struct tc_action_net *tn = net_generic(net, act_csum_ops.net_id);
bool bind = flags & TCA_ACT_FLAGS_BIND; bool bind = flags & TCA_ACT_FLAGS_BIND;
struct tcf_csum_params *params_new; struct tcf_csum_params *params_new;
struct nlattr *tb[TCA_CSUM_MAX + 1]; struct nlattr *tb[TCA_CSUM_MAX + 1];
...@@ -673,23 +672,6 @@ static void tcf_csum_cleanup(struct tc_action *a) ...@@ -673,23 +672,6 @@ static void tcf_csum_cleanup(struct tc_action *a)
kfree_rcu(params, rcu); kfree_rcu(params, rcu);
} }
static int tcf_csum_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, csum_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tcf_csum_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, csum_net_id);
return tcf_idr_search(tn, a, index);
}
static size_t tcf_csum_get_fill_size(const struct tc_action *act) static size_t tcf_csum_get_fill_size(const struct tc_action *act)
{ {
return nla_total_size(sizeof(struct tc_csum)); return nla_total_size(sizeof(struct tc_csum));
...@@ -722,8 +704,6 @@ static struct tc_action_ops act_csum_ops = { ...@@ -722,8 +704,6 @@ static struct tc_action_ops act_csum_ops = {
.dump = tcf_csum_dump, .dump = tcf_csum_dump,
.init = tcf_csum_init, .init = tcf_csum_init,
.cleanup = tcf_csum_cleanup, .cleanup = tcf_csum_cleanup,
.walk = tcf_csum_walker,
.lookup = tcf_csum_search,
.get_fill_size = tcf_csum_get_fill_size, .get_fill_size = tcf_csum_get_fill_size,
.offload_act_setup = tcf_csum_offload_act_setup, .offload_act_setup = tcf_csum_offload_act_setup,
.size = sizeof(struct tcf_csum), .size = sizeof(struct tcf_csum),
...@@ -731,20 +711,20 @@ static struct tc_action_ops act_csum_ops = { ...@@ -731,20 +711,20 @@ static struct tc_action_ops act_csum_ops = {
static __net_init int csum_init_net(struct net *net) static __net_init int csum_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, csum_net_id); struct tc_action_net *tn = net_generic(net, act_csum_ops.net_id);
return tc_action_net_init(net, tn, &act_csum_ops); return tc_action_net_init(net, tn, &act_csum_ops);
} }
static void __net_exit csum_exit_net(struct list_head *net_list) static void __net_exit csum_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, csum_net_id); tc_action_net_exit(net_list, act_csum_ops.net_id);
} }
static struct pernet_operations csum_net_ops = { static struct pernet_operations csum_net_ops = {
.init = csum_init_net, .init = csum_init_net,
.exit_batch = csum_exit_net, .exit_batch = csum_exit_net,
.id = &csum_net_id, .id = &act_csum_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -649,7 +649,6 @@ static void tcf_ct_flow_tables_uninit(void) ...@@ -649,7 +649,6 @@ static void tcf_ct_flow_tables_uninit(void)
} }
static struct tc_action_ops act_ct_ops; static struct tc_action_ops act_ct_ops;
static unsigned int ct_net_id;
struct tc_ct_action_net { struct tc_ct_action_net {
struct tc_action_net tn; /* Must be first */ struct tc_action_net tn; /* Must be first */
...@@ -1255,7 +1254,7 @@ static int tcf_ct_fill_params(struct net *net, ...@@ -1255,7 +1254,7 @@ static int tcf_ct_fill_params(struct net *net,
struct nlattr **tb, struct nlattr **tb,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct tc_ct_action_net *tn = net_generic(net, ct_net_id); struct tc_ct_action_net *tn = net_generic(net, act_ct_ops.net_id);
struct nf_conntrack_zone zone; struct nf_conntrack_zone zone;
struct nf_conn *tmpl; struct nf_conn *tmpl;
int err; int err;
...@@ -1330,7 +1329,7 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla, ...@@ -1330,7 +1329,7 @@ static int tcf_ct_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, u32 flags, struct tcf_proto *tp, u32 flags,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, ct_net_id); struct tc_action_net *tn = net_generic(net, act_ct_ops.net_id);
bool bind = flags & TCA_ACT_FLAGS_BIND; bool bind = flags & TCA_ACT_FLAGS_BIND;
struct tcf_ct_params *params = NULL; struct tcf_ct_params *params = NULL;
struct nlattr *tb[TCA_CT_MAX + 1]; struct nlattr *tb[TCA_CT_MAX + 1];
...@@ -1558,23 +1557,6 @@ static inline int tcf_ct_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -1558,23 +1557,6 @@ static inline int tcf_ct_dump(struct sk_buff *skb, struct tc_action *a,
return -1; return -1;
} }
static int tcf_ct_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, ct_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tcf_ct_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, ct_net_id);
return tcf_idr_search(tn, a, index);
}
static void tcf_stats_update(struct tc_action *a, u64 bytes, u64 packets, static void tcf_stats_update(struct tc_action *a, u64 bytes, u64 packets,
u64 drops, u64 lastuse, bool hw) u64 drops, u64 lastuse, bool hw)
{ {
...@@ -1613,8 +1595,6 @@ static struct tc_action_ops act_ct_ops = { ...@@ -1613,8 +1595,6 @@ static struct tc_action_ops act_ct_ops = {
.dump = tcf_ct_dump, .dump = tcf_ct_dump,
.init = tcf_ct_init, .init = tcf_ct_init,
.cleanup = tcf_ct_cleanup, .cleanup = tcf_ct_cleanup,
.walk = tcf_ct_walker,
.lookup = tcf_ct_search,
.stats_update = tcf_stats_update, .stats_update = tcf_stats_update,
.offload_act_setup = tcf_ct_offload_act_setup, .offload_act_setup = tcf_ct_offload_act_setup,
.size = sizeof(struct tcf_ct), .size = sizeof(struct tcf_ct),
...@@ -1623,7 +1603,7 @@ static struct tc_action_ops act_ct_ops = { ...@@ -1623,7 +1603,7 @@ static struct tc_action_ops act_ct_ops = {
static __net_init int ct_init_net(struct net *net) static __net_init int ct_init_net(struct net *net)
{ {
unsigned int n_bits = sizeof_field(struct tcf_ct_params, labels) * 8; unsigned int n_bits = sizeof_field(struct tcf_ct_params, labels) * 8;
struct tc_ct_action_net *tn = net_generic(net, ct_net_id); struct tc_ct_action_net *tn = net_generic(net, act_ct_ops.net_id);
if (nf_connlabels_get(net, n_bits - 1)) { if (nf_connlabels_get(net, n_bits - 1)) {
tn->labels = false; tn->labels = false;
...@@ -1641,20 +1621,20 @@ static void __net_exit ct_exit_net(struct list_head *net_list) ...@@ -1641,20 +1621,20 @@ static void __net_exit ct_exit_net(struct list_head *net_list)
rtnl_lock(); rtnl_lock();
list_for_each_entry(net, net_list, exit_list) { list_for_each_entry(net, net_list, exit_list) {
struct tc_ct_action_net *tn = net_generic(net, ct_net_id); struct tc_ct_action_net *tn = net_generic(net, act_ct_ops.net_id);
if (tn->labels) if (tn->labels)
nf_connlabels_put(net); nf_connlabels_put(net);
} }
rtnl_unlock(); rtnl_unlock();
tc_action_net_exit(net_list, ct_net_id); tc_action_net_exit(net_list, act_ct_ops.net_id);
} }
static struct pernet_operations ct_net_ops = { static struct pernet_operations ct_net_ops = {
.init = ct_init_net, .init = ct_init_net,
.exit_batch = ct_exit_net, .exit_batch = ct_exit_net,
.id = &ct_net_id, .id = &act_ct_ops.net_id,
.size = sizeof(struct tc_ct_action_net), .size = sizeof(struct tc_ct_action_net),
}; };
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include <net/netfilter/nf_conntrack_zones.h> #include <net/netfilter/nf_conntrack_zones.h>
static struct tc_action_ops act_ctinfo_ops; static struct tc_action_ops act_ctinfo_ops;
static unsigned int ctinfo_net_id;
static void tcf_ctinfo_dscp_set(struct nf_conn *ct, struct tcf_ctinfo *ca, static void tcf_ctinfo_dscp_set(struct nf_conn *ct, struct tcf_ctinfo *ca,
struct tcf_ctinfo_params *cp, struct tcf_ctinfo_params *cp,
...@@ -157,7 +156,7 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla, ...@@ -157,7 +156,7 @@ static int tcf_ctinfo_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, u32 flags, struct tcf_proto *tp, u32 flags,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, ctinfo_net_id); struct tc_action_net *tn = net_generic(net, act_ctinfo_ops.net_id);
bool bind = flags & TCA_ACT_FLAGS_BIND; bool bind = flags & TCA_ACT_FLAGS_BIND;
u32 dscpmask = 0, dscpstatemask, index; u32 dscpmask = 0, dscpstatemask, index;
struct nlattr *tb[TCA_CTINFO_MAX + 1]; struct nlattr *tb[TCA_CTINFO_MAX + 1];
...@@ -342,23 +341,6 @@ static int tcf_ctinfo_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -342,23 +341,6 @@ static int tcf_ctinfo_dump(struct sk_buff *skb, struct tc_action *a,
return -1; return -1;
} }
static int tcf_ctinfo_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, ctinfo_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tcf_ctinfo_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, ctinfo_net_id);
return tcf_idr_search(tn, a, index);
}
static void tcf_ctinfo_cleanup(struct tc_action *a) static void tcf_ctinfo_cleanup(struct tc_action *a)
{ {
struct tcf_ctinfo *ci = to_ctinfo(a); struct tcf_ctinfo *ci = to_ctinfo(a);
...@@ -377,27 +359,25 @@ static struct tc_action_ops act_ctinfo_ops = { ...@@ -377,27 +359,25 @@ static struct tc_action_ops act_ctinfo_ops = {
.dump = tcf_ctinfo_dump, .dump = tcf_ctinfo_dump,
.init = tcf_ctinfo_init, .init = tcf_ctinfo_init,
.cleanup= tcf_ctinfo_cleanup, .cleanup= tcf_ctinfo_cleanup,
.walk = tcf_ctinfo_walker,
.lookup = tcf_ctinfo_search,
.size = sizeof(struct tcf_ctinfo), .size = sizeof(struct tcf_ctinfo),
}; };
static __net_init int ctinfo_init_net(struct net *net) static __net_init int ctinfo_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, ctinfo_net_id); struct tc_action_net *tn = net_generic(net, act_ctinfo_ops.net_id);
return tc_action_net_init(net, tn, &act_ctinfo_ops); return tc_action_net_init(net, tn, &act_ctinfo_ops);
} }
static void __net_exit ctinfo_exit_net(struct list_head *net_list) static void __net_exit ctinfo_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, ctinfo_net_id); tc_action_net_exit(net_list, act_ctinfo_ops.net_id);
} }
static struct pernet_operations ctinfo_net_ops = { static struct pernet_operations ctinfo_net_ops = {
.init = ctinfo_init_net, .init = ctinfo_init_net,
.exit_batch = ctinfo_exit_net, .exit_batch = ctinfo_exit_net,
.id = &ctinfo_net_id, .id = &act_ctinfo_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <linux/tc_act/tc_gact.h> #include <linux/tc_act/tc_gact.h>
#include <net/tc_act/tc_gact.h> #include <net/tc_act/tc_gact.h>
static unsigned int gact_net_id;
static struct tc_action_ops act_gact_ops; static struct tc_action_ops act_gact_ops;
#ifdef CONFIG_GACT_PROB #ifdef CONFIG_GACT_PROB
...@@ -55,7 +54,7 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla, ...@@ -55,7 +54,7 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, u32 flags, struct tcf_proto *tp, u32 flags,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, gact_net_id); struct tc_action_net *tn = net_generic(net, act_gact_ops.net_id);
bool bind = flags & TCA_ACT_FLAGS_BIND; bool bind = flags & TCA_ACT_FLAGS_BIND;
struct nlattr *tb[TCA_GACT_MAX + 1]; struct nlattr *tb[TCA_GACT_MAX + 1];
struct tcf_chain *goto_ch = NULL; struct tcf_chain *goto_ch = NULL;
...@@ -222,23 +221,6 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -222,23 +221,6 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a,
return -1; return -1;
} }
static int tcf_gact_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, gact_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tcf_gact_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, gact_net_id);
return tcf_idr_search(tn, a, index);
}
static size_t tcf_gact_get_fill_size(const struct tc_action *act) static size_t tcf_gact_get_fill_size(const struct tc_action *act)
{ {
size_t sz = nla_total_size(sizeof(struct tc_gact)); /* TCA_GACT_PARMS */ size_t sz = nla_total_size(sizeof(struct tc_gact)); /* TCA_GACT_PARMS */
...@@ -308,8 +290,6 @@ static struct tc_action_ops act_gact_ops = { ...@@ -308,8 +290,6 @@ static struct tc_action_ops act_gact_ops = {
.stats_update = tcf_gact_stats_update, .stats_update = tcf_gact_stats_update,
.dump = tcf_gact_dump, .dump = tcf_gact_dump,
.init = tcf_gact_init, .init = tcf_gact_init,
.walk = tcf_gact_walker,
.lookup = tcf_gact_search,
.get_fill_size = tcf_gact_get_fill_size, .get_fill_size = tcf_gact_get_fill_size,
.offload_act_setup = tcf_gact_offload_act_setup, .offload_act_setup = tcf_gact_offload_act_setup,
.size = sizeof(struct tcf_gact), .size = sizeof(struct tcf_gact),
...@@ -317,20 +297,20 @@ static struct tc_action_ops act_gact_ops = { ...@@ -317,20 +297,20 @@ static struct tc_action_ops act_gact_ops = {
static __net_init int gact_init_net(struct net *net) static __net_init int gact_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, gact_net_id); struct tc_action_net *tn = net_generic(net, act_gact_ops.net_id);
return tc_action_net_init(net, tn, &act_gact_ops); return tc_action_net_init(net, tn, &act_gact_ops);
} }
static void __net_exit gact_exit_net(struct list_head *net_list) static void __net_exit gact_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, gact_net_id); tc_action_net_exit(net_list, act_gact_ops.net_id);
} }
static struct pernet_operations gact_net_ops = { static struct pernet_operations gact_net_ops = {
.init = gact_init_net, .init = gact_init_net,
.exit_batch = gact_exit_net, .exit_batch = gact_exit_net,
.id = &gact_net_id, .id = &act_gact_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <net/pkt_cls.h> #include <net/pkt_cls.h>
#include <net/tc_act/tc_gate.h> #include <net/tc_act/tc_gate.h>
static unsigned int gate_net_id;
static struct tc_action_ops act_gate_ops; static struct tc_action_ops act_gate_ops;
static ktime_t gate_get_time(struct tcf_gate *gact) static ktime_t gate_get_time(struct tcf_gate *gact)
...@@ -298,7 +297,7 @@ static int tcf_gate_init(struct net *net, struct nlattr *nla, ...@@ -298,7 +297,7 @@ static int tcf_gate_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, u32 flags, struct tcf_proto *tp, u32 flags,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, gate_net_id); struct tc_action_net *tn = net_generic(net, act_gate_ops.net_id);
enum tk_offsets tk_offset = TK_OFFS_TAI; enum tk_offsets tk_offset = TK_OFFS_TAI;
bool bind = flags & TCA_ACT_FLAGS_BIND; bool bind = flags & TCA_ACT_FLAGS_BIND;
struct nlattr *tb[TCA_GATE_MAX + 1]; struct nlattr *tb[TCA_GATE_MAX + 1];
...@@ -565,16 +564,6 @@ static int tcf_gate_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -565,16 +564,6 @@ static int tcf_gate_dump(struct sk_buff *skb, struct tc_action *a,
return -1; return -1;
} }
static int tcf_gate_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, gate_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static void tcf_gate_stats_update(struct tc_action *a, u64 bytes, u64 packets, static void tcf_gate_stats_update(struct tc_action *a, u64 bytes, u64 packets,
u64 drops, u64 lastuse, bool hw) u64 drops, u64 lastuse, bool hw)
{ {
...@@ -585,13 +574,6 @@ static void tcf_gate_stats_update(struct tc_action *a, u64 bytes, u64 packets, ...@@ -585,13 +574,6 @@ static void tcf_gate_stats_update(struct tc_action *a, u64 bytes, u64 packets,
tm->lastuse = max_t(u64, tm->lastuse, lastuse); tm->lastuse = max_t(u64, tm->lastuse, lastuse);
} }
static int tcf_gate_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, gate_net_id);
return tcf_idr_search(tn, a, index);
}
static size_t tcf_gate_get_fill_size(const struct tc_action *act) static size_t tcf_gate_get_fill_size(const struct tc_action *act)
{ {
return nla_total_size(sizeof(struct tc_gate)); return nla_total_size(sizeof(struct tc_gate));
...@@ -654,30 +636,28 @@ static struct tc_action_ops act_gate_ops = { ...@@ -654,30 +636,28 @@ static struct tc_action_ops act_gate_ops = {
.dump = tcf_gate_dump, .dump = tcf_gate_dump,
.init = tcf_gate_init, .init = tcf_gate_init,
.cleanup = tcf_gate_cleanup, .cleanup = tcf_gate_cleanup,
.walk = tcf_gate_walker,
.stats_update = tcf_gate_stats_update, .stats_update = tcf_gate_stats_update,
.get_fill_size = tcf_gate_get_fill_size, .get_fill_size = tcf_gate_get_fill_size,
.lookup = tcf_gate_search,
.offload_act_setup = tcf_gate_offload_act_setup, .offload_act_setup = tcf_gate_offload_act_setup,
.size = sizeof(struct tcf_gate), .size = sizeof(struct tcf_gate),
}; };
static __net_init int gate_init_net(struct net *net) static __net_init int gate_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, gate_net_id); struct tc_action_net *tn = net_generic(net, act_gate_ops.net_id);
return tc_action_net_init(net, tn, &act_gate_ops); return tc_action_net_init(net, tn, &act_gate_ops);
} }
static void __net_exit gate_exit_net(struct list_head *net_list) static void __net_exit gate_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, gate_net_id); tc_action_net_exit(net_list, act_gate_ops.net_id);
} }
static struct pernet_operations gate_net_ops = { static struct pernet_operations gate_net_ops = {
.init = gate_init_net, .init = gate_init_net,
.exit_batch = gate_exit_net, .exit_batch = gate_exit_net,
.id = &gate_net_id, .id = &act_gate_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -30,7 +30,6 @@ ...@@ -30,7 +30,6 @@
#include <linux/etherdevice.h> #include <linux/etherdevice.h>
#include <net/ife.h> #include <net/ife.h>
static unsigned int ife_net_id;
static int max_metacnt = IFE_META_MAX + 1; static int max_metacnt = IFE_META_MAX + 1;
static struct tc_action_ops act_ife_ops; static struct tc_action_ops act_ife_ops;
...@@ -482,7 +481,7 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla, ...@@ -482,7 +481,7 @@ static int tcf_ife_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, u32 flags, struct tcf_proto *tp, u32 flags,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, ife_net_id); struct tc_action_net *tn = net_generic(net, act_ife_ops.net_id);
bool bind = flags & TCA_ACT_FLAGS_BIND; bool bind = flags & TCA_ACT_FLAGS_BIND;
struct nlattr *tb[TCA_IFE_MAX + 1]; struct nlattr *tb[TCA_IFE_MAX + 1];
struct nlattr *tb2[IFE_META_MAX + 1]; struct nlattr *tb2[IFE_META_MAX + 1];
...@@ -878,23 +877,6 @@ static int tcf_ife_act(struct sk_buff *skb, const struct tc_action *a, ...@@ -878,23 +877,6 @@ static int tcf_ife_act(struct sk_buff *skb, const struct tc_action *a,
return tcf_ife_decode(skb, a, res); return tcf_ife_decode(skb, a, res);
} }
static int tcf_ife_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, ife_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tcf_ife_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, ife_net_id);
return tcf_idr_search(tn, a, index);
}
static struct tc_action_ops act_ife_ops = { static struct tc_action_ops act_ife_ops = {
.kind = "ife", .kind = "ife",
.id = TCA_ID_IFE, .id = TCA_ID_IFE,
...@@ -903,27 +885,25 @@ static struct tc_action_ops act_ife_ops = { ...@@ -903,27 +885,25 @@ static struct tc_action_ops act_ife_ops = {
.dump = tcf_ife_dump, .dump = tcf_ife_dump,
.cleanup = tcf_ife_cleanup, .cleanup = tcf_ife_cleanup,
.init = tcf_ife_init, .init = tcf_ife_init,
.walk = tcf_ife_walker,
.lookup = tcf_ife_search,
.size = sizeof(struct tcf_ife_info), .size = sizeof(struct tcf_ife_info),
}; };
static __net_init int ife_init_net(struct net *net) static __net_init int ife_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, ife_net_id); struct tc_action_net *tn = net_generic(net, act_ife_ops.net_id);
return tc_action_net_init(net, tn, &act_ife_ops); return tc_action_net_init(net, tn, &act_ife_ops);
} }
static void __net_exit ife_exit_net(struct list_head *net_list) static void __net_exit ife_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, ife_net_id); tc_action_net_exit(net_list, act_ife_ops.net_id);
} }
static struct pernet_operations ife_net_ops = { static struct pernet_operations ife_net_ops = {
.init = ife_init_net, .init = ife_init_net,
.exit_batch = ife_exit_net, .exit_batch = ife_exit_net,
.id = &ife_net_id, .id = &act_ife_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -24,10 +24,7 @@ ...@@ -24,10 +24,7 @@
#include <linux/netfilter_ipv4/ip_tables.h> #include <linux/netfilter_ipv4/ip_tables.h>
static unsigned int ipt_net_id;
static struct tc_action_ops act_ipt_ops; static struct tc_action_ops act_ipt_ops;
static unsigned int xt_net_id;
static struct tc_action_ops act_xt_ops; static struct tc_action_ops act_xt_ops;
static int ipt_init_target(struct net *net, struct xt_entry_target *t, static int ipt_init_target(struct net *net, struct xt_entry_target *t,
...@@ -206,8 +203,8 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla, ...@@ -206,8 +203,8 @@ static int tcf_ipt_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, struct tcf_proto *tp,
u32 flags, 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, return __tcf_ipt_init(net, act_ipt_ops.net_id, nla, est,
tp, flags); a, &act_ipt_ops, tp, flags);
} }
static int tcf_xt_init(struct net *net, struct nlattr *nla, static int tcf_xt_init(struct net *net, struct nlattr *nla,
...@@ -215,8 +212,8 @@ static int tcf_xt_init(struct net *net, struct nlattr *nla, ...@@ -215,8 +212,8 @@ static int tcf_xt_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, struct tcf_proto *tp,
u32 flags, 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, return __tcf_ipt_init(net, act_xt_ops.net_id, nla, est,
tp, flags); a, &act_xt_ops, tp, flags);
} }
static int tcf_ipt_act(struct sk_buff *skb, const struct tc_action *a, static int tcf_ipt_act(struct sk_buff *skb, const struct tc_action *a,
...@@ -316,23 +313,6 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind, ...@@ -316,23 +313,6 @@ static int tcf_ipt_dump(struct sk_buff *skb, struct tc_action *a, int bind,
return -1; return -1;
} }
static int tcf_ipt_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, ipt_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tcf_ipt_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, ipt_net_id);
return tcf_idr_search(tn, a, index);
}
static struct tc_action_ops act_ipt_ops = { static struct tc_action_ops act_ipt_ops = {
.kind = "ipt", .kind = "ipt",
.id = TCA_ID_IPT, .id = TCA_ID_IPT,
...@@ -341,47 +321,28 @@ static struct tc_action_ops act_ipt_ops = { ...@@ -341,47 +321,28 @@ static struct tc_action_ops act_ipt_ops = {
.dump = tcf_ipt_dump, .dump = tcf_ipt_dump,
.cleanup = tcf_ipt_release, .cleanup = tcf_ipt_release,
.init = tcf_ipt_init, .init = tcf_ipt_init,
.walk = tcf_ipt_walker,
.lookup = tcf_ipt_search,
.size = sizeof(struct tcf_ipt), .size = sizeof(struct tcf_ipt),
}; };
static __net_init int ipt_init_net(struct net *net) static __net_init int ipt_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, ipt_net_id); struct tc_action_net *tn = net_generic(net, act_ipt_ops.net_id);
return tc_action_net_init(net, tn, &act_ipt_ops); return tc_action_net_init(net, tn, &act_ipt_ops);
} }
static void __net_exit ipt_exit_net(struct list_head *net_list) static void __net_exit ipt_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, ipt_net_id); tc_action_net_exit(net_list, act_ipt_ops.net_id);
} }
static struct pernet_operations ipt_net_ops = { static struct pernet_operations ipt_net_ops = {
.init = ipt_init_net, .init = ipt_init_net,
.exit_batch = ipt_exit_net, .exit_batch = ipt_exit_net,
.id = &ipt_net_id, .id = &act_ipt_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
static int tcf_xt_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, xt_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tcf_xt_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, xt_net_id);
return tcf_idr_search(tn, a, index);
}
static struct tc_action_ops act_xt_ops = { static struct tc_action_ops act_xt_ops = {
.kind = "xt", .kind = "xt",
.id = TCA_ID_XT, .id = TCA_ID_XT,
...@@ -390,27 +351,25 @@ static struct tc_action_ops act_xt_ops = { ...@@ -390,27 +351,25 @@ static struct tc_action_ops act_xt_ops = {
.dump = tcf_ipt_dump, .dump = tcf_ipt_dump,
.cleanup = tcf_ipt_release, .cleanup = tcf_ipt_release,
.init = tcf_xt_init, .init = tcf_xt_init,
.walk = tcf_xt_walker,
.lookup = tcf_xt_search,
.size = sizeof(struct tcf_ipt), .size = sizeof(struct tcf_ipt),
}; };
static __net_init int xt_init_net(struct net *net) static __net_init int xt_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, xt_net_id); struct tc_action_net *tn = net_generic(net, act_xt_ops.net_id);
return tc_action_net_init(net, tn, &act_xt_ops); return tc_action_net_init(net, tn, &act_xt_ops);
} }
static void __net_exit xt_exit_net(struct list_head *net_list) static void __net_exit xt_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, xt_net_id); tc_action_net_exit(net_list, act_xt_ops.net_id);
} }
static struct pernet_operations xt_net_ops = { static struct pernet_operations xt_net_ops = {
.init = xt_init_net, .init = xt_init_net,
.exit_batch = xt_exit_net, .exit_batch = xt_exit_net,
.id = &xt_net_id, .id = &act_xt_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -86,7 +86,6 @@ static const struct nla_policy mirred_policy[TCA_MIRRED_MAX + 1] = { ...@@ -86,7 +86,6 @@ static const struct nla_policy mirred_policy[TCA_MIRRED_MAX + 1] = {
[TCA_MIRRED_PARMS] = { .len = sizeof(struct tc_mirred) }, [TCA_MIRRED_PARMS] = { .len = sizeof(struct tc_mirred) },
}; };
static unsigned int mirred_net_id;
static struct tc_action_ops act_mirred_ops; static struct tc_action_ops act_mirred_ops;
static int tcf_mirred_init(struct net *net, struct nlattr *nla, static int tcf_mirred_init(struct net *net, struct nlattr *nla,
...@@ -94,7 +93,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla, ...@@ -94,7 +93,7 @@ static int tcf_mirred_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, struct tcf_proto *tp,
u32 flags, struct netlink_ext_ack *extack) u32 flags, struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, mirred_net_id); struct tc_action_net *tn = net_generic(net, act_mirred_ops.net_id);
bool bind = flags & TCA_ACT_FLAGS_BIND; bool bind = flags & TCA_ACT_FLAGS_BIND;
struct nlattr *tb[TCA_MIRRED_MAX + 1]; struct nlattr *tb[TCA_MIRRED_MAX + 1];
struct tcf_chain *goto_ch = NULL; struct tcf_chain *goto_ch = NULL;
...@@ -373,23 +372,6 @@ static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind, ...@@ -373,23 +372,6 @@ static int tcf_mirred_dump(struct sk_buff *skb, struct tc_action *a, int bind,
return -1; return -1;
} }
static int tcf_mirred_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, mirred_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tcf_mirred_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, mirred_net_id);
return tcf_idr_search(tn, a, index);
}
static int mirred_device_event(struct notifier_block *unused, static int mirred_device_event(struct notifier_block *unused,
unsigned long event, void *ptr) unsigned long event, void *ptr)
{ {
...@@ -510,8 +492,6 @@ static struct tc_action_ops act_mirred_ops = { ...@@ -510,8 +492,6 @@ static struct tc_action_ops act_mirred_ops = {
.dump = tcf_mirred_dump, .dump = tcf_mirred_dump,
.cleanup = tcf_mirred_release, .cleanup = tcf_mirred_release,
.init = tcf_mirred_init, .init = tcf_mirred_init,
.walk = tcf_mirred_walker,
.lookup = tcf_mirred_search,
.get_fill_size = tcf_mirred_get_fill_size, .get_fill_size = tcf_mirred_get_fill_size,
.offload_act_setup = tcf_mirred_offload_act_setup, .offload_act_setup = tcf_mirred_offload_act_setup,
.size = sizeof(struct tcf_mirred), .size = sizeof(struct tcf_mirred),
...@@ -520,20 +500,20 @@ static struct tc_action_ops act_mirred_ops = { ...@@ -520,20 +500,20 @@ static struct tc_action_ops act_mirred_ops = {
static __net_init int mirred_init_net(struct net *net) static __net_init int mirred_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, mirred_net_id); struct tc_action_net *tn = net_generic(net, act_mirred_ops.net_id);
return tc_action_net_init(net, tn, &act_mirred_ops); return tc_action_net_init(net, tn, &act_mirred_ops);
} }
static void __net_exit mirred_exit_net(struct list_head *net_list) static void __net_exit mirred_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, mirred_net_id); tc_action_net_exit(net_list, act_mirred_ops.net_id);
} }
static struct pernet_operations mirred_net_ops = { static struct pernet_operations mirred_net_ops = {
.init = mirred_init_net, .init = mirred_init_net,
.exit_batch = mirred_exit_net, .exit_batch = mirred_exit_net,
.id = &mirred_net_id, .id = &act_mirred_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -15,7 +15,6 @@ ...@@ -15,7 +15,6 @@
#include <net/pkt_cls.h> #include <net/pkt_cls.h>
#include <net/tc_act/tc_mpls.h> #include <net/tc_act/tc_mpls.h>
static unsigned int mpls_net_id;
static struct tc_action_ops act_mpls_ops; static struct tc_action_ops act_mpls_ops;
#define ACT_MPLS_TTL_DEFAULT 255 #define ACT_MPLS_TTL_DEFAULT 255
...@@ -155,7 +154,7 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla, ...@@ -155,7 +154,7 @@ static int tcf_mpls_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, u32 flags, struct tcf_proto *tp, u32 flags,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, mpls_net_id); struct tc_action_net *tn = net_generic(net, act_mpls_ops.net_id);
bool bind = flags & TCA_ACT_FLAGS_BIND; bool bind = flags & TCA_ACT_FLAGS_BIND;
struct nlattr *tb[TCA_MPLS_MAX + 1]; struct nlattr *tb[TCA_MPLS_MAX + 1];
struct tcf_chain *goto_ch = NULL; struct tcf_chain *goto_ch = NULL;
...@@ -367,23 +366,6 @@ static int tcf_mpls_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -367,23 +366,6 @@ static int tcf_mpls_dump(struct sk_buff *skb, struct tc_action *a,
return -EMSGSIZE; return -EMSGSIZE;
} }
static int tcf_mpls_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, mpls_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tcf_mpls_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, mpls_net_id);
return tcf_idr_search(tn, a, index);
}
static int tcf_mpls_offload_act_setup(struct tc_action *act, void *entry_data, 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) struct netlink_ext_ack *extack)
...@@ -451,28 +433,26 @@ static struct tc_action_ops act_mpls_ops = { ...@@ -451,28 +433,26 @@ static struct tc_action_ops act_mpls_ops = {
.dump = tcf_mpls_dump, .dump = tcf_mpls_dump,
.init = tcf_mpls_init, .init = tcf_mpls_init,
.cleanup = tcf_mpls_cleanup, .cleanup = tcf_mpls_cleanup,
.walk = tcf_mpls_walker,
.lookup = tcf_mpls_search,
.offload_act_setup = tcf_mpls_offload_act_setup, .offload_act_setup = tcf_mpls_offload_act_setup,
.size = sizeof(struct tcf_mpls), .size = sizeof(struct tcf_mpls),
}; };
static __net_init int mpls_init_net(struct net *net) static __net_init int mpls_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, mpls_net_id); struct tc_action_net *tn = net_generic(net, act_mpls_ops.net_id);
return tc_action_net_init(net, tn, &act_mpls_ops); return tc_action_net_init(net, tn, &act_mpls_ops);
} }
static void __net_exit mpls_exit_net(struct list_head *net_list) static void __net_exit mpls_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, mpls_net_id); tc_action_net_exit(net_list, act_mpls_ops.net_id);
} }
static struct pernet_operations mpls_net_ops = { static struct pernet_operations mpls_net_ops = {
.init = mpls_init_net, .init = mpls_init_net,
.exit_batch = mpls_exit_net, .exit_batch = mpls_exit_net,
.id = &mpls_net_id, .id = &act_mpls_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -26,7 +26,6 @@ ...@@ -26,7 +26,6 @@
#include <net/udp.h> #include <net/udp.h>
static unsigned int nat_net_id;
static struct tc_action_ops act_nat_ops; static struct tc_action_ops act_nat_ops;
static const struct nla_policy nat_policy[TCA_NAT_MAX + 1] = { static const struct nla_policy nat_policy[TCA_NAT_MAX + 1] = {
...@@ -37,7 +36,7 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est, ...@@ -37,7 +36,7 @@ static int tcf_nat_init(struct net *net, struct nlattr *nla, struct nlattr *est,
struct tc_action **a, struct tcf_proto *tp, struct tc_action **a, struct tcf_proto *tp,
u32 flags, struct netlink_ext_ack *extack) u32 flags, struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, nat_net_id); struct tc_action_net *tn = net_generic(net, act_nat_ops.net_id);
bool bind = flags & TCA_ACT_FLAGS_BIND; bool bind = flags & TCA_ACT_FLAGS_BIND;
struct nlattr *tb[TCA_NAT_MAX + 1]; struct nlattr *tb[TCA_NAT_MAX + 1];
struct tcf_chain *goto_ch = NULL; struct tcf_chain *goto_ch = NULL;
...@@ -289,23 +288,6 @@ static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -289,23 +288,6 @@ static int tcf_nat_dump(struct sk_buff *skb, struct tc_action *a,
return -1; return -1;
} }
static int tcf_nat_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, nat_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tcf_nat_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, nat_net_id);
return tcf_idr_search(tn, a, index);
}
static struct tc_action_ops act_nat_ops = { static struct tc_action_ops act_nat_ops = {
.kind = "nat", .kind = "nat",
.id = TCA_ID_NAT, .id = TCA_ID_NAT,
...@@ -313,27 +295,25 @@ static struct tc_action_ops act_nat_ops = { ...@@ -313,27 +295,25 @@ static struct tc_action_ops act_nat_ops = {
.act = tcf_nat_act, .act = tcf_nat_act,
.dump = tcf_nat_dump, .dump = tcf_nat_dump,
.init = tcf_nat_init, .init = tcf_nat_init,
.walk = tcf_nat_walker,
.lookup = tcf_nat_search,
.size = sizeof(struct tcf_nat), .size = sizeof(struct tcf_nat),
}; };
static __net_init int nat_init_net(struct net *net) static __net_init int nat_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, nat_net_id); struct tc_action_net *tn = net_generic(net, act_nat_ops.net_id);
return tc_action_net_init(net, tn, &act_nat_ops); return tc_action_net_init(net, tn, &act_nat_ops);
} }
static void __net_exit nat_exit_net(struct list_head *net_list) static void __net_exit nat_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, nat_net_id); tc_action_net_exit(net_list, act_nat_ops.net_id);
} }
static struct pernet_operations nat_net_ops = { static struct pernet_operations nat_net_ops = {
.init = nat_init_net, .init = nat_init_net,
.exit_batch = nat_exit_net, .exit_batch = nat_exit_net,
.id = &nat_net_id, .id = &act_nat_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include <uapi/linux/tc_act/tc_pedit.h> #include <uapi/linux/tc_act/tc_pedit.h>
#include <net/pkt_cls.h> #include <net/pkt_cls.h>
static unsigned int pedit_net_id;
static struct tc_action_ops act_pedit_ops; static struct tc_action_ops act_pedit_ops;
static const struct nla_policy pedit_policy[TCA_PEDIT_MAX + 1] = { static const struct nla_policy pedit_policy[TCA_PEDIT_MAX + 1] = {
...@@ -139,7 +138,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla, ...@@ -139,7 +138,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, u32 flags, struct tcf_proto *tp, u32 flags,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, pedit_net_id); struct tc_action_net *tn = net_generic(net, act_pedit_ops.net_id);
bool bind = flags & TCA_ACT_FLAGS_BIND; bool bind = flags & TCA_ACT_FLAGS_BIND;
struct nlattr *tb[TCA_PEDIT_MAX + 1]; struct nlattr *tb[TCA_PEDIT_MAX + 1];
struct tcf_chain *goto_ch = NULL; struct tcf_chain *goto_ch = NULL;
...@@ -492,23 +491,6 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -492,23 +491,6 @@ static int tcf_pedit_dump(struct sk_buff *skb, struct tc_action *a,
return -1; return -1;
} }
static int tcf_pedit_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, pedit_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tcf_pedit_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, pedit_net_id);
return tcf_idr_search(tn, a, index);
}
static int tcf_pedit_offload_act_setup(struct tc_action *act, void *entry_data, 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) struct netlink_ext_ack *extack)
...@@ -553,28 +535,26 @@ static struct tc_action_ops act_pedit_ops = { ...@@ -553,28 +535,26 @@ static struct tc_action_ops act_pedit_ops = {
.dump = tcf_pedit_dump, .dump = tcf_pedit_dump,
.cleanup = tcf_pedit_cleanup, .cleanup = tcf_pedit_cleanup,
.init = tcf_pedit_init, .init = tcf_pedit_init,
.walk = tcf_pedit_walker,
.lookup = tcf_pedit_search,
.offload_act_setup = tcf_pedit_offload_act_setup, .offload_act_setup = tcf_pedit_offload_act_setup,
.size = sizeof(struct tcf_pedit), .size = sizeof(struct tcf_pedit),
}; };
static __net_init int pedit_init_net(struct net *net) static __net_init int pedit_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, pedit_net_id); struct tc_action_net *tn = net_generic(net, act_pedit_ops.net_id);
return tc_action_net_init(net, tn, &act_pedit_ops); return tc_action_net_init(net, tn, &act_pedit_ops);
} }
static void __net_exit pedit_exit_net(struct list_head *net_list) static void __net_exit pedit_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, pedit_net_id); tc_action_net_exit(net_list, act_pedit_ops.net_id);
} }
static struct pernet_operations pedit_net_ops = { static struct pernet_operations pedit_net_ops = {
.init = pedit_init_net, .init = pedit_init_net,
.exit_batch = pedit_exit_net, .exit_batch = pedit_exit_net,
.id = &pedit_net_id, .id = &act_pedit_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -22,19 +22,8 @@ ...@@ -22,19 +22,8 @@
/* Each policer is serialized by its individual spinlock */ /* Each policer is serialized by its individual spinlock */
static unsigned int police_net_id;
static struct tc_action_ops act_police_ops; static struct tc_action_ops act_police_ops;
static int tcf_police_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, police_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static const struct nla_policy police_policy[TCA_POLICE_MAX + 1] = { static const struct nla_policy police_policy[TCA_POLICE_MAX + 1] = {
[TCA_POLICE_RATE] = { .len = TC_RTAB_SIZE }, [TCA_POLICE_RATE] = { .len = TC_RTAB_SIZE },
[TCA_POLICE_PEAKRATE] = { .len = TC_RTAB_SIZE }, [TCA_POLICE_PEAKRATE] = { .len = TC_RTAB_SIZE },
...@@ -58,7 +47,7 @@ static int tcf_police_init(struct net *net, struct nlattr *nla, ...@@ -58,7 +47,7 @@ static int tcf_police_init(struct net *net, struct nlattr *nla,
struct tc_police *parm; struct tc_police *parm;
struct tcf_police *police; struct tcf_police *police;
struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL; struct qdisc_rate_table *R_tab = NULL, *P_tab = NULL;
struct tc_action_net *tn = net_generic(net, police_net_id); struct tc_action_net *tn = net_generic(net, act_police_ops.net_id);
struct tcf_police_params *new; struct tcf_police_params *new;
bool exists = false; bool exists = false;
u32 index; u32 index;
...@@ -412,13 +401,6 @@ static int tcf_police_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -412,13 +401,6 @@ static int tcf_police_dump(struct sk_buff *skb, struct tc_action *a,
return -1; return -1;
} }
static int tcf_police_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, police_net_id);
return tcf_idr_search(tn, a, index);
}
static int tcf_police_act_to_flow_act(int tc_act, u32 *extval, static int tcf_police_act_to_flow_act(int tc_act, u32 *extval,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
...@@ -513,8 +495,6 @@ static struct tc_action_ops act_police_ops = { ...@@ -513,8 +495,6 @@ static struct tc_action_ops act_police_ops = {
.act = tcf_police_act, .act = tcf_police_act,
.dump = tcf_police_dump, .dump = tcf_police_dump,
.init = tcf_police_init, .init = tcf_police_init,
.walk = tcf_police_walker,
.lookup = tcf_police_search,
.cleanup = tcf_police_cleanup, .cleanup = tcf_police_cleanup,
.offload_act_setup = tcf_police_offload_act_setup, .offload_act_setup = tcf_police_offload_act_setup,
.size = sizeof(struct tcf_police), .size = sizeof(struct tcf_police),
...@@ -522,20 +502,20 @@ static struct tc_action_ops act_police_ops = { ...@@ -522,20 +502,20 @@ static struct tc_action_ops act_police_ops = {
static __net_init int police_init_net(struct net *net) static __net_init int police_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, police_net_id); struct tc_action_net *tn = net_generic(net, act_police_ops.net_id);
return tc_action_net_init(net, tn, &act_police_ops); return tc_action_net_init(net, tn, &act_police_ops);
} }
static void __net_exit police_exit_net(struct list_head *net_list) static void __net_exit police_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, police_net_id); tc_action_net_exit(net_list, act_police_ops.net_id);
} }
static struct pernet_operations police_net_ops = { static struct pernet_operations police_net_ops = {
.init = police_init_net, .init = police_init_net,
.exit_batch = police_exit_net, .exit_batch = police_exit_net,
.id = &police_net_id, .id = &act_police_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <linux/if_arp.h> #include <linux/if_arp.h>
static unsigned int sample_net_id;
static struct tc_action_ops act_sample_ops; static struct tc_action_ops act_sample_ops;
static const struct nla_policy sample_policy[TCA_SAMPLE_MAX + 1] = { static const struct nla_policy sample_policy[TCA_SAMPLE_MAX + 1] = {
...@@ -38,7 +37,7 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla, ...@@ -38,7 +37,7 @@ static int tcf_sample_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, struct tcf_proto *tp,
u32 flags, struct netlink_ext_ack *extack) u32 flags, struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, sample_net_id); struct tc_action_net *tn = net_generic(net, act_sample_ops.net_id);
bool bind = flags & TCA_ACT_FLAGS_BIND; bool bind = flags & TCA_ACT_FLAGS_BIND;
struct nlattr *tb[TCA_SAMPLE_MAX + 1]; struct nlattr *tb[TCA_SAMPLE_MAX + 1];
struct psample_group *psample_group; struct psample_group *psample_group;
...@@ -241,23 +240,6 @@ static int tcf_sample_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -241,23 +240,6 @@ static int tcf_sample_dump(struct sk_buff *skb, struct tc_action *a,
return -1; return -1;
} }
static int tcf_sample_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, sample_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tcf_sample_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, sample_net_id);
return tcf_idr_search(tn, a, index);
}
static void tcf_psample_group_put(void *priv) static void tcf_psample_group_put(void *priv)
{ {
struct psample_group *group = priv; struct psample_group *group = priv;
...@@ -321,8 +303,6 @@ static struct tc_action_ops act_sample_ops = { ...@@ -321,8 +303,6 @@ static struct tc_action_ops act_sample_ops = {
.dump = tcf_sample_dump, .dump = tcf_sample_dump,
.init = tcf_sample_init, .init = tcf_sample_init,
.cleanup = tcf_sample_cleanup, .cleanup = tcf_sample_cleanup,
.walk = tcf_sample_walker,
.lookup = tcf_sample_search,
.get_psample_group = tcf_sample_get_group, .get_psample_group = tcf_sample_get_group,
.offload_act_setup = tcf_sample_offload_act_setup, .offload_act_setup = tcf_sample_offload_act_setup,
.size = sizeof(struct tcf_sample), .size = sizeof(struct tcf_sample),
...@@ -330,20 +310,20 @@ static struct tc_action_ops act_sample_ops = { ...@@ -330,20 +310,20 @@ static struct tc_action_ops act_sample_ops = {
static __net_init int sample_init_net(struct net *net) static __net_init int sample_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, sample_net_id); struct tc_action_net *tn = net_generic(net, act_sample_ops.net_id);
return tc_action_net_init(net, tn, &act_sample_ops); return tc_action_net_init(net, tn, &act_sample_ops);
} }
static void __net_exit sample_exit_net(struct list_head *net_list) static void __net_exit sample_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, sample_net_id); tc_action_net_exit(net_list, act_sample_ops.net_id);
} }
static struct pernet_operations sample_net_ops = { static struct pernet_operations sample_net_ops = {
.init = sample_init_net, .init = sample_init_net,
.exit_batch = sample_exit_net, .exit_batch = sample_exit_net,
.id = &sample_net_id, .id = &act_sample_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <linux/tc_act/tc_defact.h> #include <linux/tc_act/tc_defact.h>
#include <net/tc_act/tc_defact.h> #include <net/tc_act/tc_defact.h>
static unsigned int simp_net_id;
static struct tc_action_ops act_simp_ops; static struct tc_action_ops act_simp_ops;
#define SIMP_MAX_DATA 32 #define SIMP_MAX_DATA 32
...@@ -89,7 +88,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, ...@@ -89,7 +88,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, u32 flags, struct tcf_proto *tp, u32 flags,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, simp_net_id); struct tc_action_net *tn = net_generic(net, act_simp_ops.net_id);
bool bind = flags & TCA_ACT_FLAGS_BIND; bool bind = flags & TCA_ACT_FLAGS_BIND;
struct nlattr *tb[TCA_DEF_MAX + 1]; struct nlattr *tb[TCA_DEF_MAX + 1];
struct tcf_chain *goto_ch = NULL; struct tcf_chain *goto_ch = NULL;
...@@ -198,23 +197,6 @@ static int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -198,23 +197,6 @@ static int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a,
return -1; return -1;
} }
static int tcf_simp_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, simp_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tcf_simp_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, simp_net_id);
return tcf_idr_search(tn, a, index);
}
static struct tc_action_ops act_simp_ops = { static struct tc_action_ops act_simp_ops = {
.kind = "simple", .kind = "simple",
.id = TCA_ID_SIMP, .id = TCA_ID_SIMP,
...@@ -223,27 +205,25 @@ static struct tc_action_ops act_simp_ops = { ...@@ -223,27 +205,25 @@ static struct tc_action_ops act_simp_ops = {
.dump = tcf_simp_dump, .dump = tcf_simp_dump,
.cleanup = tcf_simp_release, .cleanup = tcf_simp_release,
.init = tcf_simp_init, .init = tcf_simp_init,
.walk = tcf_simp_walker,
.lookup = tcf_simp_search,
.size = sizeof(struct tcf_defact), .size = sizeof(struct tcf_defact),
}; };
static __net_init int simp_init_net(struct net *net) static __net_init int simp_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, simp_net_id); struct tc_action_net *tn = net_generic(net, act_simp_ops.net_id);
return tc_action_net_init(net, tn, &act_simp_ops); return tc_action_net_init(net, tn, &act_simp_ops);
} }
static void __net_exit simp_exit_net(struct list_head *net_list) static void __net_exit simp_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, simp_net_id); tc_action_net_exit(net_list, act_simp_ops.net_id);
} }
static struct pernet_operations simp_net_ops = { static struct pernet_operations simp_net_ops = {
.init = simp_init_net, .init = simp_init_net,
.exit_batch = simp_exit_net, .exit_batch = simp_exit_net,
.id = &simp_net_id, .id = &act_simp_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <linux/tc_act/tc_skbedit.h> #include <linux/tc_act/tc_skbedit.h>
#include <net/tc_act/tc_skbedit.h> #include <net/tc_act/tc_skbedit.h>
static unsigned int skbedit_net_id;
static struct tc_action_ops act_skbedit_ops; static struct tc_action_ops act_skbedit_ops;
static u16 tcf_skbedit_hash(struct tcf_skbedit_params *params, static u16 tcf_skbedit_hash(struct tcf_skbedit_params *params,
...@@ -118,7 +117,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla, ...@@ -118,7 +117,7 @@ static int tcf_skbedit_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, u32 act_flags, struct tcf_proto *tp, u32 act_flags,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, skbedit_net_id); struct tc_action_net *tn = net_generic(net, act_skbedit_ops.net_id);
bool bind = act_flags & TCA_ACT_FLAGS_BIND; bool bind = act_flags & TCA_ACT_FLAGS_BIND;
struct tcf_skbedit_params *params_new; struct tcf_skbedit_params *params_new;
struct nlattr *tb[TCA_SKBEDIT_MAX + 1]; struct nlattr *tb[TCA_SKBEDIT_MAX + 1];
...@@ -347,23 +346,6 @@ static void tcf_skbedit_cleanup(struct tc_action *a) ...@@ -347,23 +346,6 @@ static void tcf_skbedit_cleanup(struct tc_action *a)
kfree_rcu(params, rcu); kfree_rcu(params, rcu);
} }
static int tcf_skbedit_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, skbedit_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tcf_skbedit_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, skbedit_net_id);
return tcf_idr_search(tn, a, index);
}
static size_t tcf_skbedit_get_fill_size(const struct tc_action *act) static size_t tcf_skbedit_get_fill_size(const struct tc_action *act)
{ {
return nla_total_size(sizeof(struct tc_skbedit)) return nla_total_size(sizeof(struct tc_skbedit))
...@@ -428,29 +410,27 @@ static struct tc_action_ops act_skbedit_ops = { ...@@ -428,29 +410,27 @@ static struct tc_action_ops act_skbedit_ops = {
.dump = tcf_skbedit_dump, .dump = tcf_skbedit_dump,
.init = tcf_skbedit_init, .init = tcf_skbedit_init,
.cleanup = tcf_skbedit_cleanup, .cleanup = tcf_skbedit_cleanup,
.walk = tcf_skbedit_walker,
.get_fill_size = tcf_skbedit_get_fill_size, .get_fill_size = tcf_skbedit_get_fill_size,
.lookup = tcf_skbedit_search,
.offload_act_setup = tcf_skbedit_offload_act_setup, .offload_act_setup = tcf_skbedit_offload_act_setup,
.size = sizeof(struct tcf_skbedit), .size = sizeof(struct tcf_skbedit),
}; };
static __net_init int skbedit_init_net(struct net *net) static __net_init int skbedit_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, skbedit_net_id); struct tc_action_net *tn = net_generic(net, act_skbedit_ops.net_id);
return tc_action_net_init(net, tn, &act_skbedit_ops); return tc_action_net_init(net, tn, &act_skbedit_ops);
} }
static void __net_exit skbedit_exit_net(struct list_head *net_list) static void __net_exit skbedit_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, skbedit_net_id); tc_action_net_exit(net_list, act_skbedit_ops.net_id);
} }
static struct pernet_operations skbedit_net_ops = { static struct pernet_operations skbedit_net_ops = {
.init = skbedit_init_net, .init = skbedit_init_net,
.exit_batch = skbedit_exit_net, .exit_batch = skbedit_exit_net,
.id = &skbedit_net_id, .id = &act_skbedit_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
#include <linux/tc_act/tc_skbmod.h> #include <linux/tc_act/tc_skbmod.h>
#include <net/tc_act/tc_skbmod.h> #include <net/tc_act/tc_skbmod.h>
static unsigned int skbmod_net_id;
static struct tc_action_ops act_skbmod_ops; static struct tc_action_ops act_skbmod_ops;
static int tcf_skbmod_act(struct sk_buff *skb, const struct tc_action *a, static int tcf_skbmod_act(struct sk_buff *skb, const struct tc_action *a,
...@@ -103,7 +102,7 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla, ...@@ -103,7 +102,7 @@ static int tcf_skbmod_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, u32 flags, struct tcf_proto *tp, u32 flags,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, skbmod_net_id); struct tc_action_net *tn = net_generic(net, act_skbmod_ops.net_id);
bool ovr = flags & TCA_ACT_FLAGS_REPLACE; bool ovr = flags & TCA_ACT_FLAGS_REPLACE;
bool bind = flags & TCA_ACT_FLAGS_BIND; bool bind = flags & TCA_ACT_FLAGS_BIND;
struct nlattr *tb[TCA_SKBMOD_MAX + 1]; struct nlattr *tb[TCA_SKBMOD_MAX + 1];
...@@ -276,23 +275,6 @@ static int tcf_skbmod_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -276,23 +275,6 @@ static int tcf_skbmod_dump(struct sk_buff *skb, struct tc_action *a,
return -1; return -1;
} }
static int tcf_skbmod_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, skbmod_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tcf_skbmod_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, skbmod_net_id);
return tcf_idr_search(tn, a, index);
}
static struct tc_action_ops act_skbmod_ops = { static struct tc_action_ops act_skbmod_ops = {
.kind = "skbmod", .kind = "skbmod",
.id = TCA_ACT_SKBMOD, .id = TCA_ACT_SKBMOD,
...@@ -301,27 +283,25 @@ static struct tc_action_ops act_skbmod_ops = { ...@@ -301,27 +283,25 @@ static struct tc_action_ops act_skbmod_ops = {
.dump = tcf_skbmod_dump, .dump = tcf_skbmod_dump,
.init = tcf_skbmod_init, .init = tcf_skbmod_init,
.cleanup = tcf_skbmod_cleanup, .cleanup = tcf_skbmod_cleanup,
.walk = tcf_skbmod_walker,
.lookup = tcf_skbmod_search,
.size = sizeof(struct tcf_skbmod), .size = sizeof(struct tcf_skbmod),
}; };
static __net_init int skbmod_init_net(struct net *net) static __net_init int skbmod_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, skbmod_net_id); struct tc_action_net *tn = net_generic(net, act_skbmod_ops.net_id);
return tc_action_net_init(net, tn, &act_skbmod_ops); return tc_action_net_init(net, tn, &act_skbmod_ops);
} }
static void __net_exit skbmod_exit_net(struct list_head *net_list) static void __net_exit skbmod_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, skbmod_net_id); tc_action_net_exit(net_list, act_skbmod_ops.net_id);
} }
static struct pernet_operations skbmod_net_ops = { static struct pernet_operations skbmod_net_ops = {
.init = skbmod_init_net, .init = skbmod_init_net,
.exit_batch = skbmod_exit_net, .exit_batch = skbmod_exit_net,
.id = &skbmod_net_id, .id = &act_skbmod_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include <linux/tc_act/tc_tunnel_key.h> #include <linux/tc_act/tc_tunnel_key.h>
#include <net/tc_act/tc_tunnel_key.h> #include <net/tc_act/tc_tunnel_key.h>
static unsigned int tunnel_key_net_id;
static struct tc_action_ops act_tunnel_key_ops; static struct tc_action_ops act_tunnel_key_ops;
static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a, static int tunnel_key_act(struct sk_buff *skb, const struct tc_action *a,
...@@ -358,7 +357,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla, ...@@ -358,7 +357,7 @@ static int tunnel_key_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, u32 act_flags, struct tcf_proto *tp, u32 act_flags,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, tunnel_key_net_id); struct tc_action_net *tn = net_generic(net, act_tunnel_key_ops.net_id);
bool bind = act_flags & TCA_ACT_FLAGS_BIND; bool bind = act_flags & TCA_ACT_FLAGS_BIND;
struct nlattr *tb[TCA_TUNNEL_KEY_MAX + 1]; struct nlattr *tb[TCA_TUNNEL_KEY_MAX + 1];
struct tcf_tunnel_key_params *params_new; struct tcf_tunnel_key_params *params_new;
...@@ -770,23 +769,6 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -770,23 +769,6 @@ static int tunnel_key_dump(struct sk_buff *skb, struct tc_action *a,
return -1; return -1;
} }
static int tunnel_key_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, tunnel_key_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static int tunnel_key_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, tunnel_key_net_id);
return tcf_idr_search(tn, a, index);
}
static void tcf_tunnel_encap_put_tunnel(void *priv) static void tcf_tunnel_encap_put_tunnel(void *priv)
{ {
struct ip_tunnel_info *tunnel = priv; struct ip_tunnel_info *tunnel = priv;
...@@ -850,28 +832,26 @@ static struct tc_action_ops act_tunnel_key_ops = { ...@@ -850,28 +832,26 @@ static struct tc_action_ops act_tunnel_key_ops = {
.dump = tunnel_key_dump, .dump = tunnel_key_dump,
.init = tunnel_key_init, .init = tunnel_key_init,
.cleanup = tunnel_key_release, .cleanup = tunnel_key_release,
.walk = tunnel_key_walker,
.lookup = tunnel_key_search,
.offload_act_setup = tcf_tunnel_key_offload_act_setup, .offload_act_setup = tcf_tunnel_key_offload_act_setup,
.size = sizeof(struct tcf_tunnel_key), .size = sizeof(struct tcf_tunnel_key),
}; };
static __net_init int tunnel_key_init_net(struct net *net) static __net_init int tunnel_key_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, tunnel_key_net_id); struct tc_action_net *tn = net_generic(net, act_tunnel_key_ops.net_id);
return tc_action_net_init(net, tn, &act_tunnel_key_ops); return tc_action_net_init(net, tn, &act_tunnel_key_ops);
} }
static void __net_exit tunnel_key_exit_net(struct list_head *net_list) static void __net_exit tunnel_key_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, tunnel_key_net_id); tc_action_net_exit(net_list, act_tunnel_key_ops.net_id);
} }
static struct pernet_operations tunnel_key_net_ops = { static struct pernet_operations tunnel_key_net_ops = {
.init = tunnel_key_init_net, .init = tunnel_key_init_net,
.exit_batch = tunnel_key_exit_net, .exit_batch = tunnel_key_exit_net,
.id = &tunnel_key_net_id, .id = &act_tunnel_key_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
...@@ -16,7 +16,6 @@ ...@@ -16,7 +16,6 @@
#include <linux/tc_act/tc_vlan.h> #include <linux/tc_act/tc_vlan.h>
#include <net/tc_act/tc_vlan.h> #include <net/tc_act/tc_vlan.h>
static unsigned int vlan_net_id;
static struct tc_action_ops act_vlan_ops; static struct tc_action_ops act_vlan_ops;
static int tcf_vlan_act(struct sk_buff *skb, const struct tc_action *a, static int tcf_vlan_act(struct sk_buff *skb, const struct tc_action *a,
...@@ -117,7 +116,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla, ...@@ -117,7 +116,7 @@ static int tcf_vlan_init(struct net *net, struct nlattr *nla,
struct tcf_proto *tp, u32 flags, struct tcf_proto *tp, u32 flags,
struct netlink_ext_ack *extack) struct netlink_ext_ack *extack)
{ {
struct tc_action_net *tn = net_generic(net, vlan_net_id); struct tc_action_net *tn = net_generic(net, act_vlan_ops.net_id);
bool bind = flags & TCA_ACT_FLAGS_BIND; bool bind = flags & TCA_ACT_FLAGS_BIND;
struct nlattr *tb[TCA_VLAN_MAX + 1]; struct nlattr *tb[TCA_VLAN_MAX + 1];
struct tcf_chain *goto_ch = NULL; struct tcf_chain *goto_ch = NULL;
...@@ -333,16 +332,6 @@ static int tcf_vlan_dump(struct sk_buff *skb, struct tc_action *a, ...@@ -333,16 +332,6 @@ static int tcf_vlan_dump(struct sk_buff *skb, struct tc_action *a,
return -1; return -1;
} }
static int tcf_vlan_walker(struct net *net, struct sk_buff *skb,
struct netlink_callback *cb, int type,
const struct tc_action_ops *ops,
struct netlink_ext_ack *extack)
{
struct tc_action_net *tn = net_generic(net, vlan_net_id);
return tcf_generic_walker(tn, skb, cb, type, ops, extack);
}
static void tcf_vlan_stats_update(struct tc_action *a, u64 bytes, u64 packets, static void tcf_vlan_stats_update(struct tc_action *a, u64 bytes, u64 packets,
u64 drops, u64 lastuse, bool hw) u64 drops, u64 lastuse, bool hw)
{ {
...@@ -353,13 +342,6 @@ static void tcf_vlan_stats_update(struct tc_action *a, u64 bytes, u64 packets, ...@@ -353,13 +342,6 @@ static void tcf_vlan_stats_update(struct tc_action *a, u64 bytes, u64 packets,
tm->lastuse = max_t(u64, tm->lastuse, lastuse); tm->lastuse = max_t(u64, tm->lastuse, lastuse);
} }
static int tcf_vlan_search(struct net *net, struct tc_action **a, u32 index)
{
struct tc_action_net *tn = net_generic(net, vlan_net_id);
return tcf_idr_search(tn, a, index);
}
static size_t tcf_vlan_get_fill_size(const struct tc_action *act) static size_t tcf_vlan_get_fill_size(const struct tc_action *act)
{ {
return nla_total_size(sizeof(struct tc_vlan)) return nla_total_size(sizeof(struct tc_vlan))
...@@ -438,30 +420,28 @@ static struct tc_action_ops act_vlan_ops = { ...@@ -438,30 +420,28 @@ static struct tc_action_ops act_vlan_ops = {
.dump = tcf_vlan_dump, .dump = tcf_vlan_dump,
.init = tcf_vlan_init, .init = tcf_vlan_init,
.cleanup = tcf_vlan_cleanup, .cleanup = tcf_vlan_cleanup,
.walk = tcf_vlan_walker,
.stats_update = tcf_vlan_stats_update, .stats_update = tcf_vlan_stats_update,
.get_fill_size = tcf_vlan_get_fill_size, .get_fill_size = tcf_vlan_get_fill_size,
.lookup = tcf_vlan_search,
.offload_act_setup = tcf_vlan_offload_act_setup, .offload_act_setup = tcf_vlan_offload_act_setup,
.size = sizeof(struct tcf_vlan), .size = sizeof(struct tcf_vlan),
}; };
static __net_init int vlan_init_net(struct net *net) static __net_init int vlan_init_net(struct net *net)
{ {
struct tc_action_net *tn = net_generic(net, vlan_net_id); struct tc_action_net *tn = net_generic(net, act_vlan_ops.net_id);
return tc_action_net_init(net, tn, &act_vlan_ops); return tc_action_net_init(net, tn, &act_vlan_ops);
} }
static void __net_exit vlan_exit_net(struct list_head *net_list) static void __net_exit vlan_exit_net(struct list_head *net_list)
{ {
tc_action_net_exit(net_list, vlan_net_id); tc_action_net_exit(net_list, act_vlan_ops.net_id);
} }
static struct pernet_operations vlan_net_ops = { static struct pernet_operations vlan_net_ops = {
.init = vlan_init_net, .init = vlan_init_net,
.exit_batch = vlan_exit_net, .exit_batch = vlan_exit_net,
.id = &vlan_net_id, .id = &act_vlan_ops.net_id,
.size = sizeof(struct tc_action_net), .size = sizeof(struct tc_action_net),
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment