Unverified Commit 6275f772 authored by Rohan's avatar Rohan

entrypoint clean up

parent 32d0067b
......@@ -9,7 +9,7 @@
# */
#---------------------------------------------------------------------
#
# Dockerfile for the Open-Air-Interface UPF service
# Dockerfile for the VPP-UPF service
# Valid for Ubuntu-18.04 (bionic)
#
#---------------------------------------------------------------------
......@@ -38,7 +38,7 @@ RUN git clone https://github.com/travelping/upg-vpp.git
RUN mv upg-vpp/upf/ vpp/src/plugins/
RUN mv upg-vpp/vpp-patches/* scripts/patches/
RUN mv upg-vpp/vpp.spec /
RUN ./scripts/apply_vpp_patches
RUN ./scripts/apply_vpp_patches.sh
RUN touch /etc/apt/apt.conf.d/90forceyes
RUN echo "APT::Get::Assume-Yes "true";" >> /etc/apt/apt.conf.d/90forceyes
RUN echo "APT::Get::force-yes "true";" >> /etc/apt/apt.conf.d/90forceyes
......@@ -61,28 +61,30 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get upgrade --yes && DE
openssl \
libhyperscan-dev \
iproute2 \
vim \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /openair-upf/bin/
COPY --from=vpp-upf-builder /vpp-upf/scripts/entrypoint.sh /openair-upf/bin/entrypoint.sh
COPY --from=vpp-upf-builder /vpp-upf/scripts/run.sh /openair-upf/run.sh
COPY --from=vpp-upf-builder /vpp-upf/vpp/build-root/install-vpp-native/vpp/bin/vpp vpp
COPY --from=vpp-upf-builder /vpp-upf/vpp/build-root/install-vpp-native/vpp/bin/vppctl vppctl
WORKDIR /openair-upf/etc
COPY --from=vpp-upf-builder /vpp-upf/scripts/upf_conf/init.conf /openair-upf/etc/init.conf
COPY --from=vpp-upf-builder /vpp-upf/scripts/upf_conf/startup_debug.conf /openair-upf/etc/startup_debug.conf
COPY --from=vpp-upf-builder /vpp-upf/scripts/add_route.sh /openair-upf/etc/add_route.sh
WORKDIR /usr/lib/x86_64-linux-gnu/
COPY --from=vpp-upf-builder /vpp-upf/vpp/build-root/install-vpp-native/vpp/lib/ .
RUN ldconfig
RUN groupadd vpp
#expose
#EXPOSE <write the port numbers>
WORKDIR /openair-upf/
COPY --from=vpp-upf-builder /vpp-upf/scripts/run.sh /openair-upf/run.sh
#expose
#EXPOSE 8085/udp 2152/udp
ENTRYPOINT ["/openair-upf/bin/entrypoint.sh"]
CMD ["/openair-upf/run.sh"]
#!/usr/bin/env bash
ip link set eth0 down
ip link set eth0 name access
ip link set access up
ip link set eth1 down
ip link set eth1 name core
ip link set core up
ip link set eth2 down
ip link set eth2 name sgi
ip link set sgi up
ip route add @NETWORK_UE_IP@ via @UE_DL_Gw@ dev sgi
ip route add @SUBNET_ACCESS@ dev access
ip route add @SUBNET_CORE@ dev core
ip route add @SUBNET_SGI@ dev sgi
#!/usr/bin/env bash
cd scripts/patches/
find . -iname '*.patch' -execdir sh -c 'patch -p1 -N -d ../../vpp < $0' {} \;
#!/usr/bin/env bash
# @Raphael -> first 3 files are common to docker and native installation
# files are common to docker and native installation
#____________
# init.conf => upf config
# startup_debug.conf => vpp config (To Do -> sed location of init.conf file)
# run_sh => run vpp
# add_route.sh => container routes
#____________
set -euo pipefail
CONFIG_DIR="/openair-upf/etc"
###############################
......@@ -17,7 +18,6 @@ CONFIG_DIR="/openair-upf/etc"
for c in ${CONFIG_DIR}/*.conf; do
# grep variable names (format: ${VAR}) from template to be rendered
VARS=$(grep -oP '@[a-zA-Z0-9_]+@' ${c} | sort | uniq | xargs)
# create sed expressions for substituting each occurrence of ${VAR}
# with the value of the environment variable "VAR"
EXPRESSIONS=""
......@@ -31,57 +31,38 @@ for c in ${CONFIG_DIR}/*.conf; do
EXPRESSIONS="${EXPRESSIONS};s|${v}|${!NEW_VAR}|g"
done
EXPRESSIONS="${EXPRESSIONS#';'}"
# render template and inline replace config file
sed -i "${EXPRESSIONS}" ${c}
done
###############################
# VPP Routes
###############################
# @Raphael
# Assumption ->
# Assumption ->
# UPF has only three interfaces viz. n3 (access) eth0, n4 (core) eth1, n6 (sgi) eth2
# Near future we will have multiple interfaces (e.g. two n6 interface for edge computing case)
# We define in this order in docker-compose -> it is alphabetical order
#
ACCESS_IPV4=$(ifconfig eth0 | grep "inet " | awk '{print $2}')
CORE_IPV4=$(ifconfig eth1 | grep "inet " | awk '{print $2}')
SGI_IPV4=$(ifconfig eth2 | grep "inet " | awk '{print $2}')
# Dirty extraction -> we assume /24 subnet
export UE_DL_Gw=$SGI_IPV4
export SUBNET_ACCESS=`echo $ACCESS_IPV4 | sed -e 's/\.[^.]*\$//'`'.0/24';
export SUBNET_CORE=`echo $CORE_IPV4 | sed -e 's/\.[^.]*\$//'`'.0/24';
export SUBNET_SGI=`echo $SGI_IPV4 | sed -e 's/\.[^.]*\$//'`'.0/24';
for c in ${CONFIG_DIR}/add_route.sh; do
# grep variable names (format: ${VAR}) from template to be rendered
VARS=$(grep -oP '@[a-zA-Z0-9_]+@' ${c} | sort | uniq | xargs)
UE_DL_Gw=$SGI_IPV4
# create sed expressions for substituting each occurrence of ${VAR}
# with the value of the environment variable "VAR"
EXPRESSIONS=""
for v in ${VARS}; do
NEW_VAR=`echo $v | sed -e "s#@##g"`
if [[ "${!NEW_VAR}x" == "x" ]]; then
echo "Error: Environment variable '${NEW_VAR}' is not set." \
"Config file '$(basename $c)' requires all of $VARS."
exit 1
fi
EXPRESSIONS="${EXPRESSIONS};s|${v}|${!NEW_VAR}|g"
done
EXPRESSIONS="${EXPRESSIONS#';'}"
ip link set eth0 down
ip link set eth0 name access
ip link set access up
# render template and inline replace config file
sed -i "${EXPRESSIONS}" ${c}
done
ip link set eth1 down
ip link set eth1 name core
ip link set core up
exec "$@"
ip link set eth2 down
ip link set eth2 name sgi
ip link set sgi up
sleep 1
ip route add $NETWORK_UE_IP via $UE_DL_Gw dev sgi
exec /openair-upf/etc/add_route.sh
echo "Done setting the configuration"
#____________________________________________________________________________
exec "$@"
......@@ -36,16 +36,20 @@ services:
UDM_IPV4_ADDRESS: 192.168.61.194
UDM_PORT: 80
UDM_API_VERSION: v1
UPF_IPV4_ADDRESS: 192.168.61.201
entrypoint: /bin/bash -c \
"./bin/entrypoint.sh; ./bin/oai_smf -o -c etc/smf.conf; sleep infinity"
UPF_IPV4_ADDRESS: 192.168.61.202
USE_NETWORK_INSTANCE: 'yes'
DISCOVER_UPF: 'no'
NRF_API_VERSION: 'v1'
NRF_IPV4_ADDRESS: '127.0.0.1'
NRF_PORT: '8080'
REGISTER_NRF: 'no'
healthcheck:
test: /bin/bash -c "pgrep oai_smf"
interval: 10s
timeout: 5s
retries: 5
extra_hosts:
- "gw1.vppupf.node.epc.mnc95.mcc208.3gppnetwork.org:192.168.61.201"
- "gw1.vppupf.node.5gcn.mnc95.mcc208.3gppnetwork.org:192.168.61.202"
oai-amf:
image: oai-amf:develop
......@@ -76,6 +80,7 @@ services:
SST_1: '1'
SD_0: '123'
SD_1: '12'
SMF_SELECTION: 'no'
SMF_INSTANCE_ID_0: 1
SMF_INSTANCE_ID_1: 2
SMF_IPV4_ADDR_0: 192.168.61.196
......@@ -95,10 +100,7 @@ services:
MYSQL_PASS: 'linux'
MYSQL_DB: 'oai_db'
OPERATOR_KEY: '63bfa50ee6523365ff14c1f45f88737d'
entrypoint: /bin/bash -c \
"./bin/entrypoint.sh; ./bin/oai_amf -o -c etc/amf.conf; sleep infinity"
volumes:
- ./entrypoint.sh:/openair-amf/bin/entrypoint.sh
NF_REGISTRATION: 'no'
healthcheck:
test: /bin/bash -c "pgrep oai_smf"
interval: 10s
......@@ -127,14 +129,16 @@ services:
REALM: "3gppnetwork.org"
NETWORK_UE_IP: "12.1.1.0/24"
N3_IPV4_ADDRESS_REMOTE: "192.168.62.198"
N3_IPV4_ADDRESS_LOCAL : "192.168.62.201"
N3_IPV4_ADDRESS_LOCAL : "192.168.62.202"
N4_IPV4_ADDRESS_REMOTE: "192.168.61.196"
N4_IPV4_ADDRESS_LOCAL : "192.168.61.201"
N4_IPV4_ADDRESS_LOCAL : "192.168.61.202"
N6_IPV4_ADDRESS_REMOTE: "192.168.63.205"
N6_IPV4_ADDRESS_LOCAL : "192.168.63.201"
N6_IPV4_ADDRESS_LOCAL : "192.168.63.202"
VPP_MAIN_CORE : 0
VPP_CORE_WORKER: 1
# entrypoint: /bin/bash -c "/openair-upf/bin/entrypoint.sh;./run.sh; sleep infinity"
# volumes:
# - ../entrypoint.sh:/openair-upf/bin/entrypoint.sh
# entrypoint: /bin/bash -c "./bin/entrypoint.sh; ./run.sh"
oai-spgwu:
image: oai-spgwu-tiny:gtp_ext_header
......@@ -182,21 +186,36 @@ services:
"iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE;"\
"ip route add 10.1.1.0/24 via 192.168.61.199 dev eth0;"\
"ip route add 12.1.1.0/24 via 192.168.63.201 dev eth1; sleep infinity"
gnbsim:
image: gnbsim:latest
privileged: true
container_name: gnbsim
environment:
AMF_NGAP_IPV4_ADDRESS: 192.168.61.195
networks:
public_net:
ipv4_address: 192.168.61.198
public_net_access:
ipv4_address: 192.168.62.198
volumes:
- ./lib/modules/5.8.0-43-generic/kernel/drivers/net/gtp.ko:/lib/modules/5.8.0-43-generic/kernel/drivers/net/gtp.ko
entrypoint: /bin/bash -c "sleep infinity"
networks:
public_net:
name: oai-public-net
ipam:
config:
- subnet: 192.168.61.192/24
- subnet: 192.168.61.0/24
public_net_access:
name: oai-public-access
ipam:
config:
- subnet: 192.168.62.192/24
- subnet: 192.168.62.0/24
public_net_sgi_lan:
name: oai-public-sgi-lan
ipam:
config:
- subnet: 192.168.63.192/24
- subnet: 192.168.63.0/24
......@@ -24,7 +24,7 @@ ip route add 0.0.0.0/0 table 0 via @N4_IPV4_ADDRESS_REMOTE@ host-core
ip route add 0.0.0.0/0 table 1 via @N6_IPV4_ADDRESS_REMOTE@ host-sgi
upf pfcp endpoint ip @N4_IPV4_ADDRESS_LOCAL@ vrf 0
upf node-id fqdn gw@GW_ID@.vppupf.node.epc.mnc@MNC03@.mcc@MCC@.@REALM@
upf node-id fqdn gw@GW_ID@.vppupf.node.5gcn.mnc@MNC03@.mcc@MCC@.@REALM@
upf nwi name @NWI_CORE@ vrf 0
upf nwi name @NWI_ACCESS@ vrf 2
......
......@@ -13,8 +13,8 @@ api-trace {
}
#cpu {
# main-core 0
# corelist-workers 1
# main-core @VPP_MAIN_CORE@
# corelist-workers @VPP_CORE_WORKER@
#}
api-segment {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment