netsniff-ng: Add __maybe_unused attribute to timer functions

The two functions timer_elapsed() and timer_next_dump() both take an
argument which they don't use. Annotate them appropriately using the
__maybe_unused attribute.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
ifpps: Allow to select number of top hitter CPUs by command line option

Instead of hard-coding the maximum number of top hitter CPUs, allow the
user to set it manually using a command line option. The default value
(if no command line parameter is specified) remains at 10.

Also update the manpage accordingly.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
man: manpage hyphen fixes, take two

Fix hyphens all over.

Signed-off-by: Kartik Mistry <kartik@debian.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
man: manpage hyphen fixes, take three

More hyphen fixes all over.

Signed-off-by: Kartik Mistry <kartik@debian.org>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
Merge branch 'master' of github.com:borkmann/netsniff-ng

Needed to let Git merge to not run into conflicts with Tobias' set
of changes on ifpps resp. ifpps manpage.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
ring: add set_sockopt_tpacket_v3 and refactor others

Add set_sockopt_tpacket_v3() in preparation for TPACKET_V3.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
ring: minor: remove define since only used once

We only use it once and nowhere else, so just replace the correct
value right away.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
ring: move poll related fallback define to built_in.h

It rather belongs to built_in.h, and not here.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
ring: add necessary structures and helper functions for v3

Prepare and add some structures an helper functions for TPACKET_V3.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
ring: prepare setup_rx_ring_layout for support in v2/v3

Prepare setup_rx_ring_layout for both, v2 and v3. Also do some checks
during compile time if offsets stay the same as we operate on different
union mappings.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
ring: setup_{rx,tx}_ring_layout: use bool for jumbo_support

There's no good reason why we currently waste an 'int' for
jumbo_support while this must better be done as 'bool'.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
man: ifpps: Mention CPU limit in first section and remove BUGS section

Mention the -n command line option in the general description, not just
the hard limit. Also remove the BUGS section, since this is now
basically resolved.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
ring: implement setup of tpacket v3 ring

Implement ring setup routines and structures for TPACKET_V3.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
ring: fix wrong error message text in __get_sockopt_tpacket

Arg, this was a leftover when copying the other function. So fix it!

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
ring: move duplicate/generic code parts from rx/tx into ring.c

We do not want to maintain duplicate code, so move this into a separate
file and name those *_generic() helpers.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
ring: setup frame structure for v2/v3 in a generic way

Prepare TPACKET_V3 for allowing to transparently setting up the
frame structure such that we do not need to change much in the
netsniff-ng/trafgen code.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
ring: netsniff-ng: migrate capture only to TPACKET_V3

Lets migrate capturing to TPACKET_V3, since it will bring a better
performance due to fewer page cache misses caused by a higher density
of packets, since now they are contigous placed in the ring buffer.

It is said that TPACKET_V3 brings the following benefits:

 *) ~15 - 20% reduction in CPU-usage
 *) ~20% increase in packet capture rate
 *) ~2x increase in packet density
 *) Port aggregation analysis
 *) Non static frame size to capture entire packet payload

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
ring_rx: if v3, free it in kernel space during close

Let this be freed by the kernel during close(2) call in case of v3
otherwise we would get a -EINVAL.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
netsniff-ng: enable jumbo frames on default in tpacket_v3

Since frames are stored more compressed and contiguous, we can also
enable jumbo support in pcap dumps by default, since we have no further
restrictions in terms of ring buffer frame size.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
man: netsniff-ng: update man page to document when -J is needed

--jumbo-support is now not always needed anymore. So document when
one needs it and when not.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>