* [PATCH] snmp: fix OutOctets counter to include forwarded datagrams
@ 2012-06-05 13:41 Vincent Bernat
2012-06-07 21:53 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Vincent Bernat @ 2012-06-05 13:41 UTC (permalink / raw)
To: netdev; +Cc: davem, yoshfuji, Vincent Bernat
RFC 4293 defines ipIfStatsOutOctets (similar definition for
ipSystemStatsOutOctets):
The total number of octets in IP datagrams delivered to the lower
layers for transmission. Octets from datagrams counted in
ipIfStatsOutTransmits MUST be counted here.
And ipIfStatsOutTransmits:
The total number of IP datagrams that this entity supplied to the
lower layers for transmission. This includes datagrams generated
locally and those forwarded by this entity.
Therefore, IPSTATS_MIB_OUTOCTETS must be incremented when incrementing
IPSTATS_MIB_OUTFORWDATAGRAMS.
IP_UPD_PO_STATS is not used since ipIfStatsOutRequests must not
include forwarded datagrams:
The total number of IP datagrams that local IP user-protocols
(including ICMP) supplied to IP in requests for transmission. Note
that this counter does not include any datagrams counted in
ipIfStatsOutForwDatagrams.
Signed-off-by: Vincent Bernat <bernat@luffy.cx>
---
net/ipv4/ip_forward.c | 1 +
net/ipv4/ipmr.c | 1 +
net/ipv6/ip6_output.c | 1 +
net/ipv6/ip6mr.c | 2 ++
4 files changed, 5 insertions(+)
diff --git a/net/ipv4/ip_forward.c b/net/ipv4/ip_forward.c
index e5c44fc..ab09b12 100644
--- a/net/ipv4/ip_forward.c
+++ b/net/ipv4/ip_forward.c
@@ -44,6 +44,7 @@ static int ip_forward_finish(struct sk_buff *skb)
struct ip_options *opt = &(IPCB(skb)->opt);
IP_INC_STATS_BH(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTFORWDATAGRAMS);
+ IP_ADD_STATS_BH(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTOCTETS, skb->len);
if (unlikely(opt->optlen))
ip_forward_options(skb);
diff --git a/net/ipv4/ipmr.c b/net/ipv4/ipmr.c
index a9e519a..c94bbc6 100644
--- a/net/ipv4/ipmr.c
+++ b/net/ipv4/ipmr.c
@@ -1574,6 +1574,7 @@ static inline int ipmr_forward_finish(struct sk_buff *skb)
struct ip_options *opt = &(IPCB(skb)->opt);
IP_INC_STATS_BH(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTFORWDATAGRAMS);
+ IP_ADD_STATS_BH(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTOCTETS, skb->len);
if (unlikely(opt->optlen))
ip_forward_options(skb);
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 17b8c67..decc21d1 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -526,6 +526,7 @@ int ip6_forward(struct sk_buff *skb)
hdr->hop_limit--;
IP6_INC_STATS_BH(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS);
+ IP6_ADD_STATS_BH(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTOCTETS, skb->len);
return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD, skb, skb->dev, dst->dev,
ip6_forward_finish);
diff --git a/net/ipv6/ip6mr.c b/net/ipv6/ip6mr.c
index b15dc08..461e47c 100644
--- a/net/ipv6/ip6mr.c
+++ b/net/ipv6/ip6mr.c
@@ -1886,6 +1886,8 @@ static inline int ip6mr_forward2_finish(struct sk_buff *skb)
{
IP6_INC_STATS_BH(dev_net(skb_dst(skb)->dev), ip6_dst_idev(skb_dst(skb)),
IPSTATS_MIB_OUTFORWDATAGRAMS);
+ IP6_ADD_STATS_BH(dev_net(skb_dst(skb)->dev), ip6_dst_idev(skb_dst(skb)),
+ IPSTATS_MIB_OUTOCTETS, skb->len);
return dst_output(skb);
}
--
1.7.10
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] snmp: fix OutOctets counter to include forwarded datagrams
2012-06-05 13:41 [PATCH] snmp: fix OutOctets counter to include forwarded datagrams Vincent Bernat
@ 2012-06-07 21:53 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2012-06-07 21:53 UTC (permalink / raw)
To: bernat; +Cc: netdev, yoshfuji
From: Vincent Bernat <bernat@luffy.cx>
Date: Tue, 5 Jun 2012 15:41:42 +0200
> RFC 4293 defines ipIfStatsOutOctets (similar definition for
> ipSystemStatsOutOctets):
>
> The total number of octets in IP datagrams delivered to the lower
> layers for transmission. Octets from datagrams counted in
> ipIfStatsOutTransmits MUST be counted here.
>
> And ipIfStatsOutTransmits:
>
> The total number of IP datagrams that this entity supplied to the
> lower layers for transmission. This includes datagrams generated
> locally and those forwarded by this entity.
>
> Therefore, IPSTATS_MIB_OUTOCTETS must be incremented when incrementing
> IPSTATS_MIB_OUTFORWDATAGRAMS.
>
> IP_UPD_PO_STATS is not used since ipIfStatsOutRequests must not
> include forwarded datagrams:
>
> The total number of IP datagrams that local IP user-protocols
> (including ICMP) supplied to IP in requests for transmission. Note
> that this counter does not include any datagrams counted in
> ipIfStatsOutForwDatagrams.
>
> Signed-off-by: Vincent Bernat <bernat@luffy.cx>
Applied, thanks for the detailed analysis.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-06-07 21:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-05 13:41 [PATCH] snmp: fix OutOctets counter to include forwarded datagrams Vincent Bernat
2012-06-07 21:53 ` David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).