The bpf_helper_defs.h is used by (ibbpf provided) bpf/bpf_helpers.h.
Thus, it doesn't belong under headers/ directory.
Remove file: headers/bpf/bpf_helper_defs.h
Fixes: f0fce8f62b ("Update kernel headers and libbpf version")
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Refactor TC and XDP programs to reuse common logic for parsing
packets. Add functions for parsing packets for an identifier to
pping_helpers.h which both TC and XDP parts use. Also make it easier
to extend pping with support for new protocols, as only new parsing
functions have to be added and inserted into a single place.
Also add reserved members to end of structs in pping.h to indicate
padding.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
When some bpf example use libxdp then these can be re-added, along
with description of why projects needs to include these files.
Files removed:
headers/xdp/libxdp.h
headers/xdp/prog_dispatcher.h
headers/xdp/xdp_helpers.h
Fixes: 4513664ca3 ("Initial import with encap-forward example")
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
It is fairly natural to include <errno.h> in BPF programs as some
helpers and hooks use these errno defines (like lsm-nobpf/). Again we
discover that when compiling with clang option[1] "-target bpf" the OS
distros header files gets confused as __x86_64__ isn't define by clang
which in this case (on Fedora) cause include <gnu/stubs-32.h>.
The error looks like this:
$ make
CLANG lsm-nobpf-kern.o
In file included from lsm-nobpf-kern.c:6:
In file included from /usr/include/errno.h:25:
In file included from /usr/include/features.h:474:
/usr/include/gnu/stubs.h:7:11: fatal error: 'gnu/stubs-32.h' file not found
# include <gnu/stubs-32.h>
^~~~~~~~~~~~~~~~
This patch adds a compile test to configure script to help people
realize why compiling is failing on their systems.
[1] https://www.kernel.org/doc/html/latest/bpf/bpf_devel_QA.html#q-clang-flag-for-target-bpf
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Move some members in network_tuple and rtt_event around to avoid holes.
Also remove some uncecessary parentheses before & operator, and add
local definitions of AF_INET and AF_INET6.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Several changes to add IPv6 support:
- Change structs in pping.h
- replace ipv4_flow with network_tuple
- rename ts_key to packet_id
- rename ts_timestamp to packet_timestamp
- Add map_ipv4_to_ipv4 in pping_helpers.h
- Also remove obsolete fill_ipv4_flow
- Rewrite pping_kern*
- parse either IPv4 or IPv6 header (depending on proto)
- Use map_ipv4_to_ipv6 to store IPv4 address in network_tuple
Support printout of IPv6 addresses in pping.c
- Add function format_ip_address as wrapper over inet_ntop
- Change handle_rtt_event to first format IP-address strings in
local buffers, then perform single printout
While some steps have been taken to be more general towards different
types of packet identifiers (not just the currently supported TCP
timestamps), significant refactorization of pping_kern* will still be
required. Also, pping_kern_xdp and pping_kern_tc also have large
sections of very similar code that can be refactored into functions.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Create the /sys/fs/bpf/tc folder if it does not exist. Also check if
pping is run as root, otherwise inform user that it must run as root.
Libbpf will attempt to create the /sys/fs/bpf/tc/globals directory
when pinning the map, however it will not do so recursivly (so will
fail if /sys/fs/bpf/tc does not exist). So as a temporary solution,
attempt to create /sys/fs/bpf/tc (however, if sys/fs/bpf is not
mounted this will still fail).
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Refactor tc_bpf_load and tc_bpf_clear to use a common run_program
function which does the fork+execv.
Enclose compound statement defines in parenthesis.
Removed argument CLOCK_MONOTONIC from callers to parameterless
function get_time_ns().
Also fix some weird spacing in pping_helpers.h, and fix some
formatting issues, using clang-format with the kernel source tree
.clang-format on the whole tree.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Perform various fixes and tweaks:
- Rename several defines to make them more informative
- Remove unrolling of loop in BPF programs
- Reuse defines for program sections between userspace and kernel
space programs
- Perform fork+exec to run bpf_egress_loader script instead of
system()
- Add comment to copied scripts indicating I've modified them
- Add pping.h and pping_helpers.h as dependencies in Makefile
Also, add a brief description of what PPing is and how it works to
README
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Split the print statements for RTTs into two parts to avoid inet_ntoa
overwriting one of the IP-addresses (causing both source and
destitionation address to appear the same). Also flip the order of
source and destination to be the same as Pollere's pping.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Copy setup from traffic-pacing-edt to use BTF-defined map if configure
detects that iproute2 has libbpf support, otherwise fall back on
bpf_elf_map. Also fix a minor bug with setting default value for SEC
in bpf_egress_loader.sh.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Switch order so XDP program loads first, so the ts_start map is
automatically pinned by libbpf (solves issue with tc not preserving
the name of the map).
Unload the TCP-BPF program (or rather remove the entire clsact qdisc
it is attached to) using bpg_egress_loader script once program
exits. Also unpin ts_start map on program shutdown.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Make loader use libbpf's existing functionality for reusing pinned
maps. The name for map not kept by tc, so cannot get fd of map by
name. Use fd of first encountered map as temporary workaround.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Format the header files in the Linux kernel style (missed in previous
commit). Also fix a formating error in TODO.md that cause empty
checkboxes to not display correctly.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Format the code using the .clang-format from the kernel source tree,
with a few manual tweaks here and there. Also, remove the TODO list
from comment of pping.c and instead put it in TODO.md.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Make tc pin the ts_start map when loading the TC-BPF program, and
rewrite XDP loader to reuse map pinned by tc.
Also add comment with TODO list in pping.c.
Testing pping by adding a delay through a netem qdisc in the test
environment shows that the reported RTT will approach 100ms for any
delay lower than 100ms, but the correct RTT for any delay over
100ms. Root cause is unknown, but Pollere's original pping
implementation (as well as a bpftrace based pping implementation)
shows the same issue. This issue has not been observed when running on
real interfaces without a netem qdisc.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Split and rename files so there is one userspace program (pping) and
two kernel-space ones (one for XDP and one for TC-BPF).
Copy the shell script for loading the TC-BPF program from
traffic-pacing-edt folder, but add support for loading a specific
section.
The XDP and TC-BPF programs do not share the ts_start map, so program
does not work.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
The XDP program pushes the calculated RTTs to userspace through the
perf-buffer and the userspace program polls it to print them out
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
When installing libbpf headers into 'lib/libbpf/src/root/' then the git
submodule for libbpf is marked dirty. This result in stgit complains under
different operations.
This patch fix the issue by installing libbpf outside submodule directory.
Choose directory 'lib/libbpf-install/' to emphasize relation to 'lib/libbpf/'.
V2: Don't install the library only the header files as before. Also
installing the should be a separate commit. Patch still statically
link with libbpf/src/libbpf.a.
Signed-off-by: Jesper Dangaard Brouer <netoptimizer@brouer.com>
SPDX-License should be first line in file.
This Makefile is for bpf-examples not xdp-tools.
Signed-off-by: Jesper Dangaard Brouer <netoptimizer@brouer.com>
We run 'make install' inside the libbpf subdirectory which will mark it as
'dirty' as far as the parent repo is concerned. Since we're not doing any
libbpf development in this repository, just ignoring it should not bring
any issues; we'll still get a notification if the committed content of the
submodule changes.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
On production setup i40e driver sends all packets to CPU-6 (RX).
Thus, we want to exclude CPU-6 itself from processing/pacing
packets itself.
Signed-off-by: Jesper D. Brouer <netoptimizer@brouer.com>