From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by passt.top (Postfix) with ESMTP id 250E05A0275 for ; Fri, 8 Mar 2024 10:29:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709890157; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=wUZytrNVajMGs+0yU4XBlb2PeKe25ONn+kllZWZnOxc=; b=NoBTSsvNcU132rl0zdHkny/4x6lihbm6h6EETJSAnnzO53sfKAiiae4mgCNnfSlY6h339I GphJInQPLNHOMRtW4pv3/vO++W0yuVVORYmSsJJ1c02x+jGv5J3sY+IewyUAaRG2CjeKRA n1ZLo/2EMV49SdXVnLUOYkXz1lLUu3Y= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-490-AWmns2I2OH2wWWtPr0AxCw-1; Fri, 08 Mar 2024 04:29:15 -0500 X-MC-Unique: AWmns2I2OH2wWWtPr0AxCw-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a44460e6c06so32164266b.1 for ; Fri, 08 Mar 2024 01:29:15 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709890154; x=1710494954; h=content-transfer-encoding:mime-version:organization:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=wUZytrNVajMGs+0yU4XBlb2PeKe25ONn+kllZWZnOxc=; b=X+VMqnh+95Qp71CWfrwv5hQDWBtYFmGjaJSxJ8Ru/dzK+wxzyCgUDWDO0A7lDYkPL/ dbFENDlWtQ6dnkgcOoUoiFLGHfiRnv6j0dmqFpIp7Vk9E5mhM5c4L8Oq47Ba/2V3SPug cST5j++7DKNf2M9uaif2RfVpEnc17Owh5/jc25whUl+zBhV5FbZjYp8ZOgrZJGBIGiQ9 XxN7oCLS814KzrNhpKfGdWPvSZmJ+cn6FvF33xwqGiPZqnnOiVLzb1YTKWP88hc/9YDr ffTs0Hx2GdFz2MnNwZ78blWve4cWgmk0+usgNGUTPR+NzBcxIgnW6DEj2nIJdABHLEoQ jflg== X-Gm-Message-State: AOJu0YxGWfvZxwEPe1JH+IoC1rgDiCkLoSHGt9/lHCHfPsAw9CrsPbvK cf87OcS4wenxVW+NayFgIjABvm44+20diE/zeP5M7+CiZTJyJdTJrFqTxyYOHnpkwyqh9zfmrwq XUw9iD5eu/mJtT6Sr02ruEKyDKFnd12cwPpoHT4Vv4E4GNxP19Q== X-Received: by 2002:a50:c909:0:b0:565:edf9:8038 with SMTP id o9-20020a50c909000000b00565edf98038mr1191143edh.40.1709890153963; Fri, 08 Mar 2024 01:29:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IF+qj5Bx1eRyKTwsLdFBNCq1ge1je2YYddiUNvBL1sQCbA3AGN3ana07O6QFMNC5cedazKgIA== X-Received: by 2002:a50:c909:0:b0:565:edf9:8038 with SMTP id o9-20020a50c909000000b00565edf98038mr1191127edh.40.1709890153337; Fri, 08 Mar 2024 01:29:13 -0800 (PST) Received: from maya.cloud.tilaa.com (maya.cloud.tilaa.com. [164.138.29.33]) by smtp.gmail.com with ESMTPSA id g2-20020a056402114200b0056735c5e9eesm5976402edw.75.2024.03.08.01.29.12 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 08 Mar 2024 01:29:12 -0800 (PST) Date: Fri, 8 Mar 2024 10:28:38 +0100 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH] ip: Use regular htons() for non-constant protocol number in L2_BUF_IP4_PSUM Message-ID: <20240308102838.726dcbbb@elisabeth> In-Reply-To: References: <20240306070836.3417504-1-sbrivio@redhat.com> Organization: Red Hat X-Mailer: Claws Mail 4.2.0 (GTK 3.24.36; x86_64-pc-linux-gnu) MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: SXZAU5CJJ5D3TSMKHD66T7FBO2S4UYSG X-Message-ID-Hash: SXZAU5CJJ5D3TSMKHD66T7FBO2S4UYSG X-MailFrom: sbrivio@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: passt-dev@passt.top, Laurent Vivier X-Mailman-Version: 3.3.8 Precedence: list List-Id: Development discussion and patches for passt Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: On Fri, 8 Mar 2024 11:55:32 +1100 David Gibson wrote: > On Wed, Mar 06, 2024 at 08:08:36AM +0100, Stefano Brivio wrote: > > instead of htons_constant(), which is for... constants. > > > > Fixes: 5bf200ae8a1a ("tcp, udp: Don't include destination address in partially precomputed csums") > > Signed-off-by: Stefano Brivio > > Reviewed-by: David Gibson > > It seems to get the job done, at what's probably negligible practical > cost. My perfectionist side has some misgivings: > > AIUI, the point of htons_constant() isn't so much that it *requires* a > constant, but that because it's open-coded in plain arithmetic > operations the compiler will be able to constant fold it, if it is > invoked with a constant parameter. Right, yes, it doesn't require a constant. Still, I'd argue it's meant for constants. :) > Since htons() is a library > function, it probably can't be elided in that way. The cost of > htons_constant() is that it may be a less optimal implementation when > the calculation really does need to be done at runtime. > > I'm still a bit baffled at that Coverity warning: I can't see why it > doesn't preclude any situation where you want to write out > calculations for clarity, even though you know the result will be a > constant (and you expect the compiler to fold it). ...maybe it actually does preclude any situation like that? This is the only example we have with __bswap_constant16(), and variables mixed (ORed) with constants. Other usages of __bswap_constant16() have just a variable as argument (no "problem" with that, of course), and we use __bswap_constant_32() with constants only. -- Stefano