Commit f4fdfe95 authored by Lionel Gauthier's avatar Lionel Gauthier

Updates for openvswitch

git-svn-id: http://svn.eurecom.fr/openair4G/trunk@5015 818b1a75-f10b-46b9-bf7c-635c3b92a50f
parent 483cefbf
...@@ -32,7 +32,6 @@ declare UE_IPv4="10.0.0.8" ...@@ -32,7 +32,6 @@ declare UE_IPv4="10.0.0.8"
declare UE_IPv6="2001:1::8" declare UE_IPv6="2001:1::8"
declare UE_IPv6_CIDR=$UE_IPv6"/64" declare UE_IPv6_CIDR=$UE_IPv6"/64"
declare UE_IPv4_CIDR=$UE_IPv4"/24" declare UE_IPv4_CIDR=$UE_IPv4"/24"
declare BRIDGE="vswitch"
########################################################### ###########################################################
...@@ -116,6 +115,24 @@ ITTI_LOG_FILE=/tmp/itti_enb.$HOSTNAME.log ...@@ -116,6 +115,24 @@ ITTI_LOG_FILE=/tmp/itti_enb.$HOSTNAME.log
rotate_log_file $ITTI_LOG_FILE rotate_log_file $ITTI_LOG_FILE
gdb --args $OPENAIR_TARGETS/SIMU/USER/oaisim -a -u1 -l7 -K $ITTI_LOG_FILE --config-file $THIS_SCRIPT_PATH/CONF/enb.host.$HOSTNAME.conf #######################################################
# FIND CONFIG FILE
#######################################################
CONFIG_FILE=$THIS_SCRIPT_PATH/CONF/all.sfr.default_vswitch.conf
SEARCHED_CONFIG_FILE=$THIS_SCRIPT_PATH/CONF/all.sfr."$HOSTNAME"_vswitch.conf
if [ -f $SEARCHED_CONFIG_FILE ]; then
CONFIG_FILE=$SEARCHED_CONFIG_FILE
echo_warning "config file found is now $CONFIG_FILE"
else
echo_warning "config file $SEARCHED_CONFIG_FILE for host $HOSTNAME not found, trying default: $CONFIG_FILE"
if [ -f $CONFIG_FILE ]; then
echo_success "Default config file found: $CONFIG_FILE"
else
echo_error "Default config file not found, exiting"
exit 1
fi
fi
gdb --args $OPENAIR_TARGETS/SIMU/USER/oaisim -a -u1 -l7 -K $ITTI_LOG_FILE --enb-conf $CONFIG_FILE
...@@ -71,7 +71,6 @@ if [ ! -f /lib/modules/`uname -r`/extra/openvswitch.ko ]; then ...@@ -71,7 +71,6 @@ if [ ! -f /lib/modules/`uname -r`/extra/openvswitch.ko ]; then
$OPENAIRCN_DIR/SCRIPTS/install_openvswitch1.9.0.bash $OPENAIRCN_DIR/SCRIPTS/install_openvswitch1.9.0.bash
fi fi
IPTABLES=`which iptables`
################################## ##################################
# Get or set OBJ DIR and compile # # Get or set OBJ DIR and compile #
...@@ -115,55 +114,106 @@ cd $OPENAIRCN_DIR ...@@ -115,55 +114,106 @@ cd $OPENAIRCN_DIR
####################################################### #######################################################
# SOURCE $OPENAIRCN_DIR/UTILS/CONF/epc_$HOSTNAME.conf # FIND CONFIG FILE
####################################################### #######################################################
rm -f /tmp/source.txt CONFIG_FILE=$THIS_SCRIPT_PATH/CONF/epc.sfr.default.vswitch.conf
if [ -f $OPENAIRCN_DIR/UTILS/CONF/epc_$HOSTNAME.conf ] SEARCHED_CONFIG_FILE=$THIS_SCRIPT_PATH/CONF/epc.sfr."$HOSTNAME".vswitch.conf
then if [ -f $SEARCHED_CONFIG_FILE ]; then
cat $OPENAIRCN_DIR/UTILS/CONF/epc_$HOSTNAME.conf | tr -d " " > /tmp/source.txt CONFIG_FILE=$SEARCHED_CONFIG_FILE
source /tmp/source.txt echo_warning "config file found is now $CONFIG_FILE"
else else
echo_error "Missing config file $OPENAIRCN_DIR/UTILS/CONF/epc_$HOSTNAME.conf (Please write your own config file), exiting" echo_warning "config file $SEARCHED_CONFIG_FILE for host $HOSTNAME not found, trying default: $CONFIG_FILE"
exit 1 if [ -f $CONFIG_FILE ]; then
echo_success "Default config file found: $CONFIG_FILE"
else
echo_error "Default config file not found, exiting"
exit 1
fi
fi fi
####################################################### CONFIG_FILE_ENB=$THIS_SCRIPT_PATH/CONF/enb.sfr.default.vswitch.conf
# SOURCE $OPENAIRCN_DIR/UTILS/CONF/enb_$HOSTNAME.conf SEARCHED_CONFIG_FILE_ENB=$THIS_SCRIPT_PATH/CONF/enb.sfr."$HOSTNAME".vswitch.conf
####################################################### if [ -f $SEARCHED_CONFIG_FILE_ENB ]; then
rm -f /tmp/source.txt CONFIG_FILE_ENB=$SEARCHED_CONFIG_FILE_ENB
if [ -f $OPENAIRCN_DIR/UTILS/CONF/enb_$HOSTNAME.conf ] echo_warning "config file eNB found is now $CONFIG_FILE_ENB"
then
cat $OPENAIRCN_DIR/UTILS/CONF/enb_$HOSTNAME.conf | tr -d " " > /tmp/source.txt
source /tmp/source.txt
else else
echo_error "Missing config file $OPENAIRCN_DIR/UTILS/CONF/enb_$HOSTNAME.conf (Please write your own config file), exiting" echo_warning "config file eNB $SEARCHED_CONFIG_FILE_ENB for host $HOSTNAME not found, trying default: $CONFIG_FILE_ENB"
exit 1 if [ -f $CONFIG_FILE_ENB ]; then
echo_success "Default config file eNB found: $CONFIG_FILE_ENB"
else
echo_error "Default config file eNB not found, exiting"
exit 1
fi
fi fi
clean_epc_network
build_epc_network
test_epc_network #######################################################
# SOURCE CONFIG FILE
#######################################################
rm -f /tmp/source.txt
VARIABLES="
ENB_INTERFACE_NAME_FOR_S1_MME\|\
ENB_IPV4_ADDRESS_FOR_S1_MME\|\
ENB_INTERFACE_NAME_FOR_S1U\|\
ENB_IPV4_ADDRESS_FOR_S1U\|\
ENB_BRIDGE\|\
MME_INTERFACE_NAME_FOR_S1_MME\|\
MME_IPV4_ADDRESS_FOR_S1_MME\|\
MME_INTERFACE_NAME_FOR_S11_MME\|\
MME_IPV4_ADDRESS_FOR_S11_MME\|\
MME_BRIDGE\|\
SGW_INTERFACE_NAME_FOR_S11\|\
SGW_IPV4_ADDRESS_FOR_S11\|\
SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP\|\
SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP\|\
SGW_INTERFACE_NAME_FOR_S5_S8_UP\|\
SGW_IPV4_ADDRESS_FOR_S5_S8_UP\|\
SGW_BRIDGE\|\
PGW_INTERFACE_NAME_FOR_S5_S8\|\
PGW_IPV4_ADDRESS_FOR_S5_S8\|\
PGW_INTERFACE_NAME_FOR_SGI\|\
PGW_IPV4_ADDR_FOR_SGI"
VARIABLES=$(echo $VARIABLES | sed -e 's/\\r//g')
VARIABLES=$(echo $VARIABLES | tr -d ' ')
cat $CONFIG_FILE | grep -w "$VARIABLES"| tr -d " " | tr -d ";" > /tmp/source.txt
cat $CONFIG_FILE_ENB | grep -w "$VARIABLES"| tr -d " " | tr -d ";" >> /tmp/source.txt
source /tmp/source.txt
declare ENB_IPV4_NETMASK_FOR_S1_MME=$( echo $ENB_IPV4_ADDRESS_FOR_S1_MME | cut -f2 -d '/')
declare ENB_IPV4_NETMASK_FOR_S1U=$( echo $ENB_IPV4_ADDRESS_FOR_S1U | cut -f2 -d '/')
declare MME_IPV4_NETMASK_FOR_S1_MME=$( echo $MME_IPV4_ADDRESS_FOR_S1_MME | cut -f2 -d '/')
declare MME_IPV4_NETMASK_FOR_S11_MME=$( echo $MME_IPV4_ADDRESS_FOR_S11_MME | cut -f2 -d '/')
declare SGW_IPV4_NETMASK_FOR_S11=$( echo $SGW_IPV4_ADDRESS_FOR_S11 | cut -f2 -d '/')
declare SGW_IPV4_NETMASK_FOR_S1U_S12_S4_UP=$(echo $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP | cut -f2 -d '/')
declare SGW_IPV4_NETMASK_FOR_S5_S8_UP=$( echo $SGW_IPV4_ADDRESS_FOR_S5_S8_UP | cut -f2 -d '/')
declare PGW_IPV4_NETMASK_FOR_S5_S8=$( echo $PGW_IPV4_ADDRESS_FOR_S5_S8 | cut -f2 -d '/')
declare PGW_IPV4_NETMASK_FOR_SGI=$( echo $PGW_IPV4_ADDR_FOR_SGI | cut -f2 -d '/')
ENB_IPV4_ADDRESS_FOR_S1_MME=$( echo $ENB_IPV4_ADDRESS_FOR_S1_MME | cut -f1 -d '/')
ENB_IPV4_ADDRESS_FOR_S1U=$( echo $ENB_IPV4_ADDRESS_FOR_S1U | cut -f1 -d '/')
MME_IPV4_ADDRESS_FOR_S1_MME=$( echo $MME_IPV4_ADDRESS_FOR_S1_MME | cut -f1 -d '/')
MME_IPV4_ADDRESS_FOR_S11_MME=$( echo $MME_IPV4_ADDRESS_FOR_S11_MME | cut -f1 -d '/')
SGW_IPV4_ADDRESS_FOR_S11=$( echo $SGW_IPV4_ADDRESS_FOR_S11 | cut -f1 -d '/')
SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP=$( echo $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP | cut -f1 -d '/')
SGW_IPV4_ADDRESS_FOR_S5_S8_UP=$( echo $SGW_IPV4_ADDRESS_FOR_S5_S8_UP | cut -f1 -d '/')
PGW_IPV4_ADDRESS_FOR_S5_S8=$( echo $PGW_IPV4_ADDRESS_FOR_S5_S8 | cut -f1 -d '/')
PGW_IPV4_ADDR_FOR_SGI=$( echo $PGW_IPV4_ADDR_FOR_SGI | cut -f1 -d '/')
clean_epc_ovs_network
exit
build_epc_ovs_network
test_epc_ovs_network
##################################################.. ##################################################..
# LAUNCH MME + S+P-GW executable # LAUNCH MME + S+P-GW executable
################################################## ##################################################
MME_CONFIG_FILE=$OPENAIRCN_DIR/UTILS/CONF/mme_default.conf
if [ -f $OPENAIRCN_DIR/UTILS/CONF/mme_$HOSTNAME.conf ]; then
MME_CONFIG_FILE=$OPENAIRCN_DIR/UTILS/CONF/mme_$HOSTNAME.conf
echo_warning "MME config file found is now $MME_CONFIG_FILE"
else
echo_warning "MME config file for host $HOSTNAME not found, trying default: $MME_CONFIG_FILE"
if [ -f $MME_CONFIG_FILE ]; then
echo_success "Default MME config file found: $MME_CONFIG_FILE"
else
echo_error "Default MME config file not found, exiting"
exit 1
fi
fi
cd $OPENAIRCN_DIR/$OBJ_DIR cd $OPENAIRCN_DIR/$OBJ_DIR
ITTI_LOG_FILE=/tmp/itti_mme.log ITTI_LOG_FILE=/tmp/itti_mme.log
rotate_log_file $ITTI_LOG_FILE rotate_log_file $ITTI_LOG_FILE
$OPENAIRCN_DIR/$OBJ_DIR/OAI_EPC/oai_epc -K $ITTI_LOG_FILE -c $MME_CONFIG_FILE gdb --args $OPENAIRCN_DIR/$OBJ_DIR/OAI_EPC/oai_epc -K $ITTI_LOG_FILE -c $CONFIG_FILE
...@@ -32,6 +32,7 @@ ROOT_UID=0 ...@@ -32,6 +32,7 @@ ROOT_UID=0
E_NOTROOT=67 E_NOTROOT=67
HOSTNAME=$(hostname -f) HOSTNAME=$(hostname -f)
IPTABLES=`which iptables`
trim () trim ()
{ {
...@@ -68,6 +69,17 @@ echo_error() { ...@@ -68,6 +69,17 @@ echo_error() {
cecho "$my_string" $red cecho "$my_string" $red
} }
echo_fatal() {
local my_string=""
until [ -z "$1" ]
do
my_string="$my_string$1"
shift
done
echo_error "$my_string"
exit -1
}
echo_warning() { echo_warning() {
local my_string="" local my_string=""
until [ -z "$1" ] until [ -z "$1" ]
...@@ -207,9 +219,8 @@ assert() { ...@@ -207,9 +219,8 @@ assert() {
lineno=$2 lineno=$2
if [ ! $1 ] if [ ! $1 ]
then then
echo "Assertion failed: \"$1\"" echo_error "Assertion failed: \"$1\""
echo "File \"$0\", line $lineno" echo_fatal "File \"$0\", line $lineno"
exit $E_ASSERT_FAILED
fi fi
} }
...@@ -219,8 +230,7 @@ test_command_install_lib() { ...@@ -219,8 +230,7 @@ test_command_install_lib() {
echo_warning "$2 seems to be not installed, trying..." echo_warning "$2 seems to be not installed, trying..."
apt-get install $2 -y apt-get install $2 -y
if [ ! -f $1 ]; then if [ ! -f $1 ]; then
echo_error "$1 unavailable" echo_fatal "$1 unavailable"
exit 1
fi fi
fi fi
echo_success "$1 available" echo_success "$1 available"
...@@ -230,13 +240,12 @@ test_command_install_lib() { ...@@ -230,13 +240,12 @@ test_command_install_lib() {
test_command_install_package() { test_command_install_package() {
# usage: test_command_install_package searched_binary package_to_be_installed_if_binary_not_found optional_option_to_apt_get_install # usage: test_command_install_package searched_binary package_to_be_installed_if_binary_not_found optional_option_to_apt_get_install
if [ $# -eq 2 ]; then if [ $# -eq 2 ]; then
command -v $1 >/dev/null 2>&1 || { echo_warning "Program $1 is not installed. Trying installing it." >&2; apt-get install $2 -y; command -v $1 >/dev/null 2>&1 || { echo_error "Program $1 is not installed. Aborting." >&2; exit 1; };} command -v $1 >/dev/null 2>&1 || { echo_warning "Program $1 is not installed. Trying installing it." >&2; apt-get install $2 -y; command -v $1 >/dev/null 2>&1 || { echo_fatal "Program $1 is not installed. Aborting." >&2;};}
else else
if [ $# -eq 3 ]; then if [ $# -eq 3 ]; then
command -v $1 >/dev/null 2>&1 || { echo_warning "Program $1 is not installed. Trying installing it (apt-get install $3 $2)." >&2; apt-get install $3 $2 -y; command -v $1 >/dev/null 2>&1 || { echo_error "Program $1 is not installed. Aborting." >&2; exit 1; };} command -v $1 >/dev/null 2>&1 || { echo_warning "Program $1 is not installed. Trying installing it (apt-get install $3 $2)." >&2; apt-get install $3 $2 -y; command -v $1 >/dev/null 2>&1 || { echo_fatal "Program $1 is not installed. Aborting." >&2; };}
else else
echo_success "test_command_install_package: BAD PARAMETER" echo_fatal "test_command_install_package: BAD PARAMETER"
exit 1
fi fi
fi fi
echo_success "$1 available" echo_success "$1 available"
...@@ -244,7 +253,7 @@ test_command_install_package() { ...@@ -244,7 +253,7 @@ test_command_install_package() {
test_command_install_script() { test_command_install_script() {
# usage: test_command_install_script searched_binary script_to_be_invoked_if_binary_not_found # usage: test_command_install_script searched_binary script_to_be_invoked_if_binary_not_found
command -v $1 >/dev/null 2>&1 || { echo_warning "Program $1 is not installed. Trying installing it." >&2; bash $2; command -v $1 >/dev/null 2>&1 || { echo_error "Program $1 is not installed. Aborting." >&2; exit 1; };} command -v $1 >/dev/null 2>&1 || { echo_warning "Program $1 is not installed. Trying installing it." >&2; bash $2; command -v $1 >/dev/null 2>&1 || { echo_fatal "Program $1 is not installed. Aborting." >&2; };}
echo_success "$1 available" echo_success "$1 available"
} }
...@@ -253,8 +262,7 @@ start_openswitch_daemon() { ...@@ -253,8 +262,7 @@ start_openswitch_daemon() {
if [[ -e "/lib/modules/`uname -r`/extra/openvswitch.ko" ]] ; then if [[ -e "/lib/modules/`uname -r`/extra/openvswitch.ko" ]] ; then
bash_exec "insmod /lib/modules/`uname -r`/extra/openvswitch.ko" > /dev/null 2>&1 bash_exec "insmod /lib/modules/`uname -r`/extra/openvswitch.ko" > /dev/null 2>&1
else else
echo_error "/lib/modules/`uname -r`/extra/openvswitch.ko not found, exiting" echo_fatal "/lib/modules/`uname -r`/extra/openvswitch.ko not found, exiting"
exit -1
fi fi
is_process_started "ovsdb-server" is_process_started "ovsdb-server"
if [ $? -ne 0 ] if [ $? -ne 0 ]
...@@ -285,71 +293,341 @@ stop_openswitch_daemon() { ...@@ -285,71 +293,341 @@ stop_openswitch_daemon() {
rmmod -f openvswitch rmmod -f openvswitch
} }
check_epc_config() {
if [ ! -f $OPENAIR3_DIR/OPENAIRMME/UTILS/CONF/epc_$HOSTNAME.conf ]
then
echo "Cannot find file $OPENAIR3_DIR/OPENAIRMME/UTILS/CONF/epc_$HOSTNAME.conf"
echo "Please make sure to create one that fits your use (you can use mme_default.conf file as template)"
exit -1
fi
}
check_enb_config() {
if [ ! -f $OPENAIR3_DIR/OPENAIRMME/UTILS/CONF/enb_$HOSTNAME.conf ]
then
echo "Cannot find file $OPENAIR3_DIR/OPENAIRMME/UTILS/CONF/enb_$HOSTNAME.conf"
echo "Please make sure to create one that fits your use (you can use mme_default.conf file as template)"
exit -1
fi
}
check_for_epc_executable() { check_for_epc_executable() {
if [ ! -f $OPENAIR3_DIR/OPENAIRMME/objs/OAI_EPC/oai_epc ] if [ ! -f $OPENAIR3_DIR/OPENAIRMME/objs/OAI_EPC/oai_epc ]
then then
echo "Cannot find oai_epc executable object in directory $OPENAIR3_DIR/OPENAIRMME/objs/OAI_EPC/" echo_error "Cannot find oai_epc executable object in directory $OPENAIR3_DIR/OPENAIRMME/objs/OAI_EPC/"
echo "Please make sure you have compiled OAI EPC with --enable-standalone-epc option" echo_fatal "Please make sure you have compiled OAI EPC with --enable-standalone-epc option"
exit -1
fi fi
} }
check_for_sgw_executable() { check_for_sgw_executable() {
if [ ! -f $OPENAIR3_DIR/OPENAIRMME/objs/OAI_SGW/oai_sgw ] if [ ! -f $OPENAIR3_DIR/OPENAIRMME/objs/OAI_SGW/oai_sgw ]
then then
echo "Cannot find oai_sgw executable object in directory $OPENAIR3_DIR/OPENAIRMME/objs/OAI_SGW/" echo_error "Cannot find oai_sgw executable object in directory $OPENAIR3_DIR/OPENAIRMME/objs/OAI_SGW/"
echo "Please make sure you have compiled OAI EPC without --enable-standalone-epc option" echo_fatal "Please make sure you have compiled OAI EPC without --enable-standalone-epc option"
exit -1
fi fi
} }
check_for_mme_executable() { check_for_mme_executable() {
if [ ! -f $OPENAIR3_DIR/OPENAIRMME/objs/OAISIM_MME/oaisim_mme ] if [ ! -f $OPENAIR3_DIR/OPENAIRMME/objs/OAISIM_MME/oaisim_mme ]
then then
echo "Cannot find oai_sgw executable object in directory $OPENAIR3_DIR/OPENAIRMME/objs/OAISIM_MME/" echo_error "Cannot find oai_sgw executable object in directory $OPENAIR3_DIR/OPENAIRMME/objs/OAISIM_MME/"
echo "Please make sure you have compiled OAI EPC without --enable-standalone-epc option" echo_fatal "Please make sure you have compiled OAI EPC without --enable-standalone-epc option"
exit -1
fi fi
} }
check_for_root_rights() { check_for_root_rights() {
if [[ $EUID -ne 0 ]]; then if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root" 1>&2 echo_fatal "This script must be run as root" 1>&2
exit -1
fi fi
} }
clean_openvswitch_network(){ is_openvswitch_interface() {
################################################## echo $1
# del bridge between eNB and MME/SPGW if [[ a${1:0:2} == aeth ]]; then
################################################## return 0;
bash_exec "tunctl -d $ENB_INTERFACE_NAME_FOR_S1_MME" else
bash_exec "tunctl -d $ENB_INTERFACE_NAME_FOR_S1U" if [[ a${1:0:3} == awlan ]]; then
bash_exec "tunctl -d $MME_INTERFACE_NAME_FOR_S1_MME" return 0;
bash_exec "tunctl -d $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP" else
bash_exec "tunctl -d $MME_INTERFACE_NAME_FOR_S11_MME" if [[ a${1:0:3} == awifi ]]; then
bash_exec "tunctl -d $SGW_INTERFACE_NAME_FOR_S11" return 0;
bash_exec "ovs-vsctl del-br $BRIDGE" fi
fi
fi
return 1;
}
stop_openswitch_daemon is_real_interface() {
IF=`cat /etc/udev/rules.d/70-persistent-net.rules | grep $1 | sed 's/^.*NAME=//' | tr -d '"'`
if [[ $IF == $1 ]]; then
if [[ a${1:0:2} == aeth ]]; then
return 1;
else
if [[ a${1:0:3} == awlan ]]; then
return 1;
else
if [[ a${1:0:3} == awifi ]]; then
return 1;
fi
fi
fi
fi
return 0
}
delete_openvswitch_interface() {
is_openvswitch_interface $1
if [ $? -eq 1 ]; then
ifconfig $1 down > /dev/null 2>&1
tunctl -d $1 > /dev/null 2>&1
fi
}
create_openvswitch_interface() {
is_openvswitch_interface $1
if [ $? -eq 1 ]; then
bash_exec "tunctl -t $1"
fi
}
build_enb_vlan_network() {
# create vlan interface
if [ is_real_interface $ENB_INTERFACE_NAME_FOR_S1_MME ]; then
vconfig rem "$ENB_INTERFACE_NAME_FOR_S1_MME".1 > /dev/null 2>&1
sync
bash_exec "vconfig add ENB_INTERFACE_NAME_FOR_S1_MME 1"
sync
bash_exec "ip -4 addr add $ENB_IPV4_ADDRESS_FOR_S1_MME dev $ENB_INTERFACE_NAME_FOR_S1_MME.1"
else
echo_fatal "BAD INTERFACE NAME FOR ENB S1-MME "$ENB_INTERFACE_NAME_FOR_S1_MME" (waiting for ethx)"
fi;
if [ is_real_interface $ENB_INTERFACE_NAME_FOR_S1U ]; then
vconfig rem $ENB_INTERFACE_NAME_FOR_S1U.2 > /dev/null 2>&1
sync
bash_exec "vconfig add ENB_INTERFACE_NAME_FOR_S1U 2"
sync
bash_exec "ip -4 addr add $ENB_IPV4_ADDRESS_FOR_S1U dev $ENB_INTERFACE_NAME_FOR_S1U.2"
sync
else
echo_fatal "BAD INTERFACE NAME FOR ENB S1U "$ENB_INTERFACE_NAME_FOR_S1U" (waiting for ethx)"
fi;
}
clean_enb_vlan_network() {
# create vlan interface
if [ is_real_interface $ENB_INTERFACE_NAME_FOR_S1_MME ]; then
vconfig rem "$ENB_INTERFACE_NAME_FOR_S1_MME".1 > /dev/null 2>&1
fi;
if [ is_real_interface $ENB_INTERFACE_NAME_FOR_S1U ]; then
vconfig rem $ENB_INTERFACE_NAME_FOR_S1U.2 > /dev/null 2>&1
fi;
sync;
}
test_enb_vlan_network() {
# TEST INTERFACES
ping -q -c 1 $MME_IPV4_ADDRESS_FOR_S1_MME > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING MME S1_MME ERROR, ADDRESS IS $MME_IPV4_ADDRESS_FOR_S1_MME"; fi;
ping -q -c 1 $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING SGW S1U ERROR, ADDRESS IS $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP"; fi;
return 0
}
build_mme_spgw_vlan_network() {
# hss.eur
# |
# +-----------+ +-----------+ v +----------+
# | eNB +------+ VLAN 1+------+ MME +----+ +---+ HSS |
# | |ethx.1+------------------+ethy.1| | +------+ | |
# | +------+ +------+ +----+ +---+ |
# | |ethx.2+-------+ | | +----------+
# | +------+ | +-+-------+-+
# | | | | s11mme|
# | | | +---+---+
# | | | (optional)| VLAN 3
# +-----------+ | +---+---+
# | | s11sgw| router.eur
# | +-+-------+-+ | +--------------+
# | | S+P-GW | v | ROUTER |
# | VLAN2 +------+ +-------+ +----+ +----+
# +----------+ethy.2| |sgi +-...-+ | | +---...Internet
# +------+ +-------+ +----+ +----+
# | | 11 VLANS | |
# +-----------+ ids=[5..15] +--------------+
cat $OPENAIRCN_DIR/$OBJ_DIR/Makefile | grep CFLAGS\ \=\ | grep DENABLE_USE_NETFILTER_FOR_SGI
if [ $? -ne 0 ]
then
export ENABLE_USE_NETFILTER_FOR_SGI=0
else
export ENABLE_USE_NETFILTER_FOR_SGI=1
fi
cat $OPENAIRCN_DIR/$OBJ_DIR/Makefile | grep CFLAGS\ \=\ | grep DENABLE_USE_RAW_FOR_SGI
if [ $? -ne 0 ]
then
export ENABLE_USE_RAW_FOR_SGI=0
else
export ENABLE_USE_RAW_FOR_SGI=1
fi
bash_exec "modprobe 8021q"
# create vlan interface
if [ is_real_interface $MME_INTERFACE_NAME_FOR_S1_MME ]; then
bash_exec "vconfig rem $MME_INTERFACE_NAME_FOR_S1_MME.1" > /dev/null 2>&1
sync
bash_exec "vconfig add MME_INTERFACE_NAME_FOR_S1_MME 1"
sync
bash_exec "ip -4 addr add $MME_IPV4_ADDRESS_FOR_S1_MME dev $MME_INTERFACE_NAME_FOR_S1_MME.1"
else
echo_fatal "BAD INTERFACE NAME FOR SGW S1-MME "$MME_INTERFACE_NAME_FOR_S1_MME" (waiting for ethx)"
fi;
if [ is_real_interface $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP ]; then
vconfig rem $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP.2 > /dev/null 2>&1
sync
bash_exec "vconfig add SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP 2"
sync
bash_exec "ip -4 addr add $MME_IPV4_ADDRESS_FOR_S1_MME dev $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP.2"
sync
else
echo_fatal "BAD INTERFACE NAME FOR SGW S1U "$SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP" (waiting for ethx)"
fi;
ping -c 1 router.eur > /dev/null || { echo_fatal "router.eur does not respond to ping" >&2 ; }
IP_ROUTER=`python -c 'import socket; print socket.gethostbyname("router.eur")'`
export MAC_ROUTER=`ip neigh show | grep $IP_ROUTER | cut -d ' ' -f5 | tr -d ':'`
echo_success "ROUTER MAC ADDRESS= $MAC_ROUTER"
if [ $ENABLE_USE_NETFILTER_FOR_SGI -eq 1 ]; then
bash_exec "modprobe nf_conntrack"
bash_exec "modprobe nf_conntrack_ftp"
######################################################
# PREROUTING
######################################################
# We restore the mark following the CONNMARK mark. In fact, it does a simple MARK=CONNMARK
# where MARK is the standard mark (usable by tc)
# In French: Cette option de cible restaure le paquet marqué dans la marque de connexion
# comme défini par CONNMARK. Un masque peut aussi être défini par l'option --mask.
# Si une option mask est placée, seules les options masquées seront placées.
# Notez que cette option de cible n'est valide que dans la table mangle.
bash_exec "$IPTABLES -t mangle -A PREROUTING -j CONNMARK --restore-mark"
# TEST bash_exec "$IPTABLES -t mangle -A PREROUTING -m mark --mark 0 -i $PGW_INTERFACE_NAME_FOR_SGI -j MARK --set-mark 15"
# We set the mark of the initial packet as value of the conntrack mark for all the packets of the connection.
# This mark will be restore for the other packets by the first rule of POSTROUTING --restore-mark).
bash_exec "$IPTABLES -t mangle -A PREROUTING -j CONNMARK --save-mark"
######################################################
# POSTROUTING
######################################################
# MARK=CONNMARK
bash_exec "iptables -A POSTROUTING -t mangle -o tap0 -j CONNMARK --restore-mark"
# If we’ve got a mark no need to get further[
bash_exec "iptables -A POSTROUTING -t mangle -o tap0 -m mark ! --mark 0 -j ACCEPT"
#bash_exec "iptables -A POSTROUTING -p tcp --dport 21 -t mangle -j MARK --set-mark 1"
#bash_exec "iptables -A POSTROUTING -p tcp --dport 80 -t mangle -j MARK --set-mark 2"
# We set the mark of the initial packet as value of the conntrack mark for all the packets
# of the connection. This mark will be restore for the other packets by the first rule
# of POSTROUTING (–restore-mark).
bash_exec "iptables -A POSTROUTING -t mangle -j CONNMARK --save-mark"
bash_exec "iptables -A PREROUTING -t mangle -j CONNMARK --restore-mark"
# We restore the mark following the CONNMARK mark.
# In fact, it does a simple MARK=CONNMARK where MARK is the standard mark (usable by tc)
#bash_exec "$IPTABLES -A OUTPUT -t mangle -m mark ! --mark 0 -j CONNMARK --restore-mark"
# If we’ve got a mark no need to get further[1]
#TEST bash_exec "$IPTABLES -A OUTPUT -t mangle -p icmp -j MARK --set-mark 14"
#bash_exec "$IPTABLES -A OUTPUT -t mangle -m mark ! --mark 0 -j ACCEPT"
# We set the mark of the initial packet as value of the conntrack mark for all the packets of the connection.
# This mark will be restore for the other packets by the first rule of OUTPUT (–restore-mark).
#bash_exec "$IPTABLES -A OUTPUT -t mangle -j CONNMARK --save-mark"
######################################################
# NETFILTER QUEUE
######################################################
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 5 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 6 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 7 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 8 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 9 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 10 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 11 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 12 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 13 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 14 -j NFQUEUE --queue-num 1"
bash_exec "$IPTABLES -t mangle -A PREROUTING -i $PGW_INTERFACE_NAME_FOR_SGI -m connmark --mark 15 -j NFQUEUE --queue-num 1"
#echo 0 > /proc/sys/net/bridge/bridge-nf-call-iptables #To disable Iptables in the bridge.
#Raw table: Some years ago appeared a new tables in Iptables.
#This table can be used to avoid packets (connection really) to enter the NAT table:
# iptables -t raw -I PREROUTING -i BRIDGE -s x.x.x.x -j NOTRACK.
#bash_exec "$IPTABLES -t nat -A POSTROUTING -o $PGW_INTERFACE_NAME_FOR_SGI -j SNAT --to-source $PGW_IP_ADDR_FOR_SGI"
else
# # get ipv4 address from PGW_INTERFACE_NAME_FOR_SGI
#IP_ADDR=`ifconfig $PGW_INTERFACE_NAME_FOR_SGI | awk '/inet addr/ {split ($2,A,":"); print A[2]}' | tr '\n' ' ' | sed -n '1h;1!H;${;g;s/^[ \t]*//g;s/[ \t]*$//g;p;}'`
#NETWORK=`echo $IP_ADDR | cut -d . -f 1,2,3`
bash_exec "modprobe 8021q"
for i in 5 6 7 8 9 10 11 12 13 14 15
do
# create vlan interface
vconfig rem $PGW_INTERFACE_NAME_FOR_SGI.$i > /dev/null 2>&1
sync
bash_exec "vconfig add $PGW_INTERFACE_NAME_FOR_SGI $i"
sync
# configure vlan interface
#CIDR=$NETWORK'.'$i'/24'
base=200
NET=$(( $i + $base ))
CIDR='10.0.'$NET'.2/8'
bash_exec "ip -4 addr add $CIDR dev $PGW_INTERFACE_NAME_FOR_SGI.$i"
done
fi
bash_exec "ip link set $PGW_INTERFACE_NAME_FOR_SGI promisc on"
}
clean_epc_vlan_network() {
bash_exec "modprobe tun"
bash_exec "modprobe ip_tables"
bash_exec "modprobe iptable_nat"
bash_exec "modprobe x_tables"
bash_exec "$IPTABLES -P INPUT ACCEPT"
bash_exec "$IPTABLES -F INPUT"
bash_exec "$IPTABLES -P OUTPUT ACCEPT"
bash_exec "$IPTABLES -F OUTPUT"
bash_exec "$IPTABLES -P FORWARD ACCEPT"
bash_exec "$IPTABLES -F FORWARD"
bash_exec "$IPTABLES -t raw -F"
bash_exec "$IPTABLES -t nat -F"
bash_exec "$IPTABLES -t mangle -F"
bash_exec "$IPTABLES -t filter -F"
bash_exec "ip route flush cache"
echo " Disabling forwarding"
bash_exec "sysctl -w net.ipv4.ip_forward=0"
assert " `sysctl -n net.ipv4.ip_forward` -eq 0" $LINENO
echo " Enabling DynamicAddr.."
bash_exec "sysctl -w net.ipv4.ip_dynaddr=1"
assert " `sysctl -n net.ipv4.ip_dynaddr` -eq 1" $LINENO
bash_exec "sysctl -w net.ipv4.conf.all.log_martians=1"
assert " `sysctl -n net.ipv4.conf.all.log_martians` -eq 1" $LINENO
echo " Disabling reverse path filtering"
bash_exec "sysctl -w net.ipv4.conf.all.rp_filter=0"
assert " `sysctl -n net.ipv4.conf.all.rp_filter` -eq 0" $LINENO
bash_exec "modprobe 8021q"
ip link set $PGW_INTERFACE_NAME_FOR_SGI off > /dev/null 2>&1
for i in 5 6 7 8 9 10 11 12 13 14 15
do
# delete vlan interface
vconfig rem $PGW_INTERFACE_NAME_FOR_SGI.$i > /dev/null 2>&1
done
} }
build_openvswitch_network() { build_openvswitch_network() {
...@@ -365,7 +643,7 @@ build_openvswitch_network() { ...@@ -365,7 +643,7 @@ build_openvswitch_network() {
# | +------+ | | | +-+-------+-+ # | +------+ | | | +-+-------+-+
# | | | | +----------------| s11mme|---+ # | | | | +----------------| s11mme|---+
# | | | | +---+---+ | # | | | | +---+---+ |
# | | | | (optional)| | # | | | | (optional)| |ovs bridge is optional
# +-----------+ | | +---+---+ | # +-----------+ | | +---+---+ |
# +---|------------------ | s11sgw|---+ router.eur # +---|------------------ | s11sgw|---+ router.eur
# | +-+-------+-+ | +--------------+ # | +-+-------+-+ | +--------------+
...@@ -379,13 +657,13 @@ build_openvswitch_network() { ...@@ -379,13 +657,13 @@ build_openvswitch_network() {
################################################## ##################################################
# build bridge between eNB and MME/SPGW # build bridge between eNB and MME/SPGW
################################################## ##################################################
bash_exec "tunctl -t $ENB_INTERFACE_NAME_FOR_S1_MME" create_openvswitch_interface $ENB_INTERFACE_NAME_FOR_S1_MME
bash_exec "tunctl -t $ENB_INTERFACE_NAME_FOR_S1U" create_openvswitch_interface $ENB_INTERFACE_NAME_FOR_S1U
bash_exec "tunctl -t $MME_INTERFACE_NAME_FOR_S1_MME" create_openvswitch_interface $MME_INTERFACE_NAME_FOR_S1_MME
bash_exec "tunctl -t $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP" create_openvswitch_interface $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP
bash_exec "tunctl -t $MME_INTERFACE_NAME_FOR_S11_MME" create_openvswitch_interface $MME_INTERFACE_NAME_FOR_S11_MME
bash_exec "tunctl -t $SGW_INTERFACE_NAME_FOR_S11" create_openvswitch_interface $SGW_INTERFACE_NAME_FOR_S11
bash_exec "ovs-vsctl add-br $BRIDGE" bash_exec "ovs-vsctl add-br $BRIDGE"
bash_exec "ovs-vsctl add-port $BRIDGE $ENB_INTERFACE_NAME_FOR_S1_MME tag=1" bash_exec "ovs-vsctl add-port $BRIDGE $ENB_INTERFACE_NAME_FOR_S1_MME tag=1"
bash_exec "ovs-vsctl add-port $BRIDGE $MME_INTERFACE_NAME_FOR_S1_MME tag=1" bash_exec "ovs-vsctl add-port $BRIDGE $MME_INTERFACE_NAME_FOR_S1_MME tag=1"
...@@ -395,53 +673,65 @@ build_openvswitch_network() { ...@@ -395,53 +673,65 @@ build_openvswitch_network() {
bash_exec "ovs-vsctl add-port $BRIDGE $SGW_INTERFACE_NAME_FOR_S11 tag=3" bash_exec "ovs-vsctl add-port $BRIDGE $SGW_INTERFACE_NAME_FOR_S11 tag=3"
bash_exec "ifconfig $MME_INTERFACE_NAME_FOR_S1_MME promisc up" bash_exec "ifconfig $MME_INTERFACE_NAME_FOR_S1_MME promisc up"
bash_exec "ifconfig $MME_INTERFACE_NAME_FOR_S1_MME $MME_IP_ADDRESS_FOR_S1_MME netmask `cidr2mask $MME_IP_NETMASK_FOR_S1_MME` promisc up" bash_exec "ifconfig $MME_INTERFACE_NAME_FOR_S1_MME $MME_IPV4_ADDRESS_FOR_S1_MME netmask `cidr2mask $MME_IPV4_NETMASK_FOR_S1_MME` promisc up"
bash_exec "ifconfig $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP promisc up" bash_exec "ifconfig $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP promisc up"
bash_exec "ifconfig $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP $SGW_IP_ADDRESS_FOR_S1U_S12_S4_UP netmask `cidr2mask $SGW_IP_NETMASK_FOR_S1U_S12_S4_UP` promisc up" bash_exec "ifconfig $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP netmask `cidr2mask $SGW_IPV4_NETMASK_FOR_S1U_S12_S4_UP` promisc up"
bash_exec "ifconfig $ENB_INTERFACE_NAME_FOR_S1_MME promisc up" bash_exec "ifconfig $ENB_INTERFACE_NAME_FOR_S1_MME promisc up"
bash_exec "ifconfig $ENB_INTERFACE_NAME_FOR_S1_MME $ENB_IP_ADDRESS_FOR_S1_MME netmask `cidr2mask $ENB_IP_NETMASK_FOR_S1_MME` promisc up" bash_exec "ifconfig $ENB_INTERFACE_NAME_FOR_S1_MME $ENB_IPV4_ADDRESS_FOR_S1_MME netmask `cidr2mask $ENB_IPV4_NETMASK_FOR_S1_MME` promisc up"
bash_exec "ifconfig $ENB_INTERFACE_NAME_FOR_S1U promisc up" bash_exec "ifconfig $ENB_INTERFACE_NAME_FOR_S1U promisc up"
bash_exec "ifconfig $ENB_INTERFACE_NAME_FOR_S1U $ENB_IP_ADDRESS_FOR_S1U netmask `cidr2mask $ENB_IP_NETMASK_FOR_S1U` promisc up" bash_exec "ifconfig $ENB_INTERFACE_NAME_FOR_S1U $ENB_IPV4_ADDRESS_FOR_S1U netmask `cidr2mask $ENB_IPV4_NETMASK_FOR_S1U` promisc up"
bash_exec "ifconfig $MME_INTERFACE_NAME_FOR_S11_MME promisc up" bash_exec "ifconfig $MME_INTERFACE_NAME_FOR_S11_MME promisc up"
bash_exec "ifconfig $MME_INTERFACE_NAME_FOR_S11_MME $MME_IP_ADDRESS_FOR_S11_MME netmask `cidr2mask $MME_IP_NETMASK_FOR_S11_MME` promisc up" bash_exec "ifconfig $MME_INTERFACE_NAME_FOR_S11_MME $MME_IPV4_ADDRESS_FOR_S11_MME netmask `cidr2mask $MME_IPV4_NETMASK_FOR_S11_MME` promisc up"
bash_exec "ifconfig $ENB_INTERFACE_NAME_FOR_S1U promisc up" bash_exec "ifconfig $SGW_INTERFACE_NAME_FOR_S11 promisc up"
bash_exec "ifconfig $SGW_INTERFACE_NAME_FOR_S11 $SGW_IP_ADDRESS_FOR_S11 netmask `cidr2mask $SGW_IP_NETMASK_FOR_S11` promisc up" bash_exec "ifconfig $SGW_INTERFACE_NAME_FOR_S11 $SGW_IPV4_ADDRESS_FOR_S11 netmask `cidr2mask $SGW_IPV4_NETMASK_FOR_S11` promisc up"
} }
test_openvswitch_network() { test_openvswitch_network() {
# TEST INTERFACES
ping -q -c 1 $MME_IPV4_ADDRESS_FOR_S1_MME > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $MME_INTERFACE_NAME_FOR_S1_MME ERROR, ADDRESS IS $MME_IPV4_ADDRESS_FOR_S1_MME"; fi;
ping -q -c 1 $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP ERROR, ADDRESS IS $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP"; fi;
ping -q -c 1 $ENB_IPV4_ADDRESS_FOR_S1_MME > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $ENB_INTERFACE_NAME_FOR_S1_MME ADDR ERROR, ADDRESS IS $ENB_IPV4_ADDRESS_FOR_S1_MME"; fi;
ping -q -c 1 $ENB_IPV4_ADDRESS_FOR_S1U > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $ENB_INTERFACE_NAME_FOR_S1U ERROR, ADDRESS IS $ENB_IPV4_ADDRESS_FOR_S1U"; fi;
ping -q -c 1 $MME_IPV4_ADDRESS_FOR_S11_MME > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $MME_INTERFACE_NAME_FOR_S11_MME ERROR, ADDRESS IS $MME_IPV4_ADDRESS_FOR_S11_MME"; fi;
ping -q -c 1 $SGW_IPV4_ADDRESS_FOR_S11 > /dev/null 2>&1
if [ $? -ne 0 ]; then echo_fatal "PING INTERFACE $SGW_INTERFACE_NAME_FOR_S11 ERROR, ADDRESS IS $SGW_IPV4_ADDRESS_FOR_S11"; fi;
## TEST NETWORK BETWEEN ENB-MME-SP-GW ## TEST NETWORK BETWEEN ENB-MME-SP-GW
iperf --bind $MME_IP_ADDRESS_FOR_S1_MME -u -s 2>&1 > /dev/null & iperf --bind $MME_IPV4_ADDRESS_FOR_S1_MME -u -s 2>&1 > /dev/null &
iperf --bind $ENB_IP_ADDRESS_FOR_S1_MME -u --num 1K -c $MME_IP_ADDRESS_FOR_S1_MME 2>&1 | grep -i WARNING > /dev/null iperf --bind $ENB_IPV4_ADDRESS_FOR_S1_MME -u --num 1K -c $MME_IPV4_ADDRESS_FOR_S1_MME 2>&1 | grep -i WARNING > /dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo_error "NETWORK ERROR CONFIGURATION (openvswitch) between ENB and MME S1"
pkill iperf 2>&1 > /dev/null pkill iperf 2>&1 > /dev/null
exit 1 echo_fatal "NETWORK ERROR CONFIGURATION (openvswitch) between ENB and MME S1"
else else
echo_success "NETWORK TEST SUCCESS (openvswitch) between ENB and MME S1" echo_success "NETWORK TEST SUCCESS (openvswitch) between ENB and MME S1"
fi fi
pkill iperf 2>&1 > /dev/null pkill iperf 2>&1 > /dev/null
iperf --bind $SGW_IP_ADDRESS_FOR_S1U_S12_S4_UP -u -s 2>&1 > /dev/null & iperf --bind $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP -u -s 2>&1 > /dev/null &
iperf --bind $ENB_IP_ADDRESS_FOR_S1U -u --num 1K -c $SGW_IP_ADDRESS_FOR_S1U_S12_S4_UP 2>&1 | grep -i WARNING > /dev/null iperf --bind $ENB_IPV4_ADDRESS_FOR_S1U -u --num 1K -c $SGW_IPV4_ADDRESS_FOR_S1U_S12_S4_UP 2>&1 | grep -i WARNING > /dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo_error "NETWORK ERROR CONFIGURATION (openvswitch) between ENB and S-GW S1-U"
pkill iperf 2>&1 > /dev/null pkill iperf 2>&1 > /dev/null
exit 1 echo_fatal "NETWORK ERROR CONFIGURATION (openvswitch) between ENB and S-GW S1-U"
else else
echo_success "NETWORK TEST SUCCESS (openvswitch) between ENB and S-GW S1-U" echo_success "NETWORK TEST SUCCESS (openvswitch) between ENB and S-GW S1-U"
fi fi
pkill iperf 2>&1 > /dev/null pkill iperf 2>&1 > /dev/null
iperf --bind $SGW_IP_ADDRESS_FOR_S11 -u -s 2>&1 > /dev/null & iperf --bind $SGW_IPV4_ADDRESS_FOR_S11 -u -s 2>&1 > /dev/null &
iperf --bind $MME_IP_ADDRESS_FOR_S11_MME -u --num 1K -c $SGW_IP_ADDRESS_FOR_S11 2>&1 | grep -i WARNING > /dev/null iperf --bind $MME_IPV4_ADDRESS_FOR_S11_MME -u --num 1K -c $SGW_IPV4_ADDRESS_FOR_S11 2>&1 | grep -i WARNING > /dev/null
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
echo_error "NETWORK ERROR CONFIGURATION (openvswitch) between MME and S-GW S11"
pkill iperf 2>&1 > /dev/null pkill iperf 2>&1 > /dev/null
exit 1 echo_fatal "NETWORK ERROR CONFIGURATION (openvswitch) between MME and S-GW S11"
else else
echo_success "NETWORK TEST SUCCESS (openvswitch) between MME and S-GW S11" echo_success "NETWORK TEST SUCCESS (openvswitch) between MME and S-GW S11"
fi fi
...@@ -449,7 +739,23 @@ test_openvswitch_network() { ...@@ -449,7 +739,23 @@ test_openvswitch_network() {
return 0 return 0
} }
build_epc_network() { clean_openvswitch_network() {
##################################################
# del bridge between eNB and MME/SPGW
##################################################
delete_openvswitch_interface $ENB_INTERFACE_NAME_FOR_S1_MME
delete_openvswitch_interface $ENB_INTERFACE_NAME_FOR_S1U
delete_openvswitch_interface $MME_INTERFACE_NAME_FOR_S1_MME
delete_openvswitch_interface $SGW_INTERFACE_NAME_FOR_S1U_S12_S4_UP
delete_openvswitch_interface $MME_INTERFACE_NAME_FOR_S11_MME
delete_openvswitch_interface $SGW_INTERFACE_NAME_FOR_S11
if is_process_started ovs-vswitchd ; then
ovs-vsctl del-br $BRIDGE > /dev/null 2>&1
fi
stop_openswitch_daemon
}
build_epc_ovs_network() {
cat $OPENAIRCN_DIR/$OBJ_DIR/Makefile | grep CFLAGS\ \=\ | grep DENABLE_USE_NETFILTER_FOR_SGI cat $OPENAIRCN_DIR/$OBJ_DIR/Makefile | grep CFLAGS\ \=\ | grep DENABLE_USE_NETFILTER_FOR_SGI
if [ $? -ne 0 ] if [ $? -ne 0 ]
...@@ -469,7 +775,7 @@ build_epc_network() { ...@@ -469,7 +775,7 @@ build_epc_network() {
build_openvswitch_network build_openvswitch_network
ping -c 1 router.eur > /dev/null || { echo "router.eur does not respond to ping" >&2 ; exit ; } ping -c 1 router.eur > /dev/null || { echo_fatal "router.eur does not respond to ping" >&2 ; }
IP_ROUTER=`python -c 'import socket; print socket.gethostbyname("router.eur")'` IP_ROUTER=`python -c 'import socket; print socket.gethostbyname("router.eur")'`
export MAC_ROUTER=`ip neigh show | grep $IP_ROUTER | cut -d ' ' -f5 | tr -d ':'` export MAC_ROUTER=`ip neigh show | grep $IP_ROUTER | cut -d ' ' -f5 | tr -d ':'`
echo_success "ROUTER MAC ADDRESS= $MAC_ROUTER" echo_success "ROUTER MAC ADDRESS= $MAC_ROUTER"
...@@ -566,7 +872,7 @@ build_epc_network() { ...@@ -566,7 +872,7 @@ build_epc_network() {
for i in 5 6 7 8 9 10 11 12 13 14 15 for i in 5 6 7 8 9 10 11 12 13 14 15
do do
# create vlan interface # create vlan interface
bash_exec "vconfig rem $PGW_INTERFACE_NAME_FOR_SGI.$i" > /dev/null 2>&1 vconfig rem $PGW_INTERFACE_NAME_FOR_SGI.$i > /dev/null 2>&1
sync sync
bash_exec "vconfig add $PGW_INTERFACE_NAME_FOR_SGI $i" bash_exec "vconfig add $PGW_INTERFACE_NAME_FOR_SGI $i"
sync sync
...@@ -602,14 +908,14 @@ build_epc_network() { ...@@ -602,14 +908,14 @@ build_epc_network() {
# done # done
} }
test_epc_network() { test_epc_ovs_network() {
# Get MAC address of router.eur # Get MAC address of router.eur
ping -c 1 hss.eur > /dev/null || { echo "hss.eur does not respond to ping" >&2 ; exit ; } ping -c 1 hss.eur > /dev/null || { echo_fatal "hss.eur does not respond to ping" >&2 ; }
ping -c 1 router.eur > /dev/null || { echo "router.eur does not respond to ping" >&2 ; exit ; } ping -c 1 router.eur > /dev/null || { echo_fatal "router.eur does not respond to ping" >&2 ; }
test_openvswitch_network test_openvswitch_network
} }
clean_epc_network() { clean_epc_ovs_network() {
bash_exec "modprobe tun" bash_exec "modprobe tun"
bash_exec "modprobe ip_tables" bash_exec "modprobe ip_tables"
bash_exec "modprobe iptable_nat" bash_exec "modprobe iptable_nat"
...@@ -643,6 +949,14 @@ clean_epc_network() { ...@@ -643,6 +949,14 @@ clean_epc_network() {
echo " Disabling reverse path filtering" echo " Disabling reverse path filtering"
bash_exec "sysctl -w net.ipv4.conf.all.rp_filter=0" bash_exec "sysctl -w net.ipv4.conf.all.rp_filter=0"
assert " `sysctl -n net.ipv4.conf.all.rp_filter` -eq 0" $LINENO assert " `sysctl -n net.ipv4.conf.all.rp_filter` -eq 0" $LINENO
for i in 5 6 7 8 9 10 11 12 13 14 15
do
bash_exec "ifconfig $PGW_INTERFACE_NAME_FOR_SGI.$i down" > /dev/null 2>&1
bash_exec "vconfig rem $PGW_INTERFACE_NAME_FOR_SGI.$i" > /dev/null 2>&1
done
clean_openvswitch_network clean_openvswitch_network
} }
......
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