Received: by 10.192.165.156 with SMTP id m28csp1087033imm; Wed, 11 Apr 2018 12:09:39 -0700 (PDT) X-Google-Smtp-Source: AIpwx48Q2cFQlJqInwBjHnO6wpnQ2uWOp45bHzqdukDhtDvTyKoOQbIP9jhTWmvfijB5aZBO/rlj X-Received: by 2002:a17:902:8602:: with SMTP id f2-v6mr6215994plo.73.1523473779254; Wed, 11 Apr 2018 12:09:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523473779; cv=none; d=google.com; s=arc-20160816; b=RYB2w9IOFztG9N+KIvLf/E9fV72eZjsETGAiECrV8rUubZcTI5l7MD+Bxg6+lWY1HO G0+Da/hSyl2AE3+43v7UTgpK6n6NBgrD1EKDpHss0/eAqE2MOY3/fzlLn/Yv+vbtC+Xj 6T6iH5zuA+Vcksb42BezmenPTr33m0buLiezOsZ4ZYw3zXhiYPBMJ3NW8kqvUOvfW6bT +/xcmq344F1wQ8if7vEa13EnHltkAcUd2lZBab+nk55mOUOb0DNPQJQv0OLqqXWcpHtJ lNEx/x0dPVfkptdoa+3r7d7DuIs8haj2I+wnMXrEfHCwWT1V7rB6HPSrsqIZsQbWnZrB vVJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=EpRVY6GVumQdKWOX6uJLfzOc0EUOJh5ttGIuP040aWE=; b=eBWRj+/MRF3wCVWdOdwSn7Y8vTCh/AI62mrGVbce9IGaFbfz4hhOuhGyxtIDZbuemd 8C9FsWPsL1s1KrIZTdu2g6cdh/JJDrDYz94N2Cg3CVYx3ER0na1QVnv/TB//qE9jO7M+ 0I6XT9NOImLm5h4qmftvjWtyH1c0UVsokh5lRRA8exzs6SRkT35iaPY+2NlmTTgnizB6 eN9eGVPHUMLdZ4ha90lcyV7kIW0WCewxxWYYY07ZlDeVwjQgHNummuARWoWXoMwuhqiy 5alVsL9I6AzM2FXKRcHZpf5jOR1PDo05QRqB7MpVpaqtEmCDruSf92Y4RaOG7huq74S1 42xA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1-v6si1644213plw.143.2018.04.11.12.09.02; Wed, 11 Apr 2018 12:09:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935062AbeDKTFd (ORCPT + 99 others); Wed, 11 Apr 2018 15:05:33 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:40498 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934041AbeDKTFa (ORCPT ); Wed, 11 Apr 2018 15:05:30 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7C8ADCE3; Wed, 11 Apr 2018 19:05:29 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jeff Barnhill <0xeffeff@gmail.com>, "David S. Miller" Subject: [PATCH 4.9 280/310] net/ipv6: Increment OUTxxx counters after netfilter hook Date: Wed, 11 Apr 2018 20:36:59 +0200 Message-Id: <20180411183634.663528011@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180411183622.305902791@linuxfoundation.org> References: <20180411183622.305902791@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jeff Barnhill <0xeffeff@gmail.com> [ Upstream commit 71a1c915238c970cd9bdd5bf158b1279d6b6d55b ] 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 Signed-off-by: Greg Kroah-Hartman --- net/ipv6/ip6_output.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -356,6 +356,11 @@ static int ip6_forward_proxy_check(struc static inline int ip6_forward_finish(struct net *net, struct sock *sk, struct sk_buff *skb) { + struct dst_entry *dst = skb_dst(skb); + + __IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS); + __IP6_ADD_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTOCTETS, skb->len); + return dst_output(net, sk, skb); } @@ -549,8 +554,6 @@ int ip6_forward(struct sk_buff *skb) hdr->hop_limit--; - __IP6_INC_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTFORWDATAGRAMS); - __IP6_ADD_STATS(net, ip6_dst_idev(dst), IPSTATS_MIB_OUTOCTETS, skb->len); return NF_HOOK(NFPROTO_IPV6, NF_INET_FORWARD, net, NULL, skb, skb->dev, dst->dev, ip6_forward_finish);