Article View: linux.kernel.netdev
Article #6028Re: [PATCH net v3 5/8] net: resolve uncommon partial checksums at ingress
From: Willem de Bruijn
Date: Wed, 21 Oct 2026 14:17
Date: Wed, 21 Oct 2026 14:17
122 lines
16743 bytes
16743 bytes
Michael S. Tsirkin wrote:
> On Tue, Oct 20, 2026 at 08:05:29PM -0400, Willem de Bruijn wrote:
> > Michael S. Tsirkin wrote:
> > > On Tue, Oct 20, 2026 at 03:44:35PM -0400, Willem de Bruijn wrote:
> > > > > +/* Walk the L3 header at @nhoff: where does its transport header
> > > > > + * start, and which protocol is it? Returns false if the header
> > > > > + * is truncated, malformed or fragmented.
> > > > > + */
> > > > > +static inline bool
> > > > > +virtio_net_l4_start(struct sk_buff *skb, unsigned int nhoff, __be16 proto,
> > > > > + unsigned int *thoff, int *ip_proto)
> > > > > +{
> > > > > + if (proto == htons(ETH_P_IP)) {
> > > > > + const struct iphdr *iph = virtio_net_ip4_parse(skb, nhoff, thoff);
> > > > > +
> > > > > + if (!iph || ip_is_fragment(iph))
> > > > > + return false;
> > > > > + *ip_proto = iph->protocol;
> > > > > + return true;
> > > > > + }
> > > > > +
> > > > > + if (proto == htons(ETH_P_IPV6)) {
> > > > > + const struct ipv6hdr *iph;
> > > > > + int flags = 0;
> > > > > +
> > > > > + if (!pskb_may_pull(skb, nhoff + sizeof(*iph)))
> > > > > + return false;
> > > > > + iph = (const void *)(skb->data + nhoff);
> > > > > + if (iph->version != 6)
> > > > > + return false;
> > > > > + *thoff = nhoff + sizeof(*iph);
> > > > > + *ip_proto = iph->nexthdr;
> > > > > + if (*ip_proto != IPPROTO_TCP && *ip_proto != IPPROTO_UDP) {
> > > > > + *thoff = nhoff;
> > > > > + *ip_proto = ipv6_find_hdr(skb, thoff, -1, NULL,
> > > > > + &flags);
> > > > > + if (*ip_proto < 0 || flags & IP6_FH_F_FRAG)
> > > > > + return false;
> > > > > + }
> > > > > + return true;
> > > > > + }
> > > > > +
> > > > > + return false;
> > > > > +}
> > > >
> > > > for all this parsing: could we use flow dissection, like the
> > > > !VIRTIO_NET_HDR_F_NEEDS_CSUM case?
> > >
> > > Hmm I don't see how. That one trusts the caller's protocol and network
> > > header. We could parse L2 ourselves and use the dissector for L3+. But
> > > it stops at whatever it does not know, and every miss would turn into a
> > > drop or a software checksum for a packet the stack delivers fine. Our
> > > parser deliberately covers everything the stack can deliver.
> >
> > You're right, the protocol and network offset need to be parsed
> > manually. After that it could be passed to the flow dissector.
>
> I posted v4 with the custom parser, since i had it tested. Let's do
> cleanups on top? I spent too much time on this, to be frank.
Yes, as a matter of fact, on investigating this approach in more
detail, I agree that flow dissection is a worse choice.
> Hmm, an interesting trick, but I don't see how this works for tunnels?
> We need to dissect at inner_nh, and on success we can not leave
> network_header there - the packet continues to outer IP processing.
> I fear making all this work will be more code than the parsing it
> replaces.
On the upsides, quoting an LLM:
"
Using the flow dissector replaces all of virtio_net_ip4_parse(), virtio_net_l3_start(), virtio_net_l4_start(), and
virtio_net_csum_partial_ok_at_offset() with two compact functions:
Function | Lines of Code | Description
------------------------------------------|------------------------------------------|-----------------------------------------------------
virtio_net_setup_l3_input() | ~28 lines | Anchors L2 framing (eth_header_ops vs raw L3)
virtio_net_csum_partial_ok() | ~42 lines | Runs flow dissector and validates thoff/csum_offset
virtio_net_tnl_offsets_ok() | ~8 lines | Reuses outer dissection keys for tunnel validation
Total dedicated parsing code | ~78 lines |
──────
### Summary of Differences
• Net Code Reduction: ~103 fewer lines of C code added to virtio_net.h (~57% reduction in new parsing code).
• Eliminated Series Dependencies: Patch 7/8 (net: add ip4_parse()) is completely eliminated, reducing the patch series by an entire patch.
• Deduplication: The existing non-checksum GSO validation in __virtio_net_hdr_to_skb() (lines 120–146, 27 lines) already calls
skb_flow_dissect_flow_keys_basic(); sharing virtio_net_setup_l3_input() consolidates both paths onto a single ingress dissection mechanism.
"
I particularly like that we use the same for NEEDS_CSUM and !NEEDS_CSUM.
Also the lack of code duplication.
But, the goal of this patch is to minimize overhead in the hot path of
standard TCP/IP and UDP code. And flow dissection is significantly more
expensive that open coding those specific checks.
Technical Details
Message-ID:
<willemdebruijn.kernel.37619d32a8f3c@gmail.com>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350048-linux-kernel-netdev=dewy.ruReferences:
<cover.1792411304.git.mst@redhat.com> <9c08d12b3a7819ae03ded6a154e4f908276e93d4.1792411304.git.mst@redhat.com> <willemdebruijn.kernel.2eb449439b094@gmail.com> <20261020170908-mutt-send-email-mst@kernel.org> <willemdebruijn.kernel.1da723f98c23a@gmail.com> <20261021035050-mutt-send-email-mst@kernel.org>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-350048-linux-kernel-netdev=dewy.ru
From: willemdebruijn.kernel@gmail.com (Willem de Bruijn)
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net v3 5/8] net: resolve uncommon partial checksums at
ingress
Date: Wed, 21 Oct 2026 10:17:07 -0400
Organization: Usenet Network
Message-ID: <willemdebruijn.kernel.37619d32a8f3c@gmail.com>
References: <cover.1792411304.git.mst@redhat.com>
<9c08d12b3a7819ae03ded6a154e4f908276e93d4.1792411304.git.mst@redhat.com>
<willemdebruijn.kernel.2eb449439b094@gmail.com>
<20261020170908-mutt-send-email-mst@kernel.org>
<willemdebruijn.kernel.1da723f98c23a@gmail.com>
<20261021035050-mutt-send-email-mst@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain;
charset=utf-8
Content-Transfer-Encoding: quoted-printable
Injection-Info: usenet.network;
logging-data="4166099"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:c8c+SOLKmLendKXYAILeJLi0Aug= sha256:j7CTcZRQmdP6fnCctMmQL0w0uxrA1qfOvxexSVgskhM=
sha1:6R5uuimmMiueeqR0+FSg1UT4Ke0= sha256:H3jhtRQ+qQbRWe1yairdO+6GkJIy1MTD1mflwOG3QXw=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
by mail.dewy.ru (Postfix) with ESMTP id 75188111031; Wed, 21 Oct 2026 17:24:37 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
with ESMTP id HInGxxG5BzmB;
Wed, 21 Oct 2026 17:24:34 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-350048-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN>
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
by mail.dewy.ru (Postfix) with ESMTPS id 86AD611100C; Wed, 21 Oct 2026 17:24:22 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
by tor.lore.kernel.org (Postfix) with ESMTP id 7BBF748613; Wed, 21 Oct 2026 14:17:38 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
t=1792592231;
b=RIXwraolz/zokvLN5XxIg1fNu6go+isaG8lEh7x2Ht46ftJKx6GwpHcL0EPScIwMrLlz
UQQPDa9Sd9oV9iuR3qiSdfvOwk3r7Cz28iwpN6lBslAACSeqGVnI20o/QgayQOEdJLPcG
gMi1oxr4hEurxFQxmeDIih8AaEAjTb/1uD1dPpJ+S/wSfTg4d2xKWrcLufKPCA0o84G26
w26tExed7aJYNCVnLb1vwwmTtCe1ZlqTvhcDmDCsLRvJ6RdXQ5VdTpZUsu8YKpE8g/Xc8
JRveVVhQIPOA2KGD9+forUCrmETMamU2GmUSZi09FYeBgoaZ7/9dfCdG8L7mCI8pqGg==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792592231;
h=X-Original-To:Received:DMARC-Filter:Received:DKIM-Signature:
X-Google-DKIM-Signature:X-Forwarded-Encrypted:X-Gm-Message-State:
X-Gm-Gg:X-Received:Received:Date:From:To:Cc:Message-ID:In-Reply-To:
References:Subject:X-Mailing-List:List-Id:List-Post:List-Help:
List-Subscribe:List-Unsubscribe:List-Owner:Precedence:MIME-Version:
Content-Type:Content-Transfer-Encoding;
bh=xux5QvP8YQiJThcV5md5s9PvW9xG2SSFmNPqLeHDz08=;
b=bLFMkpRUl5pdun7ilHOQQHU+3eKiiVUk26veggdfKE9EUh9PnWXZezbbbeKNgb0wvhCD
eEo9M0hIEKnojstJ41ZCkz8ICNZVnxx9Fxl6oQyHQjrc05VgL8vfQqultM3GO+XehO6Hw
UtimrLT3FQnUzEbYSyY3t46+YXM9cz2Fy6Br/PWgnV5/MT0Wx8JtbH03LWTK5TYqzPBgM
GIlDCN0DcN/BxA6UbHeF0XAn7f41B8azGQbM63soeUPPRggsnAc+rmG5Mr+4V4SLMU6y3
bmbfAWOSJYN+M6ceuWZxFdvM1ZeKtLWvJLMHuATOd2OxJ6nsPVZnuoIcMkDnR3PPzkg==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=gNWJHZqQ;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
by smtp.subspace.kernel.org (Postfix) with ESMTP id C417F60A261D;
Wed, 21 Oct 2026 14:17:11 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
dkim=pass (2048-bit key, unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=gNWJHZqQ
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.221.176
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
t=1792592230;
b=SZ1spgDoCt1RpRfIpL5JSGonmFCaItsCSeRplprdvTsuNroMHG+qCe9p3gL9m6Uq8SZh
Akhj0obKkcw+/Nr9vXC8tU7Zq/sjbfhVdZkbMB9nPsdvD0EI+9gUdOEOcxqP0v8FIv6lw
3q6DUoUmMxTBWQhmNzS1Bp0if3lKTwCBDkvVKsbXM/p7rrXFGhBKISgS3u3Zj4W+ufnED
LXcVXy3s9TBU6Eo+qPh76wBRw/pUUB2L1ApVxDQfuuteBqneRue/iPlmSCCyHHPvqZExi
Nd8OZIg1Ybi2I9aFq1mLMSTyQX4zCtq5zo86z+2LZobafGJDZJOTMVTM1geEz3wofIQ==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
a=rsa-sha256; c=relaxed/relaxed; t=1792592230;
h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature:
X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received:
Date:From:To:Cc:Message-ID:In-Reply-To:References:Subject:
MIME-Version:Content-Type:Content-Transfer-Encoding;
bh=xux5QvP8YQiJThcV5md5s9PvW9xG2SSFmNPqLeHDz08=;
b=p8k55nQYo/W2DoVm2jAgzTvIJmhYUSAbiXxMGpYG5oGQZPs7xSuHpKAundYt202CcBAV
yYHFFgCtR4uhJ7uYc43DiVIhzWDaTrRKUVwxyJc5CX5P7rxYcl2HOObe8f/LiK7qWVTGd
uwGHlVJpMR4VA6ck2YN50MSyfCSIuel8EoupM5GMs44GMmYH8MAUwES7TWKev04lwsRRv
4YBSyucBAbPrzMgP2+gJNKRrrFiFRIHVRjzx1vKUjefENCg8fwThW8kAyuKzYAfvEcRsF
gxcCsVVTkTBS2xWXgw/akvEkIioUJ5qjLqC+2BOiPv+/etoHOxulmlPNYuLTHiZ44ZQ==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org;
dmarc=pass header.from=gmail.com;
spf=pass smtp.mailfrom=gmail.com;
dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20251104 header.b=gNWJHZqQ;
arc=none smtp.remote-ip=209.85.221.176
X-Received: from mail-vk1-f176.google.com (mail-vk1-f176.google.com [209.85.221.176])
(using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)
key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256)
(No client certificate requested)
by smtp.subspace.kernel.org (Postfix) with ESMTPS id 96CA8606A325
for <netdev@vger.kernel.org>; Wed, 21 Oct 2026 14:17:10 +0000 (UTC)
X-DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 96CA8606A325
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-vk1-f176.google.com with SMTP id 71dfb90a1353d-5ead4026fe6so292269e0c.2
for <netdev@vger.kernel.org>; Wed, 21 Oct 2026 07:17:10 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20251104; t=1792592229; x=1793197029; darn=vger.kernel.org;
h=content-transfer-encoding:content-type:mime-version:subject
:references:in-reply-to:message-id:cc:to:from:date:from:to:cc
:subject:date:message-id:reply-to:content-type;
bh=xux5QvP8YQiJThcV5md5s9PvW9xG2SSFmNPqLeHDz08=;
b=gNWJHZqQx3qCS1zclS/OkzpS4j5ftJqazpq0h00CbnAZA9rykG2MV3eBtvT8Xjnozt
p1xDkCivcaKKddL3R0QKnHA7lBSjLSGBgQsWq7r8V4Olx8yC5dUz7aowcryQnld4gxRY
iIuc3mNUpb6dEuvoCqnrmpv54SkZ7kGaqiIXk3JhNUl8tnxnVxtmgB8wgJdJ5sO68GFr
x69RSnCQSdgO14LZopyxsnlcf/wPEpYtpFrAUsBM3bEipzL9SHHApHjDIPh1/LrDqKln
ifjWE5pWhDOBrrDxC6f2/M8PvQCvM5I/41bRyYp3NEK8OmeuOL3K5hX+8b+soN0XAJQR
LprA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20260707; t=1792592229; x=1793197029;
h=content-transfer-encoding:content-type:mime-version:subject
:references:in-reply-to:message-id:cc:to:from:date:x-gm-gg
:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to
:content-type;
bh=xux5QvP8YQiJThcV5md5s9PvW9xG2SSFmNPqLeHDz08=;
b=dlQQavX3sW2z4yrA8I9I1Dg1uEUPba/qT1tKkfVIKcSLtCYs7wcnUXiCUAROMD4Lpg
AUgIDjxzoQnVTfuTHWb6q1GyXClnDaOCoY6ALs93ts2ntETPgKXHEptdJQEkCzNgef9I
1+XB/Zsu0HWeb/gVUGRhsAcRS8SotOqiifnSVRAswQCjI2dERfsgP9rmuRb5zDkZ1OZQ
ydUB11PJMGGpH3u0wI5ZUw7OfT2w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Received: by 2002:a05:6122:e145:b0:5ea:e197:43ee with SMTP id 71dfb90a1353d-5eaebe9cb1emr809668e0c.19.1792592229260;
Wed, 21 Oct 2026 07:17:09 -0700 (PDT)
X-Received: from gmail.com (111.46.245.35.bc.googleusercontent.com. [35.245.46.111])
by smtp.gmail.com with ESMTPSA id 71dfb90a1353d-5eae969803dsm3503712e0c.2.2026.10.21.07.17.08
(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
Wed, 21 Oct 2026 07:17:08 -0700 (PDT)
X-Cc: linux-kernel@vger.kernel.org,
Chris Arges <carges@cloudflare.com>,
Björn Töpel <bjorn@kernel.org>,
Phil Sutter <phil@nwl.cc>,
Jason Wang <jasowangio@gmail.com>,
Eugenio Pérez <eperezma@redhat.com>,
Xuan Zhuo <xuanzhuo@linux.alibaba.com>,
Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@kernel.org>,
Jakub Kicinski <kuba@kernel.org>,
Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org,
virtualization@lists.linux.dev,
Max Krasnyansky <maxk@qualcomm.com>,
Rusty Russell <rusty@rustcorp.com.au>,
Paulos Yibelo <habte.yibelo@gmail.com>
X-In-Reply-To: <20261021035050-mutt-send-email-mst@kernel.org>
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list