Commit 54339cbc authored by 吴洲洋's avatar 吴洲洋

add build and run script

parent 07fb5a3d
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 @gtpu_export_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.20
gtpu_export_ip: 172.16.30.10
gnb_gtpu_ip: 192.168.10.100
ip_link:
ueip: 192.169.0.0
ueIPPrefix: 24
snatInter: ens32
snatIP: 192.168.2.239
vppHost: ens40
gtpu_entry: ens38
gtpu_export: ens39
cpu: 3f
n4:
smf: 192.168.199.18
upf: 192.168.2.239
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 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
clear_all
make pkg-deb-debug
make_package debug
echo "build vpp success"
echo "unpack buptvpp.tar.gz start..."
sudo tar -zxvf $VPPINSTALL/buptvppe.tar.gz -C $VPPINSTALL > /dev/null 2>&1;
echo "unpack buptvpp.tar.gz finished!!!"
sleep 1;
#install
echo "install buptvppe start..."
sudo dpkg -i $VPPINSTALL/build-root/*.deb
sudo systemctl disable vpp;
sudo systemctl stop vpp
#rm install package
sudo rm -rf $VPPINSTALL
clear_all
sleep 1;
echo "install buptvppe finished!!!"
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 install_golang() {
rm -rf /tmp/go1.15.6.linux-amd64.tar.*
wget -P /tmp https://studygolang.com/dl/golang/go1.15.6.linux-amd64.tar.gz
rm -rf $base/go
mkdir -p $base/go
tar xvf /tmp/go1.15.6.linux-amd64.tar.gz -C /usr/local
sed -i -e '/GOROOT/d' ~/.bashrc
sed -i -e '/GOBIN/d' ~/.bashrc
sed -i -e '/GOPATH/d' ~/.bashrc
sed -i -e '/GO111MODULE/d' ~/.bashrc
sed -i -e '/GOPROXY/d' ~/.bashrc
echo "export GOROOT=\"/usr/local/go\"" >> ~/.bashrc
echo "export GOBIN=\"/usr/local/go/bin\"" >> ~/.bashrc
echo "export GOPATH=\"$base/go\"" >> ~/.bashrc
echo "export PATH=\$PATH:\$GOBIN" >> ~/.bashrc
echo "export GO111MODULE=on" >> ~/.bashrc
echo "export GOPROXY=https://goproxy.cn" >> ~/.bashrc
source ~/.bashrc
}
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 "--install_golang Configure golang's compilation environment"
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
;;
--install_golang)
install_golang
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 /etc/vpp/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=""
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 /opt/5gc/config_system.sh /opt/5gc
cp /opt/5gc/startup_debug.conf /etc/vpp
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)
rm -rf $current/yq
}
function start_vpp() {
cmd="$VPPCMD"
install_dpdk_kmod
run_nat
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 "$@"
......@@ -53,12 +53,12 @@ config: dpdk-config rdma-core-config
##############################################################################
# .deb packaging
##############################################################################
PKG_VERSION=20.05
PKG_SUFFIX=8
#PKG_VERSION=20.05
#PKG_SUFFIX=8
DEB_VER := $(PKG_VERSION)
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
INSTALLED_VER=$(shell dpkg-query --showformat='$${Version}' --show vpp-ext-deps 2> /dev/null)
......
#!/bin/bash
tar -zxvf git_bak.tar.gz
mv ./git_bak/.git ./
apt install epel-release
apt install cmake3
apt install ninja-build
......
......@@ -30,8 +30,8 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE
)
string(CONCAT VPP_VERSION "v20.05-rc0~582-g1339dce8f")
string(CONCAT VPP_LIB_VERSION "20.05")
#string(CONCAT VPP_VERSION "v20.05-rc0~582-g1339dce8f")
#string(CONCAT VPP_LIB_VERSION "20.05")
string(REPLACE "-" ";" VPP_LIB_VERSION ${VPP_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