summaryrefslogtreecommitdiff
path: root/ubuntu
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2015-07-15 15:09:22 +0800
committerChase Qi <chase.qi@linaro.org>2015-07-15 18:29:41 +0800
commit0b22389b1f484a94daac72c2d190a0d376cb4ccb (patch)
tree860ee730991e38c25ccfcd1031c321aab344d84a /ubuntu
parentf5bae31140cedda73cbb692d0a040ecafcf332e5 (diff)
downloadtest-definitions-pipe-0b22389b1f484a94daac72c2d190a0d376cb4ccb.tar.gz
ubuntu: add mutiple network interfaces test
rp_filter is set to 1 by default on Ubuntu to turn on Source Address Verification in all interfaces to prevent some spoofing attacks. For network testing, we set rp_filter to 0 so that Ubuntu send and accept packets through the specified ethernet interface Change-Id: I87e070d5ec242d6df109e483dfc7cfdae1a1ac56 Signed-off-by: Chase Qi <chase.qi@linaro.org>
Diffstat (limited to 'ubuntu')
-rw-r--r--ubuntu/multiple-network-interfaces.yaml25
-rwxr-xr-xubuntu/scripts/multiple-network-interfaces-test.sh84
2 files changed, 109 insertions, 0 deletions
diff --git a/ubuntu/multiple-network-interfaces.yaml b/ubuntu/multiple-network-interfaces.yaml
new file mode 100644
index 0000000..2891190
--- /dev/null
+++ b/ubuntu/multiple-network-interfaces.yaml
@@ -0,0 +1,25 @@
+metadata:
+ format: Lava-Test Test Definition 1.0
+ name: multiple-network-interfaces-test
+ description: "Multiple network interfaces test for Linaro Ubuntu images.
+ rp_filter is set to 1 by default on Ubuntu to turn on Source
+ Address Verification in all interfaces to prevent some
+ spoofing attacks. For network testing, we set rp_filter to 0
+ so that Ubuntu send and accept packets through the specified
+ ethernet interface"
+ maintainer:
+ - chase.qi@linaro.org
+ os:
+ - ubuntu
+ scope:
+ - functional
+ devices:
+ - d01
+ environment:
+ - lava-test-shell
+params:
+ GATEWAY: 10.0.0.1
+
+run:
+ steps:
+ - './ubuntu/scripts/multiple-network-interfaces-test.sh $GATEWAY'
diff --git a/ubuntu/scripts/multiple-network-interfaces-test.sh b/ubuntu/scripts/multiple-network-interfaces-test.sh
new file mode 100755
index 0000000..66d7523
--- /dev/null
+++ b/ubuntu/scripts/multiple-network-interfaces-test.sh
@@ -0,0 +1,84 @@
+#!/bin/sh
+#
+# Multiple network interfaces test for ubuntu
+#
+# Copyright (C) 2013, Linaro Limited.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Author: Chase Qi <chase.qi@linaro.org>
+
+# Print network gateway
+GATEWAY=$1
+echo "GATEWAY: $GATEWAY"
+
+# Print all network interfaces
+ifconfig -a
+
+# Pass rp_filter=0 to kernel to address ARP flux
+echo "Pass rp_filter=0 to kernel to address ARP flux"
+for i in all default; do
+ echo 0 > /proc/sys/net/ipv4/conf/$i/rp_filter
+ sysctl -a |grep $i.rp_filter
+done
+if [ $? -eq 0 ]; then
+ lava-test-case address-arp-flux --result pass
+else
+ lava-test-case address-arp-flux --result fail
+ exit 1
+fi
+
+# Set dhclient timeout to 2 minutes.
+cp /etc/dhcp/dhclient.conf /etc/dhcp/dhclient.conf.original
+echo "timeout 120;" >> /etc/dhcp/dhclient.conf
+
+for INTERFACE in `ifconfig -a |grep eth |awk '{print $1}'`; do
+ # Check IP address on each interface. If IP is empty, use dhclient request
+ # IP from dhcp server, then check if IP address is empty again.
+ IP=$(ifconfig $INTERFACE | grep "inet addr" | awk '{print substr($2,6)}')
+ if [ -z $IP ]; then
+ dhclient $INTERFACE
+ if [ $? -eq 0 ]; then
+ IP=$(ifconfig $INTERFACE | grep "inet addr" \
+ | awk '{print substr($2,6)}')
+ if [ -z $IP ]; then
+ lava-test-case $INTERFACE-obtain-ip-address --result fail
+ lava-test-case $INTERFACE-ping-test --result skip
+ continue
+ else
+ echo "$INTERFACE IP address: $IP"
+ lava-test-case $INTERFACE-obtain-ip-address --result pass
+ fi
+ else
+ lava-test-case $INTERFACE-obtain-ip-address --result fail
+ lava-test-case $INTERFACE-ping-test --result skip
+ continue
+ fi
+ else
+ echo "$INTERFACE IP address: $IP"
+ lava-test-case $INTERFACE-obtain-ip-address --result pass
+ fi
+
+ # Run ping test on the specific interface
+ ping -c 5 -I $INTERFACE $GATEWAY
+ if [ $? -eq 0 ]; then
+ lava-test-case $INTERFACE-ping-test --result pass
+ else
+ lava-test-case $INTERFACE-ping-test --result fail
+ fi
+done
+
+# Restore dhclient setting.
+mv /etc/dhcp/dhclient.conf.original /etc/dhcp/dhclient.conf