git: 1c16de99bd7d - stable/12 - carp: deal with negative net.inet.carp.demotion
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 22 Nov 2021 05:16:00 UTC
The branch stable/12 has been updated by kp: URL: https://cgit.FreeBSD.org/src/commit/?id=1c16de99bd7ddddad9d5877ba0f91aa2a2f57eb3 commit 1c16de99bd7ddddad9d5877ba0f91aa2a2f57eb3 Author: Marius Halden <marius.halden@modirum.com> AuthorDate: 2021-10-31 20:18:42 +0000 Commit: Kristof Provost <kp@FreeBSD.org> CommitDate: 2021-11-22 01:55:13 +0000 carp: deal with negative net.inet.carp.demotion Given nodes 1 and 2, where node 1 has an advskew of 0 and node 2 has an advskew of 100, making them master and backup respectively. If net.inet.carp.demotion is set to a negative value on node 1, node 2 might become master while node 1 still retains it master status. Wether or not node 2 becomes master seems to depend on the nodes advskew and what the demotion sysctl was set to on node 1. The reason for node 2 becoming master seems to be that the calculated advskew taking demotion into account is truncated to a single unsigned byte when copied into the carp header for sending, and node 1 stays master since it takes uses the whole non-truncated calculated advskew when deciding wether to stay master. PR: 259528 Reviewed by: donner, glebius MFC after: 3 weeks Sponsored by: Modirum MDPay Differential Revision: https://reviews.freebsd.org/D32759 (cherry picked from commit 1019354b54161c140d10a8203ff1e849c09c8010) --- sys/netinet/ip_carp.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index f4f051d14fee..acf819df694a 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -301,7 +301,9 @@ SYSCTL_VNET_PCPUSTAT(_net_inet_carp, OID_AUTO, stats, struct carpstats, #define DEMOTE_ADVSKEW(sc) \ (((sc)->sc_advskew + V_carp_demotion > CARP_MAXSKEW) ? \ - CARP_MAXSKEW : ((sc)->sc_advskew + V_carp_demotion)) + CARP_MAXSKEW : \ + (((sc)->sc_advskew + V_carp_demotion < 0) ? \ + 0 : ((sc)->sc_advskew + V_carp_demotion))) static void carp_input_c(struct mbuf *, struct carp_header *, sa_family_t); static struct carp_softc