Re: [PATCH net v3 5/8] net: resolve uncommon partial checksums at ingress
From: Michael S. Tsirkin
Date: Wed Oct 21 2026 - 03:57:28 EST
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.
--
MST