Skip to content

Commit

Permalink
libifconfig: Fix bridge status member list
Browse files Browse the repository at this point in the history
When this functionality was moved to libifconfig in 3dfbda3,
the end of list calculation was modified for unknown reasons, practically
limiting the number of bridge member returned to (about) 102.

This patch changes the calculation back to what it was originally and
adds a unit test to verify it works as expected.

Reported by:	Patrick M. Hausen (via ML)
Reviewed by:	kp
Approved by:	kp
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D43135
  • Loading branch information
grembo committed Dec 21, 2023
1 parent ad87454 commit 3d36053
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/libifconfig/libifconfig_bridge.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ ifconfig_bridge_get_bridge_status(ifconfig_handle_t *h,
free(bridge);
return (-1);
}
if (members.ifbic_len <= len)
if ((members.ifbic_len + sizeof(*members.ifbic_req)) < len)
break;
}
if (buf == NULL) {
Expand Down
28 changes: 28 additions & 0 deletions tests/sys/net/if_bridge_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -663,6 +663,33 @@ vlan_cleanup()
vnet_cleanup
}

atf_test_case "many_bridge_members" "cleanup"
many_bridge_members_head()
{
atf_set descr 'many_bridge_members ifconfig test'
atf_set require.user root
}

many_bridge_members_body()
{
vnet_init

bridge=$(vnet_mkbridge)
ifcount=256
for _ in $(seq 1 $ifcount); do
epair=$(vnet_mkepair)
ifconfig "${bridge}" addm "${epair}"a
done

atf_check -s exit:0 -o inline:"$ifcount\n" \
sh -c "ifconfig ${bridge} | grep member: | wc -l | xargs"
}

many_bridge_members_cleanup()
{
vnet_cleanup
}

atf_init_test_cases()
{
atf_add_test_case "bridge_transmit_ipv4_unicast"
Expand All @@ -677,4 +704,5 @@ atf_init_test_cases()
atf_add_test_case "gif"
atf_add_test_case "mtu"
atf_add_test_case "vlan"
atf_add_test_case "many_bridge_members"
}

0 comments on commit 3d36053

Please sign in to comment.