@@ -150,13 +150,14 @@ static int ip6_output2(struct sk_buff *skb)
150150 ip6_dev_loopback_xmit );
151151
152152 if (ipv6_hdr (skb )-> hop_limit == 0 ) {
153- IP6_INC_STATS (idev , IPSTATS_MIB_OUTDISCARDS );
153+ IP6_INC_STATS (dev_net (dev ), idev ,
154+ IPSTATS_MIB_OUTDISCARDS );
154155 kfree_skb (skb );
155156 return 0 ;
156157 }
157158 }
158159
159- IP6_INC_STATS (idev , IPSTATS_MIB_OUTMCASTPKTS );
160+ IP6_INC_STATS (dev_net ( dev ), idev , IPSTATS_MIB_OUTMCASTPKTS );
160161 }
161162
162163 return NF_HOOK (PF_INET6 , NF_INET_POST_ROUTING , skb , NULL , skb -> dev ,
@@ -175,7 +176,8 @@ int ip6_output(struct sk_buff *skb)
175176{
176177 struct inet6_dev * idev = ip6_dst_idev (skb -> dst );
177178 if (unlikely (idev -> cnf .disable_ipv6 )) {
178- IP6_INC_STATS (idev , IPSTATS_MIB_OUTDISCARDS );
179+ IP6_INC_STATS (dev_net (skb -> dst -> dev ), idev ,
180+ IPSTATS_MIB_OUTDISCARDS );
179181 kfree_skb (skb );
180182 return 0 ;
181183 }
@@ -194,6 +196,7 @@ int ip6_output(struct sk_buff *skb)
194196int ip6_xmit (struct sock * sk , struct sk_buff * skb , struct flowi * fl ,
195197 struct ipv6_txoptions * opt , int ipfragok )
196198{
199+ struct net * net = sock_net (sk );
197200 struct ipv6_pinfo * np = inet6_sk (sk );
198201 struct in6_addr * first_hop = & fl -> fl6_dst ;
199202 struct dst_entry * dst = skb -> dst ;
@@ -216,7 +219,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
216219 if (skb_headroom (skb ) < head_room ) {
217220 struct sk_buff * skb2 = skb_realloc_headroom (skb , head_room );
218221 if (skb2 == NULL ) {
219- IP6_INC_STATS (ip6_dst_idev (skb -> dst ),
222+ IP6_INC_STATS (net , ip6_dst_idev (skb -> dst ),
220223 IPSTATS_MIB_OUTDISCARDS );
221224 kfree_skb (skb );
222225 return - ENOBUFS ;
@@ -270,7 +273,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
270273
271274 mtu = dst_mtu (dst );
272275 if ((skb -> len <= mtu ) || skb -> local_df || skb_is_gso (skb )) {
273- IP6_INC_STATS (ip6_dst_idev (skb -> dst ),
276+ IP6_INC_STATS (net , ip6_dst_idev (skb -> dst ),
274277 IPSTATS_MIB_OUTREQUESTS );
275278 return NF_HOOK (PF_INET6 , NF_INET_LOCAL_OUT , skb , NULL , dst -> dev ,
276279 dst_output );
@@ -280,7 +283,7 @@ int ip6_xmit(struct sock *sk, struct sk_buff *skb, struct flowi *fl,
280283 printk (KERN_DEBUG "IPv6: sending pkt_too_big to self\n" );
281284 skb -> dev = dst -> dev ;
282285 icmpv6_send (skb , ICMPV6_PKT_TOOBIG , 0 , mtu , skb -> dev );
283- IP6_INC_STATS (ip6_dst_idev (skb -> dst ), IPSTATS_MIB_FRAGFAILS );
286+ IP6_INC_STATS (net , ip6_dst_idev (skb -> dst ), IPSTATS_MIB_FRAGFAILS );
284287 kfree_skb (skb );
285288 return - EMSGSIZE ;
286289}
@@ -422,7 +425,7 @@ int ip6_forward(struct sk_buff *skb)
422425 goto drop ;
423426
424427 if (!xfrm6_policy_check (NULL , XFRM_POLICY_FWD , skb )) {
425- IP6_INC_STATS (ip6_dst_idev (dst ), IPSTATS_MIB_INDISCARDS );
428+ IP6_INC_STATS (net , ip6_dst_idev (dst ), IPSTATS_MIB_INDISCARDS );
426429 goto drop ;
427430 }
428431
@@ -468,13 +471,14 @@ int ip6_forward(struct sk_buff *skb)
468471 if (proxied > 0 )
469472 return ip6_input (skb );
470473 else if (proxied < 0 ) {
471- IP6_INC_STATS (ip6_dst_idev (dst ), IPSTATS_MIB_INDISCARDS );
474+ IP6_INC_STATS (net , ip6_dst_idev (dst ),
475+ IPSTATS_MIB_INDISCARDS );
472476 goto drop ;
473477 }
474478 }
475479
476480 if (!xfrm6_route_forward (skb )) {
477- IP6_INC_STATS (ip6_dst_idev (dst ), IPSTATS_MIB_INDISCARDS );
481+ IP6_INC_STATS (net , ip6_dst_idev (dst ), IPSTATS_MIB_INDISCARDS );
478482 goto drop ;
479483 }
480484 dst = skb -> dst ;
@@ -530,7 +534,7 @@ int ip6_forward(struct sk_buff *skb)
530534 }
531535
532536 if (skb_cow (skb , dst -> dev -> hard_header_len )) {
533- IP6_INC_STATS (ip6_dst_idev (dst ), IPSTATS_MIB_OUTDISCARDS );
537+ IP6_INC_STATS (net , ip6_dst_idev (dst ), IPSTATS_MIB_OUTDISCARDS );
534538 goto drop ;
535539 }
536540
@@ -622,6 +626,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
622626 __be32 frag_id = 0 ;
623627 int ptr , offset = 0 , err = 0 ;
624628 u8 * prevhdr , nexthdr = 0 ;
629+ struct net * net = dev_net (skb -> dst -> dev );
625630
626631 hlen = ip6_find_1stfragopt (skb , & prevhdr );
627632 nexthdr = * prevhdr ;
@@ -635,7 +640,8 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
635640 if (!skb -> local_df ) {
636641 skb -> dev = skb -> dst -> dev ;
637642 icmpv6_send (skb , ICMPV6_PKT_TOOBIG , 0 , mtu , skb -> dev );
638- IP6_INC_STATS (ip6_dst_idev (skb -> dst ), IPSTATS_MIB_FRAGFAILS );
643+ IP6_INC_STATS (net , ip6_dst_idev (skb -> dst ),
644+ IPSTATS_MIB_FRAGFAILS );
639645 kfree_skb (skb );
640646 return - EMSGSIZE ;
641647 }
@@ -684,7 +690,8 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
684690 * prevhdr = NEXTHDR_FRAGMENT ;
685691 tmp_hdr = kmemdup (skb_network_header (skb ), hlen , GFP_ATOMIC );
686692 if (!tmp_hdr ) {
687- IP6_INC_STATS (ip6_dst_idev (skb -> dst ), IPSTATS_MIB_FRAGFAILS );
693+ IP6_INC_STATS (net , ip6_dst_idev (skb -> dst ),
694+ IPSTATS_MIB_FRAGFAILS );
688695 return - ENOMEM ;
689696 }
690697
@@ -735,7 +742,8 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
735742
736743 err = output (skb );
737744 if (!err )
738- IP6_INC_STATS (ip6_dst_idev (& rt -> u .dst ), IPSTATS_MIB_FRAGCREATES );
745+ IP6_INC_STATS (net , ip6_dst_idev (& rt -> u .dst ),
746+ IPSTATS_MIB_FRAGCREATES );
739747
740748 if (err || !frag )
741749 break ;
@@ -748,7 +756,8 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
748756 kfree (tmp_hdr );
749757
750758 if (err == 0 ) {
751- IP6_INC_STATS (ip6_dst_idev (& rt -> u .dst ), IPSTATS_MIB_FRAGOKS );
759+ IP6_INC_STATS (net , ip6_dst_idev (& rt -> u .dst ),
760+ IPSTATS_MIB_FRAGOKS );
752761 dst_release (& rt -> u .dst );
753762 return 0 ;
754763 }
@@ -759,7 +768,8 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
759768 frag = skb ;
760769 }
761770
762- IP6_INC_STATS (ip6_dst_idev (& rt -> u .dst ), IPSTATS_MIB_FRAGFAILS );
771+ IP6_INC_STATS (net , ip6_dst_idev (& rt -> u .dst ),
772+ IPSTATS_MIB_FRAGFAILS );
763773 dst_release (& rt -> u .dst );
764774 return err ;
765775 }
@@ -793,7 +803,7 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
793803
794804 if ((frag = alloc_skb (len + hlen + sizeof (struct frag_hdr )+ LL_ALLOCATED_SPACE (rt -> u .dst .dev ), GFP_ATOMIC )) == NULL ) {
795805 NETDEBUG (KERN_INFO "IPv6: frag: no memory for new fragment!\n" );
796- IP6_INC_STATS (ip6_dst_idev (skb -> dst ),
806+ IP6_INC_STATS (net , ip6_dst_idev (skb -> dst ),
797807 IPSTATS_MIB_FRAGFAILS );
798808 err = - ENOMEM ;
799809 goto fail ;
@@ -857,15 +867,16 @@ static int ip6_fragment(struct sk_buff *skb, int (*output)(struct sk_buff *))
857867 if (err )
858868 goto fail ;
859869
860- IP6_INC_STATS (ip6_dst_idev (skb -> dst ), IPSTATS_MIB_FRAGCREATES );
870+ IP6_INC_STATS (net , ip6_dst_idev (skb -> dst ),
871+ IPSTATS_MIB_FRAGCREATES );
861872 }
862- IP6_INC_STATS (ip6_dst_idev (skb -> dst ),
873+ IP6_INC_STATS (net , ip6_dst_idev (skb -> dst ),
863874 IPSTATS_MIB_FRAGOKS );
864875 kfree_skb (skb );
865876 return err ;
866877
867878fail :
868- IP6_INC_STATS (ip6_dst_idev (skb -> dst ),
879+ IP6_INC_STATS (net , ip6_dst_idev (skb -> dst ),
869880 IPSTATS_MIB_FRAGFAILS );
870881 kfree_skb (skb );
871882 return err ;
@@ -1385,7 +1396,7 @@ int ip6_append_data(struct sock *sk, int getfrag(void *from, char *to,
13851396 return 0 ;
13861397error :
13871398 inet -> cork .length -= length ;
1388- IP6_INC_STATS (rt -> rt6i_idev , IPSTATS_MIB_OUTDISCARDS );
1399+ IP6_INC_STATS (sock_net ( sk ), rt -> rt6i_idev , IPSTATS_MIB_OUTDISCARDS );
13891400 return err ;
13901401}
13911402
@@ -1409,6 +1420,7 @@ int ip6_push_pending_frames(struct sock *sk)
14091420 struct in6_addr final_dst_buf , * final_dst = & final_dst_buf ;
14101421 struct inet_sock * inet = inet_sk (sk );
14111422 struct ipv6_pinfo * np = inet6_sk (sk );
1423+ struct net * net = sock_net (sk );
14121424 struct ipv6hdr * hdr ;
14131425 struct ipv6_txoptions * opt = np -> cork .opt ;
14141426 struct rt6_info * rt = (struct rt6_info * )inet -> cork .dst ;
@@ -1462,7 +1474,7 @@ int ip6_push_pending_frames(struct sock *sk)
14621474 skb -> mark = sk -> sk_mark ;
14631475
14641476 skb -> dst = dst_clone (& rt -> u .dst );
1465- IP6_INC_STATS (rt -> rt6i_idev , IPSTATS_MIB_OUTREQUESTS );
1477+ IP6_INC_STATS (net , rt -> rt6i_idev , IPSTATS_MIB_OUTREQUESTS );
14661478 if (proto == IPPROTO_ICMPV6 ) {
14671479 struct inet6_dev * idev = ip6_dst_idev (skb -> dst );
14681480
@@ -1491,7 +1503,7 @@ void ip6_flush_pending_frames(struct sock *sk)
14911503
14921504 while ((skb = __skb_dequeue_tail (& sk -> sk_write_queue )) != NULL ) {
14931505 if (skb -> dst )
1494- IP6_INC_STATS (ip6_dst_idev (skb -> dst ),
1506+ IP6_INC_STATS (sock_net ( sk ), ip6_dst_idev (skb -> dst ),
14951507 IPSTATS_MIB_OUTDISCARDS );
14961508 kfree_skb (skb );
14971509 }
0 commit comments