Turns out the atomics just needed to operate on a 64-bit variable, we
didn't actually need a newer compiler.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Endianness fixes for IP header length, need to also rewrite Ethernet
protocol. Also use direct packet access instead of skb_store_bytes().
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
This adds an initial version of a NAT64 translator in BPF. It compiles and
loads, but doesn't actually appear to work yet.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Remember that xdp-project have fork of libbpf we use
https://github.com/xdp-project/libbpf
Synced to this libbpf via running command:
git submodule update --remote
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
This was added in kernel commit:
8fd886911a6a ("bpf: Add BTF_KIND_FLOAT to uapi") (Author: Ilya Leoshkevich)
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Fixes pull request #24
I had forgot to git add headers/vmlinux/vmlinux_arch.h in PR#24
which caused compile failures for ktrace-CO-RE.
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
Update README, mainly add a new section with a brief descriptions and
some examples of the output formats.
Also, update the files and maps list to reflect recent changes (BPF
programs can now push flow-events, and the map rtt_events has been
renamed to just events.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Simplify the three output functions by breaking them up into smaller
helper functions. Also introduce the pping_event union, which can hold
either an rtt_event or flow_event.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Make the flow_timeout function call the current output function to
simulate a flow-closing event. Also some other minor cleanup/fixes.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Add "flow events" (flow opening or closing so far) which will trigger
a printout of message.
Note: The ppviz format will only print out the traditional rtt events
as the format does not include opening/closing messages.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Use a JSON-writer library from iproute instead of complicated printf
statement. Also output timestamp, rtt and min_rtt as integers in
nanoseconds, rather than floats in seconds.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Change order of parameters for format_ip_address to follow the
convention of the printf functions where buffer is placed first,
instead of the conventions of the inet_ntop functions where buffer is
placed last.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Add per-flow tracking of number of packets and bytes
sent/received. Add these to the JSON output format.
Also update README regarding concurrency issue when updating these
statistics.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Also, remove comments about concurrency issues from code in
pping_kern.c as it is now documented in README.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
The format option can take the values "standard" (default), "json" and
ppviz (new name for "machine-friendly").
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Add Kathie's "machine friendly" as an optional output format when
passing '-m' or '--machine-friendly' to pping. This format can be used
together with Kathie's ppviz tool to visaulize the output.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Add the option to output in JSON format by passing '-j' or '--json' to
pping. Include the protocol in the JSON format, and fix so kernel-side
actually stores the protocol in the flow_address struct.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
To add timestamp to output, push the timestamp when packet was
processed from kernel as part of the rtt-event. Also keep track of
minimum encountered RTT for each flow in kernel, and also push that as
part of the RTT-event.
Additionally, avoid pushing RTT messages at all if no flow-state
information can be found (due to ex. being deleted from egress side),
as no valid min-RTT can then be given. Furthermore, no longer delete
flow-information once seeing the FIN-flag on egress in order to keep
useful flow-state around for RTT-messages longer. Due to the
FIN-handshake process, it is sufficient if the ingress program deletes
the flow-state upon seeing FIN. However, still delete flow-state from
either ingress or egress upon seeing RST flag, as RST does not have a
handshake process allowing for delayed deletion.
While minimum RTT could also be tracked from the userspace process,
userspace is not aware of when the flow is closed so would have to add
additional logic to keep track of minimum RTT for each flow and
periodically clean them up. Furthermore, keeping RTT statistics in the
flow-state map is useful for implementing future features, such as an
RTT-based sampling interval. It would also be useful in case pping is
changed to no longer have a long-running userspace process printing
out all the calculated RTTs, but instead simply occasionally looks up
the RTT from the flow-state map.
Signed-off-by: Simon Sundberg <simon.sundberg@kau.se>
Initial working version of DHCP relay using XDP is created. Currently, this code
has user program and a xdp ebpf program. User program takes network interface and
dhcp relay server IP as inputs and store it in a map. XDP program filters the
incoming DHCP requests and inserts option 82 in the DHCP request packets and
overwrites the destination IP to that of DHCP relay server IP.An optional argu
-ment for user program is also provided to unload the xdp program.
README file provides to instructions to build and load the xdp program.
Signed-off-by: Sachin Tiptur <sachin.tiptur.satyanarayana.gupta@hof-university.de>
[ whitespace fixes ]
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
There's a reason why Wireguard doesn't preserve DSCP marks across the
encapsulation, so let's make sure we warn about bypassing this in the
README.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
This is a fun example showing how to use BPF to preserve DSCP values across
an encapsulating interface, such as Wireguard. It relies on the
encapsulation layer preserving the skb->hash value across the
encapsulation, which is commonly the case on kernel encapsulation
protocols (including Wireguard), and uses a pair of TC BPF programs and a
map to re-match the packets after encapsulation and add back the DSCP
value.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Add a check that the protocol version field matches the expected value when
parsing IPv4 and IPv6 headers. This makes it possible to parse an IP header
that we don't know the version of (such as on interfaces that don't use an
Ethernet header).
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Seems we need to copy a few more bytes at once for the DHCP relay daemon,
so let's extend __bpf_memcpy to handle copies of up to 288 bytes.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Add the directory and Makefile rules to prepare for storing library
functions in lib/util like we do in xdp-tools. With this, library code can
be added by just dropping the .c and .h into lib/util and updating
lib/util/util.mk with the object name.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
We want to be able to use the new bpf_tc_attach() function for attaching TC
programs, so check for it in configure.
Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>