git: 6e439506408d - main - bridge tests: test changing the bridge MTU

Kristof Provost kp at FreeBSD.org
Wed Jul 28 20:07:26 UTC 2021


The branch main has been updated by kp:

URL: https://cgit.FreeBSD.org/src/commit/?id=6e439506408d36a663e666d35a340595539270a4

commit 6e439506408d36a663e666d35a340595539270a4
Author:     Kristof Provost <kp at FreeBSD.org>
AuthorDate: 2021-07-23 15:46:10 +0000
Commit:     Kristof Provost <kp at FreeBSD.org>
CommitDate: 2021-07-28 20:01:12 +0000

    bridge tests: test changing the bridge MTU
    
    Changing the bridge MTU will now also change all of the member interface
    MTUs. Test this.
    
    Reviewed by:    donner
    Sponsored by:   Rubicon Communications, LLC ("Netgate")
    Differential Revision:  https://reviews.freebsd.org/D31289
---
 tests/sys/net/if_bridge_test.sh | 68 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/tests/sys/net/if_bridge_test.sh b/tests/sys/net/if_bridge_test.sh
index b029d8d60419..da797f4fd39a 100755
--- a/tests/sys/net/if_bridge_test.sh
+++ b/tests/sys/net/if_bridge_test.sh
@@ -517,6 +517,73 @@ gif_cleanup()
 	vnet_cleanup
 }
 
+atf_test_case "mtu" "cleanup"
+mtu_head()
+{
+	atf_set descr 'Bridge MTU changes'
+	atf_set require.user root
+}
+
+get_mtu()
+{
+	intf=$1
+
+	ifconfig ${intf} ether | awk '$5 == "mtu" { print $6 }'
+}
+
+check_mtu()
+{
+	intf=$1
+	expected=$2
+
+	mtu=$(get_mtu $intf)
+	if [ $mtu -ne $expected ];
+	then
+		atf_fail "Expected MTU of $expected on $intf but found $mtu"
+	fi
+}
+
+mtu_body()
+{
+	vnet_init
+
+	epair=$(vnet_mkepair)
+	gif=$(ifconfig gif create)
+	echo ${gif} >> created_interfaces.lst
+	bridge=$(vnet_mkbridge)
+
+	atf_check -s exit:0 \
+		ifconfig ${bridge} addm ${epair}a
+	# Can't add an interface with an MTU mismatch
+	atf_check -s exit:1 -e ignore \
+		ifconfig ${bridge} addm ${gif}
+
+	ifconfig ${gif} mtu 1500
+	atf_check -s exit:0 \
+		ifconfig ${bridge} addm ${gif}
+
+	# Changing MTU changes it for all member interfaces
+	atf_check -s exit:0 \
+		ifconfig ${bridge} mtu 2000
+
+	check_mtu ${bridge} 2000
+	check_mtu ${gif} 2000
+	check_mtu ${epair}a 2000
+
+	# Rejected MTUs mean none of the MTUs change
+	atf_check -s exit:1 -e ignore \
+		ifconfig ${bridge} mtu 9000
+
+	check_mtu ${bridge} 2000
+	check_mtu ${gif} 2000
+	check_mtu ${epair}a 2000
+}
+
+mtu_cleanup()
+{
+	vnet_cleanup
+}
+
 atf_init_test_cases()
 {
 	atf_add_test_case "bridge_transmit_ipv4_unicast"
@@ -529,4 +596,5 @@ atf_init_test_cases()
 	atf_add_test_case "mac_conflict"
 	atf_add_test_case "stp_validation"
 	atf_add_test_case "gif"
+	atf_add_test_case "mtu"
 }


More information about the dev-commits-src-all mailing list