@@ -130,6 +130,7 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
130
130
struct flow_dissector_key_tags * key_tags ;
131
131
struct flow_dissector_key_keyid * key_keyid ;
132
132
u8 ip_proto = 0 ;
133
+ bool ret = false;
133
134
134
135
if (!data ) {
135
136
data = skb -> data ;
@@ -171,7 +172,7 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
171
172
ip :
172
173
iph = __skb_header_pointer (skb , nhoff , sizeof (_iph ), data , hlen , & _iph );
173
174
if (!iph || iph -> ihl < 5 )
174
- return false ;
175
+ goto out_bad ;
175
176
nhoff += iph -> ihl * 4 ;
176
177
177
178
ip_proto = iph -> protocol ;
@@ -197,7 +198,7 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
197
198
ipv6 :
198
199
iph = __skb_header_pointer (skb , nhoff , sizeof (_iph ), data , hlen , & _iph );
199
200
if (!iph )
200
- return false ;
201
+ goto out_bad ;
201
202
202
203
ip_proto = iph -> nexthdr ;
203
204
nhoff += sizeof (struct ipv6hdr );
@@ -234,7 +235,7 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
234
235
235
236
vlan = __skb_header_pointer (skb , nhoff , sizeof (_vlan ), data , hlen , & _vlan );
236
237
if (!vlan )
237
- return false ;
238
+ goto out_bad ;
238
239
239
240
if (skb_flow_dissector_uses_key (flow_dissector ,
240
241
FLOW_DISSECTOR_KEY_VLANID )) {
@@ -256,7 +257,7 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
256
257
} * hdr , _hdr ;
257
258
hdr = __skb_header_pointer (skb , nhoff , sizeof (_hdr ), data , hlen , & _hdr );
258
259
if (!hdr )
259
- return false ;
260
+ goto out_bad ;
260
261
proto = hdr -> proto ;
261
262
nhoff += PPPOE_SES_HLEN ;
262
263
switch (proto ) {
@@ -265,7 +266,7 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
265
266
case htons (PPP_IPV6 ):
266
267
goto ipv6 ;
267
268
default :
268
- return false ;
269
+ goto out_bad ;
269
270
}
270
271
}
271
272
case htons (ETH_P_TIPC ): {
@@ -275,9 +276,7 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
275
276
} * hdr , _hdr ;
276
277
hdr = __skb_header_pointer (skb , nhoff , sizeof (_hdr ), data , hlen , & _hdr );
277
278
if (!hdr )
278
- return false;
279
- key_basic -> n_proto = proto ;
280
- key_control -> thoff = (u16 )nhoff ;
279
+ goto out_bad ;
281
280
282
281
if (skb_flow_dissector_uses_key (flow_dissector ,
283
282
FLOW_DISSECTOR_KEY_TIPC_ADDRS )) {
@@ -287,7 +286,7 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
287
286
key_addrs -> tipcaddrs .srcnode = hdr -> srcnode ;
288
287
key_control -> addr_type = FLOW_DISSECTOR_KEY_TIPC_ADDRS ;
289
288
}
290
- return true ;
289
+ goto out_good ;
291
290
}
292
291
293
292
case htons (ETH_P_MPLS_UC ):
@@ -297,7 +296,7 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
297
296
hdr = __skb_header_pointer (skb , nhoff , sizeof (_hdr ), data ,
298
297
hlen , & _hdr );
299
298
if (!hdr )
300
- return false ;
299
+ goto out_bad ;
301
300
302
301
if ((ntohl (hdr [0 ].entry ) & MPLS_LS_LABEL_MASK ) >>
303
302
MPLS_LS_LABEL_SHIFT == MPLS_LABEL_ENTROPY ) {
@@ -310,21 +309,17 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
310
309
htonl (MPLS_LS_LABEL_MASK );
311
310
}
312
311
313
- key_basic -> n_proto = proto ;
314
- key_basic -> ip_proto = ip_proto ;
315
- key_control -> thoff = (u16 )nhoff ;
316
-
317
- return true;
312
+ goto out_good ;
318
313
}
319
314
320
- return true ;
315
+ goto out_good ;
321
316
}
322
317
323
318
case htons (ETH_P_FCOE ):
324
319
key_control -> thoff = (u16 )(nhoff + FCOE_HEADER_LEN );
325
320
/* fall through */
326
321
default :
327
- return false ;
322
+ goto out_bad ;
328
323
}
329
324
330
325
ip_proto_again :
@@ -337,7 +332,7 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
337
332
338
333
hdr = __skb_header_pointer (skb , nhoff , sizeof (_hdr ), data , hlen , & _hdr );
339
334
if (!hdr )
340
- return false ;
335
+ goto out_bad ;
341
336
/*
342
337
* Only look inside GRE if version zero and no
343
338
* routing
@@ -357,7 +352,7 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
357
352
data , hlen , & _keyid );
358
353
359
354
if (!keyid )
360
- return false ;
355
+ goto out_bad ;
361
356
362
357
if (skb_flow_dissector_uses_key (flow_dissector ,
363
358
FLOW_DISSECTOR_KEY_GRE_KEYID )) {
@@ -378,7 +373,7 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
378
373
sizeof (_eth ),
379
374
data , hlen , & _eth );
380
375
if (!eth )
381
- return false ;
376
+ goto out_bad ;
382
377
proto = eth -> h_proto ;
383
378
nhoff += sizeof (* eth );
384
379
}
@@ -395,7 +390,7 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
395
390
opthdr = __skb_header_pointer (skb , nhoff , sizeof (_opthdr ),
396
391
data , hlen , & _opthdr );
397
392
if (!opthdr )
398
- return false ;
393
+ goto out_bad ;
399
394
400
395
ip_proto = opthdr [0 ];
401
396
nhoff += (opthdr [1 ] + 1 ) << 3 ;
@@ -415,10 +410,6 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
415
410
break ;
416
411
}
417
412
418
- key_basic -> n_proto = proto ;
419
- key_basic -> ip_proto = ip_proto ;
420
- key_control -> thoff = (u16 )nhoff ;
421
-
422
413
if (skb_flow_dissector_uses_key (flow_dissector ,
423
414
FLOW_DISSECTOR_KEY_PORTS )) {
424
415
key_ports = skb_flow_dissector_target (flow_dissector ,
@@ -428,7 +419,15 @@ bool __skb_flow_dissect(const struct sk_buff *skb,
428
419
data , hlen );
429
420
}
430
421
431
- return true;
422
+ out_good :
423
+ ret = true;
424
+
425
+ out_bad :
426
+ key_basic -> n_proto = proto ;
427
+ key_basic -> ip_proto = ip_proto ;
428
+ key_control -> thoff = (u16 )nhoff ;
429
+
430
+ return ret ;
432
431
}
433
432
EXPORT_SYMBOL (__skb_flow_dissect );
434
433
0 commit comments