navarrothiago / upf-bpf Goto Github PK
View Code? Open in Web Editor NEWAn In-Kernel Solution Based on BPF/XDP for 5G UPF
License: Apache License 2.0
An In-Kernel Solution Based on BPF/XDP for 5G UPF
License: Apache License 2.0
The HTTP server would be useful for quick trials.
The Test Case is described on issue #2.
Reference: https://github.com/navarrothiago/openair-uml#input-path
The idea is to load the environment variable before run the scripts.
Based on Federico Parolo Thesis (Prototyping an eBPF-based 5G Mobile Gateway)
If free5gc' NF as control plane, how to configure this UPF-BPF, for example: N3 INTERFACE 、 N6 INTERFACE、 N4 INTERFACE
Hi,
Can I use the run.py file itself to generate the gtp packets or do I need to setup the Upf-bpf and run according to Doc.
upf-bpf/tests/trex/test_cases/run.py
Lines 29 to 35 in 2b6679f
Iam new to this if there is any way to generate gtp packets directly from run.py can you please help me with this. what are the args to be passed while running.
The idea is to create an gRPC API to enables integration with UPF/SPGWu that is not implemented with C++.
Implement logic to get session by SEID. The SEID is available in PDR stored inside the hash map (TEID->PDR).
linux/bpf.h:65:8: error: redefinition of 'struct bpf_insn'
struct bpf_insn {
^~~~~~~~
In file included from /usr/include/pcap/pcap.h:51:0,
from /usr/include/pcap.h:43,
from /usr/local/include/pcapplusplus/PcapDevice.h:17,
from /usr/local/include/pcapplusplus/PcapLiveDevice.h:5,
from /usr/local/include/pcapplusplus/PcapLiveDeviceList.h:5,
from /workspaces/openair-cn-cups/test/integration/spgwu_tests.cpp:12:
/usr/include/pcap/bpf.h:238:8: note: previous definition of 'struct bpf_insn'
struct bpf_insn {
here suggest to define PCAP_DONT_INCLUDE_PCAP_BPF_H
, but here suggest avoiding this approach.
The apply rules path diagram is available here.
Uplink data flow using GTP GPDU.
As mentioned in #18 (comment), it would be good with we do not need to include de spdlog. The UpfBpfConfig could import everything.
Check project like cilium, polycube.
E.g.: github action, cicleci
Hello!
I tried to blindly follow the instructions in the First Steps part of the README to set up the environment, and there were some issues that may be interesting to review:
I'm not used to Github, but if I can help with those, please let me know :)
The ideia is to make easier the usable of the framework
Includes:
include_directories(${SRC_TOP_DIR}/../build/ext/upf-bpf/include)
include_directories(${SRC_TOP_DIR}/../build/ext/upf-bpf/src)
include_directories(${SRC_TOP_DIR}/../build/ext/upf-bpf/src/bpf)
include_directories(${SRC_TOP_DIR}/../build/ext/upf-bpf/build/src/bpf/skel)
Libraries:
${SRC_TOP_DIR}/../build/ext/upf-bpf/build/src/libupf_xdp.a
${SRC_TOP_DIR}/../build/ext/upf-bpf/extern/libbpf/src/libbpf.a
elf
z
We must include git-lfs installation in README.md.
Because the upf-bpf is a C++ library, a good candidate to do this integration is the OpenAirInterface's SPGWu, which is also implemented using C++. Here is some suggestion of task for this PoC:
[1] - I didnt find any open source tool that could be a PFPC client (e.g. here).
[2] - I have some hardcoded implementation. Check here. The idea is to inject the ITTI messages in SPGWu. The ITTI is a m
The test case description is defined here.
Using dummy rules.
The environment was based on [8].
It is not possible to redirect packet from NIC to Wifi using XDP [5].
References:
Related Issue: #2
bpftools
with libbpf
This helper function is useful for head packet manipulation. See here for more information.
Run sample using make run-samples
and the output was:
# tracer: nop
#
# entries-in-buffer/entries-written: 0/0 #P:8
#
# _-----=> irqs-off
# / _----=> need-resched
# | / _---=> hardirq/softirq
# || / _--=> preempt-depth
# ||| / delay
# TASK-PID CPU# |||| TIMESTAMP FUNCTION
# | | | |||| |
TODO:
create_pdr
based on PFCP TS 29 244Test Case:
References:
The idea is create a basic implemantion in order to trace GTP G-PDU packets with debug messages.
Test Case:
Linux #0
make run
in Linux #0
gtpu-traffic-generator.py
in Linux #1
Linux #0
sudo tcpdump -i <NIC1 INTEFACE>
, where NIC1 INTERFACE
is the network interfaceLinux #0
sudo cat /sys/kernel/debug/tracing/trace | grep "GPDU"
in Linux #0
GTP GPDU received
Code reference:
Compiled in ubuntu 18.04 and run in ubuntu 20.04
[ebpf@india] ~/package/bin $ cd /home/ebpf/package; sudo ip link set dev enp3s0f1 xdp off; sudo ip link set dev enp3s0f0 xdp off; sudo ./bin/api 10.1.1.27 80
[sudo] password for ebpf:
Sorry, try again.
[sudo] password for ebpf:
[2021-05-23 14:21:02.602] [upf_logger] [info] [220681.901196864] (/workspaces/tests/api/Server.cpp:26) Running server on endpoint 10.1.1.27:80
[2021-05-23 14:21:05.601] [upf_logger] [debug] [220681.849340160] [bgn] Controller::setup
[2021-05-23 14:21:05.601] [upf_logger] [debug] [220681.849340160] [bgn] RulesUtilitiesImpl::RulesUtilitiesImpl
[2021-05-23 14:21:05.601] [upf_logger] [debug] [220681.849340160] [end] RulesUtilitiesImpl::RulesUtilitiesImpl
[2021-05-23 14:21:05.601] [upf_logger] [debug] [220681.849340160] (/workspaces/tests/api/Controller.cpp:37) GTP interface: enp3s0f0
[2021-05-23 14:21:05.601] [upf_logger] [debug] [220681.849340160] (/workspaces/tests/api/Controller.cpp:38) UDP interface: enp3s0f1
[2021-05-23 14:21:05.601] [upf_logger] [debug] [220681.849340160] [bgn] &UserPlaneComponent::getInstance
[2021-05-23 14:21:05.601] [upf_logger] [debug] [220681.849340160] [bgn] UserPlaneComponent::UserPlaneComponent
[2021-05-23 14:21:05.601] [upf_logger] [debug] [220681.849340160] [end] UserPlaneComponent::UserPlaneComponent
[2021-05-23 14:21:05.601] [upf_logger] [debug] [220681.849340160] [end] &UserPlaneComponent::getInstance
[2021-05-23 14:21:05.601] [upf_logger] [debug] [220681.849340160] [bgn] UserPlaneComponent::setup
[2021-05-23 14:21:05.602] [upf_logger] [debug] [220681.849340160] [bgn] UPFProgram::UPFProgram
[2021-05-23 14:21:05.602] [upf_logger] [debug] [220681.849340160] [bgn] ProgramLifeCycle<upf_xdp_bpf_c>::ProgramLifeCycle(std::function<BPFSkeletonType *()>, std::function<
[2021-05-23 14:21:05.602] [upf_logger] [debug] [220681.849340160] [end] ProgramLifeCycle<upf_xdp_bpf_c>::ProgramLifeCycle(std::function<BPFSkeletonType *()>, std::function<
[2021-05-23 14:21:05.602] [upf_logger] [debug] [220681.849340160] [end] UPFProgram::UPFProgram
[2021-05-23 14:21:05.602] [upf_logger] [debug] [220681.849340160] [bgn] &SignalHandler::getInstance
[2021-05-23 14:21:05.602] [upf_logger] [debug] [220681.849340160] [end] &SignalHandler::getInstance
[2021-05-23 14:21:05.602] [upf_logger] [debug] [220681.849340160] [bgn] SignalHandler::enable
[2021-05-23 14:21:05.602] [upf_logger] [debug] [220681.849340160] [end] SignalHandler::enable
[2021-05-23 14:21:05.602] [upf_logger] [debug] [220681.849340160] [bgn] UPFProgram::setup
[2021-05-23 14:21:05.602] [upf_logger] [debug] [220681.849340160] [bgn] *ProgramLifeCycle<upf_xdp_bpf_c>::open
libbpf: sec 'xdp_entry_point': failed to find program symbol at offset 0
libbpf: failed to initialize skeleton BPF object 'upf_xdp_bpf_c': -4001
[2021-05-23 14:21:05.603] [upf_logger] [debug] [220681.849340160] [end] *ProgramLifeCycle<upf_xdp_bpf_c>::open
[2021-05-23 14:21:05.603] [upf_logger] [debug] [220681.849340160] [bgn] UPFProgram::initializeMaps
[2021-05-23 14:21:05.603] [upf_logger] [debug] [220681.849340160] [bgn] *ProgramLifeCycle<upf_xdp_bpf_c>::getBPFSkeleton
[2021-05-23 14:21:05.603] [upf_logger] [debug] [220681.849340160] [end] *ProgramLifeCycle<upf_xdp_bpf_c>::getBPFSkeleton
ASAN:DEADLYSIGNAL
=================================================================
==220681==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000000 (pc 0x56545cca2b82 bp 0x7f40329fc3f0 sp 0x7f40329fc180 T2)
==220681==The signal is caused by a READ memory access.
==220681==Hint: address points to the zero page.
#0 0x56545cca2b81 in std::_MakeUniq<BPFMaps>::__single_object std::make_unique<BPFMaps, bpf_object_skeleton*&>(bpf_object_skeleton*&) /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../
../include/c++/7.5.0/bits/unique_ptr.h:821
#1 0x56545cca2b81 in UPFProgram::initializeMaps() /workspaces/src/programs/UPFProgram.cpp:88
#2 0x56545cca1d67 in UPFProgram::setup() /workspaces/src/programs/UPFProgram.cpp:28
#3 0x56545cc82d46 in UserPlaneComponent::setup(std::shared_ptr<RulesUtilities>, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basi
c_string<char, std::char_traits<char>, std::allocator<char> > const&) /workspaces/src/UserPlaneComponent.cpp:95
#4 0x56545cc61213 in Controller::setup(nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned l
ong, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >&, nlohmann::basic_json<std::map, std::vector, std::__cxx11::basic_string<c
har, std::char_traits<char>, std::allocator<char> >, bool, long, unsigned long, double, std::allocator, nlohmann::adl_serializer, std::vector<unsigned char, std::allocator<unsigned char> > >
&) /workspaces/tests/api/Controller.cpp:40
#5 0x56545cbcec83 in operator() /workspaces/tests/api/Server.cpp:35
#6 0x56545cbcf69f in _M_invoke /usr/include/c++/7/bits/std_function.h:316
#7 0x56545cbea2a2 in std::function<void (httplib::Request const&, httplib::Response&)>::operator()(httplib::Request const&, httplib::Response&) const /usr/include/c++/7/bits/std_function
.h:706
#8 0x56545cbdde8c in httplib::Server::dispatch_request(httplib::Request&, httplib::Response&, std::vector<std::pair<std::__cxx11::basic_regex<char, std::__cxx11::regex_traits<char> >, st
d::function<void (httplib::Request const&, httplib::Response&)> >, std::allocator<std::pair<std::__cxx11::basic_regex<char, std::__cxx11::regex_traits<char> >, std::function<void (httplib::R
equest const&, httplib::Response&)> > > > const&) /usr/local/include/httplib.h:4881
#9 0x56545cbddbe8 in httplib::Server::routing(httplib::Request&, httplib::Response&, httplib::Stream&) /usr/local/include/httplib.h:4859
#10 0x56545cbdf436 in httplib::Server::process_request(httplib::Stream&, bool, bool&, std::function<void (httplib::Request&)> const&) /usr/local/include/httplib.h:5099
#11 0x56545cbdf774 in httplib::Server::process_and_close_socket(int)::{lambda(httplib::Stream&, bool, bool&)#1}::operator()(httplib::Stream&, bool, bool&) const /usr/local/include/httpli
b.h:5131
#12 0x56545cbec747 in bool httplib::detail::process_server_socket<httplib::Server::process_and_close_socket(int)::{lambda(httplib::Stream&, bool, bool&)#1}>(int, unsigned long, long, lon
g, long, long, long, httplib::Server::process_and_close_socket(int)::{lambda(httplib::Stream&, bool, bool&)#1})::{lambda(bool, bool&)#1}::operator()(bool, bool&) const /usr/local/include/htt
plib.h:2012
#13 0x56545cbf6d95 in bool httplib::detail::process_server_socket_core<bool httplib::detail::process_server_socket<httplib::Server::process_and_close_socket(int)::{lambda(httplib::Stream
&, bool, bool&)#1}>(int, unsigned long, long, long, long, long, long, httplib::Server::process_and_close_socket(int)::{lambda(httplib::Stream&, bool, bool&)#1})::{lambda(bool, bool&)#1}>(int
, unsigned long, long, httplib::Server::process_and_close_socket(int)::{lambda(httplib::Stream&, bool, bool&)#1}) /usr/local/include/httplib.h:1994
#14 0x56545cbec804 in bool httplib::detail::process_server_socket<httplib::Server::process_and_close_socket(int)::{lambda(httplib::Stream&, bool, bool&)#1}>(int, unsigned long, long, lon
g, long, long, long, httplib::Server::process_and_close_socket(int)::{lambda(httplib::Stream&, bool, bool&)#1}) /usr/local/include/httplib.h:2013
#15 0x56545cbdf82a in httplib::Server::process_and_close_socket(int) /usr/local/include/httplib.h:5131
#16 0x56545cbdd0ae in httplib::Server::listen_internal()::{lambda()#1}::operator()() const (/home/ebpf/package/bin/api+0x19b0ae)
#17 0x56545cbf6226 in std::_Function_handler<void (), httplib::Server::listen_internal()::{lambda()#1}>::_M_invoke(std::_Any_data const&) (/home/ebpf/package/bin/api+0x1b4226)
#18 0x56545cbe6c39 in std::function<void ()>::operator()() const /usr/include/c++/7/bits/std_function.h:706
#19 0x56545cbd2da7 in httplib::ThreadPool::worker::operator()() (/home/ebpf/package/bin/api+0x190da7)
#20 0x56545cc1a700 in void std::__invoke_impl<void, httplib::ThreadPool::worker>(std::__invoke_other, httplib::ThreadPool::worker&&) (/home/ebpf/package/bin/api+0x1d8700)
#21 0x56545cc110ff in std::__invoke_result<httplib::ThreadPool::worker>::type std::__invoke<httplib::ThreadPool::worker>(httplib::ThreadPool::worker&&) (/home/ebpf/package/bin/api+0x1cf0
ff)
#22 0x56545cc5fc3b in decltype (__invoke((_S_declval<0ul>)())) std::thread::_Invoker<std::tuple<httplib::ThreadPool::worker> >::_M_invoke<0ul>(std::_Index_tuple<0ul>) (/home/ebpf/package
/bin/api+0x21dc3b)
#23 0x56545cc5fb01 in std::thread::_Invoker<std::tuple<httplib::ThreadPool::worker> >::operator()() (/home/ebpf/package/bin/api+0x21db01)
#24 0x56545cc5f961 in std::thread::_State_impl<std::thread::_Invoker<std::tuple<httplib::ThreadPool::worker> > >::_M_run() (/home/ebpf/package/bin/api+0x21d961)
#25 0x7f4035fb9d83 (/lib/x86_64-linux-gnu/libstdc++.so.6+0xd6d83)
#26 0x7f4036470608 in start_thread (/lib/x86_64-linux-gnu/libpthread.so.0+0x9608)
#27 0x7f4035df8292 in __clone (/lib/x86_64-linux-gnu/libc.so.6+0x122292)
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV /usr/bin/../lib/gcc/x86_64-linux-gnu/7.5.0/../../../../include/c++/7.5.0/bits/unique_ptr.h:821 in std::_MakeUniq<BPFMaps>::__single_object std::make_unique<BPFMaps, bpf_object_skeleton*&>(bpf_object_skeleton*&)
Thread T2 created by T0 here:
#0 0x7f40364c2b3f in pthread_create (/lib/x86_64-linux-gnu/libasan.so.4+0x38b3f)
#1 0x7f4035fba048 in std::thread::_M_start_thread(std::unique_ptr<std::thread::_State, std::default_delete<std::thread::_State> >, void (*)()) (/lib/x86_64-linux-gnu/libstdc++.so.6+0xd7048)
#2 0x56545cc015b9 in void __gnu_cxx::new_allocator<std::thread>::construct<std::thread, httplib::ThreadPool::worker>(std::thread*, httplib::ThreadPool::worker&&) (/home/ebpf/package/bin/api+0x1bf5b9)
#3 0x56545cbf11db in void std::allocator_traits<std::allocator<std::thread> >::construct<std::thread, httplib::ThreadPool::worker>(std::allocator<std::thread>&, std::thread*, httplib::ThreadPool::worker&&) (/home/ebpf/package/bin/api+0x1af1db)
#4 0x56545cbf129c in void std::vector<std::thread, std::allocator<std::thread> >::_M_realloc_insert<httplib::ThreadPool::worker>(__gnu_cxx::__normal_iterator<std::thread*, std::vector<std::thread, std::allocator<std::thread> > >, httplib::ThreadPool::worker&&) (/home/ebpf/package/bin/api+0x1af29c)
#5 0x56545cbe6d9d in void std::vector<std::thread, std::allocator<std::thread> >::emplace_back<httplib::ThreadPool::worker>(httplib::ThreadPool::worker&&) (/home/ebpf/package/bin/api+0x1a4d9d)
#6 0x56545cbd2a14 in httplib::ThreadPool::ThreadPool(unsigned long) (/home/ebpf/package/bin/api+0x190a14)
#7 0x56545cbda45f in httplib::Server::Server()::{lambda()#1}::operator()() const (/home/ebpf/package/bin/api+0x19845f)
#8 0x56545cbf3b49 in std::_Function_handler<httplib::TaskQueue* (), httplib::Server::Server()::{lambda()#1}>::_M_invoke(std::_Any_data const&) (/home/ebpf/package/bin/api+0x1b1b49)
#9 0x56545cbebc69 in std::function<httplib::TaskQueue* ()>::operator()() const (/home/ebpf/package/bin/api+0x1a9c69)
#10 0x56545cbdd107 in httplib::Server::listen_internal() (/home/ebpf/package/bin/api+0x19b107)
#11 0x56545cbdb05f in httplib::Server::listen(char const*, int, int) (/home/ebpf/package/bin/api+0x19905f)
#12 0x56545cbcf1ab in main /workspaces/tests/api/Server.cpp:46
#13 0x7f4035cfd0b2 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x270b2)
==220681==ABORTING
Use make run-samples
to build and run Hello World using BPF and XDP.
References:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.