Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp4631286ybg; Tue, 29 Oct 2019 10:01:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqzO/aTC6ljk/uzYdroBIEyfHQU1etoX39h4UGGcXsOfix42ID/YnZ7N4aTu3oTzH/zcQvyS X-Received: by 2002:a1c:27c7:: with SMTP id n190mr4816182wmn.106.1572368501826; Tue, 29 Oct 2019 10:01:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572368501; cv=none; d=google.com; s=arc-20160816; b=ECVJiTzhClBpFbgowC+54t7cXuc7cXaaskPElRkPqzTfBUNyddzktQB1DwWzvTNA6V j0YsETC6iIttWLXnT64sNAiiMJucmDRfTafqC+A3QHlTGxUIVSVuBAzeI/EuXnG+ENRG gQi6q9HGP54XgYmUceH7zC0vCAjEyHsvp2DP5NqFSPxnkFsHWrS4FQE+rMq00pg34DTX j9UuwvvSm4iU6qFBdEaK4IgFguajuHhNKTUmRBugORLojNs17DyQB1Wj9nkno2/18Och KdzAstbpmaZTGOzR0AWGQ+reM/3p3lqEgvDLPAn45HOSazg5VELqSaF57gUADDzdkNNO p0Fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=KCNhk6Yyd07rDJH7lQx7kz/Ad42c+i5/xKh7Sj0sJEQ=; b=ti3+kwNQg9jmmnTGJ26xxmVuf+LR9m66MZ2P0AHev+9farHSIYuvtNSTrp9iLkzKBI PAasDlLcqs5GDfKpzCWbYeU18hC/6iJ+d+1Zj79dI7zLtELpEXq7r5dlgCVD054+30IU +Npyf5JtSBxoh70I4CmKMOb3POZFdrPbCteCYa58vFx2p82ZCSZ7fV7M8oOo0K4fPsPC lhcEwDbwpBIGy/oeehdaoC90DfculiPuxwwIo242no42m7VItys72YEHkkoXwAKqXEXI 6EFlQNEjKrtWQM2sSz9eb5QuvtMsO/xFnTlapnYRULdyMeTTQuMnNZ+alIHyqdYnwHYT pHeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QR0rThkg; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e4si12693366edc.146.2019.10.29.10.01.15; Tue, 29 Oct 2019 10:01:41 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=QR0rThkg; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390818AbfJ2Q72 (ORCPT + 99 others); Tue, 29 Oct 2019 12:59:28 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:40553 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390785AbfJ2Q71 (ORCPT ); Tue, 29 Oct 2019 12:59:27 -0400 Received: by mail-pg1-f194.google.com with SMTP id 15so9993698pgt.7; Tue, 29 Oct 2019 09:59:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=KCNhk6Yyd07rDJH7lQx7kz/Ad42c+i5/xKh7Sj0sJEQ=; b=QR0rThkgr8CuA3Iz9x+OXG2n78b36W+SuAbts3NDbG0QugZD3+iKZfrjKTIxXbaBtC C+Y6ycxu2c4G1d7oH8fpdHVux43AaGxUNwIBbVKg0DEoKZPW9lbljtjM7PzUKBYcdmnX Uaj9bTD0PMb2Uo3W8VQrDFmvFlr5M2/G8GvxrJVWH0uEqqBWwE6Yp4ogLheYYTWe3bTF zXbM0V5Osw3sOkV/Iu7hp6w7CHkf5NzK4U7LU/sgSTT9EGYT6XYMb8IjDlN9+JcdMqcY qZWOEbR4QLn7OZ3sjjGgubCgxNyRQLrOMtKixAn0yUvUT3OOJiHm73RfCNkbqcK3mjES l47w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=KCNhk6Yyd07rDJH7lQx7kz/Ad42c+i5/xKh7Sj0sJEQ=; b=qwa1TJaiooPtocFUXI79zeQTGMzkcgn5ce5DwHqUl9nkQJgvFg5Fnd06cDTD1QlCip qAcagkwLKiE3E0WpCxDe8feorCeGjdhoclHxap4wXkDf/jQLlNaiVT8tsK4G2oxhF4m5 rKg8HFpSxHAn7x9SW2G28M7UyT6K9eARbWYjFjok7gWEyZKmQ7ZGtDSJz4W4ngV7Q1dr icLvmrGM9AhmvNqtCuT7bLgGIQvdzBonNkWfmnoX8lGeZ4D6KckQ5/RTaJr/I/GToZp8 1pJtFaNU8jLaf0UlsxOaacOtI3Vx2zDN5nrgpTNgryugCaAEgNZNPAABRtsqR7iNwTZf qPcw== X-Gm-Message-State: APjAAAXrPUjZbGr4uXEIBOx1mjM4QU33jUtyv7HVpGgZfkCfoGzQqWkC KLdtTds+WhB4HpWUYzcBdw== X-Received: by 2002:aa7:908b:: with SMTP id i11mr29026643pfa.140.1572368364864; Tue, 29 Oct 2019 09:59:24 -0700 (PDT) Received: from localhost.localdomain ([216.52.21.4]) by smtp.gmail.com with ESMTPSA id w6sm14384147pfw.84.2019.10.29.09.59.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 29 Oct 2019 09:59:24 -0700 (PDT) From: Praveen Chaudhary X-Google-Original-From: Praveen Chaudhary To: fw@strlen.de, davem@davemloft.net, kadlec@netfilter.org, pablo@netfilter.org, netfilter-devel@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Zhenggen Xu , Andy Stracner Subject: [PATCH v2] [netfilter]: Fix skb->csum calculation when netfilter manipulation for NF_NAT_MANIP_SRC\DST is done on IPV6 packet. Date: Tue, 29 Oct 2019 09:59:11 -0700 Message-Id: <1572368351-3156-2-git-send-email-pchaudhary@linkedin.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1572368351-3156-1-git-send-email-pchaudhary@linkedin.com> References: <1572368351-3156-1-git-send-email-pchaudhary@linkedin.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org No need to update skb->csum in function inet_proto_csum_replace16(), even if skb->ip_summed == CHECKSUM_COMPLETE, because change in L4 header checksum field and change in IPV6 header cancels each other for skb->csum calculation. Signed-off-by: Praveen Chaudhary Signed-off-by: Zhenggen Xu Signed-off-by: Andy Stracner Reviewed-by: Florian Westphal --- Changes in V2. 1.) Updating diff as per email discussion with Florian Westphal. Since inet_proto_csum_replace16() does incorrect calculation for skb->csum in all cases. 2.) Change in Commmit logs. --- --- net/core/utils.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/net/core/utils.c b/net/core/utils.c index 6b6e51d..cec9924 100644 --- a/net/core/utils.c +++ b/net/core/utils.c @@ -438,6 +438,12 @@ void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb, } EXPORT_SYMBOL(inet_proto_csum_replace4); +/** + * No need to update skb->csum in this function, even if + * skb->ip_summed == CHECKSUM_COMPLETE, because change in + * L4 header checksum field and change in IPV6 header + * cancels each other for skb->csum calculation. + */ void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb, const __be32 *from, const __be32 *to, bool pseudohdr) @@ -449,9 +455,6 @@ void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb, if (skb->ip_summed != CHECKSUM_PARTIAL) { *sum = csum_fold(csum_partial(diff, sizeof(diff), ~csum_unfold(*sum))); - if (skb->ip_summed == CHECKSUM_COMPLETE && pseudohdr) - skb->csum = ~csum_partial(diff, sizeof(diff), - ~skb->csum); } else if (pseudohdr) *sum = ~csum_fold(csum_partial(diff, sizeof(diff), csum_unfold(*sum))); -- 2.7.4