From nobody Sun May 1 19:18:01 2022 X-Original-To: dev-commits-src-branches@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 022601AAB13D; Sun, 1 May 2022 19:18:02 +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 4Krwwn6b9cz3QMX; Sun, 1 May 2022 19:18:01 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651432681; 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=+WuX2rCmVadK1d/XnS4gk2Xr7D3kSA3ibd1udJIzUVI=; b=JpizOdyF8SJhzx2V2KaYINEPrqlDVFMyde9UMvvm16X0Epc7RqZNk0gFBvxF36HHmt5K6b esh0yqkGIKa5m8ty8eoirjfeNvKcSJVGiBv018Vw/EIwWCL0BhJ6ud0whoAhImlMMEcbcm et9LLYlbA5pfhM8G3Ki+hXxP07m/AMAe680AAZvzK36pM1rnwVOXM4q3PcffR/tlB2ufTi 5cs84qjVnM+xz/TIRTDJ45xbjhe2B0HC0OE2rm9MgbW8tcT//61gjQwGUCUQi2anHPtlQW blTKNzxpv2EAik1JKpUikJJPLN0jwqjF4kbaG0eM58Zr7wIEMhAowR94PupD7w== 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 C3E5C1B81A; Sun, 1 May 2022 19:18:01 +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 241JI15A012394; Sun, 1 May 2022 19:18:01 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 241JI1t2012393; Sun, 1 May 2022 19:18:01 GMT (envelope-from git) Date: Sun, 1 May 2022 19:18:01 GMT Message-Id: <202205011918.241JI1t2012393@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Ravi Pokala Subject: git: 3cbc8109a985 - stable/12 - lacp: short timeout erroneously declares link-flapping List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@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/stable/12 X-Git-Reftype: branch X-Git-Commit: 3cbc8109a9855edfa24425e7ed7abafa2300148a Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1651432681; 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=+WuX2rCmVadK1d/XnS4gk2Xr7D3kSA3ibd1udJIzUVI=; b=mZ9LuaWqdE77eqlDmF5qgjhp63+/lBuq4vUZoUou9eJnP1a3kBGPfdeI1GGLOBrt1CNwUv 9XEgUeyFZim2AihVqyeTiMal5aWb6SCmDqUrMgb+xCTh82lixRoHLua4/4Il6giW2lVXIV HWBtbqvkBHWjaCtHQj27Ir8P15eXBMXIctB+XUi4FQ9rR4BmUq1bJNxbLmzOO6JJpXL4Zf Cp0cr5Xj5sOxeDbSTUsQmqeXZPTBSZcWi/GDRqUvgalPyHjvzR/WXV0KZTJnsgz7ULTEpX E5BA7LXTg+BcRi8oiktwB7WEavpn05Q6rWqe0eWL5pWresh6SoHZlDx1rfblGA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1651432681; a=rsa-sha256; cv=none; b=LefG6ZiQ0kirtvPcoiweeUmQdK9S1PcsXkYZSSaLOIwILSwxhsZ2pOJYV32/UxP9SuXW4F kwlbBYmb4bP+rFvp8sbXnRb+0S+Jm5odDT63a4dkIsxjW8lwctaE8ZbUitszutAyiUH77M Yb4kX5ZKxxfncPckkt7rf4Q7U7RHxHIGeuRZlZo5DdIWjM0XKgXrSJXzegyWomSNv2BIkj Z+dVsWgMi+LBCrydPCj++opb6HYqKTR5TkbDiagugpxloD7jNJpgUXtIsIZFuDo3baA/xJ Cdt2vioFK2k/6NrJ+u9hJpZPwaKufj7ApNi1SJuf+zoIVQFw9ucovjt7uSpW5A== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/12 has been updated by rpokala: URL: https://cgit.FreeBSD.org/src/commit/?id=3cbc8109a9855edfa24425e7ed7abafa2300148a commit 3cbc8109a9855edfa24425e7ed7abafa2300148a Author: Greg Foster AuthorDate: 2022-04-26 06:38:23 +0000 Commit: Ravi Pokala CommitDate: 2022-05-01 19:16:53 +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 (cherry picked from commit 00a80538b4471b2978c5a1990f48189f2c692e24) --- 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 1bdc2d8b852c..61cd94e5ce2f 100644 --- a/sys/net/ieee8023ad_lacp.c +++ b/sys/net/ieee8023ad_lacp.c @@ -48,6 +48,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -1704,6 +1705,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); @@ -1913,14 +1915,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 5ae48cebb62d..10c6a2c9f892 100644 --- a/sys/net/ieee8023ad_lacp.h +++ b/sys/net/ieee8023ad_lacp.h @@ -215,6 +215,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;