@@ -38,7 +38,7 @@ struct tcf_police {
38
38
bool peak_present ;
39
39
};
40
40
#define to_police (pc ) \
41
- container_of(pc, struct tcf_police, common)
41
+ container_of(pc->priv , struct tcf_police, common)
42
42
43
43
#define POL_TAB_MASK 15
44
44
@@ -119,14 +119,12 @@ static int tcf_act_police_locate(struct net *net, struct nlattr *nla,
119
119
struct nlattr * est , struct tc_action * a ,
120
120
int ovr , int bind )
121
121
{
122
- unsigned int h ;
123
122
int ret = 0 , err ;
124
123
struct nlattr * tb [TCA_POLICE_MAX + 1 ];
125
124
struct tc_police * parm ;
126
125
struct tcf_police * police ;
127
126
struct qdisc_rate_table * R_tab = NULL , * P_tab = NULL ;
128
127
struct tc_action_net * tn = net_generic (net , police_net_id );
129
- struct tcf_hashinfo * hinfo = tn -> hinfo ;
130
128
int size ;
131
129
132
130
if (nla == NULL )
@@ -145,7 +143,7 @@ static int tcf_act_police_locate(struct net *net, struct nlattr *nla,
145
143
146
144
if (parm -> index ) {
147
145
if (tcf_hash_search (tn , a , parm -> index )) {
148
- police = to_police (a -> priv );
146
+ police = to_police (a );
149
147
if (bind ) {
150
148
police -> tcf_bindcnt += 1 ;
151
149
police -> tcf_refcnt += 1 ;
@@ -156,16 +154,15 @@ static int tcf_act_police_locate(struct net *net, struct nlattr *nla,
156
154
/* not replacing */
157
155
return - EEXIST ;
158
156
}
157
+ } else {
158
+ ret = tcf_hash_create (tn , parm -> index , NULL , a ,
159
+ sizeof (* police ), bind , false);
160
+ if (ret )
161
+ return ret ;
162
+ ret = ACT_P_CREATED ;
159
163
}
160
164
161
- police = kzalloc (sizeof (* police ), GFP_KERNEL );
162
- if (police == NULL )
163
- return - ENOMEM ;
164
- ret = ACT_P_CREATED ;
165
- police -> tcf_refcnt = 1 ;
166
- spin_lock_init (& police -> tcf_lock );
167
- if (bind )
168
- police -> tcf_bindcnt = 1 ;
165
+ police = to_police (a );
169
166
override :
170
167
if (parm -> rate .rate ) {
171
168
err = - ENOMEM ;
@@ -237,16 +234,8 @@ static int tcf_act_police_locate(struct net *net, struct nlattr *nla,
237
234
return ret ;
238
235
239
236
police -> tcfp_t_c = ktime_get_ns ();
240
- police -> tcf_index = parm -> index ? parm -> index :
241
- tcf_hash_new_index (tn );
242
- police -> tcf_tm .install = jiffies ;
243
- police -> tcf_tm .lastuse = jiffies ;
244
- h = tcf_hash (police -> tcf_index , POL_TAB_MASK );
245
- spin_lock_bh (& hinfo -> lock );
246
- hlist_add_head (& police -> tcf_head , & hinfo -> htab [h ]);
247
- spin_unlock_bh (& hinfo -> lock );
237
+ tcf_hash_insert (tn , a );
248
238
249
- a -> priv = police ;
250
239
return ret ;
251
240
252
241
failure_unlock :
@@ -255,7 +244,7 @@ static int tcf_act_police_locate(struct net *net, struct nlattr *nla,
255
244
qdisc_put_rtab (P_tab );
256
245
qdisc_put_rtab (R_tab );
257
246
if (ret == ACT_P_CREATED )
258
- kfree ( police );
247
+ tcf_hash_cleanup ( a , est );
259
248
return err ;
260
249
}
261
250
0 commit comments