diff options
-rw-r--r-- | vpp-userdemo/Vagrantfile | 3 | ||||
-rw-r--r-- | vpp-userdemo/bridging | 12 | ||||
-rwxr-xr-x | vpp-userdemo/install.sh | 48 | ||||
-rwxr-xr-x | vpp-userdemo/netns.sh | 97 | ||||
-rw-r--r-- | vpp-userdemo/routing | 12 | ||||
-rw-r--r-- | vpp-userdemo/tracing | 4 |
6 files changed, 124 insertions, 52 deletions
diff --git a/vpp-userdemo/Vagrantfile b/vpp-userdemo/Vagrantfile index 32560ef..1af1681 100644 --- a/vpp-userdemo/Vagrantfile +++ b/vpp-userdemo/Vagrantfile @@ -35,6 +35,9 @@ Vagrant.configure(2) do |config| vb.customize ["modifyvm", :id, "--ioapic", "on"] vb.memory = "#{vmram}" vb.cpus = "#{vmcpu}" + + vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.1", "1"] + vb.customize ["setextradata", :id, "VBoxInternal/CPUM/SSE4.2", "1"] end config.vm.provider "vmware_fusion" do |fusion,override| fusion.vmx["memsize"] = "#{vmram}" diff --git a/vpp-userdemo/bridging b/vpp-userdemo/bridging index 1d3c458..83e305a 100644 --- a/vpp-userdemo/bridging +++ b/vpp-userdemo/bridging @@ -21,17 +21,17 @@ C2_GW="172.16.1.1" INSTR=() CMD=() INSTR+=("Welcome to the bridging demo. This will show you some simple commands to connect two -linux netnamespaces to VPP via an L2 bridge.") +linux containers to VPP via an L2 bridge.") CMD+=("") INSTR+=("To show interfaces type:") CMD+=("sudo vppctl show inter") -INSTR+=("Lets examine our workloads c1 and c2") -CMD+=("sudo ip netns exec c1 ip -o a") +INSTR+=("Lets examine our workloads cone and ctwo") +CMD+=("sudo lxc-attach -n cone -- ip -o a") INSTR+=("") -CMD+=("sudo ip netns exec c2 ip -o a") +CMD+=("sudo lxc-attach -n ctwo -- ip -o a") INSTR+=("To add interfaces, we add the host-side of the veth link pair.") CMD+=("ip link") @@ -49,10 +49,10 @@ INSTR+=("You can also see the bridge-domain") CMD+=("sudo vppctl show bridge-domain 1 detail") INSTR+=("At long last you probably want to see some pings") -CMD+=("sudo ip netns exec c1 ping -c3 172.16.1.3") +CMD+=("sudo lxc-attach -n cone -- ping -c3 172.16.1.3") INSTR+=("") -CMD+=("sudo ip netns exec c2 ping -c3 172.16.1.2") +CMD+=("sudo lxc-attach -n ctwo -- ping -c3 172.16.1.2") INSTR+=("Thanks for doing the bridging demo. To restart this demo and type these commands yourself \nvagrant ssh \nsudo /vagrant/netns.sh \ncat /vagrant/bridging.cmd") CMD+=("") diff --git a/vpp-userdemo/install.sh b/vpp-userdemo/install.sh index f9b1422..c02a622 100755 --- a/vpp-userdemo/install.sh +++ b/vpp-userdemo/install.sh @@ -22,5 +22,51 @@ fi echo "deb https://nexus.fd.io/content/repositories/fd.io.master.ubuntu.trusty.main/ ./" | sudo tee -a /etc/apt/sources.list.d/99fd.io.list apt-get -qq update -apt-get -qq install -y --force-yes vpp vpp-dpdk-dkms bridge-utils +apt-get -qq install -y --force-yes vpp vpp-dpdk-dkms bridge-utils lxc service vpp start + +#Configure LXC network to create an inteface for Linux bridge and a unconsumed second inteface +echo -e "lxc.network.name=veth0\nlxc.network.type = veth\nlxc.network.name = veth_link1" | sudo tee -a /etc/lxc/default.conf + +lxc-checkconfig + +containers=( cone ctwo ) + +for i in "${containers[@]}" +do + sudo lxc-create -t download -n $i -- --dist ubuntu --release trusty --arch amd64 +done + +for i in "${containers[@]}" +do + sudo lxc-start -n $i -d +done + +function lxc_exec() { + + cntr="$1" + rCMD="$2" + + CMD="sudo lxc-attach -n $cntr -- $rCMD" + + echo "$CMD" + eval "${CMD}" +} + +for i in "${containers[@]}" +do + lxc_exec $i "resolvconf -d eth0" + lxc_exec $i "dhclient" + + lxc_exec $i "sh -c 'echo \"deb https://nexus.fd.io/content/repositories/fd.io.master.ubuntu.trusty.main/ ./\" >> /etc/apt/sources.list.d/99fd.io.list'" + lxc_exec $i "apt-get -qq install -y wget" + lxc_exec $i "apt-get -qq update" + lxc_exec $i "apt-get -qq install -y --force-yes vpp" + lxc_exec $i "sh -c 'echo \"\\ndpdk {\\n no-pci\\n}\" >> /etc/vpp/startup.conf'" + lxc_exec $i "service vpp start" +done + +for i in "${containers[@]}" +do + sudo lxc-stop -n $i +done diff --git a/vpp-userdemo/netns.sh b/vpp-userdemo/netns.sh index 05a6605..75d94be 100755 --- a/vpp-userdemo/netns.sh +++ b/vpp-userdemo/netns.sh @@ -19,44 +19,67 @@ if [ $USER != "root" ] ; then exit fi -C1_IP=$1 -C1_GW=$2 -C2_IP=$3 -C2_GW=$4 +cone_IP=$1 +cone_GW=$2 +ctwo_IP=$3 +ctwo_GW=$4 + +containers=( cone ctwo ) +idx=1 # Restart VPP so there is no config service vpp restart -# delete previous incarnations if they exist -ip link del dev veth_link1 &>/dev/null -ip link del dev veth_link2 &>/dev/null -ip netns del c1 &>/dev/null -ip netns del c2 &>/dev/null - -#create namespaces -ip netns add c1 &>/dev/null -ip netns add c2 &>/dev/null - -# create and configure 1st veth pair -ip link add name veth_link1 type veth peer name link1 -ip link set dev link1 up -ip link set dev veth_link1 up netns c1 - -ip netns exec c1 \ - bash -c " - ip link set dev lo up - ip addr add ${C1_IP} dev veth_link1 - ip route add default via ${C1_GW} dev veth_link1 -" - -# create and configure 2nd veth pair -ip link add name veth_link2 type veth peer name link2 -ip link set dev link2 up -ip link set dev veth_link2 up netns c2 - -ip netns exec c2 \ - bash -c " - ip link set dev lo up - ip addr add ${C2_IP} dev veth_link2 - ip route add default via ${C2_GW} dev veth_link2 -" +for cntr in "${containers[@]}" +do + #stop the container + echo "stopping container $cntr" + sudo lxc-stop -n $cntr +done + +# LXC gives backend interfaces horrible names, give them a better name. +function rename_veth_interface() { + + local cntr="$1" + local nifname="$2" + + ifr_index=`sudo lxc-attach -n $cntr -- ip -o link | tail -n 1 | awk -F : '{print $1}'` + ifr_index=$((ifr_index+1)) + + for dir in /sys/class/net/*/ + do + ifindex=`cat $dir/ifindex` + if [ $ifindex == $ifr_index ] + then ifname=`basename $dir` + fi + done + + sudo ip link set $ifname down + sudo ip link set $ifname name $nifname + sudo ip link set $nifname up +} + +for cntr in "${containers[@]}" +do + cip=$cntr\_IP + cgw=$cntr\_GW + + #start the container + sudo lxc-start -n $cntr -d + + #give the backend of our veth a sensible name. + rename_veth_interface $cntr "link"$idx + + #start vpp in the container. + #sudo lxc-attach -n $cntr service vpp start + + #setup the inteface in the container + sudo lxc-attach -n $cntr -- \ + bash -c " + ip link set dev lo up + ip addr add ${!cip} dev veth_link1 + ip link set dev veth_link1 up + ip route add default via ${!cgw} dev veth_link1" + + idx=$((idx+1)) +done diff --git a/vpp-userdemo/routing b/vpp-userdemo/routing index 02e3f91..2eca7b7 100644 --- a/vpp-userdemo/routing +++ b/vpp-userdemo/routing @@ -21,17 +21,17 @@ C2_GW="172.16.2.1" INSTR=() CMD=() INSTR+=("Welcome to the routing demo. This will show you some simple commands to connect two -linux netnamespaces to VPP and ping between them.") +linux containers to VPP and ping between them.") CMD+=("") INSTR+=("To show interfaces type:") CMD+=("sudo vppctl show inter") -INSTR+=("Lets examine our workloads c1 and c2") -CMD+=("sudo ip netns exec c1 ip -o a") +INSTR+=("Lets examine our workloads cone and ctwo") +CMD+=("sudo lxc-attach -n cone -- ip -o a") INSTR+=("") -CMD+=("sudo ip netns exec c2 ip -o a") +CMD+=("sudo lxc-attach -n ctwo -- ip -o a") INSTR+=("To add interfaces, we add the host-side of the veth link pair.") CMD+=("ip link") @@ -49,10 +49,10 @@ INSTR+=("You can also see the L3 table, or FIB by doing") CMD+=("sudo vppctl show ip fib") INSTR+=("At long last you probably want to see some pings") -CMD+=("sudo ip netns exec c1 ping -c3 172.16.2.2") +CMD+=("sudo lxc-attach -n cone -- ping -c3 172.16.2.2") INSTR+=("") -CMD+=("sudo ip netns exec c2 ping -c3 172.16.1.2") +CMD+=("sudo lxc-attach -n ctwo -- ping -c3 172.16.1.2") INSTR+=("Thanks for doing the routing demo. To restart this demo and type these commands yourself \nvagrant ssh \nsudo /vagrant/netns.sh \ncat /vagrant/routing.cmd") CMD+=("") diff --git a/vpp-userdemo/tracing b/vpp-userdemo/tracing index 11b189a..3ef6d15 100644 --- a/vpp-userdemo/tracing +++ b/vpp-userdemo/tracing @@ -34,10 +34,10 @@ INSTR+=("Lets add the trace command for the graph-node our type of interface af- CMD+=("sudo vppctl trace add af-packet-input 50") INSTR+=("At long last you probably want to see some pings") -CMD+=("sudo ip netns exec c1 ping -c3 172.16.2.2") +CMD+=("sudo lxc-attach -n cone -- ping -c3 172.16.2.2") INSTR+=("") -CMD+=("sudo ip netns exec c2 ping -c3 172.16.1.2") +CMD+=("sudo lxc-attach -n ctwo -- ping -c3 172.16.1.2") INSTR+=("Viewing the trace:") CMD+=("sudo vppctl show trace") |