[UPF] Tested all platforms on open5gs (#1022)

This commit is contained in:
Sukchan Lee 2021-05-29 23:08:22 +09:00
parent 8dab1852cc
commit 5d460b0577
22 changed files with 53 additions and 137 deletions

1
debian/control vendored
View File

@ -20,6 +20,7 @@ Build-Depends: debhelper (>= 11),
libmicrohttpd-dev,
libcurl4-gnutls-dev,
libnghttp2-dev,
libtins-dev,
Standards-Version: 4.3.0
Rules-Requires-Root: no
Homepage: https://open5gs.org

View File

@ -1,30 +0,0 @@
ARG dist=centos
ARG tag=latest
FROM ${dist}:${tag}
MAINTAINER Sukchan Lee <acetcom@gmail.com>
RUN yum -y install epel-release
#RUN yum -y install https://centos7.iuscommunity.org/ius-release.rpm
RUN yum -y update
RUN yum -y install \
python3 \
ninja-build \
gcc \
flex \
bison \
git \
meson \
lksctp-tools-devel \
libidn-devel \
gnutls-devel \
libgcrypt-devel \
openssl-devel \
cyrus-sasl-devel \
libyaml-devel \
mongo-c-driver-devel \
libmicrohttpd-devel \
libcurl-devel \
libnghttp2-devel \
iproute

View File

@ -1 +0,0 @@
../8/dev

View File

@ -1 +0,0 @@
latest

View File

@ -1,37 +0,0 @@
ARG dist=centos
ARG tag=latest
FROM ${dist}:${tag}
MAINTAINER Sukchan Lee <acetcom@gmail.com>
RUN dnf -y install epel-release && \
dnf -y install 'dnf-command(config-manager)' && \
dnf config-manager --set-enabled PowerTools && \
dnf -y update
RUN dnf -y install \
https://www.elrepo.org/elrepo-release-8.el8.elrepo.noarch.rpm && \
dnf config-manager --set-enabled elrepo-testing && \
dnf -y update
RUN dnf -y install \
python3 \
ninja-build \
gcc \
flex \
bison \
git \
lksctp-tools-devel \
libidn-devel \
gnutls-devel \
libgcrypt-devel \
openssl-devel \
cyrus-sasl-devel \
libyaml-devel \
mongo-c-driver-devel \
libmicrohttpd-devel \
libcurl-devel \
libnghttp2-devel \
iproute
RUN dnf -y install meson

View File

@ -1,22 +0,0 @@
ARG dist=centos
ARG tag=latest
ARG username=acetcom
FROM ${username}/${dist}-${tag}-open5gs-base
MAINTAINER Sukchan Lee <acetcom@gmail.com>
RUN yum -y install \
cscope \
vim \
sudo \
iputils \
net-tools
COPY setup.sh /root
ARG username=acetcom
RUN useradd -m --uid=1000 ${username} && \
echo "${username} ALL=(root) NOPASSWD:ALL" > /etc/sudoers.d/${username} && \
chmod 0440 /etc/sudoers.d/${username}
WORKDIR /home/${username}

View File

@ -1,10 +0,0 @@
#!/bin/sh
if ! grep "ogstun" /proc/net/dev > /dev/null; then
ip tuntap add name ogstun mode tun
fi
ip addr del 10.45.0.1/16 dev ogstun 2> /dev/null
ip addr add 10.45.0.1/16 dev ogstun
ip addr del 2001:230:cafe::1/48 dev ogstun 2> /dev/null
ip addr add 2001:230:cafe::1/48 dev ogstun
ip link set ogstun up

View File

@ -9,9 +9,6 @@ TAG=bionic docker-compose -f docker-compose.yml -f docker-compose.test.yml run -
DIST=fedora TAG=32 docker-compose build
DIST=fedora TAG=32 docker-compose -f docker-compose.yml -f docker-compose.test.yml run --rm test
DIST=centos docker-compose build
DIST=centos docker-compose -f docker-compose.yml -f docker-compose.test.yml run --rm test
DIST=debian docker-compose build
DIST=debian docker-compose -f docker-compose.yml -f docker-compose.test.yml run --rm test

View File

@ -28,6 +28,7 @@ RUN apt-get update && \
libmicrohttpd-dev \
libcurl4-gnutls-dev \
libnghttp2-dev \
libtins-dev \
iproute2 \
ca-certificates \
netbase \

View File

@ -8,6 +8,7 @@ RUN dnf -y install \
python3 \
ninja-build \
gcc \
gcc-c++ \
flex \
bison \
git \

View File

@ -28,6 +28,7 @@ RUN apt-get update && \
libmicrohttpd-dev \
libcurl4-gnutls-dev \
libnghttp2-dev \
libtins-dev \
iproute2 \
ca-certificates \
netbase \

View File

@ -112,6 +112,7 @@ https://download.opensuse.org/repositories/home:/acetcom:/open5gs:/latest/xUbunt
https://download.opensuse.org/repositories/home:/acetcom:/open5gs:/latest/xUbuntu_19.10/
https://download.opensuse.org/repositories/home:/acetcom:/open5gs:/latest/xUbuntu_20.04/
https://download.opensuse.org/repositories/home:/acetcom:/open5gs:/latest/xUbuntu_20.10/
https://download.opensuse.org/repositories/home:/acetcom:/open5gs:/latest/xUbuntu_21.04/
```
#### openSUSE

View File

@ -44,7 +44,7 @@ $ sudo ip link set ogstun up
Install the dependencies for building the source code.
```bash
$ sudo apt install python3-pip python3-setuptools python3-wheel ninja-build build-essential flex bison git libsctp-dev libgnutls28-dev libgcrypt-dev libssl-dev libidn11-dev libmongoc-dev libbson-dev libyaml-dev libnghttp2-dev libmicrohttpd-dev libcurl4-gnutls-dev libnghttp2-dev meson
$ sudo apt install python3-pip python3-setuptools python3-wheel ninja-build build-essential flex bison git libsctp-dev libgnutls28-dev libgcrypt-dev libssl-dev libidn11-dev libmongoc-dev libbson-dev libyaml-dev libnghttp2-dev libmicrohttpd-dev libcurl4-gnutls-dev libnghttp2-dev libtins-dev meson
```
Git clone.

View File

@ -109,7 +109,7 @@ a base CentOS 8 installation.
```bash
$ sudo dnf install python3 meson ninja-build gcc flex bison git lksctp-tools-devel libidn-devel gnutls-devel libgcrypt-devel openssl-devel cyrus-sasl-devel libyaml-devel mongo-c-driver-devel libmicrohttpd-devel libcurl-devel libnghttp2-devel
$ sudo dnf install python3 meson ninja-build gcc gcc-c++ flex bison git lksctp-tools-devel libidn-devel gnutls-devel libgcrypt-devel openssl-devel cyrus-sasl-devel libyaml-devel mongo-c-driver-devel libmicrohttpd-devel libcurl-devel libnghttp2-devel
```
### Install the SCTP kernel module in kernel-modules-extra.

View File

@ -70,7 +70,7 @@ $ ip link show
Install the depedencies for building the source code.
```bash
$ sudo dnf install python3 ninja-build gcc flex bison git lksctp-tools-devel libidn-devel gnutls-devel libgcrypt-devel openssl-devel cyrus-sasl-devel libyaml-devel mongo-c-driver-devel libmicrohttpd-devel libcurl-devel libnghttp2-devel iproute
$ sudo dnf install python3 ninja-build gcc gcc-c++ flex bison git lksctp-tools-devel libidn-devel gnutls-devel libgcrypt-devel openssl-devel cyrus-sasl-devel libyaml-devel mongo-c-driver-devel libmicrohttpd-devel libcurl-devel libnghttp2-devel iproute
```
Install Meson

View File

@ -89,7 +89,7 @@ $ sudo pfctl -e -f /etc/pf.anchors/org.open5gs
Install the depedencies for building the source code.
```bash
$ brew install mongo-c-driver gnutls libgcrypt libidn libyaml libmicrohttpd nghttp2 pkg-config bison libusrsctp
$ brew install mongo-c-driver gnutls libgcrypt libidn libyaml libmicrohttpd nghttp2 pkg-config bison libusrsctp libtins
```
Configure Homebrew PATH
@ -97,6 +97,7 @@ Configure Homebrew PATH
$ export PATH="/opt/homebrew/opt/bison/bin:/opt/homebrew/bin:$PATH"
$ export LIBRARY_PATH=/opt/homebrew/lib
$ export C_INCLUDE_PATH=/opt/homebrew/include
$ export CPLUS_INCLUDE_PATH=/opt/homebrew/include
```
Install Meson using Homebrew.
@ -104,10 +105,6 @@ Install Meson using Homebrew.
$ brew install meson
```
Install libtins.
Follow the instructions at https://libtins.github.io to install libtins.
Git clone.
```bash

View File

@ -89,7 +89,7 @@ $ sudo pfctl -e -f /etc/pf.anchors/org.open5gs
Install the depedencies for building the source code.
```bash
$ brew install mongo-c-driver gnutls libgcrypt libidn libyaml libmicrohttpd nghttp2 pkg-config libusrsctp
$ brew install mongo-c-driver gnutls libgcrypt libidn libyaml libmicrohttpd nghttp2 pkg-config libusrsctp libtins
```
Install Bison and Create soft link.
@ -103,10 +103,6 @@ Install Meson using Homebrew.
$ brew install meson
```
Install libtins.
Follow the instructions at https://libtins.github.io to install libtins.
Git clone.
```bash

View File

@ -121,10 +121,6 @@ $ export LIBRARY_PATH=/usr/local/lib
$ export C_INCLUDE_PATH=/usr/local/include
```
Install libtins.
Follow the instructions at https://libtins.github.io to install libtins.
Git clone.
```bash

View File

@ -27,12 +27,14 @@
using namespace::Tins;
void _serialize_reply(uint8_t *reply_data, EthernetII &reply) {
void _serialize_reply(uint8_t *reply_data, EthernetII &reply)
{
PDU::serialization_type serialized = reply.serialize();
memcpy(reply_data, serialized.data(), reply.size());
}
bool _parse_arp(EthernetII &pdu) {
bool _parse_arp(EthernetII &pdu)
{
if (pdu.payload_type() == ETHERTYPE_ARP) {
const ARP& arp = pdu.rfind_pdu<ARP>();
return arp.opcode() == ARP::REQUEST && pdu.dst_addr().is_broadcast();
@ -46,7 +48,9 @@ bool is_arp_req(uint8_t *data, uint len)
return _parse_arp(pdu);
}
bool arp_reply(uint8_t *reply_data, uint8_t *request_data, uint len, const uint8_t *mac) {
bool arp_reply(uint8_t *reply_data, uint8_t *request_data, uint len,
const uint8_t *mac)
{
EthernetII pdu(request_data, len);
if (_parse_arp(pdu)) {
HWAddress<ETHER_ADDR_LEN> source_mac(mac);
@ -62,7 +66,8 @@ bool arp_reply(uint8_t *reply_data, uint8_t *request_data, uint len, const uint8
return false;
}
bool _parse_nd(EthernetII &pdu) {
bool _parse_nd(EthernetII &pdu)
{
if (pdu.payload_type() == ETHERTYPE_IPV6) {
const ICMPv6& icmp6 = pdu.rfind_pdu<ICMPv6>();
return icmp6.type() == ICMPv6::NEIGHBOUR_SOLICIT;
@ -79,7 +84,9 @@ bool is_nd_req(uint8_t *data, uint len)
return false;
}
bool nd_reply(uint8_t *reply_data, uint8_t *request_data, uint len, const uint8_t *mac) {
bool nd_reply(uint8_t *reply_data, uint8_t *request_data, uint len,
const uint8_t *mac)
{
EthernetII pdu(request_data, len);
if (_parse_nd(pdu)) {
HWAddress<ETHER_ADDR_LEN> source_mac(mac);

View File

@ -39,11 +39,12 @@ extern "C" {
void set_source_mac(uint8_t *data);
bool is_arp_req(uint8_t *data, uint len);
bool arp_reply(uint8_t *reply_data, uint8_t *request_data, uint len, const uint8_t *mac);
bool arp_reply(uint8_t *reply_data, uint8_t *request_data, uint len,
const uint8_t *mac);
bool is_nd_req(uint8_t *data, uint len);
bool nd_reply(uint8_t *reply_data, uint8_t *request_data, uint len, const uint8_t *mac);
bool nd_reply(uint8_t *reply_data, uint8_t *request_data, uint len,
const uint8_t *mac);
#ifdef __cplusplus
}
#endif

View File

@ -66,30 +66,44 @@ libupf_sources = files('''
pfcp-path.c
n4-build.c
n4-handler.c
arp-nd.h
'''.split())
tins_dep = cc.find_library('tins', required : true)
libtins_dep = dependency('libtins',
version: ['>=3.4'],
fallback: ['libtins', 'libtins_dep'])
libarp_nd = static_library('arp_nd',
sources : files('''
arp-nd.cpp
arp-nd.h
arp-nd.cpp
arp-nd.h
'''.split()),
dependencies : tins_dep,
dependencies : libtins_dep,
install : false)
libarp_nd_dep = declare_dependency(link_with : libarp_nd, dependencies : tins_dep)
libarp_nd_dep = declare_dependency(
link_with : libarp_nd,
dependencies : libtins_dep)
libupf = static_library('upf',
sources : libupf_sources,
dependencies : [
libapp_dep, libdiameter_gx_dep, libgtp_dep, libpfcp_dep, libtun_dep, libarp_nd_dep,
libapp_dep,
libdiameter_gx_dep,
libgtp_dep,
libpfcp_dep,
libtun_dep,
libarp_nd_dep,
],
install : false)
libupf_dep = declare_dependency(
link_with : libupf,
dependencies : [
libapp_dep, libdiameter_gx_dep, libgtp_dep, libpfcp_dep, libtun_dep, libarp_nd_dep,
libapp_dep,
libdiameter_gx_dep,
libgtp_dep,
libpfcp_dep,
libtun_dep,
libarp_nd_dep,
])
upf_sources = files('''

4
subprojects/libtins.wrap Normal file
View File

@ -0,0 +1,4 @@
[wrap-git]
directory = libtins
url = https://github.com/open5gs/libtins.git
revision = r4.3