net: gro: respect nf_conntrack_checksum for skipping csum verification
Subsystems (3)
PATCH 1/1 net: gro: respect nf_conntrack_checksum for skipping csum verification
From: Rafał Miłecki <[email protected]>
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.
---
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(+)
net/ipv4/tcp_offload.c +3 -0
@@ -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 && +#endifskb_gro_checksum_validate (skb,IPPROTO_TCP , inet_gro_compute_pseudo)) {NAPI_GRO_CB (skb)->flush =1 ;
net/ipv6/tcpv6_offload.c +3 -0
@@ -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 && +#endifskb_gro_checksum_validate (skb,IPPROTO_TCP , ip6_gro_compute_pseudo)) {NAPI_GRO_CB (skb)->flush =1 ;
Signature · 1 line
2.34.1
Quoted 9 lines · Rafał Miłecki
From: Rafał Miłecki <[email protected]>
Netfilter allows disabling checksum verification of incoming packets by setting
nf_conntrack_checksumvariable. 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
Quoted 6 lines
Some projects like OpenWrt set
nf_conntrack_checksumto 0 by default.It would be nice to allow similar optimization in the GRO code paths. This patch simply reuses
nf_conntrack_checksumvariable to skipskb_gro_checksum_validate()calls if applicable.
Problem is that GRO will be followed by TSO on the egress side.
TSO will generate segments with recomputed checksums for each one of them.
GRO only keeps one copy of the headers, so does not track original checksums for all
segments at ingress side.
So if you want to use TSO, GRO has to validate checksums.
I am afraid this nf_conntrack_checksum idea can not be transposed to GRO.
Quoted 42 lines
Signed-off-by Rafał Miłecki <[email protected]>---
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(+)net/ipv4/tcp_offload.c +3
-0@@ -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 && +#endifskb_gro_checksum_validate (skb,IPPROTO_TCP , inet_gro_compute_pseudo)) {NAPI_GRO_CB (skb)->flush =1 ;net/ipv6/tcpv6_offload.c +3
-1@@ -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 && +#endifskb_gro_checksum_validate (skb,IPPROTO_TCP , ip6_gro_compute_pseudo)) {NAPI_GRO_CB (skb)->flush =1 ; --2.34.1