From 5d460b05775f1273e29dcd3f50846fe915bfd354 Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Sat, 29 May 2021 23:08:22 +0900 Subject: [PATCH] [UPF] Tested all platforms on open5gs (#1022) --- debian/control | 1 + docker/centos/7/base/Dockerfile | 30 --------------- docker/centos/7/dev | 1 - docker/centos/8 | 1 - docker/centos/latest/base/Dockerfile | 37 ------------------- docker/centos/latest/dev/Dockerfile | 22 ----------- docker/centos/latest/dev/setup.sh | 10 ----- docker/check.sh | 3 -- docker/debian/latest/base/Dockerfile | 1 + docker/fedora/latest/base/Dockerfile | 1 + docker/ubuntu/latest/base/Dockerfile | 1 + docs/_docs/guide/01-quickstart.md | 1 + .../guide/02-building-open5gs-from-sources.md | 2 +- docs/_docs/platform/02-centos.md | 2 +- docs/_docs/platform/03-fedora.md | 2 +- .../_docs/platform/05-macosx-apple-silicon.md | 7 +--- docs/_docs/platform/06-macosx-intel.md | 6 +-- docs/_docs/platform/07-freebsd.md | 4 -- src/upf/arp-nd.cpp | 17 ++++++--- src/upf/arp-nd.h | 7 ++-- src/upf/meson.build | 30 +++++++++++---- subprojects/libtins.wrap | 4 ++ 22 files changed, 53 insertions(+), 137 deletions(-) delete mode 100644 docker/centos/7/base/Dockerfile delete mode 120000 docker/centos/7/dev delete mode 120000 docker/centos/8 delete mode 100644 docker/centos/latest/base/Dockerfile delete mode 100644 docker/centos/latest/dev/Dockerfile delete mode 100755 docker/centos/latest/dev/setup.sh create mode 100644 subprojects/libtins.wrap diff --git a/debian/control b/debian/control index 57916412e..346766a42 100644 --- a/debian/control +++ b/debian/control @@ -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 diff --git a/docker/centos/7/base/Dockerfile b/docker/centos/7/base/Dockerfile deleted file mode 100644 index 92c91e9f9..000000000 --- a/docker/centos/7/base/Dockerfile +++ /dev/null @@ -1,30 +0,0 @@ -ARG dist=centos -ARG tag=latest -FROM ${dist}:${tag} - -MAINTAINER Sukchan Lee - -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 diff --git a/docker/centos/7/dev b/docker/centos/7/dev deleted file mode 120000 index 4d9f1c963..000000000 --- a/docker/centos/7/dev +++ /dev/null @@ -1 +0,0 @@ -../8/dev \ No newline at end of file diff --git a/docker/centos/8 b/docker/centos/8 deleted file mode 120000 index b9bc2fdcb..000000000 --- a/docker/centos/8 +++ /dev/null @@ -1 +0,0 @@ -latest \ No newline at end of file diff --git a/docker/centos/latest/base/Dockerfile b/docker/centos/latest/base/Dockerfile deleted file mode 100644 index db12baf94..000000000 --- a/docker/centos/latest/base/Dockerfile +++ /dev/null @@ -1,37 +0,0 @@ -ARG dist=centos -ARG tag=latest -FROM ${dist}:${tag} - -MAINTAINER Sukchan Lee - -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 diff --git a/docker/centos/latest/dev/Dockerfile b/docker/centos/latest/dev/Dockerfile deleted file mode 100644 index 44b590668..000000000 --- a/docker/centos/latest/dev/Dockerfile +++ /dev/null @@ -1,22 +0,0 @@ -ARG dist=centos -ARG tag=latest -ARG username=acetcom -FROM ${username}/${dist}-${tag}-open5gs-base - -MAINTAINER Sukchan Lee - -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} diff --git a/docker/centos/latest/dev/setup.sh b/docker/centos/latest/dev/setup.sh deleted file mode 100755 index e3210034b..000000000 --- a/docker/centos/latest/dev/setup.sh +++ /dev/null @@ -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 diff --git a/docker/check.sh b/docker/check.sh index 5dc5d9a68..533b98236 100755 --- a/docker/check.sh +++ b/docker/check.sh @@ -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 diff --git a/docker/debian/latest/base/Dockerfile b/docker/debian/latest/base/Dockerfile index 8d3ac958e..b098b240c 100644 --- a/docker/debian/latest/base/Dockerfile +++ b/docker/debian/latest/base/Dockerfile @@ -28,6 +28,7 @@ RUN apt-get update && \ libmicrohttpd-dev \ libcurl4-gnutls-dev \ libnghttp2-dev \ + libtins-dev \ iproute2 \ ca-certificates \ netbase \ diff --git a/docker/fedora/latest/base/Dockerfile b/docker/fedora/latest/base/Dockerfile index ad6df0a63..5491b1ac5 100644 --- a/docker/fedora/latest/base/Dockerfile +++ b/docker/fedora/latest/base/Dockerfile @@ -8,6 +8,7 @@ RUN dnf -y install \ python3 \ ninja-build \ gcc \ + gcc-c++ \ flex \ bison \ git \ diff --git a/docker/ubuntu/latest/base/Dockerfile b/docker/ubuntu/latest/base/Dockerfile index 8d3ac958e..b098b240c 100644 --- a/docker/ubuntu/latest/base/Dockerfile +++ b/docker/ubuntu/latest/base/Dockerfile @@ -28,6 +28,7 @@ RUN apt-get update && \ libmicrohttpd-dev \ libcurl4-gnutls-dev \ libnghttp2-dev \ + libtins-dev \ iproute2 \ ca-certificates \ netbase \ diff --git a/docs/_docs/guide/01-quickstart.md b/docs/_docs/guide/01-quickstart.md index 8f9152958..1ec996dd6 100644 --- a/docs/_docs/guide/01-quickstart.md +++ b/docs/_docs/guide/01-quickstart.md @@ -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 diff --git a/docs/_docs/guide/02-building-open5gs-from-sources.md b/docs/_docs/guide/02-building-open5gs-from-sources.md index 7a4c3a626..2b763e871 100644 --- a/docs/_docs/guide/02-building-open5gs-from-sources.md +++ b/docs/_docs/guide/02-building-open5gs-from-sources.md @@ -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. diff --git a/docs/_docs/platform/02-centos.md b/docs/_docs/platform/02-centos.md index cf58c0b87..55cafb80a 100644 --- a/docs/_docs/platform/02-centos.md +++ b/docs/_docs/platform/02-centos.md @@ -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. diff --git a/docs/_docs/platform/03-fedora.md b/docs/_docs/platform/03-fedora.md index 835eac9b3..7312b4126 100644 --- a/docs/_docs/platform/03-fedora.md +++ b/docs/_docs/platform/03-fedora.md @@ -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 diff --git a/docs/_docs/platform/05-macosx-apple-silicon.md b/docs/_docs/platform/05-macosx-apple-silicon.md index dd95989c6..0a78c0079 100644 --- a/docs/_docs/platform/05-macosx-apple-silicon.md +++ b/docs/_docs/platform/05-macosx-apple-silicon.md @@ -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 diff --git a/docs/_docs/platform/06-macosx-intel.md b/docs/_docs/platform/06-macosx-intel.md index e1b48df8b..f81552f62 100644 --- a/docs/_docs/platform/06-macosx-intel.md +++ b/docs/_docs/platform/06-macosx-intel.md @@ -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 diff --git a/docs/_docs/platform/07-freebsd.md b/docs/_docs/platform/07-freebsd.md index 630827d67..84d6defb9 100644 --- a/docs/_docs/platform/07-freebsd.md +++ b/docs/_docs/platform/07-freebsd.md @@ -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 diff --git a/src/upf/arp-nd.cpp b/src/upf/arp-nd.cpp index 2b72e75eb..531c26431 100644 --- a/src/upf/arp-nd.cpp +++ b/src/upf/arp-nd.cpp @@ -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(); 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 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(); 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 source_mac(mac); diff --git a/src/upf/arp-nd.h b/src/upf/arp-nd.h index cca57130b..3d5712935 100644 --- a/src/upf/arp-nd.h +++ b/src/upf/arp-nd.h @@ -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 - diff --git a/src/upf/meson.build b/src/upf/meson.build index 6d720c702..bee0e522c 100644 --- a/src/upf/meson.build +++ b/src/upf/meson.build @@ -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(''' diff --git a/subprojects/libtins.wrap b/subprojects/libtins.wrap new file mode 100644 index 000000000..0c53a0970 --- /dev/null +++ b/subprojects/libtins.wrap @@ -0,0 +1,4 @@ +[wrap-git] +directory = libtins +url = https://github.com/open5gs/libtins.git +revision = r4.3