Bug 289545 - No option to disable NOMAP leads to network down/up with em0 when starting bridge.
Summary: No option to disable NOMAP leads to network down/up with em0 when starting br...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.5-RELEASE
Hardware: Any Any
: --- Affects Some People
Assignee: Zhenlei Huang
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-09-13 13:51 UTC by Leo Bicknell
Modified: 2025-10-12 03:37 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Leo Bicknell 2025-09-13 13:51:09 UTC
Bug report https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=221122 documented an unfortunate behavior of Intel network cards and how it's triggered by bhyve vm's.  I stumbled across it having the same problem on a 13.5-RELEASE install where my em0 would go down and come back up leading to a ~7 second network pause when the first vm was started or last vm stopped.

I attempted the work-around in the bug report.  I checked em0 for the features enabled, started the vm and checked again to see which features the bridge disabled.  I came up with this /etc/rc.conf line:

ifconfig_em0="DHCP -tso -lro -txcsum -rxcsum -txcsum6 -vlanmtu -vlanhwtag -vlanhwfilter -vlanhwtso -vlanhwcsum"

Unfortunately this is not a complete solution.  Before starting the first vm:

        options=4802020<JUMBO_MTU,WOL_MAGIC,NOMAP>

After starting the first VM:

        options=802020<JUMBO_MTU,WOL_MAGIC>

The bridge is still removing the option "NOMAP", and I believe that is what is still causing the network to flap.  

Unfortunately there is no ifconfig option to disable NOMAP.  In fact, there appears to be no real documentation about it at all anywhere.  Indeed, the only place I can even find this in the source is https://github.com/freebsd/freebsd-src/blob/main/sbin/ifconfig/ifconfig.c#L1674 where ifconfig prints it out.

Should there be a "-nocap" for ifconfig?  Is there some better solution?
Comment 1 Andriy Gapon freebsd_committer freebsd_triage 2025-09-14 15:52:51 UTC
Regarding "NOMAP" flag, bit 26, it's curious that the code names it IFCAP_B_MEXTPG / IFCAP_MEXTPG.
Comment 2 spork 2025-09-14 17:56:58 UTC
I see the other bug (where I burned a decent amount of time testing and got zero feedback) was closed: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=221122

Is this truly fixed or not?

The test case I outlined seemed pretty straightforward and my shoddy "fix" fixed it, but I'm not sure what came of all that, if anything, as there's no message noting how or if the bug was fixed.
Comment 3 Leo Bicknell 2025-09-14 18:12:44 UTC
I think saying "the bug" is a bit ambiguous.  There appear to be multiple components to this problem:

#1 Some Intel NICs drop link when particular capabilities are changed, like hardware offload.  I have never seen clear documentation if this is a problem with the FreeBSD driver, or if this is firmware inside the NIC that is the responsibility of Intel.  The attitude in several bug reports is "that's just the way it is with those NICs", but no one has ever documented WHY in any of the posts I have seen.

#2 When a bridge is brought up it has to force all component interfaces to have the same set of capabilities.  It appears in older code this was not documented, but somewhere along the way was documented and is now spelled out in the man 4 bridge page.  While the paragraph is clear, I suspect many people would not understand the implications from just reading the man page.  

#3 A workaround for the combination of #1 and #2 is to manually disable the capabilities on one or more interfaces so that when the bridge starts up everything matches and the bridge code does not need to change them.  This seems like a mostly reasonable workaround to me, and was the one I was trying to implement.  It was in the process of implementing that I found this capability "NOMAP" which there appears to be no cli way to turn off, appears to be virtually undocumented, but which bridge must turn off, which means the entire workaround does not work.

#4 An unstated workaround is to replace the Intel card with a non-Intel NIC that does not have this problem.

In this bug report my main goal is to get an argument to ifconfig to disable "NOMAP" so the workaround is a functional workaround again.  That would make me happy.  However I can see how other people would prefer that #1 be fixed, either by fixing the FreeBSD driver or by getting Intel to fix their card.  Given Intel generally produces high quality NIC cards that people like I can see how getting it fixed could be a priority for some.
Comment 4 spork 2025-09-15 02:31:42 UTC
this feels like a lot of words to discredit that this has a large impact on people that run lots of virtualized things. The reason some were asking for a toggle was to let the "it's not a problem" crowd carry on while those who found it not acceptable for their environment could change the behavior from default.

