Commit ca9c330f authored by wangyongshou's avatar wangyongshou

Support multiple gnb multiple gtpu tunnel

parents d31c5ab9 1d7c27f2
set interface state if_n3 up
set interface ip address if_n3 @gtpu_entry_ip@/24
set interface state if_n6 up
set interface ip address if_n6 @gtpu_export_ip@/24
create gtpu tunnel src @gtpu_entry_ip@ dst @gnb_gtpu_ip@ teid 1 encap-vrf-id 0 decap-next node ip4-lookup
ip route add @ue_ip@/24 via gtpu_tunnel0
ip route add 0.0.0.0/0 via if_n6 @vpp_host_ip@
gnb: @gnb@
smf : @smf@
upf : @upf@
logSize : @logSize@
unix {
nodaemon
log /var/log/upf/vpp/vpp.log
full-coredump
interactive
gid vpp
cli-listen /run/vpp/cli.sock
exec /opt/5gc/config_system.sh
logsize 100
}
api-trace {
on
}
api-segment {
gid vpp
}
logging
{
default-log-level info
default-syslog-log-level info
}
statseg {
default
per-node-counters on
}
cpu {
main-core @MAINCORE@
corelist-workers @WORKERCORE@
scheduler-policy fifo
scheduler-priority 50
}
#buffers {
#buffers-per-numa 128000
#Default is 2048
#}
dpdk {
dev default {
num-rx-queues 1
}
dev @PCI_ADDR_ID_ENTRY@
{
name if_n3
num-rx-queues 2
num-tx-queues 2
}
dev @PCI_ADDR_ID_EXPORT@
{
name if_n6
num-rx-queues 1
}
uio-driver vfio-pci
no-multi-seg
socket-mem 2048,2048
no-tx-checksum-offload
}
heapsize 2G
plugins {
path /usr/lib/x86_64-linux-gnu/vpp_plugins
plugin default { enable }
plugin dpdk_plugin.so { enable }
plugin gtpu_plugin.so { enable }
plugin upf_plugin.so { enable }
}
vpp:
system:
gtpu_entry_ip: 192.168.10.40
gtpu_export_ip: 192.168.50.10
gnb_gtpu_ip: 192.168.10.100
ip_link:
ueip: 192.169.0.0
ueIPPrefix: 24
snatInter: ens32
snatIP: 192.168.2.78
vppHost: ens35
vppHostIP: 192.168.50.11
gtpu_entry: ens33
gtpu_export: ens34
cpu: 3f
n4:
smf: 192.168.2.39
upf: 192.168.2.78
logSize: 100
File added
#!/bin/bash
current="$PWD"
base=$(dirname "$PWD")
VPPPATH="$base/src/vppe"
VPPINSTALL="$base/install/vpp"
BUILD_ROOT="build-root"
configure="$base/etc"
N4SRC="$base/src/upf-n4/cmd/upf/main"
N4PATH="$base/install/n4"
function pre_install(){
sudo apt-get install net-tools
sudo apt-get install ethtool
sudo apt-get install make
sudo apt-get install cmake
sudo apt-get install ccache
sudo apt-get install dpkg-buildpackage
cd $base/src/vppe
$base/src/vppe/pre_install.sh
}
function vpp(){
echo "start build vpp"
cd $VPPPATH
make rebuild
echo "build vpp success"
cp $base/src/vppe/build-root/install-vpp_debug-native/vpp/bin/* /usr/bin
cp -r $base/src/vppe/build-root/install-vpp_debug-native/vpp/lib/vpp_plugins /usr/lib/x86_64-linux-gnu
groupadd -g 344 vpp
return 0
}
function make_package()
{
#clear
rm -rf $VPPPATH/${BUILD_ROOT}/.ccache;
find $VPPPATH/${BUILD_ROOT}/ -name '*.c' -type f -print -exec rm -rf {} \;
find $VPPPATH/${BUILD_ROOT}/ -name '*.o' -type f -print -exec rm -rf {} \;
find $VPPPATH/${BUILD_ROOT}/ -name '*.o.cmd' -type f -print -exec rm -rf {} \;
find $VPPPATH/${BUILD_ROOT}/ -name '*.debug' -type f -print -exec rm -rf {} \;
find $VPPPATH/${BUILD_ROOT}/ -name '*.api.json' -type f -print -exec rm -rf {} \;
rm -rf $VPPPATH/${BUILD_ROOT}/build-test;
#pkg
vpp_tar_gz="buptvppe.tar.gz"
cd $VPPPATH
sudo tar -zcvf $vpp_tar_gz ${BUILD_ROOT} > /dev/null 2>&1;
sudo rm -rf $VPPINSTALL
sudo mkdir -p $VPPINSTALL
sudo mv $VPPPATH/$vpp_tar_gz $VPPINSTALL
}
function n4(){
echo "start build 5GN4"
cd $N4SRC
go build
echo "build 5GN4 success"
mkdir -p $N4PATH
mv $N4SRC/main $N4PATH
}
function clear_all()
{
cd $VPPPATH
make wipe
rm -rf $VPPPATH/${BUILD_ROOT}/build-test;
rm -rf $VPPPATH/${BUILD_ROOT}/build-vpp_debug-native;
rm -rf $VPPPATH/${BUILD_ROOT}/build-vpp-native;
rm -rf $VPPPATH/${BUILD_ROOT}/install-vpp-native;
rm -rf $VPPPATH/${BUILD_ROOT}/install-vpp_debug-native;
rm -rf $VPPPATH/${BUILD_ROOT}/*.deb
rm -rf $VPPPATH/${BUILD_ROOT}/vpp_20.05-rc0~582*
rm -rf $VPPPATH/build/external/downloads/*
}
function help()
{
echo " "
echo "Usage: build_upf [OPTION]..."
echo "--pre_install Pre-installation of dependencies required by UPF"
echo "--vpp Build vpp"
echo "--n4 Build N4"
echo "--c Remove files generated by previous compilation "
}
function main() {
if [ $# -eq 0 ];
then
help
exit
fi
until [ -z "$1" ]; do
case "$1" in
--all)
pre_install
install_golang
vpp
n4
shift
;;
--pre_install)
pre_install
shift
;;
--vpp)
vpp
shift
;;
--n4)
n4
shift
;;
--c)
clear_all
shift
;;
esac
done
exit 0
}
main "$@"
This diff is collapsed.
#!/bin/bash
current="$PWD"
base=$(dirname "$PWD")
VPPPATH="$base/src/vppe"
VPPINSTALL="$base/upf/vpp"
BUILD_ROOT="build-root"
configure="$base/etc"
arp="$base/src/setuniarp"
config_system=""
VPPPROCESS="vpp"
VPPCMD="/usr/bin/vpp -c /opt/5gc/startup_debug.conf"
N4PROCESS="main"
N4PATH="$base/install/n4"
UEIP=""
PREFIX=""
INTER=""
MAC=""
VPPEXPORT=""
ARPPROCESS="setuniarp"
UE_IP=""
UE_IP_PREFIX=""
SNAT_INTER=""
SNAT_IP=""
VPPHOST=""
DPDK_EXPORT=""
DPDK_ENTRY=""
DPDK_ENTRY_PCI=""
DPDK_EXPORT_PCI=""
DRIVE=""
CPUNUMBER=""
function init_configure(){
yaml="$1"
# vpp
mkdir -p /opt/5gc
cp -r $configure/template /opt/5gc
$base/plugin/configure -i $yaml -o /opt/5gc
cp $base/plugin/yq $current
# arp
UEIP=$($current/yq r $yaml vpp.ip_link.ueip)
PREFIX=$($current/yq r $yaml vpp.ip_link.ueIPPrefix)
INTER=$($current/yq r $yaml vpp.ip_link.vppHost)
VPPEXPORT=$($current/yq r $yaml vpp.system.gtpu_export_ip)
MAC=$(ifconfig $INTER|grep ether|awk '{print $2}')
# nat
UE_IP=$($current/yq r $yaml vpp.ip_link.ueip)
UE_IP_PREFIX=$($current/yq r $yaml vpp.ip_link.ueIPPrefix)
SNAT_INTER=$($current/yq r $yaml vpp.ip_link.snatInter)
SNAT_IP=$($current/yq r $yaml vpp.ip_link.snatIP)
VPPHOST=$($current/yq r $yaml vpp.ip_link.vppHost)
DPDK_EXPORT=$($current/yq r $yaml vpp.ip_link.gtpu_export)
DPDK_ENTRY=$($current/yq r $yaml vpp.ip_link.gtpu_entry)
CPUNUMBER=$($current/yq r $yaml vpp.ip_link.cpu)
rm -rf $current/yq
}
function start_vpp() {
cmd="$VPPCMD"
install_dpdk_kmod
run_nat
$base/plugin/interreput -i $CPUNUMBER
echo Y | sudo tee /sys/module/vfio/parameters/enable_unsafe_noiommu_mode
$cmd >/dev/null 2>&1 &
sleep 1s
pid=$(pidof $VPPPROCESS)
if test -z "$pid"; then
echo "vpp startup failed"
else
echo "vpp $pid startup success"
fi
}
function start_n4() {
$N4PATH/main -c /opt/5gc/n4_config.yaml >/dev/null 2>&1 &
sleep 1s
pid2=$(pidof $N4PROCESS)
if test -z "$pid2"; then
echo "n4 startup failed"
else
echo "n4 $pid2 startup success"
fi
}
function start_arp() {
echo "start arp"
echo "$arp"/setuniarp $INTER $MAC "$UEIP/$PREFIX" $VPPEXPORT
"$arp"/setuniarp $INTER $MAC "$UEIP/$PREFIX" $VPPEXPORT >/dev/null 2>&1 &
sleep 1s
pid2=$(pidof $ARPPROCESS)
if test -z "$pid2"; then
echo "arp startup failed"
else
echo "arp $pid2 startup success"
fi
exit 0
}
function close_vpp() {
pid=$(pidof $VPPPROCESS)
if test -z "$pid"; then
echo "vpp $pid is not startup"
else
echo "kill vpp $pid"
kill -9 ${pid}
fi
}
function close_n4() {
pid=$(pidof $N4PROCESS)
if test -z "$pid"; then
echo "n4 $pid is not startup"
else
echo "kill n4 $pid"
kill -9 ${pid}
fi
}
function close_arp() {
pid=$(pidof $ARPPROCESS)
if test -z "$pid"; then
echo "arp $pid is not startup"
else
echo "kill arp $pid"
kill -9 ${pid}
fi
}
function install_dpdk_kmod() {
sudo modprobe vfio-pci;
insmod_result=$?
exec_result $insmod_result
return 0;
}
function exec_result()
{
if [ $1 -ne 0 ]; then
echo "insmod vfio-pci.ko false"
fi
echo "insmod vfio-pci.ko success!!!"
}
function run_nat(){
echo "$UE_IP"
echo "$UE_IP_PREFIX"
echo "$SNAT_INTER"
echo "$SNAT_IP"
echo "$VPPHOST"
echo "$DPDK_EXPORT"
echo "$DPDK_ENTRY"
sudo ifconfig $DPDK_EXPORT down
sudo ifconfig $DPDK_ENTRY down
sudo ethtool -K "$SNAT_INTER" gro off;
sudo ethtool -K "$SNAT_INTER" tso off;
sudo ethtool -K "$SNAT_INTER" sg off;
#del
sudo iptables -t nat -D POSTROUTING -s "$UE_IP/$UE_IP_PREFIX" -j SNAT --to-source "$SNAT_IP"
iptables -t mangle -D POSTROUTING -p tcp --tcp-flags SYN,RST SYN -o "$SNAT_INTER" -j TCPMSS --set-mss 1300
#add
sudo iptables -t nat -A POSTROUTING -s "$UE_IP/$UE_IP_PREFIX" -j SNAT --to-source "$SNAT_IP"
iptables -t mangle -A POSTROUTING -p tcp --tcp-flags SYN,RST SYN -o "$SNAT_INTER" -j TCPMSS --set-mss 1300
#system
echo "1" > /proc/sys/net/ipv4/ip_forward
}
function help()
{
echo " "
echo "Usage: build_upf [OPTION]..."
echo "--start Start UPF"
echo "--close Close UPF"
}
function install_depence(){
cp $base/plugin/yq $current > /dev/null 2>&1
cp $base/plugin/replace/replace $current > /dev/null 2>&1
}
function unbind(){
python3 $current/dpdk-devbind.py -u 0000:$DPDK_EXPORT_PCI ;
python3 $current/dpdk-devbind.py -u 0000:$DPDK_EXPORT_PCI;
python3 $current/dpdk-devbind.py -b $DRIVE $DPDK_EXPORT_PCI
sleep 1
python3 $current/dpdk-devbind.py -b $DRIVE $DPDK_EXPORT_PCI
sleep 1
ifconfig $DPDK_EXPORT down;
sleep 1
ifconfig $DPDK_ENTRY down;
sleep 1
}
function main() {
install_depence
if [ $# -eq 0 ];
then
help
exit
fi
until [ -z "$1" ]; do
case "$1" in
-o)
init_configure $2
start_vpp
start_n4
start_arp
shift
;;
--close)
close_vpp
close_n4
close_arp
# unbind
shift
;;
esac
done
return 0
}
main "$@"
File added
...@@ -53,12 +53,12 @@ config: dpdk-config rdma-core-config ...@@ -53,12 +53,12 @@ config: dpdk-config rdma-core-config
############################################################################## ##############################################################################
# .deb packaging # .deb packaging
############################################################################## ##############################################################################
PKG_VERSION=20.05 #PKG_VERSION=20.05
PKG_SUFFIX=8 #PKG_SUFFIX=8
DEB_VER := $(PKG_VERSION) DEB_VER := $(PKG_VERSION)
DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null) DEB_ARCH=$(shell dpkg --print-architecture 2> /dev/null)
DEB_ARCH=amd64 #DEB_ARCH=amd64
DEV_DEB=vpp-ext-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb DEV_DEB=vpp-ext-deps_$(DEB_VER)-$(PKG_SUFFIX)_$(DEB_ARCH).deb
INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-ext-deps 2> /dev/null) INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-ext-deps 2> /dev/null)
......
#!/bin/bash #!/bin/bash
tar -zxvf git_bak.tar.gz
mv ./git_bak/.git ./
apt install epel-release apt install epel-release
apt install cmake3 apt install cmake3
apt install ninja-build apt install ninja-build
......
...@@ -30,8 +30,8 @@ execute_process( ...@@ -30,8 +30,8 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE OUTPUT_STRIP_TRAILING_WHITESPACE
) )
string(CONCAT VPP_VERSION "v20.05-rc0~582-g1339dce8f") #string(CONCAT VPP_VERSION "v20.05-rc0~582-g1339dce8f")
string(CONCAT VPP_LIB_VERSION "20.05") #string(CONCAT VPP_LIB_VERSION "20.05")
string(REPLACE "-" ";" VPP_LIB_VERSION ${VPP_VERSION}) string(REPLACE "-" ";" VPP_LIB_VERSION ${VPP_VERSION})
list(GET VPP_LIB_VERSION 0 VPP_LIB_VERSION) list(GET VPP_LIB_VERSION 0 VPP_LIB_VERSION)
......
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