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>
#include <net/snmp.h>
struct netns_mib {
+ DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics);
};
#endif
extern struct proto tcp_prot;
-DECLARE_SNMP_STAT(struct tcp_mib, tcp_statistics);
-#define TCP_INC_STATS(net, field) do { (void)net; SNMP_INC_STATS(tcp_statistics, field); } while (0)
-#define TCP_INC_STATS_BH(net, field) do { (void)net; SNMP_INC_STATS_BH(tcp_statistics, field); } while (0)
-#define TCP_DEC_STATS(net, field) do { (void)net; SNMP_DEC_STATS(tcp_statistics, field); } while (0)
-#define TCP_ADD_STATS_USER(net, field, val) do { (void)net; SNMP_ADD_STATS_USER(tcp_statistics, field, val); } while (0)
+#define TCP_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.tcp_statistics, field)
+#define TCP_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.tcp_statistics, field)
+#define TCP_DEC_STATS(net, field) SNMP_DEC_STATS((net)->mib.tcp_statistics, field)
+#define TCP_ADD_STATS_USER(net, field, val) SNMP_ADD_STATS_USER((net)->mib.tcp_statistics, field, val)
extern void tcp_v4_err(struct sk_buff *skb, u32);
static __net_init int ipv4_mib_init_net(struct net *net)
{
+ if (snmp_mib_init((void **)net->mib.tcp_statistics,
+ sizeof(struct tcp_mib)) < 0)
+ goto err_tcp_mib;
+
+ tcp_mib_init(net);
return 0;
+
+err_tcp_mib:
+ return -ENOMEM;
}
static __net_exit void ipv4_mib_exit_net(struct net *net)
{
+ snmp_mib_free((void **)net->mib.tcp_statistics);
}
static __net_initdata struct pernet_operations ipv4_mib_ops = {
if (snmp_mib_init((void **)icmpmsg_statistics,
sizeof(struct icmpmsg_mib)) < 0)
goto err_icmpmsg_mib;
- if (snmp_mib_init((void **)tcp_statistics,
- sizeof(struct tcp_mib)) < 0)
- goto err_tcp_mib;
if (snmp_mib_init((void **)udp_statistics,
sizeof(struct udp_mib)) < 0)
goto err_udp_mib;
sizeof(struct udp_mib)) < 0)
goto err_udplite_mib;
- tcp_mib_init(&init_net);
-
if (register_pernet_subsys(&ipv4_mib_ops))
goto err_net;
err_udplite_mib:
snmp_mib_free((void **)udp_statistics);
err_udp_mib:
- snmp_mib_free((void **)tcp_statistics);
-err_tcp_mib:
snmp_mib_free((void **)icmpmsg_statistics);
err_icmpmsg_mib:
snmp_mib_free((void **)icmp_statistics);
/* MaxConn field is signed, RFC 2012 */
if (snmp4_tcp_list[i].entry == TCP_MIB_MAXCONN)
seq_printf(seq, " %ld",
- snmp_fold_field((void **)tcp_statistics,
+ snmp_fold_field((void **)init_net.mib.tcp_statistics,
snmp4_tcp_list[i].entry));
else
seq_printf(seq, " %lu",
- snmp_fold_field((void **)tcp_statistics,
+ snmp_fold_field((void **)init_net.mib.tcp_statistics,
snmp4_tcp_list[i].entry));
}
int sysctl_tcp_fin_timeout __read_mostly = TCP_FIN_TIMEOUT;
-DEFINE_SNMP_STAT(struct tcp_mib, tcp_statistics) __read_mostly;
-
atomic_t tcp_orphan_count = ATOMIC_INIT(0);
EXPORT_SYMBOL_GPL(tcp_orphan_count);
EXPORT_SYMBOL(tcp_sendpage);
EXPORT_SYMBOL(tcp_setsockopt);
EXPORT_SYMBOL(tcp_shutdown);
-EXPORT_SYMBOL(tcp_statistics);