diff options
author | Nobuhiro MIKI <nmiki@yahoo-corp.jp> | 2023-03-29 14:51:14 +0900 |
---|---|---|
committer | Ilya Maximets <i.maximets@ovn.org> | 2023-03-29 21:41:27 +0200 |
commit | 0db74e0eb41b1cd105d7ef2d27d55af47cc7cf87 (patch) | |
tree | 163bc245fcf812e16c8405f3898ce0a873ddd048 | |
parent | b354cee2e0a79a5fbe7140e964bb30e7c57919d6 (diff) | |
download | openvswitch-0db74e0eb41b1cd105d7ef2d27d55af47cc7cf87.tar.gz |
tests: Define new ADD_VETH_NS macro.
The new ADD_VETH_NS macro creates two netns and connects them
with a veth pair. We can use it for testing in a generic purpose.
e.g.
ADD_VETH_NS([ns1], [p1], [1.1.1.1/24], [ns2], [p2], [1.1.1.2/24])
Signed-off-by: Nobuhiro MIKI <nmiki@yahoo-corp.jp>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
-rw-r--r-- | tests/system-common-macros.at | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/tests/system-common-macros.at b/tests/system-common-macros.at index 8b9f5c752..0077a8609 100644 --- a/tests/system-common-macros.at +++ b/tests/system-common-macros.at @@ -126,6 +126,22 @@ m4_define([ADD_VETH_BOND], ] ) +# ADD_VETH_NS([ns1], [port1], [ip_addr1], [ns2], [port2], [ip_addr2]) +# +# Add a pair of veth ports in 'ns1' and 'ns2'. The port names are 'port1' +# and 'port2' respectively, and the IP addresses 'ip_addr1' and 'ip_addr2' +# are assigned to each port. +m4_define([ADD_VETH_NS], + [ AT_CHECK([ip link add $2 type veth peer name $5]), + AT_CHECK([ip link set $2 netns $1]) + AT_CHECK([ip link set $5 netns $4]) + NS_CHECK_EXEC([$1], [ip link set $2 up]) + NS_CHECK_EXEC([$4], [ip link set $5 up]) + NS_CHECK_EXEC([$1], [ip addr add $3 dev $2]) + NS_CHECK_EXEC([$4], [ip addr add $6 dev $5]) + ] +) + # ADD_VLAN([port], [namespace], [vlan-id], [ip-addr]) # # Add a VLAN device named 'port' within 'namespace'. It will be configured |