From nobody Wed Apr 27 19:59:21 2022 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 083B41AA9FA7; Wed, 27 Apr 2022 19:59:22 +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 4KpV2K6nMLz3P9Q; Wed, 27 Apr 2022 19:59:21 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651089562; 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=QYj+YkNSScTSh66gL5Lr4PX3tCi2tTtfaYAlkyF2c30=; b=H56MsVzW6Ke3gcQSCR2TK1f5EcNWjft8XXRDA5lgS7PLmI6/Hkmdx0IFrLWaDidfXbTKOI k9Jr5ZZcvz4PL+lLiWrIMfJs02h5bXS/Ec6UqcuuOer60D178uWAOO7D7m13/zS/gQ7My9 LfLaZNqg4WqjAquSUhJmeeYrft7Nvzo6oCkBDT1w2cMDYyR/woKi4e7jxb9swjxgRwKdOe 7NcVdt0qhTjdNMWNfha3g+uup2YtPxTN+8FEKJEJ8onBU+BPuqGSo3gnGCtjUBjf/TysuF jGYB2Nd7ZEv4QJBpEK76j6l0CNSc9viZlN82B6V0Br+HUvWBWG5MMGHqpYfajQ== 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 C57112607; Wed, 27 Apr 2022 19:59:21 +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 23RJxLVX087719; Wed, 27 Apr 2022 19:59:21 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 23RJxLJw087718; Wed, 27 Apr 2022 19:59:21 GMT (envelope-from git) Date: Wed, 27 Apr 2022 19:59:21 GMT Message-Id: <202204271959.23RJxLJw087718@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Ravi Pokala Subject: git: 00a80538b447 - main - lacp: short timeout erroneously declares link-flapping 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: rpokala X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 00a80538b4471b2978c5a1990f48189f2c692e24 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651089562; 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=QYj+YkNSScTSh66gL5Lr4PX3tCi2tTtfaYAlkyF2c30=; b=mPmrVtNQ9UVGyENlLLgpoV6uuP9X7em9Syh58WYxDQr8WZJLWvuNFkosjZsttgeRM1Dmw/ 5NHv61v2TUk3MibPr5HnSxVm+DsqITR1/YfXna/uB9NL66j52COiYOmBed1P52b6FUjQik +nH164p7AVqvk26AliGxKSWdyQEj6jwjYuieRrBYn3gIfoZ6m3fP58ItyHKE2rmQ0shsrm RahXUvyHqJrmwovzFB3zqWcYZ6RBUmfOSOdCaISEAnfpYqZjr53aFfwuNCeZbNJ2B6+P6u WC3IibFQd6shkqjfPlu46GRoVw3MODc9O5LoyadM355+rm9vZw+qyxEc2zcQqA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651089562; a=rsa-sha256; cv=none; b=aIxNBHd+yjVz0kVGGGdQLo7fzK5z0WJJAlKjW1z9KIaTsRksXavUHBrz96E07MqsTh1PeE kFCjI91hBjehV8gg38rN9G3au1Rzn073tEnsRXm09knYYyKp3joAPA6KcuDIm6gNXpJhGz ST4ycnA5OBZQ828fMQ/PFbQg2HGTtfOhd9sBw6A+WyXxGL7cjy4HFclkvbF6Uey1Ghv3Lu uyq5rt1pT2D86Ix2YCsyIYNWMWTbZwlwyAsvvqAgYy3rPqGwQ9/bcUhRGU3EhOHUO4DgmD 4I4zSdSmxXadhJjAquAGPkTvW2vUqkz9YTRQZ+0Dm/1kuXQfBRnKCBn9KQh+Yw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by rpokala: URL: https://cgit.FreeBSD.org/src/commit/?id=00a80538b4471b2978c5a1990f48189f2c692e24 commit 00a80538b4471b2978c5a1990f48189f2c692e24 Author: Greg Foster AuthorDate: 2022-04-26 06:38:23 +0000 Commit: Ravi Pokala CommitDate: 2022-04-27 19:41:30 +0000 lacp: short timeout erroneously declares link-flapping Panasas was seeing a higher-than-expected number of link-flap events. After joint debugging with the switch vendor, we determined there were problems on both sides; either of which might cause the occasional event, but together caused lots of them. On the switch side, an internal queuing issue was causing LACP PDUs -- which should be sent every second, in short-timeout mode -- to sometimes be sent slightly later than they should have been. In some cases, two successive PDUs were late, but we never saw three late PDUs in a row. On the FreeBSD side, we saw a link-flap event every time there were two late PDUs, while the spec says that it takes *three* seconds of downtime to trigger that event. It turns out that if a PDU was received shortly before the timer code was run, it would decrement less than a full second after the PDU arrived. Then two delayed PDUs would cause two additional decrements, causing it to reach zero less than three seconds after the most-recent on-time PDU. The solution is to note the time a PDU arrives, and only decrement if at least a full second has elapsed since then. Reported by: Greg Foster Reviewed by: gallatin Tested by: Greg Foster MFC after: 3 days Sponsored by: Panasas Differential Revision: https://reviews.freebsd.org/D35070 --- sys/net/ieee8023ad_lacp.c | 18 ++++++++++++++++-- sys/net/ieee8023ad_lacp.h | 1 + 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/sys/net/ieee8023ad_lacp.c b/sys/net/ieee8023ad_lacp.c index cf07890e051f..1e2e638fcdf5 100644 --- a/sys/net/ieee8023ad_lacp.c +++ b/sys/net/ieee8023ad_lacp.c @@ -49,6 +49,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -1731,6 +1732,7 @@ lacp_sm_rx(struct lacp_port *lp, const struct lacpdu *du) * EXPIRED, DEFAULTED, CURRENT -> CURRENT */ + microuptime(&lp->lp_last_lacpdu_rx); lacp_sm_rx_update_selected(lp, du); lacp_sm_rx_update_ntt(lp, du); lacp_sm_rx_record_pdu(lp, du); @@ -1940,14 +1942,26 @@ static void lacp_run_timers(struct lacp_port *lp) { int i; + struct timeval time_diff; for (i = 0; i < LACP_NTIMER; i++) { KASSERT(lp->lp_timer[i] >= 0, ("invalid timer value %d", lp->lp_timer[i])); if (lp->lp_timer[i] == 0) { continue; - } else if (--lp->lp_timer[i] <= 0) { - if (lacp_timer_funcs[i]) { + } else { + if (i == LACP_TIMER_CURRENT_WHILE) { + microuptime(&time_diff); + timevalsub(&time_diff, &lp->lp_last_lacpdu_rx); + if (time_diff.tv_sec) { + /* At least one sec has elapsed since last LACP packet. */ + --lp->lp_timer[i]; + } + } else { + --lp->lp_timer[i]; + } + + if ((lp->lp_timer[i] <= 0) && (lacp_timer_funcs[i])) { (*lacp_timer_funcs[i])(lp); } } diff --git a/sys/net/ieee8023ad_lacp.h b/sys/net/ieee8023ad_lacp.h index f02a9e7d9a43..0610ed855d50 100644 --- a/sys/net/ieee8023ad_lacp.h +++ b/sys/net/ieee8023ad_lacp.h @@ -222,6 +222,7 @@ struct lacp_port { #define lp_key lp_actor.lip_key #define lp_systemid lp_actor.lip_systemid struct timeval lp_last_lacpdu; + struct timeval lp_last_lacpdu_rx; int lp_lacpdu_sent; enum lacp_mux_state lp_mux_state; enum lacp_selected lp_selected;