提交 923c6586 编写于 作者: P Pavel Emelyanov 提交者: David S. Miller

mib: put icmpmsg statistics on struct net

Signed-off-by: NPavel Emelyanov <xemul@openvz.org>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 b60538a0
......@@ -29,11 +29,10 @@ struct icmp_err {
};
extern struct icmp_err icmp_err_convert[];
DECLARE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics);
#define ICMP_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.icmp_statistics, field)
#define ICMP_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.icmp_statistics, field)
#define ICMPMSGOUT_INC_STATS(net, field) SNMP_INC_STATS(icmpmsg_statistics, field+256)
#define ICMPMSGIN_INC_STATS_BH(net, field) SNMP_INC_STATS_BH(icmpmsg_statistics, field)
#define ICMPMSGOUT_INC_STATS(net, field) SNMP_INC_STATS((net)->mib.icmpmsg_statistics, field+256)
#define ICMPMSGIN_INC_STATS_BH(net, field) SNMP_INC_STATS_BH((net)->mib.icmpmsg_statistics, field)
struct dst_entry;
struct net_proto_family;
......
......@@ -10,6 +10,7 @@ struct netns_mib {
DEFINE_SNMP_STAT(struct udp_mib, udp_statistics);
DEFINE_SNMP_STAT(struct udp_mib, udplite_statistics);
DEFINE_SNMP_STAT(struct icmp_mib, icmp_statistics);
DEFINE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics);
};
#endif
......@@ -1358,10 +1358,15 @@ static __net_init int ipv4_mib_init_net(struct net *net)
if (snmp_mib_init((void **)net->mib.icmp_statistics,
sizeof(struct icmp_mib)) < 0)
goto err_icmp_mib;
if (snmp_mib_init((void **)net->mib.icmpmsg_statistics,
sizeof(struct icmpmsg_mib)) < 0)
goto err_icmpmsg_mib;
tcp_mib_init(net);
return 0;
err_icmpmsg_mib:
snmp_mib_free((void **)net->mib.icmp_statistics);
err_icmp_mib:
snmp_mib_free((void **)net->mib.udplite_statistics);
err_udplite_mib:
......@@ -1378,6 +1383,7 @@ static __net_init int ipv4_mib_init_net(struct net *net)
static __net_exit void ipv4_mib_exit_net(struct net *net)
{
snmp_mib_free((void **)net->mib.icmpmsg_statistics);
snmp_mib_free((void **)net->mib.icmp_statistics);
snmp_mib_free((void **)net->mib.udplite_statistics);
snmp_mib_free((void **)net->mib.udp_statistics);
......@@ -1393,18 +1399,12 @@ static __net_initdata struct pernet_operations ipv4_mib_ops = {
static int __init init_ipv4_mibs(void)
{
if (snmp_mib_init((void **)icmpmsg_statistics,
sizeof(struct icmpmsg_mib)) < 0)
goto err_icmpmsg_mib;
if (register_pernet_subsys(&ipv4_mib_ops))
goto err_net;
return 0;
err_net:
snmp_mib_free((void **)icmpmsg_statistics);
err_icmpmsg_mib:
return -ENOMEM;
}
......
......@@ -111,11 +111,6 @@ struct icmp_bxm {
unsigned char optbuf[40];
};
/*
* Statistics
*/
DEFINE_SNMP_STAT(struct icmpmsg_mib, icmpmsg_statistics) __read_mostly;
/* An array of errno for error messages from dest unreach. */
/* RFC 1122: 3.2.2.1 States that NET_UNREACH, HOST_UNREACH and SR_FAILED MUST be considered 'transient errs'. */
......
......@@ -270,7 +270,7 @@ static void icmpmsg_put(struct seq_file *seq)
count = 0;
for (i = 0; i < ICMPMSG_MIB_MAX; i++) {
if (snmp_fold_field((void **) icmpmsg_statistics, i))
if (snmp_fold_field((void **) init_net.mib.icmpmsg_statistics, i))
out[count++] = i;
if (count < PERLINE)
continue;
......@@ -282,7 +282,7 @@ static void icmpmsg_put(struct seq_file *seq)
seq_printf(seq, "\nIcmpMsg: ");
for (j = 0; j < PERLINE; ++j)
seq_printf(seq, " %lu",
snmp_fold_field((void **) icmpmsg_statistics,
snmp_fold_field((void **) init_net.mib.icmpmsg_statistics,
out[j]));
seq_putc(seq, '\n');
}
......@@ -294,7 +294,7 @@ static void icmpmsg_put(struct seq_file *seq)
seq_printf(seq, "\nIcmpMsg:");
for (j = 0; j < count; ++j)
seq_printf(seq, " %lu", snmp_fold_field((void **)
icmpmsg_statistics, out[j]));
init_net.mib.icmpmsg_statistics, out[j]));
}
#undef PERLINE
......@@ -315,14 +315,14 @@ static void icmp_put(struct seq_file *seq)
snmp_fold_field((void **) init_net.mib.icmp_statistics, ICMP_MIB_INERRORS));
for (i=0; icmpmibmap[i].name != NULL; i++)
seq_printf(seq, " %lu",
snmp_fold_field((void **) icmpmsg_statistics,
snmp_fold_field((void **) init_net.mib.icmpmsg_statistics,
icmpmibmap[i].index));
seq_printf(seq, " %lu %lu",
snmp_fold_field((void **) init_net.mib.icmp_statistics, ICMP_MIB_OUTMSGS),
snmp_fold_field((void **) init_net.mib.icmp_statistics, ICMP_MIB_OUTERRORS));
for (i=0; icmpmibmap[i].name != NULL; i++)
seq_printf(seq, " %lu",
snmp_fold_field((void **) icmpmsg_statistics,
snmp_fold_field((void **) init_net.mib.icmpmsg_statistics,
icmpmibmap[i].index | 0x100));
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册