~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/drivers/net/virtio_net/basic_features.sh

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #!/bin/bash
  2 # SPDX-License-Identifier: GPL-2.0
  3 
  4 # See virtio_net_common.sh comments for more details about assumed setup
  5 
  6 ALL_TESTS="
  7         initial_ping_test
  8         f_mac_test
  9 "
 10 
 11 source virtio_net_common.sh
 12 
 13 lib_dir=$(dirname "$0")
 14 source "$lib_dir"/../../../net/forwarding/lib.sh
 15 
 16 h1=${NETIFS[p1]}
 17 h2=${NETIFS[p2]}
 18 
 19 h1_create()
 20 {
 21         simple_if_init $h1 $H1_IPV4/24 $H1_IPV6/64
 22 }
 23 
 24 h1_destroy()
 25 {
 26         simple_if_fini $h1 $H1_IPV4/24 $H1_IPV6/64
 27 }
 28 
 29 h2_create()
 30 {
 31         simple_if_init $h2 $H2_IPV4/24 $H2_IPV6/64
 32 }
 33 
 34 h2_destroy()
 35 {
 36         simple_if_fini $h2 $H2_IPV4/24 $H2_IPV6/64
 37 }
 38 
 39 initial_ping_test()
 40 {
 41         setup_cleanup
 42         setup_prepare
 43         ping_test $h1 $H2_IPV4 " simple"
 44 }
 45 
 46 f_mac_test()
 47 {
 48         RET=0
 49         local test_name="mac feature filtered"
 50 
 51         virtio_feature_present $h1 $VIRTIO_NET_F_MAC
 52         if [ $? -ne 0 ]; then
 53                 log_test_skip "$test_name" "Device $h1 is missing feature $VIRTIO_NET_F_MAC."
 54                 return 0
 55         fi
 56         virtio_feature_present $h1 $VIRTIO_NET_F_MAC
 57         if [ $? -ne 0 ]; then
 58                 log_test_skip "$test_name" "Device $h2 is missing feature $VIRTIO_NET_F_MAC."
 59                 return 0
 60         fi
 61 
 62         setup_cleanup
 63         setup_prepare
 64 
 65         grep -q 0 /sys/class/net/$h1/addr_assign_type
 66         check_err $? "Permanent address assign type for $h1 is not set"
 67         grep -q 0 /sys/class/net/$h2/addr_assign_type
 68         check_err $? "Permanent address assign type for $h2 is not set"
 69 
 70         setup_cleanup
 71         virtio_filter_feature_add $h1 $VIRTIO_NET_F_MAC
 72         virtio_filter_feature_add $h2 $VIRTIO_NET_F_MAC
 73         setup_prepare
 74 
 75         grep -q 0 /sys/class/net/$h1/addr_assign_type
 76         check_fail $? "Permanent address assign type for $h1 is set when F_MAC feature is filtered"
 77         grep -q 0 /sys/class/net/$h2/addr_assign_type
 78         check_fail $? "Permanent address assign type for $h2 is set when F_MAC feature is filtered"
 79 
 80         ping_do $h1 $H2_IPV4
 81         check_err $? "Ping failed"
 82 
 83         log_test "$test_name"
 84 }
 85 
 86 setup_prepare()
 87 {
 88         virtio_device_rebind $h1
 89         virtio_device_rebind $h2
 90         wait_for_dev $h1
 91         wait_for_dev $h2
 92 
 93         vrf_prepare
 94 
 95         h1_create
 96         h2_create
 97 }
 98 
 99 setup_cleanup()
100 {
101         h2_destroy
102         h1_destroy
103 
104         vrf_cleanup
105 
106         virtio_filter_features_clear $h1
107         virtio_filter_features_clear $h2
108         virtio_device_rebind $h1
109         virtio_device_rebind $h2
110         wait_for_dev $h1
111         wait_for_dev $h2
112 }
113 
114 cleanup()
115 {
116         pre_cleanup
117         setup_cleanup
118 }
119 
120 check_driver $h1 "virtio_net"
121 check_driver $h2 "virtio_net"
122 check_virtio_debugfs $h1
123 check_virtio_debugfs $h2
124 
125 trap cleanup EXIT
126 
127 setup_prepare
128 
129 tests_run
130 
131 exit "$EXIT_STATUS"

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php