@@ -136,15 +136,15 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
136
136
{
137
137
struct tc_action_net * tn = net_generic (net , pedit_net_id );
138
138
struct nlattr * tb [TCA_PEDIT_MAX + 1 ];
139
- struct nlattr * pattr ;
140
- struct tc_pedit * parm ;
141
- int ret = 0 , err ;
142
- struct tcf_pedit * p ;
143
139
struct tc_pedit_key * keys = NULL ;
144
140
struct tcf_pedit_key_ex * keys_ex ;
141
+ struct tc_pedit * parm ;
142
+ struct nlattr * pattr ;
143
+ struct tcf_pedit * p ;
144
+ int ret = 0 , err ;
145
145
int ksize ;
146
146
147
- if (nla == NULL )
147
+ if (! nla )
148
148
return - EINVAL ;
149
149
150
150
err = nla_parse_nested (tb , TCA_PEDIT_MAX , nla , pedit_policy , NULL );
@@ -175,7 +175,7 @@ static int tcf_pedit_init(struct net *net, struct nlattr *nla,
175
175
return ret ;
176
176
p = to_pedit (* a );
177
177
keys = kmalloc (ksize , GFP_KERNEL );
178
- if (keys == NULL ) {
178
+ if (! keys ) {
179
179
tcf_idr_release (* a , bind );
180
180
kfree (keys_ex );
181
181
return - ENOMEM ;
@@ -220,6 +220,7 @@ static void tcf_pedit_cleanup(struct tc_action *a)
220
220
{
221
221
struct tcf_pedit * p = to_pedit (a );
222
222
struct tc_pedit_key * keys = p -> tcfp_keys ;
223
+
223
224
kfree (keys );
224
225
kfree (p -> tcfp_keys_ex );
225
226
}
@@ -284,11 +285,12 @@ static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a,
284
285
if (p -> tcfp_nkeys > 0 ) {
285
286
struct tc_pedit_key * tkey = p -> tcfp_keys ;
286
287
struct tcf_pedit_key_ex * tkey_ex = p -> tcfp_keys_ex ;
287
- enum pedit_header_type htype = TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK ;
288
+ enum pedit_header_type htype =
289
+ TCA_PEDIT_KEY_EX_HDR_TYPE_NETWORK ;
288
290
enum pedit_cmd cmd = TCA_PEDIT_KEY_EX_CMD_SET ;
289
291
290
292
for (i = p -> tcfp_nkeys ; i > 0 ; i -- , tkey ++ ) {
291
- u32 * ptr , _data ;
293
+ u32 * ptr , hdata ;
292
294
int offset = tkey -> off ;
293
295
int hoffset ;
294
296
u32 val ;
@@ -303,39 +305,39 @@ static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a,
303
305
304
306
rc = pedit_skb_hdr_offset (skb , htype , & hoffset );
305
307
if (rc ) {
306
- pr_info ("tc filter pedit bad header type specified (0x%x)\n" ,
308
+ pr_info ("tc action pedit bad header type specified (0x%x)\n" ,
307
309
htype );
308
310
goto bad ;
309
311
}
310
312
311
313
if (tkey -> offmask ) {
312
- char * d , _d ;
314
+ u8 * d , _d ;
313
315
314
316
if (!offset_valid (skb , hoffset + tkey -> at )) {
315
- pr_info ("tc filter pedit 'at' offset %d out of bounds\n" ,
317
+ pr_info ("tc action pedit 'at' offset %d out of bounds\n" ,
316
318
hoffset + tkey -> at );
317
319
goto bad ;
318
320
}
319
- d = skb_header_pointer (skb , hoffset + tkey -> at , 1 ,
320
- & _d );
321
+ d = skb_header_pointer (skb , hoffset + tkey -> at ,
322
+ sizeof ( _d ), & _d );
321
323
if (!d )
322
324
goto bad ;
323
325
offset += (* d & tkey -> offmask ) >> tkey -> shift ;
324
326
}
325
327
326
328
if (offset % 4 ) {
327
- pr_info ("tc filter pedit"
328
- " offset must be on 32 bit boundaries\n" );
329
+ pr_info ("tc action pedit offset must be on 32 bit boundaries\n" );
329
330
goto bad ;
330
331
}
331
332
332
333
if (!offset_valid (skb , hoffset + offset )) {
333
- pr_info ("tc filter pedit offset %d out of bounds\n" ,
334
+ pr_info ("tc action pedit offset %d out of bounds\n" ,
334
335
hoffset + offset );
335
336
goto bad ;
336
337
}
337
338
338
- ptr = skb_header_pointer (skb , hoffset + offset , 4 , & _data );
339
+ ptr = skb_header_pointer (skb , hoffset + offset ,
340
+ sizeof (hdata ), & hdata );
339
341
if (!ptr )
340
342
goto bad ;
341
343
/* just do it, baby */
@@ -347,19 +349,20 @@ static int tcf_pedit(struct sk_buff *skb, const struct tc_action *a,
347
349
val = (* ptr + tkey -> val ) & ~tkey -> mask ;
348
350
break ;
349
351
default :
350
- pr_info ("tc filter pedit bad command (%d)\n" ,
352
+ pr_info ("tc action pedit bad command (%d)\n" ,
351
353
cmd );
352
354
goto bad ;
353
355
}
354
356
355
357
* ptr = ((* ptr & tkey -> mask ) ^ val );
356
- if (ptr == & _data )
358
+ if (ptr == & hdata )
357
359
skb_store_bits (skb , hoffset + offset , ptr , 4 );
358
360
}
359
361
360
362
goto done ;
361
- } else
363
+ } else {
362
364
WARN (1 , "pedit BUG: index %d\n" , p -> tcf_index );
365
+ }
363
366
364
367
bad :
365
368
p -> tcf_qstats .overlimits ++ ;
0 commit comments