[Bug 262983] net.pfsync.carp_demotion_factor value is "ignored"

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 01 Apr 2022 16:40:24 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=262983

            Bug ID: 262983
           Summary: net.pfsync.carp_demotion_factor value is "ignored"
           Product: Base System
           Version: 13.0-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: email@luiz.eng.br

Created attachment 232871
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=232871&action=edit
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.

-- 
You are receiving this mail because:
You are the assignee for the bug.