git: 651dd086bf73 - stable/13 - pkt-gen: Allow limiting received packets
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Sat, 31 Dec 2022 14:35:38 UTC
The branch stable/13 has been updated by vmaffione: URL: https://cgit.FreeBSD.org/src/commit/?id=651dd086bf7361b7237af9c57cb9292010e44017 commit 651dd086bf7361b7237af9c57cb9292010e44017 Author: Allan Jude <allanjude@FreeBSD.org> AuthorDate: 2021-05-17 23:04:08 +0000 Commit: Vincenzo Maffione <vmaffione@FreeBSD.org> 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: <https://reviews.freebsd.org/D###> (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