Bug 292634 - make ifconfig display bridge members when a span interface is added
Summary: make ifconfig display bridge members when a span interface is added
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 15.0-RELEASE
Hardware: Any Any
: --- Affects Only Me
Assignee: Lexi Winter
URL: https://reviews.freebsd.org/D56694
Keywords: regression
Depends on:
Blocks:
 
Reported: 2026-01-21 20:32 UTC by Emrion
Modified: 2026-05-05 15:06 UTC (History)
3 users (show)

See Also:
ivy: mfc-stable14-


Attachments
Add scan the span list for bridge_lookup_member (220 bytes, patch)
2026-01-23 21:36 UTC, Emrion
no flags Details | Diff
Add scan the span list for bridge_lookup_member (1.05 KB, patch)
2026-01-24 11:48 UTC, Simon Wollwage
no flags Details | Diff
Add scanning of span list for bridge_lookup_member (812 bytes, patch)
2026-01-24 16:09 UTC, Emrion
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Emrion 2026-01-21 20:32:44 UTC
It's just a display issue, normal and span members work as intended.

To reproduce the problem (on 15.0-RELEASE):

# ifconfig bridge0 create
# ifconfig tap0 create
# ifconfig tap1 create
# ifconfig bridge0 addm tap0
# ifconfig bridge0
bridge0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=10<VLAN_HWTAGGING>
        ether 58:9c:fc:10:ab:d7
        id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
        maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
        root id 00:00:00:00:00:00 priority 0 ifcost 0 port 0
        bridge flags=0<>
        member: tap0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
                port 4 priority 128 path cost 2000000 vlan protocol 802.1q
        groups: bridge
        nd6 options=9<PERFORMNUD,IFDISABLED>
# ifconfig bridge0 span tap1
# ifconfig bridge0
bridge0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
        options=10<VLAN_HWTAGGING>
        ether 58:9c:fc:10:ab:d7
        groups: bridge
#

----------------------------------------
For reference, on 14.3-RELEASE, we get:

# ifconfig bridge0 create
# ifconfig tap0 create
# ifconfig tap1 create
# ifconfig bridge0 addm tap0
# ifconfig bridge0 span tap1
# ifconfig bridge0
bridge0: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500
	options=0
	ether 58:9c:fc:10:b3:24
	id 00:00:00:00:00:00 priority 32768 hellotime 2 fwddelay 15
	maxage 20 holdcnt 6 proto rstp maxaddr 2000 timeout 1200
	root id 00:00:00:00:00:00 priority 0 ifcost 0 port 0
	member: tap0 flags=143<LEARNING,DISCOVER,AUTOEDGE,AUTOPTP>
	        ifmaxaddr 0 port 4 priority 128 path cost 2000000
	member: tap1 flags=8<SPAN>
	        ifmaxaddr 0 port 5 priority 128 path cost 2000000
	groups: bridge
	nd6 options=9<PERFORMNUD,IFDISABLED>
#
Comment 1 Emrion 2026-01-22 13:29:59 UTC
I'm looking at the code.
I think the problem comes from sbin/ifconfig/ifbridge.c, line 212:

