* [LTP] [PATCH] ip_tests.sh: don't use hardcoded eth0
@ 2014-03-28 1:44 Simon Xu
2014-03-28 5:08 ` Mike Frysinger
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Simon Xu @ 2014-03-28 1:44 UTC (permalink / raw)
To: ltp-list
The script uses hardcoded 'eth0' which used to work on most systems.
This fix tries to find a 'working' network interface using the hostname.
Signed-off-by: Simon Xu <xu.simon@oracle.com>
---
testcases/network/iproute/ip_tests.sh | 50 +++++++++++++++++++----------------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/testcases/network/iproute/ip_tests.sh b/testcases/network/iproute/ip_tests.sh
index ed20540..4bba243 100755
--- a/testcases/network/iproute/ip_tests.sh
+++ b/testcases/network/iproute/ip_tests.sh
@@ -38,7 +38,7 @@ set +x
# Description: - Check if command ip is available.
# - Check if command ifconfig is available.
# - check if command awk is available.
-# - alias eth0 to eth0:1 with IP 10.1.1.12
+# - alias $INF to $INF:1 with IP 10.1.1.12
#
# Return - zero on success
# - non zero on failure. return value from commands ($RC)
@@ -46,7 +46,7 @@ init()
{
export TST_TOTAL=2 # total numner of tests in this file.
- export TCID="ip_tests " # this is the init function.
+ export TCID="ip_tests" # this is the init function.
export TST_COUNT=0 # init identifier,
if [ -z $TMP ]
@@ -107,22 +107,26 @@ init()
tst_resm TINFO "INIT: Inititalizing tests."
- # Aliasing eth0 to create private network.
- /sbin/ifconfig eth0:1 10.1.1.12 >$LTPTMP/tst_ip.err 2>&1
+ # Get network interface.
+ IP=$(dig +short $(hostname))
+ INF=$(ifconfig|grep -B1 $IP|head -1|sed 's/:.*//')
+
+ # Aliasing $INF to create private network.
+ /sbin/ifconfig $INF:1 10.1.1.12 >$LTPTMP/tst_ip.err 2>&1
RC=$?
if [ $RC -ne 0 ]
then
- tst_brk TBROK NULL NULL "INIT: failed aliasing eth0:1 with IP 10.1.1.12"
+ tst_brk TBROK NULL NULL "INIT: failed aliasing $INF:1 with IP 10.1.1.12"
return $RC
else
- /sbin/route add -host 10.1.1.12 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1
+ /sbin/route add -host 10.1.1.12 dev $INF:1 >$LTPTMP/tst_ip.err 2>&1
RC=$?
if [ $RC -ne 0 ]
then
tst_brk TBROK NULL NULL "INIT: failed adding route to 10.1.1.12"
return $RC
else
- tst_resm TINFO "INIT: added alias: `ifconfig eth0:1`"
+ tst_resm TINFO "INIT: added alias: `ifconfig $INF:1`"
fi
fi
@@ -148,7 +152,7 @@ init()
# Function: cleanup
#
# Description - remove temporary files and directories.
-# - remove alias to eth0
+# - remove alias to $INF
#
# Return - zero on success
# - non zero on failure. return value from commands ($RC)
@@ -157,11 +161,11 @@ cleanup()
TCID=dhcpd
TST_COUNT=0
- /sbin/ifconfig eth0:1 >$LTPTMP/tst_ip.err 2>&1
+ /sbin/ifconfig $INF:1 >$LTPTMP/tst_ip.err 2>&1
RC=$?
if [ $RC -eq 0 ]
then
- /sbin/ifconfig eth0:1 down >$LTPTMP/tst_ip.err 2>&1
+ /sbin/ifconfig $INF:1 down >$LTPTMP/tst_ip.err 2>&1
fi
rm -fr $LTPTMP
@@ -189,11 +193,11 @@ test01()
tst_resm TINFO \
"Test #1: ip link set DEVICE mtu MTU changes the device mtu size"
- tst_resm TINFO "Test #1: changing mtu size of eth0:1 device."
+ tst_resm TINFO "Test #1: changing mtu size of $INF:1 device."
MTUSZ_BAK=`ifconfig eth0:1 | grep -i MTU | sed "s/^.*MTU://" \
| awk '{print $1}'`
- ip link set eth0:1 mtu 300 >$LTPTMP/tst_ip.err 2>&1
+ ip link set $INF:1 mtu 300 >$LTPTMP/tst_ip.err 2>&1
if [ $RC -ne 0 ]
then
tst_res TFAIL $LTPTMP/tst_ip.err \
@@ -204,7 +208,7 @@ test01()
if [ $MTUSZ -eq 300 ]
then
tst_resm TPASS "Test #1: changing mtu size success"
- ip link set eth0:1 mtu $MTUSZ_BAK \
+ ip link set $INF:1 mtu $MTUSZ_BAK \
>$LTPTMP/tst_ip.err 2>&1
else
tst_resm FAIL NULL \
@@ -256,7 +260,7 @@ test02()
return $RC
else
tst_resm TPASS \
- "Test #2: Listed eth0:1 and returned correct attributes"
+ "Test #2: Listed $INF:1 and returned correct attributes"
fi
return $RC
}
@@ -365,7 +369,7 @@ test04()
return $RC
else
tst_resm TINFO \
- "Test #4: ip neigh show - shows all neighbour entries in arp tables."
+ "Test #4: ip neigh show - shows all neighbour entries in arp tables."
cat > $LTPTMP/tst_ip.exp <<-EOF
127.0.0.1 dev lo lladdr 00:00:00:00:00:00 REACHABLE
@@ -443,14 +447,14 @@ test05()
tst_resm TINFO \
- "Test #5: create an interface with inet 10.6.6.6 alias to eth0"
+ "Test #5: create an interface with inet 10.6.6.6 alias to $INF"
- ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1
+ ifconfig $INF:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1
RC=$?
if [ $RC -ne 0 ]
then
tst_brk TBROK $LTPTMP/tst_ip.err NULL \
- "Test #5: unable to create interface eth0:1 inet 10.6.6.6. Reason:"
+ "Test #5: unable to create interface $INF:1 inet 10.6.6.6. Reason:"
return $RC
fi
@@ -541,16 +545,16 @@ test06()
tst_resm TINFO \
"Test #6: ip maddr add - adds a new multicast addr"
- ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1
+ ifconfig $INF:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1
RC=$?
if [ $RC -ne 0 ]
then
tst_brk TBROK $LTPTMP/tst_ip.err NULL \
- "Test #6: unable to create interface eth0:1 inet 10.6.6.6. Reason:"
+ "Test #6: unable to create interface $INF:1 inet 10.6.6.6. Reason:"
return $RC
fi
- ip maddr add 66:66:00:00:00:66 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1
+ ip maddr add 66:66:00:00:00:66 dev $INF:1 >$LTPTMP/tst_ip.err 2>&1
RC=$?
if [ $RC -ne 0 ]
then
@@ -579,7 +583,7 @@ test06()
if [ $RC -ne 0 ]
then
tst_res FAIL $LTPTMP/tst_ip.err \
- "Test #6: multicast addr not added to eth0:1. Details:"
+ "Test #6: multicast addr not added to $INF:1. Details:"
return $RC
fi
fi
@@ -587,7 +591,7 @@ test06()
tst_resm TINFO \
"Test #6: ip maddr del - deletes multicast addr."
- ip maddr del 66:66:00:00:00:66 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1
+ ip maddr del 66:66:00:00:00:66 dev $INF:1 >$LTPTMP/tst_ip.err 2>&1
RC=$?
if [ $RC -ne 0 ]
then
--
1.9.1
------------------------------------------------------------------------------
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH] ip_tests.sh: don't use hardcoded eth0
2014-03-28 1:44 [LTP] [PATCH] ip_tests.sh: don't use hardcoded eth0 Simon Xu
@ 2014-03-28 5:08 ` Mike Frysinger
2014-04-09 6:09 ` Simon Xu
2014-04-25 12:04 ` Stanislav Kholmanskikh
2014-04-09 6:10 ` Simon Xu
` (2 subsequent siblings)
3 siblings, 2 replies; 8+ messages in thread
From: Mike Frysinger @ 2014-03-28 5:08 UTC (permalink / raw)
To: ltp-list
[-- Attachment #1.1: Type: text/plain, Size: 236 bytes --]
On Fri 28 Mar 2014 09:44:24 Simon Xu wrote:
> The script uses hardcoded 'eth0' which used to work on most systems.
> This fix tries to find a 'working' network interface using the hostname.
why doesn't hardcoding "lo" work ?
-mike
[-- Attachment #1.2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
[-- Attachment #2: Type: text/plain, Size: 79 bytes --]
------------------------------------------------------------------------------
[-- Attachment #3: Type: text/plain, Size: 155 bytes --]
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH] ip_tests.sh: don't use hardcoded eth0
2014-03-28 5:08 ` Mike Frysinger
@ 2014-04-09 6:09 ` Simon Xu
2014-04-25 12:04 ` Stanislav Kholmanskikh
1 sibling, 0 replies; 8+ messages in thread
From: Simon Xu @ 2014-04-09 6:09 UTC (permalink / raw)
To: Mike Frysinger, ltp-list
In my CentOS box, running "ifconfig lo:1 10.1.1.12" immediately hangs
the ssh connection, I have to run "systemctl restart network" in local
tty to make network work again. Could you help to try the testcases in
ip_tests.sh on your box and report back?
Thanks
Simon
On 2014/3/28 13:08, Mike Frysinger wrote:
> On Fri 28 Mar 2014 09:44:24 Simon Xu wrote:
>> The script uses hardcoded 'eth0' which used to work on most systems.
>> This fix tries to find a 'working' network interface using the hostname.
> why doesn't hardcoding "lo" work ?
> -mike
------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH] ip_tests.sh: don't use hardcoded eth0
2014-03-28 1:44 [LTP] [PATCH] ip_tests.sh: don't use hardcoded eth0 Simon Xu
2014-03-28 5:08 ` Mike Frysinger
@ 2014-04-09 6:10 ` Simon Xu
2014-04-25 1:06 ` Simon Xu
2014-04-25 12:26 ` Stanislav Kholmanskikh
3 siblings, 0 replies; 8+ messages in thread
From: Simon Xu @ 2014-04-09 6:10 UTC (permalink / raw)
To: ltp-list
Could anyone else help to review the patch?
Thanks
Simon
On 2014/3/28 9:44, Simon Xu wrote:
> The script uses hardcoded 'eth0' which used to work on most systems.
> This fix tries to find a 'working' network interface using the hostname.
>
> Signed-off-by: Simon Xu <xu.simon@oracle.com>
> ---
> testcases/network/iproute/ip_tests.sh | 50 +++++++++++++++++++----------------
> 1 file changed, 27 insertions(+), 23 deletions(-)
>
> diff --git a/testcases/network/iproute/ip_tests.sh b/testcases/network/iproute/ip_tests.sh
> index ed20540..4bba243 100755
> --- a/testcases/network/iproute/ip_tests.sh
> +++ b/testcases/network/iproute/ip_tests.sh
> @@ -38,7 +38,7 @@ set +x
> # Description: - Check if command ip is available.
> # - Check if command ifconfig is available.
> # - check if command awk is available.
> -# - alias eth0 to eth0:1 with IP 10.1.1.12
> +# - alias $INF to $INF:1 with IP 10.1.1.12
> #
> # Return - zero on success
> # - non zero on failure. return value from commands ($RC)
> @@ -46,7 +46,7 @@ init()
> {
>
> export TST_TOTAL=2 # total numner of tests in this file.
> - export TCID="ip_tests " # this is the init function.
> + export TCID="ip_tests" # this is the init function.
> export TST_COUNT=0 # init identifier,
>
> if [ -z $TMP ]
> @@ -107,22 +107,26 @@ init()
>
> tst_resm TINFO "INIT: Inititalizing tests."
>
> - # Aliasing eth0 to create private network.
> - /sbin/ifconfig eth0:1 10.1.1.12 >$LTPTMP/tst_ip.err 2>&1
> + # Get network interface.
> + IP=$(dig +short $(hostname))
> + INF=$(ifconfig|grep -B1 $IP|head -1|sed 's/:.*//')
> +
> + # Aliasing $INF to create private network.
> + /sbin/ifconfig $INF:1 10.1.1.12 >$LTPTMP/tst_ip.err 2>&1
> RC=$?
> if [ $RC -ne 0 ]
> then
> - tst_brk TBROK NULL NULL "INIT: failed aliasing eth0:1 with IP 10.1.1.12"
> + tst_brk TBROK NULL NULL "INIT: failed aliasing $INF:1 with IP 10.1.1.12"
> return $RC
> else
> - /sbin/route add -host 10.1.1.12 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1
> + /sbin/route add -host 10.1.1.12 dev $INF:1 >$LTPTMP/tst_ip.err 2>&1
> RC=$?
> if [ $RC -ne 0 ]
> then
> tst_brk TBROK NULL NULL "INIT: failed adding route to 10.1.1.12"
> return $RC
> else
> - tst_resm TINFO "INIT: added alias: `ifconfig eth0:1`"
> + tst_resm TINFO "INIT: added alias: `ifconfig $INF:1`"
> fi
> fi
>
> @@ -148,7 +152,7 @@ init()
> # Function: cleanup
> #
> # Description - remove temporary files and directories.
> -# - remove alias to eth0
> +# - remove alias to $INF
> #
> # Return - zero on success
> # - non zero on failure. return value from commands ($RC)
> @@ -157,11 +161,11 @@ cleanup()
> TCID=dhcpd
> TST_COUNT=0
>
> - /sbin/ifconfig eth0:1 >$LTPTMP/tst_ip.err 2>&1
> + /sbin/ifconfig $INF:1 >$LTPTMP/tst_ip.err 2>&1
> RC=$?
> if [ $RC -eq 0 ]
> then
> - /sbin/ifconfig eth0:1 down >$LTPTMP/tst_ip.err 2>&1
> + /sbin/ifconfig $INF:1 down >$LTPTMP/tst_ip.err 2>&1
> fi
>
> rm -fr $LTPTMP
> @@ -189,11 +193,11 @@ test01()
> tst_resm TINFO \
> "Test #1: ip link set DEVICE mtu MTU changes the device mtu size"
>
> - tst_resm TINFO "Test #1: changing mtu size of eth0:1 device."
> + tst_resm TINFO "Test #1: changing mtu size of $INF:1 device."
>
> MTUSZ_BAK=`ifconfig eth0:1 | grep -i MTU | sed "s/^.*MTU://" \
> | awk '{print $1}'`
> - ip link set eth0:1 mtu 300 >$LTPTMP/tst_ip.err 2>&1
> + ip link set $INF:1 mtu 300 >$LTPTMP/tst_ip.err 2>&1
> if [ $RC -ne 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> @@ -204,7 +208,7 @@ test01()
> if [ $MTUSZ -eq 300 ]
> then
> tst_resm TPASS "Test #1: changing mtu size success"
> - ip link set eth0:1 mtu $MTUSZ_BAK \
> + ip link set $INF:1 mtu $MTUSZ_BAK \
> >$LTPTMP/tst_ip.err 2>&1
> else
> tst_resm FAIL NULL \
> @@ -256,7 +260,7 @@ test02()
> return $RC
> else
> tst_resm TPASS \
> - "Test #2: Listed eth0:1 and returned correct attributes"
> + "Test #2: Listed $INF:1 and returned correct attributes"
> fi
> return $RC
> }
> @@ -365,7 +369,7 @@ test04()
> return $RC
> else
> tst_resm TINFO \
> - "Test #4: ip neigh show - shows all neighbour entries in arp tables."
> + "Test #4: ip neigh show - shows all neighbour entries in arp tables."
>
> cat > $LTPTMP/tst_ip.exp <<-EOF
> 127.0.0.1 dev lo lladdr 00:00:00:00:00:00 REACHABLE
> @@ -443,14 +447,14 @@ test05()
>
>
> tst_resm TINFO \
> - "Test #5: create an interface with inet 10.6.6.6 alias to eth0"
> + "Test #5: create an interface with inet 10.6.6.6 alias to $INF"
>
> - ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1
> + ifconfig $INF:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1
> RC=$?
> if [ $RC -ne 0 ]
> then
> tst_brk TBROK $LTPTMP/tst_ip.err NULL \
> - "Test #5: unable to create interface eth0:1 inet 10.6.6.6. Reason:"
> + "Test #5: unable to create interface $INF:1 inet 10.6.6.6. Reason:"
> return $RC
> fi
>
> @@ -541,16 +545,16 @@ test06()
> tst_resm TINFO \
> "Test #6: ip maddr add - adds a new multicast addr"
>
> - ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1
> + ifconfig $INF:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1
> RC=$?
> if [ $RC -ne 0 ]
> then
> tst_brk TBROK $LTPTMP/tst_ip.err NULL \
> - "Test #6: unable to create interface eth0:1 inet 10.6.6.6. Reason:"
> + "Test #6: unable to create interface $INF:1 inet 10.6.6.6. Reason:"
> return $RC
> fi
>
> - ip maddr add 66:66:00:00:00:66 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1
> + ip maddr add 66:66:00:00:00:66 dev $INF:1 >$LTPTMP/tst_ip.err 2>&1
> RC=$?
> if [ $RC -ne 0 ]
> then
> @@ -579,7 +583,7 @@ test06()
> if [ $RC -ne 0 ]
> then
> tst_res FAIL $LTPTMP/tst_ip.err \
> - "Test #6: multicast addr not added to eth0:1. Details:"
> + "Test #6: multicast addr not added to $INF:1. Details:"
> return $RC
> fi
> fi
> @@ -587,7 +591,7 @@ test06()
> tst_resm TINFO \
> "Test #6: ip maddr del - deletes multicast addr."
>
> - ip maddr del 66:66:00:00:00:66 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1
> + ip maddr del 66:66:00:00:00:66 dev $INF:1 >$LTPTMP/tst_ip.err 2>&1
> RC=$?
> if [ $RC -ne 0 ]
> then
------------------------------------------------------------------------------
Put Bad Developers to Shame
Dominate Development with Jenkins Continuous Integration
Continuously Automate Build, Test & Deployment
Start a new project now. Try Jenkins in the cloud.
http://p.sf.net/sfu/13600_Cloudbees
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH] ip_tests.sh: don't use hardcoded eth0
2014-03-28 1:44 [LTP] [PATCH] ip_tests.sh: don't use hardcoded eth0 Simon Xu
2014-03-28 5:08 ` Mike Frysinger
2014-04-09 6:10 ` Simon Xu
@ 2014-04-25 1:06 ` Simon Xu
2014-04-25 12:26 ` Stanislav Kholmanskikh
3 siblings, 0 replies; 8+ messages in thread
From: Simon Xu @ 2014-04-25 1:06 UTC (permalink / raw)
To: ltp-list
Could anyone help to review this?
Thanks
Simon
On 2014/3/28 9:44, Simon Xu wrote:
> The script uses hardcoded 'eth0' which used to work on most systems.
> This fix tries to find a 'working' network interface using the hostname.
>
> Signed-off-by: Simon Xu <xu.simon@oracle.com>
> ---
> testcases/network/iproute/ip_tests.sh | 50 +++++++++++++++++++----------------
> 1 file changed, 27 insertions(+), 23 deletions(-)
>
> diff --git a/testcases/network/iproute/ip_tests.sh b/testcases/network/iproute/ip_tests.sh
> index ed20540..4bba243 100755
> --- a/testcases/network/iproute/ip_tests.sh
> +++ b/testcases/network/iproute/ip_tests.sh
> @@ -38,7 +38,7 @@ set +x
> # Description: - Check if command ip is available.
> # - Check if command ifconfig is available.
> # - check if command awk is available.
> -# - alias eth0 to eth0:1 with IP 10.1.1.12
> +# - alias $INF to $INF:1 with IP 10.1.1.12
> #
> # Return - zero on success
> # - non zero on failure. return value from commands ($RC)
> @@ -46,7 +46,7 @@ init()
> {
>
> export TST_TOTAL=2 # total numner of tests in this file.
> - export TCID="ip_tests " # this is the init function.
> + export TCID="ip_tests" # this is the init function.
> export TST_COUNT=0 # init identifier,
>
> if [ -z $TMP ]
> @@ -107,22 +107,26 @@ init()
>
> tst_resm TINFO "INIT: Inititalizing tests."
>
> - # Aliasing eth0 to create private network.
> - /sbin/ifconfig eth0:1 10.1.1.12 >$LTPTMP/tst_ip.err 2>&1
> + # Get network interface.
> + IP=$(dig +short $(hostname))
> + INF=$(ifconfig|grep -B1 $IP|head -1|sed 's/:.*//')
> +
> + # Aliasing $INF to create private network.
> + /sbin/ifconfig $INF:1 10.1.1.12 >$LTPTMP/tst_ip.err 2>&1
> RC=$?
> if [ $RC -ne 0 ]
> then
> - tst_brk TBROK NULL NULL "INIT: failed aliasing eth0:1 with IP 10.1.1.12"
> + tst_brk TBROK NULL NULL "INIT: failed aliasing $INF:1 with IP 10.1.1.12"
> return $RC
> else
> - /sbin/route add -host 10.1.1.12 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1
> + /sbin/route add -host 10.1.1.12 dev $INF:1 >$LTPTMP/tst_ip.err 2>&1
> RC=$?
> if [ $RC -ne 0 ]
> then
> tst_brk TBROK NULL NULL "INIT: failed adding route to 10.1.1.12"
> return $RC
> else
> - tst_resm TINFO "INIT: added alias: `ifconfig eth0:1`"
> + tst_resm TINFO "INIT: added alias: `ifconfig $INF:1`"
> fi
> fi
>
> @@ -148,7 +152,7 @@ init()
> # Function: cleanup
> #
> # Description - remove temporary files and directories.
> -# - remove alias to eth0
> +# - remove alias to $INF
> #
> # Return - zero on success
> # - non zero on failure. return value from commands ($RC)
> @@ -157,11 +161,11 @@ cleanup()
> TCID=dhcpd
> TST_COUNT=0
>
> - /sbin/ifconfig eth0:1 >$LTPTMP/tst_ip.err 2>&1
> + /sbin/ifconfig $INF:1 >$LTPTMP/tst_ip.err 2>&1
> RC=$?
> if [ $RC -eq 0 ]
> then
> - /sbin/ifconfig eth0:1 down >$LTPTMP/tst_ip.err 2>&1
> + /sbin/ifconfig $INF:1 down >$LTPTMP/tst_ip.err 2>&1
> fi
>
> rm -fr $LTPTMP
> @@ -189,11 +193,11 @@ test01()
> tst_resm TINFO \
> "Test #1: ip link set DEVICE mtu MTU changes the device mtu size"
>
> - tst_resm TINFO "Test #1: changing mtu size of eth0:1 device."
> + tst_resm TINFO "Test #1: changing mtu size of $INF:1 device."
>
> MTUSZ_BAK=`ifconfig eth0:1 | grep -i MTU | sed "s/^.*MTU://" \
> | awk '{print $1}'`
> - ip link set eth0:1 mtu 300 >$LTPTMP/tst_ip.err 2>&1
> + ip link set $INF:1 mtu 300 >$LTPTMP/tst_ip.err 2>&1
> if [ $RC -ne 0 ]
> then
> tst_res TFAIL $LTPTMP/tst_ip.err \
> @@ -204,7 +208,7 @@ test01()
> if [ $MTUSZ -eq 300 ]
> then
> tst_resm TPASS "Test #1: changing mtu size success"
> - ip link set eth0:1 mtu $MTUSZ_BAK \
> + ip link set $INF:1 mtu $MTUSZ_BAK \
> >$LTPTMP/tst_ip.err 2>&1
> else
> tst_resm FAIL NULL \
> @@ -256,7 +260,7 @@ test02()
> return $RC
> else
> tst_resm TPASS \
> - "Test #2: Listed eth0:1 and returned correct attributes"
> + "Test #2: Listed $INF:1 and returned correct attributes"
> fi
> return $RC
> }
> @@ -365,7 +369,7 @@ test04()
> return $RC
> else
> tst_resm TINFO \
> - "Test #4: ip neigh show - shows all neighbour entries in arp tables."
> + "Test #4: ip neigh show - shows all neighbour entries in arp tables."
>
> cat > $LTPTMP/tst_ip.exp <<-EOF
> 127.0.0.1 dev lo lladdr 00:00:00:00:00:00 REACHABLE
> @@ -443,14 +447,14 @@ test05()
>
>
> tst_resm TINFO \
> - "Test #5: create an interface with inet 10.6.6.6 alias to eth0"
> + "Test #5: create an interface with inet 10.6.6.6 alias to $INF"
>
> - ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1
> + ifconfig $INF:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1
> RC=$?
> if [ $RC -ne 0 ]
> then
> tst_brk TBROK $LTPTMP/tst_ip.err NULL \
> - "Test #5: unable to create interface eth0:1 inet 10.6.6.6. Reason:"
> + "Test #5: unable to create interface $INF:1 inet 10.6.6.6. Reason:"
> return $RC
> fi
>
> @@ -541,16 +545,16 @@ test06()
> tst_resm TINFO \
> "Test #6: ip maddr add - adds a new multicast addr"
>
> - ifconfig eth0:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1
> + ifconfig $INF:1 10.6.6.6 netmask 255.255.255.0 >$LTPTMP/tst_ip.err 2>&1
> RC=$?
> if [ $RC -ne 0 ]
> then
> tst_brk TBROK $LTPTMP/tst_ip.err NULL \
> - "Test #6: unable to create interface eth0:1 inet 10.6.6.6. Reason:"
> + "Test #6: unable to create interface $INF:1 inet 10.6.6.6. Reason:"
> return $RC
> fi
>
> - ip maddr add 66:66:00:00:00:66 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1
> + ip maddr add 66:66:00:00:00:66 dev $INF:1 >$LTPTMP/tst_ip.err 2>&1
> RC=$?
> if [ $RC -ne 0 ]
> then
> @@ -579,7 +583,7 @@ test06()
> if [ $RC -ne 0 ]
> then
> tst_res FAIL $LTPTMP/tst_ip.err \
> - "Test #6: multicast addr not added to eth0:1. Details:"
> + "Test #6: multicast addr not added to $INF:1. Details:"
> return $RC
> fi
> fi
> @@ -587,7 +591,7 @@ test06()
> tst_resm TINFO \
> "Test #6: ip maddr del - deletes multicast addr."
>
> - ip maddr del 66:66:00:00:00:66 dev eth0:1 >$LTPTMP/tst_ip.err 2>&1
> + ip maddr del 66:66:00:00:00:66 dev $INF:1 >$LTPTMP/tst_ip.err 2>&1
> RC=$?
> if [ $RC -ne 0 ]
> then
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH] ip_tests.sh: don't use hardcoded eth0
2014-03-28 5:08 ` Mike Frysinger
2014-04-09 6:09 ` Simon Xu
@ 2014-04-25 12:04 ` Stanislav Kholmanskikh
1 sibling, 0 replies; 8+ messages in thread
From: Stanislav Kholmanskikh @ 2014-04-25 12:04 UTC (permalink / raw)
To: Mike Frysinger, ltp-list, x >> "XU.SIMON"
Hi!
On 03/28/2014 09:08 AM, Mike Frysinger wrote:
> On Fri 28 Mar 2014 09:44:24 Simon Xu wrote:
>> The script uses hardcoded 'eth0' which used to work on most systems.
>> This fix tries to find a 'working' network interface using the hostname.
>
> why doesn't hardcoding "lo" work ?
> -mike
I think we can't use the loopback interface because test06 fails if
invoked with lo:
[root@kholmanskikh stas]# /sbin/ifconfig lo:1 1.2.3.4 netmask
255.255.255.0 up
[root@kholmanskikh stas]# /sbin/ip maddr add 66:66:00:00:00:66 dev lo:1
ioctl: Invalid argument
[root@kholmanskikh stas]# /sbin/ifconfig eth0:1 3.4.5.6 netmask
255.255.255.0 up
[root@kholmanskikh stas]# /sbin/ip maddr add 66:66:00:00:00:66 dev eth0:1
[root@kholmanskikh stas]#
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH] ip_tests.sh: don't use hardcoded eth0
2014-03-28 1:44 [LTP] [PATCH] ip_tests.sh: don't use hardcoded eth0 Simon Xu
` (2 preceding siblings ...)
2014-04-25 1:06 ` Simon Xu
@ 2014-04-25 12:26 ` Stanislav Kholmanskikh
3 siblings, 0 replies; 8+ messages in thread
From: Stanislav Kholmanskikh @ 2014-04-25 12:26 UTC (permalink / raw)
To: Simon Xu, ltp-list
Hi!
On 03/28/2014 05:44 AM, Simon Xu wrote:
> The script uses hardcoded 'eth0' which used to work on most systems.
> This fix tries to find a 'working' network interface using the hostname.
>
> Signed-off-by: Simon Xu <xu.simon@oracle.com>
> ---
> testcases/network/iproute/ip_tests.sh | 50 +++++++++++++++++++----------------
> 1 file changed, 27 insertions(+), 23 deletions(-)
>
> diff --git a/testcases/network/iproute/ip_tests.sh b/testcases/network/iproute/ip_tests.sh
> index ed20540..4bba243 100755
> --- a/testcases/network/iproute/ip_tests.sh
> +++ b/testcases/network/iproute/ip_tests.sh
> @@ -38,7 +38,7 @@ set +x
> # Description: - Check if command ip is available.
> # - Check if command ifconfig is available.
> # - check if command awk is available.
> -# - alias eth0 to eth0:1 with IP 10.1.1.12
> +# - alias $INF to $INF:1 with IP 10.1.1.12
> #
> # Return - zero on success
> # - non zero on failure. return value from commands ($RC)
> @@ -46,7 +46,7 @@ init()
> {
>
> export TST_TOTAL=2 # total numner of tests in this file.
> - export TCID="ip_tests " # this is the init function.
> + export TCID="ip_tests" # this is the init function.
> export TST_COUNT=0 # init identifier,
>
> if [ -z $TMP ]
> @@ -107,22 +107,26 @@ init()
>
> tst_resm TINFO "INIT: Inititalizing tests."
>
> - # Aliasing eth0 to create private network.
> - /sbin/ifconfig eth0:1 10.1.1.12 >$LTPTMP/tst_ip.err 2>&1
> + # Get network interface.
> + IP=$(dig +short $(hostname))
This would require that the $(hostname) is registered to DNS.
Given that we only need a working device (no matter what ip it has),
maybe just do something like:
/sbin/ifconfig | grep HWaddr | head -n 1
to get a L2-capable device.
What do you think?
> + INF=$(ifconfig|grep -B1 $IP|head -1|sed 's/:.*//')
> +
> + # Aliasing $INF to create private network.
> + /sbin/ifconfig $INF:1 10.1.1.12 >$LTPTMP/tst_ip.err 2>&1
> RC=$?
> if [ $RC -ne 0 ]
> then
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [LTP] [PATCH] ip_tests.sh: don't use hardcoded eth0
@ 2014-04-25 13:59 Joseph Beckenbach
0 siblings, 0 replies; 8+ messages in thread
From: Joseph Beckenbach @ 2014-04-25 13:59 UTC (permalink / raw)
To: ltp-list@lists.sourceforge.net
Hi, Simon!
> Could anyone help to review this?
At least one of the existing network scripts does this, not sure which one.
It annoyed my lab-mates when it started sending on an interface I didn't want it to send on.
I'd like to see documented in the top-level INSTALL that the hostname needs to corresponds to the network-interface intended for test traffic.
(That would go with the rest of the network-test preparation instructions.)
And also that other tests which hard-code eth0 or any other interface also do this check.
Maybe an environment variable can specify preference, then fall back to hostname check like you propose in your patch?
Joseph
------------------------------------------------------------------------------
Start Your Social Network Today - Download eXo Platform
Build your Enterprise Intranet with eXo Platform Software
Java Based Open Source Intranet - Social, Extensible, Cloud Ready
Get Started Now And Turn Your Intranet Into A Collaboration Platform
http://p.sf.net/sfu/ExoPlatform
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2014-04-25 13:59 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-28 1:44 [LTP] [PATCH] ip_tests.sh: don't use hardcoded eth0 Simon Xu
2014-03-28 5:08 ` Mike Frysinger
2014-04-09 6:09 ` Simon Xu
2014-04-25 12:04 ` Stanislav Kholmanskikh
2014-04-09 6:10 ` Simon Xu
2014-04-25 1:06 ` Simon Xu
2014-04-25 12:26 ` Stanislav Kholmanskikh
-- strict thread matches above, loose matches on Subject: below --
2014-04-25 13:59 Joseph Beckenbach
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox