Bug 252594 - netmap pkt-gen verbose output out of bounds
Summary: netmap pkt-gen verbose output out of bounds
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: CURRENT
Hardware: amd64 Any
: --- Affects Only Me
Assignee: Vincenzo Maffione
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-01-11 19:27 UTC by Brian Poole
Modified: 2021-01-15 21:03 UTC (History)
3 users (show)

See Also:
vmaffione: maintainer-feedback+
vmaffione: mfc-stable12+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Brian Poole 2021-01-11 19:27:05 UTC
Hello,

I was testing pkt-gen with multiple queues and the verbose flag when I noticed the verbose output prints an extra ring. Below pkt-gen is configured for 16 queues but prints out queues 0-16.

310.048504 main [3158] nifp at offset 0, 16 tx 16 rx region 1
310.048506 main [3162]    TX0 at 0x0xa9000 slots 1023
310.048508 main [3162]    TX1 at 0x0xb2000 slots 1023
310.048510 main [3162]    TX2 at 0x0xbb000 slots 1023
310.048513 main [3162]    TX3 at 0x0xc4000 slots 1023
310.048516 main [3162]    TX4 at 0x0xcd000 slots 1023
310.048519 main [3162]    TX5 at 0x0xd6000 slots 1023
310.048523 main [3162]    TX6 at 0x0xdf000 slots 1023
310.048526 main [3162]    TX7 at 0x0xe8000 slots 1023
310.048528 main [3162]    TX8 at 0x0xf1000 slots 1023
310.048530 main [3162]    TX9 at 0x0xfa000 slots 1023
310.048533 main [3162]    TX10 at 0x0x103000 slots 1023
310.048535 main [3162]    TX11 at 0x0x10c000 slots 1023
310.048538 main [3162]    TX12 at 0x0x115000 slots 1023
310.048540 main [3162]    TX13 at 0x0x11e000 slots 1023
310.048543 main [3162]    TX14 at 0x0x127000 slots 1023
310.048545 main [3162]    TX15 at 0x0x130000 slots 1023
310.048548 main [3162]    TX16 at 0x0x0 slots 0
310.048549 main [3167]    RX0 at 0x0x19000 slots 1024
310.048551 main [3167]    RX1 at 0x0x22000 slots 1024
310.048553 main [3167]    RX2 at 0x0x2b000 slots 1024
310.048556 main [3167]    RX3 at 0x0x34000 slots 1024
310.048558 main [3167]    RX4 at 0x0x3d000 slots 1024
310.048561 main [3167]    RX5 at 0x0x46000 slots 1024
310.048563 main [3167]    RX6 at 0x0x4f000 slots 1024
310.048565 main [3167]    RX7 at 0x0x58000 slots 1024
310.048568 main [3167]    RX8 at 0x0x61000 slots 1024
310.048570 main [3167]    RX9 at 0x0x6a000 slots 1024
310.048572 main [3167]    RX10 at 0x0x73000 slots 1024
310.048575 main [3167]    RX11 at 0x0x7c000 slots 1024
310.048577 main [3167]    RX12 at 0x0x85000 slots 1024
310.048580 main [3167]    RX13 at 0x0x8e000 slots 1024
310.048582 main [3167]    RX14 at 0x0x97000 slots 1024
310.048584 main [3167]    RX15 at 0x0xa0000 slots 1024
310.048587 main [3167]    RX16 at 0x0x0 slots 0


It appears the Netmap repo fixed this problem in commit 81b7a0d but the fix wasn't propagated to FreeBSD. If you look at correcting this, I would also like to add that on current FreeBSD the %p modifier adds the '0x' pattern automatically so the formatting above results in a double '0x0x'.
Comment 1 commit-hook freebsd_committer 2021-01-12 22:05:34 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=d7493759fbfb382a008f4036d4cc80c82950daed

commit d7493759fbfb382a008f4036d4cc80c82950daed
Author:     Vincenzo Maffione <vmaffione@FreeBSD.org>
AuthorDate: 2021-01-12 22:02:28 +0000
Commit:     Vincenzo Maffione <vmaffione@FreeBSD.org>
CommitDate: 2021-01-12 22:05:04 +0000

    netmap: pkt-gen: fix offset hex formatting

    PR:             252594
    Reported by:    brpoole@vt.edu
    MFC after:      3 days

 tools/tools/netmap/pkt-gen.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Comment 2 Vincenzo Maffione freebsd_committer 2021-01-12 22:18:16 UTC
The changes in commit 81b7a0d on the github are already in CURRENT.

I don't see anything wrong with your output.
pkt-gen (in verbose mode) is just dumping the content of your instance of "struct netmap_if" (there is one of them associated to each netmap file descriptor), which lives in the netmap shared memory. There is an entry of each netmap ring that it is possible to open, even if you actually open only a subset. You can spot the non-opened rings as those that have offset "0" (offset 0 points to a "dummy" ring). Rings #17 (N+1) are the TX/RX host (aka sw) rings, which are among the possible rings you could open.

If you run something like:

# pkt-gen -i ix0* -v

you'll open also the host rings, and therefore you will see a non-zero offset also there.

If you open only the host rings:

# pkt-gen -i ix0^ -v

you'll see offset "0" for all the hardware rings.
Comment 3 Brian Poole 2021-01-12 23:03:09 UTC
My apologies; I had forgotten the host rings. I performed the tests you described and saw the expected output for each. Sorry to bother you.
Comment 4 Vincenzo Maffione freebsd_committer 2021-01-13 20:26:34 UTC
No worries. I applied the fix you suggested, thanks for spotting that.
Comment 5 commit-hook freebsd_committer 2021-01-15 20:59:29 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=b791b5763f2bf3a3e8c45e00f66f5a63f2a12bf1

commit b791b5763f2bf3a3e8c45e00f66f5a63f2a12bf1
Author:     Vincenzo Maffione <vmaffione@FreeBSD.org>
AuthorDate: 2021-01-12 22:02:28 +0000
Commit:     Vincenzo Maffione <vmaffione@FreeBSD.org>
CommitDate: 2021-01-15 20:58:56 +0000

    netmap: pkt-gen: fix offset hex formatting

    PR:             252594
    Reported by:    brpoole@vt.edu
    MFC after:      3 days

 tools/tools/netmap/pkt-gen.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)