Page MenuHomeFreeBSD

jail: Avoid multipurpose return value of function prison_ip_restrict()

Authored by zlei on Dec 31 2022, 7:58 AM.
Referenced Files
Unknown Object (File)
Tue, Jun 6, 1:19 AM
Unknown Object (File)
Mon, Jun 5, 1:05 PM
Unknown Object (File)
Fri, May 26, 4:20 AM
Unknown Object (File)
Apr 8 2023, 8:44 PM
Unknown Object (File)
Apr 6 2023, 1:54 AM
Unknown Object (File)
Mar 23 2023, 6:07 AM
Unknown Object (File)
Mar 18 2023, 11:21 PM
Unknown Object (File)
Feb 26 2023, 9:36 PM



Currently function prison_ip_restrict() returns true if the replacement buffer was used, or no buffer provided and allocation fails and should redo. The logic is confusion and cause possibly infinite loop from eb8dcdeac22d .

No functional change intended.

Diff Detail

rG FreeBSD src repository
Lint Not Applicable
Tests Not Applicable

Event Timeline

It took me longer to remember what I had done in the first place than it did to understand the new logic. I like this.

This revision is now accepted and ready to land.Dec 31 2022, 8:04 PM
zlei retitled this revision from jail: Avoid multiple purpose return value of function prison_ip_restrict() to jail: Avoid multipurpose return value of function prison_ip_restrict().Jan 9 2023, 7:15 AM
zlei edited the summary of this revision. (Show Details)

Type of redo_ip4 can be changed to bool and this expression reduced to:

redo_ip4 = !prison_ip_restrict(tpr, PR_INET, &ip4);

Same applies to redo_ip6.

I'm planning to do this on stable branches.

Do you have any plans to MFC eb8dcdeac22d (and related fixes)?
If no I'd prefer commit this separately (from D37906) so it is easy to track and review.


Good catch!