diff options
author | Denis V. Lunev <den@openvz.org> | 2008-10-08 13:36:03 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-10-08 14:16:45 -0400 |
commit | 9261e53701121f83eb9482347d68833e95315362 (patch) | |
tree | 9e3ba61bb72233eb544bc22ebd29a0dafa90a89e | |
parent | 087fe24033c4280a15b03cce41eaec844c92f8e5 (diff) |
ipv6: making ip and icmp statistics per/namespace
Signed-off-by: Denis V. Lunev <den@openvz.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/ipv6.h | 10 | ||||
-rw-r--r-- | include/net/netns/mib.h | 3 | ||||
-rw-r--r-- | net/ipv6/af_inet6.c | 38 | ||||
-rw-r--r-- | net/ipv6/proc.c | 8 |
4 files changed, 28 insertions, 31 deletions
diff --git a/include/net/ipv6.h b/include/net/ipv6.h index d0538dd2c44b..6d5b58a1c743 100644 --- a/include/net/ipv6.h +++ b/include/net/ipv6.h | |||
@@ -113,23 +113,20 @@ extern struct ctl_path net_ipv6_ctl_path[]; | |||
113 | #define _DEVINC(net, statname, modifier, idev, field) \ | 113 | #define _DEVINC(net, statname, modifier, idev, field) \ |
114 | ({ \ | 114 | ({ \ |
115 | struct inet6_dev *_idev = (idev); \ | 115 | struct inet6_dev *_idev = (idev); \ |
116 | (void)(net); \ | ||
117 | if (likely(_idev != NULL)) \ | 116 | if (likely(_idev != NULL)) \ |
118 | SNMP_INC_STATS##modifier((_idev)->stats.statname, (field)); \ | 117 | SNMP_INC_STATS##modifier((_idev)->stats.statname, (field)); \ |
119 | SNMP_INC_STATS##modifier(statname##_statistics, (field)); \ | 118 | SNMP_INC_STATS##modifier((net)->mib.statname##_statistics, (field));\ |
120 | }) | 119 | }) |
121 | 120 | ||
122 | #define _DEVADD(net, statname, modifier, idev, field, val) \ | 121 | #define _DEVADD(net, statname, modifier, idev, field, val) \ |
123 | ({ \ | 122 | ({ \ |
124 | struct inet6_dev *_idev = (idev); \ | 123 | struct inet6_dev *_idev = (idev); \ |
125 | (void)(net); \ | ||
126 | if (likely(_idev != NULL)) \ | 124 | if (likely(_idev != NULL)) \ |
127 | SNMP_ADD_STATS##modifier((_idev)->stats.statname, (field), (val)); \ | 125 | SNMP_ADD_STATS##modifier((_idev)->stats.statname, (field), (val)); \ |
128 | SNMP_ADD_STATS##modifier(statname##_statistics, (field), (val));\ | 126 | SNMP_ADD_STATS##modifier((net)->mib.statname##_statistics, (field), (val));\ |
129 | }) | 127 | }) |
130 | 128 | ||
131 | /* MIBs */ | 129 | /* MIBs */ |
132 | DECLARE_SNMP_STAT(struct ipstats_mib, ipv6_statistics); | ||
133 | 130 | ||
134 | #define IP6_INC_STATS(net, idev,field) \ | 131 | #define IP6_INC_STATS(net, idev,field) \ |
135 | _DEVINC(net, ipv6, , idev, field) | 132 | _DEVINC(net, ipv6, , idev, field) |
@@ -138,9 +135,6 @@ DECLARE_SNMP_STAT(struct ipstats_mib, ipv6_statistics); | |||
138 | #define IP6_ADD_STATS_BH(net, idev,field,val) \ | 135 | #define IP6_ADD_STATS_BH(net, idev,field,val) \ |
139 | _DEVADD(net, ipv6, _BH, idev, field, val) | 136 | _DEVADD(net, ipv6, _BH, idev, field, val) |
140 | 137 | ||
141 | DECLARE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics); | ||
142 | DECLARE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics); | ||
143 | |||
144 | #define ICMP6_INC_STATS(net, idev, field) \ | 138 | #define ICMP6_INC_STATS(net, idev, field) \ |
145 | _DEVINC(net, icmpv6, , idev, field) | 139 | _DEVINC(net, icmpv6, , idev, field) |
146 | #define ICMP6_INC_STATS_BH(net, idev, field) \ | 140 | #define ICMP6_INC_STATS_BH(net, idev, field) \ |
diff --git a/include/net/netns/mib.h b/include/net/netns/mib.h index 4e58f0519ce8..10cb7c336de5 100644 --- a/include/net/netns/mib.h +++ b/include/net/netns/mib.h | |||
@@ -16,6 +16,9 @@ struct netns_mib { | |||
16 | struct proc_dir_entry *proc_net_devsnmp6; | 16 | struct proc_dir_entry *proc_net_devsnmp6; |
17 | DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6); | 17 | DEFINE_SNMP_STAT(struct udp_mib, udp_stats_in6); |
18 | DEFINE_SNMP_STAT(struct udp_mib, udplite_stats_in6); | 18 | DEFINE_SNMP_STAT(struct udp_mib, udplite_stats_in6); |
19 | DEFINE_SNMP_STAT(struct ipstats_mib, ipv6_statistics); | ||
20 | DEFINE_SNMP_STAT(struct icmpv6_mib, icmpv6_statistics); | ||
21 | DEFINE_SNMP_STAT(struct icmpv6msg_mib, icmpv6msg_statistics); | ||
19 | #endif | 22 | #endif |
20 | }; | 23 | }; |
21 | 24 | ||
diff --git a/net/ipv6/af_inet6.c b/net/ipv6/af_inet6.c index 127b240d2d81..6b509d7700de 100644 --- a/net/ipv6/af_inet6.c +++ b/net/ipv6/af_inet6.c | |||
@@ -797,31 +797,11 @@ static void ipv6_packet_cleanup(void) | |||
797 | 797 | ||
798 | static int __init init_ipv6_mibs(void) | 798 | static int __init init_ipv6_mibs(void) |
799 | { | 799 | { |
800 | if (snmp_mib_init((void **)ipv6_statistics, | ||
801 | sizeof(struct ipstats_mib)) < 0) | ||
802 | goto err_ip_mib; | ||
803 | if (snmp_mib_init((void **)icmpv6_statistics, | ||
804 | sizeof(struct icmpv6_mib)) < 0) | ||
805 | goto err_icmp_mib; | ||
806 | if (snmp_mib_init((void **)icmpv6msg_statistics, | ||
807 | sizeof(struct icmpv6msg_mib)) < 0) | ||
808 | goto err_icmpmsg_mib; | ||
809 | return 0; | 800 | return 0; |
810 | |||
811 | err_icmpmsg_mib: | ||
812 | snmp_mib_free((void **)icmpv6_statistics); | ||
813 | err_icmp_mib: | ||
814 | snmp_mib_free((void **)ipv6_statistics); | ||
815 | err_ip_mib: | ||
816 | return -ENOMEM; | ||
817 | |||
818 | } | 801 | } |
819 | 802 | ||
820 | static void cleanup_ipv6_mibs(void) | 803 | static void cleanup_ipv6_mibs(void) |
821 | { | 804 | { |
822 | snmp_mib_free((void **)ipv6_statistics); | ||
823 | snmp_mib_free((void **)icmpv6_statistics); | ||
824 | snmp_mib_free((void **)icmpv6msg_statistics); | ||
825 | } | 805 | } |
826 | 806 | ||
827 | static int __net_init ipv6_init_mibs(struct net *net) | 807 | 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 | if (snmp_mib_init((void **)net->mib.udplite_stats_in6, | 812 | if (snmp_mib_init((void **)net->mib.udplite_stats_in6, |
833 | sizeof (struct udp_mib)) < 0) | 813 | sizeof (struct udp_mib)) < 0) |
834 | goto err_udplite_mib; | 814 | goto err_udplite_mib; |
815 | if (snmp_mib_init((void **)net->mib.ipv6_statistics, | ||
816 | sizeof(struct ipstats_mib)) < 0) | ||
817 | goto err_ip_mib; | ||
818 | if (snmp_mib_init((void **)net->mib.icmpv6_statistics, | ||
819 | sizeof(struct icmpv6_mib)) < 0) | ||
820 | goto err_icmp_mib; | ||
821 | if (snmp_mib_init((void **)net->mib.icmpv6msg_statistics, | ||
822 | sizeof(struct icmpv6msg_mib)) < 0) | ||
823 | goto err_icmpmsg_mib; | ||
835 | return 0; | 824 | return 0; |
836 | 825 | ||
826 | err_icmpmsg_mib: | ||
827 | snmp_mib_free((void **)net->mib.icmpv6_statistics); | ||
828 | err_icmp_mib: | ||
829 | snmp_mib_free((void **)net->mib.ipv6_statistics); | ||
830 | err_ip_mib: | ||
831 | snmp_mib_free((void **)net->mib.udplite_stats_in6); | ||
837 | err_udplite_mib: | 832 | err_udplite_mib: |
838 | snmp_mib_free((void **)net->mib.udp_stats_in6); | 833 | snmp_mib_free((void **)net->mib.udp_stats_in6); |
839 | return -ENOMEM; | 834 | return -ENOMEM; |
@@ -843,6 +838,9 @@ static void __net_exit ipv6_cleanup_mibs(struct net *net) | |||
843 | { | 838 | { |
844 | snmp_mib_free((void **)net->mib.udp_stats_in6); | 839 | snmp_mib_free((void **)net->mib.udp_stats_in6); |
845 | snmp_mib_free((void **)net->mib.udplite_stats_in6); | 840 | snmp_mib_free((void **)net->mib.udplite_stats_in6); |
841 | snmp_mib_free((void **)net->mib.ipv6_statistics); | ||
842 | snmp_mib_free((void **)net->mib.icmpv6_statistics); | ||
843 | snmp_mib_free((void **)net->mib.icmpv6msg_statistics); | ||
846 | } | 844 | } |
847 | 845 | ||
848 | static int inet6_net_init(struct net *net) | 846 | static int inet6_net_init(struct net *net) |
diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index c78cf754ef3f..07f0b76e7427 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c | |||
@@ -177,9 +177,11 @@ static int snmp6_seq_show(struct seq_file *seq, void *v) | |||
177 | { | 177 | { |
178 | struct net *net = (struct net *)seq->private; | 178 | struct net *net = (struct net *)seq->private; |
179 | 179 | ||
180 | snmp6_seq_show_item(seq, (void **)ipv6_statistics, snmp6_ipstats_list); | 180 | snmp6_seq_show_item(seq, (void **)net->mib.ipv6_statistics, |
181 | snmp6_seq_show_item(seq, (void **)icmpv6_statistics, snmp6_icmp6_list); | 181 | snmp6_ipstats_list); |
182 | snmp6_seq_show_icmpv6msg(seq, (void **)icmpv6msg_statistics); | 182 | snmp6_seq_show_item(seq, (void **)net->mib.icmpv6_statistics, |
183 | snmp6_icmp6_list); | ||
184 | snmp6_seq_show_icmpv6msg(seq, (void **)net->mib.icmpv6msg_statistics); | ||
183 | snmp6_seq_show_item(seq, (void **)net->mib.udp_stats_in6, | 185 | snmp6_seq_show_item(seq, (void **)net->mib.udp_stats_in6, |
184 | snmp6_udp6_list); | 186 | snmp6_udp6_list); |
185 | snmp6_seq_show_item(seq, (void **)net->mib.udplite_stats_in6, | 187 | snmp6_seq_show_item(seq, (void **)net->mib.udplite_stats_in6, |