Page MenuHomeFreeBSD

ifnet: vnet_if_return(): Avoid unnecessary recursive acquisition of ifnet_detach_sxlock
AcceptedPublic

Authored by zlei on Tue, Apr 7, 3:26 AM.
Tags
None
Referenced Files
F151669933: D56288.diff
Thu, Apr 9, 9:59 PM
F151644934: D56288.diff
Thu, Apr 9, 6:06 PM
F151618953: D56288.diff
Thu, Apr 9, 1:27 PM
Unknown Object (File)
Thu, Apr 9, 7:47 AM

Details

Reviewers
kp
pouria
Group Reviewers
network
Summary

vnet_if_return() will be invocked by vnet_sysuninit() on vnet destructing,
while the lock ifnet_detach_sxlock has been acquired in vnet_destroy()
already.

With this change the order of locking is more clear. There should be no
functional change.

Fixes: 868bf82153e8 if: avoid interface destroy race
MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

zlei requested review of this revision.Tue, Apr 7, 3:26 AM

This LGTM, but here's an idea: why not do it the other way around?
It makes more sense not to acquire the lock on every vnet_destroy, since many modules don't require ifnet_detach_sxlock.
Of course it requires more work, but IMHO it's worth it.

This LGTM, but here's an idea: why not do it the other way around?

This is part of the cleanup.

It makes more sense not to acquire the lock on every vnet_destroy, since many modules don't require ifnet_detach_sxlock.

I think so.

Quoted from the commit log of 6d2a10d96fb5d4ee42fd67b0b07a6d098db5d55a,

Widen the ifnet_detach_sxlock to cover the entire vnet sysuninit code.
    This ensures that we can't end up having the vnet_sysuninit free the UDP
    pcb while the detach code is running and trying to purge the UDP pcb.

I guess the locking issues with UDP pcb is actually covered by this change 6d2a10d96fb5d4ee42fd67b0b07a6d098db5d55a .

The sx lock ifnet_detach_sxlock was introduced to solely resolve the ifnet detach / vmove racing issue ?

Of course it requires more work, but IMHO it's worth it.

This revision is now accepted and ready to land.Tue, Apr 7, 9:45 AM