File: get_dev

package info (click to toggle)
vip-manager 1.0.2-6
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 436 kB
  • sloc: sh: 316; makefile: 44
file content (22 lines) | stat: -rw-r--r-- 802 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
--- a/test/behaviour_test.sh
+++ b/test/behaviour_test.sh
@@ -13,17 +13,8 @@ function get_dev {
     # select a suitable device for testing purposes
     # * a device that is an "ether"
     # * and isn't a nil hardware address
-
-    # https://www.kernel.org/doc/Documentation/ABI/testing/sysfs-class-net
-    ARPHRD_ETHER=1
-
-    for dev in /sys/class/net/* ; do
-        test ! -e "$dev/address" && continue
-        test "`cat $dev/address`" = "00:00:00:00:00:00" && continue
-        test "`cat $dev/type`" != "$ARPHRD_ETHER" && continue
-        basename "$dev"
-        break
-    done
+    # strip suffix from name (veth3@if8 -> veth3)
+    ip -oneline link show | grep link/ether | grep state.UP | grep -v 00:00:00:00:00:00 | cut -d ":" -f2 | cut -d "@" -f 1 | head -n1
 }
 
 dev="`get_dev`"