From c8ec3702d02202c5c887b24895220c6a064db386 Mon Sep 17 00:00:00 2001 From: Sukchan Lee Date: Sat, 28 Oct 2017 10:09:44 +0000 Subject: [PATCH] update debian rule for override_dh_auto_test VM(like OBS) may not support SCTP At this point, I disabled SCTP-needed test code. --- .gitignore | 1 + debian/control | 13 +++++++---- debian/nextepc-pgw.postinst | 46 +++++++++++++++++++++++++++++++++++++ debian/nextepc-pgw.preinst | 21 ----------------- debian/rules | 27 ++++++++++++++++++---- src/mme/mme_init.c | 10 -------- src/mme/mme_sm.c | 26 +++++++++++++++++++++ support/config/hss.conf.in | 2 +- support/config/mme.conf.in | 3 +-- support/config/pcrf.conf.in | 2 +- support/config/pgw.conf.in | 3 +-- support/config/sgw.conf.in | 3 +-- 12 files changed, 108 insertions(+), 49 deletions(-) create mode 100644 debian/nextepc-pgw.postinst delete mode 100644 debian/nextepc-pgw.preinst diff --git a/.gitignore b/.gitignore index d09cf0352..e6f78ac97 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ lib/freeDiameter-*/include/freeDiameter/version.h lib/freeDiameter-*/include/freeDiameter/config.h.in lib/freeDiameter-*/include/freeDiameter/freeDiameter-host.h lib/core/include/core.h +support/systemd/nextepc-*.service support/logrotate/nextepc # autotools diff --git a/debian/control b/debian/control index 6aaf731c6..a998cfe7c 100644 --- a/debian/control +++ b/debian/control @@ -11,11 +11,12 @@ Build-Depends: debhelper (>= 9), flex, bison, libsctp-dev, - libssl-dev, libgnutls28-dev, libgcrypt-dev, + libssl-dev, libmongoc-dev, - libbson-dev + libbson-dev, + mongodb Standards-Version: 3.9.6 Vcs-Browser: https://github.com/acetcom/nextepc Vcs-Git: git://github.com/acetcom/nextepc @@ -67,7 +68,8 @@ Architecture: any Multi-Arch: same Depends: ${shlibs:Depends}, ${misc:Depends}, - nextepc-core (= ${binary:Version}) + nextepc-core (= ${binary:Version}), + iproute2 Description: Open Source based 3GPP EPC PGW (Packet Data Network Gateway) NextEPC is a C-language Open Source implementation of the 3GPP Evolved Packet Core, i.e. the core network of an LTE network. @@ -83,8 +85,9 @@ Architecture: any Multi-Arch: same Depends: ${shlibs:Depends}, ${misc:Depends}, - nextepc-core (= ${binary:Version}) -Description: Open Source based 3GPP EPC PGW (Policy and Charging Rules Function) + nextepc-core (= ${binary:Version}), + mongodb +Description: Open Source based 3GPP EPC PCRF (Policy and Charging Rules Function) NextEPC is a C-language Open Source implementation of the 3GPP Evolved Packet Core, i.e. the core network of an LTE network. . diff --git a/debian/nextepc-pgw.postinst b/debian/nextepc-pgw.postinst new file mode 100644 index 000000000..9eeb0e489 --- /dev/null +++ b/debian/nextepc-pgw.postinst @@ -0,0 +1,46 @@ +#!/bin/sh +# postinst script for nextepc +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + if ! grep "pgwtun" /proc/net/dev > /dev/null; then + ip tuntap add name pgwtun mode tun + ip addr add 45.45.0.1/16 dev pgwtun + ip link set pgwtun up + fi + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 + + diff --git a/debian/nextepc-pgw.preinst b/debian/nextepc-pgw.preinst deleted file mode 100644 index 823d50ba8..000000000 --- a/debian/nextepc-pgw.preinst +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# postinst script for nextepc -# -# see: dh_installdeb(1) - -set -e - -if ! grep "pgwtun" /proc/net/dev > /dev/null; then - ip tuntap add name pgwtun mode tun - ip addr add 45.45.0.1/16 dev pgwtun - ip link set pgwtun up -fi - -# dh_installdeb will replace this with shell code automatically -# generated by other debhelper scripts. - -#DEBHELPER# - -exit 0 - - diff --git a/debian/rules b/debian/rules index 2f13cc021..0575296f7 100755 --- a/debian/rules +++ b/debian/rules @@ -15,10 +15,27 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+all dh $@ --with autoreconf --with systemd override_dh_auto_test: - mkdir -p debian/test/etc/nextepc/freeDiameter debian/test/var/log/nextepc - sed 's?@SYSCONF_DIR@?'`pwd`'/debian/test/etc?g;s?@LOCALSTATE_DIR@?'`pwd`'/debian/test/var?g' support/config/nextepc.conf.in > debian/test/etc/nextepc/nextepc.conf + mkdir -p debian/test/db debian/test/etc/nextepc/freeDiameter debian/test/var/log/nextepc; \ + sed 's?@SYSCONF_DIR@?'`pwd`'/debian/test/etc?g;s?@LOCALSTATE_DIR@?'`pwd`'/debian/test/var?g' support/config/nextepc.conf.in > debian/test/etc/nextepc/nextepc.conf; \ for i in `find support/freeDiameter -name '*.conf.in' -printf "%f\n" | sed 's/.in$$//g'`; do \ sed 's?@SYSCONF_DIR@/nextepc?'`pwd`'/support?g;s?@LIB_DIR@/nextepc/\([_a-z0-9]*\)\.so?'`pwd`'/lib/fd/extensions/\1/.libs/\1.so?g' support/freeDiameter/$$i.in > debian/test/etc/nextepc/freeDiameter/$$i; \ - done; - test/testepc -f debian/test/etc/nextepc/nextepc.conf -c - rm -rf debian/test + done; \ + testcore_excluded_list=; \ + testepc_excluded_list=; \ + if ! cat /proc/net/protocols | grep SCTP > /dev/null; then \ + testcore_excluded_list="-x testnetlib"; \ + testepc_excluded_list="-x s1setup_test attach_test volte_test handover_test"; \ + fi; \ + mongodb_required=yes; \ + if ps -ef | grep mongod | grep -v grep > /dev/null; then \ + mongodb_required=no; \ + fi; \ + if test "x$$mongodb_required" = xyes; then \ + mongod --fork --logpath debian/test/var/log/mongodb.log --dbpath debian/test/db; \ + fi; \ + lib/core/test/testcore $$testcore_excluded_list || exit; \ + test/testepc -f debian/test/etc/nextepc/nextepc.conf -c $$testepc_excluded_list || exit; \ + if test "x$$mongodb_required" = xyes; then \ + pkill mongod; \ + fi; \ + rm -rf debian/test; diff --git a/src/mme/mme_init.c b/src/mme/mme_init.c index 7e5491c55..7084960cf 100644 --- a/src/mme/mme_init.c +++ b/src/mme/mme_init.c @@ -6,7 +6,6 @@ #include "mme_event.h" #include "mme_fd_path.h" -#include "mme_gtp_path.h" #include "s1ap_path.h" static thread_id sm_thread; @@ -39,11 +38,6 @@ status_t mme_initialize() rv = thread_create(&net_thread, NULL, net_main, NULL); if (rv != CORE_OK) return rv; - rv = mme_gtp_open(); - if (rv != CORE_OK) return rv; - rv = s1ap_open(); - if (rv != CORE_OK) return rv; - initialized = 1; return CORE_OK; @@ -53,10 +47,6 @@ void mme_terminate(void) { if (!initialized) return; - mme_gtp_close(); - s1ap_close(mme_self()->s1ap_sock); - mme_self()->s1ap_sock = NULL; - thread_delete(net_thread); thread_delete(sm_thread); diff --git a/src/mme/mme_sm.c b/src/mme/mme_sm.c index 1b4ce7567..fe1761734 100644 --- a/src/mme/mme_sm.c +++ b/src/mme/mme_sm.c @@ -12,6 +12,7 @@ #include "nas_path.h" #include "emm_handler.h" #include "esm_handler.h" +#include "mme_gtp_path.h" #include "mme_s11_handler.h" #include "fd_lib.h" #include "mme_fd_path.h" @@ -46,10 +47,35 @@ void mme_state_operational(fsm_t *s, event_t *e) { case FSM_ENTRY_SIG: { + rv = mme_gtp_open(); + if (rv != CORE_OK) + { + d_error("Can't establish S11-GTP path"); + break; + } + rv = s1ap_open(); + if (rv != CORE_OK) + { + d_error("Can't establish S1AP path"); + break; + } + break; } case FSM_EXIT_SIG: { + rv = mme_gtp_close(); + if (rv != CORE_OK) + { + d_error("Can't close S11-GTP path"); + } + rv = s1ap_close(mme_self()->s1ap_sock); + if (rv != CORE_OK) + { + d_error("Can't close S1AP path"); + } + mme_self()->s1ap_sock = NULL; + break; } case MME_EVT_S1AP_LO_ACCEPT: diff --git a/support/config/hss.conf.in b/support/config/hss.conf.in index afb3a7df4..07a734bcb 100644 --- a/support/config/hss.conf.in +++ b/support/config/hss.conf.in @@ -1,6 +1,6 @@ { DB_URI : "mongodb://localhost/nextepc", - LOG_PATH : "@LOCALSTATE_DIR@/log/nextepc/nextepc.log", + LOG_PATH : "@LOCALSTATE_DIR@/log/nextepc/hss.log", TRACE: { FD: 1, diff --git a/support/config/mme.conf.in b/support/config/mme.conf.in index 65d18df9d..94ac91e0b 100644 --- a/support/config/mme.conf.in +++ b/support/config/mme.conf.in @@ -1,6 +1,5 @@ { - DB_URI : "mongodb://localhost/nextepc", - LOG_PATH : "@LOCALSTATE_DIR@/log/nextepc/nextepc.log", + LOG_PATH : "@LOCALSTATE_DIR@/log/nextepc/mme.log", TRACE: { S1AP: 1, diff --git a/support/config/pcrf.conf.in b/support/config/pcrf.conf.in index 83773dd43..b960e4b43 100644 --- a/support/config/pcrf.conf.in +++ b/support/config/pcrf.conf.in @@ -1,6 +1,6 @@ { DB_URI : "mongodb://localhost/nextepc", - LOG_PATH : "@LOCALSTATE_DIR@/log/nextepc/nextepc.log", + LOG_PATH : "@LOCALSTATE_DIR@/log/nextepc/pcrf.log", TRACE: { FD: 1, diff --git a/support/config/pgw.conf.in b/support/config/pgw.conf.in index c1a2cb36c..dc30e9a9d 100644 --- a/support/config/pgw.conf.in +++ b/support/config/pgw.conf.in @@ -1,6 +1,5 @@ { - DB_URI : "mongodb://localhost/nextepc", - LOG_PATH : "@LOCALSTATE_DIR@/log/nextepc/nextepc.log", + LOG_PATH : "@LOCALSTATE_DIR@/log/nextepc/pgw.log", TRACE: { FD: 1, diff --git a/support/config/sgw.conf.in b/support/config/sgw.conf.in index 02be82d5f..870b1fa89 100644 --- a/support/config/sgw.conf.in +++ b/support/config/sgw.conf.in @@ -1,6 +1,5 @@ { - DB_URI : "mongodb://localhost/nextepc", - LOG_PATH : "@LOCALSTATE_DIR@/log/nextepc/nextepc.log", + LOG_PATH : "@LOCALSTATE_DIR@/log/nextepc/sgw.log", TRACE: { GTP: 1,