From mboxrd@z Thu Jan 1 00:00:00 1970 From: Eric Dumazet Subject: Re: [net-next PATCH v2 4/8] udp: Do not pass checksum as a parameter to GSO segmentation Date: Fri, 4 May 2018 13:19:15 -0700 Message-ID: <52c9b572-ddcd-94ea-b9b6-787ca924698a@gmail.com> References: <20180504182537.5194.72775.stgit@localhost.localdomain> <20180504182958.5194.62398.stgit@localhost.localdomain> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit To: Alexander Duyck , netdev@vger.kernel.org, willemb@google.com, davem@davemloft.net Return-path: Received: from mail-pf0-f182.google.com ([209.85.192.182]:32906 "EHLO mail-pf0-f182.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751522AbeEDUTS (ORCPT ); Fri, 4 May 2018 16:19:18 -0400 Received: by mail-pf0-f182.google.com with SMTP id f20so9477068pfn.0 for ; Fri, 04 May 2018 13:19:18 -0700 (PDT) In-Reply-To: <20180504182958.5194.62398.stgit@localhost.localdomain> Content-Language: en-US Sender: netdev-owner@vger.kernel.org List-ID: On 05/04/2018 11:30 AM, Alexander Duyck wrote: > From: Alexander Duyck > > This patch is meant to allow us to avoid having to recompute the checksum > from scratch and have it passed as a parameter. > > Instead of taking that approach we can take advantage of the fact that the > length that was used to compute the existing checksum is included in the > UDP header. If we cancel that out by adding the value XOR with 0xFFFF we > can then just add the new length in and fold that into the new result. > > > + uh = udp_hdr(segs); > + > + /* compute checksum adjustment based on old length versus new */ > + newlen = htons(sizeof(*uh) + mss); > + check = ~csum_fold((__force __wsum)((__force u32)uh->check + > + ((__force u32)uh->len ^ 0xFFFF) + > + (__force u32)newlen)); > + Can't this use csum_sub() instead of this ^ 0xFFFF trick ?