Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2527565rdb; Fri, 8 Dec 2023 10:35:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFksomMpfZ8rwNpYGR3Dij4HoY0fFT1u6vPJCzQQDmocOjZKmT4acQi5FMfOQTREL8mBOrc X-Received: by 2002:a17:902:aa8d:b0:1d0:6ffd:6e8e with SMTP id d13-20020a170902aa8d00b001d06ffd6e8emr386755plr.134.1702060526212; Fri, 08 Dec 2023 10:35:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702060526; cv=none; d=google.com; s=arc-20160816; b=RP6Dv7kcd4+1x7/b6cQOhoaSwMCGecpAEapryU+KEvlWm69aBQvzVnFEFoWCXYmEgm 0UzxyOEP4Sp6dikCYd5G/gIWNb1ej6QxuL2PGDW+s8UfcUdKnMpamZ4KcKB2h5sepxI1 3elD21oQ73oWDf10J0riiINasTQm2waHIndWStlKlPzAtGTckkFdPtEbhwhdWZOGbSdu KbSegWU1/FDZws6IbvPVT79Ef0tN3T9+DXOrVJJe7fSWg1HUMmTwX7jjmkTjbaQa//ZZ ekOCbYdoSxYInYhcd28OfMVAb33DiuhRCha3Zp0CfDNd4F0p9gDvVYok9VCE32DYLx+d +Txg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=iqgkejpa/rkBjVNHaS0A5K5PJBwcgcqylwReeoFCRMk=; fh=ldq3c3V9Ed5GG5JaCS5XviCv1ZZL1NK27GlE9n5V6X0=; b=j86hEDGmyJZQwNO2TKT874RnF+bxFQdELPB3GiT+wC6HMk3uSnoDzCI36h3SCAcQWe XNUQuD3KfQ56ngFs4tLxVELHpTdq3UHqOkLEGR15+x1JylocYsouBPykyqujH20R1Fcu ZQcMTElL/+JdYiiYGLChMhmyesosQgljH6Sts/p0GP4V/zm6/klqs+lHLsjkPU2nPLVm j+7A1I/fP70HkWzWYuXRzoBuiyaKeDpMMLUc5LwMUyiumIRIsph8MdTd6d67ujea2kTr 6agzaYGRHZeBTlvmywiL+A7g0sleToaFHA//LAgQaF9iwuMv4ydIQYlmNYmW+X7pPTbt UflA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=T8fPULZ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id n9-20020a170903110900b001cffca283fasi1985371plh.144.2023.12.08.10.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 10:35:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.org.uk header.s=zeniv-20220401 header.b=T8fPULZ5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=zeniv.linux.org.uk Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 0B429819D726; Fri, 8 Dec 2023 10:35:24 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574566AbjLHSfJ (ORCPT + 99 others); Fri, 8 Dec 2023 13:35:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233827AbjLHSfI (ORCPT ); Fri, 8 Dec 2023 13:35:08 -0500 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 359C9118; Fri, 8 Dec 2023 10:35:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=iqgkejpa/rkBjVNHaS0A5K5PJBwcgcqylwReeoFCRMk=; b=T8fPULZ5vJHN49SgmCJX6fdWHu K2+z2sIwrEFOU7FxzoPXvlYTiVfVy/1kf0iqenNn+9+iFZtFhNYTldLX4Rr+NQ/HRQs4KWCwkossM Sc/dQJmTG6XvnTRHyU/gq4AnzkLGN0Avu0Di1LdozAE2/fG4QmSKzbGdau55xtyTEINys4KWTf2vB pGuVJ4uO49mMYJFsmlRnLCFJzYNBrGbaFa3GIhzxGl9ZZ/Y1+jCzll9OZJ+1Buc2kiuBss55jwjx2 w/4+Hi3Jek0qA6w9PIuLzevHiFoNU9Yayvv1wbQJpivKSAE7ivt+SznrVQCd7cLDLlgxfBLEeYhhP xuZC4PGw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1rBfgr-0091iZ-2K; Fri, 08 Dec 2023 18:35:09 +0000 Date: Fri, 8 Dec 2023 18:35:09 +0000 From: Al Viro To: David Laight Cc: "linux-arch@vger.kernel.org" , gus Gusenleitner Klaus , Al Viro , Thomas Gleixner , lkml , Ingo Molnar , "bp@alien8.de" , "dave.hansen@linux.intel.com" , "x86@kernel.org" , "David S. Miller" , "dsahern@kernel.org" , "kuba@kernel.org" , Paolo Abeni , Eric Dumazet Subject: Re: [RFC][PATCHES v2] checksum stuff Message-ID: <20231208183509.GC1674809@ZenIV> References: <20231019080615.GY800259@ZenIV> <20231021071525.GA789610@ZenIV> <20231021222203.GA800259@ZenIV> <20231022194020.GA972254@ZenIV> <20231205022100.GB1674809@ZenIV> <602ab11ffa2c4cc49bb9ecae2f0540b0@AcuMS.aculab.com> <20231206224359.GR1674809@ZenIV> <46711b57a62348059cfe798c8acea941@AcuMS.aculab.com> <20231208141712.GA1674809@ZenIV> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Fri, 08 Dec 2023 10:35:24 -0800 (PST) On Fri, Dec 08, 2023 at 03:56:27PM +0000, David Laight wrote: > > You add them as natural numbers. If there is no carry and result > > fits into N bits, that's it. If there is carry, you add it to > > the lower N bits of sum. > > > > Discussion of properties of that operation is present e.g. in > > RFC1071, titled "Computing the Internet Checksum". > > > > May I politely suggest that some basic understanding of the > > arithmetics involved might be useful for this discussion? > > Well 0x0000 is +0 and 0xffff is -0, mathematically they are (mostly) > equal. As representations of signed integers they are. However, the origin of operation in question is irrelevant. Again, read the fucking RFC. > I bet that ICMP response (with id == 0 and seq == 0) is the only > place it is possible to get an ip-checksum of a zero buffer. > So it will be pretty moot for copy+checksum with can return 0xffff > (or lots of other values) for an all-zero buffer. Egads... Your bets are your business; you *still* have not bothered to look at the callers of these primitives. Given the accuracy of your guesses so far, pardon me for treating any "I bet"/"it stands for reason"/etc. coming from you as empty handwaving. > In terms of copy+checksum returning an error, why not reduce the > 32bit wcsum once (to 17 bits) and return -1 (or ~0u) on error? > Much simpler than your patch and it won't have the lurking problem > of the result being assigned to a 32bit variable. In case you have somehow missed it, quite a few of the affected places are in assembler. The same would apply to added code that would do this reduction. Which is going to be considerably less trivial than the changes done in that patch.