In a server environment, it's not really an option to be either a) swapping out all your servers or b) adding new ethernet cards to expensive 1U servers that already include a high quality pair of NICs that operate fine under other OSes.
Comment 5 Mark Johnston freebsd_committer freebsd_triage 2025-09-19 16:08:20 UTC
Does ifconfig em0 -mextpg fix the problem?  I don't understand why ifconfig reports it as NOMAP instead of MEXTPG.
Comment 6 Leo Bicknell 2025-09-19 16:22:51 UTC
(In reply to Mark Johnston from comment #5)

Yes! Adding -mextpg fixes it for me and removes the NOMAP option.  

So, should ifconfig output something like "MEXTPG" instead of "NOMAP"?  Should "NOMAP" be added to the ifconfig man page?
Comment 7 Mark Johnston freebsd_committer freebsd_triage 2025-09-19 16:39:35 UTC
(In reply to Leo Bicknell from comment #6)
Well, the plot thickens... on one system I have

em1: flags=8802<BROADCAST,SIMPLEX,MULTICAST> metric 0 mtu 1500        options=4e504bb<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,JUMBO_MTU,VLAN_HWCSUM,LRO,VLAN_HWFILTER,VLAN_HWTSO,RXCSUM_IPV6,TXCSUM_IPV6,HWSTATS,MEXTPG>

i.e., MEXTPG is listed instead of NOMAP.  I don't understand how, the string "MEXTPG" doesn't appear anywhere in the ifconfig sources, but I do see "NOMAP".
Comment 8 Mark Johnston freebsd_committer freebsd_triage 2025-09-19 16:59:18 UTC
ahh, this was implicitly fixed when ifconfig was converted to use netlink.  Now the name comes from ifcap_bit_names in sys/net/if_strings.h.

So, I believe the problem now is "just fixed".  We should update the string in the non-netlink case too.
Comment 9 Zhenlei Huang freebsd_committer freebsd_triage 2025-09-19 17:37:52 UTC
(In reply to Mark Johnston from comment #7)
The reporter is on FreeBSD 13.5 .

The IFCAP_NOMAP was introduced by John via commit https://cgit.freebsd.org/src/commit/?id=82334850ea451f7f6903be20e4836118e6a77460 , and later it was refactored by Gleb, and converted to IFCAP_MEXTPG via commit https://cgit.freebsd.org/src/commit/?id=3f43ada98c89bce5ae416e203ba0e81595a5cd88 . The commit was MFCed to stable/13 and is in releng/13.5 .

It appears the refactoring is not complete. The `\33NOMAP` in ifconfig.c was left unchanged. I think that should be converted to `\33MEXTPG` ( for stable/13 ) . CC @Gleb .
Comment 10 commit-hook freebsd_committer freebsd_triage 2025-09-19 19:19:51 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=5017fdb728811fd3e15d7151524378f49a49aee1

commit 5017fdb728811fd3e15d7151524378f49a49aee1
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2025-09-19 19:18:27 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2025-09-19 19:18:27 +0000

    ifconfig: Fix the display of the IFCAP_MEXTPG capability without netlink

    Historically this capability is IFCAP_NOMAP but it was renamed to
    IFCAP_MEXTPG. Catch up with the change 3f43ada98c89.

    PR:             289545
    Fixes:          3f43ada98c89 Catch up with 6edfd179c86: mechanically rename IFCAP_NOMAP to IFCAP_MEXTPG
    MFC after:      3 days

 sbin/ifconfig/ifconfig.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 11 commit-hook freebsd_committer freebsd_triage 2025-09-24 13:31:30 UTC
A commit in branch stable/15 references this bug:

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

commit 5f472754ba6f9cc95607956c6e2ad6483c9dd157
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2025-09-19 19:18:27 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2025-09-24 13:29:24 +0000

    ifconfig: Fix the display of the IFCAP_MEXTPG capability without netlink

    Historically this capability is IFCAP_NOMAP but it was renamed to
    IFCAP_MEXTPG. Catch up with the change 3f43ada98c89.

    PR:             289545
    Fixes:          3f43ada98c89 Catch up with 6edfd179c86: mechanically rename IFCAP_NOMAP to IFCAP_MEXTPG
    MFC after:      3 days

    (cherry picked from commit 5017fdb728811fd3e15d7151524378f49a49aee1)

 sbin/ifconfig/ifconfig.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 12 commit-hook freebsd_committer freebsd_triage 2025-09-27 15:14:59 UTC
A commit in branch stable/14 references this bug:

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

commit 6a2eca1b38d762776676065d72518d30d1f1f348
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2025-09-19 19:18:27 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2025-09-27 15:11:40 +0000

    ifconfig: Fix the display of the IFCAP_MEXTPG capability without netlink

    Historically this capability is IFCAP_NOMAP but it was renamed to
    IFCAP_MEXTPG. Catch up with the change 3f43ada98c89.

    PR:             289545
    Fixes:          3f43ada98c89 Catch up with 6edfd179c86: mechanically rename IFCAP_NOMAP to IFCAP_MEXTPG
    MFC after:      3 days

    (cherry picked from commit 5017fdb728811fd3e15d7151524378f49a49aee1)
    (cherry picked from commit 5f472754ba6f9cc95607956c6e2ad6483c9dd157)

 sbin/ifconfig/ifconfig.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 13 commit-hook freebsd_committer freebsd_triage 2025-10-04 16:45:39 UTC
A commit in branch stable/13 references this bug:

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

commit d334e045a471d2bb0db2f9bb750eb7e67ef0823f
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2025-09-19 19:18:27 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2025-10-04 16:43:27 +0000

    ifconfig: Fix the display of the IFCAP_MEXTPG capability

    Historically this capability is IFCAP_NOMAP but it was renamed to
    IFCAP_MEXTPG. Catch up with the change 3f43ada98c89.

    This is a direct commit to stable/13.

    PR:             289545
    Fixes:          3f43ada98c89 Catch up with 6edfd179c86: mechanically rename IFCAP_NOMAP to IFCAP_MEXTPG

 sbin/ifconfig/ifconfig.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)