Page MenuHomeFreeBSD

sys: don't panic on ifm_status being NULL
ClosedPublic

Authored by adrian on Sat, May 3, 3:44 PM.
Tags
None
Referenced Files
F116625141: D50136.id155016.diff
Thu, May 8, 1:15 PM
Unknown Object (File)
Wed, May 7, 6:24 PM
Unknown Object (File)
Wed, May 7, 8:22 AM
Unknown Object (File)
Wed, May 7, 5:41 AM
Unknown Object (File)
Tue, May 6, 4:50 AM
Unknown Object (File)
Tue, May 6, 1:53 AM
Unknown Object (File)
Tue, May 6, 1:33 AM
Unknown Object (File)
Mon, May 5, 10:03 AM

Details

Summary

Some ethernet drivers that use miibus aren't probe/attaching the
miibus early enough for the ifioctl path to correctly run without
panicing.

Although yes, the drivers do need fixing, this stops them from
immediately panicing the kernel when they're loaded.

PR: kern/286530

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 63972
Build 60856: arc lint + arc unit

Event Timeline

adrian requested review of this revision.Sat, May 3, 3:44 PM

I just wonder if the panic is a feature that the driver is broken? That is, does the driver still work ok if the ordering is wrong and this patch is applied?

sys/net/if_media.c
294

Style wants a blank line before comments.

bz added inline comments.
sys/net/if_media.c
303

That's likely going to be an unhelpful error. ENXIO is likely also misleading.
But it should really be a panic("Fix the driver") or given you want it to be graceful, I'd add a uprintf saying something along the lines of "This driver needs fixing to work" so you do not get and endless amount of PRs (which you open yourself).

In D50136#1143592, @jhb wrote:

I just wonder if the panic is a feature that the driver is broken? That is, does the driver still work ok if the ordering is wrong and this patch is applied?

Both if_vr and if_re work fine with the diff applied. miibus eventually does come up, phys get probed, IP address assignment => working traffic, tested with iperf on both NICs.

sys/net/if_media.c
303

ENXIO is likely .. less misleading?
I don't mind adding a printf that's less terrible than mine in local debugging (ifmedia_ioctl: re0: ifm_status = NULL; erroring).

It's happening when netlink wants to query the media state before announcing the new link. I'm sure /something/ will break that's subscribing to the notification.

EDOOFUS was invented exactly for that. How many drivers do need a fix? Why this change instead of fixing the drivers?

EDOOFUS was invented exactly for that. How many drivers do need a fix? Why this change instead of fixing the drivers?

Shall I return EDOOFUS? :-)

I just want it to not panic in -HEAD whilst I go and do some cleanup and if_re work.

I think EDOOFUS is fine.

This revision is now accepted and ready to land.Tue, May 6, 9:16 PM

address feedback from jhb / glebius

This revision now requires review to proceed.Tue, May 6, 10:17 PM
This revision was not accepted when it landed; it landed in state Needs Review.Wed, May 7, 4:22 AM
This revision was automatically updated to reflect the committed changes.