]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
mib: put ip statistics on struct net
authorPavel Emelyanov <xemul@openvz.org>
Fri, 18 Jul 2008 11:02:42 +0000 (04:02 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 18 Jul 2008 11:02:42 +0000 (04:02 -0700)
Similar to tcp one.

Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/ip.h
include/net/netns/mib.h
net/ipv4/af_inet.c
net/ipv4/ip_input.c
net/ipv4/proc.c

index 02924fb4bdbf882f2c2cad8fda7a454be6a97cff..ff2535ada02e582cfa22290eff7beb1ba259af87 100644 (file)
@@ -156,10 +156,9 @@ struct ipv4_config
 };
 
 extern struct ipv4_config ipv4_config;
-DECLARE_SNMP_STAT(struct ipstats_mib, ip_statistics);
-#define IP_INC_STATS(net, field)       do { (void)net; SNMP_INC_STATS(ip_statistics, field); } while (0)
-#define IP_INC_STATS_BH(net, field)    do { (void)net; SNMP_INC_STATS_BH(ip_statistics, field); } while (0)
-#define IP_ADD_STATS_BH(net, field, val) SNMP_ADD_STATS_BH(ip_statistics, field, val)
+#define IP_INC_STATS(net, field)       SNMP_INC_STATS((net)->mib.ip_statistics, field)
+#define IP_INC_STATS_BH(net, field)    SNMP_INC_STATS_BH((net)->mib.ip_statistics, field)
+#define IP_ADD_STATS_BH(net, field, val) SNMP_ADD_STATS_BH((net)->mib.ip_statistics, field, val)
 DECLARE_SNMP_STAT(struct linux_mib, net_statistics);
 #define NET_INC_STATS(net, field)      do { (void)net; SNMP_INC_STATS(net_statistics, field); } while (0)
 #define NET_INC_STATS_BH(net, field)   do { (void)net; SNMP_INC_STATS_BH(net_statistics, field); } while (0)
index 8f96079bf0e3fe8160cad0baea84d05291d5d72a..1094ebbf0b42fd63315f8ac62d5ccd2a3e8dfea8 100644 (file)
@@ -5,6 +5,7 @@
 
 struct netns_mib {
        DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics);
+       DEFINE_SNMP_STAT(struct ipstats_mib, ip_statistics);
 };
 
 #endif
index c1a3e986f8b499e1612dd534b70d5c5ff9c05c0b..3090a9307c4620382696148ace9934e95a7d4f78 100644 (file)
@@ -1345,16 +1345,22 @@ static __net_init int ipv4_mib_init_net(struct net *net)
        if (snmp_mib_init((void **)net->mib.tcp_statistics,
                          sizeof(struct tcp_mib)) < 0)
                goto err_tcp_mib;
+       if (snmp_mib_init((void **)net->mib.ip_statistics,
+                         sizeof(struct ipstats_mib)) < 0)
+               goto err_ip_mib;
 
        tcp_mib_init(net);
        return 0;
 
+err_ip_mib:
+       snmp_mib_free((void **)net->mib.tcp_statistics);
 err_tcp_mib:
        return -ENOMEM;
 }
 
 static __net_exit void ipv4_mib_exit_net(struct net *net)
 {
+       snmp_mib_free((void **)net->mib.ip_statistics);
        snmp_mib_free((void **)net->mib.tcp_statistics);
 }
 
@@ -1368,9 +1374,6 @@ static int __init init_ipv4_mibs(void)
        if (snmp_mib_init((void **)net_statistics,
                          sizeof(struct linux_mib)) < 0)
                goto err_net_mib;
-       if (snmp_mib_init((void **)ip_statistics,
-                         sizeof(struct ipstats_mib)) < 0)
-               goto err_ip_mib;
        if (snmp_mib_init((void **)icmp_statistics,
                          sizeof(struct icmp_mib)) < 0)
                goto err_icmp_mib;
@@ -1398,8 +1401,6 @@ err_udp_mib:
 err_icmpmsg_mib:
        snmp_mib_free((void **)icmp_statistics);
 err_icmp_mib:
-       snmp_mib_free((void **)ip_statistics);
-err_ip_mib:
        snmp_mib_free((void **)net_statistics);
 err_net_mib:
        return -ENOMEM;
index 043f640df4b7c23cd6ac3adaf0544d3778d33e82..e0bed56c51f1952d9d20d75729f01e83e31e2eed 100644 (file)
 #include <linux/mroute.h>
 #include <linux/netlink.h>
 
-/*
- *     SNMP management statistics
- */
-
-DEFINE_SNMP_STAT(struct ipstats_mib, ip_statistics) __read_mostly;
-
 /*
  *     Process Router Attention IP option
  */
@@ -447,5 +441,3 @@ drop:
 out:
        return NET_RX_DROP;
 }
-
-EXPORT_SYMBOL(ip_statistics);
index 19e1d8e257da75a46ca8f25b6d8a764aa3fb2b08..2698bb2ce98f82c9855450abb402ef87b8072721 100644 (file)
@@ -344,7 +344,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v)
 
        for (i = 0; snmp4_ipstats_list[i].name != NULL; i++)
                seq_printf(seq, " %lu",
-                          snmp_fold_field((void **)ip_statistics,
+                          snmp_fold_field((void **)init_net.mib.ip_statistics,
                                           snmp4_ipstats_list[i].entry));
 
        icmp_put(seq);  /* RFC 2011 compatibility */
@@ -431,7 +431,7 @@ static int netstat_seq_show(struct seq_file *seq, void *v)
        seq_puts(seq, "\nIpExt:");
        for (i = 0; snmp4_ipextstats_list[i].name != NULL; i++)
                seq_printf(seq, " %lu",
-                          snmp_fold_field((void **)ip_statistics,
+                          snmp_fold_field((void **)init_net.mib.ip_statistics,
                                           snmp4_ipextstats_list[i].entry));
 
        seq_putc(seq, '\n');