Re: [PATCH v3 4/5] pcapng: handle packets copied before file open

Kevin Traynor
2026-03-19T10:34:30Z

On 2/28/26 5:35 PM, Stephen Hemminger wrote:
> Either through misuse of the API, or races it might happen
> that rte_pcapng_copy() is called before rte_pcapng_fdopen().
>
> Simplest solution to handle this is to modify the logic for
> TSC to nanosecond epoch conversion to handle the case where
> the difference is negative.
>
> Bugzilla ID: 1291
> Fixes: 166591931b72 ("pcapng: modify timestamp calculation")
> Cc: stable@dpdk.org
>

Hi Stephen,

Fixes tag goes back to 23.11 but the fix modifies a function added in
26.03 commit below, which doesn't apply cleanly either.

So will just drop from LTS. Otherwise we'll need custom backports and
there's quite a lot of churn.

thanks,
Kevin.

commit 4fc65615b274701070c67f8c424d93aef8bf7483
Author: Stephen Hemminger <stephen@networkplumber.org>
Date: Mon Feb 16 13:38:03 2026 -0800

pcapng: improve performance of timestamping

> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> lib/pcapng/rte_pcapng.c | 10 +++++++---
> 1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/lib/pcapng/rte_pcapng.c b/lib/pcapng/rte_pcapng.c
> index b93af418aa..b5d1026891 100644
> --- a/lib/pcapng/rte_pcapng.c
> +++ b/lib/pcapng/rte_pcapng.c
> @@ -157,11 +157,15 @@ tsc_to_ns_epoch(const struct tsc_clock *clk, uint64_t tsc)
> {
> uint64_t delta, ns;
>
> + if (unlikely(tsc < clk->tsc_base)) {
> + delta = clk->tsc_base - tsc;
> + ns = (delta >> clk->shift) * NSEC_PER_SEC;
> + return clk->ns_base - rte_reciprocal_divide_u64(ns, &clk->tsc_hz_inv);
> + }
> +
> delta = tsc - clk->tsc_base;
> ns = (delta >> clk->shift) * NSEC_PER_SEC;
> - ns = rte_reciprocal_divide_u64(ns, &clk->tsc_hz_inv);
> -
> - return clk->ns_base + ns;
> + return clk->ns_base + rte_reciprocal_divide_u64(ns, &clk->tsc_hz_inv);
> }
>
> /* length of option including padding */