Commit Graph

59 Commits

Author SHA1 Message Date
1bb5a44152 pping: Create pin-folder and check if root
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>
2021-02-04 19:56:49 +01:00
c777287af2 pping: Minor refactor and whitespace fixes
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>
2021-02-04 19:52:40 +01:00
7410d5cc2c pping: Various minor fixes
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>
2021-02-04 19:48:01 +01:00
71c6458712 pping: Fix incorrect printout of IP-address
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>
2021-02-04 19:47:15 +01:00
b920d72fe0 pping: Let libbpf pin map and clean up TC and map at end
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>
2021-02-04 19:44:33 +01:00
337126306b pping: Switch to BTF-defined maps for XDP program
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>
2021-02-04 19:44:06 +01:00
d3a5de62c4 pping: Format code and add SPDX lincense tags
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>
2021-02-04 19:43:03 +01:00
1010e53065 pping: Share ts_start map, pping at working stage
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>
2021-02-04 19:41:40 +01:00
954c66b0e8 pping: Add TC-BPF program for egress
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>
2021-02-04 19:39:16 +01:00