From: "Rafał Miłecki" <zajec5@gmail.com>
To: openwrt-devel@lists.openwrt.org,
Eric Dumazet <edumazet@google.com>,
"David S . Miller" <davem@davemloft.net>,
Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org>,
David Ahern <dsahern@kernel.org>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
"Rafał Miłecki" <rafal@milecki.pl>
Subject: [PATCH] net: gro: respect nf_conntrack_checksum for skipping csum verification
Date: Fri, 10 Jun 2022 12:36:53 +0200 [thread overview]
Message-ID: <20220610103653.15261-1-zajec5@gmail.com> (raw)
From: Rafał Miłecki <rafal@milecki.pl>
Netfilter allows disabling checksum verification of incoming packets by
setting nf_conntrack_checksum variable. That feature is very useful for
home routers which:
1. Most of the time just /forward/ network traffic
2. Have slow CPU(s) and csum calculation is a challenge
Some projects like OpenWrt set nf_conntrack_checksum to 0 by default.
It would be nice to allow similar optimization in the GRO code paths.
This patch simply reuses nf_conntrack_checksum variable to skip
skb_gro_checksum_validate() calls if applicable.
Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
Hi guys,
I'm not very familiar with net subsystem, please let me know if there is
a better way of implementing such a feature.
---
net/ipv4/tcp_offload.c | 3 +++
net/ipv6/tcpv6_offload.c | 3 +++
2 files changed, 6 insertions(+)
diff --git a/net/ipv4/tcp_offload.c b/net/ipv4/tcp_offload.c
index 30abde86db45..734a3c0f3d4a 100644
--- a/net/ipv4/tcp_offload.c
+++ b/net/ipv4/tcp_offload.c
@@ -311,6 +311,9 @@ struct sk_buff *tcp4_gro_receive(struct list_head *head, struct sk_buff *skb)
{
/* Don't bother verifying checksum if we're going to flush anyway. */
if (!NAPI_GRO_CB(skb)->flush &&
+#if IS_ENABLED(CONFIG_NF_CONNTRACK)
+ dev_net(skb->dev)->ct.sysctl_checksum &&
+#endif
skb_gro_checksum_validate(skb, IPPROTO_TCP,
inet_gro_compute_pseudo)) {
NAPI_GRO_CB(skb)->flush = 1;
diff --git a/net/ipv6/tcpv6_offload.c b/net/ipv6/tcpv6_offload.c
index 39db5a226855..2144afa56fa3 100644
--- a/net/ipv6/tcpv6_offload.c
+++ b/net/ipv6/tcpv6_offload.c
@@ -18,6 +18,9 @@ struct sk_buff *tcp6_gro_receive(struct list_head *head, struct sk_buff *skb)
{
/* Don't bother verifying checksum if we're going to flush anyway. */
if (!NAPI_GRO_CB(skb)->flush &&
+#if IS_ENABLED(CONFIG_NF_CONNTRACK)
+ dev_net(skb->dev)->ct.sysctl_checksum &&
+#endif
skb_gro_checksum_validate(skb, IPPROTO_TCP,
ip6_gro_compute_pseudo)) {
NAPI_GRO_CB(skb)->flush = 1;
--
2.34.1
next reply other threads:[~2022-06-10 10:42 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-10 10:36 Rafał Miłecki [this message]
2022-06-10 14:08 ` Eric Dumazet
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=20220610103653.15261-1-zajec5@gmail.com \
--to=zajec5@gmail.com \
--cc=davem@davemloft.net \
--cc=dsahern@kernel.org \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=openwrt-devel@lists.openwrt.org \
--cc=pabeni@redhat.com \
--cc=rafal@milecki.pl \
--cc=yoshfuji@linux-ipv6.org \
/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
all inboxes | Powered by JetHome®