Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3983040ybg; Mon, 28 Oct 2019 23:55:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyPONAxau9NtWTZ6t1S4mBIm43yI4LH7CkkX2LwMwtH9k8D1ebcy41a5S8F1Uf4PWVLq0F7 X-Received: by 2002:aa7:dc49:: with SMTP id g9mr11254185edu.62.1572332103331; Mon, 28 Oct 2019 23:55:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572332103; cv=none; d=google.com; s=arc-20160816; b=I6L4LDOYBiS74naKdhDxvGibhxbm1ON5AsVT59mu5ZvtizweF8hPdf1YtvAjAgB5c2 B0Qjt156ISBGMSgyAxLfb2vc2YkSdnJTiSbJNPCF5KJxpGW58VMXmQHeSXbWml3XiRP7 FechsSpz2JRMEddtLMDQLmWaSx8U/tQ0WTCzpsh05ryk1mm/QjU2Py3+6izjgdrmiUxE v5cJ49Ke+QNoi8RgC9/XLgFmVT2Ft6QpGyRAPFYHpavBCDH6kk5MTZ/un3QLAbCvJvTa 1ACsW1L9VwLjc5ttIdO0QZwdRZQ14w6YaSawCv42roUeCgLg8AUwINn0Y0B4tFGcEcWu TqmQ== 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=SLsHdSpGVghNKZAiodqcIoULrVap1KUhD8kKjq3mW3w=; b=V19PWM0iklHHslWtAx0DOrGVsxmUT7oYp0Gcr2Aafs7tcnHw1AGaWY3zc8iz/YgpDI JSiSV3+ji3lM/+ZiVxpcuBalFuC+KH+/w+y62v8vPJGWA072CHryqWZryYRNYhCDCgUp KYgKmfFZZxqcV9W0MJXcHiXXEtLFeohy6kDb7uQbrGvVIWEL9Y0imJrbk/II9X6zD9HF DOqvGae9AZRJVtSLN0nddfLTE/sI93NHONG2oUiY1pcQrc8Y6SIf2/74HRIJ1xAPffVk d9f06btYAF0zWmsbE7888E9XUrxdFYocLFDjjuRCkh7egCl/NvxF+l36dZzk5RKuEQ8p dJgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=etrXUoao; 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 q24si7127298ejr.128.2019.10.28.23.54.39; Mon, 28 Oct 2019 23:55:03 -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=etrXUoao; 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 S1728739AbfJ1W2L (ORCPT + 99 others); Mon, 28 Oct 2019 18:28:11 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:35234 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726940AbfJ1W2K (ORCPT ); Mon, 28 Oct 2019 18:28:10 -0400 Received: by mail-pl1-f196.google.com with SMTP id x6so2383947pln.2; Mon, 28 Oct 2019 15:28:09 -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=SLsHdSpGVghNKZAiodqcIoULrVap1KUhD8kKjq3mW3w=; b=etrXUoaoXhqfA3Q1EsxZxmK/UylppXThWsAkHLSrPRyhpTBBcNvvrE9zjHDnKQQ909 CODjX43WiLRzKgDae2iOOmxdsD2wf8ZF6cQQn5ax8Kuu9sfgxEqiTHiXGhczYhK2kBbM yn0X1x1JBOnNKgAiBB0oK33KGoExQKL+qx81qpuXBjeg/FNu9F4PL9bQNFlT+TVryPVj QM+40wMH5Azwuk4fVktYRVE+hEtsXzs7nWoulBTwtGh1oeE+U439MoTXq51IhxlwEnaR IiNX+DoUOyRWbwsphzgtR5kIdeUxXxdkR+75rRqckCxygdljuI4CobNSflzV63cjQAB5 Kv7A== 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=SLsHdSpGVghNKZAiodqcIoULrVap1KUhD8kKjq3mW3w=; b=Sr52vXa+41f5OM+a9V7iOb+q2syf+FK1D/ZzGCArfrRyJskDpW9pi6ED4eWxTCqWbi omAVc5/z63PSjIcET4yRHUt/y1kAcjm9IBTNaxqIAVc/aDJGPkyXVe1S2ATwtLtQITdR mwfRbLgQqzcnxaNxnI0qzytKrnIqe4mLrrxS5BL0c9/mGY38GErASVdt8WRQ0GHzHF6e NYpvOfVl/mE4VDbYmC/4vxZLYwm9o44Z3YVlzR2ak2iv/BRuvWSXfwHdUwFvFtnpzTWo sNTj67pw/Gij4fYJPb+JI7RjxoeCFIHKarq2bmxIi9poGgJbOuXaFc1HrckNdAAInvsN xfEg== X-Gm-Message-State: APjAAAXl77y3wu+tcdrLsmh0y5U/mJqOvXElGFT5UA9u08ZorBwl3OZM Qz0QfIluE/kWcqufu3ZdAQ== X-Received: by 2002:a17:902:6901:: with SMTP id j1mr402271plk.185.1572301688154; Mon, 28 Oct 2019 15:28:08 -0700 (PDT) Received: from localhost.localdomain ([216.52.21.4]) by smtp.gmail.com with ESMTPSA id p4sm483060pjo.3.2019.10.28.15.28.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Oct 2019 15:28:07 -0700 (PDT) From: Praveen Chaudhary X-Google-Original-From: Praveen Chaudhary To: davem@davemloft.net, fw@strlen.de, kadlec@netfilter.org, pablo@netfilter.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Zhenggen Xu , Andy Stracner Subject: [PATCH] [netfilter]: Fix skb->csum calculation when netfilter manipulation for NF_NAT_MANIP_SRC\DST is done on IPV6 packet. Date: Mon, 28 Oct 2019 15:27:55 -0700 Message-Id: <1572301675-5403-2-git-send-email-pchaudhary@linkedin.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1572301675-5403-1-git-send-email-pchaudhary@linkedin.com> References: <1572301675-5403-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 --- 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