Page MenuHomeFreeBSD

ctld: if adding a target fails, retry it on the next reload
ClosedPublic

Authored by asomers on Oct 12 2022, 10:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Nov 3, 4:09 PM
Unknown Object (File)
Sun, Nov 3, 4:09 PM
Unknown Object (File)
Sun, Nov 3, 3:46 PM
Unknown Object (File)
Oct 4 2024, 4:29 PM
Unknown Object (File)
Oct 4 2024, 11:39 AM
Unknown Object (File)
Sep 27 2024, 6:30 PM
Unknown Object (File)
Sep 26 2024, 12:44 AM
Unknown Object (File)
Sep 24 2024, 12:15 PM
Subscribers

Details

Summary

If the admin creates more CTL ports than kern.cam.ctl.max_ports, then
adding some will fail. If he then removes some ports and does
"service ctld reload", he would expect that the new ports would get
added in the newly-freed port space. But they don't, because ctld
assigned them port numbers during their first creation attempts.

Fix this bug by removing newly created ports from ctld's internal list
if the kernel rejects them for any reason. That way, a subsequent
config reload will attempt to add them again, possibly with new port
numbers.

MFC after: 2 weeks
Sponsored by: Axcient

Test Plan

Manually tested

Diff Detail

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

Event Timeline

usr.sbin/ctld/ctld.c
2133

Do you want the 'port_is_dummy' check here as well?

usr.sbin/ctld/ctld.c
2133

I don't think it's needed. If oldport is a dummy, then we would've tried to add newport. And since there's an error, we should delete it. We know that at this point it isn't possible for newport to be a dummy.

usr.sbin/ctld/ctld.c
2133

Right, I mean that this should match the condition on line 2121 so that this mirrors kernel_port_add(). That is:

if (oldport == NULL || port_is_dummy(oldport))
   port_delete(newport);

Right now if oldport is a dummy and kernel_port_add fails, your change would still not delete newport.

usr.sbin/ctld/ctld.c
2133

Yep, you're right. I'll change it.

  • Also delete newport if old port is a dummy
This revision is now accepted and ready to land.Oct 21 2022, 6:51 PM