aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/net/ip.h2
-rw-r--r--net/dccp/ipv4.c2
-rw-r--r--net/ipv4/datagram.c2
-rw-r--r--net/ipv4/inet_connection_sock.c4
-rw-r--r--net/ipv4/ip_forward.c4
-rw-r--r--net/ipv4/ip_fragment.c17
-rw-r--r--net/ipv4/ip_input.c30
-rw-r--r--net/ipv4/ipmr.c4
-rw-r--r--net/ipv4/route.c3
-rw-r--r--net/ipv4/tcp_ipv4.c2
-rw-r--r--net/ipv4/udp.c2
-rw-r--r--net/sctp/output.c3
12 files changed, 41 insertions, 34 deletions
diff --git a/include/net/ip.h b/include/net/ip.h
index b9aaa32e4759..9973ce08d8fd 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -158,7 +158,7 @@ struct ipv4_config
158extern struct ipv4_config ipv4_config; 158extern struct ipv4_config ipv4_config;
159DECLARE_SNMP_STAT(struct ipstats_mib, ip_statistics); 159DECLARE_SNMP_STAT(struct ipstats_mib, ip_statistics);
160#define IP_INC_STATS(net, field) do { (void)net; SNMP_INC_STATS(ip_statistics, field); } while (0) 160#define IP_INC_STATS(net, field) do { (void)net; SNMP_INC_STATS(ip_statistics, field); } while (0)
161#define IP_INC_STATS_BH(field) SNMP_INC_STATS_BH(ip_statistics, field) 161#define IP_INC_STATS_BH(net, field) do { (void)net; SNMP_INC_STATS_BH(ip_statistics, field); } while (0)
162#define IP_ADD_STATS_BH(field, val) SNMP_ADD_STATS_BH(ip_statistics, field, val) 162#define IP_ADD_STATS_BH(field, val) SNMP_ADD_STATS_BH(ip_statistics, field, val)
163DECLARE_SNMP_STAT(struct linux_mib, net_statistics); 163DECLARE_SNMP_STAT(struct linux_mib, net_statistics);
164#define NET_INC_STATS(field) SNMP_INC_STATS(net_statistics, field) 164#define NET_INC_STATS(field) SNMP_INC_STATS(net_statistics, field)
diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c
index 2b03c47cab1b..9f760a1e312c 100644
--- a/net/dccp/ipv4.c
+++ b/net/dccp/ipv4.c
@@ -465,7 +465,7 @@ static struct dst_entry* dccp_v4_route_skb(struct net *net, struct sock *sk,
465 465
466 security_skb_classify_flow(skb, &fl); 466 security_skb_classify_flow(skb, &fl);
467 if (ip_route_output_flow(net, &rt, &fl, sk, 0)) { 467 if (ip_route_output_flow(net, &rt, &fl, sk, 0)) {
468 IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES); 468 IP_INC_STATS_BH(net, IPSTATS_MIB_OUTNOROUTES);
469 return NULL; 469 return NULL;
470 } 470 }
471 471
diff --git a/net/ipv4/datagram.c b/net/ipv4/datagram.c
index 0c0c73f368ce..5e6c5a0f3fde 100644
--- a/net/ipv4/datagram.c
+++ b/net/ipv4/datagram.c
@@ -52,7 +52,7 @@ int ip4_datagram_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
52 inet->sport, usin->sin_port, sk, 1); 52 inet->sport, usin->sin_port, sk, 1);
53 if (err) { 53 if (err) {
54 if (err == -ENETUNREACH) 54 if (err == -ENETUNREACH)
55 IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES); 55 IP_INC_STATS_BH(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
56 return err; 56 return err;
57 } 57 }
58 58
diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c
index 8338e1066654..bb81c958b744 100644
--- a/net/ipv4/inet_connection_sock.c
+++ b/net/ipv4/inet_connection_sock.c
@@ -342,12 +342,12 @@ struct dst_entry* inet_csk_route_req(struct sock *sk,
342 342
343 security_req_classify_flow(req, &fl); 343 security_req_classify_flow(req, &fl);
344 if (ip_route_output_flow(net, &rt, &fl, sk, 0)) { 344 if (ip_route_output_flow(net, &rt, &fl, sk, 0)) {
345 IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES); 345 IP_INC_STATS_BH(net, IPSTATS_MIB_OUTNOROUTES);
346 return NULL; 346 return NULL;
347 } 347 }
348 if (opt && opt->is_strictroute && rt->rt_dst != rt->rt_gateway) { 348 if (opt && opt->is_strictroute && rt->rt_dst != rt->rt_gateway) {
349 ip_rt_put(rt); 349 ip_rt_put(rt);
350 IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES); 350 IP_INC_STATS_BH(net, IPSTATS_MIB_OUTNOROUTES);
351 return NULL; 351 return NULL;
352 } 352 }
353 return &rt->u.dst; 353 return &rt->u.dst;
diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c
index 7f78a5a7e1e7..450016b89a18 100644
--- a/net/ipv4/ip_forward.c
+++ b/net/ipv4/ip_forward.c
@@ -42,7 +42,7 @@ static int ip_forward_finish(struct sk_buff *skb)
42{ 42{
43 struct ip_options * opt = &(IPCB(skb)->opt); 43 struct ip_options * opt = &(IPCB(skb)->opt);
44 44
45 IP_INC_STATS_BH(IPSTATS_MIB_OUTFORWDATAGRAMS); 45 IP_INC_STATS_BH(dev_net(skb->dst->dev), IPSTATS_MIB_OUTFORWDATAGRAMS);
46 46
47 if (unlikely(opt->optlen)) 47 if (unlikely(opt->optlen))
48 ip_forward_options(skb); 48 ip_forward_options(skb);
@@ -123,7 +123,7 @@ sr_failed:
123 123
124too_many_hops: 124too_many_hops:
125 /* Tell the sender its packet died... */ 125 /* Tell the sender its packet died... */
126 IP_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 126 IP_INC_STATS_BH(dev_net(skb->dst->dev), IPSTATS_MIB_INHDRERRORS);
127 icmp_send(skb, ICMP_TIME_EXCEEDED, ICMP_EXC_TTL, 0); 127 icmp_send(skb, ICMP_TIME_EXCEEDED, ICMP_EXC_TTL, 0);
128drop: 128drop:
129 kfree_skb(skb); 129 kfree_skb(skb);
diff --git a/net/ipv4/ip_fragment.c b/net/ipv4/ip_fragment.c
index e23be5b36e1d..65364c06ada5 100644
--- a/net/ipv4/ip_fragment.c
+++ b/net/ipv4/ip_fragment.c
@@ -199,8 +199,8 @@ static void ip_expire(unsigned long arg)
199 199
200 ipq_kill(qp); 200 ipq_kill(qp);
201 201
202 IP_INC_STATS_BH(IPSTATS_MIB_REASMTIMEOUT); 202 IP_INC_STATS_BH(net, IPSTATS_MIB_REASMTIMEOUT);
203 IP_INC_STATS_BH(IPSTATS_MIB_REASMFAILS); 203 IP_INC_STATS_BH(net, IPSTATS_MIB_REASMFAILS);
204 204
205 if ((qp->q.last_in & INET_FRAG_FIRST_IN) && qp->q.fragments != NULL) { 205 if ((qp->q.last_in & INET_FRAG_FIRST_IN) && qp->q.fragments != NULL) {
206 struct sk_buff *head = qp->q.fragments; 206 struct sk_buff *head = qp->q.fragments;
@@ -261,7 +261,10 @@ static inline int ip_frag_too_far(struct ipq *qp)
261 rc = qp->q.fragments && (end - start) > max; 261 rc = qp->q.fragments && (end - start) > max;
262 262
263 if (rc) { 263 if (rc) {
264 IP_INC_STATS_BH(IPSTATS_MIB_REASMFAILS); 264 struct net *net;
265
266 net = container_of(qp->q.net, struct net, ipv4.frags);
267 IP_INC_STATS_BH(net, IPSTATS_MIB_REASMFAILS);
265 } 268 }
266 269
267 return rc; 270 return rc;
@@ -545,7 +548,7 @@ static int ip_frag_reasm(struct ipq *qp, struct sk_buff *prev,
545 iph = ip_hdr(head); 548 iph = ip_hdr(head);
546 iph->frag_off = 0; 549 iph->frag_off = 0;
547 iph->tot_len = htons(len); 550 iph->tot_len = htons(len);
548 IP_INC_STATS_BH(IPSTATS_MIB_REASMOKS); 551 IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_REASMOKS);
549 qp->q.fragments = NULL; 552 qp->q.fragments = NULL;
550 return 0; 553 return 0;
551 554
@@ -560,7 +563,7 @@ out_oversize:
560 "Oversized IP packet from " NIPQUAD_FMT ".\n", 563 "Oversized IP packet from " NIPQUAD_FMT ".\n",
561 NIPQUAD(qp->saddr)); 564 NIPQUAD(qp->saddr));
562out_fail: 565out_fail:
563 IP_INC_STATS_BH(IPSTATS_MIB_REASMFAILS); 566 IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_REASMFAILS);
564 return err; 567 return err;
565} 568}
566 569
@@ -571,7 +574,7 @@ int ip_defrag(struct sk_buff *skb, u32 user)
571 struct net *net; 574 struct net *net;
572 575
573 net = skb->dev ? dev_net(skb->dev) : dev_net(skb->dst->dev); 576 net = skb->dev ? dev_net(skb->dev) : dev_net(skb->dst->dev);
574 IP_INC_STATS_BH(IPSTATS_MIB_REASMREQDS); 577 IP_INC_STATS_BH(net, IPSTATS_MIB_REASMREQDS);
575 578
576 /* Start by cleaning up the memory. */ 579 /* Start by cleaning up the memory. */
577 if (atomic_read(&net->ipv4.frags.mem) > net->ipv4.frags.high_thresh) 580 if (atomic_read(&net->ipv4.frags.mem) > net->ipv4.frags.high_thresh)
@@ -590,7 +593,7 @@ int ip_defrag(struct sk_buff *skb, u32 user)
590 return ret; 593 return ret;
591 } 594 }
592 595
593 IP_INC_STATS_BH(IPSTATS_MIB_REASMFAILS); 596 IP_INC_STATS_BH(net, IPSTATS_MIB_REASMFAILS);
594 kfree_skb(skb); 597 kfree_skb(skb);
595 return -ENOMEM; 598 return -ENOMEM;
596} 599}
diff --git a/net/ipv4/ip_input.c b/net/ipv4/ip_input.c
index 7c26428ea67b..043f640df4b7 100644
--- a/net/ipv4/ip_input.c
+++ b/net/ipv4/ip_input.c
@@ -230,16 +230,16 @@ static int ip_local_deliver_finish(struct sk_buff *skb)
230 protocol = -ret; 230 protocol = -ret;
231 goto resubmit; 231 goto resubmit;
232 } 232 }
233 IP_INC_STATS_BH(IPSTATS_MIB_INDELIVERS); 233 IP_INC_STATS_BH(net, IPSTATS_MIB_INDELIVERS);
234 } else { 234 } else {
235 if (!raw) { 235 if (!raw) {
236 if (xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) { 236 if (xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
237 IP_INC_STATS_BH(IPSTATS_MIB_INUNKNOWNPROTOS); 237 IP_INC_STATS_BH(net, IPSTATS_MIB_INUNKNOWNPROTOS);
238 icmp_send(skb, ICMP_DEST_UNREACH, 238 icmp_send(skb, ICMP_DEST_UNREACH,
239 ICMP_PROT_UNREACH, 0); 239 ICMP_PROT_UNREACH, 0);
240 } 240 }
241 } else 241 } else
242 IP_INC_STATS_BH(IPSTATS_MIB_INDELIVERS); 242 IP_INC_STATS_BH(net, IPSTATS_MIB_INDELIVERS);
243 kfree_skb(skb); 243 kfree_skb(skb);
244 } 244 }
245 } 245 }
@@ -281,7 +281,7 @@ static inline int ip_rcv_options(struct sk_buff *skb)
281 --ANK (980813) 281 --ANK (980813)
282 */ 282 */
283 if (skb_cow(skb, skb_headroom(skb))) { 283 if (skb_cow(skb, skb_headroom(skb))) {
284 IP_INC_STATS_BH(IPSTATS_MIB_INDISCARDS); 284 IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INDISCARDS);
285 goto drop; 285 goto drop;
286 } 286 }
287 287
@@ -290,7 +290,7 @@ static inline int ip_rcv_options(struct sk_buff *skb)
290 opt->optlen = iph->ihl*4 - sizeof(struct iphdr); 290 opt->optlen = iph->ihl*4 - sizeof(struct iphdr);
291 291
292 if (ip_options_compile(dev_net(dev), opt, skb)) { 292 if (ip_options_compile(dev_net(dev), opt, skb)) {
293 IP_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 293 IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INHDRERRORS);
294 goto drop; 294 goto drop;
295 } 295 }
296 296
@@ -334,9 +334,11 @@ static int ip_rcv_finish(struct sk_buff *skb)
334 skb->dev); 334 skb->dev);
335 if (unlikely(err)) { 335 if (unlikely(err)) {
336 if (err == -EHOSTUNREACH) 336 if (err == -EHOSTUNREACH)
337 IP_INC_STATS_BH(IPSTATS_MIB_INADDRERRORS); 337 IP_INC_STATS_BH(dev_net(skb->dev),
338 IPSTATS_MIB_INADDRERRORS);
338 else if (err == -ENETUNREACH) 339 else if (err == -ENETUNREACH)
339 IP_INC_STATS_BH(IPSTATS_MIB_INNOROUTES); 340 IP_INC_STATS_BH(dev_net(skb->dev),
341 IPSTATS_MIB_INNOROUTES);
340 goto drop; 342 goto drop;
341 } 343 }
342 } 344 }
@@ -357,9 +359,9 @@ static int ip_rcv_finish(struct sk_buff *skb)
357 359
358 rt = skb->rtable; 360 rt = skb->rtable;
359 if (rt->rt_type == RTN_MULTICAST) 361 if (rt->rt_type == RTN_MULTICAST)
360 IP_INC_STATS_BH(IPSTATS_MIB_INMCASTPKTS); 362 IP_INC_STATS_BH(dev_net(rt->u.dst.dev), IPSTATS_MIB_INMCASTPKTS);
361 else if (rt->rt_type == RTN_BROADCAST) 363 else if (rt->rt_type == RTN_BROADCAST)
362 IP_INC_STATS_BH(IPSTATS_MIB_INBCASTPKTS); 364 IP_INC_STATS_BH(dev_net(rt->u.dst.dev), IPSTATS_MIB_INBCASTPKTS);
363 365
364 return dst_input(skb); 366 return dst_input(skb);
365 367
@@ -382,10 +384,10 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
382 if (skb->pkt_type == PACKET_OTHERHOST) 384 if (skb->pkt_type == PACKET_OTHERHOST)
383 goto drop; 385 goto drop;
384 386
385 IP_INC_STATS_BH(IPSTATS_MIB_INRECEIVES); 387 IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INRECEIVES);
386 388
387 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) { 389 if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) {
388 IP_INC_STATS_BH(IPSTATS_MIB_INDISCARDS); 390 IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INDISCARDS);
389 goto out; 391 goto out;
390 } 392 }
391 393
@@ -418,7 +420,7 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
418 420
419 len = ntohs(iph->tot_len); 421 len = ntohs(iph->tot_len);
420 if (skb->len < len) { 422 if (skb->len < len) {
421 IP_INC_STATS_BH(IPSTATS_MIB_INTRUNCATEDPKTS); 423 IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INTRUNCATEDPKTS);
422 goto drop; 424 goto drop;
423 } else if (len < (iph->ihl*4)) 425 } else if (len < (iph->ihl*4))
424 goto inhdr_error; 426 goto inhdr_error;
@@ -428,7 +430,7 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
428 * Note this now means skb->len holds ntohs(iph->tot_len). 430 * Note this now means skb->len holds ntohs(iph->tot_len).
429 */ 431 */
430 if (pskb_trim_rcsum(skb, len)) { 432 if (pskb_trim_rcsum(skb, len)) {
431 IP_INC_STATS_BH(IPSTATS_MIB_INDISCARDS); 433 IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INDISCARDS);
432 goto drop; 434 goto drop;
433 } 435 }
434 436
@@ -439,7 +441,7 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt,
439 ip_rcv_finish); 441 ip_rcv_finish);
440 442
441inhdr_error: 443inhdr_error:
442 IP_INC_STATS_BH(IPSTATS_MIB_INHDRERRORS); 444 IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_INHDRERRORS);
443drop: 445drop:
444 kfree_skb(skb); 446 kfree_skb(skb);
445out: 447out:
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index c9ab47b966b5..033c712c3a5d 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1178,7 +1178,7 @@ static inline int ipmr_forward_finish(struct sk_buff *skb)
1178{ 1178{
1179 struct ip_options * opt = &(IPCB(skb)->opt); 1179 struct ip_options * opt = &(IPCB(skb)->opt);
1180 1180
1181 IP_INC_STATS_BH(IPSTATS_MIB_OUTFORWDATAGRAMS); 1181 IP_INC_STATS_BH(dev_net(skb->dst->dev), IPSTATS_MIB_OUTFORWDATAGRAMS);
1182 1182
1183 if (unlikely(opt->optlen)) 1183 if (unlikely(opt->optlen))
1184 ip_forward_options(skb); 1184 ip_forward_options(skb);
@@ -1241,7 +1241,7 @@ static void ipmr_queue_xmit(struct sk_buff *skb, struct mfc_cache *c, int vifi)
1241 to blackhole. 1241 to blackhole.
1242 */ 1242 */
1243 1243
1244 IP_INC_STATS_BH(IPSTATS_MIB_FRAGFAILS); 1244 IP_INC_STATS_BH(dev_net(dev), IPSTATS_MIB_FRAGFAILS);
1245 ip_rt_put(rt); 1245 ip_rt_put(rt);
1246 goto out_free; 1246 goto out_free;
1247 } 1247 }
diff --git a/net/ipv4/route.c b/net/ipv4/route.c
index 79c1e74263a1..e4ab0ac94f92 100644
--- a/net/ipv4/route.c
+++ b/net/ipv4/route.c
@@ -1429,7 +1429,8 @@ static int ip_error(struct sk_buff *skb)
1429 break; 1429 break;
1430 case ENETUNREACH: 1430 case ENETUNREACH:
1431 code = ICMP_NET_UNREACH; 1431 code = ICMP_NET_UNREACH;
1432 IP_INC_STATS_BH(IPSTATS_MIB_INNOROUTES); 1432 IP_INC_STATS_BH(dev_net(rt->u.dst.dev),
1433 IPSTATS_MIB_INNOROUTES);
1433 break; 1434 break;
1434 case EACCES: 1435 case EACCES:
1435 code = ICMP_PKT_FILTERED; 1436 code = ICMP_PKT_FILTERED;
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index 0fefd4409413..7797d528701b 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -175,7 +175,7 @@ int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)
175 inet->sport, usin->sin_port, sk, 1); 175 inet->sport, usin->sin_port, sk, 1);
176 if (tmp < 0) { 176 if (tmp < 0) {
177 if (tmp == -ENETUNREACH) 177 if (tmp == -ENETUNREACH)
178 IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES); 178 IP_INC_STATS_BH(sock_net(sk), IPSTATS_MIB_OUTNOROUTES);
179 return tmp; 179 return tmp;
180 } 180 }
181 181
diff --git a/net/ipv4/udp.c b/net/ipv4/udp.c
index 048ef57edc1d..1560d11ba6ef 100644
--- a/net/ipv4/udp.c
+++ b/net/ipv4/udp.c
@@ -662,7 +662,7 @@ int udp_sendmsg(struct kiocb *iocb, struct sock *sk, struct msghdr *msg,
662 err = ip_route_output_flow(net, &rt, &fl, sk, 1); 662 err = ip_route_output_flow(net, &rt, &fl, sk, 1);
663 if (err) { 663 if (err) {
664 if (err == -ENETUNREACH) 664 if (err == -ENETUNREACH)
665 IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES); 665 IP_INC_STATS_BH(net, IPSTATS_MIB_OUTNOROUTES);
666 goto out; 666 goto out;
667 } 667 }
668 668
diff --git a/net/sctp/output.c b/net/sctp/output.c
index abcd00dc05eb..9a63a3fb9011 100644
--- a/net/sctp/output.c
+++ b/net/sctp/output.c
@@ -50,6 +50,7 @@
50#include <linux/init.h> 50#include <linux/init.h>
51#include <net/inet_ecn.h> 51#include <net/inet_ecn.h>
52#include <net/icmp.h> 52#include <net/icmp.h>
53#include <net/net_namespace.h>
53 54
54#ifndef TEST_FRAME 55#ifndef TEST_FRAME
55#include <net/tcp.h> 56#include <net/tcp.h>
@@ -595,7 +596,7 @@ out:
595 return err; 596 return err;
596no_route: 597no_route:
597 kfree_skb(nskb); 598 kfree_skb(nskb);
598 IP_INC_STATS_BH(IPSTATS_MIB_OUTNOROUTES); 599 IP_INC_STATS_BH(&init_net, IPSTATS_MIB_OUTNOROUTES);
599 600
600 /* FIXME: Returning the 'err' will effect all the associations 601 /* FIXME: Returning the 'err' will effect all the associations
601 * associated with a socket, although only one of the paths of the 602 * associated with a socket, although only one of the paths of the