Bug 232397

Summary: ctld does not depend on sysctl.conf being evaluated
Product: Base System Reporter: Mahmoud Al-Qudsi <mqudsi>
Component: confAssignee: Edward Tomasz Napierala <trasz>
Status: Closed FIXED    
Severity: Affects Only Me CC: andrey, eborisch+FreeBSD, gldisater, grahamperrin, henric_jungheim, jcduss13, pete, trasz
Priority: ---    
Version: 11.2-STABLE   
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=254432
Attachments:
Description Flags
Add dependancy on NETWORKING none

Description Mahmoud Al-Qudsi 2018-10-18 17:47:55 UTC
The ctld service does not wait for sysctl.conf to be evaluated before running. 

Unfortunately, the drivers for some popular cards require sysctl configuration in sysctl.conf (not possible in loader.conf) to bring them up in the correct mode (e.g. mlx4/mlx4en to set the card in ip instead of ib mode), meaning that when ctld starts up, it fails immediately because it can't listen on the requested address.

I'm unsure how to modify /etc/rc.d/ctld to enact a dependency on sysctl.conf's evaluation; for my purposes I ended up hacking the ctld service itself to unconditionally execute the sysctls I need set prior to actually processing the service start command.
Comment 1 Jeremy Faulkner 2021-01-01 21:09:36 UTC
Created attachment 221173 [details]
Add dependancy on NETWORKING

If the ctl.conf specifies an IP address then ctld won't start. Adding a requirement on NETWORKING will solve my issue, and your example. What other sysctl's were you using?
Comment 2 Jeremy Faulkner 2021-01-13 01:20:55 UTC
NETWORKING requires netif which requires sysctl
Comment 3 Mahmoud Al-Qudsi 2021-01-13 05:28:23 UTC
Yup. This should do the trick.
Comment 4 Pete French 2021-03-17 14:12:23 UTC
I just hit this as well, not because of sysctl.conf, but because of specifying an IP address in ctld.conf. Can we get the dependency on NETWORKING include din time for 13 ?

Am guessing not, given the timing, but even just getting this fixed in current & stable would be nice...
Comment 5 Pete French 2021-03-17 14:14:09 UTC
BTW, having the bug as "affects only me" is a bit of a mischaracterisation, as this will affect anyone who only wants ctld to listen on a specific IP address wont it ?
Comment 6 Mark Linimon freebsd_committer freebsd_triage 2021-03-17 15:12:51 UTC
(In reply to Pete French from comment #5)
[Speaking for myself here, not as bugmeister@]

I will repeat my usual claim that the "Affects" setting is ... ah ... merely decorative.

In an organization that has paid employees who can be told "prioritze PRs based on the following criteria", such things mean something.

But we aren't such an organization.  I have never heard of any bug triagers that use that field to look for PRs.

If I were some kind of ruthless dictator I'd just turn it off :-)
Comment 7 commit-hook freebsd_committer freebsd_triage 2021-04-05 15:43:02 UTC
A commit in branch main references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=015351de04e3e621cff825cc1fdad5faf078c3ac

commit 015351de04e3e621cff825cc1fdad5faf078c3ac
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-04-05 15:40:49 +0000
Commit:     Edward Tomasz Napierala <trasz@FreeBSD.org>
CommitDate: 2021-04-05 15:40:54 +0000

    rc: make ctld depend on NETWORKING

    This fixes a problem where ctld(8) would refuse to start on boot
    with a specific IP address to listen on configured in ctl.conf(5).
    It also fixes a problem where ctld(8) would fail to start with
    some network interfaces which require a sysctl.conf(5) tweak
    to configure them, eg to switch them from InfiniBand to IP mode.

    PR:             232397
    Reported By:    Mahmoud Al-Qudsi <mqudsi at neosmart.net>
    Submitted By:   Jeremy Faulkner <gldisater at gmail.com>
    Reviewed By:    mav
    Differential Revision:  https://reviews.freebsd.org/D29578

 libexec/rc/rc.d/ctld | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 8 Pete French 2021-10-05 16:18:55 UTC
tripped up by this again today... could we get the patch MFC'd into 12 maybe ?
Comment 9 Andrey Fesenko 2022-01-11 22:02:25 UTC
13 too
Comment 10 commit-hook freebsd_committer freebsd_triage 2022-01-21 07:46:19 UTC
A commit in branch stable/13 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=c0163f4abef029cd5ed6db9357665ae29a86716d

commit c0163f4abef029cd5ed6db9357665ae29a86716d
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-04-05 15:40:49 +0000
Commit:     Andriy Gapon <avg@FreeBSD.org>
CommitDate: 2022-01-21 07:45:20 +0000

    rc: make ctld depend on NETWORKING

    This fixes a problem where ctld(8) would refuse to start on boot
    with a specific IP address to listen on configured in ctl.conf(5).
    It also fixes a problem where ctld(8) would fail to start with
    some network interfaces which require a sysctl.conf(5) tweak
    to configure them, eg to switch them from InfiniBand to IP mode.

    PR:             232397

    (cherry picked from commit 015351de04e3e621cff825cc1fdad5faf078c3ac)

 libexec/rc/rc.d/ctld | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 11 commit-hook freebsd_committer freebsd_triage 2022-01-21 07:48:21 UTC
A commit in branch stable/12 references this bug:

URL: https://cgit.FreeBSD.org/src/commit/?id=e265658e4e36c779c5c33bd9c25dd620eb83b886

commit e265658e4e36c779c5c33bd9c25dd620eb83b886
Author:     Edward Tomasz Napierala <trasz@FreeBSD.org>
AuthorDate: 2021-04-05 15:40:49 +0000
Commit:     Andriy Gapon <avg@FreeBSD.org>
CommitDate: 2022-01-21 07:46:42 +0000

    rc: make ctld depend on NETWORKING

    This fixes a problem where ctld(8) would refuse to start on boot
    with a specific IP address to listen on configured in ctl.conf(5).
    It also fixes a problem where ctld(8) would fail to start with
    some network interfaces which require a sysctl.conf(5) tweak
    to configure them, eg to switch them from InfiniBand to IP mode.

    PR:             232397
    Reported By:    Mahmoud Al-Qudsi <mqudsi at neosmart.net>
    Submitted By:   Jeremy Faulkner <gldisater at gmail.com>

    (cherry picked from commit 015351de04e3e621cff825cc1fdad5faf078c3ac)

 libexec/rc/rc.d/ctld | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 12 Andriy Gapon freebsd_committer freebsd_triage 2022-01-24 07:53:07 UTC
*** Bug 254432 has been marked as a duplicate of this bug. ***
Comment 13 eborisch+FreeBSD 2022-03-04 01:11:19 UTC
With 12.2 going EOL, there are likely to be another wave of updaters; it would be nice to get this simple fix into 13.0-pX. Lead to some mild panic these evening for myself.

(I knew I could always go back thanks to boot environments, so only mild. ;)
Comment 14 Graham Perrin freebsd_committer freebsd_triage 2022-03-14 08:15:12 UTC
(In reply to eborisch+FreeBSD from comment #13)

<https://github.com/freebsd/freebsd-src/commit/c0163f4abef029cd5ed6db9357665ae29a86716d> is in both stable/13 and releng/13.1