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

index 738c87ce183daf2f0c7acc05be0e03a961cb40af..23e699fdb5cc0cfb70fee3e301726afb49b907a6 100644 (file)
@@ -8,6 +8,7 @@ struct netns_mib {
        DEFINE_SNMP_STAT(struct ipstats_mib, ip_statistics);
        DEFINE_SNMP_STAT(struct linux_mib, net_statistics);
        DEFINE_SNMP_STAT(struct udp_mib, udp_statistics);
+       DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics);
 };
 
 #endif
index ba5544152708db8be8c71a0bbc9d10e107f286ad..addcdc67234c63dd6afc714a8b580dda02c28888 100644 (file)
@@ -151,17 +151,16 @@ extern int        udp_lib_setsockopt(struct sock *sk, int level, int optname,
 DECLARE_SNMP_STAT(struct udp_mib, udp_stats_in6);
 
 /* UDP-Lite does not have a standardized MIB yet, so we inherit from UDP */
-DECLARE_SNMP_STAT(struct udp_mib, udplite_statistics);
 DECLARE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
 
 /*
  *     SNMP statistics for UDP and UDP-Lite
  */
 #define UDP_INC_STATS_USER(net, field, is_udplite)           do { \
-       if (is_udplite) SNMP_INC_STATS_USER(udplite_statistics, field);       \
+       if (is_udplite) SNMP_INC_STATS_USER((net)->mib.udplite_statistics, field);       \
        else            SNMP_INC_STATS_USER((net)->mib.udp_statistics, field);  }  while(0)
 #define UDP_INC_STATS_BH(net, field, is_udplite)             do { \
-       if (is_udplite) SNMP_INC_STATS_BH(udplite_statistics, field);         \
+       if (is_udplite) SNMP_INC_STATS_BH((net)->mib.udplite_statistics, field);         \
        else            SNMP_INC_STATS_BH((net)->mib.udp_statistics, field);    }  while(0)
 
 #define UDP6_INC_STATS_BH(net, field, is_udplite)          do { (void)net;  \
index 1f418164ebf2720cf96e07846d9abf5fdf2d2135..bf1f200c65753c4ec1ca5a92ee03bcd5c099d8b1 100644 (file)
@@ -1352,10 +1352,15 @@ static __net_init int ipv4_mib_init_net(struct net *net)
        if (snmp_mib_init((void **)net->mib.udp_statistics,
                          sizeof(struct udp_mib)) < 0)
                goto err_udp_mib;
+       if (snmp_mib_init((void **)net->mib.udplite_statistics,
+                         sizeof(struct udp_mib)) < 0)
+               goto err_udplite_mib;
 
        tcp_mib_init(net);
        return 0;
 
+err_udplite_mib:
+       snmp_mib_free((void **)net->mib.udp_statistics);
 err_udp_mib:
        snmp_mib_free((void **)net->mib.net_statistics);
 err_net_mib:
@@ -1368,6 +1373,7 @@ err_tcp_mib:
 
 static __net_exit void ipv4_mib_exit_net(struct net *net)
 {
+       snmp_mib_free((void **)net->mib.udplite_statistics);
        snmp_mib_free((void **)net->mib.udp_statistics);
        snmp_mib_free((void **)net->mib.net_statistics);
        snmp_mib_free((void **)net->mib.ip_statistics);
@@ -1387,9 +1393,6 @@ static int __init init_ipv4_mibs(void)
        if (snmp_mib_init((void **)icmpmsg_statistics,
                          sizeof(struct icmpmsg_mib)) < 0)
                goto err_icmpmsg_mib;
-       if (snmp_mib_init((void **)udplite_statistics,
-                         sizeof(struct udp_mib)) < 0)
-               goto err_udplite_mib;
 
        if (register_pernet_subsys(&ipv4_mib_ops))
                goto err_net;
@@ -1397,8 +1400,6 @@ static int __init init_ipv4_mibs(void)
        return 0;
 
 err_net:
-       snmp_mib_free((void **)udplite_statistics);
-err_udplite_mib:
        snmp_mib_free((void **)icmpmsg_statistics);
 err_icmpmsg_mib:
        snmp_mib_free((void **)icmp_statistics);
index 869085c8e43fed88dbf292f0c289bf349fc23b59..765418334b3c6a11ca17d27522799e8157fe232f 100644 (file)
@@ -385,7 +385,7 @@ static int snmp_seq_show(struct seq_file *seq, void *v)
        seq_puts(seq, "\nUdpLite:");
        for (i = 0; snmp4_udp_list[i].name != NULL; i++)
                seq_printf(seq, " %lu",
-                          snmp_fold_field((void **)udplite_statistics,
+                          snmp_fold_field((void **)init_net.mib.udplite_statistics,
                                           snmp4_udp_list[i].entry));
 
        seq_putc(seq, '\n');
index 4ad16b6d51386a6a921cdb298bd8009a10bbc430..3c807964da96a95eb08f738974abda92b0959f87 100644 (file)
@@ -11,7 +11,6 @@
  *             2 of the License, or (at your option) any later version.
  */
 #include "udp_impl.h"
-DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics)   __read_mostly;
 
 struct hlist_head      udplite_hash[UDP_HTABLE_SIZE];