Bug 262983 - net.pfsync.carp_demotion_factor value is "ignored"
Summary: net.pfsync.carp_demotion_factor value is "ignored"
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: 13.0-RELEASE
Hardware: amd64 Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-01 16:40 UTC by Luiz Amaral
Modified: 2022-04-11 18:06 UTC (History)
1 user (show)

See Also:


Attachments
carp_demotion_factor flag patch (816 bytes, patch)
2022-04-01 16:40 UTC, Luiz Amaral
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Luiz Amaral 2022-04-01 16:40:24 UTC
Created attachment 232871 [details]
carp_demotion_factor flag patch

During a maintenance to move our pfsync connection, I tried to set "net.pfsync.carp_demotion_factor" to 0 in order to avoid a CARP demotion while the pfsync service restarted, but to my surprise, the CARP still got demoted by the default value of 240.

The server is acting as a router, running GENERIC kernel, version 13.0-RELEASE-p6.

Upon investigation, I noticed that this sysctl was missing the flag CTLFLAG_VNET on its declaration.

After patching the code in sys/netpfil/pf/if_pfsync.c to include the flag, the sysctl started behaving as expected.

Reproduction steps:
$ sysctl net.pfsync.carp_demotion_factor=0
$ service pfsync restart
$ grep carp /var/log/syslog
Observe the carp still getting demoted by the default value, 240.
2022-03-31T09:09:16.428406+00:00 router-awtest-02 kernel: carp: demoted by 240 to 240 (pfsync bulk start)
2022-03-31T09:09:16.428423+00:00 router-awtest-02 kernel: carp: demoted by -240 to 0 (pfsync bulk done)

After applying the patch, the same steps should yield a demotion by 0:
2022-04-01T10:05:35.764685+00:00 router-awtest-02 kernel: carp: demoted by 0 to 0 (pfsync bulk start)
2022-04-01T10:05:35.764701+00:00 router-awtest-02 kernel: carp: demoted by 0 to 0 (pfsync bulk done)

The patch was applied to 13.0-RELEASE, but should also apply cleanly on CURRENT.
Comment 1 Luiz Amaral 2022-04-01 20:19:21 UTC
Code review request created: https://reviews.freebsd.org/D34737
Comment 2 commit-hook freebsd_committer freebsd_triage 2022-04-02 12:12:19 UTC
A commit in branch main references this bug:

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

commit 654c1b8ef3c0fcbad3a77ea2a6f35c0dffc86e88
Author:     Luiz Amaral <email@luiz.eng.br>
AuthorDate: 2022-04-02 10:09:06 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-04-02 10:11:32 +0000

    pfsync: Add CTLFLAG_VNET to carp_demotion_factor sysctl

    When trying to avoid a CARP demotion during a pfsync service restart, I
    noticed that a non-default value for the net.pfsync.carp_demotion_factor
    sysctl was not being applied during the demotion. The CARP was always
    demoted by 240.

    After investigating, I realized that the sysctl was using VNET_NAME()
    without the CTLFLAG_VNET.

    PR:             262983
    Reviewed by:    kp
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D34737

 sys/netpfil/pf/if_pfsync.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 3 Luiz Amaral 2022-04-07 11:28:59 UTC
I'm moving back to In Progress as I realized that there is the MFC pending.
Comment 4 commit-hook freebsd_committer freebsd_triage 2022-04-11 14:53:40 UTC
A commit in branch stable/12 references this bug:

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

commit 44250a19c8fd442e106aeb586bba33215caaedc5
Author:     Luiz Amaral <email@luiz.eng.br>
AuthorDate: 2022-04-02 10:09:06 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-04-11 14:52:51 +0000

    pfsync: Add CTLFLAG_VNET to carp_demotion_factor sysctl

    When trying to avoid a CARP demotion during a pfsync service restart, I
    noticed that a non-default value for the net.pfsync.carp_demotion_factor
    sysctl was not being applied during the demotion. The CARP was always
    demoted by 240.

    After investigating, I realized that the sysctl was using VNET_NAME()
    without the CTLFLAG_VNET.

    PR:             262983
    Reviewed by:    kp
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D34737

    (cherry picked from commit 654c1b8ef3c0fcbad3a77ea2a6f35c0dffc86e88)

 sys/netpfil/pf/if_pfsync.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 5 commit-hook freebsd_committer freebsd_triage 2022-04-11 14:53:41 UTC
A commit in branch stable/13 references this bug:

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

commit 68efe27ffaec8bec9968800f2eddeca2940b78e4
Author:     Luiz Amaral <email@luiz.eng.br>
AuthorDate: 2022-04-02 10:09:06 +0000
Commit:     Kristof Provost <kp@FreeBSD.org>
CommitDate: 2022-04-11 14:52:33 +0000

    pfsync: Add CTLFLAG_VNET to carp_demotion_factor sysctl

    When trying to avoid a CARP demotion during a pfsync service restart, I
    noticed that a non-default value for the net.pfsync.carp_demotion_factor
    sysctl was not being applied during the demotion. The CARP was always
    demoted by 240.

    After investigating, I realized that the sysctl was using VNET_NAME()
    without the CTLFLAG_VNET.

    PR:             262983
    Reviewed by:    kp
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D34737

    (cherry picked from commit 654c1b8ef3c0fcbad3a77ea2a6f35c0dffc86e88)

 sys/netpfil/pf/if_pfsync.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Comment 6 Ed Maste freebsd_committer freebsd_triage 2022-04-11 18:06:20 UTC
Mark closed again, has been MFC'd