Subject: Re: [PATCH nf-next RFC 1/3] xt_statistic: taking GRO/GSO into account for nth-match

From: Florian Westphal <[email-masked]>
Date: Mon, 8 Dec 2025 15:18:25 +0100

Nick Wood <[email-masked]> wrote:
> > It was easier to change the nth code (and easier for me to reason about)
> > than dealing with converting the the formula to use an integer
> > approximation (given we don't have floating point calc in kernel).
> 
> with s = integer sample rate (i.e s=100 if we're sampling 1/100)
> and n = nr_packets:
> 
> sample_threshold = [ 2**32 //s //s ] * [n*(s - (n-1))] ;
> 
> if get_random_u32 < sample_threshold {
>     sample_single_subpacket
> }*

Thanks for clarifying.  But we can't do that within the limitations
imposed by the netfilter framework.

We can only flag the entire skb/aggregate as either matching or not
matching.  We can't signal a 'match this subpacket'.

While we could split the aggregate within the conditional, we can't
(re)inject splitted packets back into the processing pipeline.

If there is a way, I can't think of anything.  At least not without
major rework of the entire netfilter stack :-|