Commit 61a7e260 authored by Pavel Emelyanov's avatar Pavel Emelyanov Committed by David S. Miller

mib: put net statistics on struct net

Similar to ip and tcp ones :)
Signed-off-by: default avatarPavel Emelyanov <xemul@openvz.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a20f5799
...@@ -159,12 +159,11 @@ extern struct ipv4_config ipv4_config; ...@@ -159,12 +159,11 @@ extern struct ipv4_config ipv4_config;
#define IP_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.ip_statistics, field) #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_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) #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) SNMP_INC_STATS((net)->mib.net_statistics, field)
#define NET_INC_STATS(net, field) do { (void)net; SNMP_INC_STATS(net_statistics, field); } while (0) #define NET_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.net_statistics, field)
#define NET_INC_STATS_BH(net, field) do { (void)net; SNMP_INC_STATS_BH(net_statistics, field); } while (0) #define NET_INC_STATS_USER(net, field) SNMP_INC_STATS_USER((net)->mib.net_statistics, field)
#define NET_INC_STATS_USER(net, field) do { (void)net; SNMP_INC_STATS_USER(net_statistics, field); } while (0) #define NET_ADD_STATS_BH(net, field, adnd) SNMP_ADD_STATS_BH((net)->mib.net_statistics, field, adnd)
#define NET_ADD_STATS_BH(net, field, adnd) do { (void)net; SNMP_ADD_STATS_BH(net_statistics, field, adnd); } while (0) #define NET_ADD_STATS_USER(net, field, adnd) SNMP_ADD_STATS_USER((net)->mib.net_statistics, field, adnd)
#define NET_ADD_STATS_USER(net, field, adnd) do { (void)net; SNMP_ADD_STATS_USER(net_statistics, field, adnd); } while (0)
extern unsigned long snmp_fold_field(void *mib[], int offt); extern unsigned long snmp_fold_field(void *mib[], int offt);
extern int snmp_mib_init(void *ptr[2], size_t mibsize); extern int snmp_mib_init(void *ptr[2], size_t mibsize);
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
struct netns_mib { struct netns_mib {
DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics); DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics);
DEFINE_SNMP_STAT(struct ipstats_mib, ip_statistics); DEFINE_SNMP_STAT(struct ipstats_mib, ip_statistics);
DEFINE_SNMP_STAT(struct linux_mib, net_statistics);
}; };
#endif #endif
...@@ -115,8 +115,6 @@ ...@@ -115,8 +115,6 @@
#include <linux/mroute.h> #include <linux/mroute.h>
#endif #endif
DEFINE_SNMP_STAT(struct linux_mib, net_statistics) __read_mostly;
extern void ip_mc_drop_socket(struct sock *sk); extern void ip_mc_drop_socket(struct sock *sk);
/* The inetsw table contains everything that inet_create needs to /* The inetsw table contains everything that inet_create needs to
...@@ -1348,10 +1346,15 @@ static __net_init int ipv4_mib_init_net(struct net *net) ...@@ -1348,10 +1346,15 @@ static __net_init int ipv4_mib_init_net(struct net *net)
if (snmp_mib_init((void **)net->mib.ip_statistics, if (snmp_mib_init((void **)net->mib.ip_statistics,
sizeof(struct ipstats_mib)) < 0) sizeof(struct ipstats_mib)) < 0)
goto err_ip_mib; goto err_ip_mib;
if (snmp_mib_init((void **)net->mib.net_statistics,
sizeof(struct linux_mib)) < 0)
goto err_net_mib;
tcp_mib_init(net); tcp_mib_init(net);
return 0; return 0;
err_net_mib:
snmp_mib_free((void **)net->mib.ip_statistics);
err_ip_mib: err_ip_mib:
snmp_mib_free((void **)net->mib.tcp_statistics); snmp_mib_free((void **)net->mib.tcp_statistics);
err_tcp_mib: err_tcp_mib:
...@@ -1360,6 +1363,7 @@ static __net_init int ipv4_mib_init_net(struct net *net) ...@@ -1360,6 +1363,7 @@ static __net_init int ipv4_mib_init_net(struct net *net)
static __net_exit void ipv4_mib_exit_net(struct net *net) static __net_exit void ipv4_mib_exit_net(struct net *net)
{ {
snmp_mib_free((void **)net->mib.net_statistics);
snmp_mib_free((void **)net->mib.ip_statistics); snmp_mib_free((void **)net->mib.ip_statistics);
snmp_mib_free((void **)net->mib.tcp_statistics); snmp_mib_free((void **)net->mib.tcp_statistics);
} }
...@@ -1371,9 +1375,6 @@ static __net_initdata struct pernet_operations ipv4_mib_ops = { ...@@ -1371,9 +1375,6 @@ static __net_initdata struct pernet_operations ipv4_mib_ops = {
static int __init init_ipv4_mibs(void) 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 **)icmp_statistics, if (snmp_mib_init((void **)icmp_statistics,
sizeof(struct icmp_mib)) < 0) sizeof(struct icmp_mib)) < 0)
goto err_icmp_mib; goto err_icmp_mib;
...@@ -1401,8 +1402,6 @@ static int __init init_ipv4_mibs(void) ...@@ -1401,8 +1402,6 @@ static int __init init_ipv4_mibs(void)
err_icmpmsg_mib: err_icmpmsg_mib:
snmp_mib_free((void **)icmp_statistics); snmp_mib_free((void **)icmp_statistics);
err_icmp_mib: err_icmp_mib:
snmp_mib_free((void **)net_statistics);
err_net_mib:
return -ENOMEM; return -ENOMEM;
} }
...@@ -1582,5 +1581,4 @@ EXPORT_SYMBOL(inet_sock_destruct); ...@@ -1582,5 +1581,4 @@ EXPORT_SYMBOL(inet_sock_destruct);
EXPORT_SYMBOL(inet_stream_connect); EXPORT_SYMBOL(inet_stream_connect);
EXPORT_SYMBOL(inet_stream_ops); EXPORT_SYMBOL(inet_stream_ops);
EXPORT_SYMBOL(inet_unregister_protosw); EXPORT_SYMBOL(inet_unregister_protosw);
EXPORT_SYMBOL(net_statistics);
EXPORT_SYMBOL(sysctl_ip_nonlocal_bind); EXPORT_SYMBOL(sysctl_ip_nonlocal_bind);
...@@ -421,7 +421,7 @@ static int netstat_seq_show(struct seq_file *seq, void *v) ...@@ -421,7 +421,7 @@ static int netstat_seq_show(struct seq_file *seq, void *v)
seq_puts(seq, "\nTcpExt:"); seq_puts(seq, "\nTcpExt:");
for (i = 0; snmp4_net_list[i].name != NULL; i++) for (i = 0; snmp4_net_list[i].name != NULL; i++)
seq_printf(seq, " %lu", seq_printf(seq, " %lu",
snmp_fold_field((void **)net_statistics, snmp_fold_field((void **)init_net.mib.net_statistics,
snmp4_net_list[i].entry)); snmp4_net_list[i].entry));
seq_puts(seq, "\nIpExt:"); seq_puts(seq, "\nIpExt:");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment