From nobody Sun Dec 19 01:20:15 2021 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 42A6818F61A2; Sun, 19 Dec 2021 01:20:16 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JGlJb6yT4z4hBk; Sun, 19 Dec 2021 01:20:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C928219861; Sun, 19 Dec 2021 01:20:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 1BJ1KFQb098812; Sun, 19 Dec 2021 01:20:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 1BJ1KFiv098808; Sun, 19 Dec 2021 01:20:15 GMT (envelope-from git) Date: Sun, 19 Dec 2021 01:20:15 GMT Message-Id: <202112190120.1BJ1KFiv098808@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Gleb Smirnoff Subject: git: 9a8cf950b259 - main - carp: fix send error demotion recovery List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: glebius X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 9a8cf950b259f6833c7562ce941b0cfeae6687e5 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1639876816; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UJmM8UZtJzJ6JUOGP5tS45SlXlS6aSal/xKne5i1WFc=; b=nreZyHkKbYNjLfR1OR2mld5lc6q2zXXgqDqPI9scNYgA0nE9wqn5VwwwjioY7SDjWxGby4 fGTUTcIi+RSLURab9Pqk8uGE/nc91nvHh6NoNQ+PTU+/UFUg5x/OzTxZHlJUN0OP4/fRIe C8tj6s3vEWM9cU7ww8lddXCOXmpLiAllkZJTFgNQLuYLrdDAsG4xFzORjjQKt1j4dBoOPL QZ6igRA7uYTkdFITKbau3zt/ffEc8EzLbkMvBDnm073GIxK51Wa8GKa90n2w23pJsSWDve UxqOLr1wz6JgGw8cT37AlD9ywBXyAlxZd1E6EHJ7m8CgPWrXUw5xicLT/IT+sQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1639876816; a=rsa-sha256; cv=none; b=P8CNKZdTiwJ4Wf1gBun3hWls/kW0zjN+vTd36aMUS6Gh9Da03JmzHEj1pIHJfjLf058f77 yTP4J5AvI0CmIB5xES3zwIryh7OgO9HRd7oZ7bwn/xXRPIrtBN5lJ7yV7VaNxBtX8tvk4P E3LGpctzZIbwKZc6ukiFZktagYeL87BwlU0zmtg+YWtPGuHrOGsLVKC36O2jymOLKyanj+ GNT9gk3EBvm8BkCylvp6Okl7ya0llwc8NfjzwT5o8E/ZZP0qXENoT5GlNZn9cMmDQwhm3e cdebbzIn2DuL09tqVvqLXKQbOCvV/NWnTA9OTTcsYUOb+m3kvbv03DxL/E8tjQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by glebius: URL: https://cgit.FreeBSD.org/src/commit/?id=9a8cf950b259f6833c7562ce941b0cfeae6687e5 commit 9a8cf950b259f6833c7562ce941b0cfeae6687e5 Author: Gleb Smirnoff AuthorDate: 2021-12-19 01:19:26 +0000 Commit: Gleb Smirnoff CommitDate: 2021-12-19 01:19:26 +0000 carp: fix send error demotion recovery The problem is that carp(4) would clear the error counter on first successful send, and stop counting successes after that. Fix this logic and document it in human language. PR: 260499 Differential revision: https://reviews.freebsd.org/D33536 --- sys/netinet/ip_carp.c | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/sys/netinet/ip_carp.c b/sys/netinet/ip_carp.c index 7554becb974e..71558be619d8 100644 --- a/sys/netinet/ip_carp.c +++ b/sys/netinet/ip_carp.c @@ -854,6 +854,13 @@ static void carp_send_ad_error(struct carp_softc *sc, int error) { + /* + * We track errors and successfull sends with this logic: + * - Any error resets success counter to 0. + * - MAX_ERRORS triggers demotion. + * - MIN_SUCCESS successes resets error counter to 0. + * - MIN_SUCCESS reverts demotion, if it was triggered before. + */ if (error) { if (sc->sc_sendad_errors < INT_MAX) sc->sc_sendad_errors++; @@ -865,17 +872,17 @@ carp_send_ad_error(struct carp_softc *sc, int error) carp_demote_adj(V_carp_senderr_adj, msg); } sc->sc_sendad_success = 0; - } else { - if (sc->sc_sendad_errors >= CARP_SENDAD_MAX_ERRORS && - ++sc->sc_sendad_success >= CARP_SENDAD_MIN_SUCCESS) { - static const char fmt[] = "send ok on %s"; - char msg[sizeof(fmt) + IFNAMSIZ]; - - sprintf(msg, fmt, sc->sc_carpdev->if_xname); - carp_demote_adj(-V_carp_senderr_adj, msg); - sc->sc_sendad_errors = 0; - } else + } else if (sc->sc_sendad_errors > 0) { + if (++sc->sc_sendad_success >= CARP_SENDAD_MIN_SUCCESS) { + if (sc->sc_sendad_errors >= CARP_SENDAD_MAX_ERRORS) { + static const char fmt[] = "send ok on %s"; + char msg[sizeof(fmt) + IFNAMSIZ]; + + sprintf(msg, fmt, sc->sc_carpdev->if_xname); + carp_demote_adj(-V_carp_senderr_adj, msg); + } sc->sc_sendad_errors = 0; + } } }