From nobody Sun Feb 8 05:42:37 2026 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CF9882D5922 for ; Sun, 18 Jan 2026 11:00:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768734030; cv=none; b=fP16iJXOdR4dPukww9Xe3EIA52oW1Cg1YWQNScBXteIWi7byOGoxNbngxwNXmM5GqCgjdt9ZJZ/UjmwbsWbF9osgz67K5MjvNZNMi/IBFkxyGhAbTrDrk5/UmlE9tZAoM3TS9ZrA+GDfYLyyYlh9SlMqGW1eMCv+8UDylxM+igE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768734030; c=relaxed/simple; bh=xTW7lVbfJsgnlziO9m7HRTBaTgvYhjTEK5XGbQnoB3Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Re3KDp5QLnctHa8VS6OEyO0hMauPDiCtX9Uz65Sm1ckW08EYsYyQsb8SV8dADq4uePdvKRqKPZfk5eklLJifbNZO1lMJIhjlgcJYG2+RGhN0OtVUMRMfjSKfFaJAWG9SnhL9IDTf+9chh1b+G9f0lKlvE+PWRdeuSku+N6KM+E4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ObtrVycN; arc=none smtp.client-ip=209.85.221.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ObtrVycN" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-42fb6ce71c7so3036240f8f.1 for ; Sun, 18 Jan 2026 03:00:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768734027; x=1769338827; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=uKBmUb8EWfQ3VixqXwZwtOjhnNqHJe7y4QanLPyxD5w=; b=ObtrVycNhWQxpzGEbvfkl6t74RD+e5Xa8s5K+vzWrG4huyRSRM1lXj3b/5u6vP19Ot CBTCp1s/plfYmd/GqQ4VATWlw5vY9pxkoAxtPVLdXjkKrtR0bi8WqHS9wTLp/7NNp9J0 86pbwEAhyxSBKmwwIelLMyVSgD6m/cba3ZbHM4zwfvsTd8fvCXzERn5T4loCldcyYWoL oojMehVHZiCZUDuZ9NbOwjdWSgSsyIOedMx7IN6CLUUUo9VG0h/5eBy6UwqvxBJe+QdI eri0BSPXaNiN/i/FWFuTR6nag9xTOBA93F5/ON7cfgVCAm4bqOJaaSV+7TjMKTnLV8SF 9pYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768734027; x=1769338827; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=uKBmUb8EWfQ3VixqXwZwtOjhnNqHJe7y4QanLPyxD5w=; b=D//EYyc70MX/HHLaJsmd56o0q+sW+sut1auncawBNLA8rJlVLAsW1DyhCvwfd3/08j Deud7iA6gg6ghndjIVxuPYht+K0cP+7Lb2/Jbpf05R2fa/ivFjtVYTPprATANRb1DKcV db4cnXlbg2AfskDsL1aFLzUbcWKRV4cyR928fpCLv55kB93GTWB++HFdlFI6q7x+hjbe pWZX64etv3wtPwQmlx3Ue0aMjEDW/Ml5cvodj2ni/hlIdneNkdto8tMturDU6NMhy9Tg xeZ53nJFTUPl1tUKj/80eKoTE+ZZikg2hG6e0srtgh8iMOXy/FbhcJ5z20Lr0PHY53XA hzug== X-Forwarded-Encrypted: i=1; AJvYcCWQmyABrHqCarMjmfQ6cxuGekLNBvXFTL9usdDR4KrEjeiVdnC+3fnithj0BhpncOCPPDenXMlq4zNTMyc=@vger.kernel.org X-Gm-Message-State: AOJu0YwUyl6Jrfy2ed6HgxQsx1gXv5Od0VWrXY6FAUP68VILqFq3PEiL DxfIqDa9HzNGKUiSwdVVNiLurJzxAlFnRnSrWMmKguorJ98TWgMJ9rWU X-Gm-Gg: AY/fxX5esDvVZHnPzijCl2JZKAYLaP6EaTMk+XMlxuDknRMqCvkYuUVgHOqIYgfYSUA 5iQWv5dTjsitK19cvFazbCnZf4v9qAhFWa4B7FNZCx9VEg+z7THuhjt7DBE0FeARpKwZcXlR+/f 6RjBIfy4/76JBKXC8wb7RpNjZ6W+Qd5088ddI24+qSf+y6mMqXHrGkDRVg6bnrp/BiLtiVoCKDi vwp6XwqAW0Hi1I5lySncOO9cBqgRAu39yRM0dc8uTS/XLyYAg4LBm5yMjwJQfp9VDkbOk8td0q+ yhMDkb2mWUSDy3PNz5RWEPGRywOYVnnvWRnSF7H0GZfmbbzlJ/RfWMxR/SOxrbdrn/0vuYO27Hy b3e2yLjKg8ve0PIWohjfxuss1Rfq39A8arPcea/xotrCi7vT2X+f/ngKyOzD2YkviTvLsyq8GRl NdXY91W2ohoOXI9w== X-Received: by 2002:a05:6000:2508:b0:42f:a025:92b3 with SMTP id ffacd0b85a97d-4356997f624mr9664336f8f.2.1768734027088; Sun, 18 Jan 2026 03:00:27 -0800 (PST) Received: from [192.168.1.243] ([143.58.192.3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4356992201csm16864635f8f.2.2026.01.18.03.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jan 2026 03:00:26 -0800 (PST) From: Andre Carvalho Date: Sun, 18 Jan 2026 11:00:21 +0000 Subject: [PATCH net-next v11 1/7] netconsole: add target_state enum Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260118-netcons-retrigger-v11-1-4de36aebcf48@gmail.com> References: <20260118-netcons-retrigger-v11-0-4de36aebcf48@gmail.com> In-Reply-To: <20260118-netcons-retrigger-v11-0-4de36aebcf48@gmail.com> To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Andre Carvalho X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1768734024; l=747; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=BLduFEel2At1ZpRoHzUB/43M6t0wpDLHJLh+eokOBeA=; b=EXwY2RlQfw+7R/YiOkF4CCoYwqRLJCiNBYIb5qg9mHzMZqxohK2PlhJhzFdz5dhoB5uLQcSEK 721xCiHBkgnDeNXximlgcX9AUeO3WyGBjqH1bdaO9j7QdNj/9y9Rk/h X-Developer-Key: i=asantostc@gmail.com; a=ed25519; pk=eWre+RwFHCxkiaQrZLsjC67mZ/pZnzSM/f7/+yFXY4Q= From: Breno Leitao Introduces a enum to track netconsole target state which is going to replace the enabled boolean. Signed-off-by: Breno Leitao Signed-off-by: Andre Carvalho Tested-by: Breno Leitao --- drivers/net/netconsole.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 9cb4dfc242f5..e2ec09f238a0 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -119,6 +119,11 @@ enum sysdata_feature { MAX_SYSDATA_ITEMS =3D 4, }; =20 +enum target_state { + STATE_DISABLED, + STATE_ENABLED, +}; + /** * struct netconsole_target - Represents a configured netconsole target. * @list: Links this target into the target_list. --=20 2.52.0 From nobody Sun Feb 8 05:42:37 2026 Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 63DE832A3FF for ; Sun, 18 Jan 2026 11:00:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768734034; cv=none; b=C2YXUKriVx3HrshTXarsCia3GYvExqVlTkmYGDQjZ2B06syOfa75J365uXM/OQJC1VNdiDcKHv1GHjbIihKAmj63eYc1mEzAwO7KlEvqK6joJ71XO9tsXqXcVoUZdggTyX6RUcDkcBmsbd3RilJPJoT6QVFZUN5L6wYVekWOUZw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768734034; c=relaxed/simple; bh=ptkTe+cYKKYMyCNyu+hE6VVzhConXnPLG7fL2BaD9jQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=l5g1cTrrXGHY4u8fMLEYG4gfmT29tX2YudvtvchLsZ/8FzQFmy5TyyUN2SpyPX2hu6BuP545fpfOS8nZ+OMpx0Zj/J3ixVmxnw0TxWCQ0w2ARTUeOiDeT71pidQgbcN2JpoVC/FePKm5/mnft3irLyVSuKWOUSs8rJ6rjcYtD24= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GCXWFaEi; arc=none smtp.client-ip=209.85.221.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GCXWFaEi" Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-431048c4068so1924094f8f.1 for ; Sun, 18 Jan 2026 03:00:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768734029; x=1769338829; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=t+RTp3NdTDs9G43jfmTa4TiJRQPqbtzKxkq+h8ATOJA=; b=GCXWFaEizNjPk3nUN3oRWy/U6/l7axdHJlrUkVEhHhuSZyXIP4RT15Op/aGEEmEnkN dWO+gFBE0llbV21nSM1HeJZviBGozM6pJO8UObRxfRlz8nZ96xinW1rj/NCRgxuhoRAc nesN1AqcHqHj8GM6n2IiLyTD/OP6zASOi1A4e9n5UloHNi6dZvKeRzcjeA2PxrfyhSX1 RcdpaiFGrwqt11FzOxyN6mJSs5mmOZKH6pRk/yMWGtFUV1DdTKCdE3LVyuuOMXib3bQt CkYIvsZDrRbYe/ae+JJHkmf7TDpNdVjsrOIYlL+ilI2Bv1UmQGMRjeZwKbTdDCj8YZEL WPXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768734029; x=1769338829; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=t+RTp3NdTDs9G43jfmTa4TiJRQPqbtzKxkq+h8ATOJA=; b=a18sKe2+EiRL4Kx2C4KYGn6P9ryza63ZY03IfkJYmmGmyOwL048vvwi9D1lpaKEiqF O9CflKxVFDAJwfYT8UgGU4rGvDmHI3EcCrZLqM0UQvVvOKaqFmeEZ91jnWOazfS7cfW/ osUGndbuJPIzCQZwUR0sKUu9gmIA0K0SYMBvV2OQBA/qDitinR28LV7nVSLVifzn7+fw rKX8o9s8drtaxk139m+Sr3J3soUbHFifSeDs8AZNNRuSHsQ5qt46vr+C867f8A94JsAe 5bfWatGZ4cmlI5WxJ/R/tv7xNCiDNNTcyBJ02XMZJwx3vMke1KO/8alEJ8VKiGAJHjTf JtEg== X-Forwarded-Encrypted: i=1; AJvYcCU6BHLGgHzejdzHNofYeiH0s7NkUPq5BHgZWPidjePhYRdWsCiRGw8fCOW7of0A/VFs6i9xyt2cyWQVDIs=@vger.kernel.org X-Gm-Message-State: AOJu0YzAUex+/+0NSTqGkaJwbhuZnvWfef5PNjWb6IK8bkPVGGB5iuwf u/1K98MpitmE118/W6okcddj7LT6jOygKXw94B0ppxMbPs7/StFzGK0q X-Gm-Gg: AY/fxX4JuqGwLSMY/Mlnhd4+wBFdRoUUrbdvlF5YpisD8SbZV2GS2qeAraUp1eDbPcz uyvsl4c6wt1bIDKafqv5OaNaC7aRTTE+jOIP4xAgoBuJW2N/GD90c2nJq84OR6aXmN3HaXowGHz BOtE1jVo3ca1524gERSjH1OCky5fFd7QcvTnJrFMu5Tia4EDdAPrBjwxu/+gntb0m7KYh1TLWhy chMd1ZYdXmauFulicZcK8OdBKt4LE2ymjW6Bcu9blsEd6YWBXTaxLRUzTBltNQVB2v6nLs5zwRv CXhuu7pQkGW4rnZM0bsOcPYrBQZWmjxdJZDv4h2707g4saEKeFFUHT1DzthmyeUCP03GFiQ2QiA cWLJ1gTzDq8w+shtGRt9JF8yg4oHOqZoGVQmuWSO2+F3GHrv53R1WYyAYpdyXCGKbwRux2NhykW tvrru+CM+ZMWYbGw== X-Received: by 2002:a05:6000:184b:b0:431:de5:93c7 with SMTP id ffacd0b85a97d-434cc998542mr16989547f8f.2.1768734028487; Sun, 18 Jan 2026 03:00:28 -0800 (PST) Received: from [192.168.1.243] ([143.58.192.3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4356992201csm16864635f8f.2.2026.01.18.03.00.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jan 2026 03:00:27 -0800 (PST) From: Andre Carvalho Date: Sun, 18 Jan 2026 11:00:22 +0000 Subject: [PATCH net-next v11 2/7] netconsole: convert 'enabled' flag to enum for clearer state management Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260118-netcons-retrigger-v11-2-4de36aebcf48@gmail.com> References: <20260118-netcons-retrigger-v11-0-4de36aebcf48@gmail.com> In-Reply-To: <20260118-netcons-retrigger-v11-0-4de36aebcf48@gmail.com> To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Andre Carvalho X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1768734024; l=8948; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=ptkTe+cYKKYMyCNyu+hE6VVzhConXnPLG7fL2BaD9jQ=; b=6Psep5ulEf30penn26h1zF9CxK41ii8nal/NEfAH/R3RYXYQhPQRQLIJLdNLSlaRic7O3Kiv1 UwgbCSZgAd9C4HPFiu4cbY4XbnuznbSkE6uA/CDzaaXeJqdbb0toHCI X-Developer-Key: i=asantostc@gmail.com; a=ed25519; pk=eWre+RwFHCxkiaQrZLsjC67mZ/pZnzSM/f7/+yFXY4Q= This patch refactors the netconsole driver's target enabled state from a simple boolean to an explicit enum (`target_state`). This allow the states to be expanded to a new state in the upcoming change. Co-developed-by: Breno Leitao Signed-off-by: Breno Leitao Reviewed-by: Breno Leitao Signed-off-by: Andre Carvalho Tested-by: Breno Leitao --- drivers/net/netconsole.c | 52 ++++++++++++++++++++++++++------------------= ---- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index e2ec09f238a0..b21ecea60d52 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -135,12 +135,12 @@ enum target_state { * @sysdata_fields: Sysdata features enabled. * @msgcounter: Message sent counter. * @stats: Packet send stats for the target. Used for debugging. - * @enabled: On / off knob to enable / disable target. + * @state: State of the target. * Visible from userspace (read-write). * We maintain a strict 1:1 correspondence between this and * whether the corresponding netpoll is active or inactive. * Also, other parameters of a target may be modified at - * runtime only when it is disabled (enabled =3D=3D 0). + * runtime only when it is disabled (state =3D=3D STATE_DISABLED). * @extended: Denotes whether console is extended or not. * @release: Denotes whether kernel release version should be prepended * to the message. Depends on extended console. @@ -170,7 +170,7 @@ struct netconsole_target { u32 msgcounter; #endif struct netconsole_target_stats stats; - bool enabled; + enum target_state state; bool extended; bool release; struct netpoll np; @@ -262,6 +262,7 @@ static struct netconsole_target *alloc_and_init(void) nt->np.local_port =3D 6665; nt->np.remote_port =3D 6666; eth_broadcast_addr(nt->np.remote_mac); + nt->state =3D STATE_DISABLED; =20 return nt; } @@ -280,7 +281,7 @@ static void netconsole_process_cleanups_core(void) mutex_lock(&target_cleanup_list_lock); list_for_each_entry_safe(nt, tmp, &target_cleanup_list, list) { /* all entries in the cleanup_list needs to be disabled */ - WARN_ON_ONCE(nt->enabled); + WARN_ON_ONCE(nt->state =3D=3D STATE_ENABLED); do_netpoll_cleanup(&nt->np); /* moved the cleaned target to target_list. Need to hold both * locks @@ -403,7 +404,7 @@ static void trim_newline(char *s, size_t maxlen) =20 static ssize_t enabled_show(struct config_item *item, char *buf) { - return sysfs_emit(buf, "%d\n", to_target(item)->enabled); + return sysfs_emit(buf, "%d\n", to_target(item)->state =3D=3D STATE_ENABLE= D); } =20 static ssize_t extended_show(struct config_item *item, char *buf) @@ -570,8 +571,8 @@ static ssize_t enabled_store(struct config_item *item, const char *buf, size_t count) { struct netconsole_target *nt =3D to_target(item); + bool enabled, current_enabled; unsigned long flags; - bool enabled; ssize_t ret; =20 mutex_lock(&dynamic_netconsole_mutex); @@ -580,9 +581,10 @@ static ssize_t enabled_store(struct config_item *item, goto out_unlock; =20 ret =3D -EINVAL; - if (enabled =3D=3D nt->enabled) { + current_enabled =3D nt->state =3D=3D STATE_ENABLED; + if (enabled =3D=3D current_enabled) { pr_info("network logging has already %s\n", - nt->enabled ? "started" : "stopped"); + current_enabled ? "started" : "stopped"); goto out_unlock; } =20 @@ -615,16 +617,16 @@ static ssize_t enabled_store(struct config_item *item, if (ret) goto out_unlock; =20 - nt->enabled =3D true; + nt->state =3D STATE_ENABLED; pr_info("network logging started\n"); } else { /* false */ /* We need to disable the netconsole before cleaning it up * otherwise we might end up in write_msg() with - * nt->np.dev =3D=3D NULL and nt->enabled =3D=3D true + * nt->np.dev =3D=3D NULL and nt->state =3D=3D STATE_ENABLED */ mutex_lock(&target_cleanup_list_lock); spin_lock_irqsave(&target_list_lock, flags); - nt->enabled =3D false; + nt->state =3D STATE_DISABLED; /* Remove the target from the list, while holding * target_list_lock */ @@ -653,7 +655,7 @@ static ssize_t release_store(struct config_item *item, = const char *buf, ssize_t ret; =20 mutex_lock(&dynamic_netconsole_mutex); - if (nt->enabled) { + if (nt->state =3D=3D STATE_ENABLED) { pr_err("target (%s) is enabled, disable to update parameters\n", config_item_name(&nt->group.cg_item)); ret =3D -EINVAL; @@ -680,7 +682,7 @@ static ssize_t extended_store(struct config_item *item,= const char *buf, ssize_t ret; =20 mutex_lock(&dynamic_netconsole_mutex); - if (nt->enabled) { + if (nt->state =3D=3D STATE_ENABLED) { pr_err("target (%s) is enabled, disable to update parameters\n", config_item_name(&nt->group.cg_item)); ret =3D -EINVAL; @@ -704,7 +706,7 @@ static ssize_t dev_name_store(struct config_item *item,= const char *buf, struct netconsole_target *nt =3D to_target(item); =20 mutex_lock(&dynamic_netconsole_mutex); - if (nt->enabled) { + if (nt->state =3D=3D STATE_ENABLED) { pr_err("target (%s) is enabled, disable to update parameters\n", config_item_name(&nt->group.cg_item)); mutex_unlock(&dynamic_netconsole_mutex); @@ -725,7 +727,7 @@ static ssize_t local_port_store(struct config_item *ite= m, const char *buf, ssize_t ret =3D -EINVAL; =20 mutex_lock(&dynamic_netconsole_mutex); - if (nt->enabled) { + if (nt->state =3D=3D STATE_ENABLED) { pr_err("target (%s) is enabled, disable to update parameters\n", config_item_name(&nt->group.cg_item)); goto out_unlock; @@ -747,7 +749,7 @@ static ssize_t remote_port_store(struct config_item *it= em, ssize_t ret =3D -EINVAL; =20 mutex_lock(&dynamic_netconsole_mutex); - if (nt->enabled) { + if (nt->state =3D=3D STATE_ENABLED) { pr_err("target (%s) is enabled, disable to update parameters\n", config_item_name(&nt->group.cg_item)); goto out_unlock; @@ -770,7 +772,7 @@ static ssize_t local_ip_store(struct config_item *item,= const char *buf, int ipv6; =20 mutex_lock(&dynamic_netconsole_mutex); - if (nt->enabled) { + if (nt->state =3D=3D STATE_ENABLED) { pr_err("target (%s) is enabled, disable to update parameters\n", config_item_name(&nt->group.cg_item)); goto out_unlock; @@ -795,7 +797,7 @@ static ssize_t remote_ip_store(struct config_item *item= , const char *buf, int ipv6; =20 mutex_lock(&dynamic_netconsole_mutex); - if (nt->enabled) { + if (nt->state =3D=3D STATE_ENABLED) { pr_err("target (%s) is enabled, disable to update parameters\n", config_item_name(&nt->group.cg_item)); goto out_unlock; @@ -830,7 +832,7 @@ static ssize_t remote_mac_store(struct config_item *ite= m, const char *buf, ssize_t ret =3D -EINVAL; =20 mutex_lock(&dynamic_netconsole_mutex); - if (nt->enabled) { + if (nt->state =3D=3D STATE_ENABLED) { pr_err("target (%s) is enabled, disable to update parameters\n", config_item_name(&nt->group.cg_item)); goto out_unlock; @@ -1326,7 +1328,7 @@ static void drop_netconsole_target(struct config_grou= p *group, * The target may have never been enabled, or was manually disabled * before being removed so netpoll may have already been cleaned up. */ - if (nt->enabled) + if (nt->state =3D=3D STATE_ENABLED) netpoll_cleanup(&nt->np); =20 config_item_put(&nt->group.cg_item); @@ -1444,7 +1446,7 @@ static int netconsole_netdev_event(struct notifier_bl= ock *this, case NETDEV_RELEASE: case NETDEV_JOIN: case NETDEV_UNREGISTER: - nt->enabled =3D false; + nt->state =3D STATE_DISABLED; list_move(&nt->list, &target_cleanup_list); stopped =3D true; } @@ -1725,7 +1727,8 @@ static void write_ext_msg(struct console *con, const = char *msg, =20 spin_lock_irqsave(&target_list_lock, flags); list_for_each_entry(nt, &target_list, list) - if (nt->extended && nt->enabled && netif_running(nt->np.dev)) + if (nt->extended && nt->state =3D=3D STATE_ENABLED && + netif_running(nt->np.dev)) send_ext_msg_udp(nt, msg, len); spin_unlock_irqrestore(&target_list_lock, flags); } @@ -1745,7 +1748,8 @@ static void write_msg(struct console *con, const char= *msg, unsigned int len) =20 spin_lock_irqsave(&target_list_lock, flags); list_for_each_entry(nt, &target_list, list) { - if (!nt->extended && nt->enabled && netif_running(nt->np.dev)) { + if (!nt->extended && nt->state =3D=3D STATE_ENABLED && + netif_running(nt->np.dev)) { /* * We nest this inside the for-each-target loop above * so that we're able to get as much logging out to @@ -1901,7 +1905,7 @@ static struct netconsole_target *alloc_param_target(c= har *target_config, */ goto fail; } else { - nt->enabled =3D true; + nt->state =3D STATE_ENABLED; } populate_configfs_item(nt, cmdline_count); =20 --=20 2.52.0 From nobody Sun Feb 8 05:42:37 2026 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DD7EF32ABE1 for ; Sun, 18 Jan 2026 11:00:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768734035; cv=none; b=pO7xROoHRMZ7VfxQ6hxGic0lP4ngXf0nNd0LoAqFvioIupZPwTJhFhxkKcOatGhW5F8301sqfJo3MHx845UHhBnnr9xySzOREp/XZI0Q6qrS68UT4VO7AdzZ9guKreGOu4ogew0tKYCRh10XdR9HMskj7We5o1cK6Uaa4ZMPg20= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768734035; c=relaxed/simple; bh=oZlSrKc5HSf8OTgk8Y9zCO1ND/6B7m7anVTBiZTQDCE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=u+MYWk2lciLYs5EuraDxQnpCrleSPg3Cay175T1dA6LpRpHuCON1DJY+vIk0Ev/VXJSjXb8RmWVTgr9dwRTuiElQSbA5xMbs75Od+NY8mny1jQMuwCBnCwGmbbaihAEXuA7s9xX86VfgWcuWIujaixLYMgXc//s1ZGLJzqlpMKw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZM6xEzUr; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZM6xEzUr" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-4801c1ad878so22827335e9.1 for ; Sun, 18 Jan 2026 03:00:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768734030; x=1769338830; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=J4d7URFdeCPYu3U6zdfTOnUzmMHd/kT6rS033v+6Sa8=; b=ZM6xEzUrJlnixDJMgVzB0RlaEAtNQNqH5SfVkeIQEauMxckLI/TBKtHBnpuff55nnR Qfmk47OrfmbJOlfBU+m2KUiJtiI3FDPAkWsKsGa8DnEuFF599MdIf4ZtHFi3AAGRjv/x BpG789CWMVFeDXo7P3mALGDwQp4u8h4NOFqdcclPAncfwOLdWdVh3Nhr9B0JM1DfF/kQ AbIUtIKq4zL3U1kLQuFruCJLCb1pEGzDDtZKWFrv0kSidyFsmfThvScE80Auz7FlKlPH cckli9Xk8oduWAfjRFJPO/AhERzVETjQEOOJk88n+IhYJ03uxhSa4BRjv6vcDialNYL4 xkxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768734030; x=1769338830; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=J4d7URFdeCPYu3U6zdfTOnUzmMHd/kT6rS033v+6Sa8=; b=UvE01JHuIWDlVuNlWGUsqCrocxekiCvyM60r/7yB6IUrYpidSfrOOFLfVjfrUA53ND e3JoJLhfMg4FqXkQ+bYKGmcXuxxLan4z3TKmPhpUDszEJILy3mNYmwVD9WDHZ/Z1SzkH 7KeAy553P/wdVnsact2VpxwVgNfGV9EXrpAnoi4YJXODw2FvNqggygNuG/x7b7imSKcx k0i1WSW3mV311ObhmM+IMXx2nSZb6Ll71SyiZlnny5ebUnzbfjBZDxynKL7OlKP593ps bTfpOXv7aN8IgNtWzy+pX19MwC3+RDrfkOkwkAEWNsmsxxWWw5I80mEDNGGhsRokJ3sX ThUA== X-Forwarded-Encrypted: i=1; AJvYcCUlZiG3/OUsIfv0L6g8nqC2Yixc6W+cmGY5hi3b+g4ptoLW2XZ8VQLXS008BI3jMOlyLtjL0z64pD/uf4k=@vger.kernel.org X-Gm-Message-State: AOJu0Yw5kiuIqTGVj3J4P28EBLoy3hKy+F5OhtTbkX3I+kmCESFoJ4dx oqw0JoYBl+kMNmpk5Se3pIEC+PVgr3dxX/Y7ujTzv2TFeL4XqjH5dNHb X-Gm-Gg: AY/fxX5VFO+2Y+Xhoh6SRq+2+nHjLg6cvyixHG5N6uxzypOI9GnCILAEtRNyIaj22OV R1p49XJDY2e9GdbAezJKqZp1sMwJ0OtGV1uE7zmHYThABs8A/aQv3qfN5Y2aCc7Y9whK9pMYByU YqI6ExCtLb9LwKRRiztYjqERbAxlIKIK4sVipaYhL4kjE+7h3dVVp4vcfcG2jtbwp45ykXjzIS0 RPS8u6ReoQo7vBuuF3N9+Pa9anvDUrkswNH0xVJdH3NA+l80pxyW0ArLFhHfRDoeAZGzW5h50Ug mNawdGJ1DqaxVKhsRaCVBv4+SqzT7G2Fmr4G+gqq+jaU6DpyFH9qk7xgcJCRnaEehp3o3SsW78F Svo7bJqieRkGFdLAnfJKD/3KIet4wQMBCv4adox2W+wjfqaUoDj9FILzP/2rl0ojcy4AARon8Pq P2DAVgo9JFt/WZ8Q== X-Received: by 2002:a05:600c:4448:b0:465:a51d:d4 with SMTP id 5b1f17b1804b1-4801e2fdd54mr95040255e9.6.1768734029915; Sun, 18 Jan 2026 03:00:29 -0800 (PST) Received: from [192.168.1.243] ([143.58.192.3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4356992201csm16864635f8f.2.2026.01.18.03.00.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jan 2026 03:00:29 -0800 (PST) From: Andre Carvalho Date: Sun, 18 Jan 2026 11:00:23 +0000 Subject: [PATCH net-next v11 3/7] netconsole: add STATE_DEACTIVATED to track targets disabled by low level Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260118-netcons-retrigger-v11-3-4de36aebcf48@gmail.com> References: <20260118-netcons-retrigger-v11-0-4de36aebcf48@gmail.com> In-Reply-To: <20260118-netcons-retrigger-v11-0-4de36aebcf48@gmail.com> To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Andre Carvalho X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1768734024; l=2409; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=Bc0ee9DYK1oiSRrahxYGeDv2Y4gYudwUsG3FQq7nt2Y=; b=w47Bv0mJSq0H++87nzW6h5KMtb3quL1YV8R5bcPQBf+b6qibDRwH/Xr8ZeczEx6pVS526X8qp lrjJUKt/nNBD6Mn65spkAIhk/Po4No1vvdD2+IQ7ZEqu04Z7jMsQ0UG X-Developer-Key: i=asantostc@gmail.com; a=ed25519; pk=eWre+RwFHCxkiaQrZLsjC67mZ/pZnzSM/f7/+yFXY4Q= From: Breno Leitao When the low level interface brings a netconsole target down, record this using a new STATE_DEACTIVATED state. This allows netconsole to distinguish between targets explicitly disabled by users and those deactivated due to interface state changes. It also enables automatic recovery and re-enabling of targets if the underlying low-level interfaces come back online. From a code perspective, anything that is not STATE_ENABLED is disabled. Devices (de)enslaving are marked STATE_DISABLED to prevent automatically resuming as enslaved interfaces cannot have netconsole enabled. Signed-off-by: Breno Leitao Signed-off-by: Andre Carvalho Tested-by: Breno Leitao --- drivers/net/netconsole.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index b21ecea60d52..7a1e5559fc0d 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -122,6 +122,7 @@ enum sysdata_feature { enum target_state { STATE_DISABLED, STATE_ENABLED, + STATE_DEACTIVATED, }; =20 /** @@ -580,6 +581,14 @@ static ssize_t enabled_store(struct config_item *item, if (ret) goto out_unlock; =20 + /* When the user explicitly enables or disables a target that is + * currently deactivated, reset its state to disabled. The DEACTIVATED + * state only tracks interface-driven deactivation and should _not_ + * persist when the user manually changes the target's enabled state. + */ + if (nt->state =3D=3D STATE_DEACTIVATED) + nt->state =3D STATE_DISABLED; + ret =3D -EINVAL; current_enabled =3D nt->state =3D=3D STATE_ENABLED; if (enabled =3D=3D current_enabled) { @@ -1445,10 +1454,19 @@ static int netconsole_netdev_event(struct notifier_= block *this, break; case NETDEV_RELEASE: case NETDEV_JOIN: - case NETDEV_UNREGISTER: + /* transition target to DISABLED instead of + * DEACTIVATED when (de)enslaving devices as + * their targets should not be automatically + * resumed when the interface is brought up. + */ nt->state =3D STATE_DISABLED; list_move(&nt->list, &target_cleanup_list); stopped =3D true; + break; + case NETDEV_UNREGISTER: + nt->state =3D STATE_DEACTIVATED; + list_move(&nt->list, &target_cleanup_list); + stopped =3D true; } } netconsole_target_put(nt); --=20 2.52.0 From nobody Sun Feb 8 05:42:37 2026 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E08EA32ABC8 for ; Sun, 18 Jan 2026 11:00:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768734038; cv=none; b=HgrN48vE+Jb5mbXkQFk0wis5FWewjb+hCcP1KDnRISUpbiUrJcqZY9tQ7WV1mAQ9uRwRTYFdLEuUQOhUpXBtrYl8aO2DlClRRfW9yLinQzAYVS11EoEjmYCvejMe5l/VKxxOkiM8GmAm5uz/rAcoRTJxaFbmlzVqcyW3Q1il+QM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768734038; c=relaxed/simple; bh=2IR9K9fFwUyb3vK1T1dQvAvM/jN1tGrfN72mQMj/cpo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=D1xGsvznrlVi++eri7qEn64TVOrsKnRFRPc6cQot9BkYJ6SPPSsDbrVXiz98+YEE4Hwsc4XlAXLts6FHKbf6v+OFBEFaUaHCLewnLUI/41mDSKQrtIEWYto+Ux+hyICGpRLIwg2bEwiYgrBPzh4rdaHxbUdXTXzK2GTTZp2PgWI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=gpbP/0VU; arc=none smtp.client-ip=209.85.128.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="gpbP/0VU" Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-47ee3da7447so20501095e9.0 for ; Sun, 18 Jan 2026 03:00:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768734031; x=1769338831; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=+ZJpugnwNeH6pltmuI9tKkzaUCo5szMqMArK7fNoASs=; b=gpbP/0VUM7wN14tUSOCRuaNj7g8IhqrWgy1uMClUU6YkG4NEaitoH3D4DyU/Wmgxuc X7ZSKLRX3OvJ7rHjfYhP3vRUSJb9BhDm7SruURfY+wUt2UMFtPFDbDYkJtZWjVGPXjxG JnJXrjGWMm+SaHN7rIgGIbCGDvV+b80VtxnqwpFP3qL9J69WwIGrkh1wJRwrIrpRQJAJ zBSmXlkfqG63iuiz4auzsKAWCYi+pjyL54HEwaJC1nFnuM6HERnRVBQ17/jC3EL4lCH+ FVNXWMy7bifrWlg6btew66qssPs8KmUelJRVg8rXgzdHKawaEZ5bJJEjoVJKpGQJkVYf urRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768734031; x=1769338831; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=+ZJpugnwNeH6pltmuI9tKkzaUCo5szMqMArK7fNoASs=; b=vRMZtNdI6WD/WIJ0EbzLDlF7HJQN/0MA5DK2d7FhESHd9oYwz+kD+DyP4w4X4sSd0v aEVrhDq8xk1XxhpI2kND3NbDFSGVWRJ70NH2sAQlVWw4gl5nVNBX+RXXBg0utVsf5Xfi Rw4H0m6RLb5lZxKDLwHnBOmIVZjmmhK2pBFhoqbOy5UaNJAXXFlDvqRLPVKMe9YwyaPK e0IjPitCMjNHknIvr5q/xvb4vr909DqiA45j7bLuB/N/2pxNFnHLMHtZPQ/D7nYi6eXL fKfYbXTDlLPjmimt1KZGg9/1RZ4afgrUY1nPxLComUZGqCIWcgZRiZ14GaIuTa2T3k8B B78w== X-Forwarded-Encrypted: i=1; AJvYcCVb7VNUDc+FWOnOSUHHKfD/c+HsrX/hgCee82FXelcQWo+MsFFTmcdVmpRYbJ+hR7bKk/L1+QCwIQhPbZk=@vger.kernel.org X-Gm-Message-State: AOJu0YyJPbruT+kmFlpdnyB8vFrMv6AxvxntqGzBiQEOHVElO3W8Cj8E MuBjIpHytqNxZf7ywb2u6QKx5OjCwRi/vttSzzn0Vn4EKHHOQUr6hQwg X-Gm-Gg: AY/fxX4JlHsY+Pjk83wnAQX9NMxhDRyBwxE5hp+8CC0GxhqcZPUEh7Otu/Le8itWWZ8 TwWw+4muiAOZorWVgqS5uR0hMsTsODlRsBWckhziP66rloidUkoKelVs3Qpc+DIfeyDbSui58ck C2bTc397ktGkeuGk6WSII5JLLG/BX0M4O1WVU9u+puX/k2dhF0ZtRo498t3U3HsVocm4HiwR/yi +I69s2STn4QxpLk4fN3qbOiLQ47KhTY7rvgeKZ/N5DoJ96iAdCwu2ACOs3NkV7B/HN99sF5MxkA edvoG1th1r0tC29cZU/JF7MCFmLsLgmD56E9NhCknsJWfyjY3Jc9YV7vX4225DlP+FJRiPMql4v 9MH46NgohPcRvTP/eWDPDZtVcextoed2hJwfG6LJ/wyEHy4WPe0MM1Q9Cs7JCMyieg+1L2lvA7p eKqAZ9CKqRyuyz3g== X-Received: by 2002:a5d:64e6:0:b0:432:dc23:34f with SMTP id ffacd0b85a97d-43569bd0b90mr11399255f8f.53.1768734031192; Sun, 18 Jan 2026 03:00:31 -0800 (PST) Received: from [192.168.1.243] ([143.58.192.3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4356992201csm16864635f8f.2.2026.01.18.03.00.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jan 2026 03:00:30 -0800 (PST) From: Andre Carvalho Date: Sun, 18 Jan 2026 11:00:24 +0000 Subject: [PATCH net-next v11 4/7] netconsole: clear dev_name for devices bound by mac Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260118-netcons-retrigger-v11-4-4de36aebcf48@gmail.com> References: <20260118-netcons-retrigger-v11-0-4de36aebcf48@gmail.com> In-Reply-To: <20260118-netcons-retrigger-v11-0-4de36aebcf48@gmail.com> To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Andre Carvalho X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1768734024; l=1518; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=2IR9K9fFwUyb3vK1T1dQvAvM/jN1tGrfN72mQMj/cpo=; b=ZvsPAc1Nu3ncrw9ojdKCeN2DHwyPVw7plQa3n07vRyJd/cxxaUO+SA0AoD9lL2k2nzwCszWvh nW9AXxX1gTCCe+wxKObWzHnTXE+T7uhtZbLMIQUgtk/NLL5m5Yo7t1D X-Developer-Key: i=asantostc@gmail.com; a=ed25519; pk=eWre+RwFHCxkiaQrZLsjC67mZ/pZnzSM/f7/+yFXY4Q= This patch makes sure netconsole clears dev_name for devices bound by mac in order to allow calling setup_netpoll on targets that have previously been cleaned up (in order to support resuming deactivated targets). This is required as netpoll_setup populates dev_name even when devices are matched via mac address. The cleanup is done inside netconsole as bound by mac is a netconsole concept. Signed-off-by: Andre Carvalho Reviewed-by: Breno Leitao Tested-by: Breno Leitao --- drivers/net/netconsole.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 7a1e5559fc0d..02a3463e8d24 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -242,6 +242,12 @@ static void populate_configfs_item(struct netconsole_t= arget *nt, } #endif /* CONFIG_NETCONSOLE_DYNAMIC */ =20 +/* Check if the target was bound by mac address. */ +static bool bound_by_mac(struct netconsole_target *nt) +{ + return is_valid_ether_addr(nt->np.dev_mac); +} + /* Allocate and initialize with defaults. * Note that these targets get their config_item fields zeroed-out. */ @@ -284,6 +290,8 @@ static void netconsole_process_cleanups_core(void) /* all entries in the cleanup_list needs to be disabled */ WARN_ON_ONCE(nt->state =3D=3D STATE_ENABLED); do_netpoll_cleanup(&nt->np); + if (bound_by_mac(nt)) + memset(&nt->np.dev_name, 0, IFNAMSIZ); /* moved the cleaned target to target_list. Need to hold both * locks */ --=20 2.52.0 From nobody Sun Feb 8 05:42:37 2026 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 40BC632C31B for ; Sun, 18 Jan 2026 11:00:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768734043; cv=none; b=vD9dXfJjEm3s40xSvFrOeV4WxK/yGcoIDI+/db0loiwmKOHC4VZ1iMntfVtal8Mp+dJYlpRQt73nNF/DpBmb/LBgaQY8olNZLeCCgQFBtJWR1rZHZH3KCV+ENjAz7TUOWkz43aJDhqUjiR7QORPpW87cAEDU5ylmuGwF3f+GTq0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768734043; c=relaxed/simple; bh=4PDwzlCI+jgQG2jAxOz1RlldCa/d+sKTSpqV/8xAtWQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SN35e6Fq+0N/8xt93ANJI2wYEiIlgfx2c8EumXv5w4gMKL0ASLGugPjeYs0mAoX4XQgclcN6zrMS3Q30rXDnTchxBkfinbJgEbM0cwUj5yFChrDbefgKC4GSlSOKnf1/LXJGlbTzkrZrD6XyLctLPvuJikdPGJZR+91RSGQdUy4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=kzeORgji; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kzeORgji" Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-42fbc305914so2842767f8f.0 for ; Sun, 18 Jan 2026 03:00:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768734033; x=1769338833; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=JUk5UFagcf4IlgTEQ/iWJeI/RTRWAeLpBdR/nh29wa0=; b=kzeORgjiISvpqKR3m8sKjLUxWRqK13aUdgUcsnmPrhk6UWBGpX6b5UFKyUB5YE207n KLikJVpV/jJZZV26tn8o3OXz1hRbVbRN9a2s/La/XY54DKu3R6/XUj6iFS4U+VFAONlQ 6TDpl5DhvG8mnoypQ1CEUIozWY7raGEbAgc5SvYn2rKubHV/outZuCIZZKNLtR7+kxQl dJwnZzeEDeEF+8DlOnAz/h58i2bUSrIC/xlFo+cRogTSgpF2KCAU3dziIW/ocF2T8MWX f5qANr+ozzA+23GdKkAxYOjIAHct1RX+4VSUdqbgw6rPMHPVmftzbxaBU444hPUTI+Ew sLDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768734033; x=1769338833; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=JUk5UFagcf4IlgTEQ/iWJeI/RTRWAeLpBdR/nh29wa0=; b=ZUSM4fyrNFH9WKm/m0lRoDdi1gKK1On+STpmSY7hn6Yyu7MW9hfD+pTBXllfgBQz78 gEiOTsiZgYLXOQ0DX7tqF/rBoO69FNAxUSZDoQZ/LV9CfDrnaRvZX6Psz0PRK56GCBta Nm8tp6gdU/J9iZDMM42kELWN8v/UXb0MS43bP2qhdaOaZm0QpolorJRSfBRV/N+ksWdU 0opkO5egwQ8d3zzcGzn0H0NbhehFFWBva2C7tV4kZca2UApmvj1vNbWjDN34v8oZVoDY 19ReOe4JhCg178+8vHSzx3LKasmQZg//BRNkmgqG46XGINkP0ejyjxkr4Wme26Vq0mGq mt0A== X-Forwarded-Encrypted: i=1; AJvYcCXW/NmAxf+cAlT5/P1nnL/z7SojM57esWpm9PPN59It4on18sua6ctiuzJDKy9CQ/PoQA+4AGpXIMauJiQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyyamugKndgETPacnhdm8duMvcMxF6GqJAT9sXf49jviybyH13x SMurM/379iFnM7jEYWBn7yYphKZbb7V0rGkzZh+de6p0gTjoAMwJc1rl X-Gm-Gg: AY/fxX44dcoumGglnN5uHw6FTltI208ZlxaN+ZNt8u+KW034bNus8jq1u3O3cZmLawz C3wy5lvp49N6jiGH3Elz2h+4LE6Lh8oWmLuvydWLCfiqkqiOxp8dY0tJTp7YWBZ5B/DCqXtJ3hK rfpfXwaf7YQWU5pgGJd0x/TBJLRug5mx4djamAdK/NLjR7rwOcLVNARxoAWt4QbtTZGjT8kxDio tNb6IPqBIxhb3NswZqssfrmUI31bmFaFTCs4jeGtp9ivyZx9+v6E4hn5j1HrINI2ThGZDZi0rLa MHhPKO+VqQx2Uc4U5Yr9syNwaV+jij39fv7fPkhWh8sX2UtDcc9er2ekXe6pyyJQGWO8zRWBWGV ef2CzztZpz6uTgJnuU7m2PQQyDZ6fXnNcPfdGkPj5gJQBQygwhp5zlIVLpwrwNcrjj4gmhZ320k lDMArcPIH8zTYxTQ== X-Received: by 2002:a05:6000:2893:b0:430:f72e:c998 with SMTP id ffacd0b85a97d-43569bc59abmr9967735f8f.51.1768734032489; Sun, 18 Jan 2026 03:00:32 -0800 (PST) Received: from [192.168.1.243] ([143.58.192.3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4356992201csm16864635f8f.2.2026.01.18.03.00.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jan 2026 03:00:31 -0800 (PST) From: Andre Carvalho Date: Sun, 18 Jan 2026 11:00:25 +0000 Subject: [PATCH net-next v11 5/7] netconsole: introduce helpers for dynamic_netconsole_mutex lock/unlock Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260118-netcons-retrigger-v11-5-4de36aebcf48@gmail.com> References: <20260118-netcons-retrigger-v11-0-4de36aebcf48@gmail.com> In-Reply-To: <20260118-netcons-retrigger-v11-0-4de36aebcf48@gmail.com> To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Andre Carvalho X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1768734024; l=12692; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=4PDwzlCI+jgQG2jAxOz1RlldCa/d+sKTSpqV/8xAtWQ=; b=n1tlGfJ0dqCeUafoiYG6d53iNV8/9mZo3d2HkLXyTSrR59v/rV15yYLeNpuN8h7pvpZl5SjU4 rjVFCtHsJ4yAdxfW/UQctV6IqTzCJi77U7G6Q9MF3GqUmsPz0MXBv6K X-Developer-Key: i=asantostc@gmail.com; a=ed25519; pk=eWre+RwFHCxkiaQrZLsjC67mZ/pZnzSM/f7/+yFXY4Q= This commit introduces two helper functions to perform lock/unlock on dynamic_netconsole_mutex providing no-op stub versions when compiled without CONFIG_NETCONSOLE_DYNAMIC and refactors existing call sites to use the new helpers. This is done following kernel coding style guidelines, in preparation for an upcoming change. It avoids the need for preprocessor conditionals in the call site and keeps the logic easier to follow. Signed-off-by: Andre Carvalho Reviewed-by: Breno Leitao Tested-by: Breno Leitao --- drivers/net/netconsole.c | 97 +++++++++++++++++++++++++++++---------------= ---- 1 file changed, 58 insertions(+), 39 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 02a3463e8d24..46d990f3d904 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -213,6 +213,16 @@ static void netconsole_target_put(struct netconsole_ta= rget *nt) config_group_put(&nt->group); } =20 +static void dynamic_netconsole_mutex_lock(void) +{ + mutex_lock(&dynamic_netconsole_mutex); +} + +static void dynamic_netconsole_mutex_unlock(void) +{ + mutex_unlock(&dynamic_netconsole_mutex); +} + #else /* !CONFIG_NETCONSOLE_DYNAMIC */ =20 static int __init dynamic_netconsole_init(void) @@ -240,6 +250,15 @@ static void populate_configfs_item(struct netconsole_t= arget *nt, int cmdline_count) { } + +static void dynamic_netconsole_mutex_lock(void) +{ +} + +static void dynamic_netconsole_mutex_unlock(void) +{ +} + #endif /* CONFIG_NETCONSOLE_DYNAMIC */ =20 /* Check if the target was bound by mac address. */ @@ -495,9 +514,9 @@ static ssize_t sysdata_cpu_nr_enabled_show(struct confi= g_item *item, char *buf) struct netconsole_target *nt =3D to_target(item->ci_parent); bool cpu_nr_enabled; =20 - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); cpu_nr_enabled =3D !!(nt->sysdata_fields & SYSDATA_CPU_NR); - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); =20 return sysfs_emit(buf, "%d\n", cpu_nr_enabled); } @@ -509,9 +528,9 @@ static ssize_t sysdata_taskname_enabled_show(struct con= fig_item *item, struct netconsole_target *nt =3D to_target(item->ci_parent); bool taskname_enabled; =20 - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); taskname_enabled =3D !!(nt->sysdata_fields & SYSDATA_TASKNAME); - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); =20 return sysfs_emit(buf, "%d\n", taskname_enabled); } @@ -522,9 +541,9 @@ static ssize_t sysdata_release_enabled_show(struct conf= ig_item *item, struct netconsole_target *nt =3D to_target(item->ci_parent); bool release_enabled; =20 - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); release_enabled =3D !!(nt->sysdata_fields & SYSDATA_TASKNAME); - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); =20 return sysfs_emit(buf, "%d\n", release_enabled); } @@ -562,9 +581,9 @@ static ssize_t sysdata_msgid_enabled_show(struct config= _item *item, struct netconsole_target *nt =3D to_target(item->ci_parent); bool msgid_enabled; =20 - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); msgid_enabled =3D !!(nt->sysdata_fields & SYSDATA_MSGID); - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); =20 return sysfs_emit(buf, "%d\n", msgid_enabled); } @@ -584,7 +603,7 @@ static ssize_t enabled_store(struct config_item *item, unsigned long flags; ssize_t ret; =20 - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); ret =3D kstrtobool(buf, &enabled); if (ret) goto out_unlock; @@ -660,7 +679,7 @@ static ssize_t enabled_store(struct config_item *item, /* Deferred cleanup */ netconsole_process_cleanups(); out_unlock: - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); return ret; } =20 @@ -671,7 +690,7 @@ static ssize_t release_store(struct config_item *item, = const char *buf, bool release; ssize_t ret; =20 - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); if (nt->state =3D=3D STATE_ENABLED) { pr_err("target (%s) is enabled, disable to update parameters\n", config_item_name(&nt->group.cg_item)); @@ -687,7 +706,7 @@ static ssize_t release_store(struct config_item *item, = const char *buf, =20 ret =3D strnlen(buf, count); out_unlock: - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); return ret; } =20 @@ -698,7 +717,7 @@ static ssize_t extended_store(struct config_item *item,= const char *buf, bool extended; ssize_t ret; =20 - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); if (nt->state =3D=3D STATE_ENABLED) { pr_err("target (%s) is enabled, disable to update parameters\n", config_item_name(&nt->group.cg_item)); @@ -713,7 +732,7 @@ static ssize_t extended_store(struct config_item *item,= const char *buf, nt->extended =3D extended; ret =3D strnlen(buf, count); out_unlock: - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); return ret; } =20 @@ -722,18 +741,18 @@ static ssize_t dev_name_store(struct config_item *ite= m, const char *buf, { struct netconsole_target *nt =3D to_target(item); =20 - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); if (nt->state =3D=3D STATE_ENABLED) { pr_err("target (%s) is enabled, disable to update parameters\n", config_item_name(&nt->group.cg_item)); - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); return -EINVAL; } =20 strscpy(nt->np.dev_name, buf, IFNAMSIZ); trim_newline(nt->np.dev_name, IFNAMSIZ); =20 - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); return strnlen(buf, count); } =20 @@ -743,7 +762,7 @@ static ssize_t local_port_store(struct config_item *ite= m, const char *buf, struct netconsole_target *nt =3D to_target(item); ssize_t ret =3D -EINVAL; =20 - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); if (nt->state =3D=3D STATE_ENABLED) { pr_err("target (%s) is enabled, disable to update parameters\n", config_item_name(&nt->group.cg_item)); @@ -755,7 +774,7 @@ static ssize_t local_port_store(struct config_item *ite= m, const char *buf, goto out_unlock; ret =3D strnlen(buf, count); out_unlock: - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); return ret; } =20 @@ -765,7 +784,7 @@ static ssize_t remote_port_store(struct config_item *it= em, struct netconsole_target *nt =3D to_target(item); ssize_t ret =3D -EINVAL; =20 - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); if (nt->state =3D=3D STATE_ENABLED) { pr_err("target (%s) is enabled, disable to update parameters\n", config_item_name(&nt->group.cg_item)); @@ -777,7 +796,7 @@ static ssize_t remote_port_store(struct config_item *it= em, goto out_unlock; ret =3D strnlen(buf, count); out_unlock: - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); return ret; } =20 @@ -788,7 +807,7 @@ static ssize_t local_ip_store(struct config_item *item,= const char *buf, ssize_t ret =3D -EINVAL; int ipv6; =20 - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); if (nt->state =3D=3D STATE_ENABLED) { pr_err("target (%s) is enabled, disable to update parameters\n", config_item_name(&nt->group.cg_item)); @@ -802,7 +821,7 @@ static ssize_t local_ip_store(struct config_item *item,= const char *buf, =20 ret =3D strnlen(buf, count); out_unlock: - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); return ret; } =20 @@ -813,7 +832,7 @@ static ssize_t remote_ip_store(struct config_item *item= , const char *buf, ssize_t ret =3D -EINVAL; int ipv6; =20 - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); if (nt->state =3D=3D STATE_ENABLED) { pr_err("target (%s) is enabled, disable to update parameters\n", config_item_name(&nt->group.cg_item)); @@ -827,7 +846,7 @@ static ssize_t remote_ip_store(struct config_item *item= , const char *buf, =20 ret =3D strnlen(buf, count); out_unlock: - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); return ret; } =20 @@ -848,7 +867,7 @@ static ssize_t remote_mac_store(struct config_item *ite= m, const char *buf, u8 remote_mac[ETH_ALEN]; ssize_t ret =3D -EINVAL; =20 - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); if (nt->state =3D=3D STATE_ENABLED) { pr_err("target (%s) is enabled, disable to update parameters\n", config_item_name(&nt->group.cg_item)); @@ -863,7 +882,7 @@ static ssize_t remote_mac_store(struct config_item *ite= m, const char *buf, =20 ret =3D strnlen(buf, count); out_unlock: - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); return ret; } =20 @@ -984,7 +1003,7 @@ static ssize_t userdatum_value_store(struct config_ite= m *item, const char *buf, return -EMSGSIZE; =20 mutex_lock(&netconsole_subsys.su_mutex); - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); =20 ret =3D strscpy(udm->value, buf, sizeof(udm->value)); if (ret < 0) @@ -998,7 +1017,7 @@ static ssize_t userdatum_value_store(struct config_ite= m *item, const char *buf, goto out_unlock; ret =3D count; out_unlock: - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); mutex_unlock(&netconsole_subsys.su_mutex); return ret; } @@ -1026,7 +1045,7 @@ static ssize_t sysdata_msgid_enabled_store(struct con= fig_item *item, return ret; =20 mutex_lock(&netconsole_subsys.su_mutex); - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); curr =3D !!(nt->sysdata_fields & SYSDATA_MSGID); if (msgid_enabled =3D=3D curr) goto unlock_ok; @@ -1038,7 +1057,7 @@ static ssize_t sysdata_msgid_enabled_store(struct con= fig_item *item, =20 unlock_ok: ret =3D strnlen(buf, count); - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); mutex_unlock(&netconsole_subsys.su_mutex); return ret; } @@ -1055,7 +1074,7 @@ static ssize_t sysdata_release_enabled_store(struct c= onfig_item *item, return ret; =20 mutex_lock(&netconsole_subsys.su_mutex); - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); curr =3D !!(nt->sysdata_fields & SYSDATA_RELEASE); if (release_enabled =3D=3D curr) goto unlock_ok; @@ -1067,7 +1086,7 @@ static ssize_t sysdata_release_enabled_store(struct c= onfig_item *item, =20 unlock_ok: ret =3D strnlen(buf, count); - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); mutex_unlock(&netconsole_subsys.su_mutex); return ret; } @@ -1084,7 +1103,7 @@ static ssize_t sysdata_taskname_enabled_store(struct = config_item *item, return ret; =20 mutex_lock(&netconsole_subsys.su_mutex); - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); curr =3D !!(nt->sysdata_fields & SYSDATA_TASKNAME); if (taskname_enabled =3D=3D curr) goto unlock_ok; @@ -1096,7 +1115,7 @@ static ssize_t sysdata_taskname_enabled_store(struct = config_item *item, =20 unlock_ok: ret =3D strnlen(buf, count); - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); mutex_unlock(&netconsole_subsys.su_mutex); return ret; } @@ -1114,7 +1133,7 @@ static ssize_t sysdata_cpu_nr_enabled_store(struct co= nfig_item *item, return ret; =20 mutex_lock(&netconsole_subsys.su_mutex); - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); curr =3D !!(nt->sysdata_fields & SYSDATA_CPU_NR); if (cpu_nr_enabled =3D=3D curr) /* no change requested */ @@ -1130,7 +1149,7 @@ static ssize_t sysdata_cpu_nr_enabled_store(struct co= nfig_item *item, =20 unlock_ok: ret =3D strnlen(buf, count); - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); mutex_unlock(&netconsole_subsys.su_mutex); return ret; } @@ -1192,10 +1211,10 @@ static void userdatum_drop(struct config_group *gro= up, struct config_item *item) ud =3D to_userdata(&group->cg_item); nt =3D userdata_to_target(ud); =20 - mutex_lock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_lock(); update_userdata(nt); config_item_put(item); - mutex_unlock(&dynamic_netconsole_mutex); + dynamic_netconsole_mutex_unlock(); } =20 static struct configfs_attribute *userdata_attrs[] =3D { --=20 2.52.0 From nobody Sun Feb 8 05:42:37 2026 Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C01632B99B for ; Sun, 18 Jan 2026 11:00:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768734043; cv=none; b=d9E1D+taVgGg/AwRmmPyoxb6V5FoHU7DXBKSt/H2UiAHFCfDUZlKFzl3Ei1UeUBMem7zxbLOrUOfy0zb6Q33krfD7lRJV8KeawkVBkXXj4V4aw15ukhuvQqPTvn7hCqCzmxNEKZl4jEYdfgyJ/v7QKpOBzFQNzeBE454i+p5504= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768734043; c=relaxed/simple; bh=r1PE8fDi2fMuVloDtOFpaMYOvsXBjkenyxTGboQyEIM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YxrLK+48ZS2mx7rrSqBuUghM5OdpJYkOPJG4Z43dTElXWJsFs+4XcUo2W6Ke0uU9p0LoFwcKlzCSBwGw9HSsA79l+dNTEwriYe4/W9J1Vkb/ZiYmvddFsPWfsDnyzX9YBJdiRKH26Wm+rBAbnvO0CWlPs3/pKcOGAkvJOAqYfcQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=K9nrEp5j; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K9nrEp5j" Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-47ee3da7447so20501355e9.0 for ; Sun, 18 Jan 2026 03:00:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768734035; x=1769338835; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=qpQJfNEVMidDJUe69qz1mLAVV7hXmHzYrjKAzwHkdw4=; b=K9nrEp5jIWTBBgj9T/JNu9q85QG6fJg4I3inV1Nm72IeD3O0J8s9cKq2sNMXDrigP0 U9+LvkjVOkO/9nazF9g1nA+QEYk5E3JG+UsJGjDSVJ4bgXNsbZChtFi5nIUkoNn+IphP H/Be7Pw66L2eGVNigThCelxQ+djzUrhprIZsGAz4KPt0utXpY+jcPE2Ts2HjwKvb5G86 i1HXk32XHtxpDVtwCzi4JqPtABje5UXQ3XxWzW0FNeylQybi8bosA7xhTctQP+sYkyvQ wiYBQJ7Urazmfeuqq3rJLIQF5LqOQ4KQ1dIPH5aDFJx3MFoPo3NsyLPi/HGQErHWAu86 CLkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768734035; x=1769338835; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=qpQJfNEVMidDJUe69qz1mLAVV7hXmHzYrjKAzwHkdw4=; b=I+aYdSet72mC0LH/ZXHxrNpPtQLmdT2pyP+qIY7rKM+4BGs/W5HvxAGzWP8LhQy5Ox jnsL8iPiB4TsaQ13K/oA1rPhABCZCHr45I8lX89o9/fB3qWHTEKCwPllIqm5w8/8BdcD bKqr+UI6RG0bCPBzKMNuZaF/iCccDY4ffoGft3WC4oPniSF9fDU9LrcqwXBGJudpAw6M j1maaz8PolrrBR1J+TaASpDXQK8p7WQ03KHzNrQrmlCdQem9nG/MEa7YZcHw8/0GqAPc b3O7V/Uj9zqsqDYzeJN0e8tKzsgULLXEMzm32mklbLzVnWCyOZ6LHHrKFc1z94OtvqwD bS/g== X-Forwarded-Encrypted: i=1; AJvYcCUq964F4YOXBKXRh8Vb183OJn0iEkZ0BkQm33i0A9XFuSdTzrsC+ecGkUkfAaH3pWxHnbO/caXz9JbhvsE=@vger.kernel.org X-Gm-Message-State: AOJu0YyRkjqse+XJiFvh01UZv0aod1FFqnT6glGP2nNuoN2In8jtu+hS OFUp3IkamVDb6T/tXG5NjlkquJuGhq1tyzq3dDoJEjgyAcfpj2YSOAoR X-Gm-Gg: AY/fxX4wE4lBOJEIe32lp2x3sPOzKWkE7J5sWJ5dmLLIaISykFo+VlfeXfD5aY3lcjt qybqACzMUCT/F7d3WLOSDK9iyyB/RsXrnCY3Jzkest5EOwsRkcdTZlieSLF0Ym0Hyzu2Pn/BxU+ RghTmlXLosmdagKzdSBu5744i9OlzmNZIXB25Dlgv00c+i6p93s7ocAq+DcqojpA4zjY5x9J2Qp LiH5eFVAYOhXrTh3YerW8o2S77a2lNV7w//KyVlwdCondZTTyHpUCFdTHpYUM72eY4iabibnxFn I0rzFC3sWGPDL/HdwNajk/CSVVj5ceZAYgLXH3GVJXTMUeyehTIdGEaS91KKndc3fzTk+SZU7BT O6TJFSm8W8LPuMMT1sx9dwcpwxYUytMumqE3fdtDrS0Wb0apckPs6Ea/mTeqv0AwowdwwOXExTo VxfPDmlYA9f1XikQ== X-Received: by 2002:a5d:5886:0:b0:430:f9c2:8500 with SMTP id ffacd0b85a97d-43569bcdf8bmr8324359f8f.43.1768734034340; Sun, 18 Jan 2026 03:00:34 -0800 (PST) Received: from [192.168.1.243] ([143.58.192.3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4356992201csm16864635f8f.2.2026.01.18.03.00.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jan 2026 03:00:33 -0800 (PST) From: Andre Carvalho Date: Sun, 18 Jan 2026 11:00:26 +0000 Subject: [PATCH net-next v11 6/7] netconsole: resume previously deactivated target Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260118-netcons-retrigger-v11-6-4de36aebcf48@gmail.com> References: <20260118-netcons-retrigger-v11-0-4de36aebcf48@gmail.com> In-Reply-To: <20260118-netcons-retrigger-v11-0-4de36aebcf48@gmail.com> To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Andre Carvalho X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1768734024; l=9836; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=r1PE8fDi2fMuVloDtOFpaMYOvsXBjkenyxTGboQyEIM=; b=ZNi18xocRfYTkc/kQ5yZlD1bOBS69EKqwGAfehdKI2VvIDsd8NIwVBTm1nMIEzNi1sEkKNQup skNA0Bf7zFuA+a7oNCL3H1sTMjmRdsi8Zi6x6EYI1mR27S6Fz4W1mxz X-Developer-Key: i=asantostc@gmail.com; a=ed25519; pk=eWre+RwFHCxkiaQrZLsjC67mZ/pZnzSM/f7/+yFXY4Q= Attempt to resume a previously deactivated target when the associated interface comes back (NETDEV_REGISTER) or when it changes name (NETDEV_CHANGENAME) by calling netpoll_setup on the device. Depending on how the target was setup (by mac or interface name), the corresponding field is compared with the device being brought up. Targets that match the incoming device, are scheduled for resume on a workqueue. Resuming happens on a workqueue as we can't execute netpoll_setup in the context of the netdev event. A standalone workqueue (as opposed to the global one) is used to allow for proper cleanup process during netconsole module cleanup as we need to be able to flush all pending work before traversing the target list given that targets are temporarily removed from the list during resume_target. Target transitions to STATE_DISABLED in case of failures resuming it to avoid retrying the same target indefinitely. Signed-off-by: Andre Carvalho Reviewed-by: Breno Leitao Tested-by: Breno Leitao --- drivers/net/netconsole.c | 127 +++++++++++++++++++++++++++++++++++++++++++= +--- 1 file changed, 120 insertions(+), 7 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 46d990f3d904..82c232f9ede2 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -39,6 +39,7 @@ #include #include #include +#include =20 MODULE_AUTHOR("Matt Mackall "); MODULE_DESCRIPTION("Console driver for network interfaces"); @@ -85,6 +86,8 @@ static DEFINE_SPINLOCK(target_list_lock); /* This needs to be a mutex because netpoll_cleanup might sleep */ static DEFINE_MUTEX(target_cleanup_list_lock); =20 +static struct workqueue_struct *netconsole_wq; + /* * Console driver for netconsoles. Register only consoles that have * an associated target of the same type. @@ -138,10 +141,14 @@ enum target_state { * @stats: Packet send stats for the target. Used for debugging. * @state: State of the target. * Visible from userspace (read-write). - * We maintain a strict 1:1 correspondence between this and - * whether the corresponding netpoll is active or inactive. + * From a userspace perspective, the target is either enabled or + * disabled. Internally, although both STATE_DISABLED and + * STATE_DEACTIVATED correspond to inactive targets, the latter is + * due to automatic interface state changes and will try + * recover automatically, if the interface comes back + * online. * Also, other parameters of a target may be modified at - * runtime only when it is disabled (state =3D=3D STATE_DISABLED). + * runtime only when it is disabled (state !=3D STATE_ENABLED). * @extended: Denotes whether console is extended or not. * @release: Denotes whether kernel release version should be prepended * to the message. Depends on extended console. @@ -155,6 +162,7 @@ enum target_state { * local_mac (read-only) * remote_mac (read-write) * @buf: The buffer used to send the full msg to the network stack + * @resume_wq: Workqueue to resume deactivated target */ struct netconsole_target { struct list_head list; @@ -177,6 +185,7 @@ struct netconsole_target { struct netpoll np; /* protected by target_list_lock */ char buf[MAX_PRINT_CHUNK]; + struct work_struct resume_wq; }; =20 #ifdef CONFIG_NETCONSOLE_DYNAMIC @@ -267,6 +276,70 @@ static bool bound_by_mac(struct netconsole_target *nt) return is_valid_ether_addr(nt->np.dev_mac); } =20 +/* Attempts to resume logging to a deactivated target. */ +static void resume_target(struct netconsole_target *nt) +{ + if (netpoll_setup(&nt->np)) { + /* netpoll fails setup once, do not try again. */ + nt->state =3D STATE_DISABLED; + return; + } + + nt->state =3D STATE_ENABLED; + pr_info("network logging resumed on interface %s\n", nt->np.dev_name); +} + +/* Checks if a deactivated target matches a device. */ +static bool deactivated_target_match(struct netconsole_target *nt, + struct net_device *ndev) +{ + if (nt->state !=3D STATE_DEACTIVATED) + return false; + + if (bound_by_mac(nt)) + return !memcmp(nt->np.dev_mac, ndev->dev_addr, ETH_ALEN); + return !strncmp(nt->np.dev_name, ndev->name, IFNAMSIZ); +} + +/* Process work scheduled for target resume. */ +static void process_resume_target(struct work_struct *work) +{ + struct netconsole_target *nt; + unsigned long flags; + + nt =3D container_of(work, struct netconsole_target, resume_wq); + + dynamic_netconsole_mutex_lock(); + + spin_lock_irqsave(&target_list_lock, flags); + /* Check if target is still deactivated as it may have been disabled + * while resume was being scheduled. + */ + if (nt->state !=3D STATE_DEACTIVATED) { + spin_unlock_irqrestore(&target_list_lock, flags); + goto out_unlock; + } + + /* resume_target is IRQ unsafe, remove target from + * target_list in order to resume it with IRQ enabled. + */ + list_del_init(&nt->list); + spin_unlock_irqrestore(&target_list_lock, flags); + + resume_target(nt); + + /* At this point the target is either enabled or disabled and + * was cleaned up before getting deactivated. Either way, add it + * back to target list. + */ + spin_lock_irqsave(&target_list_lock, flags); + list_add(&nt->list, &target_list); + spin_unlock_irqrestore(&target_list_lock, flags); + +out_unlock: + dynamic_netconsole_mutex_unlock(); +} + /* Allocate and initialize with defaults. * Note that these targets get their config_item fields zeroed-out. */ @@ -289,6 +362,7 @@ static struct netconsole_target *alloc_and_init(void) nt->np.remote_port =3D 6666; eth_broadcast_addr(nt->np.remote_mac); nt->state =3D STATE_DISABLED; + INIT_WORK(&nt->resume_wq, process_resume_target); =20 return nt; } @@ -1353,13 +1427,29 @@ static struct config_group *make_netconsole_target(= struct config_group *group, static void drop_netconsole_target(struct config_group *group, struct config_item *item) { - unsigned long flags; struct netconsole_target *nt =3D to_target(item); + unsigned long flags; + + dynamic_netconsole_mutex_lock(); =20 spin_lock_irqsave(&target_list_lock, flags); + /* Disable deactivated target to prevent races between resume attempt + * and target removal. + */ + if (nt->state =3D=3D STATE_DEACTIVATED) + nt->state =3D STATE_DISABLED; list_del(&nt->list); spin_unlock_irqrestore(&target_list_lock, flags); =20 + dynamic_netconsole_mutex_unlock(); + + /* Now that the target has been marked disabled no further work + * can be scheduled. Existing work will skip as targets are not + * deactivated anymore. Cancel any scheduled resume and wait for + * completion. + */ + cancel_work_sync(&nt->resume_wq); + /* * The target may have never been enabled, or was manually disabled * before being removed so netpoll may have already been cleaned up. @@ -1461,13 +1551,14 @@ static int prepare_sysdata(struct netconsole_target= *nt) static int netconsole_netdev_event(struct notifier_block *this, unsigned long event, void *ptr) { - unsigned long flags; - struct netconsole_target *nt, *tmp; struct net_device *dev =3D netdev_notifier_info_to_dev(ptr); + struct netconsole_target *nt, *tmp; bool stopped =3D false; + unsigned long flags; =20 if (!(event =3D=3D NETDEV_CHANGENAME || event =3D=3D NETDEV_UNREGISTER || - event =3D=3D NETDEV_RELEASE || event =3D=3D NETDEV_JOIN)) + event =3D=3D NETDEV_RELEASE || event =3D=3D NETDEV_JOIN || + event =3D=3D NETDEV_REGISTER)) goto done; =20 mutex_lock(&target_cleanup_list_lock); @@ -1496,6 +1587,13 @@ static int netconsole_netdev_event(struct notifier_b= lock *this, stopped =3D true; } } + if ((event =3D=3D NETDEV_REGISTER || event =3D=3D NETDEV_CHANGENAME) && + deactivated_target_match(nt, dev)) + /* Schedule resume on a workqueue as it will attempt + * to UP the device, which can't be done as part of this + * notifier. + */ + queue_work(netconsole_wq, &nt->resume_wq); netconsole_target_put(nt); } spin_unlock_irqrestore(&target_list_lock, flags); @@ -1964,6 +2062,7 @@ static struct netconsole_target *alloc_param_target(c= har *target_config, /* Cleanup netpoll for given target (from boot/module param) and free it */ static void free_param_target(struct netconsole_target *nt) { + cancel_work_sync(&nt->resume_wq); netpoll_cleanup(&nt->np); #ifdef CONFIG_NETCONSOLE_DYNAMIC kfree(nt->userdata); @@ -2018,6 +2117,12 @@ static int __init init_netconsole(void) } } =20 + netconsole_wq =3D alloc_workqueue("netconsole", WQ_UNBOUND, 0); + if (!netconsole_wq) { + err =3D -ENOMEM; + goto fail; + } + err =3D register_netdevice_notifier(&netconsole_netdev_notifier); if (err) goto fail; @@ -2040,6 +2145,8 @@ static int __init init_netconsole(void) fail: pr_err("cleaning up\n"); =20 + if (netconsole_wq) + flush_workqueue(netconsole_wq); /* * Remove all targets and destroy them (only targets created * from the boot/module option exist here). Skipping the list @@ -2050,6 +2157,9 @@ static int __init init_netconsole(void) free_param_target(nt); } =20 + if (netconsole_wq) + destroy_workqueue(netconsole_wq); + return err; } =20 @@ -2063,6 +2173,7 @@ static void __exit cleanup_netconsole(void) unregister_console(&netconsole); dynamic_netconsole_exit(); unregister_netdevice_notifier(&netconsole_netdev_notifier); + flush_workqueue(netconsole_wq); =20 /* * Targets created via configfs pin references on our module @@ -2076,6 +2187,8 @@ static void __exit cleanup_netconsole(void) list_del(&nt->list); free_param_target(nt); } + + destroy_workqueue(netconsole_wq); } =20 /* --=20 2.52.0 From nobody Sun Feb 8 05:42:37 2026 Received: from mail-wr1-f53.google.com (mail-wr1-f53.google.com [209.85.221.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1B7D326957 for ; Sun, 18 Jan 2026 11:00:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768734049; cv=none; b=dQcyczlVdtB/fBPkdT3ZQvY3hkKsJnrWKwLmPFZJMWtDciS8Ik7Mr37b1DbgXpiTMZhDiK1O3Z7YXxQqXlgoICz1ltylF1mh46LAtpmHmeRuEokSbLFE9kSVINe79XW9JAJguO12FC2otZsoT0j14dIuyzV5PJi+9Rn2VafdVLo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768734049; c=relaxed/simple; bh=e+w0DAW9oXvqNZy9JiObhL7asMTKcY24W84QkRdGT9w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SZCtIhmND8qihiRfbnLUt9Ete3SpjDQmosrbR324ufYAEzxRaDGtxmTI/99cI000aT2NuXgZbsuaIbFZufZ5SCS5HedBaYjv40xxJ10cTq+/WRRQgOYJWmHlrlrfeiNhbSOxYA1cfb1BjuF9zpAicNq76S+MsZ3+ZRxUrJa4BI8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TbzHdWjc; arc=none smtp.client-ip=209.85.221.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TbzHdWjc" Received: by mail-wr1-f53.google.com with SMTP id ffacd0b85a97d-42fb03c3cf2so2287963f8f.1 for ; Sun, 18 Jan 2026 03:00:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768734036; x=1769338836; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=O0hfwQRUIahRpuglzDE/ef/thxNWT6Y5iS8nFpch8gc=; b=TbzHdWjc9ICyxcUzFeNcITNE8FqMOlXkUzbzMSKnntIs4sKF5FEqZ5uSnQ39cnJZZ2 kSnJm0Og7A3Vbc+U0Xq3hGqYWDrbYZa/75QMCgsairb2wrbO0WbIuPGlXbLoQYjgFPRQ wrwQ7T95kP+ehtcjk4eqEW+kTletjdLL2ElEQNPHwb/M6nO3j8wXrYZkxqdt+ooyn3PI dDpdASxXw81xc9Mh7CO353BSyWcvcP7Q+3wq0kCtmoxhV9AFHGKdQ/IGszjLjUGjB/CL r0hB1x8OJHmOAWY2mYwkNr2DhfWYtQh36Ckx3jvvwCn+zgdQ+KAv827WMg8dVvG94mjL Jd1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768734036; x=1769338836; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=O0hfwQRUIahRpuglzDE/ef/thxNWT6Y5iS8nFpch8gc=; b=wDPVDKahLgRoKqoMR/t85/rbCxh8+J+gtz4Q7dx5EmOrkdrXhmyqeIWbzR+i1GbtWW a5T63/c6nzdJDlsvcGlfSZqvXlP/zFCH3acJMgq5hMAsqZCUwU9XA8WKSxPlommMxFuC 9rALVJgxLRG5ocvO/hbUf+RL6daKQYtugSJ8u68UhmeUdQIUpuI63r/iUn1x0O+cjXEb al0+dh6lxFzLHroWEpyWzTBLYqaeyLN4h0MnO1p1vCGLo4iQoN8xHmBb8tun/SEIa1nb yCZxSmPRvGOvnF+GWW6e6AT0U9JyjgcSq2SPfW2Lf0kWYKCI7zb2W51lmhk1Hc4nQwKt MO1g== X-Forwarded-Encrypted: i=1; AJvYcCU0VADZs5EYikC8p6AiL+VwOspJ3vr3HxIaPZKzX45IepmS5iJonSUe0QqpAA//BEcs28gp1hBBLsZpfWc=@vger.kernel.org X-Gm-Message-State: AOJu0Yz5hw3Jr1tPKN2X97DCtQOQtkppXnrwJgEP5zykpQpijC/JcQ14 Fy+21i5D1b1eGLeD87PBCDIFETdVuLVCtVmGL3WSyAglxOFSdNpZhVXk X-Gm-Gg: AY/fxX7onqE0fY6wPDPe8/UTGcUYxOevU/Q3WVy+rkvUi0J7uKtIUhwVCJULmDhoSLP oObCmzkrnvcHNDcPVimlpRNRWneGpzpnGnyPQaAAY/VCpv3YMN6W8j/0pQX66y8P+OICRNM0XWj v0+EWkPHlNMkP1BZ6gCaGzFZFPXVWxBuG8on1QwC4KKHCLbQVtOPv11y9qmEojVNrMWVcaeXC6i bzD9nctzIoAmBApLkNGsKVaSVe5jwFr+l2LedNs8TmGzr57XcjGSfjfIb+/tQOeicOlgekOh8SZ BEP2OvrN3pumtQgsB85ViYSCXGADjEM+bqTKr1X0V9yH64EgA1LTnS0RCNl789DkxkXQX7/JP/8 EcQlLy33lcJ/+P0bxDVoB1AWb8y1NcMjWsfUxgP+cQS3Nr6W5odFqA5zc3CQFlTDfpVrZp2RxKj L/udAzwHN6+4AoTQ== X-Received: by 2002:a05:6000:1847:b0:42b:5592:ebe6 with SMTP id ffacd0b85a97d-43569df48d2mr7889842f8f.0.1768734035801; Sun, 18 Jan 2026 03:00:35 -0800 (PST) Received: from [192.168.1.243] ([143.58.192.3]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4356992201csm16864635f8f.2.2026.01.18.03.00.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 18 Jan 2026 03:00:34 -0800 (PST) From: Andre Carvalho Date: Sun, 18 Jan 2026 11:00:27 +0000 Subject: [PATCH net-next v11 7/7] selftests: netconsole: validate target resume Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260118-netcons-retrigger-v11-7-4de36aebcf48@gmail.com> References: <20260118-netcons-retrigger-v11-0-4de36aebcf48@gmail.com> In-Reply-To: <20260118-netcons-retrigger-v11-0-4de36aebcf48@gmail.com> To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan , Simon Horman Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Andre Carvalho X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1768734024; l=7540; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=e+w0DAW9oXvqNZy9JiObhL7asMTKcY24W84QkRdGT9w=; b=0mH19GhErzAi1HimK1aBDCmL/tFdWqtd24AQ//SxdqMJYyv7XsN/yIF3OeKiKm5yvv4m6WAfw sNIKnCD9eK6As+DnEEGjNces9E3u968aPRhvsbJ6V58cbkHTlj4zvRg X-Developer-Key: i=asantostc@gmail.com; a=ed25519; pk=eWre+RwFHCxkiaQrZLsjC67mZ/pZnzSM/f7/+yFXY4Q= Introduce a new netconsole selftest to validate that netconsole is able to resume a deactivated target when the low level interface comes back. The test setups the network using netdevsim, creates a netconsole target and then remove/add netdevsim in order to bring the same interfaces back. Afterwards, the test validates that the target works as expected. Targets are created via cmdline parameters to the module to ensure that we are able to resume targets that were bound by mac and interface name. Reviewed-by: Breno Leitao Signed-off-by: Andre Carvalho Tested-by: Breno Leitao --- tools/testing/selftests/drivers/net/Makefile | 1 + .../selftests/drivers/net/lib/sh/lib_netcons.sh | 35 +++++- .../selftests/drivers/net/netcons_resume.sh | 124 +++++++++++++++++= ++++ 3 files changed, 155 insertions(+), 5 deletions(-) diff --git a/tools/testing/selftests/drivers/net/Makefile b/tools/testing/s= elftests/drivers/net/Makefile index f5c71d993750..3eba569b3366 100644 --- a/tools/testing/selftests/drivers/net/Makefile +++ b/tools/testing/selftests/drivers/net/Makefile @@ -19,6 +19,7 @@ TEST_PROGS :=3D \ netcons_cmdline.sh \ netcons_fragmented_msg.sh \ netcons_overflow.sh \ + netcons_resume.sh \ netcons_sysdata.sh \ netcons_torture.sh \ netpoll_basic.py \ diff --git a/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh b/to= ols/testing/selftests/drivers/net/lib/sh/lib_netcons.sh index ae8abff4be40..b6093bcf2b06 100644 --- a/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh +++ b/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh @@ -203,19 +203,21 @@ function do_cleanup() { function cleanup_netcons() { # delete netconsole dynamic reconfiguration # do not fail if the target is already disabled - if [[ ! -d "${NETCONS_PATH}" ]] + local TARGET_PATH=3D${1:-${NETCONS_PATH}} + + if [[ ! -d "${TARGET_PATH}" ]] then # in some cases this is called before netcons path is created return fi - if [[ $(cat "${NETCONS_PATH}"/enabled) !=3D 0 ]] + if [[ $(cat "${TARGET_PATH}"/enabled) !=3D 0 ]] then - echo 0 > "${NETCONS_PATH}"/enabled || true + echo 0 > "${TARGET_PATH}"/enabled || true fi # Remove all the keys that got created during the selftest - find "${NETCONS_PATH}/userdata/" -mindepth 1 -type d -delete + find "${TARGET_PATH}/userdata/" -mindepth 1 -type d -delete # Remove the configfs entry - rmdir "${NETCONS_PATH}" + rmdir "${TARGET_PATH}" } =20 function cleanup() { @@ -377,6 +379,29 @@ function check_netconsole_module() { fi } =20 +function wait_target_state() { + local TARGET=3D${1} + local STATE=3D${2} + local TARGET_PATH=3D"${NETCONS_CONFIGFS}"/"${TARGET}" + local ENABLED=3D0 + + if [ "${STATE}" =3D=3D "enabled" ] + then + ENABLED=3D1 + fi + + if [ ! -d "$TARGET_PATH" ]; then + echo "FAIL: Target does not exist." >&2 + exit "${ksft_fail}" + fi + + local CHECK_CMD=3D"grep \"$ENABLED\" \"$TARGET_PATH/enabled\"" + slowwait 2 sh -c "test -n \"\$($CHECK_CMD)\"" || { + echo "FAIL: ${TARGET} is not ${STATE}." >&2 + exit "${ksft_fail}" + } +} + # A wrapper to translate protocol version to udp version function wait_for_port() { local NAMESPACE=3D${1} diff --git a/tools/testing/selftests/drivers/net/netcons_resume.sh b/tools/= testing/selftests/drivers/net/netcons_resume.sh new file mode 100755 index 000000000000..fc5e5e3ad3d4 --- /dev/null +++ b/tools/testing/selftests/drivers/net/netcons_resume.sh @@ -0,0 +1,124 @@ +#!/usr/bin/env bash +# SPDX-License-Identifier: GPL-2.0 + +# This test validates that netconsole is able to resume a target that was +# deactivated when its interface was removed when the interface is brought +# back up. +# +# The test configures a netconsole target and then removes netdevsim modul= e to +# cause the interface to disappear. Targets are configured via cmdline to = ensure +# targets bound by interface name and mac address can be resumed. +# The test verifies that the target moved to disabled state before adding +# netdevsim and the interface back. +# +# Finally, the test verifies that the target is re-enabled automatically a= nd +# the message is received on the destination interface. +# +# Author: Andre Carvalho + +set -euo pipefail + +SCRIPTDIR=3D$(dirname "$(readlink -e "${BASH_SOURCE[0]}")") + +source "${SCRIPTDIR}"/lib/sh/lib_netcons.sh + +SAVED_SRCMAC=3D"" # to be populated later +SAVED_DSTMAC=3D"" # to be populated later + +modprobe netdevsim 2> /dev/null || true +rmmod netconsole 2> /dev/null || true + +check_netconsole_module + +function cleanup() { + cleanup_netcons "${NETCONS_CONFIGFS}/cmdline0" + do_cleanup + rmmod netconsole +} + +function trigger_reactivation() { + # Add back low level module + modprobe netdevsim + # Recreate namespace and two interfaces + set_network + # Restore MACs + ip netns exec "${NAMESPACE}" ip link set "${DSTIF}" \ + address "${SAVED_DSTMAC}" + if [ "${BINDMODE}" =3D=3D "mac" ]; then + ip link set dev "${SRCIF}" down + ip link set dev "${SRCIF}" address "${SAVED_SRCMAC}" + # Rename device in order to trigger target resume, as initial + # when device was recreated it didn't have correct mac address. + ip link set dev "${SRCIF}" name "${TARGET}" + fi +} + +function trigger_deactivation() { + # Start by storing mac addresses so we can be restored in reactivate + SAVED_DSTMAC=3D$(ip netns exec "${NAMESPACE}" \ + cat /sys/class/net/"$DSTIF"/address) + SAVED_SRCMAC=3D$(mac_get "${SRCIF}") + # Remove low level module + rmmod netdevsim +} + +trap cleanup EXIT + +# Run the test twice, with different cmdline parameters +for BINDMODE in "ifname" "mac" +do + echo "Running with bind mode: ${BINDMODE}" >&2 + # Set current loglevel to KERN_INFO(6), and default to KERN_NOTICE(5) + echo "6 5" > /proc/sys/kernel/printk + + # Create one namespace and two interfaces + set_network + + # Create the command line for netconsole, with the configuration from + # the function above + CMDLINE=3D$(create_cmdline_str "${BINDMODE}") + + # The content of kmsg will be save to the following file + OUTPUT_FILE=3D"/tmp/${TARGET}-${BINDMODE}" + + # Load the module, with the cmdline set + modprobe netconsole "${CMDLINE}" + # Expose cmdline target in configfs + mkdir "${NETCONS_CONFIGFS}/cmdline0" + + # Target should be enabled + wait_target_state "cmdline0" "enabled" + + # Trigger deactivation by unloading netdevsim module. Target should be + # disabled. + trigger_deactivation + wait_target_state "cmdline0" "disabled" + + # Trigger reactivation by loading netdevsim, recreating the network and + # restoring mac addresses. Target should be re-enabled. + trigger_reactivation + wait_target_state "cmdline0" "enabled" + + # Listen for netconsole port inside the namespace and destination + # interface + listen_port_and_save_to "${OUTPUT_FILE}" & + # Wait for socat to start and listen to the port. + wait_local_port_listen "${NAMESPACE}" "${PORT}" udp + # Send the message + echo "${MSG}: ${TARGET}" > /dev/kmsg + # Wait until socat saves the file to disk + busywait "${BUSYWAIT_TIMEOUT}" test -s "${OUTPUT_FILE}" + # Make sure the message was received in the dst part + # and exit + validate_msg "${OUTPUT_FILE}" + + # kill socat in case it is still running + pkill_socat + # Cleanup & unload the module + cleanup + + echo "${BINDMODE} : Test passed" >&2 +done + +trap - EXIT +exit "${EXIT_STATUS}" --=20 2.52.0