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 0A8CDA0506; 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 9A95D4068B; Tue, 17 May 2022 23:04:46 +0200 (CEST) Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) by mails.dpdk.org (Postfix) with ESMTP id 0A91240041 for ; Tue, 17 May 2022 23:04:44 +0200 (CEST) Received: by mail-pj1-f44.google.com with SMTP id a23-20020a17090acb9700b001df4e9f4870so49107pju.1 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=4P7gJJbL8haNeL2zhaRrHJD4v1HyngNcOMv7Em+TTusRXAIsyR5IvoW50Vz3Go1QSO kDZUf44V7j38+YviEH6C3lg4pekfGMiYBo+lsUqY4IcdRYfbmZYrEEmMReoFqyUzLCz9 OwOOmAi4Fwn5W1q323I+NnO0uy0ne5Kx3jrItQ12LiXijIZB4uN4N4FZDWqRybJxVxBf 6HHJGg47Z70bnBX4eqifzXFT1rtb1ZXXzzlmtXTczISIUImbHPA2SJsNsuKwr7c/Ylud AwpKdWFCkLafAKI8hi+PeSpk3Wv9Q5y7GRqGaXL//hCyKj1xU8QfMDluxDvChO4LQyNJ 4PTg== X-Gm-Message-State: AOAM531bylds6KK2fHU/jvLHlyFsvJ6SAzQBXvccO1baAEqvskvsff38 b9TA4JoJoL2oA3l254BOMBgGyQ== 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: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-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.