Page MenuHomeFreeBSD

ifnet: Add some sanity checks
ClosedPublic

Authored by zlei on Mon, Mar 16, 8:23 AM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Apr 8, 9:55 AM
Unknown Object (File)
Tue, Apr 7, 4:50 PM
Unknown Object (File)
Sun, Apr 5, 1:20 PM
Unknown Object (File)
Mon, Mar 30, 10:10 AM
Unknown Object (File)
Fri, Mar 27, 12:07 AM
Unknown Object (File)
Wed, Mar 25, 12:26 AM
Unknown Object (File)
Tue, Mar 24, 9:30 AM
Unknown Object (File)
Tue, Mar 24, 1:26 AM

Details

Summary

To be more robust since the checking is performed where the interface
is referenced.

While here, remove a redundant check from if_vmove_loan().

MFC after: 2 weeks

Diff Detail

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

Event Timeline

zlei requested review of this revision.Mon, Mar 16, 8:23 AM

I'm not sure how these assertions will be beneficial if we have to add them to every function of the ifp [un]linking.
IMHO, KASSERT/MPASS are existing to verify programmatic assumptions.
And yes, these changes are definitely verifies programmatic assumptions.
However, I don't think that using them to verify every programmatic assumptions per function is appropriate.

sys/net/if.c
2118–2121

while you're here, could you please fix its style too?

This revision is now accepted and ready to land.Mon, Mar 16, 10:59 AM
zlei added inline comments.
sys/net/if.c
2118–2121

while you're here, could you please fix its style too?

The flag IFF_DYING is a bit useless in practices. The writes to if_flags is not lock protected, hence a thread is not guareenteed to see it. Also it is a bit confusing to see a IFF_DYING interface on a "alive" list.

I believe the only valid consumer of IFF_DYING is the driver, to prevent potential race condition on ioctls. Anyway this flag do not belong to if_flags.

There're plans to remove IFF_DYING. See also https://reviews.freebsd.org/D49412.
I do not want to touch the style right now.

zlei marked an inline comment as done.Thu, Apr 2, 3:55 AM

I'm not sure how these assertions will be beneficial if we have to add them to every function of the ifp [un]linking.
IMHO, KASSERT/MPASS are existing to verify programmatic assumptions.

For example assertions in if_unlink_ifnet(), there're multiple places, if_detach() / if_vmove_loan() / if_vmove_reclaim() / vnet_if_return() want them. You do not want to repeat everywhere.

And yes, these changes are definitely verifies programmatic assumptions.
However, I don't think that using them to verify every programmatic assumptions per function is appropriate.

For assertions in ifunit() / ifunit_ref(), they guarantee the ifp is in good shape when being used, also they serve a document to developers. The net stack evolves, but the document lags.

This revision was automatically updated to reflect the committed changes.