flimflam_test: Add netmask when configuring backchannel ethernet.
Specifying a netmask allows the kernel to add the correct network route
to the backchannel ethernet interface.
BUG=chromium-os:36385
TEST=Setup backchannel and verify the netmask is the same as eth0
Change-Id: I20538c05720bfbc440670fdd560638ccf0c19a6e
Reviewed-on: https://gerrit.chromium.org/gerrit/38150
Commit-Ready: Thieu Le <thieule@chromium.org>
Reviewed-by: Thieu Le <thieule@chromium.org>
Tested-by: Thieu Le <thieule@chromium.org>
diff --git a/test/backchannel b/test/backchannel
index 7187880..9e6d34e 100644
--- a/test/backchannel
+++ b/test/backchannel
@@ -1,4 +1,9 @@
#!/bin/sh
+
+# Copyright (c) 2012 The Chromium OS Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
# Backchannel control script - sets up and tears down backchannel network
# interfaces. Backchannel interfaces are hidden from flimflam and will never be
# the default route.
@@ -8,10 +13,6 @@
# pseudo-modem0
#
-# Copyright (c) 2009 The Chromium OS Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
test_if=eth_test
usage () {
@@ -30,6 +31,11 @@
| awk -F ':' '{ print $2 }'
}
+netmask () {
+ ifconfig "$1" | awk '/Mask:/ { print $4 }' \
+ | awk -F ':' '{ print $2 }'
+}
+
# We need to down the interface (and therefore stop flimflam) across the
# invocation of nameif, according to nameif(1).
renameif () {
@@ -44,11 +50,12 @@
setup () {
oldip=$(ipaddr "$1")
+ oldnetmask=$(netmask "$1")
if [ ! -z $2 ] ; then
test_if="$2"
fi
renameif "$1" "$test_if"
- ifconfig "$test_if" "$oldip"
+ ifconfig "$test_if" "$oldip" netmask "$oldnetmask"
}
teardown () {