Skip to content

Commit

Permalink
vnet tests: check for if_bridge.ko
Browse files Browse the repository at this point in the history
A number of tests create a bridge, but did not check if if_bridge.ko is loaded.

We usually get away with that, because `ifconfig bridge create` autoloads the
module, but if we run the tests in a jail (e.g. because of kyua's upcoming
execenv.jail.params feature) we can't load the module and these tests can fail.

Check if the module is loaded, skip the test if it is not.

Reviewed by:	markj
MFC after:	1 week
Event:		Kitchener-Waterloo Hackathon 202406
Differential Revision:	https://reviews.freebsd.org/D45487
  • Loading branch information
kprovost committed Jun 4, 2024
1 parent 0570440 commit 480ad40
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 3 deletions.
7 changes: 7 additions & 0 deletions tests/sys/common/vnet.subr
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ vnet_mkepair()
echo ${ifname%a}
}

vnet_init_bridge()
{
if ! kldstat -q -m if_bridge; then
atf_skip "This test requires if_bridge"
fi
}

vnet_mkbridge()
{
ifname=$(ifconfig bridge create)
Expand Down
13 changes: 13 additions & 0 deletions tests/sys/net/if_bridge_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ bridge_transmit_ipv4_unicast_head()
bridge_transmit_ipv4_unicast_body()
{
vnet_init
vnet_init_bridge

epair_alcatraz=$(vnet_mkepair)
epair_singsing=$(vnet_mkepair)
Expand Down Expand Up @@ -76,6 +77,7 @@ stp_head()
stp_body()
{
vnet_init
vnet_init_bridge

epair_one=$(vnet_mkepair)
epair_two=$(vnet_mkepair)
Expand Down Expand Up @@ -142,6 +144,7 @@ stp_vlan_head()
stp_vlan_body()
{
vnet_init
vnet_init_bridge

epair_one=$(vnet_mkepair)
epair_two=$(vnet_mkepair)
Expand Down Expand Up @@ -216,6 +219,7 @@ static_head()
static_body()
{
vnet_init
vnet_init_bridge

epair=$(vnet_mkepair)
bridge=$(vnet_mkbridge)
Expand Down Expand Up @@ -273,6 +277,7 @@ span_head()
span_body()
{
vnet_init
vnet_init_bridge

epair=$(vnet_mkepair)
epair_span=$(vnet_mkepair)
Expand Down Expand Up @@ -326,6 +331,7 @@ delete_with_members_head()
delete_with_members_body()
{
vnet_init
vnet_init_bridge

bridge=$(vnet_mkbridge)
epair=$(vnet_mkepair)
Expand All @@ -352,6 +358,7 @@ mac_conflict_head()
mac_conflict_body()
{
vnet_init
vnet_init_bridge

epair=$(vnet_mkepair)

Expand Down Expand Up @@ -390,6 +397,7 @@ inherit_mac_head()
inherit_mac_body()
{
vnet_init
vnet_init_bridge

bridge=$(vnet_mkbridge)
epair=$(vnet_mkepair)
Expand Down Expand Up @@ -418,6 +426,7 @@ stp_validation_head()
stp_validation_body()
{
vnet_init
vnet_init_bridge

epair_one=$(vnet_mkepair)
epair_two=$(vnet_mkepair)
Expand Down Expand Up @@ -461,6 +470,7 @@ gif_head()
gif_body()
{
vnet_init
vnet_init_bridge

epair=$(vnet_mkepair)

Expand Down Expand Up @@ -545,6 +555,7 @@ check_mtu()
mtu_body()
{
vnet_init
vnet_init_bridge

epair=$(vnet_mkepair)
gif=$(ifconfig gif create)
Expand Down Expand Up @@ -606,6 +617,7 @@ vlan_head()
vlan_body()
{
vnet_init
vnet_init_bridge

vid=1

Expand Down Expand Up @@ -673,6 +685,7 @@ many_bridge_members_head()
many_bridge_members_body()
{
vnet_init
vnet_init_bridge

bridge=$(vnet_mkbridge)
ifcount=256
Expand Down
2 changes: 2 additions & 0 deletions tests/sys/net/if_ovpn/if_ovpn.sh
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,7 @@ multi_client_head()
multi_client_body()
{
ovpn_init
vnet_init_bridge

bridge=$(vnet_mkbridge)
srv=$(vnet_mkepair)
Expand Down Expand Up @@ -814,6 +815,7 @@ ra_head()
ra_body()
{
ovpn_init
vnet_init_bridge

bridge=$(vnet_mkbridge)
srv=$(vnet_mkepair)
Expand Down
8 changes: 8 additions & 0 deletions tests/sys/netinet/carp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ basic_v4_head()
basic_v4_body()
{
carp_init
vnet_init_bridge

bridge=$(vnet_mkbridge)
epair_one=$(vnet_mkepair)
Expand Down Expand Up @@ -115,6 +116,7 @@ vrrp_v4_head()
vrrp_v4_body()
{
carp_init
vnet_init_bridge

j=vrrp_basic_v4

Expand Down Expand Up @@ -161,6 +163,7 @@ unicast_v4_head()
unicast_v4_body()
{
carp_init
vnet_init_bridge

bridge=$(vnet_mkbridge)
epair_one=$(vnet_mkepair)
Expand Down Expand Up @@ -218,6 +221,7 @@ basic_v6_head()
basic_v6_body()
{
carp_init
vnet_init_bridge

bridge=$(vnet_mkbridge)
epair_one=$(vnet_mkepair)
Expand Down Expand Up @@ -265,6 +269,7 @@ vrrp_v6_head()
vrrp_v6_body()
{
carp_init
vnet_init_bridge

j=carp_basic_v6

Expand Down Expand Up @@ -314,6 +319,7 @@ unicast_v6_head()
unicast_v6_body()
{
carp_init
vnet_init_bridge

bridge=$(vnet_mkbridge)
epair_one=$(vnet_mkepair)
Expand Down Expand Up @@ -375,6 +381,7 @@ unicast_ll_v6_head()
unicast_ll_v6_body()
{
carp_init
vnet_init_bridge

j=carp_uni_ll_v6

Expand Down Expand Up @@ -485,6 +492,7 @@ nd6_ns_source_mac_head()
nd6_ns_source_mac_body()
{
carp_init
vnet_init_bridge

bridge=$(vnet_mkbridge)
epair_one=$(vnet_mkepair)
Expand Down
1 change: 1 addition & 0 deletions tests/sys/netpfil/common/rdr.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ local_redirect_body()
firewall=$1
firewall_init $firewall
nat_init $firewall
vnet_init_bridge

bridge=$(vnet_mkbridge)
ifconfig ${bridge} 192.0.2.1/24 up
Expand Down
4 changes: 1 addition & 3 deletions tests/sys/netpfil/pf/altq.sh
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,7 @@ codel_bridge_body()
{
altq_init
is_altq_supported codel
if ! kldstat -q -m if_bridge; then
atf_skip "This test requires if_bridge"
fi
vnet_init_bridge

epair=$(vnet_mkepair)
ifconfig ${epair}a 192.0.2.1/24 up
Expand Down
1 change: 1 addition & 0 deletions tests/sys/netpfil/pf/pfsync.sh
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ pbr_common_body()
atf_skip "This test requires carp"
fi
pfsynct_init
vnet_init_bridge

bridge0=$(vnet_mkbridge)
bridge1=$(vnet_mkbridge)
Expand Down
1 change: 1 addition & 0 deletions tests/sys/netpfil/pf/sctp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@ pfsync_body()

sctp_init
pfsynct_init
vnet_init_bridge
if ! kldstat -q -m carp
then
atf_skip "This test requires carp"
Expand Down
1 change: 1 addition & 0 deletions tests/sys/netpfil/pf/tcp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ rst_head()
rst_body()
{
pft_init
vnet_init_bridge

epair_srv=$(vnet_mkepair)
epair_cl=$(vnet_mkepair)
Expand Down

0 comments on commit 480ad40

Please sign in to comment.