Page MenuHomeFreeBSD

ctld: Use nvlist instead of home-rolled name-value lists
ClosedPublic

Authored by jhb on Jan 22 2025, 7:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Feb 21, 6:37 AM
Unknown Object (File)
Sat, Feb 15, 12:47 AM
Unknown Object (File)
Tue, Feb 11, 3:39 PM
Unknown Object (File)
Mon, Feb 10, 11:05 PM
Unknown Object (File)
Mon, Feb 10, 7:10 PM
Unknown Object (File)
Mon, Feb 10, 12:04 AM
Unknown Object (File)
Sat, Feb 8, 2:14 AM
Unknown Object (File)
Wed, Feb 5, 8:42 PM
Subscribers

Diff Detail

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

Event Timeline

asomers added inline comments.
usr.sbin/ctld/kernel.c
643

Since you aren't using the type, anyway.

This revision now requires changes to proceed.Jan 22 2025, 10:52 PM
usr.sbin/ctld/kernel.c
643

Ah, ok. I thought it was mandatory for some reason. I think I need to fix this in a couple of places.

usr.sbin/ctld/ctld.c
1565

Another place that doesn't need type

This revision is now accepted and ready to land.Jan 23 2025, 4:14 PM

I don't remember nvlists much, but shouldn't errors be checked via nvlist_error() sometimes?

usr.sbin/ctld/ctld.c
1566

The number of arguments seems to not match here. There should be prefix passed first. Considering the #if 0 I wonder if it was even build-tested.

I'm not quite sure where to put the nvlist_error calls TBH.

usr.sbin/ctld/ctld.c
1566

Oops, no, I was just trying to update the existing #if 0 code, but I haven't tried to make use of it.

In D48595#1109250, @jhb wrote:

I'm not quite sure where to put the nvlist_error calls TBH.

Kind of everywhere where errors are possible, I think. On a quick look it seems nvlist functions just stop working after some first error has happened. So I guess it may produce weird results if errors are not checked the caller. But In particular I've noticed that you removed ability to return errors from few places in parse.y.

In D48595#1109269, @mav wrote:
In D48595#1109250, @jhb wrote:

I'm not quite sure where to put the nvlist_error calls TBH.

Kind of everywhere where errors are possible, I think. On a quick look it seems nvlist functions just stop working after some first error has happened. So I guess it may produce weird results if errors are not checked the caller. But In particular I've noticed that you removed ability to return errors from few places in parse.y.

So nvlist_pack() will fail and an error will ultimately get reported that way. I will re-add the duplicate option handling that was previously done in option_new (probably bringing back option_new as a wrapper).

In general the only way nvlist will fail is if malloc() fails, and if that happens the program is likely to crash anyway. I know ctld is one of the few programs we have that tries to check the results of calloc() and malloc(), but if that has failed you are almost better off crashing than running in a crippled state where you can't do anything (and outputting errors is probably going to try to call malloc() somewhere and blow up anyway).

Restore various error checks

This revision now requires review to proceed.Jan 23 2025, 8:36 PM
This revision was not accepted when it landed; it landed in state Needs Review.Thu, Jan 30, 3:49 PM
This revision was automatically updated to reflect the committed changes.