diff options
Diffstat (limited to 'net/sched/act_simple.c')
-rw-r--r-- | net/sched/act_simple.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/net/sched/act_simple.c b/net/sched/act_simple.c index 318328d34d12..289af6f9bb3b 100644 --- a/net/sched/act_simple.c +++ b/net/sched/act_simple.c | |||
@@ -27,12 +27,13 @@ | |||
27 | #define SIMP_TAB_MASK 7 | 27 | #define SIMP_TAB_MASK 7 |
28 | 28 | ||
29 | static int simp_net_id; | 29 | static int simp_net_id; |
30 | static struct tc_action_ops act_simp_ops; | ||
30 | 31 | ||
31 | #define SIMP_MAX_DATA 32 | 32 | #define SIMP_MAX_DATA 32 |
32 | static int tcf_simp(struct sk_buff *skb, const struct tc_action *a, | 33 | static int tcf_simp(struct sk_buff *skb, const struct tc_action *a, |
33 | struct tcf_result *res) | 34 | struct tcf_result *res) |
34 | { | 35 | { |
35 | struct tcf_defact *d = a->priv; | 36 | struct tcf_defact *d = to_defact(a); |
36 | 37 | ||
37 | spin_lock(&d->tcf_lock); | 38 | spin_lock(&d->tcf_lock); |
38 | tcf_lastuse_update(&d->tcf_tm); | 39 | tcf_lastuse_update(&d->tcf_tm); |
@@ -79,7 +80,7 @@ static const struct nla_policy simple_policy[TCA_DEF_MAX + 1] = { | |||
79 | }; | 80 | }; |
80 | 81 | ||
81 | static int tcf_simp_init(struct net *net, struct nlattr *nla, | 82 | static int tcf_simp_init(struct net *net, struct nlattr *nla, |
82 | struct nlattr *est, struct tc_action *a, | 83 | struct nlattr *est, struct tc_action **a, |
83 | int ovr, int bind) | 84 | int ovr, int bind) |
84 | { | 85 | { |
85 | struct tc_action_net *tn = net_generic(net, simp_net_id); | 86 | struct tc_action_net *tn = net_generic(net, simp_net_id); |
@@ -100,7 +101,6 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, | |||
100 | if (tb[TCA_DEF_PARMS] == NULL) | 101 | if (tb[TCA_DEF_PARMS] == NULL) |
101 | return -EINVAL; | 102 | return -EINVAL; |
102 | 103 | ||
103 | |||
104 | parm = nla_data(tb[TCA_DEF_PARMS]); | 104 | parm = nla_data(tb[TCA_DEF_PARMS]); |
105 | exists = tcf_hash_check(tn, parm->index, a, bind); | 105 | exists = tcf_hash_check(tn, parm->index, a, bind); |
106 | if (exists && bind) | 106 | if (exists && bind) |
@@ -108,7 +108,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, | |||
108 | 108 | ||
109 | if (tb[TCA_DEF_DATA] == NULL) { | 109 | if (tb[TCA_DEF_DATA] == NULL) { |
110 | if (exists) | 110 | if (exists) |
111 | tcf_hash_release(a, bind); | 111 | tcf_hash_release(*a, bind); |
112 | return -EINVAL; | 112 | return -EINVAL; |
113 | } | 113 | } |
114 | 114 | ||
@@ -116,22 +116,22 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, | |||
116 | 116 | ||
117 | if (!exists) { | 117 | if (!exists) { |
118 | ret = tcf_hash_create(tn, parm->index, est, a, | 118 | ret = tcf_hash_create(tn, parm->index, est, a, |
119 | sizeof(*d), bind, false); | 119 | &act_simp_ops, bind, false); |
120 | if (ret) | 120 | if (ret) |
121 | return ret; | 121 | return ret; |
122 | 122 | ||
123 | d = to_defact(a); | 123 | d = to_defact(*a); |
124 | ret = alloc_defdata(d, defdata); | 124 | ret = alloc_defdata(d, defdata); |
125 | if (ret < 0) { | 125 | if (ret < 0) { |
126 | tcf_hash_cleanup(a, est); | 126 | tcf_hash_cleanup(*a, est); |
127 | return ret; | 127 | return ret; |
128 | } | 128 | } |
129 | d->tcf_action = parm->action; | 129 | d->tcf_action = parm->action; |
130 | ret = ACT_P_CREATED; | 130 | ret = ACT_P_CREATED; |
131 | } else { | 131 | } else { |
132 | d = to_defact(a); | 132 | d = to_defact(*a); |
133 | 133 | ||
134 | tcf_hash_release(a, bind); | 134 | tcf_hash_release(*a, bind); |
135 | if (!ovr) | 135 | if (!ovr) |
136 | return -EEXIST; | 136 | return -EEXIST; |
137 | 137 | ||
@@ -139,7 +139,7 @@ static int tcf_simp_init(struct net *net, struct nlattr *nla, | |||
139 | } | 139 | } |
140 | 140 | ||
141 | if (ret == ACT_P_CREATED) | 141 | if (ret == ACT_P_CREATED) |
142 | tcf_hash_insert(tn, a); | 142 | tcf_hash_insert(tn, *a); |
143 | return ret; | 143 | return ret; |
144 | } | 144 | } |
145 | 145 | ||
@@ -147,7 +147,7 @@ static int tcf_simp_dump(struct sk_buff *skb, struct tc_action *a, | |||
147 | int bind, int ref) | 147 | int bind, int ref) |
148 | { | 148 | { |
149 | unsigned char *b = skb_tail_pointer(skb); | 149 | unsigned char *b = skb_tail_pointer(skb); |
150 | struct tcf_defact *d = a->priv; | 150 | struct tcf_defact *d = to_defact(a); |
151 | struct tc_defact opt = { | 151 | struct tc_defact opt = { |
152 | .index = d->tcf_index, | 152 | .index = d->tcf_index, |
153 | .refcnt = d->tcf_refcnt - ref, | 153 | .refcnt = d->tcf_refcnt - ref, |
@@ -172,14 +172,14 @@ nla_put_failure: | |||
172 | 172 | ||
173 | static int tcf_simp_walker(struct net *net, struct sk_buff *skb, | 173 | static int tcf_simp_walker(struct net *net, struct sk_buff *skb, |
174 | struct netlink_callback *cb, int type, | 174 | struct netlink_callback *cb, int type, |
175 | struct tc_action *a) | 175 | const struct tc_action_ops *ops) |
176 | { | 176 | { |
177 | struct tc_action_net *tn = net_generic(net, simp_net_id); | 177 | struct tc_action_net *tn = net_generic(net, simp_net_id); |
178 | 178 | ||
179 | return tcf_generic_walker(tn, skb, cb, type, a); | 179 | return tcf_generic_walker(tn, skb, cb, type, ops); |
180 | } | 180 | } |
181 | 181 | ||
182 | static int tcf_simp_search(struct net *net, struct tc_action *a, u32 index) | 182 | static int tcf_simp_search(struct net *net, struct tc_action **a, u32 index) |
183 | { | 183 | { |
184 | struct tc_action_net *tn = net_generic(net, simp_net_id); | 184 | struct tc_action_net *tn = net_generic(net, simp_net_id); |
185 | 185 | ||
@@ -196,6 +196,7 @@ static struct tc_action_ops act_simp_ops = { | |||
196 | .init = tcf_simp_init, | 196 | .init = tcf_simp_init, |
197 | .walk = tcf_simp_walker, | 197 | .walk = tcf_simp_walker, |
198 | .lookup = tcf_simp_search, | 198 | .lookup = tcf_simp_search, |
199 | .size = sizeof(struct tcf_defact), | ||
199 | }; | 200 | }; |
200 | 201 | ||
201 | static __net_init int simp_init_net(struct net *net) | 202 | static __net_init int simp_init_net(struct net *net) |