From patchwork Tue Sep 19 11:37:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Erik Karlsson X-Patchwork-Id: 1836659 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=ElqakEVA; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=eZ/VwFfZ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.openwrt.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4RqfsQ4Kcnz1ync for ; Tue, 19 Sep 2023 21:42:18 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=tfAsplaKvqI3ZBiO2nlQubqUy89VkWB1uVHzi2Q5/TE=; b=ElqakEVA/ZBpXr hoa9ezvUi2iF//20DJBaP0jrGhcAqvAlVj2ToVtOEmw/dZrlo+42HDGWyzDOAHNSEdUIVNK8VFQlV 9q80x0s+YOpEv8qcsXW6wK5CPJxVRU0xUhID+ca2/lz20nCHp4FmHaKtY1yONclN3QeQ8CXYEEU+X aQDy2QFTal8v+pUrn4HomG3jui8znIjlnjjMQzNCprKFRP0EHEYH7jzJkwXAJ8uAHHRlJrGUsZnsI nWzlIxK1Rf3iL5g9O2y4dKzGe+FfV1oQ4Twp7DZHrdfYf6amSwEKcOsjy7lth8Rr1ZRwrpPSmw2DP k71M3vi2pFKasyPk+Rig==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qiZ5X-000JQZ-0M; Tue, 19 Sep 2023 11:40:19 +0000 Received: from mail-lj1-x232.google.com ([2a00:1450:4864:20::232]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qiZ5U-000JP8-08 for openwrt-devel@lists.openwrt.org; Tue, 19 Sep 2023 11:40:17 +0000 Received: by mail-lj1-x232.google.com with SMTP id 38308e7fff4ca-2b703a0453fso92433861fa.3 for ; Tue, 19 Sep 2023 04:40:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695123613; x=1695728413; darn=lists.openwrt.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=PvEW+lttD/hD9olA+rpnMno7R2gGH+ZZGZGNc3/CAeE=; b=eZ/VwFfZGVjdwDTH7nsZjtmA32zkMqBUAbaiVmgPQ2dEvicKQz4RtEPDLEVE9GjboS pwJOyH5jdruoEuVOIJ3krJcTf6NmwrzjXIPUgj5QiMGacJ8Bd0xqmr1nnG3yq1E4URi1 sznaxcXtgsWIBl486iKO2WsH+oYbRndJuc0HH0XIFF0fs38Ck8olEo/Mc+TQkh3f9Jkh 7KChJswxg3wIL5OJSq7ULRpAhFOH+vlN73H/KWPwddvZhbuxxw+2iZxW4kmkuxpFzQl7 i/csK9wualfg1LJMP6+VvauQPKXXVcNANSLyWPEDevOtGIzrKPDv2BUI6TLMrnFUpUXV ijFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695123613; x=1695728413; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=PvEW+lttD/hD9olA+rpnMno7R2gGH+ZZGZGNc3/CAeE=; b=H+gmb7uZuI8oZvNg3i97KszTSefd3Qhmbh3vKU3p7ImyGCSXdXM2as0FJUN+TqVi4Q U2LXOZ25XBL6PwTJSCxnERUPWzMh9+Ia3w6ZFVj689V0RHqhTSwBZSiFpbKL9lg5mhVD J7l0bA4EIPiIAFUq7L+R6qeQ+Hj2dqu5wXNlJUaw1kCgyrugzIVtfrzbibATIkyRag/T r3vbNxNQgQUsf9QgMib50A1Ism6UJfa53Q1ch2LB03lmIVwCc8qpEpx2MMtKVOOTMJjH 4C5APlAvmvAZ5xf6rPd+LyVECEYHa2PR3Mq41ghipK5yPOEIgT3bkAv24ZjEp7I0u0Fk 5NDg== X-Gm-Message-State: AOJu0Yy+HeIahj/92vRIC0/ekLHic5jqL2AX1U6W1N1Y6eRdjBGmuddl Dg0NvJVTg5mrVD19/4SJL6IzB/TxvLE= X-Google-Smtp-Source: AGHT+IHKO9LKD4xIuXzASXMr9uL/TYnKw/4rbRMmSVZ8p5WjFQlGfvT8fSMKuLGsV0THx2HO+3XykQ== X-Received: by 2002:a05:651c:19ab:b0:2bf:f6b6:6c31 with SMTP id bx43-20020a05651c19ab00b002bff6b66c31mr7993036ljb.41.1695123612589; Tue, 19 Sep 2023 04:40:12 -0700 (PDT) Received: from se-pc-erik.genexislocal.nl ([2001:9b0:1:3302:703:aa92:cdd0:1246]) by smtp.gmail.com with ESMTPSA id x5-20020a05651c104500b002bfc44dd6b3sm2499511ljm.63.2023.09.19.04.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 04:40:12 -0700 (PDT) From: Erik Karlsson To: openwrt-devel@lists.openwrt.org Cc: Erik Karlsson Subject: [PATCH netifd] interface: do not release device on link down Date: Tue, 19 Sep 2023 13:37:59 +0200 Message-Id: <20230919113800.27593-1-erik.r.karlsson@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230919_044016_076690_4CA1AA20 X-CRM114-Status: GOOD ( 14.61 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Erik Karlsson On IFPEV_DOWN, do not release the main device if the interface is intended to be brought back up again by interface_handle_config_change and there is no configuration change. This avoids releasing the [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:232 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [erik.r.karlsson[at]gmail.com] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "openwrt-devel" Errors-To: openwrt-devel-bounces+incoming=patchwork.ozlabs.org@lists.openwrt.org From: Erik Karlsson On IFPEV_DOWN, do not release the main device if the interface is intended to be brought back up again by interface_handle_config_change and there is no configuration change. This avoids releasing the device and then claiming it again when link is lost. Releasing and then claiming the device can, if the driver is configured to power the PHY down when IFF_UP is cleared, cause the PHY to be power cycled. This can in combination with glitchy hardware and/or drivers where it takes a few seconds for the link to stabilize after the PHY has been powered up cause a loop where loss of link causes netifd to power cycle the PHY and when the PHY comes back up the link glitches and the cycle repeats. Signed-off-by: Erik Karlsson --- interface.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/interface.c b/interface.c index a18e872..151dc9d 100644 --- a/interface.c +++ b/interface.c @@ -774,7 +774,7 @@ interface_proto_event_cb(struct interface_proto_state *state, enum interface_pro netifd_log_message(L_NOTICE, "Interface '%s' is now down\n", iface->name); mark_interface_down(iface); interface_write_resolv_conf(iface->jail); - if (iface->main_dev.dev) + if (iface->main_dev.dev && !(iface->config_state == IFC_NORMAL && iface->autostart && iface->available)) device_release(&iface->main_dev); if (iface->l3_dev.dev) device_remove_user(&iface->l3_dev);