@@ -280,6 +280,7 @@ static const struct tlvtype_proc tlvprocdestopt_lst[] = {
280
280
281
281
static int ipv6_destopt_rcv (struct sk_buff * skb )
282
282
{
283
+ struct inet6_dev * idev = __in6_dev_get (skb -> dev );
283
284
struct inet6_skb_parm * opt = IP6CB (skb );
284
285
#if IS_ENABLED (CONFIG_IPV6_MIP6 )
285
286
__u16 dstbuf ;
@@ -291,7 +292,7 @@ static int ipv6_destopt_rcv(struct sk_buff *skb)
291
292
if (!pskb_may_pull (skb , skb_transport_offset (skb ) + 8 ) ||
292
293
!pskb_may_pull (skb , (skb_transport_offset (skb ) +
293
294
((skb_transport_header (skb )[1 ] + 1 ) << 3 )))) {
294
- __IP6_INC_STATS (dev_net (dst -> dev ), ip6_dst_idev ( dst ) ,
295
+ __IP6_INC_STATS (dev_net (dst -> dev ), idev ,
295
296
IPSTATS_MIB_INHDRERRORS );
296
297
fail_and_free :
297
298
kfree_skb (skb );
@@ -319,8 +320,7 @@ static int ipv6_destopt_rcv(struct sk_buff *skb)
319
320
return 1 ;
320
321
}
321
322
322
- __IP6_INC_STATS (dev_net (dst -> dev ),
323
- ip6_dst_idev (dst ), IPSTATS_MIB_INHDRERRORS );
323
+ __IP6_INC_STATS (net , idev , IPSTATS_MIB_INHDRERRORS );
324
324
return -1 ;
325
325
}
326
326
@@ -416,8 +416,7 @@ static int ipv6_srh_rcv(struct sk_buff *skb)
416
416
}
417
417
418
418
if (hdr -> segments_left >= (hdr -> hdrlen >> 1 )) {
419
- __IP6_INC_STATS (net , ip6_dst_idev (skb_dst (skb )),
420
- IPSTATS_MIB_INHDRERRORS );
419
+ __IP6_INC_STATS (net , idev , IPSTATS_MIB_INHDRERRORS );
421
420
icmpv6_param_prob (skb , ICMPV6_HDR_FIELD ,
422
421
((& hdr -> segments_left ) -
423
422
skb_network_header (skb )));
@@ -456,8 +455,7 @@ static int ipv6_srh_rcv(struct sk_buff *skb)
456
455
457
456
if (skb_dst (skb )-> dev -> flags & IFF_LOOPBACK ) {
458
457
if (ipv6_hdr (skb )-> hop_limit <= 1 ) {
459
- __IP6_INC_STATS (net , ip6_dst_idev (skb_dst (skb )),
460
- IPSTATS_MIB_INHDRERRORS );
458
+ __IP6_INC_STATS (net , idev , IPSTATS_MIB_INHDRERRORS );
461
459
icmpv6_send (skb , ICMPV6_TIME_EXCEED ,
462
460
ICMPV6_EXC_HOPLIMIT , 0 );
463
461
kfree_skb (skb );
@@ -481,10 +479,10 @@ static int ipv6_srh_rcv(struct sk_buff *skb)
481
479
/* called with rcu_read_lock() */
482
480
static int ipv6_rthdr_rcv (struct sk_buff * skb )
483
481
{
482
+ struct inet6_dev * idev = __in6_dev_get (skb -> dev );
484
483
struct inet6_skb_parm * opt = IP6CB (skb );
485
484
struct in6_addr * addr = NULL ;
486
485
struct in6_addr daddr ;
487
- struct inet6_dev * idev ;
488
486
int n , i ;
489
487
struct ipv6_rt_hdr * hdr ;
490
488
struct rt0_hdr * rthdr ;
@@ -498,8 +496,7 @@ static int ipv6_rthdr_rcv(struct sk_buff *skb)
498
496
if (!pskb_may_pull (skb , skb_transport_offset (skb ) + 8 ) ||
499
497
!pskb_may_pull (skb , (skb_transport_offset (skb ) +
500
498
((skb_transport_header (skb )[1 ] + 1 ) << 3 )))) {
501
- __IP6_INC_STATS (net , ip6_dst_idev (skb_dst (skb )),
502
- IPSTATS_MIB_INHDRERRORS );
499
+ __IP6_INC_STATS (net , idev , IPSTATS_MIB_INHDRERRORS );
503
500
kfree_skb (skb );
504
501
return -1 ;
505
502
}
@@ -508,8 +505,7 @@ static int ipv6_rthdr_rcv(struct sk_buff *skb)
508
505
509
506
if (ipv6_addr_is_multicast (& ipv6_hdr (skb )-> daddr ) ||
510
507
skb -> pkt_type != PACKET_HOST ) {
511
- __IP6_INC_STATS (net , ip6_dst_idev (skb_dst (skb )),
512
- IPSTATS_MIB_INADDRERRORS );
508
+ __IP6_INC_STATS (net , idev , IPSTATS_MIB_INADDRERRORS );
513
509
kfree_skb (skb );
514
510
return -1 ;
515
511
}
@@ -527,7 +523,7 @@ static int ipv6_rthdr_rcv(struct sk_buff *skb)
527
523
* processed by own
528
524
*/
529
525
if (!addr ) {
530
- __IP6_INC_STATS (net , ip6_dst_idev ( skb_dst ( skb )) ,
526
+ __IP6_INC_STATS (net , idev ,
531
527
IPSTATS_MIB_INADDRERRORS );
532
528
kfree_skb (skb );
533
529
return -1 ;
@@ -553,8 +549,7 @@ static int ipv6_rthdr_rcv(struct sk_buff *skb)
553
549
goto unknown_rh ;
554
550
/* Silently discard invalid RTH type 2 */
555
551
if (hdr -> hdrlen != 2 || hdr -> segments_left != 1 ) {
556
- __IP6_INC_STATS (net , ip6_dst_idev (skb_dst (skb )),
557
- IPSTATS_MIB_INHDRERRORS );
552
+ __IP6_INC_STATS (net , idev , IPSTATS_MIB_INHDRERRORS );
558
553
kfree_skb (skb );
559
554
return -1 ;
560
555
}
@@ -572,8 +567,7 @@ static int ipv6_rthdr_rcv(struct sk_buff *skb)
572
567
n = hdr -> hdrlen >> 1 ;
573
568
574
569
if (hdr -> segments_left > n ) {
575
- __IP6_INC_STATS (net , ip6_dst_idev (skb_dst (skb )),
576
- IPSTATS_MIB_INHDRERRORS );
570
+ __IP6_INC_STATS (net , idev , IPSTATS_MIB_INHDRERRORS );
577
571
icmpv6_param_prob (skb , ICMPV6_HDR_FIELD ,
578
572
((& hdr -> segments_left ) -
579
573
skb_network_header (skb )));
@@ -609,14 +603,12 @@ static int ipv6_rthdr_rcv(struct sk_buff *skb)
609
603
if (xfrm6_input_addr (skb , (xfrm_address_t * )addr ,
610
604
(xfrm_address_t * )& ipv6_hdr (skb )-> saddr ,
611
605
IPPROTO_ROUTING ) < 0 ) {
612
- __IP6_INC_STATS (net , ip6_dst_idev (skb_dst (skb )),
613
- IPSTATS_MIB_INADDRERRORS );
606
+ __IP6_INC_STATS (net , idev , IPSTATS_MIB_INADDRERRORS );
614
607
kfree_skb (skb );
615
608
return -1 ;
616
609
}
617
610
if (!ipv6_chk_home_addr (dev_net (skb_dst (skb )-> dev ), addr )) {
618
- __IP6_INC_STATS (net , ip6_dst_idev (skb_dst (skb )),
619
- IPSTATS_MIB_INADDRERRORS );
611
+ __IP6_INC_STATS (net , idev , IPSTATS_MIB_INADDRERRORS );
620
612
kfree_skb (skb );
621
613
return -1 ;
622
614
}
@@ -627,8 +619,7 @@ static int ipv6_rthdr_rcv(struct sk_buff *skb)
627
619
}
628
620
629
621
if (ipv6_addr_is_multicast (addr )) {
630
- __IP6_INC_STATS (net , ip6_dst_idev (skb_dst (skb )),
631
- IPSTATS_MIB_INADDRERRORS );
622
+ __IP6_INC_STATS (net , idev , IPSTATS_MIB_INADDRERRORS );
632
623
kfree_skb (skb );
633
624
return -1 ;
634
625
}
@@ -647,8 +638,7 @@ static int ipv6_rthdr_rcv(struct sk_buff *skb)
647
638
648
639
if (skb_dst (skb )-> dev -> flags & IFF_LOOPBACK ) {
649
640
if (ipv6_hdr (skb )-> hop_limit <= 1 ) {
650
- __IP6_INC_STATS (net , ip6_dst_idev (skb_dst (skb )),
651
- IPSTATS_MIB_INHDRERRORS );
641
+ __IP6_INC_STATS (net , idev , IPSTATS_MIB_INHDRERRORS );
652
642
icmpv6_send (skb , ICMPV6_TIME_EXCEED , ICMPV6_EXC_HOPLIMIT ,
653
643
0 );
654
644
kfree_skb (skb );
@@ -663,7 +653,7 @@ static int ipv6_rthdr_rcv(struct sk_buff *skb)
663
653
return -1 ;
664
654
665
655
unknown_rh :
666
- __IP6_INC_STATS (net , ip6_dst_idev ( skb_dst ( skb )) , IPSTATS_MIB_INHDRERRORS );
656
+ __IP6_INC_STATS (net , idev , IPSTATS_MIB_INHDRERRORS );
667
657
icmpv6_param_prob (skb , ICMPV6_HDR_FIELD ,
668
658
(& hdr -> type ) - skb_network_header (skb ));
669
659
return -1 ;
@@ -755,34 +745,31 @@ static bool ipv6_hop_ra(struct sk_buff *skb, int optoff)
755
745
static bool ipv6_hop_jumbo (struct sk_buff * skb , int optoff )
756
746
{
757
747
const unsigned char * nh = skb_network_header (skb );
748
+ struct inet6_dev * idev = __in6_dev_get_safely (skb -> dev );
758
749
struct net * net = ipv6_skb_net (skb );
759
750
u32 pkt_len ;
760
751
761
752
if (nh [optoff + 1 ] != 4 || (optoff & 3 ) != 2 ) {
762
753
net_dbg_ratelimited ("ipv6_hop_jumbo: wrong jumbo opt length/alignment %d\n" ,
763
754
nh [optoff + 1 ]);
764
- __IP6_INC_STATS (net , ipv6_skb_idev (skb ),
765
- IPSTATS_MIB_INHDRERRORS );
755
+ __IP6_INC_STATS (net , idev , IPSTATS_MIB_INHDRERRORS );
766
756
goto drop ;
767
757
}
768
758
769
759
pkt_len = ntohl (* (__be32 * )(nh + optoff + 2 ));
770
760
if (pkt_len <= IPV6_MAXPLEN ) {
771
- __IP6_INC_STATS (net , ipv6_skb_idev (skb ),
772
- IPSTATS_MIB_INHDRERRORS );
761
+ __IP6_INC_STATS (net , idev , IPSTATS_MIB_INHDRERRORS );
773
762
icmpv6_param_prob (skb , ICMPV6_HDR_FIELD , optoff + 2 );
774
763
return false;
775
764
}
776
765
if (ipv6_hdr (skb )-> payload_len ) {
777
- __IP6_INC_STATS (net , ipv6_skb_idev (skb ),
778
- IPSTATS_MIB_INHDRERRORS );
766
+ __IP6_INC_STATS (net , idev , IPSTATS_MIB_INHDRERRORS );
779
767
icmpv6_param_prob (skb , ICMPV6_HDR_FIELD , optoff );
780
768
return false;
781
769
}
782
770
783
771
if (pkt_len > skb -> len - sizeof (struct ipv6hdr )) {
784
- __IP6_INC_STATS (net , ipv6_skb_idev (skb ),
785
- IPSTATS_MIB_INTRUNCATEDPKTS );
772
+ __IP6_INC_STATS (net , idev , IPSTATS_MIB_INTRUNCATEDPKTS );
786
773
goto drop ;
787
774
}
788
775
0 commit comments