...
 
Commits (185)
......@@ -8,3 +8,14 @@ netns-bin/netns_run
netlab/bird6/bird*
netlab/bird4/bird*
netlab-int/cf-ospf/__pycache__
netlab-int/tests/__pycache__
netlab-int/.NOTES.md
# Virtual enviroments
env/
.env
requirements.txt
netlab/runtest_local
......@@ -266,14 +266,14 @@ EOF
cat <<EOF >> rc/rc-loc-at$T
cd /tmp/bird
\$AUTOCONF
#./configure
./configure --enable-debug
./configure --sysconfdir=/etc --with-runtimedir=/run
#./configure --enable-debug
#sed -e 's/-g -O2/-g3 -O0/' -i obj/Rules
\$MAKE
\$MAKE install
PATH=\$PATH:/usr/local/sbin
ulimit -c unlimited
bird -d -c /etc/bird.conf &
bird
EOF
done
......
......@@ -120,6 +120,28 @@ protocol ospf {
}
EOF
cf dL-4 -- cat <<EOF
protocol bgp {
local 192.168.225.162 as 65123;
neighbor 192.168.192.1 as 65534;
import all;
export none;
table bt;
igp table master;
}
EOF
cf dL-6 -- cat <<EOF
protocol bgp {
local 2001:1488:a001::225:162 as 65123;
neighbor 2001:1488:a001::1 as 65534;
import all;
export none;
table bt;
igp table master;
}
EOF
for T in {dL,dR}; do
cf $T-4 -- cat <<EOF
template bgp bc {
......@@ -133,7 +155,6 @@ template bgp bc {
EOF
cf $T-6 -- cat <<EOF
table bt;
template bgp bc {
local ${IPA[$T-6]} as 65123;
import all;
......@@ -152,22 +173,12 @@ for M in ${MACH[@]}; do
cf $D-4 -- cat <<EOF
protocol bgp from bc {
neighbor ${IPA[$M-4]} as 65123;
import all;
export all;
table bt;
igp table master;
next hop self;
}
EOF
cf $D-6 -- cat <<EOF
protocol bgp from bc {
neighbor ${IPA[$M-6]} as 65123;
import all;
export all;
table bt;
igp table master;
next hop self;
}
EOF
......@@ -225,25 +236,25 @@ EOF
cat <<'EOF' >> rc/rc-loc-at$T
cd /tmp/bird4
$AUTOCONF
./configure --with-suffix=4
./configure --sysconfdir=/etc --with-runtimedir=/run --with-suffix=4
#./configure --enable-debug
#sed -e 's/-g -O2/-g3 -O0/' -i obj/Rules
$MAKE
$MAKE install
PATH=$PATH:/usr/local/sbin
ulimit -c unlimited
bird4 -c /etc/bird4.conf
bird4
cd /tmp/bird6
$AUTOCONF
./configure --enable-ipv6 --with-suffix=6
./configure --sysconfdir=/etc --with-runtimedir=/run --enable-ipv6 --with-suffix=6
#./configure --enable-debug
#sed -e 's/-g -O2/-g3 -O0/' -i obj/Rules
$MAKE
$MAKE install
PATH=$PATH:/usr/local/sbin
ulimit -c unlimited
bird6 -c /etc/bird6.conf
bird6
EOF
done
......
NETLAB_NODES="m1 m2 m3 m4"
netlab_init
if_dummy m1 ve0 192.168.1 2001:db8:01:1
if_dummy m2 ve0 192.168.2 2001:db8:02:1
if_dummy m3 ve0 192.168.3 2001:db8:03:1
if_dummy m4 ve0 192.168.4 2001:db8:04:1
if_veth m1 ve1 m2 ve2 192.168.11 2001:db8:11:1
if_veth m2 ve1 m3 ve2 192.168.12 2001:db8:12:1
if_veth m3 ve1 m4 ve2 192.168.13 2001:db8:13:1
if_veth m4 ve1 m1 ve2 192.168.14 2001:db8:14:1
netlab_start
NETLAB_NODES="m1 m2 m3 m4"
netlab_init
if_dummy m1 ve0 192.168.1 2001:db8:01:1
if_dummy m2 ve0 192.168.2 2001:db8:02:1
if_dummy m3 ve0 192.168.3 2001:db8:03:1
if_dummy m4 ve0 192.168.4 2001:db8:04:1
if_veth m1 ve1 m2 ve2 192.168.11
if_veth m2 ve1 m3 ve2 192.168.12
if_veth m3 ve1 m4 ve2 192.168.13
if_veth m4 ve1 m1 ve2 192.168.14
netlab_start
NETLAB_NODES="m1 m2 m3 m4"
netlab_init
if_dummy m1 ve0 192.168.1 2001:db8:01:1
if_dummy m2 ve0 192.168.2 2001:db8:02:1
if_dummy m3 ve0 192.168.3 2001:db8:03:1
if_dummy m4 ve0 192.168.4 2001:db8:04:1
if_veth m1 ve1 m2 ve2 192.168.11
if_veth m2 ve1 m3 ve2 192.168.12
if_veth m3 ve1 m4 ve2 192.168.13
if_veth m4 ve1 m1 ve2 192.168.14
netlab_start
NETLAB_NODES="m1 m2 m3 m4"
netlab_init
vrf m1 vrf1 100
vrf m1 vrf2 200
vrf m1 vrf3 300
vrf m2 vrf0 100
vrf m3 vrf0 100
vrf m4 vrf0 100
if_dummy m1/vrf1 vd1 10.1.1 2001:db8:1:1
if_dummy m1/vrf2 vd2 10.1.1 2001:db8:1:1
if_dummy m1/vrf3 vd3 10.1.1 2001:db8:1:1
if_dummy m2/vrf0 ve0 10.5.1.2/24 2001:db8:5:1::2/64
if_dummy m3/vrf0 ve0 10.5.1.3/24 2001:db8:5:1::3/64
if_dummy m4/vrf0 ve0 10.5.1.4/24 2001:db8:5:1::4/64
if_veth m1/vrf1 ve1 m2/vrf0 ve1 10.0.1 2001:db8:0:1
if_veth m1/vrf2 ve2 m3/vrf0 ve1 10.0.2 2001:db8:0:2
if_veth m1/vrf3 ve3 m4/vrf0 ve1 10.0.3 2001:db8:0:3
netlab_start
BIRD binaries should be copied here:
bird
birdc
if [ -f $COMMON/bird ]
then
ln -s $COMMON/bird bird
ln -s $COMMON/birdc birdc
ln -s $CONFIG/bird_$1.conf bird.conf
fi
sysctl net.ipv4.ip_forward=1
sysctl net.ipv4.tcp_l3mdev_accept=1
sysctl net.ipv6.conf.all.forwarding=1
if [ -f /proc/sys/net/mpls/platform_labels ]
then
sysctl net.mpls.platform_labels=1024
fi
ulimit -c unlimited
./bird -l
#./bird -c bird.conf -s bird.ctl
if [ -S bird.ctl ]
then ./birdc -l down
fi
NETLAB_NODES="m1 m2 m3 m4"
netlab_init
if_dummy $m1 ve0 10.1.1 2001:db8:1:1
if_dummy $m2 ve0 10.2.1 2001:db8:2:1
if_dummy $m3 ve0 10.3.1 2001:db8:3:1
if_dummy $m4 ve0 10.4.1 2001:db8:4:1
if_veth $m1 ve1 $m2 ve2 10.0.1 2001:db8:0:1
if_veth $m2 ve1 $m3 ve2 10.0.2 2001:db8:0:2
if_veth $m3 ve1 $m4 ve2 10.0.3 2001:db8:0:3
if_veth $m4 ve1 $m1 ve2 10.0.4 2001:db8:0:4
# sleep 2
netlab_start
NETLAB_NODES="m1 m2 m3 m4"
netlab_init
if_dummy $m1 ve0 10.1.1 2001:db8:1:1
if_dummy $m2 ve0 10.2.1 2001:db8:2:1
if_dummy $m3 ve0 10.3.1 2001:db8:3:1
if_dummy $m4 ve0 10.4.1 2001:db8:4:1
if_veth $m1 ve1 $m2 ve2 10.0.1
if_veth $m2 ve1 $m3 ve2 10.0.2
if_veth $m3 ve1 $m4 ve2 10.0.3
if_veth $m4 ve1 $m1 ve2 10.0.4
# sleep 2
netlab_start
NETLAB_NODES="m1 m2 m3 m4"
netlab_init
if_dummy $m1 ve0 10.1.1 2001:db8:1:1
if_dummy $m2 ve0 10.2.1 2001:db8:2:1
if_dummy $m3 ve0 10.3.1 2001:db8:3:1
if_dummy $m4 ve0 10.4.1 2001:db8:4:1
if_veth $m1 ve1 $m2 ve2 10.0.1
if_veth $m2 ve1 $m3 ve2 10.0.2
if_veth $m3 ve1 $m4 ve2 10.0.3
if_veth $m4 ve1 $m1 ve2 10.0.4
# sleep 2
netlab_start
NETLAB_NODES="m1 m2 m3 m4 m5"
netlab_init
vrf $m1 vrf1 100
vrf $m1 vrf2 200
if_dummy $m1/vrf1 vd1 10.1.1 2001:db8:1:1
if_dummy $m1/vrf2 vd2 10.1.1 2001:db8:1:1
if_dummy $m2 ve0 10.2.1.1/24 2001:db8:2:1::1/64
if_dummy $m3 ve0 10.3.1.1/24 2001:db8:3:1::1/64
if_dummy $m4 ve0 10.2.1.2/24 2001:db8:2:1::2/64
if_dummy $m5 ve0 10.3.1.2/24 2001:db8:3:1::2/64
if_veth $m1/vrf1 ve1 $m2 ve2 10.0.1 2001:db8:0:1
if_veth $m2 ve1 $m3 ve2 10.0.2 2001:db8:0:2
if_veth $m3 ve1 $m1/vrf1 ve2 10.0.3 2001:db8:0:3
if_veth $m1/vrf2 ve3 $m4 ve2 10.0.1 2001:db8:0:1
if_veth $m4 ve1 $m5 ve2 10.0.2 2001:db8:0:2
if_veth $m5 ve1 $m1/vrf2 ve4 10.0.3 2001:db8:0:3
# sleep 2
netlab_start
BIRD binaries should be copied here, with 4/6 suffix:
bird4
bird6
birdc4
birdc6
if [ -f $COMMON/bird4 ]
then
ln -s $COMMON/bird4 bird4
ln -s $COMMON/birdc4 birdc4
ln -s $CONFIG/bird4_$1.conf bird4.conf
fi
if [ -f $COMMON/bird6 ]
then
ln -s $COMMON/bird6 bird6
ln -s $COMMON/birdc6 birdc6
ln -s $CONFIG/bird6_$1.conf bird6.conf
fi
sysctl net.ipv4.ip_forward=1
sysctl net.ipv4.tcp_l3mdev_accept=1
sysctl net.ipv6.conf.all.forwarding=1
ulimit -c unlimited
./bird4 -l -c bird4.conf
./bird6 -l
# valgrind --log-file=valgrind4.log --leak-check=full --tool=memcheck --time-stamp=yes --leak-resolution=high --num-callers=40 ./bird4 -l -d -c bird4.conf &
# valgrind --log-file=valgrind6.log --leak-check=full --tool=memcheck --time-stamp=yes --leak-resolution=high --num-callers=40 ./bird6 -l -d -d &
# valgrind --track-origins=yes --log-file=valgrind4.log --leak-check=full --tool=memcheck --time-stamp=yes --leak-resolution=high --num-callers=40 ./bird4 -l -d -c bird4.conf &
# valgrind --track-origins=yes --log-file=valgrind6.log --leak-check=full --tool=memcheck --time-stamp=yes --leak-resolution=high --num-callers=40 ./bird6 -l -d &
if [ -S bird4.ctl -o -S bird.ctl ]
then ./birdc4 -l down
fi
if [ -S bird6.ctl ]
then ./birdc6 -l down
fi
......@@ -7,14 +7,17 @@ export CONFIG="../config"
function netlab_init_node()
{
N=$1
ip netns add $N
echo Preparing $N
mkdir $N
touch $N/netns
netns_new sleep 30d &
PID=$!
eval $N=$PID
echo $PID > $N.pid
sleep .1
ip netns exec $N ip -4 rule add l3mdev priority 1000
ip netns exec $N ip -6 rule add l3mdev priority 1000
netns_run $PID ip -4 rule add l3mdev priority 1000
netns_run $PID ip -6 rule add l3mdev priority 1000
}
......@@ -31,16 +34,18 @@ function netlab_init()
function netlab_start_node()
{
N=$1
echo Starting $N
PID=${!N}
echo Starting $N
mkdir $N
cd $N
if [ -f $CONFIG/$N.start ]
then ip netns exec $N bash $CONFIG/$N.start $N
then netns_run $PID bash $CONFIG/$N.start $N
fi
if [ -f $COMMON/common.start ]
then ip netns exec $N bash $COMMON/common.start $N
then netns_run $PID bash $COMMON/common.start $N
fi
cd ..
......@@ -50,23 +55,26 @@ function netlab_start_node()
function netlab_stop_node()
{
N=$1
PID=$2
echo Stopping $N
cd $N
if [ -f $COMMON/common.stop ]
then ip netns exec $N bash $COMMON/common.stop $N
then netns_run $PID bash $COMMON/common.stop $N
fi
if [ -f $CONFIG/$N.stop ]
then ip netns exec $N bash $CONFIG/$N.stop $N
then netns_run $PID bash $CONFIG/$N.stop $N
fi
cd ..
rm -rf $N
echo
}
kill $PID
rm $N.pid
}
function netlab_start()
{
......@@ -77,36 +85,34 @@ function netlab_start()
function netlab_stop()
{
for N in */netns
do
netlab_stop_node ${N%/netns}
ip netns del ${N%/netns}
for N in *.pid
do netlab_stop_node ${N%.pid} $(cat $N)
done
}
function if_dummy()
{
NS=${1%%/*}
IF=$2