Page MenuHomeFreeBSD

D55363.id.diff
No OneTemporary

D55363.id.diff

diff --git a/tests/sys/net/Makefile b/tests/sys/net/Makefile
--- a/tests/sys/net/Makefile
+++ b/tests/sys/net/Makefile
@@ -10,6 +10,7 @@
TEST_METADATA.if_bridge_test+= execenv_jail_params="vnet allow.raw_sockets"
ATF_TESTS_SH+= if_clone_test
ATF_TESTS_SH+= if_gif
+ATF_TESTS_SH+= if_gre
ATF_TESTS_SH+= if_lagg_test
ATF_TESTS_SH+= if_stf
ATF_TESTS_SH+= if_tun_test
diff --git a/tests/sys/net/if_gre.sh b/tests/sys/net/if_gre.sh
new file mode 100644
--- /dev/null
+++ b/tests/sys/net/if_gre.sh
@@ -0,0 +1,486 @@
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+# Copyright (c) 2026 Pouria Mousavizadeh Tehrani <pouria@FreeBSD.org>
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+
+. $(atf_get_srcdir)/../common/vnet.subr
+
+atf_test_case "gre4_basic" "cleanup"
+gre4_basic_head()
+{
+ atf_set descr 'Create a gre(4) tunnel over ipv4 underlay'
+ atf_set require.user root
+}
+
+gre4_basic_body()
+{
+ local epair endpoint1 endpoint2
+ local v4tunnel1 v4tunnel2 v6tunnel1 v6tunnel2
+
+ endpoint1=192.168.2.1
+ endpoint2=192.168.2.2
+ v4tunnel1=169.254.0.1
+ v4tunnel2=169.254.0.2
+ v6tunnel1=2001:db8::1
+ v6tunnel2=2001:db8::2
+
+ if ! kldstat -qm if_gre; then
+ atf_skip "This test requires if_gre"
+ fi
+
+ vnet_init
+ epair=$(vnet_mkepair)
+ vnet_mkjail gretest1 ${epair}a
+ vnet_mkjail gretest2 ${epair}b
+
+ ifconfig -j gretest1 ${epair}a inet ${endpoint1}/30 up
+ ifconfig -j gretest2 ${epair}b inet ${endpoint2}/30 up
+
+ # Sanity check
+ atf_check -s exit:0 -o ignore \
+ jexec gretest1 ping -c 1 -t 3 ${endpoint2}
+ atf_check -s exit:0 -o ignore \
+ jexec gretest2 ping -c 1 -t 3 ${endpoint1}
+
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 create inet tunnel ${endpoint1} ${endpoint2} up
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 create inet tunnel ${endpoint2} ${endpoint1} up
+
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 inet ${v4tunnel1} ${v4tunnel2}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 inet6 ${v6tunnel1}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 inet ${v4tunnel2} ${v4tunnel1}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 inet6 ${v6tunnel2}
+
+ # Tunnel test
+ atf_check -s exit:0 -o ignore jexec gretest1 ping -nc 1 -t 1 $v4tunnel2
+ atf_check -s exit:0 -o ignore jexec gretest2 ping -nc 1 -t 1 $v4tunnel1
+ atf_check -s exit:0 -o ignore jexec gretest1 ping -nc 1 -t 1 $v6tunnel2
+ atf_check -s exit:0 -o ignore jexec gretest2 ping -nc 1 -t 1 $v6tunnel1
+}
+
+gre4_basic_cleanup()
+{
+ vnet_cleanup
+}
+
+atf_test_case "gre6_basic" "cleanup"
+gre6_basic_head()
+{
+ atf_set descr 'Create a gre(4) tunnel over ipv6 underlay'
+ atf_set require.user root
+}
+
+gre6_basic_body()
+{
+ local epair endpoint1 endpoint2
+ local v4tunnel1 v4tunnel2 v6tunnel1 v6tunnel2
+
+ endpoint1=3fff::1
+ endpoint2=3fff::2
+ v4tunnel1=169.254.0.1
+ v4tunnel2=169.254.0.2
+ v6tunnel1=2001:db8::1
+ v6tunnel2=2001:db8::2
+
+ if ! kldstat -qm if_gre; then
+ atf_skip "This test requires if_gre"
+ fi
+
+ vnet_init
+ epair=$(vnet_mkepair)
+ vnet_mkjail gretest1 ${epair}a
+ vnet_mkjail gretest2 ${epair}b
+
+ ifconfig -j gretest1 ${epair}a inet6 ${endpoint1} up
+ ifconfig -j gretest2 ${epair}b inet6 ${endpoint2} up
+
+ # Sanity check
+ atf_check -s exit:0 -o ignore \
+ jexec gretest1 ping -c 1 -t 3 ${endpoint2}
+ atf_check -s exit:0 -o ignore \
+ jexec gretest2 ping -c 1 -t 3 ${endpoint1}
+
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 create inet6 tunnel ${endpoint1} ${endpoint2} up
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 create inet6 tunnel ${endpoint2} ${endpoint1} up
+
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 inet ${v4tunnel1} ${v4tunnel2}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 inet6 ${v6tunnel1}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 inet ${v4tunnel2} ${v4tunnel1}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 inet6 ${v6tunnel2}
+
+ # Tunnel test
+ atf_check -s exit:0 -o ignore jexec gretest1 ping -nc 1 -t 1 $v4tunnel2
+ atf_check -s exit:0 -o ignore jexec gretest2 ping -nc 1 -t 1 $v4tunnel1
+ atf_check -s exit:0 -o ignore jexec gretest1 ping -nc 1 -t 1 $v6tunnel2
+ atf_check -s exit:0 -o ignore jexec gretest2 ping -nc 1 -t 1 $v6tunnel1
+}
+
+gre6_basic_cleanup()
+{
+ vnet_cleanup
+}
+
+atf_test_case "gre6_csum" "cleanup"
+gre6_csum_head()
+{
+ atf_set descr 'Create a gre(4) tunnel over ipv6 underlay with checksum option'
+ atf_set require.user root
+}
+
+gre6_csum_body()
+{
+ local epair endpoint1 endpoint2
+ local v4tunnel1 v4tunnel2 v6tunnel1 v6tunnel2
+
+ endpoint1=3fff::1
+ endpoint2=3fff::2
+ v4tunnel1=169.254.0.1
+ v4tunnel2=169.254.0.2
+ v6tunnel1=2001:db8::1
+ v6tunnel2=2001:db8::2
+
+ if ! kldstat -qm if_gre; then
+ atf_skip "This test requires if_gre"
+ fi
+
+ vnet_init
+ epair=$(vnet_mkepair)
+ vnet_mkjail gretest1 ${epair}a
+ vnet_mkjail gretest2 ${epair}b
+
+ ifconfig -j gretest1 ${epair}a inet6 ${endpoint1} up
+ ifconfig -j gretest2 ${epair}b inet6 ${endpoint2} up
+
+ # Sanity check
+ atf_check -s exit:0 -o ignore \
+ jexec gretest1 ping -c 1 -t 3 ${endpoint2}
+ atf_check -s exit:0 -o ignore \
+ jexec gretest2 ping -c 1 -t 3 ${endpoint1}
+
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 create inet6 tunnel ${endpoint1} ${endpoint2} \
+ enable_csum up
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 create inet6 tunnel ${endpoint2} ${endpoint1} \
+ enable_csum up
+
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 inet ${v4tunnel1} ${v4tunnel2}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 inet6 ${v6tunnel1}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 inet ${v4tunnel2} ${v4tunnel1}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 inet6 ${v6tunnel2}
+
+ # ifconfig test
+ atf_check -s exit:0 -o match:"ENABLE_CSUM" ifconfig -j gretest1 gre1
+ atf_check -s exit:0 -o match:"ENABLE_CSUM" ifconfig -j gretest2 gre1
+
+ # Tunnel test
+ atf_check -s exit:0 -o ignore jexec gretest1 ping -nc 1 -t 1 $v4tunnel2
+ atf_check -s exit:0 -o ignore jexec gretest2 ping -nc 1 -t 1 $v4tunnel1
+ atf_check -s exit:0 -o ignore jexec gretest1 ping -nc 1 -t 1 $v6tunnel2
+ atf_check -s exit:0 -o ignore jexec gretest2 ping -nc 1 -t 1 $v6tunnel1
+}
+
+gre6_csum_cleanup()
+{
+ vnet_cleanup
+}
+
+
+atf_test_case "gre6_key" "cleanup"
+gre6_key_head()
+{
+ atf_set descr 'Create a gre(4) tunnel over ipv6 underlay with gre key option'
+ atf_set require.user root
+}
+
+gre6_key_body()
+{
+ local epair endpoint1 endpoint2
+ local v4tunnel1 v4tunnel2 v6tunnel1 v6tunnel2
+
+ endpoint1=3fff::1
+ endpoint2=3fff::2
+ v4tunnel1=169.254.0.1
+ v4tunnel2=169.254.0.2
+ v6tunnel1=2001:db8::1
+ v6tunnel2=2001:db8::2
+
+ if ! kldstat -qm if_gre; then
+ atf_skip "This test requires if_gre"
+ fi
+
+ vnet_init
+ epair=$(vnet_mkepair)
+ vnet_mkjail gretest1 ${epair}a
+ vnet_mkjail gretest2 ${epair}b
+
+ ifconfig -j gretest1 ${epair}a inet6 ${endpoint1} up
+ ifconfig -j gretest2 ${epair}b inet6 ${endpoint2} up
+
+ # Sanity check
+ atf_check -s exit:0 -o ignore \
+ jexec gretest1 ping -c 1 -t 3 ${endpoint2}
+ atf_check -s exit:0 -o ignore \
+ jexec gretest2 ping -c 1 -t 3 ${endpoint1}
+
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 create inet6 tunnel ${endpoint1} ${endpoint2} \
+ grekey 10 up
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 create inet6 tunnel ${endpoint2} ${endpoint1} \
+ grekey 10 up
+
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 inet ${v4tunnel1} ${v4tunnel2}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 inet6 ${v6tunnel1}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 inet ${v4tunnel2} ${v4tunnel1}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 inet6 ${v6tunnel2}
+
+ # ifconfig test
+ atf_check -s exit:0 -o match:"grekey: 0xa \(10\)" ifconfig -j gretest1 gre1
+ atf_check -s exit:0 -o match:"grekey: 0xa \(10\)" ifconfig -j gretest2 gre1
+
+ # Tunnel test
+ atf_check -s exit:0 -o ignore jexec gretest1 ping -nc 1 -t 1 $v4tunnel2
+ atf_check -s exit:0 -o ignore jexec gretest2 ping -nc 1 -t 1 $v4tunnel1
+ atf_check -s exit:0 -o ignore jexec gretest1 ping -nc 1 -t 1 $v6tunnel2
+ atf_check -s exit:0 -o ignore jexec gretest2 ping -nc 1 -t 1 $v6tunnel1
+}
+
+gre6_key_cleanup()
+{
+ vnet_cleanup
+}
+
+atf_test_case "gre6_seq" "cleanup"
+gre6_seq_head()
+{
+ atf_set descr 'Create a sequenced gre(4) tunnel over ipv6 underlay'
+ atf_set require.user root
+}
+
+gre6_seq_body()
+{
+ local epair endpoint1 endpoint2
+ local v4tunnel1 v4tunnel2 v6tunnel1 v6tunnel2
+
+ endpoint1=3fff::1
+ endpoint2=3fff::2
+ v4tunnel1=169.254.0.1
+ v4tunnel2=169.254.0.2
+ v6tunnel1=2001:db8::1
+ v6tunnel2=2001:db8::2
+
+ if ! kldstat -qm if_gre; then
+ atf_skip "This test requires if_gre"
+ fi
+
+ vnet_init
+ epair=$(vnet_mkepair)
+ vnet_mkjail gretest1 ${epair}a
+ vnet_mkjail gretest2 ${epair}b
+
+ ifconfig -j gretest1 ${epair}a inet6 ${endpoint1} up
+ ifconfig -j gretest2 ${epair}b inet6 ${endpoint2} up
+
+ # Sanity check
+ atf_check -s exit:0 -o ignore \
+ jexec gretest1 ping -c 1 -t 3 ${endpoint2}
+ atf_check -s exit:0 -o ignore \
+ jexec gretest2 ping -c 1 -t 3 ${endpoint1}
+
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 create inet6 tunnel ${endpoint1} ${endpoint2} \
+ enable_seq up
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 create inet6 tunnel ${endpoint2} ${endpoint1} \
+ enable_seq up
+
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 inet ${v4tunnel1} ${v4tunnel2}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 inet6 ${v6tunnel1}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 inet ${v4tunnel2} ${v4tunnel1}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 inet6 ${v6tunnel2}
+
+ # ifconfig test
+ atf_check -s exit:0 -o match:"ENABLE_SEQ" ifconfig -j gretest1 gre1
+ atf_check -s exit:0 -o match:"ENABLE_SEQ" ifconfig -j gretest2 gre1
+
+ # Tunnel test
+ atf_check -s exit:0 -o ignore jexec gretest1 ping -nc 1 -t 1 $v4tunnel2
+ atf_check -s exit:0 -o ignore jexec gretest2 ping -nc 1 -t 1 $v4tunnel1
+ atf_check -s exit:0 -o ignore jexec gretest1 ping -nc 1 -t 1 $v6tunnel2
+ atf_check -s exit:0 -o ignore jexec gretest2 ping -nc 1 -t 1 $v6tunnel1
+}
+
+gre6_seq_cleanup()
+{
+ vnet_cleanup
+}
+
+atf_test_case "gre6_udpencap" "cleanup"
+gre6_udpencap_head()
+{
+ atf_set descr 'Create a gre(4) over UDP tunnel with ipv6 underlay'
+ atf_set require.user root
+}
+
+gre6_udpencap_body()
+{
+ local epair endpoint1 endpoint2
+ local v4tunnel1 v4tunnel2 v6tunnel1 v6tunnel2
+
+ endpoint1=3fff::1
+ endpoint2=3fff::2
+ v4tunnel1=169.254.0.1
+ v4tunnel2=169.254.0.2
+ v6tunnel1=2001:db8::1
+ v6tunnel2=2001:db8::2
+
+ if ! kldstat -qm if_gre; then
+ atf_skip "This test requires if_gre"
+ fi
+
+ vnet_init
+ epair=$(vnet_mkepair)
+ vnet_mkjail gretest1 ${epair}a
+ vnet_mkjail gretest2 ${epair}b
+
+ ifconfig -j gretest1 ${epair}a inet6 ${endpoint1} up
+ ifconfig -j gretest2 ${epair}b inet6 ${endpoint2} up
+
+ # Sanity check
+ atf_check -s exit:0 -o ignore \
+ jexec gretest1 ping -c 1 -t 3 ${endpoint2}
+ atf_check -s exit:0 -o ignore \
+ jexec gretest2 ping -c 1 -t 3 ${endpoint1}
+
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 create inet6 tunnel ${endpoint1} ${endpoint2} \
+ udpencap up
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 create inet6 tunnel ${endpoint2} ${endpoint1} \
+ udpencap udpport 55555 up
+
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 inet ${v4tunnel1} ${v4tunnel2}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest1 gre1 inet6 ${v6tunnel1}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 inet ${v4tunnel2} ${v4tunnel1}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest2 gre1 inet6 ${v6tunnel2}
+
+ # ifconfig test
+ atf_check -s exit:0 -o match:"UDPENCAP" ifconfig -j gretest1 gre1
+ atf_check -s exit:0 -o match:"udpport: 55555" ifconfig -j gretest2 gre1
+
+ # Tunnel test
+ atf_check -s exit:0 -o ignore jexec gretest1 ping -nc 1 -t 1 $v4tunnel2
+ atf_check -s exit:0 -o ignore jexec gretest2 ping -nc 1 -t 1 $v4tunnel1
+ atf_check -s exit:0 -o ignore jexec gretest1 ping -nc 1 -t 1 $v6tunnel2
+ atf_check -s exit:0 -o ignore jexec gretest2 ping -nc 1 -t 1 $v6tunnel1
+}
+
+gre6_udpencap_cleanup()
+{
+ vnet_cleanup
+}
+
+atf_test_case "gre_blind_options" "cleanup"
+gre_blind_options_head()
+{
+ atf_set descr 'Create a gre(4) tunnel to test gre options blindly'
+ atf_set require.user root
+}
+
+gre_blind_options_body()
+{
+ local gre
+
+ v4tunnel1=169.254.0.1
+ v4tunnel2=169.254.0.2
+ v6tunnel1=2001:db8::1
+ v6tunnel2=2001:db8::2
+
+ if ! kldstat -qm if_gre; then
+ atf_skip "This test requires if_gre"
+ fi
+
+ vnet_init
+ vnet_mkjail gretest
+
+ gre=$(ifconfig -j gretest gre create \
+ enable_seq grekey 10 enable_csum udpencap udpport 55555 up)
+
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest $gre inet ${v4tunnel1} ${v4tunnel2}
+ atf_check -s exit:0 -o ignore \
+ ifconfig -j gretest $gre inet6 ${v6tunnel1}
+
+ # ifconfig test
+ atf_check -s exit:0 -o match:"grekey: 0xa \(10\)" ifconfig -j gretest $gre
+ atf_check -s exit:0 -o match:"ENABLE_CSUM" ifconfig -j gretest $gre
+ atf_check -s exit:0 -o match:"ENABLE_SEQ" ifconfig -j gretest $gre
+ atf_check -s exit:0 -o match:"UDPENCAP" ifconfig -j gretest $gre
+ atf_check -s exit:0 -o match:"udpport: 55555" ifconfig -j gretest $gre
+}
+
+gre_blind_options_cleanup()
+{
+ vnet_cleanup
+}
+
+
+atf_init_test_cases()
+{
+ atf_add_test_case "gre4_basic"
+ atf_add_test_case "gre6_basic"
+ atf_add_test_case "gre6_csum"
+ atf_add_test_case "gre6_key"
+ atf_add_test_case "gre6_seq"
+ atf_add_test_case "gre6_udpencap"
+ atf_add_test_case "gre_blind_options"
+}

File Metadata

Mime Type
text/plain
Expires
Fri, May 22, 10:23 AM (2 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33418658
Default Alt Text
D55363.id.diff (14 KB)

Event Timeline