From nobody Sat Dec 31 14:35:38 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Nkl6L6NbRz2nd0b; Sat, 31 Dec 2022 14:35:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Nkl6L5XVMz4Ynn; Sat, 31 Dec 2022 14:35:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672497338; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=F+U0W2Wh80+deOnDi/TgDtP9AdON2TXLByXOLoEVsGc=; b=Pio6jxX9WPCn37KBkdsEnA6HS9NOUAjW1l8CKvcfYqcHPvB74fb0DNpZ7jdXvjbnO0mfws nab23VCNgYS4o/juQqWmFwDdmNHZSzJRlW8D3uYCGtyhtqlcCG+veDDcypJeGkeBDChJoi izHgfmb47uCvhfY+noIjPHdHHMJ5OPBRwT0FtDRzbPNkb+PRo0TBqEYkvS7v391flw2w9m uIuQyv4WQ7SF2eeI3BJoIxcMJK2lJqg9PtYBRySElQ+EODgoTLJPaJqlHSAwuLgHqqnqtn MCxDNwYzeDUd2YTj/o4Fmm3fAaAxV6ptF2qxuksWd9YnAtPDys1E6eU/Dyuiyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1672497338; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=F+U0W2Wh80+deOnDi/TgDtP9AdON2TXLByXOLoEVsGc=; b=yUIcRuQ/4tJ13/4mJ6xQHMpizCuDeCC7BmWBSDIZi2KkbxRHUIj8qglZNwCryTiebPYgBo 33zGaKXxPlJOlhoGyFrQ3H5qE/JOnPgd5mqT//0+m6H9H4ZbFGH/Pu4kDCbNfzDWaaoB19 1H3ZZY/sM+Nu59Nfi7ds+sMidcwI9U5+LL5fo5yJPp6SO4w9TxemmbUGTmR8TraLs1Igy4 8m2E2HP+SHKJ0Ifj82/DGuh88OdP6w4AcyxVoUdEppXi060XvfjY3iukZRv8jb6JfjLDDO w8EywQkIttLTo8AqzzeskjPbeaDK1VIOxZ9iDsHtaSHjkBx4X1y8BYiiN0Sk1g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1672497338; a=rsa-sha256; cv=none; b=tmn8Qn9UMt2VGGFP/66r8aJMw8QIwz1WvKQWxmcKY0fJPgmVKXIPGlGxYMjEy/EvGwwfwK 2Xx18qM1q7mE+rCH+SnU8A35RoreSx2JAIuown1AukZxlgSVoP/nPAxXI4Xcly9Rub3/P3 C3whEspA9DWbqqClNPkGMB+JnVE62r/rxc4W0kzRIOQleGJkAHR0MJQPkZbpbpTZbV35AC LIBGI4IS4OVHF6kzbd97NJLt5A5pfrKJsNqvhymVcvRnYrhcba4dSZmSbuUtBAvip3uNxB 2L/+6YulBS2qyBBawbWm25puzNwVE2sHjwqIjxjji156ScoxPvzC+26qv3DSPg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Nkl6L4TPYzs4Z; Sat, 31 Dec 2022 14:35:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 2BVEZcQh056142; Sat, 31 Dec 2022 14:35:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 2BVEZcw5056141; Sat, 31 Dec 2022 14:35:38 GMT (envelope-from git) Date: Sat, 31 Dec 2022 14:35:38 GMT Message-Id: <202212311435.2BVEZcw5056141@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vincenzo Maffione Subject: git: 651dd086bf73 - stable/13 - pkt-gen: Allow limiting received packets List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vmaffione X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 651dd086bf7361b7237af9c57cb9292010e44017 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=651dd086bf7361b7237af9c57cb9292010e44017 commit 651dd086bf7361b7237af9c57cb9292010e44017 Author: Allan Jude AuthorDate: 2021-05-17 23:04:08 +0000 Commit: Vincenzo Maffione CommitDate: 2022-12-31 14:32:55 +0000 pkt-gen: Allow limiting received packets Makes pkg-gen quit after having received N packets, the same way it already supports doing for sent packets. Reviewed by: vmaffione Sponsored by: Klara Inc. MFC after: 4 weeks Differential Revision: https://reviews.freebsd.org/D30266 (cherry picked from commit 20d684ecc9d7d9128774f2e3c287058868f48bb0) netmap: pkt-gen: fix compilation issue Remove stray characters preventing the source code from being compiled. Fixes: 20d684ecc9d7 ("pkt-gen: Allow limiting received packets"). Submitted by: ar_semihalf.com Reviewed by: vmaffione Differential Revision: (cherry picked from commit 950cf4a29a8e11962cf4672311f685af590c106e) --- tools/tools/netmap/pkt-gen.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/tools/tools/netmap/pkt-gen.c b/tools/tools/netmap/pkt-gen.c index 3ecdbd2c3cc4..84835c300283 100644 --- a/tools/tools/netmap/pkt-gen.c +++ b/tools/tools/netmap/pkt-gen.c @@ -1837,6 +1837,7 @@ receiver_body(void *data) struct netmap_ring *rxring; int i; struct my_ctrs cur; + uint64_t n = targ->g->npackets / targ->g->nthreads; memset(&cur, 0, sizeof(cur)); @@ -1864,7 +1865,7 @@ receiver_body(void *data) /* main loop, exit after 1s silence */ clock_gettime(CLOCK_REALTIME_PRECISE, &targ->tic); if (targ->g->dev_type == DEV_TAP) { - while (!targ->cancel) { + while (!targ->cancel && (n == 0 || targ->ctr.pkts < n)) { char buf[MAX_BODYSIZE]; /* XXX should we poll ? */ i = read(targ->g->main_fd, buf, sizeof(buf)); @@ -1876,7 +1877,7 @@ receiver_body(void *data) } #ifndef NO_PCAP } else if (targ->g->dev_type == DEV_PCAP) { - while (!targ->cancel) { + while (!targ->cancel && (n == 0 || targ->ctr.pkts < n)) { /* XXX should we poll ? */ pcap_dispatch(targ->g->p, targ->g->burst, receive_pcap, (u_char *)&targ->ctr); @@ -1887,7 +1888,7 @@ receiver_body(void *data) int dump = targ->g->options & OPT_DUMP; nifp = targ->nmd->nifp; - while (!targ->cancel) { + while (!targ->cancel && (n == 0 || targ->ctr.pkts < n)) { /* Once we started to receive packets, wait at most 1 seconds before quitting. */ #ifdef BUSYWAIT