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>
netsniff-ng: minor: update help description

Give -J a lower prio in the help option ranking and state that its
only for replay or forwarding.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
ifpps: Rename variable containing top number of CPUs

To make it more clear whether we're using the total number of CPUs or
the top number (default 10 or specified by user), rename the variable,
where the top number is used.

Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
zsh: update zsh autocompletion functions to implementation

Update those functions to implementation status.

Signed-off-by: Hideo Hattori <hhatto.jp@gmail.com>
Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
irq: break out from xutils and save + restore

Break out IRQ functionality from xutils, simplify it, and
save + restore IRQ affinity list.

Signed-off-by: Daniel Borkmann <dborkman@redhat.com>
netsniff-ng: v3: fix packet accounting on --num

We need to carry frame_count through multiple calls of walk function
to account correctly for --num <pkts>. Also, move socket stats printing
into rx ring, since it belongs there.

Todo: the kernel socket seems to have a different count that what we
see. This needs to be fixed one way or the other. Not yet sure what's
causing this.

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