diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile deleted file mode 100644 index 8679575..0000000 --- a/.devcontainer/Dockerfile +++ /dev/null @@ -1,56 +0,0 @@ - -#------------------------------------------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information. -#------------------------------------------------------------------------------------------------------------- - -# Note: You can use any Debian/Ubuntu based image you want. -FROM debian:9 - -# Avoid warnings by switching to noninteractive -ENV DEBIAN_FRONTEND=noninteractive - -# Docker Compose version -ARG COMPOSE_VERSION=1.24.0 - -# This Dockerfile adds a non-root user with sudo access. Use the "remoteUser" -# property in devcontainer.json to use it. On Linux, the container user's GID/UIDs -# will be updated to match your local UID/GID (when using the dockerFile property). -# See https://aka.ms/vscode-remote/containers/non-root-user for details. -ARG USERNAME=vscode -ARG USER_UID=1000 -ARG USER_GID=$USER_UID - -# Configure apt and install packages -RUN apt-get update \ - && apt-get -y install --no-install-recommends apt-utils dialog 2>&1 \ - # - # Verify git, process tools installed - && apt-get -y install git openssh-client less iproute4 procps \ - # - # Install Docker CE CLI - && apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common lsb-release \ - && curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | (OUT=$(apt-key add - 2>&1) || echo $OUT) \ - && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" \ - && apt-get update \ - && apt-get install -y docker-ce-cli \ - # - # Install Docker Compose - && curl -sSL "https://github.com/docker/compose/releases/download/${COMPOSE_VERSION}/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose \ - && chmod +x /usr/local/bin/docker-compose \ - # - # Create a non-root user to use if preferred - see https://aka.ms/vscode-remote/containers/non-root-user. - && groupadd --gid $USER_GID $USERNAME \ - && useradd -s /bin/bash --uid $USER_UID --gid $USER_GID -m $USERNAME \ - # [Optional] Add sudo support for the non-root user - && apt-get install -y sudo \ - && echo $USERNAME ALL=\(root\) NOPASSWD:ALL > /etc/sudoers.d/$USERNAME\ - && chmod 0440 /etc/sudoers.d/$USERNAME \ - # - # Clean up - && apt-get autoremove -y \ - && apt-get clean -y \ - && rm -rf /var/lib/apt/lists/* - -# Switch back to dialog for any ad-hoc use of apt-get -ENV DEBIAN_FRONTEND=dialog diff --git a/.env.sample.sh b/.env.sample.sh new file mode 100644 index 0000000..8275f20 --- /dev/null +++ b/.env.sample.sh @@ -0,0 +1,94 @@ +# Docker container workspace. +WORKSPACE=/workspaces + +BPF_SAMPLES_DIR="${WORKSPACE}"/build/samples +BPF_BINARY_DIR="${WORKSPACE}"/build/tests + +# Compilation environment variable. +NUM_THREADS= + +# Docker environment variable. +USERNAME=oai-spgwu +IMAGE_TAG=upee +IMAGE_VERSION=v1.0 +DOCKERFILE=Dockerfile +SSH_FOLDER=~/.ssh +SSH_PUBLIC_KEY_FILE=id_rsa.pub +SSH_PRIVATE_KEY_FILE=id_rsa +SSH_CONFIG_FILE=config +GIT_CONFIG=~/.gitconfig +BASH_RC=~/.bashrc + +# TODO navarrothiago - Remove hardcoded https://github.com/navarrothiago/upf-bpf/issues/24 +DEVICE_IN= +DEVICE_OUT_UL= +DEVICE_OUT_DL= + +# TODO navarrothiago - pass as exec param. +GTP_INTERFACE= +UDP_INTERFACE= +SOCKET_BUFFER_ENABLED=0 + +# Test environment variables. +TEST_CASE=hello_world +GTEST_FILTER_ARGS="*.*" + +# Jump server. +JUMP_SERVER_NAME= +JUMP_SERVER_USERNAME= +JUMP_SERVER_IP= +JUMP_SERVER_PORT= + +# Trex version. +TREX_VERSION=v2.87 +TREX_SHA256SUM=290c1be468335a2de2e69f217b139c9b1198732e529bfd069348d05297548b8a + +# Trex server configuration. +TREX_SERVER_NAME= # Warning: Optional - If you set the name, it must be configured on your ssh config. +TREX_SERVER_IP= +TREX_SERVER_ASYNC_PORT= +TREX_SERVER_SYNC_PORT= +TREX_SERVER_USERNAME= +TREX_SERVER_SSH="${TREX_SERVER_NAME}" +# TREX_SERVER_SSH="${TREX_SERVER_USERNAME}"@"${TREX_SERVER_IP}" +TREX_SERVER_UPLOAD_DIR= +TREX_SERVER_DIR="${TREX_SERVER_UPLOAD_DIR}"/"${TREX_VERSION}" + +# Trex client configuration. +TREX_CLIENT_NAME= # Warning: Optional - If you set the name, it must be configured on your ssh config. +TREX_CLIENT_IP= +TREX_CLIENT_USERNAME= +TREX_CLIENT_SSH="${TREX_CLIENT_NAME}" +# TREX_CLIENT_SSH="${TREX_CLIENT_USERNAME}"@"${TREX_CLIENT_IP}" +TREX_CLIENT_UPLOAD_DIR= +TREX_CLIENT_DIR="${TREX_CLIENT_UPLOAD_DIR}"/trex_client +TREX_CLIENT_LIB_DIR="${TREX_CLIENT_DIR}"/interactive + +# DUT - Device Under Test Configuration. +DUT_NAME= # Warning: Optional - If you set the name, it must be configured on your ssh config. +DUT_IP= +DUT_USERNAME= +DUT_UPLOAD_DIR= + +# Test local configuration. +LOCAL_CONFIG_DIR="${WORKSPACE}"/tests/trex/config +LOCAL_TRAFFIC_DIR="${WORKSPACE}"/tests/trex/traffic +LOCAL_TEST_CASES_DIR="${WORKSPACE}"/tests/trex/test_cases +LOCAL_SERVER_UPLOAD_DIR="${WORKSPACE}"/tests/trex +LOCAL_PACKAGE="${WORKSPACE}"/package + +# Test remote configuration +REMOTE_CONFIG_DIR="${TREX_SERVER_UPLOAD_DIR}"/config +REMOTE_TRAFFIC_DIR="${TREX_SERVER_UPLOAD_DIR}"/traffic +REMOTE_TEST_CASES_DIR="${TREX_SERVER_UPLOAD_DIR}"/test_cases + +# SSH port forwarding configuration +LOCAL_HTTP_SSH_PORT_FORWARDING= +LOCAL_TREX_SYNC_SSH_PORT_FORWARDING= +LOCAL_TREX_ASYNC_SSH_PORT_FORWARDING= +API_HTTP_PORT= + +# Programs name +API_PROGRAM_NAME=api + +PYTHONPATH=/workspaces/tests/trex/trex_client/interactive/ diff --git a/.gitattributes b/.gitattributes index a9d952d..f5675ed 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,4 @@ bin/bpftool filter=lfs diff=lfs merge=lfs -text +*.svg filter=lfs diff=lfs merge=lfs -text +*.png filter=lfs diff=lfs merge=lfs -text + diff --git a/.gitignore b/.gitignore index dde110d..799513f 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ tests/trex/v* tests/trex/trex_client tests/reports/*.json *.png +env.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fef86c..7f56400 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,8 +71,8 @@ write_basic_package_version_file( "${version_config}" COMPATIBILITY SameMajorVersion ) -# set(INCLUDE_INSTALL_DIR include/) -# set(LIB_INSTALL_DIR lib/ ) +set(INCLUDE_INSTALL_DIR include/) +set(LIB_INSTALL_DIR lib/ ) # Configure 'Config.cmake' # Use variables: # * TARGETS_EXPORT_NAME diff --git a/Makefile b/Makefile index eded8cd..bb79c6f 100644 --- a/Makefile +++ b/Makefile @@ -85,8 +85,8 @@ run-redirect-map-sample: all ## Build all and run BPF XDP redirect sample run-control-plane-tests: force-xdp-deload ## Run ControlPlaneTests ./tests/scripts/run_test ControlPlaneTests -run-session-manager-tests: force-xdp-deload ## Run SessionManagerTests - sudo bash ./tests/scripts/run_test UPFProgramTests +run-session-manager-tests: force-xdp-deload ## Run SessionManagerTests + sudo -E bash ./tests/scripts/run_test UPFProgramTests rerun: force-xdp-deload run ## Build all and run BPF XDP UPF @@ -94,7 +94,7 @@ dut-run: ## Run ControlPlaneTests on DUT sudo ./bin/ControlPlaneTests force-xdp-deload: ## Kill all and force deload XDP programs - sudo bash tests/scripts/force_xdp_deload + sudo -E bash tests/scripts/force_xdp_deload trex: ## Install, deploy configuration and run t-rex on remote server tests/scripts/install_trex_remote @@ -114,6 +114,9 @@ tmux: ## Create a test session using tmux docker-build: ## Build development image docker/build_docker +docker-build-ubuntu-18.04: ## Build development image + docker/build_docker ubuntu:18.04 + docker-run: ## Run development container docker/run_docker diff --git a/README.md b/README.md index d0f6f42..4307fcf 100644 --- a/README.md +++ b/README.md @@ -1,54 +1,132 @@ -User plane function using BPF and XDP for mobile core network (4G/5G). +# 5G UPF using eBPF/XDP -## Usage -### Build Docker Image +An open source C++ library powered by eBPF/XDP for user plane in mobile core network (5G/LTE). -Copy the keys to jump server and run `make docker-build` -### Testing +The key pillars of this project are: -![setup-for-GPDU-debug-issue-2-upf-bpf](https://user-images.githubusercontent.com/42647168/86470179-4486cc80-bd11-11ea-8f55-fee848b12e11.png) +- In-kernel fast packet processing +- Flexible and programmable dataplane +- Portable to different systems -- Open terminal in `Linux #0` -- Configure veth pairs with `make config-veth-pair` in `Linux #0` -- Install the spdlog library with `make setup` -- Build, load and run program with `make run` in `Linux #0` -- Login remote Scapy `ssh -X navarro@192.168.15.7 "cd /work/mestrado/scapy/; sudo -S ./run_scapy"` -- Generate GTP G-PDU using [Scapy](https://github.com/secdev/scapy) with `gtpu-traffic-generator.py` in `Linux #1` -- Open other terminal tab in `Linux #0` -- Check logs: `sudo cat /sys/kernel/debug/tracing/trace | grep "GPDU"` in `Linux #0` +These points are achieved mainly by eBPF/XDP and CO-RE (Compile Once - Run Everywhere) technologies. -### Make Commands +This project is based on the following 3GPP Technical Specification: +- LTE; 5G; Interface between the Control Plane and the User Plane nodes (3GPP TS 29.244 version 16.5.0 Release 16) +- 5G; System architecture for the 5G System (5GS) (3GPP TS 23.501 version 16.5.0 Release 16) -``` -- all Build all -- clean Clean all build files -- all-verbose Build all in verbose mode -- config-veth-pair Config veth pair. It must be run before `run-*` targets -- run-hello-world-samples Build all and run BPF XDP hello world sample -- run-redirect-map-sample Build all and run BPF XDP redirect sample -- run Build all and run BPF XDP UPF -- run-scapy Run scapy for packet manipulation -- force-xdp-deload Force deload XDP programs -``` +The main goal is to enable in-kernel fast packet processing in third-party UPF/5G or SPGWu/LTE components in order to: +1. Boost them for those which does not have any fast packet processing enabled, or +2. Co-locate them with other fast packet processing solutions (e.g. DPDK) + +Possible scenarios that take advantage of this type of technology: MEC, 5G NPN (Non Public Networks), on-premise, 5G enterprise, and much more. + +## Design + +The library is divided in layers: +- **Management Layer**: An user space layer responsible to receive requests from the third-party UPF/SPGWu components to manage PFCP sessions and eBPF programs lifecycle +- **Datapath Layer**: A kernel space layer representing by eBPF/XDP programs responsible to handle the user traffic (datapath) for fast packet processing + +The high level design is shown in figure below. + +drawing + +The library has a component, called `PFCP Sesssion Manager`, which is a C++ API responsible to manage PFCP (Packet Forwarding Control Protocol) sessions. For each session, there is an eBPF program that represents the PFCP context in the fast path. These programs are managed by `eBPF Program Manager` component. The fast path is composed by three main function: parser, traffic classifier and traffic forwarder. The image below shows this in more detail. + +drawing + +A low-level design (Datapath Layer) is shown below. + +drawing + +## Features + +As described in 3GPP TS 29.244, the Information Elements (IEs) are part of the PFCP context. The PFCP context is created by sending PFCP Session Establishment Request message. The main features supported in this project are: -## Dependencies +Management Layer - CRUD +- PFCP Session +- PDR (Packet Detection Rule) +- FAR (Forwarding Action Rule) -Upee +Fast Datapath Layer +- UDP and GTP parse +- Traffic classification based on PDR +- Traffic fowarding based on FAR + +The logical data model between PFCP Session and IEs is shown in the image below. For more detail, see 3GPP TS 29.244 version 16.5.0 Release 16. + +drawing + +### WIP + +Management Layer - CRUD +- QER (QoS Enforcement Rule) + +Fast Datapath Layer +- Policy Enforcement based on QER + +## Main Dependencies + +Core - libbpf -- libelf -- libz +- bpftool +- spdlog - clang >= version 3.4.0 - llvm >= version 3.7.1 - kernel-headers => version 5.3 -- bpftool +- cmake >= 3.16 Test - scapy v2.4.3 -- spdlog - gtest - sysstat - trex v2.86 +## First Steps + +The project use a docker container to build the UPF library. The command below will provision the docker image with all the project dependencies. + +``` +make docker-build +``` + +> Warning: THE SSH PRIVATE KEY IS COPIED TO THE DOCKER IMAGE. DO NOT PUSH THIS IMAGE TO THE INTERNET!! + +After that, run the container with: + +``` +make docker-run +``` + +> You can also use the vscode development container feature to build the image and login into the container. +> Check [here](https://code.visualstudio.com/docs/remote/create-dev-container#_create-a-devcontainerjson-file) to understand how to open the [devcontainer.json](.devcontainer/devcontainer.json) file. + +Inside the container, compile the dependencies with + +``` +make setup +``` + +## Build and Installation + +The library is built and installed with + +``` +make install +``` + +The `package` folder is create with the headers, library and some binaries for testing. + +``` +package +├── bin # Contains binaries for testing +├── lib # Contains libupf_xdp.a library +└── tests # COntains scripts for testing +``` + +## How to test the software + +The instructions here is still missing. If you need to know how to test, contact me. For your information, there are UTs for Session Management layers. Also, you can check the video [Performance Evaluation with UPF eBPF/XDP Library for 5G Core Network](https://www.youtube.com/watch?v=6KYFDMJJH2o) to see the performance evaluation (deprecated). + ## Tree The directory structure was created based on this [notes](https://blogs.oracle.com/linux/notes-on-bpf-4). @@ -66,7 +144,7 @@ The directory structure was created based on this [notes](https://blogs.oracle.c └── src: Source files directory ``` -## TRex +## TRex If you faced the problem below, create a symbolic from `libc.a -> liblibc.a` `No such file or directory: b'liblibc.a'` @@ -74,5 +152,11 @@ If you faced the problem below, create a symbolic from `libc.a -> liblibc.a` ## Contact Thiago Navarro -Email: navarro.ime@gmail.com -Twitter: navarr0thiag0 +- Mail: +- GitHub: [@navarrothiago](https://github.com/navarrothiago/) +- Twitter: [@navarr0thiag0](https://twitter.com/navarr0thiag0) + +## References + +- [Author M.Sc. Qualification](https://docs.google.com/presentation/d/1Q24M4Ce8TPPhiM305_Oxs0iQFmmukKwSKdlNcJ0T2uo/edit#slide=id.gc2b6cd2cb2_0_92) +- [Performance Evaluation with UPF eBPF/XDP Library for 5G Core Network](https://www.youtube.com/watch?v=6KYFDMJJH2o) diff --git a/docker/Dockerfile b/docker/Dockerfile index c167e40..a8b720a 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -1,4 +1,5 @@ -FROM ubuntu:20.04 +ARG BASE_DEV_IMAGE=ubuntu:20.04 +FROM $BASE_DEV_IMAGE ARG UNAME=oai-spgwu WORKDIR /tmp/$UNAME @@ -72,12 +73,11 @@ RUN apt-get update && \ apt-get install -y \ tmux -# It is comment due to ubuntu 20.04 base image. -# If you use another one, uncomment the lines below. -# RUN apt-get update && \ -# apt-get -y install libssl-dev && \ -# wget -c https://github.com/Kitware/CMake/releases/download/v3.19.2/cmake-3.19.2.tar.gz -O - | tar -xz && \ -# cd cmake-3.19.2 && ./bootstrap && make && make install +# Ubuntu 20.04 already support cmake 3.19. +RUN if [ $BASE_DEV_IMAGE != "ubuntu:20.04" ]; then apt-get update && \ + apt-get -y install libssl-dev && \ + wget -c https://github.com/Kitware/CMake/releases/download/v3.19.2/cmake-3.19.2.tar.gz -O - | tar -xz && \ + cd cmake-3.19.2 && ./bootstrap && make -j4 && make install; fi # Add your local bashrc ADD .bashrc /home/$USERNAME/ @@ -127,7 +127,8 @@ RUN apt-get install -y locales && \ update-locale LANG=$LAN # Install Docker CE CLI -RUN apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common lsb-release \ +RUN apt-get update \ + && apt-get install -y apt-transport-https ca-certificates curl gnupg-agent software-properties-common lsb-release \ && curl -fsSL https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]')/gpg | (OUT=$(apt-key add - 2>&1) || echo $OUT) \ && add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/$(lsb_release -is | tr '[:upper:]' '[:lower:]') $(lsb_release -cs) stable" \ && apt-get update \ @@ -141,17 +142,16 @@ RUN apt-get update && \ RUN pip3 install ipykernel RUN pip3 install matplotlib -RUN pip3 install paramiko RUN pip3 install autopep8 RUN apt-get update && \ apt-get install -y \ rsync -ARG ENV_FILENAME="env.sh" -ADD ${ENV_FILENAME} ${ENV_FILENAME} +# TODO: pass as ARG +RUN echo "ENV_FILE=/workspaces/env.sh" >> /etc/environment # Omit if you want to keep the default as root. # USER $USERNAME -CMD ${ENV_FILENAME} && /bin/bash +CMD /bin/bash diff --git a/docker/build_docker b/docker/build_docker index 26d8015..f080246 100755 --- a/docker/build_docker +++ b/docker/build_docker @@ -9,6 +9,9 @@ main() { local -r context="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" source "${context}"/../env.sh local env_file_name=env.sh + local base_dev_image="${1-ubuntu:20.04}" + + echo "Base image "${base_dev_image}"" # Copy configuration files and ssh keys to the docker context folder. cp "${GIT_CONFIG}" "${context}" @@ -20,13 +23,14 @@ main() { cp "${context}"/../env.sh "${context}" # Build dockerfile. - docker build --tag="${IMAGE}":"${VERSION}" --rm -f "${context}"/"${DOCKERFILE}" "${context}" \ + docker build --tag="${IMAGE_TAG}":"${IMAGE_VERSION}" --rm -f "${context}"/"${DOCKERFILE}" "${context}" \ --build-arg ENV_FILENAME="${env_file_name}" \ --build-arg DUT_SERVER_IP="${DUT_IP}" \ --build-arg TREX_SERVER_IP="${TREX_SERVER_IP}" \ --build-arg JUMP_SERVER_USERNAME="${JUMP_SERVER_USERNAME}" \ --build-arg JUMP_SERVER_IP="${JUMP_SERVER_IP}" \ - --build-arg JUMP_SERVER_PORT="${JUMP_SERVER_PORT}" + --build-arg JUMP_SERVER_PORT="${JUMP_SERVER_PORT}" \ + --build-arg BASE_DEV_IMAGE="${base_dev_image}" # Remove configuration files and ssh keys from the docker context folder. rm "${context}"/.gitconfig @@ -35,6 +39,10 @@ main() { rm "${context}"/"${SSH_CONFIG_FILE}" rm "${context}"/.bashrc rm "${context}"/env.sh + + echo + echo "Image "${IMAGE_TAG}" was build with base image "${base_dev_image}"" + echo } main "$@" diff --git a/docker/run_docker b/docker/run_docker index 786d75f..b39777b 100755 --- a/docker/run_docker +++ b/docker/run_docker @@ -12,7 +12,7 @@ main() { --env-file "${dirname}"/../env.sh \ --volume "${dirname}"/../:"${WORKSPACE}" \ --privileged \ - --workdir "${WORKSPACE}" "${IMAGE}":"${VERSION}" \ + --workdir "${WORKSPACE}" "${IMAGE_TAG}":"${IMAGE_VERSION}" \ /bin/bash exit 0 diff --git a/img/up-ebpf-xdp-high-level.png b/img/up-ebpf-xdp-high-level.png new file mode 100644 index 0000000..dd95a5f --- /dev/null +++ b/img/up-ebpf-xdp-high-level.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:231199e0347cc6d2885d71109e60f4feef34a112326320685d76c5eb30226c28 +size 59437 diff --git a/img/up-ebpf-xdp-high-level.svg b/img/up-ebpf-xdp-high-level.svg new file mode 100644 index 0000000..fe93424 --- /dev/null +++ b/img/up-ebpf-xdp-high-level.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bc7fb9ddccb468b38c6e182a0a75b9028ded3a49f40aea52f1fe4b32010f4916 +size 17492 diff --git a/img/up-ebpf-xdp-high-level2.png b/img/up-ebpf-xdp-high-level2.png new file mode 100644 index 0000000..d17d9f6 --- /dev/null +++ b/img/up-ebpf-xdp-high-level2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8c0d7e39a5a9fedd7751a3e624c931f3767ba488266265a57b39282d18d0b2c2 +size 102536 diff --git a/img/up-ebpf-xdp-high-level2.svg b/img/up-ebpf-xdp-high-level2.svg new file mode 100644 index 0000000..b056859 --- /dev/null +++ b/img/up-ebpf-xdp-high-level2.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:50f988bd897395b1724a66808f402fad78647fc6ee4a933c47667a42562b00b5 +size 25197 diff --git a/img/up-ebpf-xdp-ies.png b/img/up-ebpf-xdp-ies.png new file mode 100644 index 0000000..b72b7ef --- /dev/null +++ b/img/up-ebpf-xdp-ies.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4f945423b3606776c7b9bde0659a27701a9c8acbc457ecab6f600f6928f63ee2 +size 137919 diff --git a/img/up-ebpf-xdp-ies.svg b/img/up-ebpf-xdp-ies.svg new file mode 100644 index 0000000..99d94fe --- /dev/null +++ b/img/up-ebpf-xdp-ies.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6f556aaf601751cc7db5f8990a73ef0e6f46ef2669dd6f8ca702c2241e229cc1 +size 45410 diff --git a/img/up-ebpf-xdp-low-level.png b/img/up-ebpf-xdp-low-level.png new file mode 100644 index 0000000..0e658cd --- /dev/null +++ b/img/up-ebpf-xdp-low-level.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:6a987b8718b6a4b654539adbc93af25e4deda029abd08b120e3d8157bb218805 +size 156683 diff --git a/img/up-ebpf-xdp-low-level.svg b/img/up-ebpf-xdp-low-level.svg new file mode 100644 index 0000000..52bd58e --- /dev/null +++ b/img/up-ebpf-xdp-low-level.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8a72c9ecc403ffef1f9d43eccb1964bac28bc8875940060e0ce57e0aff203828 +size 53414 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f3320a2..963b2b6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -64,8 +64,8 @@ install( # Headers: # * ./*.h -> /include/*.h -# install( -# DIRECTORY "./" -# DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" -# FILES_MATCHING PATTERN "*.h" -# ) +install( + DIRECTORY "./" + DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}" + FILES_MATCHING PATTERN "*.h" +) diff --git a/src/SessionProgramManager.h b/src/SessionProgramManager.h index 42bccc4..6b48472 100644 --- a/src/SessionProgramManager.h +++ b/src/SessionProgramManager.h @@ -10,7 +10,7 @@ class OnStateChangeSessionProgramObserver; class SessionProgram; /** - * @brief This class is used to manager the SessionProgramManager. + * @brief This class is used to manager the PFCP Sesssion (eBPF bytecode) in kernel space. * */ class SessionProgramManager diff --git a/src/programs/ProgramLifeCycle.hpp b/src/programs/ProgramLifeCycle.hpp index 4d99ed4..6e92edc 100644 --- a/src/programs/ProgramLifeCycle.hpp +++ b/src/programs/ProgramLifeCycle.hpp @@ -108,8 +108,10 @@ ProgramLifeCycle::ProgramLifeCycle(std::functionlink("xdp_entry_point", mUDPInterface.c_str()); + LOG_DBG("Link GTP interface to interface {}", mGTPInterface.c_str()) mpLifeCycle->link("xdp_entry_point", mGTPInterface.c_str()); } diff --git a/tests/README.md b/tests/README.md new file mode 100644 index 0000000..fe845de --- /dev/null +++ b/tests/README.md @@ -0,0 +1,12 @@ +# Testing + +![setup-for-GPDU-debug-issue-2-upf-bpf](https://user-images.githubusercontent.com/42647168/86470179-4486cc80-bd11-11ea-8f55-fee848b12e11.png) + +- Open terminal in `Linux #0` +- Configure veth pairs with `make config-veth-pair` in `Linux #0` +- Install the spdlog library with `make setup` +- Build, load and run program with `make run` in `Linux #0` +- Login remote Scapy `ssh -X navarro@192.168.15.7 "cd /work/mestrado/scapy/; sudo -S ./run_scapy"` +- Generate GTP G-PDU using [Scapy](https://github.com/secdev/scapy) with `gtpu-traffic-generator.py` in `Linux #1` +- Open other terminal tab in `Linux #0` +- Check logs: `sudo cat /sys/kernel/debug/tracing/trace | grep "GPDU"` in `Linux #0` \ No newline at end of file diff --git a/tests/scripts/config_veth_pair b/tests/scripts/config_veth_pair index 46fed59..22eaf5e 100755 --- a/tests/scripts/config_veth_pair +++ b/tests/scripts/config_veth_pair @@ -12,7 +12,7 @@ create_namespace() { local -r filename="${dirname}/$(basename "${BASH_SOURCE[0]}")" # TODO navarrothiago - check if it is recommend to call env.sh here. - source "${dirname}"/../../env.sh + source "${ENV_FILE}" local nr_cpu=$(nproc) local namespace=$1 diff --git a/tests/scripts/deploy_package b/tests/scripts/deploy_package index bbbf433..a81b284 100755 --- a/tests/scripts/deploy_package +++ b/tests/scripts/deploy_package @@ -11,7 +11,7 @@ main() { local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" local -r filename="${dirname}/$(basename "${BASH_SOURCE[0]}")" - source "${dirname}"/../../env.sh + source "${ENV_FILE}" echo echo "Copy package with binary and libraries." diff --git a/tests/scripts/deploy_trex_config b/tests/scripts/deploy_trex_config index e009e67..152de89 100755 --- a/tests/scripts/deploy_trex_config +++ b/tests/scripts/deploy_trex_config @@ -10,7 +10,7 @@ main() { local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - source "${dirname}"/../../env.sh + source "${ENV_FILE}" scp -r "${LOCAL_CONFIG_DIR}" "${TREX_SERVER_SSH}":"${TREX_SERVER_UPLOAD_DIR}" scp -r "${LOCAL_TRAFFIC_DIR}" "${TREX_SERVER_SSH}":"${TREX_SERVER_UPLOAD_DIR}" diff --git a/tests/scripts/force_xdp_deload b/tests/scripts/force_xdp_deload index 81ede94..0c94392 100755 --- a/tests/scripts/force_xdp_deload +++ b/tests/scripts/force_xdp_deload @@ -7,7 +7,7 @@ main() { set -o nounset local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - source "${dirname}"/../../env.sh + source "${ENV_FILE}" local gtp_interface=${1:-veth0} local udp_interface=${2:-veth1} diff --git a/tests/scripts/install_trex_remote b/tests/scripts/install_trex_remote index aa5d5c6..c700f0a 100755 --- a/tests/scripts/install_trex_remote +++ b/tests/scripts/install_trex_remote @@ -11,7 +11,7 @@ main() { local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - source "${dirname}"/../../env.sh + source "${ENV_FILE}" # Execute local script (install_trex) on the server. diff --git a/tests/scripts/run_sample b/tests/scripts/run_sample index 4af973e..8988096 100755 --- a/tests/scripts/run_sample +++ b/tests/scripts/run_sample @@ -6,7 +6,7 @@ main() { set -o nounset local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - source "${dirname}"/../../env.sh + source "${ENV_FILE}" local sample_binary_name=$1 diff --git a/tests/scripts/run_test b/tests/scripts/run_test index 1dc4386..71fa09e 100755 --- a/tests/scripts/run_test +++ b/tests/scripts/run_test @@ -5,7 +5,7 @@ main() { set -o pipefail local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - source "${dirname}"/../../env.sh + source "${ENV_FILE}" local test_binary=$1 local gtp_interface=${2:-veth0} diff --git a/tests/scripts/run_trex_server b/tests/scripts/run_trex_server index 2ea7d15..d92fc27 100755 --- a/tests/scripts/run_trex_server +++ b/tests/scripts/run_trex_server @@ -10,7 +10,7 @@ main() { local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - source "${dirname}"/../../env.sh + source "${ENV_FILE}" echo echo "Run t-rex server on "${TREX_SERVER_IP}"." diff --git a/tests/scripts/run_trex_test_case b/tests/scripts/run_trex_test_case index 40a0b3c..0454a78 100755 --- a/tests/scripts/run_trex_test_case +++ b/tests/scripts/run_trex_test_case @@ -9,7 +9,7 @@ main() { set -o nounset local -r dirname="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" - source "${dirname}"/../../env.sh + source "${ENV_FILE}" local test_case_file="${1}".py local run_trex_client_command="export PYTHONPATH='"${TREX_CLIENT_LIB_DIR}"'; python3 "${REMOTE_TEST_CASES_DIR}"/""${test_case_file}" diff --git a/tests/scripts/start_session b/tests/scripts/start_session index 2ad4567..b1d80c4 100755 --- a/tests/scripts/start_session +++ b/tests/scripts/start_session @@ -78,7 +78,7 @@ main() { local -r filename="${dirname}/$(basename "${BASH_SOURCE[0]}")" local -r session_name="upee" - source "${dirname}"/../../env.sh + source "${ENV_FILE}" # if [[ $# != 4 ]]; then # echo >&2 "TODO!! "