diff options
Diffstat (limited to 'net/sched/act_gact.c')
-rw-r--r-- | net/sched/act_gact.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/net/sched/act_gact.c b/net/sched/act_gact.c index 19058a7f3e5c..e24a4093d6f6 100644 --- a/net/sched/act_gact.c +++ b/net/sched/act_gact.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #define GACT_TAB_MASK 15 | 26 | #define GACT_TAB_MASK 15 |
27 | 27 | ||
28 | static int gact_net_id; | 28 | static int gact_net_id; |
29 | static struct tc_action_ops act_gact_ops; | ||
29 | 30 | ||
30 | #ifdef CONFIG_GACT_PROB | 31 | #ifdef CONFIG_GACT_PROB |
31 | static int gact_net_rand(struct tcf_gact *gact) | 32 | static int gact_net_rand(struct tcf_gact *gact) |
@@ -56,7 +57,7 @@ static const struct nla_policy gact_policy[TCA_GACT_MAX + 1] = { | |||
56 | }; | 57 | }; |
57 | 58 | ||
58 | static int tcf_gact_init(struct net *net, struct nlattr *nla, | 59 | static int tcf_gact_init(struct net *net, struct nlattr *nla, |
59 | struct nlattr *est, struct tc_action *a, | 60 | struct nlattr *est, struct tc_action **a, |
60 | int ovr, int bind) | 61 | int ovr, int bind) |
61 | { | 62 | { |
62 | struct tc_action_net *tn = net_generic(net, gact_net_id); | 63 | struct tc_action_net *tn = net_generic(net, gact_net_id); |
@@ -93,19 +94,19 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla, | |||
93 | 94 | ||
94 | if (!tcf_hash_check(tn, parm->index, a, bind)) { | 95 | if (!tcf_hash_check(tn, parm->index, a, bind)) { |
95 | ret = tcf_hash_create(tn, parm->index, est, a, | 96 | ret = tcf_hash_create(tn, parm->index, est, a, |
96 | sizeof(*gact), bind, true); | 97 | &act_gact_ops, bind, true); |
97 | if (ret) | 98 | if (ret) |
98 | return ret; | 99 | return ret; |
99 | ret = ACT_P_CREATED; | 100 | ret = ACT_P_CREATED; |
100 | } else { | 101 | } else { |
101 | if (bind)/* dont override defaults */ | 102 | if (bind)/* dont override defaults */ |
102 | return 0; | 103 | return 0; |
103 | tcf_hash_release(a, bind); | 104 | tcf_hash_release(*a, bind); |
104 | if (!ovr) | 105 | if (!ovr) |
105 | return -EEXIST; | 106 | return -EEXIST; |
106 | } | 107 | } |
107 | 108 | ||
108 | gact = to_gact(a); | 109 | gact = to_gact(*a); |
109 | 110 | ||
110 | ASSERT_RTNL(); | 111 | ASSERT_RTNL(); |
111 | gact->tcf_action = parm->action; | 112 | gact->tcf_action = parm->action; |
@@ -121,14 +122,14 @@ static int tcf_gact_init(struct net *net, struct nlattr *nla, | |||
121 | } | 122 | } |
122 | #endif | 123 | #endif |
123 | if (ret == ACT_P_CREATED) | 124 | if (ret == ACT_P_CREATED) |
124 | tcf_hash_insert(tn, a); | 125 | tcf_hash_insert(tn, *a); |
125 | return ret; | 126 | return ret; |
126 | } | 127 | } |
127 | 128 | ||
128 | static int tcf_gact(struct sk_buff *skb, const struct tc_action *a, | 129 | static int tcf_gact(struct sk_buff *skb, const struct tc_action *a, |
129 | struct tcf_result *res) | 130 | struct tcf_result *res) |
130 | { | 131 | { |
131 | struct tcf_gact *gact = a->priv; | 132 | struct tcf_gact *gact = to_gact(a); |
132 | int action = READ_ONCE(gact->tcf_action); | 133 | int action = READ_ONCE(gact->tcf_action); |
133 | 134 | ||
134 | #ifdef CONFIG_GACT_PROB | 135 | #ifdef CONFIG_GACT_PROB |
@@ -151,7 +152,7 @@ static int tcf_gact(struct sk_buff *skb, const struct tc_action *a, | |||
151 | static void tcf_gact_stats_update(struct tc_action *a, u64 bytes, u32 packets, | 152 | static void tcf_gact_stats_update(struct tc_action *a, u64 bytes, u32 packets, |
152 | u64 lastuse) | 153 | u64 lastuse) |
153 | { | 154 | { |
154 | struct tcf_gact *gact = a->priv; | 155 | struct tcf_gact *gact = to_gact(a); |
155 | int action = READ_ONCE(gact->tcf_action); | 156 | int action = READ_ONCE(gact->tcf_action); |
156 | struct tcf_t *tm = &gact->tcf_tm; | 157 | struct tcf_t *tm = &gact->tcf_tm; |
157 | 158 | ||
@@ -166,7 +167,7 @@ static int tcf_gact_dump(struct sk_buff *skb, struct tc_action *a, | |||
166 | int bind, int ref) | 167 | int bind, int ref) |
167 | { | 168 | { |
168 | unsigned char *b = skb_tail_pointer(skb); | 169 | unsigned char *b = skb_tail_pointer(skb); |
169 | struct tcf_gact *gact = a->priv; | 170 | struct tcf_gact *gact = to_gact(a); |
170 | struct tc_gact opt = { | 171 | struct tc_gact opt = { |
171 | .index = gact->tcf_index, | 172 | .index = gact->tcf_index, |
172 | .refcnt = gact->tcf_refcnt - ref, | 173 | .refcnt = gact->tcf_refcnt - ref, |
@@ -201,14 +202,14 @@ nla_put_failure: | |||
201 | 202 | ||
202 | static int tcf_gact_walker(struct net *net, struct sk_buff *skb, | 203 | static int tcf_gact_walker(struct net *net, struct sk_buff *skb, |
203 | struct netlink_callback *cb, int type, | 204 | struct netlink_callback *cb, int type, |
204 | struct tc_action *a) | 205 | const struct tc_action_ops *ops) |
205 | { | 206 | { |
206 | struct tc_action_net *tn = net_generic(net, gact_net_id); | 207 | struct tc_action_net *tn = net_generic(net, gact_net_id); |
207 | 208 | ||
208 | return tcf_generic_walker(tn, skb, cb, type, a); | 209 | return tcf_generic_walker(tn, skb, cb, type, ops); |
209 | } | 210 | } |
210 | 211 | ||
211 | static int tcf_gact_search(struct net *net, struct tc_action *a, u32 index) | 212 | static int tcf_gact_search(struct net *net, struct tc_action **a, u32 index) |
212 | { | 213 | { |
213 | struct tc_action_net *tn = net_generic(net, gact_net_id); | 214 | struct tc_action_net *tn = net_generic(net, gact_net_id); |
214 | 215 | ||
@@ -225,6 +226,7 @@ static struct tc_action_ops act_gact_ops = { | |||
225 | .init = tcf_gact_init, | 226 | .init = tcf_gact_init, |
226 | .walk = tcf_gact_walker, | 227 | .walk = tcf_gact_walker, |
227 | .lookup = tcf_gact_search, | 228 | .lookup = tcf_gact_search, |
229 | .size = sizeof(struct tcf_gact), | ||
228 | }; | 230 | }; |
229 | 231 | ||
230 | static __net_init int gact_init_net(struct net *net) | 232 | static __net_init int gact_init_net(struct net *net) |