Possibility of BBR implementation in Linux BPF and issue encountered

183 views
Skip to first unread message

Mingrui

unread,
Sep 4, 2024, 9:09:19 AM9/4/24
to BBR Development

Hello everyone,


I was studying the BPF-based TCP Congestion Control Algorithms to achieve more flexibility in modifying TCP CCA without compiling the whole kernel. 


There were two examples of bpf_cubic and bpf_dctcp in kernel code, this motivated me to emulate existing work and transfer BBR to BPF_BBR.

However, I encountered following issue when I tried to register compiled object to kernel

libbpf: sec '.rodata': failed to determine size from ELF: size 0, err -2

More log here https://github.com/zmrui/bbr-bpf/blob/main/bpftool_debug_bbr.txt


My questions are:

  1. Is that possible to transfer BBR to BPF format? 

  2. Does anyone have any insights into the possible reason for that issue?

  3. Although the Clang compiler does not prompt, but I wonder if anyone could point out my implementation issue if there is one.


Thanks,

Mingrui


====

Here is my modified code

https://github.com/zmrui/bbr-bpf/blob/main/bpf_bbrv3.c

As PATCH to net-next.git 

https://github.com/zmrui/bbr-bpf/blob/main/0001-bbrv3.patch

https://github.com/zmrui/bbr-bpf/blob/main/0002-bbrv3-to-bpf.patch


My testing steps are:

$ clang -O2 -target bpf -c -g bpf_bbrv3.c

$ sudo bpftool struct_ops -d register bpf_bbrv3.o 


My changes to tcp_bbr.c(v3) are:

* Commented bpf_cubic unused tcp_congestion_ops section( .owner, .flags, .get_info)

* Change tcp_congestion_ops to BPF SEC struct_ops format

* Borrow macro defines, e.g. NSEC_PER_USEC, from other Linux files

* Borrow macro defines, e.g. WRITE_ONCE(), max_t(), from other Linux files

* Reimplemented abs(), do_div(), cmpxchg() to C code, and always return ceil-1 in get_random_u32_below() to implement it in C code.

* Copy implementation of kernel networking functions, e.g. tcp_packets_in_flight(),  and minmax related functions, e.g. minmax_reset()



Kevin Yang

unread,
Sep 10, 2024, 11:09:24 AM9/10/24
to Mingrui, BBR Development
Hi Mingrui,

Good to know that you're interested in BPF-based BBR.

> Is that possible to transfer BBR to BPF format?
It should be possible, at least I don't see any issue with that.

It would be hard for us to help you resolve BPF loading or compiling issues.
I'd suggest you to start with a bare minimum skelton code that can compile and load, then you can gradually add bbrv3 logic to the code step by step until you get the error. Then you should be able to tell what is causing the issue.

Thanks,
kevin

--
You received this message because you are subscribed to the Google Groups "BBR Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bbr-dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/bbr-dev/9058e6fa-6e26-4d46-ae3e-68bdd2cd1b06n%40googlegroups.com.

Mingrui Zhang

unread,
Sep 10, 2024, 11:09:32 AM9/10/24
to Kevin Yang, BBR Development

Thank you, Kevin,

> I'd suggest you to start with a bare minimum skelton code that can compile and load, then you can gradually add bbrv3 logic to the code step by step until you get the error. Then you should be able to tell what is causing the issue.

Thank you for your suggestion, and I will start from the the bare minimum skelton code from tools/testing/selftests/bpf/progs/tcp_ca_kfunc.c which direct call kfunc to kernel BBR and gradually add bbrv3 logic.


Thanks,

Mingrui

Reply all
Reply to author
Forward
0 new messages