Skip to content

Commit 3368b22

Browse files
pmachatadavem330
authored andcommitted
selftests: forwarding: lib: Extract interface-init functions
The function simple_if_init() does two things: it creates a VRF, then moves an interface into this VRF and configures addresses. The latter comes in handy when adding more interfaces into a VRF later on. The situation is similar for simple_if_fini(). Therefore split the interface remastering and address de/initialization logic to a new pair of helpers __simple_if_init() / __simple_if_fini(), and defer to these helpers from simple_if_init() and simple_if_fini(). Signed-off-by: Petr Machata <petrm@mellanox.com> Reviewed-by: Ido Schimmel <idosch@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent a66d62d commit 3368b22

File tree

1 file changed

+25
-7
lines changed
  • tools/testing/selftests/net/forwarding

1 file changed

+25
-7
lines changed

tools/testing/selftests/net/forwarding/lib.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,29 @@ __addr_add_del()
287287
done
288288
}
289289

290+
__simple_if_init()
291+
{
292+
local if_name=$1; shift
293+
local vrf_name=$1; shift
294+
local addrs=("${@}")
295+
296+
ip link set dev $if_name master $vrf_name
297+
ip link set dev $if_name up
298+
299+
__addr_add_del $if_name add "${addrs[@]}"
300+
}
301+
302+
__simple_if_fini()
303+
{
304+
local if_name=$1; shift
305+
local addrs=("${@}")
306+
307+
__addr_add_del $if_name del "${addrs[@]}"
308+
309+
ip link set dev $if_name down
310+
ip link set dev $if_name nomaster
311+
}
312+
290313
simple_if_init()
291314
{
292315
local if_name=$1
@@ -298,11 +321,8 @@ simple_if_init()
298321
array=("${@}")
299322

300323
vrf_create $vrf_name
301-
ip link set dev $if_name master $vrf_name
302324
ip link set dev $vrf_name up
303-
ip link set dev $if_name up
304-
305-
__addr_add_del $if_name add "${array[@]}"
325+
__simple_if_init $if_name $vrf_name "${array[@]}"
306326
}
307327

308328
simple_if_fini()
@@ -315,9 +335,7 @@ simple_if_fini()
315335
vrf_name=v$if_name
316336
array=("${@}")
317337

318-
__addr_add_del $if_name del "${array[@]}"
319-
320-
ip link set dev $if_name down
338+
__simple_if_fini $if_name "${array[@]}"
321339
vrf_destroy $vrf_name
322340
}
323341

0 commit comments

Comments
 (0)