On Fri, Aug 08, 2025 at 03:57:04PM +0200, Laurent Vivier wrote:
On 06/08/2025 08:21, David Gibson wrote:
On Tue, Aug 05, 2025 at 05:46:18PM +0200, Laurent Vivier wrote:
Use packet_data() and extract headers using IOV_REMOVE_HEADER() and IOV_PEEK_HEADER() rather than packet_get().
Remove packet_get() as it is not used anymore.
[snip]
@@ -896,21 +896,28 @@ resume: for (seq_count = 0, seq = NULL; i < in->count; i++) { size_t l4len, plen, check; struct in6_addr *saddr, *daddr; + struct ipv6hdr ip6h_storage; + struct ethhdr eh_storage; + struct udphdr uh_storage; const struct ethhdr *eh; const struct udphdr *uh; struct iov_tail data; struct ipv6hdr *ip6h; uint8_t proto; - char *l4h; - eh = packet_get(in, i, 0, sizeof(*eh), NULL); + if (!packet_data(in, i, &data)) + return -1; + + eh = IOV_REMOVE_HEADER(&data, eh_storage); if (!eh) continue; - ip6h = packet_get(in, i, sizeof(*eh), sizeof(*ip6h), &check); + ip6h = IOV_PEEK_HEADER(&data, ip6h_storage); if (!ip6h) continue;
You peek the IPv6 header here, but I haven't spotted where you remove / drop it before...
In fact, data offset is modified by ipv6_l4hdr() that scans the headers and the data provided to ipv6_l4hdr() must point to an ipv6hdr (it provides also the proto that is alloed to do the correct IOV_PEEK_HEADER()).
Ah, right. -- David Gibson (he or they) | I'll have my music baroque, and my code david AT gibson.dropbear.id.au | minimalist, thank you, not the other way | around. http://www.ozlabs.org/~dgibson