Page MenuHomeFreeBSD

netlink: Fix IFF_UP flag handling in RTM_NEWLINK's modify_link handler
ClosedPublic

Authored by saheed on Aug 12 2025, 8:15 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Nov 12, 5:27 AM
Unknown Object (File)
Wed, Nov 5, 11:52 PM
Unknown Object (File)
Sun, Nov 2, 5:44 PM
Unknown Object (File)
Sat, Nov 1, 9:03 PM
Unknown Object (File)
Sat, Nov 1, 7:12 PM
Unknown Object (File)
Fri, Oct 31, 7:14 AM
Unknown Object (File)
Wed, Oct 29, 3:52 PM
Unknown Object (File)
Wed, Oct 29, 12:07 PM

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

This revision is now accepted and ready to land.Aug 12 2025, 8:51 AM

This fix has existed out of tree in @obiwac's BATMAN tree
:)

So that seems correct if ifi_change lists the changed flags we should look at.

I can't find any use of it in our tree, and the only Linux documentation I found (https://www.man7.org/linux/man-pages/man7/rtnetlink.7.html) says "ifi_change is reserved for future use and should be always set to 0xFFFFFFFF."

What am I missing?

In D51871#1185494, @kp wrote:

So that seems correct if ifi_change lists the changed flags we should look at.

I can't find any use of it in our tree, and the only Linux documentation I found (https://www.man7.org/linux/man-pages/man7/rtnetlink.7.html) says "ifi_change is reserved for future use and should be always set to 0xFFFFFFFF."

What am I missing?

Linux is actually doing something based on ifi_change currently (relevant code in net/core/rtnetlink.c, rtnl_dev_combine_flags).

It uses the previous flags for bits where ifi_change are unset to change device flags, so basically this is equivalent to what our code does.
The exception is when ifi_change is 0, then it assumes it is 0xFFFFFFFF, which differs in behaviour to our code (we should do (lattrs->ifi_change & IFF_UP) != 0 || lattrs->ifi_change == 0 to emulate this).

So I guess we should decide whether to stick to the documentation then or keep things in line with Linux. Thoughts?

Linux is actually doing something based on ifi_change currently (relevant code in net/core/rtnetlink.c, rtnl_dev_combine_flags).

Ah yes, "Documentation does not match reality", that's what I was missing. I did not check Linux code, I only looked at our tree.

It uses the previous flags for bits where ifi_change are unset to change device flags, so basically this is equivalent to what our code does.
The exception is when ifi_change is 0, then it assumes it is 0xFFFFFFFF, which differs in behaviour to our code (we should do (lattrs->ifi_change & IFF_UP) != 0 || lattrs->ifi_change == 0 to emulate this).

So I guess we should decide whether to stick to the documentation then or keep things in line with Linux. Thoughts?

I'd be inclined to pick up Linux's bug compatibility as well. Presumably there's code out there that makes this incorrect assumption about ifi_change, and we may as well go all out on being compatible. Especially if it's easy to do. That can be done separately if you prefer (or not at all, if either of you have strong views here).

In D51871#1185539, @kp wrote:

I'd be inclined to pick up Linux's bug compatibility as well. Presumably there's code out there that makes this incorrect assumption about ifi_change, and we may as well go all out on being compatible. Especially if it's easy to do. That can be done separately if you prefer (or not at all, if either of you have strong views here).

I too think we should have this bug compatibility

In D51871#1185539, @kp wrote:

I'd be inclined to pick up Linux's bug compatibility as well. Presumably there's code out there that makes this incorrect assumption about ifi_change, and we may as well go all out on being compatible. Especially if it's easy to do. That can be done separately if you prefer (or not at all, if either of you have strong views here).

I too think we should have this bug compatibility

On the same page :)

mckusick added a subscriber: mckusick.

Mentor approval for commit.

  • netlink: Modify all flags when ifi_change is 0 in RTM_NEWLINK

Adds linux's ifi_change bug compatibility

This revision now requires review to proceed.Aug 14 2025, 7:21 AM
obiwac added inline comments.
sys/netlink/route/iface_drivers.c
103–104

maybe mention this change in your summary

This revision is now accepted and ready to land.Aug 14 2025, 8:16 AM
saheed marked an inline comment as done.

Mentor approval for commit.

I'll reopen this revision to have only IFF_UP related change without touching IFF_PROMISC

saheed edited the summary of this revision. (Show Details)

Removed handling IFF_PROMISC when ifi_change=0

This revision is now accepted and ready to land.Aug 23 2025, 2:38 PM

Mentor approval for commit.