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, Nov 21, 6:38 AM
Unknown Object (File)
Oct 28 2024, 1:36 PM
Unknown Object (File)
Oct 26 2024, 7:07 AM
Unknown Object (File)
Oct 19 2024, 2:31 AM
Unknown Object (File)
Oct 8 2024, 5:12 AM
Unknown Object (File)
Sep 30 2024, 2:35 AM
Unknown Object (File)
Sep 14 2024, 7:06 AM
Unknown Object (File)
Sep 2 2024, 3:20 AM

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.