Commit 1db8a26a authored by Hideaki Yoshifuji's avatar Hideaki Yoshifuji

[IPV4] use ip-independent ipstats_mib to store IPv4 statistics.

parent 84a4a805
......@@ -150,7 +150,7 @@ struct ipv4_config
};
extern struct ipv4_config ipv4_config;
DECLARE_SNMP_STAT(struct ip_mib, ip_statistics);
DECLARE_SNMP_STAT(struct ipstats_mib, ip_statistics);
#define IP_INC_STATS(field) SNMP_INC_STATS(ip_statistics, field)
#define IP_INC_STATS_BH(field) SNMP_INC_STATS_BH(ip_statistics, field)
#define IP_INC_STATS_USER(field) SNMP_INC_STATS_USER(ip_statistics, field)
......
......@@ -60,30 +60,6 @@ struct snmp_item {
* RFC 1213: MIB-II
* RFC 2011 (updates 1213): SNMPv2-MIB-IP
* RFC 2863: Interfaces Group MIB
*/
struct ip_mib
{
unsigned long IpInReceives;
unsigned long IpInHdrErrors;
unsigned long IpInAddrErrors;
unsigned long IpForwDatagrams;
unsigned long IpInUnknownProtos;
unsigned long IpInDiscards;
unsigned long IpInDelivers;
unsigned long IpOutRequests;
unsigned long IpOutDiscards;
unsigned long IpOutNoRoutes;
unsigned long IpReasmTimeout;
unsigned long IpReasmReqds;
unsigned long IpReasmOKs;
unsigned long IpReasmFails;
unsigned long IpFragOKs;
unsigned long IpFragFails;
unsigned long IpFragCreates;
unsigned long __pad[0];
};
/*
* RFC 2465: IPv6 MIB: General Group
* draft-ietf-ipv6-rfc2011-update-10.txt: MIB for IP: IP Statistics Tables
*/
......
......@@ -1066,8 +1066,8 @@ static int __init init_ipv4_mibs(void)
{
net_statistics[0] = alloc_percpu(struct linux_mib);
net_statistics[1] = alloc_percpu(struct linux_mib);
ip_statistics[0] = alloc_percpu(struct ip_mib);
ip_statistics[1] = alloc_percpu(struct ip_mib);
ip_statistics[0] = alloc_percpu(struct ipstats_mib);
ip_statistics[1] = alloc_percpu(struct ipstats_mib);
icmp_statistics[0] = alloc_percpu(struct icmp_mib);
icmp_statistics[1] = alloc_percpu(struct icmp_mib);
tcp_statistics[0] = alloc_percpu(struct tcp_mib);
......
......@@ -46,7 +46,7 @@ static inline int ip_forward_finish(struct sk_buff *skb)
{
struct ip_options * opt = &(IPCB(skb)->opt);
IP_INC_STATS_BH(IpForwDatagrams);
IP_INC_STATS_BH(OutForwDatagrams);
if (unlikely(opt->optlen))
ip_forward_options(skb);
......
......@@ -263,7 +263,7 @@ static void ip_evictor(void)
spin_unlock(&qp->lock);
ipq_put(qp);
IP_INC_STATS_BH(IpReasmFails);
IP_INC_STATS_BH(ReasmFails);
}
}
......@@ -281,8 +281,8 @@ static void ip_expire(unsigned long arg)
ipq_kill(qp);
IP_INC_STATS_BH(IpReasmTimeout);
IP_INC_STATS_BH(IpReasmFails);
IP_INC_STATS_BH(ReasmTimeout);
IP_INC_STATS_BH(ReasmFails);
if ((qp->last_in&FIRST_IN) && qp->fragments != NULL) {
struct sk_buff *head = qp->fragments;
......@@ -609,7 +609,7 @@ static struct sk_buff *ip_frag_reasm(struct ipq *qp, struct net_device *dev)
iph = head->nh.iph;
iph->frag_off = 0;
iph->tot_len = htons(len);
IP_INC_STATS_BH(IpReasmOKs);
IP_INC_STATS_BH(ReasmOKs);
qp->fragments = NULL;
return head;
......@@ -625,7 +625,7 @@ static struct sk_buff *ip_frag_reasm(struct ipq *qp, struct net_device *dev)
"Oversized IP packet from %d.%d.%d.%d.\n",
NIPQUAD(qp->saddr));
out_fail:
IP_INC_STATS_BH(IpReasmFails);
IP_INC_STATS_BH(ReasmFails);
return NULL;
}
......@@ -636,7 +636,7 @@ struct sk_buff *ip_defrag(struct sk_buff *skb)
struct ipq *qp;
struct net_device *dev;
IP_INC_STATS_BH(IpReasmReqds);
IP_INC_STATS_BH(ReasmReqds);
/* Start by cleaning up the memory. */
if (atomic_read(&ip_frag_mem) > sysctl_ipfrag_high_thresh)
......@@ -661,7 +661,7 @@ struct sk_buff *ip_defrag(struct sk_buff *skb)
return ret;
}
IP_INC_STATS_BH(IpReasmFails);
IP_INC_STATS_BH(ReasmFails);
kfree_skb(skb);
return NULL;
}
......
......@@ -150,7 +150,7 @@
* SNMP management statistics
*/
DEFINE_SNMP_STAT(struct ip_mib, ip_statistics);
DEFINE_SNMP_STAT(struct ipstats_mib, ip_statistics);
/*
* Process Router Attention IP option
......@@ -249,16 +249,16 @@ static inline int ip_local_deliver_finish(struct sk_buff *skb)
protocol = -ret;
goto resubmit;
}
IP_INC_STATS_BH(IpInDelivers);
IP_INC_STATS_BH(InDelivers);
} else {
if (!raw_sk) {
if (xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
IP_INC_STATS_BH(IpInUnknownProtos);
IP_INC_STATS_BH(InUnknownProtos);
icmp_send(skb, ICMP_DEST_UNREACH,
ICMP_PROT_UNREACH, 0);
}
} else
IP_INC_STATS_BH(IpInDelivers);
IP_INC_STATS_BH(InDelivers);
kfree_skb(skb);
}
}
......@@ -324,7 +324,7 @@ static inline int ip_rcv_finish(struct sk_buff *skb)
*/
if (skb_cow(skb, skb_headroom(skb))) {
IP_INC_STATS_BH(IpInDiscards);
IP_INC_STATS_BH(InDiscards);
goto drop;
}
iph = skb->nh.iph;
......@@ -353,7 +353,7 @@ static inline int ip_rcv_finish(struct sk_buff *skb)
return dst_input(skb);
inhdr_error:
IP_INC_STATS_BH(IpInHdrErrors);
IP_INC_STATS_BH(InHdrErrors);
drop:
kfree_skb(skb);
return NET_RX_DROP;
......@@ -372,10 +372,10 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt)
if (skb->pkt_type == PACKET_OTHERHOST)
goto drop;
IP_INC_STATS_BH(IpInReceives);
IP_INC_STATS_BH(InReceives);
if ((skb = skb_share_check(skb, GFP_ATOMIC)) == NULL) {
IP_INC_STATS_BH(IpInDiscards);
IP_INC_STATS_BH(InDiscards);
goto out;
}
......@@ -426,7 +426,7 @@ int ip_rcv(struct sk_buff *skb, struct net_device *dev, struct packet_type *pt)
ip_rcv_finish);
inhdr_error:
IP_INC_STATS_BH(IpInHdrErrors);
IP_INC_STATS_BH(InHdrErrors);
drop:
kfree_skb(skb);
out:
......
......@@ -232,7 +232,7 @@ int ip_mc_output(struct sk_buff *skb)
/*
* If the indicated interface is up and running, send the packet.
*/
IP_INC_STATS(IpOutRequests);
IP_INC_STATS(OutRequests);
skb->dev = dev;
skb->protocol = htons(ETH_P_IP);
......@@ -285,7 +285,7 @@ int ip_mc_output(struct sk_buff *skb)
int ip_output(struct sk_buff *skb)
{
IP_INC_STATS(IpOutRequests);
IP_INC_STATS(OutRequests);
if ((skb->len > dst_pmtu(skb->dst) || skb_shinfo(skb)->frag_list) &&
!skb_shinfo(skb)->tso_size)
......@@ -390,7 +390,7 @@ int ip_queue_xmit(struct sk_buff *skb, int ipfragok)
dst_output);
no_route:
IP_INC_STATS(IpOutNoRoutes);
IP_INC_STATS(OutNoRoutes);
kfree_skb(skb);
return -EHOSTUNREACH;
}
......@@ -547,7 +547,7 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
}
if (err == 0) {
IP_INC_STATS(IpFragOKs);
IP_INC_STATS(FragOKs);
return 0;
}
......@@ -556,7 +556,7 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
kfree_skb(frag);
frag = skb;
}
IP_INC_STATS(IpFragFails);
IP_INC_STATS(FragFails);
return err;
}
......@@ -662,7 +662,7 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
* Put this fragment into the sending queue.
*/
IP_INC_STATS(IpFragCreates);
IP_INC_STATS(FragCreates);
iph->tot_len = htons(len + hlen);
......@@ -673,12 +673,12 @@ int ip_fragment(struct sk_buff *skb, int (*output)(struct sk_buff*))
goto fail;
}
kfree_skb(skb);
IP_INC_STATS(IpFragOKs);
IP_INC_STATS(FragOKs);
return err;
fail:
kfree_skb(skb);
IP_INC_STATS(IpFragFails);
IP_INC_STATS(FragFails);
return err;
}
......@@ -975,7 +975,7 @@ int ip_append_data(struct sock *sk,
error:
inet->cork.length -= length;
IP_INC_STATS(IpOutDiscards);
IP_INC_STATS(OutDiscards);
return err;
}
......@@ -1088,7 +1088,7 @@ ssize_t ip_append_page(struct sock *sk, struct page *page,
error:
inet->cork.length -= size;
IP_INC_STATS(IpOutDiscards);
IP_INC_STATS(OutDiscards);
return err;
}
......@@ -1198,7 +1198,7 @@ int ip_push_pending_frames(struct sock *sk)
return err;
error:
IP_INC_STATS(IpOutDiscards);
IP_INC_STATS(OutDiscards);
goto out;
}
......
......@@ -1115,7 +1115,7 @@ static inline int ipmr_forward_finish(struct sk_buff *skb)
{
struct ip_options * opt = &(IPCB(skb)->opt);
IP_INC_STATS_BH(IpForwDatagrams);
IP_INC_STATS_BH(OutForwDatagrams);
if (unlikely(opt->optlen))
ip_forward_options(skb);
......@@ -1178,7 +1178,7 @@ static void ipmr_queue_xmit(struct sk_buff *skb, struct mfc_cache *c, int vifi)
to blackhole.
*/
IP_INC_STATS_BH(IpFragFails);
IP_INC_STATS_BH(FragFails);
ip_rt_put(rt);
goto out_free;
}
......
......@@ -88,7 +88,7 @@ static struct file_operations sockstat_seq_fops = {
};
static unsigned long
fold_field(void *mib[], int nr)
__fold_field(void *mib[], int offt)
{
unsigned long res = 0;
int i;
......@@ -98,14 +98,41 @@ fold_field(void *mib[], int nr)
continue;
res +=
*((unsigned long *) (((void *) per_cpu_ptr(mib[0], i)) +
sizeof (unsigned long) * nr));
offt));
res +=
*((unsigned long *) (((void *) per_cpu_ptr(mib[1], i)) +
sizeof (unsigned long) * nr));
offt));
}
return res;
}
#define fold_field(_mib, _nr) __fold_field(_mib, (sizeof(unsigned long) * (_nr)))
/* snmp items */
static struct snmp_item snmp4_ipstats_list[] = {
#define __SNMP_GEN(x,y) SNMP_ITEM(struct ipstats_mib, x, y)
#define SNMP_GEN(x) __SNMP_GEN(x, #x)
SNMP_GEN(InReceives),
SNMP_GEN(InHdrErrors),
SNMP_GEN(InAddrErrors),
__SNMP_GEN(OutForwDatagrams,"ForwDatagrams"), /* for backward compatibility */
SNMP_GEN(InUnknownProtos),
SNMP_GEN(InDiscards),
SNMP_GEN(InDelivers),
SNMP_GEN(OutRequests),
SNMP_GEN(OutDiscards),
SNMP_GEN(OutNoRoutes),
SNMP_GEN(ReasmTimeout),
SNMP_GEN(ReasmReqds),
SNMP_GEN(ReasmOKs),
SNMP_GEN(ReasmFails),
SNMP_GEN(FragOKs),
SNMP_GEN(FragFails),
SNMP_GEN(FragCreates),
SNMP_ITEM_SENTINEL
#undef SNMP_GEN
};
/*
* Called from the PROCfs module. This outputs /proc/net/snmp.
*/
......@@ -113,17 +140,18 @@ static int snmp_seq_show(struct seq_file *seq, void *v)
{
int i;
seq_printf(seq, "Ip: Forwarding DefaultTTL InReceives InHdrErrors "
"InAddrErrors ForwDatagrams InUnknownProtos "
"InDiscards InDelivers OutRequests OutDiscards "
"OutNoRoutes ReasmTimeout ReasmReqds ReasmOKs "
"ReasmFails FragOKs FragFails FragCreates\nIp: %d %d",
seq_printf(seq, "Ip: Forwarding DefaultTTL");
for (i = 0; snmp4_ipstats_list[i].name != NULL; i++)
seq_printf(seq, " %s", snmp4_ipstats_list[i].name);
seq_printf(seq, "\nIp: %d %d",
ipv4_devconf.forwarding ? 1 : 2, sysctl_ip_default_ttl);
for (i = 0;
i < offsetof(struct ip_mib, __pad) / sizeof(unsigned long); i++)
for (i = 0; snmp4_ipstats_list[i].name != NULL; i++)
seq_printf(seq, " %lu",
fold_field((void **) ip_statistics, i));
__fold_field((void **) ip_statistics,
snmp4_ipstats_list[i].offset));
seq_printf(seq, "\nIcmp: InMsgs InErrors InDestUnreachs InTimeExcds "
"InParmProbs InSrcQuenchs InRedirects InEchos "
......
......@@ -319,7 +319,7 @@ static int raw_send_hdrinc(struct sock *sk, void *from, int length,
err = -EFAULT;
kfree_skb(skb);
error:
IP_INC_STATS(IpOutDiscards);
IP_INC_STATS(OutDiscards);
return err;
}
......
......@@ -1290,12 +1290,12 @@ static struct dst_entry* tcp_v4_route_req(struct sock *sk,
.dport = req->rmt_port } } };
if (ip_route_output_flow(&rt, &fl, sk, 0)) {
IP_INC_STATS_BH(IpOutNoRoutes);
IP_INC_STATS_BH(OutNoRoutes);
return NULL;
}
if (opt && opt->is_strictroute && rt->rt_dst != rt->rt_gateway) {
ip_rt_put(rt);
IP_INC_STATS_BH(IpOutNoRoutes);
IP_INC_STATS_BH(OutNoRoutes);
return NULL;
}
return &rt->u.dst;
......
......@@ -496,7 +496,7 @@ int sctp_packet_transmit(struct sctp_packet *packet)
return err;
no_route:
kfree_skb(nskb);
IP_INC_STATS_BH(IpOutNoRoutes);
IP_INC_STATS_BH(OutNoRoutes);
/* FIXME: Returning the 'err' will effect all the associations
* associated with a socket, although only one of the paths of the
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment