Prefer using ip instead of ifconfig.

Includes other minor improvements.
This commit is contained in:
tgoff0 2015-05-22 00:55:20 +00:00
parent 2f3ec89ef4
commit c68e05b4b5
5 changed files with 33 additions and 25 deletions

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh -e
# #
# iperf-performance.sh # iperf-performance.sh
# #
@ -20,7 +20,7 @@ STAMP=`date +%Y%m%d%H%M%S`
# client---(loopback)---server # client---(loopback)---server
# #
loopbacktest () { loopbacktest () {
killall iperf 2> /dev/null killall iperf 2> /dev/null || true
echo ">> loopback iperf test" echo ">> loopback iperf test"
echo "loopback" > ${LOG} echo "loopback" > ${LOG}
@ -61,14 +61,16 @@ lxcvethtest () {
echo "starting lxc iperf server" echo "starting lxc iperf server"
vnoded -l $SERVER.log -p $SERVER.pid -c $SERVER vnoded -l $SERVER.log -p $SERVER.pid -c $SERVER
ip link add name veth0.1 type veth peer name veth0 ip link add name veth0.1 type veth peer name veth0
ip link set veth0 netns `cat $SERVER.pid` ip link set veth0 netns `cat $SERVER.pid` up
vcmd -c $SERVER -- ifconfig veth0 $SERVERIP/24 vcmd -c $SERVER -- ip link set lo up
vcmd -c $SERVER -- ip addr add $SERVERIP/24 dev veth0
vcmd -c $SERVER -- iperf -s -y c >> ${LOG} & vcmd -c $SERVER -- iperf -s -y c >> ${LOG} &
echo "starting lxc iperf client" echo "starting lxc iperf client"
vnoded -l $CLIENT.log -p $CLIENT.pid -c $CLIENT vnoded -l $CLIENT.log -p $CLIENT.pid -c $CLIENT
ip link set veth0.1 netns `cat $CLIENT.pid` ip link set veth0.1 netns `cat $CLIENT.pid` up
vcmd -c $CLIENT -- ifconfig veth0.1 $CLIENTIP/24 vcmd -c $CLIENT -- ip link set lo up
vcmd -c $CLIENT -- ip addr add $CLIENTIP/24 dev veth0.1
i=1 i=1
while [ $i -le $NUMRUNS ]; do while [ $i -le $NUMRUNS ]; do
@ -112,8 +114,9 @@ lxcbrtest () {
echo "starting lxc iperf server" echo "starting lxc iperf server"
vnoded -l $SERVER.log -p $SERVER.pid -c $SERVER vnoded -l $SERVER.log -p $SERVER.pid -c $SERVER
ip link add name veth0.1 type veth peer name veth0 ip link add name veth0.1 type veth peer name veth0
ip link set veth0 netns `cat $SERVER.pid` ip link set veth0 netns `cat $SERVER.pid` up
vcmd -c $SERVER -- ifconfig veth0 $SERVERIP/24 vcmd -c $SERVER -- ip link set lo up
vcmd -c $SERVER -- ip addr add $SERVERIP/24 dev veth0
brctl addif $BRIDGE veth0.1 brctl addif $BRIDGE veth0.1
ip link set veth0.1 up ip link set veth0.1 up
vcmd -c $SERVER -- iperf -s -y c >> ${LOG} & vcmd -c $SERVER -- iperf -s -y c >> ${LOG} &
@ -121,8 +124,9 @@ lxcbrtest () {
echo "starting lxc iperf client" echo "starting lxc iperf client"
vnoded -l $CLIENT.log -p $CLIENT.pid -c $CLIENT vnoded -l $CLIENT.log -p $CLIENT.pid -c $CLIENT
ip link add name veth1.1 type veth peer name veth1 ip link add name veth1.1 type veth peer name veth1
ip link set veth1 netns `cat $CLIENT.pid` ip link set veth1 netns `cat $CLIENT.pid` up
vcmd -c $CLIENT -- ifconfig veth1 $CLIENTIP/24 vcmd -c $CLIENT -- ip link set lo up
vcmd -c $CLIENT -- ip addr add $CLIENTIP/24 dev veth1
brctl addif $BRIDGE veth1.1 brctl addif $BRIDGE veth1.1
ip link set veth1.1 up ip link set veth1.1 up
@ -216,8 +220,9 @@ clientstest () {
echo "starting lxc iperf server" echo "starting lxc iperf server"
vnoded -l $SERVER.log -p $SERVER.pid -c $SERVER vnoded -l $SERVER.log -p $SERVER.pid -c $SERVER
ip link add name veth0.1 type veth peer name veth0 ip link add name veth0.1 type veth peer name veth0
ip link set veth0 netns `cat $SERVER.pid` ip link set veth0 netns `cat $SERVER.pid` up
vcmd -c $SERVER -- ifconfig veth0 $SERVERIP/24 vcmd -c $SERVER -- ip link set lo up
vcmd -c $SERVER -- ip addr add $SERVERIP/24 dev veth0
brctl addif $BRIDGE veth0.1 brctl addif $BRIDGE veth0.1
ip link set veth0.1 up ip link set veth0.1 up
vcmd -c $SERVER -- iperf -s -y c >> ${LOG} & vcmd -c $SERVER -- iperf -s -y c >> ${LOG} &
@ -230,8 +235,9 @@ clientstest () {
CLIENTIP=10.0.0.1$i CLIENTIP=10.0.0.1$i
vnoded -l $CLIENT.log -p $CLIENT.pid -c $CLIENT vnoded -l $CLIENT.log -p $CLIENT.pid -c $CLIENT
ip link add name veth1.$i type veth peer name veth1 ip link add name veth1.$i type veth peer name veth1
ip link set veth1 netns `cat $CLIENT.pid` ip link set veth1 netns `cat $CLIENT.pid` up
vcmd -c $CLIENT -- ifconfig veth1 $CLIENTIP/24 vcmd -c $CLIENT -- ip link set lo up
vcmd -c $CLIENT -- ip addr add $CLIENTIP/24 dev veth1
brctl addif $BRIDGE veth1.$i brctl addif $BRIDGE veth1.$i
ip link set veth1.$i up ip link set veth1.$i up
i=$((i+1)) i=$((i+1))

View file

@ -1,4 +1,4 @@
#!/bin/sh #!/bin/sh -e
# Below is a transcript of creating two emulated nodes and connecting them # Below is a transcript of creating two emulated nodes and connecting them
# together with a wired link. You can run the core-cleanup script to clean # together with a wired link. You can run the core-cleanup script to clean
# up after this script. # up after this script.
@ -8,16 +8,16 @@ vnoded -c /tmp/n1.ctl -l /tmp/n1.log -p /tmp/n1.pid
# create a virtual Ethernet (veth) pair, installing one end into node 1 # create a virtual Ethernet (veth) pair, installing one end into node 1
ip link add name n1.0.1 type veth peer name n1.0 ip link add name n1.0.1 type veth peer name n1.0
ip link set n1.0 netns `cat /tmp/n1.pid` ip link set n1.0 netns `cat /tmp/n1.pid`
vcmd -c /tmp/n1.ctl -- ip link set n1.0 name eth0 vcmd -c /tmp/n1.ctl -- /bin/sh -e -c \
vcmd -c /tmp/n1.ctl -- ifconfig eth0 10.0.0.1/24 "ip link set lo up && ip link set n1.0 name eth0 up && ip addr add 10.0.0.1/24 dev eth0"
# create node 2 namespace container # create node 2 namespace container
vnoded -c /tmp/n2.ctl -l /tmp/n2.log -p /tmp/n2.pid vnoded -c /tmp/n2.ctl -l /tmp/n2.log -p /tmp/n2.pid
# create a virtual Ethernet (veth) pair, installing one end into node 2 # create a virtual Ethernet (veth) pair, installing one end into node 2
ip link add name n2.0.1 type veth peer name n2.0 ip link add name n2.0.1 type veth peer name n2.0
ip link set n2.0 netns `cat /tmp/n2.pid` ip link set n2.0 netns `cat /tmp/n2.pid`
vcmd -c /tmp/n2.ctl -- ip link set n2.0 name eth0 vcmd -c /tmp/n2.ctl -- /bin/sh -e -c \
vcmd -c /tmp/n2.ctl -- ifconfig eth0 10.0.0.2/24 "ip link set lo up && ip link set n2.0 name eth0 up && ip addr add 10.0.0.2/24 dev eth0"
# bridge together nodes 1 and 2 using the other end of each veth pair # bridge together nodes 1 and 2 using the other end of each veth pair
brctl addbr b.1.1 brctl addbr b.1.1

View file

@ -47,7 +47,7 @@ killall -q emaneeventservice
if [ -d /sys/class/net ]; then if [ -d /sys/class/net ]; then
ifcommand="ls -1 /sys/class/net" ifcommand="ls -1 /sys/class/net"
else else
ifcommand="ifconfig -a" ifcommand="ip -o link show | sed -r -e 's/[0-9]+: ([^[:space:]]+): .*/\1/'"
fi fi
eval "$ifcommand" | awk ' eval "$ifcommand" | awk '

View file

@ -153,16 +153,18 @@ Below is a transcript of creating two emulated nodes and connecting them togethe
# create a virtual Ethernet (veth) pair, installing one end into node 1 # create a virtual Ethernet (veth) pair, installing one end into node 1
ip link add name n1.0.1 type veth peer name n1.0 ip link add name n1.0.1 type veth peer name n1.0
ip link set n1.0 netns `cat /tmp/n1.pid` ip link set n1.0 netns `cat /tmp/n1.pid`
vcmd -c /tmp/n1.ctl -- ip link set n1.0 name eth0 vcmd -c /tmp/n1.ctl -- ip link set lo up
vcmd -c /tmp/n1.ctl -- ifconfig eth0 10.0.0.1/24 vcmd -c /tmp/n1.ctl -- ip link set n1.0 name eth0 up
vcmd -c /tmp/n1.ctl -- ip addr add 10.0.0.1/24 dev eth0
# create node 2 namespace container # create node 2 namespace container
vnoded -c /tmp/n2.ctl -l /tmp/n2.log -p /tmp/n2.pid vnoded -c /tmp/n2.ctl -l /tmp/n2.log -p /tmp/n2.pid
# create a virtual Ethernet (veth) pair, installing one end into node 2 # create a virtual Ethernet (veth) pair, installing one end into node 2
ip link add name n2.0.1 type veth peer name n2.0 ip link add name n2.0.1 type veth peer name n2.0
ip link set n2.0 netns `cat /tmp/n2.pid` ip link set n2.0 netns `cat /tmp/n2.pid`
vcmd -c /tmp/n2.ctl -- ip link set n2.0 name eth0 vcmd -c /tmp/n2.ctl -- ip link set lo up
vcmd -c /tmp/n2.ctl -- ifconfig eth0 10.0.0.2/24 vcmd -c /tmp/n2.ctl -- ip link set n2.0 name eth0 up
vcmd -c /tmp/n2.ctl -- ip addr add 10.0.0.2/24 eth0
# bridge together nodes 1 and 2 using the other end of each veth pair # bridge together nodes 1 and 2 using the other end of each veth pair
brctl addbr b.1.1 brctl addbr b.1.1

View file

@ -1127,7 +1127,7 @@ session, configure an address on the host.
sudo brctl show sudo brctl show
# determine bridge name from the above command # determine bridge name from the above command
# assign an IP address on the same network as the linked node # assign an IP address on the same network as the linked node
sudo ifconfig b.48304.34658 10.0.1.2/24 sudo ip addr add 10.0.1.2/24 dev b.48304.34658
In the example shown above, the host will have the address ``10.0.1.2`` and In the example shown above, the host will have the address ``10.0.1.2`` and
the node linked to the RJ45 may have the address ``10.0.1.1``. the node linked to the RJ45 may have the address ``10.0.1.1``.