From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 63FD4A0508 for ; Tue, 17 May 2022 23:04:47 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5B3D441109; Tue, 17 May 2022 23:04:47 +0200 (CEST) Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by mails.dpdk.org (Postfix) with ESMTP id 0BD2B4068B for ; Tue, 17 May 2022 23:04:44 +0200 (CEST) Received: by mail-pl1-f178.google.com with SMTP id q4so18383445plr.11 for ; Tue, 17 May 2022 14:04:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20210112.gappssmtp.com; s=20210112; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=wP71eXPJBbGtoTGZZlmGK8qewxJ7u8DuZYzY/9Hp3cI=; b=YmQU+5M4jl2qA+vf8Kend3ljMGO4oY60bJlnrBt88SLICt9ADxEA1OtVM8CDAgHRPL 2anmhpCj6bCw8sqOCoNJJnUAEkvKrUYWMdsMxTB1j2bB9KDlEf6EBv1Amq/fiypjgjPF iA4hN3NBwLG1xCRyNXWEs0ikmfjbgG1VJUAGqEj1i6bvMkQ6VKqvizscX+NQy1WyWjg/ bm6GdJIDqHiTBzisI53/D52XkvHQticPupsaq4i6k22u9+dsNGyJ4yI/1s2B+Dd2wAU/ 6TfLeJxLpSI0ITRGCDnOWJCrgOF4oszgN0eLe253+uiH/IbLANJNPv/UPGD42FjVmFkT 0k6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=wP71eXPJBbGtoTGZZlmGK8qewxJ7u8DuZYzY/9Hp3cI=; b=xhHmKMejCwj7xVyLOVNwFegZMFgCn2VOpuX7M0FgWZd/HjMVTnMDwHMa3fsSFrix44 iiZY6g/fw61BPFTt1ukDevejnDhb7TzKF17/iJ0gC+9XwBzbUcAX27JxypFHP85ejcTy Yap47aAdque7nVbyBICCpRdBPLb7ykK+nfJhPMAZzrrZCObEzPPjQX532IDFZMUbbv0f Iq+sJ4QH37hHYuqnxS8w6dx2f9jOK9gRSDkXUYRBboI7w9ain1zRvhsJCb5NCpmDrv2+ eUKWbg9me7fb4iPQjVv5bsOt7dV4QJDW6poFHcnJxLp6RAGl1qz0j+KutAYGxMRBjkrb rOAw== X-Gm-Message-State: AOAM531ewbdYJd2CT/Fdj5PZdwNhSYT4BBLZD1FNT4IN0WWsu5jdu9VD zgjJUF2M6UKqKqMM3dVzLURQcQ== X-Google-Smtp-Source: ABdhPJwqiDsmIIBxzqLstDFv/0ZaGCz3WstPLLiGQgaUU6dTr1nmSBdLk1u9U0121QAN+bQBfxgSUA== X-Received: by 2002:a17:90a:17e8:b0:1df:4e82:a7aa with SMTP id q95-20020a17090a17e800b001df4e82a7aamr13564921pja.4.1652821484100; Tue, 17 May 2022 14:04:44 -0700 (PDT) Received: from hermes.local (204-195-112-199.wavecable.com. [204.195.112.199]) by smtp.gmail.com with ESMTPSA id z13-20020aa7958d000000b0050dc7628151sm195573pfj.43.2022.05.17.14.04.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 14:04:43 -0700 (PDT) Date: Tue, 17 May 2022 14:04:40 -0700 From: Stephen Hemminger To: Quentin Armitage Cc: Reshma Pattan , Ray Kinsella , dev@dpdk.org, stable@dpdk.org Subject: Re: [PATCH v2] libpcapng: fix timestamp wrapping in output files Message-ID: <20220517140440.44776434@hermes.local> In-Reply-To: <20220517100115.157888-1-quentin@armitage.org.uk> References: <20220511094655.4f885c84@hermes.local> <20220517100115.157888-1-quentin@armitage.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org On Tue, 17 May 2022 11:01:15 +0100 Quentin Armitage wrote: > In pcap_tsc_to_ns(), delta * NSEC_PER_SEC will overflow approx 8 > seconds after pcap_init is called when using a TSC with a frequency > of 2.5GHz. > > To avoid the overflow, update the saved time and TSC value once > delta >= tsc_hz. > > Fixes: 8d23ce8f5ee ("pcapng: add new library for writing pcapng files") > Cc: stable@dpdk.org > > Signed-off-by: Quentin Armitage > --- > v2: > - Don't call clock_gettime() in fast path > - Update pcapng_time.ns and pcapng_time.cycles to ensure delta < tsc_hz > - Stop using constructor to initialise pcapng_time.tsc_hz since > it is not initialised until rte_eal_init() is called > - use mean value of TSC before and after call to clock_gettime() > - only call rte_get_tsc_hz() once > - use rte_reciprocal functions instead of division > > lib/pcapng/rte_pcapng.c | 47 ++++++++++++++++++++++++++++++++++++----- > 1 file changed, 42 insertions(+), 5 deletions(-) Side note: looked at an alternative using the timestamp offset option described in the PCAPNG IETF standard. if_tsoffset: The if_tsoffset option is a 64-bit signed integer value that specifies an offset (in seconds) that must be added to the timestamp of each packet to obtain the absolute timestamp of a packet. If the option is missing, the timestamps stored in the packet MUST be considered absolute timestamps. The time zone of the offset can be specified with the option if_tzone. But not supported even by current wireshark so not useful.