diff options
author | Pavel Emelyanov <xemul@openvz.org> | 2008-07-18 07:03:08 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-07-18 07:03:08 -0400 |
commit | 61a7e26028b94805fd686a6dc9dbd9941f8f19b0 (patch) | |
tree | 2253a6f827a68ea5a7041456c5bfcac0d8e24138 | |
parent | a20f5799ca7ceb24d63c74b6fdad4b0c0ee91f4f (diff) |
mib: put net statistics on struct net
Similar to ip and tcp ones :)
Signed-off-by: Pavel Emelyanov <xemul@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/ip.h | 11 | ||||
-rw-r--r-- | include/net/netns/mib.h | 1 | ||||
-rw-r--r-- | net/ipv4/af_inet.c | 14 | ||||
-rw-r--r-- | net/ipv4/proc.c | 2 |
4 files changed, 13 insertions, 15 deletions
diff --git a/include/net/ip.h b/include/net/ip.h index ff2535ada02e..b5862b975207 100644 --- a/include/net/ip.h +++ b/include/net/ip.h | |||
@@ -159,12 +159,11 @@ extern struct ipv4_config ipv4_config; | |||
159 | #define IP_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.ip_statistics, field) | 159 | #define IP_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.ip_statistics, field) |
160 | #define IP_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.ip_statistics, field) | 160 | #define IP_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.ip_statistics, field) |
161 | #define IP_ADD_STATS_BH(net, field, val) SNMP_ADD_STATS_BH((net)->mib.ip_statistics, field, val) | 161 | #define IP_ADD_STATS_BH(net, field, val) SNMP_ADD_STATS_BH((net)->mib.ip_statistics, field, val) |
162 | DECLARE_SNMP_STAT(struct linux_mib, net_statistics); | 162 | #define NET_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.net_statistics, field) |
163 | #define NET_INC_STATS(net, field) do { (void)net; SNMP_INC_STATS(net_statistics, field); } while (0) | 163 | #define NET_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.net_statistics, field) |
164 | #define NET_INC_STATS_BH(net, field) do { (void)net; SNMP_INC_STATS_BH(net_statistics, field); } while (0) | 164 | #define NET_INC_STATS_USER(net, field) SNMP_INC_STATS_USER((net)->mib.net_statistics, field) |
165 | #define NET_INC_STATS_USER(net, field) do { (void)net; SNMP_INC_STATS_USER(net_statistics, field); } while (0) | 165 | #define NET_ADD_STATS_BH(net, field, adnd) SNMP_ADD_STATS_BH((net)->mib.net_statistics, field, adnd) |
166 | #define NET_ADD_STATS_BH(net, field, adnd) do { (void)net; SNMP_ADD_STATS_BH(net_statistics, field, adnd); } while (0) | 166 | #define NET_ADD_STATS_USER(net, field, adnd) SNMP_ADD_STATS_USER((net)->mib.net_statistics, field, adnd) |
167 | #define NET_ADD_STATS_USER(net, field, adnd) do { (void)net; SNMP_ADD_STATS_USER(net_statistics, field, adnd); } while (0) | ||
168 | 167 | ||
169 | extern unsigned long snmp_fold_field(void *mib[], int offt); | 168 | extern unsigned long snmp_fold_field(void *mib[], int offt); |
170 | extern int snmp_mib_init(void *ptr[2], size_t mibsize); | 169 | extern int snmp_mib_init(void *ptr[2], size_t mibsize); |
diff --git a/include/net/netns/mib.h b/include/net/netns/mib.h index 1094ebbf0b42..b5b1115adfa8 100644 --- a/include/net/netns/mib.h +++ b/include/net/netns/mib.h | |||
@@ -6,6 +6,7 @@ | |||
6 | struct netns_mib { | 6 | struct netns_mib { |
7 | DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics); | 7 | DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics); |
8 | DEFINE_SNMP_STAT(struct ipstats_mib, ip_statistics); | 8 | DEFINE_SNMP_STAT(struct ipstats_mib, ip_statistics); |
9 | DEFINE_SNMP_STAT(struct linux_mib, net_statistics); | ||
9 | }; | 10 | }; |
10 | 11 | ||
11 | #endif | 12 | #endif |
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c index 3090a9307c46..776ed3199b52 100644 --- a/net/ipv4/af_inet.c +++ b/net/ipv4/af_inet.c | |||
@@ -115,8 +115,6 @@ | |||
115 | #include <linux/mroute.h> | 115 | #include <linux/mroute.h> |
116 | #endif | 116 | #endif |
117 | 117 | ||
118 | DEFINE_SNMP_STAT(struct linux_mib, net_statistics) __read_mostly; | ||
119 | |||
120 | extern void ip_mc_drop_socket(struct sock *sk); | 118 | extern void ip_mc_drop_socket(struct sock *sk); |
121 | 119 | ||
122 | /* The inetsw table contains everything that inet_create needs to | 120 | /* 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 | if (snmp_mib_init((void **)net->mib.ip_statistics, | 1346 | if (snmp_mib_init((void **)net->mib.ip_statistics, |
1349 | sizeof(struct ipstats_mib)) < 0) | 1347 | sizeof(struct ipstats_mib)) < 0) |
1350 | goto err_ip_mib; | 1348 | goto err_ip_mib; |
1349 | if (snmp_mib_init((void **)net->mib.net_statistics, | ||
1350 | sizeof(struct linux_mib)) < 0) | ||
1351 | goto err_net_mib; | ||
1351 | 1352 | ||
1352 | tcp_mib_init(net); | 1353 | tcp_mib_init(net); |
1353 | return 0; | 1354 | return 0; |
1354 | 1355 | ||
1356 | err_net_mib: | ||
1357 | snmp_mib_free((void **)net->mib.ip_statistics); | ||
1355 | err_ip_mib: | 1358 | err_ip_mib: |
1356 | snmp_mib_free((void **)net->mib.tcp_statistics); | 1359 | snmp_mib_free((void **)net->mib.tcp_statistics); |
1357 | err_tcp_mib: | 1360 | err_tcp_mib: |
@@ -1360,6 +1363,7 @@ err_tcp_mib: | |||
1360 | 1363 | ||
1361 | static __net_exit void ipv4_mib_exit_net(struct net *net) | 1364 | static __net_exit void ipv4_mib_exit_net(struct net *net) |
1362 | { | 1365 | { |
1366 | snmp_mib_free((void **)net->mib.net_statistics); | ||
1363 | snmp_mib_free((void **)net->mib.ip_statistics); | 1367 | snmp_mib_free((void **)net->mib.ip_statistics); |
1364 | snmp_mib_free((void **)net->mib.tcp_statistics); | 1368 | snmp_mib_free((void **)net->mib.tcp_statistics); |
1365 | } | 1369 | } |
@@ -1371,9 +1375,6 @@ static __net_initdata struct pernet_operations ipv4_mib_ops = { | |||
1371 | 1375 | ||
1372 | static int __init init_ipv4_mibs(void) | 1376 | static int __init init_ipv4_mibs(void) |
1373 | { | 1377 | { |
1374 | if (snmp_mib_init((void **)net_statistics, | ||
1375 | sizeof(struct linux_mib)) < 0) | ||
1376 | goto err_net_mib; | ||
1377 | if (snmp_mib_init((void **)icmp_statistics, | 1378 | if (snmp_mib_init((void **)icmp_statistics, |
1378 | sizeof(struct icmp_mib)) < 0) | 1379 | sizeof(struct icmp_mib)) < 0) |
1379 | goto err_icmp_mib; | 1380 | goto err_icmp_mib; |
@@ -1401,8 +1402,6 @@ err_udp_mib: | |||
1401 | err_icmpmsg_mib: | 1402 | err_icmpmsg_mib: |
1402 | snmp_mib_free((void **)icmp_statistics); | 1403 | snmp_mib_free((void **)icmp_statistics); |
1403 | err_icmp_mib: | 1404 | err_icmp_mib: |
1404 | snmp_mib_free((void **)net_statistics); | ||
1405 | err_net_mib: | ||
1406 | return -ENOMEM; | 1405 | return -ENOMEM; |
1407 | } | 1406 | } |
1408 | 1407 | ||
@@ -1582,5 +1581,4 @@ EXPORT_SYMBOL(inet_sock_destruct); | |||
1582 | EXPORT_SYMBOL(inet_stream_connect); | 1581 | EXPORT_SYMBOL(inet_stream_connect); |
1583 | EXPORT_SYMBOL(inet_stream_ops); | 1582 | EXPORT_SYMBOL(inet_stream_ops); |
1584 | EXPORT_SYMBOL(inet_unregister_protosw); | 1583 | EXPORT_SYMBOL(inet_unregister_protosw); |
1585 | EXPORT_SYMBOL(net_statistics); | ||
1586 | EXPORT_SYMBOL(sysctl_ip_nonlocal_bind); | 1584 | EXPORT_SYMBOL(sysctl_ip_nonlocal_bind); |
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index 2698bb2ce98f..ef38b1dccfda 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c | |||
@@ -421,7 +421,7 @@ static int netstat_seq_show(struct seq_file *seq, void *v) | |||
421 | seq_puts(seq, "\nTcpExt:"); | 421 | seq_puts(seq, "\nTcpExt:"); |
422 | for (i = 0; snmp4_net_list[i].name != NULL; i++) | 422 | for (i = 0; snmp4_net_list[i].name != NULL; i++) |
423 | seq_printf(seq, " %lu", | 423 | seq_printf(seq, " %lu", |
424 | snmp_fold_field((void **)net_statistics, | 424 | snmp_fold_field((void **)init_net.mib.net_statistics, |
425 | snmp4_net_list[i].entry)); | 425 | snmp4_net_list[i].entry)); |
426 | 426 | ||
427 | seq_puts(seq, "\nIpExt:"); | 427 | seq_puts(seq, "\nIpExt:"); |