diff options
author | Jeff Barnhill <0xeffeff@gmail.com> | 2018-04-05 17:29:47 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-04-05 22:23:43 -0400 |
commit | 71a1c915238c970cd9bdd5bf158b1279d6b6d55b (patch) | |
tree | d04926ef528f98f576d3d5aed87ebcb410ee122f | |
parent | a2aeea1cc14f9143f973b99950f39b38be144f3e (diff) |
net/ipv6: Increment OUTxxx counters after netfilter hook
At the end of ip6_forward(), IPSTATS_MIB_OUTFORWDATAGRAMS and
IPSTATS_MIB_OUTOCTETS are incremented immediately before the NF_HOOK call
for NFPROTO_IPV6 / NF_INET_FORWARD. As a result, these counters get
incremented regardless of whether or not the netfilter hook allows the
packet to continue being processed. This change increments the counters
in ip6_forward_finish() so that it will not happen if the netfilter hook
chooses to terminate the packet, which is similar to how IPv4 works.
Signed-off-by: Jeff Barnhill <0xeffeff@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/ipv6/ip6_output.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index b8ee50e94af3..2e891d2c30ef 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c | |||
@@ -375,6 +375,11 @@ static int ip6_forward_proxy_check(struct sk_buff *skb) | |||
375 | static inline int ip6_forward_finish(struct net *net, struct sock *sk, | 375 | static inline int ip6_forward_finish(struct net *net, struct sock *sk, |
376 | struct sk_buff *skb) | 376 | struct sk_buff *skb) |
377 | { | 377 | { |
378 | struct dst_entry *dst = skb_dst(skb); | ||
379 | |||
380 | __IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS); | ||
381 | __IP6_ADD_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTOCTETS, skb->len); | ||
382 | |||
378 | return dst_output(net, sk, skb); | 383 | return dst_output(net, sk, skb); |
379 | } | 384 | } |
380 | 385 | ||
@@ -569,8 +574,6 @@ int ip6_forward(struct sk_buff *skb) | |||
569 | 574 | ||
570 | hdr->hop_limit--; | 575 | hdr->hop_limit--; |
571 | 576 | ||
572 | __IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS); | ||
573 | __IP6_ADD_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTOCTETS, skb->len); | ||
574 | return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD, | 577 | return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD, |
575 | net, NULL, skb, skb->dev, dst->dev, | 578 | net, NULL, skb, skb->dev, dst->dev, |
576 | ip6_forward_finish); | 579 | ip6_forward_finish); |