Skip to content

Commit

Permalink
[#13] Fixes compilation with new version upf-bpf
Browse files Browse the repository at this point in the history
  • Loading branch information
navarrothiago committed May 29, 2021
1 parent fc13355 commit edc0fae
Show file tree
Hide file tree
Showing 10 changed files with 44 additions and 26 deletions.
16 changes: 14 additions & 2 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,18 @@
"ms-vscode.cpptools",
"twxs.cmake",
"cschlosser.doxdocgen",
"amiralizadeh9480.cpp-helper"
"amiralizadeh9480.cpp-helper",
"eamodio.gitlens",
"albert.tabout",
"redhat.vscode-yaml",
"ms-python.python",
"ms-python.vscode-pylance",
"l13rary.l13-sh-snippets",
"foxundermoon.shell-format",
"TabNine.tabnine-vscode",
"streetsidesoftware.code-spell-checker",
"streetsidesoftware.code-spell-checker-portuguese",
"shan.code-settings-sync"
],

// Use 'forwardPorts' to make a list of ports inside the container available locally.
Expand All @@ -38,7 +49,8 @@
"--privileged",
"--name=openair-cn-cups",
"-v",
"${localEnv:HOME}/.bashrc:/root/.bashrc"
"${localEnv:HOME}/.bashrc:/root/.bashrc",
"--env-file", "env.sh"
],

// Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-in-docker.
Expand Down
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TEST_DIR=$(PROJECT_DIR)/build/Debug
NUM_THREADS=8

# Interface to be configured with veth pair.
DEVICE_IN=enp0s20f0u4u2u4
DEVICE_IN=enp0s20f0u9
DEVICE_OUT=veth0

.PHONY: help
Expand Down Expand Up @@ -58,10 +58,10 @@ docker-login: ## Login in openair-cn-cups container
docker exec -it openair-cn-cups /bin/bash -c 'cd /workspaces/openair-cn-cups && /bin/bash'

docker-create-network: ## Create macvlan with subnet 192.168.15.0 using enp0s20f0u1 interface
docker network create -d macvlan --subnet=192.168.15.0/24 --gateway=192.168.15.1 -o parent=enp0s20f0u4u2u4 macvlan-enp0s20f0u4u2u4
docker network create -d macvlan --subnet=192.168.15.0/24 --gateway=192.168.15.1 -o parent=enp0s20f0u8 macvlan-enp0s20f0u8

docker-setup-network: ## Connect maclan on container openair-cn-cup and create spgwu interfaces
docker network connect macvlan-enp0s20f0u4u2u4 openair-cn-cups
docker-setup-network: ## Connect maclan on coutainer openair-cn-cup and create spgwu interfaces
docker network connect macvlan-enp0s20f0u8 openair-cn-cups

docker-config-spgwu-iface: ## Create and configure spgwu interefaces
$(PROJECT_DIR)/configs/config-spgwu-interface.sh
Expand All @@ -81,15 +81,18 @@ kill-spgwu: ## Kill spgwu

# TODO navarrothiago - include from upf-bpf, avoiding hardcoded.
config-veth-pair: ## Config veth pair. It must be run before <run-*> targets
sudo ./build/ext/upf-bpf/tests/scripts/config_veth_pair.sh $(DEVICE_IN)
sudo ./build/ext/upf-bpf/tests/scripts/config_veth_pair

setup: docker-config-spgwu-iface config-veth-pair ## Install upf-bpf dependencies
cd build/ext/upf-bpf/ && \
make clean-all && \
make setup && \
make install && \
cd ../../../

clean-upf-bpf:
cd build/ext/upf-bpf/ && \
make clean-all

force-xdp-deload: ## Kill all and force deload XDP programs
sudo ip link set dev $(DEVICE_IN) xdpgeneric off
sudo ip link set dev $(DEVICE_OUT) xdpgeneric off
Expand Down
9 changes: 8 additions & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN apt-get update && \
# TODO: Instead of clone, we should download only de dependencies.
# TODO: Remove repository in the end.
# TODO: Check if this really needed. vscode mount this on container.
RUN git clone --depth=1 --branch=$GIT_TAG https://github.com/OPENAIRINTERFACE/openair-cn-cups.git
RUN git clone --depth=1 --branch=$GIT_TAG https://github.com/navarrothiago/openair-cn-cups.git

RUN git clone --depth=1 --branch=master https://github.com/gabime/spdlog.git openair-cn-cups/build/ext/spdlog

