Add command-line flags for each protocol that pping should attempt to
parse and report RTTs for (currently -T/--tcp and -C/--icmp). If no
protocol is specified assume TCP. To clarify this, output a message
before start on how ePPing has been configured (stating output format,
tracked protocols and which interface to run on).
Additionally, as the ppviz format was only designed for TCP it does
not have any field for which protocol an entry belongs to. Therefore,
emit a warning in case the user selects the ppviz format with anything
other than TCP.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Allow pping to passivly monitor RTT for ICMP echo request/reply
flows. Use the echo identifier as ports, and echo sequence as packet
identifier.
Additionally, add protocol to standard output format in order to be
able to distinguish between TCP and ICMP flows.
The ppviz format does not include protocol, making it impossible to
distinguish between TCP and ICMP traffic. Will add warning if ppviz
format is used together with ICMP traffic in the future.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
The echoed TCP timestamp (TSecr) is only valid if the ACK flag is
set. So make sure to only attempt to match on ACK packets.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Digging into the return value of netdev_pick_tx().
Want to be able to debug the case where a socket
selects another queue_id.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
The BPF-prog "not_txq_zero" also needed to take into account
that skb->queue_mapping usually isn't set for locally
generated traffic.
I worry that sockets can set another queue id that could
override our (BPF choice) in netdev_pick_tx().
See sk_tx_queue_set() and sk_tx_queue_get().
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
This version of the XPS script have been modified to
work with the shell ash. As bash was not avail on
the Yocto target host.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Also intercept SIGTERM (in addition the the previously intercepted
SIGINT) and perform graceful shutdown.
Perhaps it also makes sense to perform graceful shutdown on some
additional signals, like SIGHUP and SIGQUIT?
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
This seems to be a common occuring issue with tc cmdline.
And the C-code have inherited the issue in the API.
Trying to replace a TC-BPF prog often result in appending a new prog
(as a new tc filter instance).
Be careful to set both handle and prio and the replace flag.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
The reason for going this route is that this allow us to
create a user binary that contains the BPF object file.
Thus, we can avoid having to load the BPF file from
a specific location or having to be in same dir as file.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
The Yocto build this is intended for doesn't have /bin/bash
adapt script.
External program "getopt" not avail.
The 'sort' tool is also different, as it comes from busybox.
Adapt the cmdline options for 'sort'.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Yocto build have a problem with loading this via tc
# tc filter replace dev eth1 egress prio 0xC000 handle 1 bpf da obj tc_txq_policy_kern.o
Continuing without mounted eBPF fs. Too old kernel?
mkdir (null)/globals failed: No such file or directory
Unable to load program
It can be worked around via mounting BPF file-system manually:
# mount -t bpf bpf /sys/fs/bpf/
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
The libbpf API has deprecated a number of functions used by the pping
loader. While a couple of functions have simply been renamed,
bpf_object__find_program_by_title has been completely deprecated in
favor of bpf_object__find_program_by_name. Therefore, change so that
BPF programs are found based on the C function names rather than
section names.
Also remove defines of section names as they are no longer used, and
change the section names in pping_kern.c to use "tc" instead of
"classifier/ingress" and "classifier/egress".
Finally replace the flags json_format and json_ppviz in pping_config
with a single enum for the different output formats. This makes the
logic for which output format to use clearer compared to relying on
multiple (supposedly) mutually exclusive flags (and implicitly
assuming standard format if neither flag was set).
One potential concern with this commit is that it introduces some
"magical strings". In case the function names in pping_kern.c are
changed it will require multiple changes in pping.c.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
The rate-limit and cleanup-interval arguments were only verified to be
positive. Add a check for an upper bound to avoid user being able to
pass values that result in an internal overflow. The limits for both
rate-limit and cleanup-interval have been set to one week which should
be more then enough for any reasonable user.
Additionally, disable the period cleanup entirely if the value 0 is
passed to cleanup-interval.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Make several changes to functions related to attaching and detaching
the BPF programs:
- Check the BPF program id when detaching programs to ensure that the
correct programs are removed.
- When attaching tc-programs, keep track of if the clsact qdisc was
created or existed previously. Attempt to delete the qdisc if it was
created and attaching failed. If the --force argument was given, also
attempt to delete qdisc on shutdown in case it did not previously
exist.
- Rely on XDP flags to replace existing XDP program if --force is used
rather than explicitly detaching any XDP program first.
- Print out hints for why pping might have failed attaching the XDP
program.
Also, use libbpf_strerror instead of strerror to better display
libbpf-specific error codes, and for more reliable error handling in
general (don't need to ensure the error codes are positive).
Finally, change return codes of tc programs to TC_ACT_UNSPEC from
TC_ACT_OK to allow other TC-BPF programs to be used on the same
interface as pping.
Concerns with this commit:
- When attaching a tc program libbpf will emit a warning if the
clsact qdisc already exists on the interface. The fact that the
clsact already exists is not an issue, and is handled in tc_attach
by checking for EEXIST, so the warning could be a bit
misleading/confusing for the user.
- The tc_attach and xdp_attach functions attempt to return the u32
prog_id in an int. In case the programs are assigned a very high
id (> 2^31) this may cause it to be interpreted as an error instead.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
For some machines, XDP may not be suitable due to ex. lack of XDP
support in NIC drivers or another program already being attached to
the XDP hook on the desired interface. Therefore, add an option to use
the tc-ingress hook instead of XDP to attach the pping ingress BPF
program on.
In practice, this adds an additional BPF program to the object file (a
TC ingress program). To avoid loading an unnecessary BPF program, also
explicitly disable autoloading for the ingress program not selected.
Also, change the tc programs to return TC_ACT_OK instead of
BPF_OK. While both should be compatible, the TC_ACT_* return codes
seem to be more commonly used for TC-BPF programs.
Concerns with this commit:
- The error messages for XDP attach failure has gotten slightly less
descriptive. I plan to improve the code for attaching and detaching
XDP programs in a separate commit, and will then address that.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
libbpf v0.4 added an API for attaching/detaching TC-BPF programs. So
use the new API to attach the tc program instead of calling on an
external script (which uses the tc command line utility).
Avoid removing the clsact qdisc on program shutdown or error, as
there's currently no convenient way to ensure the qdisc isn't used by
other programs as well. This means pping will not completely clean up
after itself, but this is a safer alternative than always destroying
the qdsic as done by the external script, which may pull the rug out
underneath other programs using the qdisc.
Finally, remove the pin_dir member from the configuration as pping no
longer pins any programs or maps, and remove deleted tc loading
scripts from README.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Add cleanup code to load_attach_bpfprogs function, so it should always
unpin tc program, and additionally detach the tc and xdp programs in
case of any failure.
Also unpin tc program directly after attaching it (rather than on
program shutdown), so that multiple instances of pping can be run
simultaneously (on different interfaces).
Finally, rename some of the functions for attaching/detaching tc
programs to be more consistent with the xdp ones.
Note: Still need to keep a copy of most of the cleanup code in main as
well, as the tc and xdp programs also need to be detached on program
shutdown or if later functions fail.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Newer libbpf uses constants from the newer kernel header file, so
compilation breaks unless we have the newest version of the kernel header.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
The bpf_program__next() helper was deprecated in favour of
bpf_object__next_program(), so switch to that.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Update the libbpf submodule to the latest version, and update the configure
script so we check for the newer bpf_object__next_program() helper (to fix
deprecation warnings).
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
I hope there exist a better API for determining when AF_XDP
is ready for transmitting packets.
This workaround keeps trying to send a single packet, and
check return value seen from sendto() syscall, until it
doesn't return an error.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Give a print WARN if code/AF_XDP somehow have MORE packets to
complete from CQ than our counter for xsk->outstanding_tx packets.
This should not happen, but currently hunting for a TX issue.
The code (below) reset xsk->outstanding_tx, which were introduced
via a discussion on xdp-tutorial:
https://github.com/xdp-project/xdp-tutorial/issues/180
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>