From 81defdf9c56fa11e58907e27e2d4a860e213374e Mon Sep 17 00:00:00 2001 From: Thiago Navarro Date: Sun, 16 May 2021 19:30:08 -0300 Subject: [PATCH] [#39] Cleans up environment --- .gitattributes | 2 ++ CMakeLists.txt | 4 ++-- Makefile | 9 ++++++--- README.md | 13 ++++++++++++- docker/Dockerfile | 21 ++++++++++----------- docker/build_docker | 12 ++++++++++-- docker/run_docker | 2 +- env.sh | 6 +++--- img/UPeBPF-design.svg | 3 +++ src/CMakeLists.txt | 10 +++++----- src/programs/ProgramLifeCycle.hpp | 2 ++ src/programs/UPFProgram.cpp | 2 ++ tests/scripts/config_veth_pair | 2 +- tests/scripts/deploy_package | 2 +- tests/scripts/deploy_trex_config | 2 +- tests/scripts/force_xdp_deload | 2 +- tests/scripts/install_trex_remote | 2 +- tests/scripts/run_sample | 2 +- tests/scripts/run_test | 2 +- tests/scripts/run_trex_server | 2 +- tests/scripts/run_trex_test_case | 2 +- tests/scripts/start_session | 2 +- 22 files changed, 68 insertions(+), 38 deletions(-) create mode 100644 img/UPeBPF-design.svg diff --git a/.gitattributes b/.gitattributes index a9d952d..c2cbd5d 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,3 @@ bin/bpftool filter=lfs diff=lfs merge=lfs -text +*.svg filter=lfs diff=lfs merge=lfs -text + 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..0be21f6 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,20 @@ -User plane function using BPF and XDP for mobile core network (4G/5G). +# Telco User Plane using eBPF/XDP + +An open source C++ library powered by eBPF/XDP for user plane in mobile core network (LTE/5G). + +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) + +

+ drawing +

## Usage ### Build Docker Image Copy the keys to jump server and run `make docker-build` + ### Testing ![setup-for-GPDU-debug-issue-2-upf-bpf](https://user-images.githubusercontent.com/42647168/86470179-4486cc80-bd11-11ea-8f55-fee848b12e11.png) diff --git a/docker/Dockerfile b/docker/Dockerfile index c167e40..92110c9 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/ @@ -141,17 +141,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/env.sh b/env.sh index 0c0df75..67ef704 100644 --- a/env.sh +++ b/env.sh @@ -9,8 +9,8 @@ NUM_THREADS=4 # Docker environment variable. USERNAME=oai-spgwu -IMAGE=upee -VERSION=v1.0 +IMAGE_TAG=upee +IMAGE_VERSION=v1.0 DOCKERFILE=Dockerfile SSH_FOLDER=~/.ssh SSH_PUBLIC_KEY_FILE=id_rsa.pub @@ -91,4 +91,4 @@ API_HTTP_PORT=80 # Programs name API_PROGRAM_NAME=api -PYTHONPATH=/workspaces/tests/trex/trex_client/interactive/ \ No newline at end of file +PYTHONPATH=/workspaces/tests/trex/trex_client/interactive/ diff --git a/img/UPeBPF-design.svg b/img/UPeBPF-design.svg new file mode 100644 index 0000000..3e2204e --- /dev/null +++ b/img/UPeBPF-design.svg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5d88b3e9f9ae6815dcd21969ce13db5b2ab072157f9406e17134c7d80b94f71b +size 77337 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/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/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!! "