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.129.124]) by passt.top (Postfix) with ESMTP id AC6145A0267 for ; Tue, 18 Oct 2022 10:40:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1666082404; 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=8uPgf7IhHujHMZglUtlfMQWlt/s9PdRlOHa0NiEp7Fw=; b=f/o7UtrSY2FND96kVPIm1UMmAXnAAuBr0XjNlGeSAOeDKRb9y4fpxWGI/t5L0cMNsfEef8 pxj/tdkR6H662OVb8yQ+MVjpwhdgz+h7XkvK/c55nEJxbDsmbMVmsJYcW4JHJMXNwh4fgc tXscNiVTxJDPB+AWjOQnxBqO6JuWTb4= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-343-dk0i30qoPruc_blMNhvwbg-1; Tue, 18 Oct 2022 04:40:01 -0400 X-MC-Unique: dk0i30qoPruc_blMNhvwbg-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B99FC3C0CD4E; Tue, 18 Oct 2022 08:40:00 +0000 (UTC) Received: from maya.cloud.tilaa.com (ovpn-208-31.brq.redhat.com [10.40.208.31]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 723F340F156; Tue, 18 Oct 2022 08:40:00 +0000 (UTC) Date: Tue, 18 Oct 2022 05:03:49 +0200 From: Stefano Brivio To: David Gibson Subject: Re: [PATCH 05/14] Add csum_ip4_header() helper to calculate IPv4 header checksums Message-ID: <20221018050349.19c0a0a9@elisabeth> In-Reply-To: <20221017085807.473470-6-david@gibson.dropbear.id.au> References: <20221017085807.473470-1-david@gibson.dropbear.id.au> <20221017085807.473470-6-david@gibson.dropbear.id.au> Organization: Red Hat MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Message-ID-Hash: GNMALVFLGP63ASH4WLZIVUEMFGTBNUFT X-Message-ID-Hash: GNMALVFLGP63ASH4WLZIVUEMFGTBNUFT 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 X-Mailman-Version: 3.3.3 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 Mon, 17 Oct 2022 19:57:58 +1100 David Gibson wrote: > We calculate IPv4 header checksums in at least two places, in dhcp() and > in tap_ip_send. Add a helper to handle this calculation in both places. > > Signed-off-by: David Gibson > --- > checksum.c | 6 ++++++ > checksum.h | 1 + > dhcp.c | 3 +-- > tap.c | 3 +-- > 4 files changed, 9 insertions(+), 4 deletions(-) > > diff --git a/checksum.c b/checksum.c > index 72f1cfb..f25a96a 100644 > --- a/checksum.c > +++ b/checksum.c > @@ -114,6 +114,12 @@ uint16_t csum_unaligned(const void *buf, size_t len, uint32_t init) > return (uint16_t)~csum_fold(sum_16b(buf, len) + init); > } > /** * csum_ip4_header() - Calculate and set IPv4 header checksum * @iph: IPv4 header */ ...I just tried to run Doxygen, I think it would be nice to have eventually (especially for DOT call graphs), things don't look too bad. > +void csum_ip4_header(struct iphdr *ip4hr) > +{ > + ip4hr->check = 0; > + ip4hr->check = csum_unaligned(ip4hr, (size_t)ip4hr->ihl * 4, 0); iph, for consistency. -- Stefano