提交 9261e537 编写于 作者: D Denis V. Lunev 提交者: David S. Miller

ipv6: making ip and icmp statistics per/namespace

Signed-off-by: NDenis V. Lunev <den@openvz.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 087fe240
...@@ -113,23 +113,20 @@ extern struct ctl_path net_ipv6_ctl_path[]; ...@@ -113,23 +113,20 @@ extern struct ctl_path net_ipv6_ctl_path[];
#define _DEVINC(net, statname, modifier, idev, field) \ #define _DEVINC(net, statname, modifier, idev, field) \
({ \ ({ \
struct inet6_dev *_idev = (idev); \ struct inet6_dev *_idev = (idev); \
(void)(net); \
if (likely(_idev != NULL)) \ if (likely(_idev != NULL)) \
SNMP_INC_STATS##modifier((_idev)->stats.statname, (field)); \ SNMP_INC_STATS##modifier((_idev)->stats.statname, (field)); \
SNMP_INC_STATS##modifier(statname##_statistics, (field)); \ SNMP_INC_STATS##modifier((net)->mib.statname##_statistics, (field));\
}) })
#define _DEVADD(net, statname, modifier, idev, field, val) \ #define _DEVADD(net, statname, modifier, idev, field, val) \
({ \ ({ \
struct inet6_dev *_idev = (idev); \ struct inet6_dev *_idev = (idev); \
(void)(net); \
if (likely(_idev != NULL)) \ if (likely(_idev != NULL)) \
SNMP_ADD_STATS##modifier((_idev)->stats.statname, (field), (val)); \ SNMP_ADD_STATS##modifier((_idev)->stats.statname, (field), (val)); \
SNMP_ADD_STATS##modifier(statname##_statistics, (field), (val));\ SNMP_ADD_STATS##modifier((net)->mib.statname##_statistics, (field), (val));\
}) })
/* MIBs */ /* MIBs */
DECLARE_SNMP_STAT(struct ipstats_mib, ipv6_statistics);
#define IP6_INC_STATS(net, idev,field) \ #define IP6_INC_STATS(net, idev,field) \
_DEVINC(net, ipv6, , idev, field) _DEVINC(net, ipv6, , idev, field)
...@@ -138,9 +135,6 @@ DECLARE_SNMP_STAT(struct ipstats_mib, ipv6_statistics); ...@@ -138,9 +135,6 @@ DECLARE_SNMP_STAT(struct ipstats_mib, ipv6_statistics);
#define IP6_ADD_STATS_BH(net, idev,field,val) \ #define IP6_ADD_STATS_BH(net, idev,field,val) \
_DEVADD(net, ipv6, _BH, idev, field, val) _DEVADD(net, ipv6, _BH, idev, field, val)
DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics);
DECLARE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics);
#define ICMP6_INC_STATS(net, idev, field) \ #define ICMP6_INC_STATS(net, idev, field) \
_DEVINC(net, icmpv6, , idev, field) _DEVINC(net, icmpv6, , idev, field)
#define ICMP6_INC_STATS_BH(net, idev, field) \ #define ICMP6_INC_STATS_BH(net, idev, field) \
......
...@@ -16,6 +16,9 @@ struct netns_mib { ...@@ -16,6 +16,9 @@ struct netns_mib {
struct proc_dir_entry *proc_net_devsnmp6; struct proc_dir_entry *proc_net_devsnmp6;
DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6); DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6);
DEFINE_SNMP_STAT(struct udp_mib, udplite_stats_in6); DEFINE_SNMP_STAT(struct udp_mib, udplite_stats_in6);
DEFINE_SNMP_STAT(struct ipstats_mib, ipv6_statistics);
DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics);
DEFINE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics);
#endif #endif
}; };
......
...@@ -797,31 +797,11 @@ static void ipv6_packet_cleanup(void) ...@@ -797,31 +797,11 @@ static void ipv6_packet_cleanup(void)
static int __init init_ipv6_mibs(void) static int __init init_ipv6_mibs(void)
{ {
if (snmp_mib_init((void **)ipv6_statistics,
sizeof(struct ipstats_mib)) < 0)
goto err_ip_mib;
if (snmp_mib_init((void **)icmpv6_statistics,
sizeof(struct icmpv6_mib)) < 0)
goto err_icmp_mib;
if (snmp_mib_init((void **)icmpv6msg_statistics,
sizeof(struct icmpv6msg_mib)) < 0)
goto err_icmpmsg_mib;
return 0; return 0;
err_icmpmsg_mib:
snmp_mib_free((void **)icmpv6_statistics);
err_icmp_mib:
snmp_mib_free((void **)ipv6_statistics);
err_ip_mib:
return -ENOMEM;
} }
static void cleanup_ipv6_mibs(void) static void cleanup_ipv6_mibs(void)
{ {
snmp_mib_free((void **)ipv6_statistics);
snmp_mib_free((void **)icmpv6_statistics);
snmp_mib_free((void **)icmpv6msg_statistics);
} }
static int __net_init ipv6_init_mibs(struct net *net) static int __net_init ipv6_init_mibs(struct net *net)
...@@ -832,8 +812,23 @@ static int __net_init ipv6_init_mibs(struct net *net) ...@@ -832,8 +812,23 @@ static int __net_init ipv6_init_mibs(struct net *net)
if (snmp_mib_init((void **)net->mib.udplite_stats_in6, if (snmp_mib_init((void **)net->mib.udplite_stats_in6,
sizeof (struct udp_mib)) < 0) sizeof (struct udp_mib)) < 0)
goto err_udplite_mib; goto err_udplite_mib;
if (snmp_mib_init((void **)net->mib.ipv6_statistics,
sizeof(struct ipstats_mib)) < 0)
goto err_ip_mib;
if (snmp_mib_init((void **)net->mib.icmpv6_statistics,
sizeof(struct icmpv6_mib)) < 0)
goto err_icmp_mib;
if (snmp_mib_init((void **)net->mib.icmpv6msg_statistics,
sizeof(struct icmpv6msg_mib)) < 0)
goto err_icmpmsg_mib;
return 0; return 0;
err_icmpmsg_mib:
snmp_mib_free((void **)net->mib.icmpv6_statistics);
err_icmp_mib:
snmp_mib_free((void **)net->mib.ipv6_statistics);
err_ip_mib:
snmp_mib_free((void **)net->mib.udplite_stats_in6);
err_udplite_mib: err_udplite_mib:
snmp_mib_free((void **)net->mib.udp_stats_in6); snmp_mib_free((void **)net->mib.udp_stats_in6);
return -ENOMEM; return -ENOMEM;
...@@ -843,6 +838,9 @@ static void __net_exit ipv6_cleanup_mibs(struct net *net) ...@@ -843,6 +838,9 @@ static void __net_exit ipv6_cleanup_mibs(struct net *net)
{ {
snmp_mib_free((void **)net->mib.udp_stats_in6); snmp_mib_free((void **)net->mib.udp_stats_in6);
snmp_mib_free((void **)net->mib.udplite_stats_in6); snmp_mib_free((void **)net->mib.udplite_stats_in6);
snmp_mib_free((void **)net->mib.ipv6_statistics);
snmp_mib_free((void **)net->mib.icmpv6_statistics);
snmp_mib_free((void **)net->mib.icmpv6msg_statistics);
} }
static int inet6_net_init(struct net *net) static int inet6_net_init(struct net *net)
......
...@@ -177,9 +177,11 @@ static int snmp6_seq_show(struct seq_file *seq, void *v) ...@@ -177,9 +177,11 @@ static int snmp6_seq_show(struct seq_file *seq, void *v)
{ {
struct net *net = (struct net *)seq->private; struct net *net = (struct net *)seq->private;
snmp6_seq_show_item(seq, (void **)ipv6_statistics, snmp6_ipstats_list); snmp6_seq_show_item(seq, (void **)net->mib.ipv6_statistics,
snmp6_seq_show_item(seq, (void **)icmpv6_statistics, snmp6_icmp6_list); snmp6_ipstats_list);
snmp6_seq_show_icmpv6msg(seq, (void **)icmpv6msg_statistics); snmp6_seq_show_item(seq, (void **)net->mib.icmpv6_statistics,
snmp6_icmp6_list);
snmp6_seq_show_icmpv6msg(seq, (void **)net->mib.icmpv6msg_statistics);
snmp6_seq_show_item(seq, (void **)net->mib.udp_stats_in6, snmp6_seq_show_item(seq, (void **)net->mib.udp_stats_in6,
snmp6_udp6_list); snmp6_udp6_list);
snmp6_seq_show_item(seq, (void **)net->mib.udplite_stats_in6, snmp6_seq_show_item(seq, (void **)net->mib.udplite_stats_in6,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册