Page MenuHomeFreeBSD

jail: Make prison_owns_vnet() operate on a prison instead of a ucred
ClosedPublic

Authored by markj on Jul 25 2025, 1:42 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Sep 5, 9:50 AM
Unknown Object (File)
Thu, Aug 28, 3:52 PM
Unknown Object (File)
Sat, Aug 23, 2:30 AM
Unknown Object (File)
Thu, Aug 14, 11:35 PM
Unknown Object (File)
Wed, Aug 13, 7:00 PM
Unknown Object (File)
Aug 3 2025, 8:08 AM
Unknown Object (File)
Jul 29 2025, 2:38 AM
Unknown Object (File)
Jul 29 2025, 1:54 AM

Details

Diff Detail

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

Event Timeline

markj requested review of this revision.Jul 25 2025, 1:42 PM

prison_owns_vnet taking a struct prison makes sense

There's a general trend in the "prison can do this thing" functions that they all take a ucred. One the one hand it seems reasonable that they would all take a struct prison instead, but is there a particular reason to break the trend for this case?

There's a general trend in the "prison can do this thing" functions that they all take a ucred. One the one hand it seems reasonable that they would all take a struct prison instead, but is there a particular reason to break the trend for this case?

D51525 and D51526 both require this change. In particular, I want to be able to determine, from a jail PR_METHOD_REMOVE callback, whether the jail belongs to its own VNET. There, there is no credential I can use.

I could instead add an alternative function or even just an inline "is PR_VNET set" check.

I could instead add an alternative function or even just an inline "is PR_VNET set" check.

I'm fine with the change, just didn't have the context.

I actually like the idea of the simple inline check, since I generally get annoyed by abstractions that are no easier to remember than the thing they're abstracting. But since that functions does exist, it seems best to just twist it a little to meet your needs.

This revision is now accepted and ready to land.Jul 25 2025, 5:46 PM

I could instead add an alternative function or even just an inline "is PR_VNET set" check.

I'm fine with the change, just didn't have the context.

I actually like the idea of the simple inline check, since I generally get annoyed by abstractions that are no easier to remember than the thing they're abstracting. But since that functions does exist, it seems best to just twist it a little to meet your needs.

I'd argue that using prison_owns_vnet() is every so slightly clearer than checking PR_VNET, at least to someone who isn't too familiar with jail internals. I had to take a minute to check that PR_VNET being set really does mean that the jail owns its VNET, and not just that the jail belongs to a non-default VNET.