Page MenuHomeFreeBSD

Teach route(8) to run in jails
ClosedPublic

Authored by nyan_myuji.xyz on Jun 1 2023, 2:44 PM.
Tags
Referenced Files
Unknown Object (File)
Thu, Jun 6, 11:34 AM
Unknown Object (File)
Mon, May 27, 6:57 PM
Unknown Object (File)
Mon, May 27, 6:57 PM
Unknown Object (File)
Sat, May 25, 5:06 PM
Unknown Object (File)
May 9 2024, 10:38 PM
Unknown Object (File)
May 7 2024, 10:37 AM
Unknown Object (File)
Apr 26 2024, 12:44 AM
Unknown Object (File)
Apr 21 2024, 1:57 PM

Details

Summary

Add -j <jail> flag to route(8) to allow route to perform actions in
a Jail.

Diff Detail

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

Event Timeline

Thank you for working on this! Conceptually it LGTM, please see a comment on the implementation part.

sbin/route/route.c
237

I'd rather save the parameter here and explicitly call some jail_attach wrapper later. This will help keep argument parsing and business logic split, hopefully maintaining the same level of readability

  • move jail attach away from arg parse

@melifaro Thank you so much for reviewing and the suggestion! I have moved the jail attach bit out and added the missed Makefile changes. (oops)

melifaro added inline comments.
sbin/route/route.c
238

Do we need usejail at all?

This revision is now accepted and ready to land.Jun 1 2023, 7:30 PM

It reads to me like initialising jail_name to NULL and replacing if (usejail) with if (jail_name != NULL) would make the usejail variable superfluous. Splitting a pointer and its validity into two variables like this (jail_name and usejail) introduces the potential for contradiction if only one of the two is updated. If this split is required for something I would like to see them stored together in a struct { char *, bool } instead of destructured into two variables.

sbin/route/route.c
238

It reads to me like initialising jail_name to NULL and replacing if (usejail) with if (jail_name != NULL) would make the usejail variable superfluous. Splitting a pointer and its validity into two variables like this (jail_name and usejail) introduces the potential for contradiction if only one of the two is updated. If this split is required for something I would like to see them stored together in a struct { char *, bool } instead of destructured into two variables.

This revision now requires review to proceed.Jun 2 2023, 6:00 PM
This revision is now accepted and ready to land.Jun 12 2023, 2:49 PM

The jail_name variable must be initialised to NULL. This should be done through an explicit char * jail_name = NULL; in line 101 of route.c.

This revision now requires changes to proceed.Jun 12 2023, 2:53 PM

The jail_name variable must be initialised to NULL. This should be done through an explicit char * jail_name = NULL; in line 101 of route.c.

Static storage are always initialized to 0/NULL by C standard.

This revision was not accepted when it landed; it landed in state Needs Revision.Jun 13 2023, 6:08 AM
This revision was automatically updated to reflect the committed changes.

The jail_name variable must be initialised to NULL. This should be done through an explicit char * jail_name = NULL; in line 101 of route.c.

Static storage are always initialized to 0/NULL by C standard.

You're correct. Looking at just the diff again I assumed it was allocated on the stack instead of in the bss section.