mib: put icmpmsg statistics on struct net
authorPavel Emelyanov <xemul@openvz.org>
Fri, 18 Jul 2008 11:04:22 +0000 (04:04 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 18 Jul 2008 11:04:22 +0000 (04:04 -0700)
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
include/net/icmp.h
include/net/netns/mib.h
net/ipv4/af_inet.c
net/ipv4/icmp.c
net/ipv4/proc.c

index e14f2c03f42efc6746225da335f40f3593fe999a..dfa72d4e89071c01ee02044864411c46f4d5b2cb 100644 (file)
@@ -29,11 +29,10 @@ struct icmp_err {
 };
 
 extern struct icmp_err icmp_err_convert[];
-DECLARE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics);
 #define ICMP_INC_STATS(net, field)     SNMP_INC_STATS((net)->mib.icmp_statistics, field)
 #define ICMP_INC_STATS_BH(net, field)  SNMP_INC_STATS_BH((net)->mib.icmp_statistics, field)
-#define ICMPMSGOUT_INC_STATS(net, field)       SNMP_INC_STATS(icmpmsg_statistics, field+256)
-#define ICMPMSGIN_INC_STATS_BH(net, field)     SNMP_INC_STATS_BH(icmpmsg_statistics, field)
+#define ICMPMSGOUT_INC_STATS(net, field)       SNMP_INC_STATS((net)->mib.icmpmsg_statistics, field+256)
+#define ICMPMSGIN_INC_STATS_BH(net, field)     SNMP_INC_STATS_BH((net)->mib.icmpmsg_statistics, field)
 
 struct dst_entry;
 struct net_proto_family;
index 03f5abdf58e5da219bdf80dbe06a7a010cc1ea6a..449147604642db764622dd0b96fe7c4650732532 100644 (file)
@@ -10,6 +10,7 @@ struct netns_mib {
        DEFINE_SNMP_STAT(struct udp_mib, udp_statistics);
        DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics);
        DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics);
+       DEFINE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics);
 };
 
 #endif
index 5c72bb3adadd4f5aa3d008c19ce014f42a09ec6d..36ff6dc769c6b25c3bbf5a158b0f4074929cf140 100644 (file)
@@ -1358,10 +1358,15 @@ static __net_init int ipv4_mib_init_net(struct net *net)
        if (snmp_mib_init((void **)net->mib.icmp_statistics,
                          sizeof(struct icmp_mib)) < 0)
                goto err_icmp_mib;
+       if (snmp_mib_init((void **)net->mib.icmpmsg_statistics,
+                         sizeof(struct icmpmsg_mib)) < 0)
+               goto err_icmpmsg_mib;
 
        tcp_mib_init(net);
        return 0;
 
+err_icmpmsg_mib:
+       snmp_mib_free((void **)net->mib.icmp_statistics);
 err_icmp_mib:
        snmp_mib_free((void **)net->mib.udplite_statistics);
 err_udplite_mib:
@@ -1378,6 +1383,7 @@ err_tcp_mib:
 
 static __net_exit void ipv4_mib_exit_net(struct net *net)
 {
+       snmp_mib_free((void **)net->mib.icmpmsg_statistics);
        snmp_mib_free((void **)net->mib.icmp_statistics);
        snmp_mib_free((void **)net->mib.udplite_statistics);
        snmp_mib_free((void **)net->mib.udp_statistics);
@@ -1393,18 +1399,12 @@ static __net_initdata struct pernet_operations ipv4_mib_ops = {
 
 static int __init init_ipv4_mibs(void)
 {
-       if (snmp_mib_init((void **)icmpmsg_statistics,
-                         sizeof(struct icmpmsg_mib)) < 0)
-               goto err_icmpmsg_mib;
-
        if (register_pernet_subsys(&ipv4_mib_ops))
                goto err_net;
 
        return 0;
 
 err_net:
-       snmp_mib_free((void **)icmpmsg_statistics);
-err_icmpmsg_mib:
        return -ENOMEM;
 }
 
index 33f958902d9b05774459aee46ffa33dc383fee85..860558633b2c28b0ae9e8f658846d0b0bbe2b49b 100644 (file)
@@ -111,11 +111,6 @@ struct icmp_bxm {
        unsigned char  optbuf[40];
 };
 
-/*
- *     Statistics
- */
-DEFINE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics) __read_mostly;
-
 /* An array of errno for error messages from dest unreach. */
 /* RFC 1122: 3.2.2.1 States that NET_UNREACH, HOST_UNREACH and SR_FAILED MUST be considered 'transient errs'. */
 
index 6b43cce05587f1278fa8978456ef5fdd3c0cb679..e11144b0134a20726d494a0e4de6802c02fadeda 100644 (file)
@@ -270,7 +270,7 @@ static void icmpmsg_put(struct seq_file *seq)
        count = 0;
        for (i = 0; i < ICMPMSG_MIB_MAX; i++) {
 
-               if (snmp_fold_field((void **) icmpmsg_statistics, i))
+               if (snmp_fold_field((void **) init_net.mib.icmpmsg_statistics, i))
                        out[count++] = i;
                if (count < PERLINE)
                        continue;
@@ -282,7 +282,7 @@ static void icmpmsg_put(struct seq_file *seq)
                seq_printf(seq, "\nIcmpMsg: ");
                for (j = 0; j < PERLINE; ++j)
                        seq_printf(seq, " %lu",
-                               snmp_fold_field((void **) icmpmsg_statistics,
+                               snmp_fold_field((void **) init_net.mib.icmpmsg_statistics,
                                out[j]));
                seq_putc(seq, '\n');
        }
@@ -294,7 +294,7 @@ static void icmpmsg_put(struct seq_file *seq)
                seq_printf(seq, "\nIcmpMsg:");
                for (j = 0; j < count; ++j)
                        seq_printf(seq, " %lu", snmp_fold_field((void **)
-                               icmpmsg_statistics, out[j]));
+                               init_net.mib.icmpmsg_statistics, out[j]));
        }
 
 #undef PERLINE
@@ -315,14 +315,14 @@ static void icmp_put(struct seq_file *seq)
                snmp_fold_field((void **) init_net.mib.icmp_statistics, ICMP_MIB_INERRORS));
        for (i=0; icmpmibmap[i].name != NULL; i++)
                seq_printf(seq, " %lu",
-                       snmp_fold_field((void **) icmpmsg_statistics,
+                       snmp_fold_field((void **) init_net.mib.icmpmsg_statistics,
                                icmpmibmap[i].index));
        seq_printf(seq, " %lu %lu",
                snmp_fold_field((void **) init_net.mib.icmp_statistics, ICMP_MIB_OUTMSGS),
                snmp_fold_field((void **) init_net.mib.icmp_statistics, ICMP_MIB_OUTERRORS));
        for (i=0; icmpmibmap[i].name != NULL; i++)
                seq_printf(seq, " %lu",
-                       snmp_fold_field((void **) icmpmsg_statistics,
+                       snmp_fold_field((void **) init_net.mib.icmpmsg_statistics,
                                icmpmibmap[i].index | 0x100));
 }