Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

snmp: fix OutOctets counter to include forwarded datagrams

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>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Vincent Bernat and committed by
David S. Miller
2d8dbb04 278f015e

+5
+1
net/ipv4/ip_forward.c
··· 44 44 struct ip_options *opt = &(IPCB(skb)->opt); 45 45 46 46 IP_INC_STATS_BH(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTFORWDATAGRAMS); 47 + IP_ADD_STATS_BH(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTOCTETS, skb->len); 47 48 48 49 if (unlikely(opt->optlen)) 49 50 ip_forward_options(skb);
+1
net/ipv4/ipmr.c
··· 1574 1574 struct ip_options *opt = &(IPCB(skb)->opt); 1575 1575 1576 1576 IP_INC_STATS_BH(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTFORWDATAGRAMS); 1577 + IP_ADD_STATS_BH(dev_net(skb_dst(skb)->dev), IPSTATS_MIB_OUTOCTETS, skb->len); 1577 1578 1578 1579 if (unlikely(opt->optlen)) 1579 1580 ip_forward_options(skb);
+1
net/ipv6/ip6_output.c
··· 526 526 hdr->hop_limit--; 527 527 528 528 IP6_INC_STATS_BH(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS); 529 + IP6_ADD_STATS_BH(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTOCTETS, skb->len); 529 530 return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD, skb, skb->dev, dst->dev, 530 531 ip6_forward_finish); 531 532
+2
net/ipv6/ip6mr.c
··· 1886 1886 { 1887 1887 IP6_INC_STATS_BH(dev_net(skb_dst(skb)->dev), ip6_dst_idev(skb_dst(skb)), 1888 1888 IPSTATS_MIB_OUTFORWDATAGRAMS); 1889 + IP6_ADD_STATS_BH(dev_net(skb_dst(skb)->dev), ip6_dst_idev(skb_dst(skb)), 1890 + IPSTATS_MIB_OUTOCTETS, skb->len); 1889 1891 return dst_output(skb); 1890 1892 } 1891 1893