* [PATCH net-next] udp: Avoid post-GRO UDP checksum recalculation
@ 2019-05-23 19:36 Sean Tranchetti
2019-05-24 12:50 ` Paolo Abeni
2019-05-25 17:53 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Sean Tranchetti @ 2019-05-23 19:36 UTC (permalink / raw)
To: davem, netdev
Cc: Sean Tranchetti, Paolo Abeni, Subash Abhinov Kasiviswanathan
Currently, when resegmenting an unexpected UDP GRO packet, the full UDP
checksum will be calculated for every new SKB created by skb_segment()
because the netdev features passed in by udp_rcv_segment() lack any
information about checksum offload capabilities.
We have no need to perform this calculation again, as
1) The GRO implementation guarantees that any packets making it to the
udp_rcv_segment() function had correct checksums, and, more
importantly,
2) Upon the successful return of udp_rcv_segment(), we immediately pull
the UDP header off and either queue the segment to the socket or
hand it off to a new protocol handler. In either case, the checksum
is not needed.
Fixes: cf329aa42b66 ("udp: cope with UDP GRO packet misdirection")
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Subash Abhinov Kasiviswanathan <subashab@codeaurora.org>
Signed-off-by: Sean Tranchetti <stranche@codeaurora.org>
---
include/net/udp.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/include/net/udp.h b/include/net/udp.h
index d8ce937..6164d5c 100644
--- a/include/net/udp.h
+++ b/include/net/udp.h
@@ -472,11 +472,15 @@ static inline struct sk_buff *udp_rcv_segment(struct sock *sk,
struct sk_buff *skb, bool ipv4)
{
struct sk_buff *segs;
+ netdev_features_t features = NETIF_F_SG;
+
+ /* Avoid csum recalculation in skb_segment() */
+ features |= NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM;
/* the GSO CB lays after the UDP one, no need to save and restore any
* CB fragment
*/
- segs = __skb_gso_segment(skb, NETIF_F_SG, false);
+ segs = __skb_gso_segment(skb, features, false);
if (unlikely(IS_ERR_OR_NULL(segs))) {
int segs_nr = skb_shinfo(skb)->gso_segs;
--
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] udp: Avoid post-GRO UDP checksum recalculation
2019-05-23 19:36 [PATCH net-next] udp: Avoid post-GRO UDP checksum recalculation Sean Tranchetti
@ 2019-05-24 12:50 ` Paolo Abeni
2019-05-25 17:53 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Paolo Abeni @ 2019-05-24 12:50 UTC (permalink / raw)
To: Sean Tranchetti, davem, netdev; +Cc: Subash Abhinov Kasiviswanathan
On Thu, 2019-05-23 at 13:36 -0600, Sean Tranchetti wrote:
> Currently, when resegmenting an unexpected UDP GRO packet, the full UDP
> checksum will be calculated for every new SKB created by skb_segment()
> because the netdev features passed in by udp_rcv_segment() lack any
> information about checksum offload capabilities.
>
> We have no need to perform this calculation again, as
> 1) The GRO implementation guarantees that any packets making it to the
> udp_rcv_segment() function had correct checksums, and, more
> importantly,
> 2) Upon the successful return of udp_rcv_segment(), we immediately pull
> the UDP header off and either queue the segment to the socket or
> hand it off to a new protocol handler. In either case, the checksum
> is not needed.
I *think* there is a possible, even if unlikely, exception to the
above: if userspace has set the IP_CHECKSUM sockopt, recvmsg can later
try to access skb csum.
I think that setting NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM only if
!inet_get_convert_csum() would address the above,
Other than that LGTM, thanks for catching this!
Paolo
p.s. I suspect that with this patch GRO + resegmentation is notably
faster than the plain unaggregated path, do you have by chance any
related datapoint?
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] udp: Avoid post-GRO UDP checksum recalculation
2019-05-23 19:36 [PATCH net-next] udp: Avoid post-GRO UDP checksum recalculation Sean Tranchetti
2019-05-24 12:50 ` Paolo Abeni
@ 2019-05-25 17:53 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-05-25 17:53 UTC (permalink / raw)
To: stranche; +Cc: netdev, pabeni, subashab
From: Sean Tranchetti <stranche@codeaurora.org>
Date: Thu, 23 May 2019 13:36:17 -0600
> @@ -472,11 +472,15 @@ static inline struct sk_buff *udp_rcv_segment(struct sock *sk,
> struct sk_buff *skb, bool ipv4)
> {
> struct sk_buff *segs;
> + netdev_features_t features = NETIF_F_SG;
When you respin this based upon Paolo's feedback, please reverse christmas
tree these local variables.
Thank you.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-05-25 17:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-23 19:36 [PATCH net-next] udp: Avoid post-GRO UDP checksum recalculation Sean Tranchetti
2019-05-24 12:50 ` Paolo Abeni
2019-05-25 17:53 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.