ifpps: Use unsigned int to store number of cpus

The number of CPUs can never be negative and get_number_cpus() returns
unsigned int too, so consistently conver all variables holding a CPU
number or number of CPUs to type unsigned int.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
ifpps: Don't bug out if interface went down

In case the interface ifpps is running on went down, ifpps bugged out
because the stats didn't look plausible anymore, due to the IRQ count
being reset:

ifpps: ifpps.c:563: stats_diff: Assertion `!((new->irqs[i] - old->irqs[i]) > (new->irqs[i]))' failed

Fix this by setting the difference to 0 in this case. ifpps will thus
display a irqs/t value of 0 instead of bugging out.

This fixes #74.

Reported-by: Jon Schipp <jonschipp@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
ifpps: Skip reading IRQ number from /proc/interrupts

We don't use the IRQ number we read from /proc/interrupts, so just skip
it while reading. This also allows us to drop the irq_nr member from
struct ifstat.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
netsniff-ng: Simplify dump file creation logic

Instead of using goto, just check stats if stat() returned 0 and used
ctx->dump_dir afterwards. This makes the logic a bit easier to follow.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
man: netsniff-ng: add note about netsniff

Add a note to the man-page that there's a other tool that is unrelated
to netsniff-ng.

Signed-off-by: Jon Schipp <jonschipp@gmail.com>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
netsniff-ng: Remove unnecessary fmemset() of struct stat

The struct stat is filled by the call to stat(2) in the next line, so
there is no need to explicitely set it to 0 before.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
bpf: ldi,ldxi: allow for '#' prefix in numbers

For consistency, allow for '#' prefix in numbers, which we currently
do not do. So keep old mode as compatibility to not break current
programs, and add new one with '#' prefix.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
ifpps: Reuse device bitrate for screen_header()

Instead of issuing another call to device_bitrate(), reuse the the value
acquired in screen_update() and pass it to screen_header().

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
ifpps: show percentage of theoretical line-rate

Also show the percentage of the (theoretical) line rate, not just the
current rate.

Suggested-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
ifpps: make display of line rate percentage optional

In order to not to clutter the display too much, make the display of the
percentage of the theoretical line rate dependent on a command line
option.

Suggested-by: Daniel Borkmann <dborkman@redhat.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
ifpps: man: add -P option

Add a man page entry for the new -P option.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
ifpps: zsh: add -P option

Add an entry for autocompletion support.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
bpfc: add gnu as style %-register prefix

Let a and x register also be addressed as %x and %a.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
ifpps: correct calculation of line rate percentage

The line rate is given in Mbit rather than MiB (in which {rx,tx}_bytes
were converted). Correct the calculation by converting {rx,tx}_bytes to
Mbit:

  (n bytes * 8 bits per byte) / 1000^2 = (n bytes) / 125000

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
trafgen: combine likely conditions

Combine multiple likely conditions into one.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
doc: authors: moved Tobias one up

Nothing changes in that regard, Tobias and myself are both maintaining
and continue to do so on one and the same level. Tobias does an awesome
job, so this should be credited to him right here!

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
doc: readme: give note about what tools are still experimental

We still have to get curvetun and mausezahn in line with the rest
of the landscape, as they are not ready and in a quality we wish
they would be. Therefore, mark and document them as experiemental
for now until they are fixed up.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
trafgen: remove inner loop

Get rid of inner loop in fast path. This simplifies code and readability.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
netsniff-ng: Display pcap I/O method in verbose mode

If a user accidentially specifies more than one of --mm/--sg/--clrw, the
option specified last will be used - as expected from standard command
line tools. In order to still prevent users from being confused by this,
explicitely display the pcap I/O method used in verbose mode.

In order for the output to be more user-friendly, actually write out the
method names in const char *pcap_ops_group_to_str, which isn't used
anywhere else anyway.

Suggested-by: Jon Schipp <jonschipp@gmail.com>
Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
ifpps: add option that omits CSV header

Adds option -o|--omit-header which does not print the CSV header
e.g. when the user does not need it.

Signed-off-by: Jon Schipp <jonschipp@gmail.com>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>