aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Emelyanov <xemul@openvz.org>2008-07-18 07:02:08 -0400
committerDavid S. Miller <davem@davemloft.net>2008-07-18 07:02:08 -0400
commit57ef42d59d1c1d79be59fc3c6380ae14234e38c3 (patch)
tree4ccc2166f6967ac1fb582715f7d7d5bb5c9205fc
parent9b4661bd6e5437508e0920608f3213c23212cd1b (diff)
mib: put tcp statistics on struct net
Proc temporary uses stats from init_net. BTW, TCP_XXX_STATS are beautiful (w/o do { } while (0) facing) again :) Signed-off-by: Pavel Emelyanov <xemul@openvz.org> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--include/net/netns/mib.h1
-rw-r--r--include/net/tcp.h9
-rw-r--r--net/ipv4/af_inet.c16
-rw-r--r--net/ipv4/proc.c4
-rw-r--r--net/ipv4/tcp.c3
5 files changed, 16 insertions, 17 deletions
diff --git a/include/net/netns/mib.h b/include/net/netns/mib.h
index 9f4b31ed18c3..8f96079bf0e3 100644
--- a/include/net/netns/mib.h
+++ b/include/net/netns/mib.h
@@ -4,6 +4,7 @@
4#include <net/snmp.h> 4#include <net/snmp.h>
5 5
6struct netns_mib { 6struct netns_mib {
7 DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics);
7}; 8};
8 9
9#endif 10#endif
diff --git a/include/net/tcp.h b/include/net/tcp.h
index 60e5be8b925b..92d7b551dc55 100644
--- a/include/net/tcp.h
+++ b/include/net/tcp.h
@@ -265,11 +265,10 @@ static inline int tcp_too_many_orphans(struct sock *sk, int num)
265 265
266extern struct proto tcp_prot; 266extern struct proto tcp_prot;
267 267
268DECLARE_SNMP_STAT(struct tcp_mib, tcp_statistics); 268#define TCP_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.tcp_statistics, field)
269#define TCP_INC_STATS(net, field) do { (void)net; SNMP_INC_STATS(tcp_statistics, field); } while (0) 269#define TCP_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.tcp_statistics, field)
270#define TCP_INC_STATS_BH(net, field) do { (void)net; SNMP_INC_STATS_BH(tcp_statistics, field); } while (0) 270#define TCP_DEC_STATS(net, field) SNMP_DEC_STATS((net)->mib.tcp_statistics, field)
271#define TCP_DEC_STATS(net, field) do { (void)net; SNMP_DEC_STATS(tcp_statistics, field); } while (0) 271#define TCP_ADD_STATS_USER(net, field, val) SNMP_ADD_STATS_USER((net)->mib.tcp_statistics, field, val)
272#define TCP_ADD_STATS_USER(net, field, val) do { (void)net; SNMP_ADD_STATS_USER(tcp_statistics, field, val); } while (0)
273 272
274extern void tcp_v4_err(struct sk_buff *skb, u32); 273extern void tcp_v4_err(struct sk_buff *skb, u32);
275 274
diff --git a/net/ipv4/af_inet.c b/net/ipv4/af_inet.c
index b4b77aa07953..c1a3e986f8b4 100644
--- a/net/ipv4/af_inet.c
+++ b/net/ipv4/af_inet.c
@@ -1342,11 +1342,20 @@ static struct net_protocol icmp_protocol = {
1342 1342
1343static __net_init int ipv4_mib_init_net(struct net *net) 1343static __net_init int ipv4_mib_init_net(struct net *net)
1344{ 1344{
1345 if (snmp_mib_init((void **)net->mib.tcp_statistics,
1346 sizeof(struct tcp_mib)) < 0)
1347 goto err_tcp_mib;
1348
1349 tcp_mib_init(net);
1345 return 0; 1350 return 0;
1351
1352err_tcp_mib:
1353 return -ENOMEM;
1346} 1354}
1347 1355
1348static __net_exit void ipv4_mib_exit_net(struct net *net) 1356static __net_exit void ipv4_mib_exit_net(struct net *net)
1349{ 1357{
1358 snmp_mib_free((void **)net->mib.tcp_statistics);
1350} 1359}
1351 1360
1352static __net_initdata struct pernet_operations ipv4_mib_ops = { 1361static __net_initdata struct pernet_operations ipv4_mib_ops = {
@@ -1368,9 +1377,6 @@ static int __init init_ipv4_mibs(void)
1368 if (snmp_mib_init((void **)icmpmsg_statistics, 1377 if (snmp_mib_init((void **)icmpmsg_statistics,
1369 sizeof(struct icmpmsg_mib)) < 0) 1378 sizeof(struct icmpmsg_mib)) < 0)
1370 goto err_icmpmsg_mib; 1379 goto err_icmpmsg_mib;
1371 if (snmp_mib_init((void **)tcp_statistics,
1372 sizeof(struct tcp_mib)) < 0)
1373 goto err_tcp_mib;
1374 if (snmp_mib_init((void **)udp_statistics, 1380 if (snmp_mib_init((void **)udp_statistics,
1375 sizeof(struct udp_mib)) < 0) 1381 sizeof(struct udp_mib)) < 0)
1376 goto err_udp_mib; 1382 goto err_udp_mib;
@@ -1378,8 +1384,6 @@ static int __init init_ipv4_mibs(void)
1378 sizeof(struct udp_mib)) < 0) 1384 sizeof(struct udp_mib)) < 0)
1379 goto err_udplite_mib; 1385 goto err_udplite_mib;
1380 1386
1381 tcp_mib_init(&init_net);
1382
1383 if (register_pernet_subsys(&ipv4_mib_ops)) 1387 if (register_pernet_subsys(&ipv4_mib_ops))
1384 goto err_net; 1388 goto err_net;
1385 1389
@@ -1390,8 +1394,6 @@ err_net:
1390err_udplite_mib: 1394err_udplite_mib:
1391 snmp_mib_free((void **)udp_statistics); 1395 snmp_mib_free((void **)udp_statistics);
1392err_udp_mib: 1396err_udp_mib:
1393 snmp_mib_free((void **)tcp_statistics);
1394err_tcp_mib:
1395 snmp_mib_free((void **)icmpmsg_statistics); 1397 snmp_mib_free((void **)icmpmsg_statistics);
1396err_icmpmsg_mib: 1398err_icmpmsg_mib:
1397 snmp_mib_free((void **)icmp_statistics); 1399 snmp_mib_free((void **)icmp_statistics);
diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c
index eb5cee279c5f..19e1d8e257da 100644
--- a/net/ipv4/proc.c
+++ b/net/ipv4/proc.c
@@ -359,11 +359,11 @@ static int snmp_seq_show(struct seq_file *seq, void *v)
359 /* MaxConn field is signed, RFC 2012 */ 359 /* MaxConn field is signed, RFC 2012 */
360 if (snmp4_tcp_list[i].entry == TCP_MIB_MAXCONN) 360 if (snmp4_tcp_list[i].entry == TCP_MIB_MAXCONN)
361 seq_printf(seq, " %ld", 361 seq_printf(seq, " %ld",
362 snmp_fold_field((void **)tcp_statistics, 362 snmp_fold_field((void **)init_net.mib.tcp_statistics,
363 snmp4_tcp_list[i].entry)); 363 snmp4_tcp_list[i].entry));
364 else 364 else
365 seq_printf(seq, " %lu", 365 seq_printf(seq, " %lu",
366 snmp_fold_field((void **)tcp_statistics, 366 snmp_fold_field((void **)init_net.mib.tcp_statistics,
367 snmp4_tcp_list[i].entry)); 367 snmp4_tcp_list[i].entry));
368 } 368 }
369 369
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index eec8cf7c0247..827e6132af5f 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -277,8 +277,6 @@
277 277
278int sysctl_tcp_fin_timeout __read_mostly = TCP_FIN_TIMEOUT; 278int sysctl_tcp_fin_timeout __read_mostly = TCP_FIN_TIMEOUT;
279 279
280DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics) __read_mostly;
281
282atomic_t tcp_orphan_count = ATOMIC_INIT(0); 280atomic_t tcp_orphan_count = ATOMIC_INIT(0);
283 281
284EXPORT_SYMBOL_GPL(tcp_orphan_count); 282EXPORT_SYMBOL_GPL(tcp_orphan_count);
@@ -2802,4 +2800,3 @@ EXPORT_SYMBOL(tcp_splice_read);
2802EXPORT_SYMBOL(tcp_sendpage); 2800EXPORT_SYMBOL(tcp_sendpage);
2803EXPORT_SYMBOL(tcp_setsockopt); 2801EXPORT_SYMBOL(tcp_setsockopt);
2804EXPORT_SYMBOL(tcp_shutdown); 2802EXPORT_SYMBOL(tcp_shutdown);
2805EXPORT_SYMBOL(tcp_statistics);