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)
Feb 20 2024, 9:05 AM
Unknown Object (File)
Jan 3 2024, 12:27 PM
Unknown Object (File)
Dec 20 2023, 6:18 AM
Unknown Object (File)
Dec 15 2023, 5:17 AM
Unknown Object (File)
Dec 12 2023, 4:19 AM
Unknown Object (File)
Dec 3 2023, 11:39 PM
Unknown Object (File)
Jul 24 2023, 6:52 PM
Unknown Object (File)
Jul 24 2023, 6:38 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 Passed
Unit
No Test Coverage
Build Status
Buildable 47822
Build 44709: arc lint + arc unit

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