Expand Down Expand Up @@ -124,6 +124,13 @@ RUN apt-get update && \
RUN apt-get update && \
apt-get -y install ethtool

# Ubuntu 20.04 already support cmake 3.16.3.
# RUN if [ $BASE_DEV_IMAGE != "ubuntu:20.04" ]; then apt-get update && \
RUN apt-get update && \
apt-get -y install libssl-dev && \
wget -c https://github.com/Kitware/CMake/releases/download/v3.16.3/cmake-3.16.3.tar.gz -O - | tar -xz && \
cd cmake-3.16.3 && ./bootstrap && make -j4 && make install; fi

USER root
#USER $UNAME

Expand Down
6 changes: 3 additions & 3 deletions etc/spgw_u-dev.conf
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ SPGW-U =
S1U_S12_S4_UP :
{
# S-GW binded interface for S1-U communication (GTPV1-U) can be ethernet interface, virtual ethernet interface, we don't advise wireless interfaces
INTERFACE_NAME = "enp0s20f0u4u2u4"; # STRING, interface name, YOUR NETWORK CONFIG HERE
INTERFACE_NAME = "enp0s20f0u8"; # STRING, interface name, YOUR NETWORK CONFIG HERE
IPV4_ADDRESS = "read"; # STRING, CIDR or "read to let app read interface configured IP address
#PORT = 2152; # Default is 2152
#SCHED_PARAMS :
Expand All @@ -69,7 +69,7 @@ SPGW-U =
SX :
{
# S/P-GW binded interface for SX communication
INTERFACE_NAME = "enp0s20f0u4u2u4:sxu"; # STRING, interface name
INTERFACE_NAME = "enp0s20f0u8:sxu"; # STRING, interface name
IPV4_ADDRESS = "read"; # STRING, CIDR or "read" to let app read interface configured IP address
#PORT = 8805; # Default is 8805
#SCHED_PARAMS :
Expand All @@ -82,7 +82,7 @@ SPGW-U =
SGI :
{
# No config to set, the software will set the SGi interface to the interface used for the default route.
INTERFACE_NAME = "wlp0s20f3"; # STRING, interface name or "default_gateway"
INTERFACE_NAME = "enp1s0f1"; # STRING, interface name or "default_gateway"
IPV4_ADDRESS = "read"; # STRING, CIDR or "read" to let app read interface configured IP address
#SCHED_PARAMS :
#{
Expand Down
1 change: 1 addition & 0 deletions src/oai_spgwu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ else(STATIC_LINKING)
SET(BUILD_SHARED_LIBS ON)
endif(STATIC_LINKING)

cmake_policy(SET CMP0070 OLD)
file(GENERATE
OUTPUT "includes-spgwu.txt"
CONTENT "$<TARGET_PROPERTY:spgwu,INCLUDE_DIRECTORIES>\n"
Expand Down
8 changes: 1 addition & 7 deletions src/spgwu/interfaces/PacketDetectionRulesImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,10 @@ PacketDetectionRulesImpl::~PacketDetectionRulesImpl()
LOG_FUNC();
}

uint64_t PacketDetectionRulesImpl::getLocalSeid()
{
LOG_FUNC();
return mPdr.local_seid;
}

teid_t_ PacketDetectionRulesImpl::getTeid()
{
LOG_FUNC();
return mPdr.teid;
return mPdr.pdi.fteid.teid;
}

pdr_id_t_ PacketDetectionRulesImpl::getPdrId()
Expand Down
1 change: 0 additions & 1 deletion src/spgwu/interfaces/PacketDetectionRulesImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class PacketDetectionRulesImpl : public PacketDetectionRules
PacketDetectionRulesImpl(pfcp::pfcp_pdr &myPdr);
PacketDetectionRulesImpl(pfcp_pdr_t_ &myPdr);
virtual ~PacketDetectionRulesImpl();
uint64_t getLocalSeid() override;
teid_t_ getTeid() override;
pdr_id_t_ getPdrId() override;
precedence_t_ getPrecedence() override;
Expand Down
5 changes: 3 additions & 2 deletions src/spgwu/simpleswitch/pfcp_session.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,14 @@ void pfcp_session::add(std::shared_ptr<pfcp::pfcp_far> far)
{
Logger::spgwu_sx().info( "pfcp_session::add(far) seid " SEID_FMT " ", seid);
fars.push_back(far);
UPFProgramManager::getInstance().getSessionManager()->addFAR(seid, std::make_shared<ForwardingActionRulesImpl>(*far));
UserPlaneComponent::getInstance().getSessionManager()->addFAR(seid, std::make_shared<ForwardingActionRulesImpl>(*far));
}
//------------------------------------------------------------------------------
void pfcp_session::add(std::shared_ptr<pfcp::pfcp_pdr> pdr)
{
Logger::spgwu_sx().info( "pfcp_session::add(pdr) seid " SEID_FMT " ", seid);
pdrs.push_back(pdr);
UPFProgramManager::getInstance().getSessionManager()->addPDR(seid, std::make_shared<PacketDetectionRulesImpl>(*pdr));
UserPlaneComponent::getInstance().getSessionManager()->addPDR(seid, std::make_shared<PacketDetectionRulesImpl>(*pdr));
}
//------------------------------------------------------------------------------
bool pfcp_session::remove(const pfcp::far_id_t& far_id, uint8_t& cause_value)
Expand Down Expand Up @@ -240,6 +240,7 @@ bool pfcp_session::create(const pfcp::create_pdr& cr_pdr, pfcp::cause_t& cause,
std::shared_ptr<pfcp_pdr> spdr = std::shared_ptr<pfcp_pdr>(pdr);
pdr->set(get_up_seid());
if ((pdi.ue_ip_address.first) && (pdi.ue_ip_address.second.v4)) {
// TODO (navarrothiago) put code here!
pfcp_switch_inst->add_pfcp_dl_pdr_by_ue_ip(be32toh(pdi.ue_ip_address.second.ipv4_address.s_addr), spdr);
} else {
cause.cause_value = CAUSE_VALUE_REQUEST_REJECTED;
Expand Down
2 changes: 1 addition & 1 deletion src/spgwu/simpleswitch/pfcp_session.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "msg_pfcp.hpp"
#include "pfcp_far.hpp"
#include "pfcp_pdr.hpp"
#include <UPFProgramManager.h>
#include <UserPlaneComponent.h>
#include <SessionManager.h>
#include "../interfaces/SessionBpfImpl.h"

Expand Down
7 changes: 4 additions & 3 deletions src/spgwu/simpleswitch/pfcp_switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include <linux/if_packet.h>
#include <stdexcept>
#include <net/ethernet.h>
#include <UPFProgramManager.h>
#include <UserPlaneComponent.h>
#include <SessionManager.h>
#include <interfaces/RulesUtilitiesImpl.h>

Expand Down Expand Up @@ -376,7 +376,7 @@ pfcp_switch::pfcp_switch() : seid_generator_(), teid_s1u_generator_(),
thread_sock_.detach();

mpRulesImpl = std::make_shared<RulesUtilitiesImpl>();
UPFProgramManager::getInstance().setup(mpRulesImpl);
UserPlaneComponent::getInstance().setup(mpRulesImpl, spgwu_cfg.sgi.if_name, spgwu_cfg.s1_up.if_name);
}
//------------------------------------------------------------------------------
bool pfcp_switch::get_pfcp_session_by_cp_fseid(const pfcp::fseid_t& fseid, std::shared_ptr<pfcp::pfcp_session>& session) const
Expand Down Expand Up @@ -520,6 +520,7 @@ std::string pfcp_switch::to_string() const
bool pfcp_switch::create_packet_in_access(std::shared_ptr<pfcp::pfcp_pdr>& pdr, const pfcp::fteid_t& in, uint8_t& cause)
{
cause = CAUSE_VALUE_REQUEST_ACCEPTED;
// TODO (navarrothiago) put code here!
add_pfcp_ul_pdr_by_up_teid(in.teid, pdr);
return true;
}
Expand All @@ -538,7 +539,7 @@ void pfcp_switch::handle_pfcp_session_establishment_request(std::shared_ptr<itti
pfcp_session* session = nullptr;
if (not exist) {
session = new pfcp_session(fseid, generate_seid());
UPFProgramManager::getInstance().getSessionManager()->createSession(std::make_shared<SessionBpfImpl>(*session));
UserPlaneComponent::getInstance().getSessionManager()->createSession(std::make_shared<SessionBpfImpl>(*session));

for (auto it : req->pfcp_ies.create_fars) {
create_far& cr_far = it;
Expand Down

0 comments on commit edc0fae

Please sign in to comment.