static void
bridge_status(if_ctx *ctx)
{
	struct ifconfig_bridge_status *bridge;
	struct ifbropreq *params;
	const char *pad, *prefix;
	uint8_t lladdr[ETHER_ADDR_LEN];
	uint16_t bprio;

	if (ifconfig_bridge_get_bridge_status(lifh, ctx->ifname, &bridge) == -1)
		return;

	params = bridge->params;

	PV2ID(params->ifbop_bridgeid, bprio, lladdr);
	printf("\tid %s priority %u hellotime %u fwddelay %u\n",
	    (...snip...)

The function ifconfig_bridge_get_bridge_status() could return -1 when a span interface is present as a bridge member, thus stopping all the subsequent prints (as we see in the ifconfig output).

This function is located in lib/libifconfig/libifconfig_bridge.c. Maybe one of the two last commits is responsible for this issue.
Comment 2 Emrion 2026-01-23 21:36:32 UTC
Created attachment 267422 [details]
Add scan the span list for bridge_lookup_member

This patch is for 15.0-RELEASE.
-------------------------------

My first intuition was right.

It's well the call to ifconfig_bridge_get_bridge_status() in sbin/ifconfig/ifbridge.c which answers -1 when a span member is present in the bridge.

ifconfig_bridge_get_bridge_status() is defined in lib/libifconfig/libifconfig_bridge.c. The error comes from these lines:
if (ifconfig_bridge_ioctlwrap(h, name, BRDGGIFVLANSET, &vreq,
		    sizeof(vreq), false) != 0) {
			goto err;
		}

Looking at sys/net/if_bridge.c, the function bridge_ioctl_gifvlanset() is failed in case of a span member at: bif = bridge_lookup_member(sc, req->bv_ifname);

And, finally, inspecting bridge_lookup_member(), I saw that it looks only in the normal members list, not in the span list (&sc->sc_spanlist). So, I just added some lines to look into the span list before to return NULL.
Comment 3 Simon Wollwage freebsd_triage 2026-01-24 11:48:53 UTC
Created attachment 267434 [details]
Add scan the span list for bridge_lookup_member

^Triage: rebase patch

To make it easier for committers to apply the patches and merge them, please use git and run `git format-patch @~1`, that makes it most convenient.
Comment 4 Emrion 2026-01-24 16:09:33 UTC
Created attachment 267445 [details]
Add scanning of span list for bridge_lookup_member
Comment 5 Emrion 2026-01-24 16:12:35 UTC
(In reply to Simon Wollwage from comment #3)
Sorry, git is over complicated for me, yet I use it.
I wonder why your patch is altering bridge_ioctl_gifvlanset() since I didn't touch to its function code.

Following your guide, I get what this attachement.
Comment 6 Emrion 2026-04-24 14:02:16 UTC
Will this patch be committed for 15.1-RELEASE?
Comment 7 Lexi Winter freebsd_committer freebsd_triage 2026-04-28 17:02:05 UTC
thank you for the bug report and the patch.  i decided to fix this a different way, by not attempting BRDGGIFVLANSET for span members.

the fix should be in 15.1-RELEASE.
Comment 8 Emrion 2026-04-28 19:04:07 UTC
(In reply to Lexi Winter from comment #7)
I suppose there is a good reason for that.

However, the function bridge_lookup_member() in the kmod answers NULL in case of a span member. So, a span member isn't a member. Is this ok for you?
Comment 9 Lexi Winter freebsd_committer freebsd_triage 2026-04-28 19:07:37 UTC
i think it's debatable whether a span member is "a bridge member" or not; however, changing bridge_lookup_member() to return span members opens a huge can of worms--e.g., can you now configure VLANs on span members, even though this doesn't work or make sense?--if we want to fix this for 15.1, this change is the least invasive way to do that.
Comment 10 commit-hook freebsd_committer freebsd_triage 2026-04-29 03:18:14 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=454322c08b8aa181939c8d920472f03cfd591032

commit 454322c08b8aa181939c8d920472f03cfd591032
Author:     Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2026-04-29 03:11:20 +0000
Commit:     Lexi Winter <ivy@FreeBSD.org>
CommitDate: 2026-04-29 03:12:20 +0000

    libifconfig: Skip bridge VLAN config for span members

    bridge(4) doesn't support BRDGGIFVLANSET for span members, which
    means if a span interface is configured, libifconfig will fail to
    fetch bridge members.  Skip this for IFBIF_SPAN members.

    PR:     292634
    MFC after:      3 days
    Reported by:    Emrion <kmachine@free.fr>
    Reviewed by:    pouria, zlei
    Sponsored by:   https://www.patreon.com/bsdivy
    Differential Revision:  https://reviews.freebsd.org/D56694

 lib/libifconfig/libifconfig_bridge.c | 5 +++++
 1 file changed, 5 insertions(+)
Comment 11 Emrion 2026-04-29 16:40:32 UTC
(In reply to Lexi Winter from comment #9)
I tested your patch, and without surprise, it works for me.
I won't contrary you about the useless of VLAN concerning span member. As, even for me, it makes sense. :-)

What is worrying me it's what devs define exactly as a bridge member. Because if it is not clear for all, more serious bugs will come.
Comment 12 commit-hook freebsd_committer freebsd_triage 2026-05-04 00:16:27 UTC
A commit in branch stable/15 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=0a919e2a9265b5cdaeb2c5d51c29791b4eb7335c

commit 0a919e2a9265b5cdaeb2c5d51c29791b4eb7335c
Author:     Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2026-04-29 03:11:20 +0000
Commit:     Lexi Winter <ivy@FreeBSD.org>
CommitDate: 2026-05-04 00:14:37 +0000

    libifconfig: Skip bridge VLAN config for span members

    bridge(4) doesn't support BRDGGIFVLANSET for span members, which
    means if a span interface is configured, libifconfig will fail to
    fetch bridge members.  Skip this for IFBIF_SPAN members.

    PR:     292634
    MFC after:      3 days
    Reported by:    Emrion <kmachine@free.fr>
    Reviewed by:    pouria, zlei
    Sponsored by:   https://www.patreon.com/bsdivy
    Differential Revision:  https://reviews.freebsd.org/D56694

    (cherry picked from commit 454322c08b8aa181939c8d920472f03cfd591032)

 lib/libifconfig/libifconfig_bridge.c | 5 +++++
 1 file changed, 5 insertions(+)
Comment 13 Mark Linimon freebsd_committer freebsd_triage 2026-05-04 08:34:20 UTC
^Triage: apparently no MFC to 14 is planned.
Comment 14 commit-hook freebsd_committer freebsd_triage 2026-05-05 15:06:10 UTC
A commit in branch releng/15.1 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=5f901e157aafa6ed4550fe39dbc121f7668459b7

commit 5f901e157aafa6ed4550fe39dbc121f7668459b7
Author:     Lexi Winter <ivy@FreeBSD.org>
AuthorDate: 2026-04-29 03:11:20 +0000
Commit:     Lexi Winter <ivy@FreeBSD.org>
CommitDate: 2026-05-05 15:03:45 +0000

    libifconfig: Skip bridge VLAN config for span members

    bridge(4) doesn't support BRDGGIFVLANSET for span members, which
    means if a span interface is configured, libifconfig will fail to
    fetch bridge members.  Skip this for IFBIF_SPAN members.

    PR:     292634
    MFC after:      3 days
    Reported by:    Emrion <kmachine@free.fr>
    Reviewed by:    pouria, zlei
    Approved by:    re (cperciva)
    Sponsored by:   https://www.patreon.com/bsdivy
    Differential Revision:  https://reviews.freebsd.org/D56694

    (cherry picked from commit 454322c08b8aa181939c8d920472f03cfd591032)
    (cherry picked from commit 0a919e2a9265b5cdaeb2c5d51c29791b4eb7335c)

 lib/libifconfig/libifconfig_bridge.c | 5 +++++
 1 file changed, 5 insertions(+)