From: Praveen Chaudhary <praveen5582@gmail.com>
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 <zxu@linkedin.com>, Andy Stracner <astracner@linkedin.com>
Subject: [PATCH] [netfilter]: Fix skb->csum calculation when netfilter manipulation for NF_NAT_MANIP_SRC\DST is done on IPV6 packet.
Date: Wed, 23 Oct 2019 12:02:22 -0700 [thread overview]
Message-ID: <1571857342-8407-2-git-send-email-pchaudhary@linkedin.com> (raw)
In-Reply-To: <1571857342-8407-1-git-send-email-pchaudhary@linkedin.com>
Update skb->csum, when netfilter code updates IPV6 SRC\DST address in IPV6 HEADER due to iptable rule.
Signed-off-by: Praveen Chaudhary <pchaudhary@linkedin.com>
Signed-off-by: Zhenggen Xu <zxu@linkedin.com>
Signed-off-by: Andy Stracner <astracner@linkedin.com>
---
include/net/checksum.h | 2 ++
net/core/utils.c | 13 +++++++++++++
net/netfilter/nf_nat_proto.c | 2 ++
3 files changed, 17 insertions(+)
diff --git a/include/net/checksum.h b/include/net/checksum.h
index 97bf488..d7d28b7 100644
--- a/include/net/checksum.h
+++ b/include/net/checksum.h
@@ -145,6 +145,8 @@ void inet_proto_csum_replace4(__sum16 *sum, struct sk_buff *skb,
void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb,
const __be32 *from, const __be32 *to,
bool pseudohdr);
+void inet_proto_skb_csum_replace16(struct sk_buff *skb,
+ const __be32 *from, const __be32 *to);
void inet_proto_csum_replace_by_diff(__sum16 *sum, struct sk_buff *skb,
__wsum diff, bool pseudohdr);
diff --git a/net/core/utils.c b/net/core/utils.c
index 6b6e51d..ab3284b 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -458,6 +458,19 @@ void inet_proto_csum_replace16(__sum16 *sum, struct sk_buff *skb,
}
EXPORT_SYMBOL(inet_proto_csum_replace16);
+void inet_proto_skb_csum_replace16(struct sk_buff *skb,
+ const __be32 *from, const __be32 *to)
+{
+ __be32 diff[] = {
+ ~from[0], ~from[1], ~from[2], ~from[3],
+ to[0], to[1], to[2], to[3],
+ };
+ if (skb->ip_summed == CHECKSUM_COMPLETE)
+ skb->csum = csum_partial(diff, sizeof(diff),
+ skb->csum);
+}
+EXPORT_SYMBOL(inet_proto_skb_csum_replace16);
+
void inet_proto_csum_replace_by_diff(__sum16 *sum, struct sk_buff *skb,
__wsum diff, bool pseudohdr)
{
diff --git a/net/netfilter/nf_nat_proto.c b/net/netfilter/nf_nat_proto.c
index 0a59c14..de94590 100644
--- a/net/netfilter/nf_nat_proto.c
+++ b/net/netfilter/nf_nat_proto.c
@@ -467,6 +467,8 @@ static void nf_nat_ipv6_csum_update(struct sk_buff *skb,
}
inet_proto_csum_replace16(check, skb, oldip->s6_addr32,
newip->s6_addr32, true);
+ inet_proto_skb_csum_replace16(skb, oldip->s6_addr32,
+ newip->s6_addr32);
#endif
}
--
2.7.4
next prev parent reply other threads:[~2019-10-23 19:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-23 19:02 [PATCH] " Praveen Chaudhary
2019-10-23 19:02 ` Praveen Chaudhary [this message]
2019-10-23 19:33 ` [PATCH] [netfilter]: " Florian Westphal
2019-10-23 20:56 ` [PATCH] [netfilter]: Fix skb->csum calculation when netfilter Praveen Chaudhary
[not found] ` <CAJ_cd4qHM3kqz24Uywpyyz0mPz7axiNZk0Q385ROd4O8XZ11fA@mail.gmail.com>
2019-10-24 1:12 ` [PATCH] [netfilter]: Fix skb->csum calculation when netfilter manipulation for NF_NAT_MANIP_SRC\DST is done on IPV6 packet Florian Westphal
2019-10-24 5:19 ` [netfilter]: Fix skb->csum calculation when netfilter Praveen Chaudhary
2019-10-28 22:27 [PATCH] [netfilter]: Fix skb->csum calculation when netfilter manipulation for NF_NAT_MANIP_SRC\DST is done on IPV6 packet Praveen Chaudhary
2019-10-28 22:27 ` Praveen Chaudhary
2019-10-29 16:09 ` Florian Westphal
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1571857342-8407-2-git-send-email-pchaudhary@linkedin.com \
--to=praveen5582@gmail.com \
--cc=astracner@linkedin.com \
--cc=davem@davemloft.net \
--cc=fw@strlen.de \
--cc=kadlec@netfilter.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pablo@netfilter.org \
--cc=zxu@linkedin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome