From nobody Sun Feb 8 02:08:28 2026 Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) (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 A77042BEC4E for ; Sun, 9 Nov 2025 11:06:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762686379; cv=none; b=jzIIQ0Qt7TQgePOjgzD/rAqJ/rkyBZ3VKbDwe2eO+tZoJzycpmr07ICUjI4pExt8w0cOMVWaJWNKI9qAn6L9QycQ/8KwwcfO31cB2u3WzZ//RnpOoWr/I87hAoXJWxn4odpIevBUPZPZonfd4lmc+LO7Gwk4+RhOlqN3SG16PO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762686379; c=relaxed/simple; bh=0a6Z9vm59vHUX3M3EDlQdpNuJbepNNHLaFpEBjgVj1o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=tAPCGoFFMcsiR9zd56oTK6/B0FeG0GOezEq/vf9kBDidUo7j6eoY4fcTT27Repmw/NsASLQm4SS2KmjYVIfGDgpLIB93VT0rZTlx+JYNQdvupF9CUC9aLjfdXd7oYm64a+XA6W3N800JQ9Qd984PvOJcr9swwL1PY77DRdHcOv4= 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=PSqDLK7q; arc=none smtp.client-ip=209.85.221.54 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="PSqDLK7q" Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-42b312a086eso404992f8f.2 for ; Sun, 09 Nov 2025 03:06:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762686376; x=1763291176; 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=UMuZ/D7eDR+K5SfJd8pIttc4xM0fYqKI56Vw1YxCazE=; b=PSqDLK7q+7+x9cpznSyDTJYm/t3Yj7KXUS4bZcNOwy1Z9zFvLA6GgVQynuuveJrA8I 8viCBBc9foVP7X4unSNMkfnnvKdwq8EfGv2P3HANFP+UffL5knxtRgkoZdbFykK3KK9b zFIIUjkdIgwCdgr7n5PXqs7TZn6ZxS0X5SOhQZ8eB5YfUkmj7Sv+jK27/1kH9ltqPRfM d88jd1laeyzm5CeXpfSU1sX+fUbg14UpE8zl1hRABqbP0llFUdhakHIOPxwq6QbLcSOQ dElBK4fdGwJAix8+ohmIurRoOSaF37ZAFS5reVyrfy6Zr46t5oQ8peozu/0fTeCeAKs/ Y38Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762686376; x=1763291176; 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=UMuZ/D7eDR+K5SfJd8pIttc4xM0fYqKI56Vw1YxCazE=; b=m8hETppBCvfGJDuSyL4XpAn3S1P6wwPvdA7VUM4+StrepXBoylrQH4M73IF6COdOF/ +eZLZ0sx9Bi7vRmeoead8cQFYtrOOIDu0Lj7pSKEOhUhLXf9QKUSO7DT/A3mLYlY6klN ryfNCZJ+rmrHHve5N9LOPHOi8xGvjvpSFs7dJTVX0BdGCF0Rp/qWDMbRiWG1MB3WOhn4 eeV9Ahm5tq+xmMpaoxGTh/w1z5krq7eYFwl3ipCcDhN/k98uqYS1AZ29E4sJF3tqLrT9 vBu9RFjkqOs4fmnlhNYSzw8Tt0VzS9dnQAB47JhwB7I6r4CyTN5Mi6OIEuxkXAY7gjUh p0nQ== X-Forwarded-Encrypted: i=1; AJvYcCVRc+1DEngYEI+hIb9YWMCWtDCITv9xtTtMPReKgd4hMg/vMbemfNLr5Nxx1Padbm7HrZ7I5DB5zZAd+A4=@vger.kernel.org X-Gm-Message-State: AOJu0Yyi/dyI6zoIT0OOGfM81As85DfnFhJI+ztDQzKT/BY/bQlhNPd/ ivjW1jtnpuj91+11QFVYD1AsFofC4z6SqJbbgsT0sGt6oL6YlT2m6Q98 X-Gm-Gg: ASbGnctwlCwGt4Evb+VMJOeDCGRkjfykDv2okQiBSKluYuD3etRwFbLsrgTCvDcC2r2 1u67Rt/VzSI9keFkq6V/Rq1VEIHxZ9qKTL31Pe43bU+jOyMHbJ/xjcf7wzCl15nDFfWi6EXFU4R dIQgeqP/9FCR9nmICR58t5M5qGtOdhB5fUmfbxhL7m34KtNWudvR1V7CVgTxHXckHnvx2gGWWqG rQk9SRhhNeMtKjJN4Hv4wTvoZ2AGRd70rL1R1wSUXWZQ7NuZWiAfRB9kw+P3aSKJ8KokRm3odOq gquyYEFEAvcOGWwMyk4j1spQXAhS6Zc1pYXbhw5eAnBaOYQG3o+gkSbvY1id7oW5nIJc+2iFEl+ bHP2NiyxY86FqnsZ87wlw0CHQaCNB2SFrrnhaXMJTFvHLvOXl2o6FRNb2WrbKhaW/7I0MLgP2I2 zx10AXf6eOLKJv5C0= X-Google-Smtp-Source: AGHT+IHFhjADorg/ZR5107ihIL53sgAhlpAdhqkAU05FL/iFU41EOoPQsS82Rvhk2qa66vEBuFTWSA== X-Received: by 2002:a05:6000:2f86:b0:42b:2a41:f2e with SMTP id ffacd0b85a97d-42b2dbefcfcmr3776049f8f.23.1762686375742; Sun, 09 Nov 2025 03:06:15 -0800 (PST) Received: from [192.168.1.243] ([143.58.192.81]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42b316775f2sm6354925f8f.16.2025.11.09.03.06.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Nov 2025 03:06:15 -0800 (PST) From: Andre Carvalho Date: Sun, 09 Nov 2025 11:05:51 +0000 Subject: [PATCH net-next v3 1/6] 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: <20251109-netcons-retrigger-v3-1-1654c280bbe6@gmail.com> References: <20251109-netcons-retrigger-v3-0-1654c280bbe6@gmail.com> In-Reply-To: <20251109-netcons-retrigger-v3-0-1654c280bbe6@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=1762686373; l=748; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=Po4s941eMErBwuDFYeqR/VDMArYoBzjcjN8/MMT+h9s=; b=Dob/xrKXJfj0d4xZnl+MCY/sthJswm5B+vonAmQ2jJUC40wOI+WQMq9EY9UZP0OdSo/OqAzvi sGBHZfFAmgpACXKkgVcqacoh5HiO2KkyE2FaVqEAiOjeUmhl2PYJVn7 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 --- drivers/net/netconsole.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index bb6e03a92956..7a7eba041e23 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -117,6 +117,11 @@ enum sysdata_feature { SYSDATA_MSGID =3D BIT(3), }; =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.51.2 From nobody Sun Feb 8 02:08:28 2026 Received: from mail-wm1-f42.google.com (mail-wm1-f42.google.com [209.85.128.42]) (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 93B4F2DC32C for ; Sun, 9 Nov 2025 11:06:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762686383; cv=none; b=ipIsNfa2sOfqOkUqGvHVbf9zcaFoPPrPFSgjIe+sT7lWSFE2Moo5avJCYo72JVH8649ZHoee6akShjE/oUUjE2RHPiGjWkmlwN0b06ueb3aXuU+Fg2N9MwDHjCkaMEo3MXgN5TOYAuqBPQuP5/4GL8SSpNZKFGxLqomIyCNwUO0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762686383; c=relaxed/simple; bh=h/WMgGuer/rTaYwZTdPaPC720ScIfwyjdiEy9wHdF6o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mmwYdqviCqTyiu1c5DK7pU1eFDk+tP0CPeFyv3IC9lZKVgpqo0DCkJ2FmBv+iJgSN/zlqGtYbrG4gE/JfW1zeYLzBzZ3mef68oh0zKOJ447qLmL9ZMjr4YIFgw0eCldFO9U/HYRsNlJZ9lW+vJZ+Cm1fHT11bLx888IuSyxNgJ0= 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=DbkYDuwc; arc=none smtp.client-ip=209.85.128.42 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="DbkYDuwc" Received: by mail-wm1-f42.google.com with SMTP id 5b1f17b1804b1-47728f914a4so12319865e9.1 for ; Sun, 09 Nov 2025 03:06:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762686378; x=1763291178; 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=64c74E2vcVe9LLOPxPVEYauBTLRgO0onhWdcRTaSbWE=; b=DbkYDuwcrmd+SkCfRetlyfl+3I1xxmhENz4n4a8NKTOeCqE5DNTj985zoscu6z2KSM rw2l4SPhRx2lw6cOUzAHiHDrlrJcY8MKMEwhLKBZ1dNvh4Qthppi8GMFr5wqv04CkIhW fv/hUmhLpVBfcYm3CPI8yAYiGREl7wYtIvCutdmEd6j8WTjJiiqcGEAdolwHD6xYzTcZ o2162+U53EC7vfybHYrpPCXmezkHzxjHX5tkVS1EJW34OaHcGuz3kvpQNy29qyGpufKX 5TCDqimIY5DJollXXH8PyokDkOZ6h8KBEKXBqoZIvjJLEw89Dr/tBkFkSaUVX9CD+30L gTkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762686378; x=1763291178; 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=64c74E2vcVe9LLOPxPVEYauBTLRgO0onhWdcRTaSbWE=; b=Vs5FPm4ibfU424CZN8Gvk8VC+QSq65JaTLUlZBjIoxsdHFHYqLqVewC4CNcSD+B5dP IDu04YHak2MPD/dnpla+Fzh2n8MjrkoyrqnK0njbOAYtIi1hd7Pgl0s3fIws6OE/bEi/ x5RF2nZqQIZsqLfqTysrGLQC3SVF+aWoa/r2SyYKaEUWg+OCydxzVBu0CzM0FVO5JG0S 1avfyd8Ikdo95Jhgf5h0/5Vv/rbXAT1gSFARif4vb5f+aRO6eYgr/uuZzcqZbbfBfNp+ wSlTFYchC4tMSCRnIqAM9JiFm+JwL6X8dTqc5lRq/65uKibgMchNwgPBURYV00MjXKk7 Ni6Q== X-Forwarded-Encrypted: i=1; AJvYcCUDPtkLMUmpFyb7cx+UGm9baS5ozcZXDqps/wfQwFqNVWtAxERWjF+Pgo13imqcIVYcG5PuTsPtOhLmVrY=@vger.kernel.org X-Gm-Message-State: AOJu0YygHo9A1CqkfyXiNpLrgxvCJl7xRMioaX3fwAH/ive+pnFU+4cj MjUpsM4+FVJKIIQpz/cLOahXC4OL+u0vD2aPcBrWSm8Mw+BUtLTKrSpG X-Gm-Gg: ASbGncsLU3S06HtP7qc7Jx/3PYDaDnnFz4AtZMHDzjM06JKtUzE39TKXZ0Zkfh9x9hS sqnhUyAumwRx5VtJ9IuJWwMsL6KYFhhZ6HaKsULmar+MUMfK3oSoD7qL0N1dGpKFfeMb/MSq5qu VExR9RwoSYy6k3pHKI5P3MV0sYfDU1WFszBANm49iTvvhs5JsYzdq2N+L59bEh9Xf7Tbxp40Jt8 Ixb23l2II3rjllWj5I4/TD4kAXBFsq/MRnbTb5H+9iprImGNpxdROjikJSc0pF66una5P4iFJms Xd/QY7jdvt0s4rew9p1P1Ebkisn3tVaGI7m6lpLtxldjuVaEMS9+9gEvnWEIL2OJL5TIfnol4hS 80KH5FUICXp8i6IYqNrKNDOEN6KJobewnjVf4JeRn1oNNhR5nZWFdizZ7HVgvqL17TVKoiAoiK8 IYTO0dsKu5Xdztwmg= X-Google-Smtp-Source: AGHT+IElNeJQDYPuBNLWxLepB/r6OhpxlCq+w+1c++Q3X4zRKFwmD79E2oW0gj0qD1clRNtZWMhpXg== X-Received: by 2002:a05:600c:1912:b0:477:7946:dcf4 with SMTP id 5b1f17b1804b1-4777946df44mr12371535e9.24.1762686377258; Sun, 09 Nov 2025 03:06:17 -0800 (PST) Received: from [192.168.1.243] ([143.58.192.81]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42b316775f2sm6354925f8f.16.2025.11.09.03.06.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Nov 2025 03:06:16 -0800 (PST) From: Andre Carvalho Date: Sun, 09 Nov 2025 11:05:52 +0000 Subject: [PATCH net-next v3 2/6] 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: <20251109-netcons-retrigger-v3-2-1654c280bbe6@gmail.com> References: <20251109-netcons-retrigger-v3-0-1654c280bbe6@gmail.com> In-Reply-To: <20251109-netcons-retrigger-v3-0-1654c280bbe6@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=1762686373; l=8901; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=h/WMgGuer/rTaYwZTdPaPC720ScIfwyjdiEy9wHdF6o=; b=VAchufCNgG/NAzO0ZRSXPzdMA+wl8320gdAokMA044REpEazAIMj2itMKFHH+aspzZ352NXxh o02VWDApaRaBMPOJ46tOsnp9vDclUsbecYWznIXB9EGoK7uLRYi13lV 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 Signed-off-by: Andre Carvalho --- 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 7a7eba041e23..2d15f7ab7235 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -132,12 +132,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. @@ -165,7 +165,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; @@ -257,6 +257,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; } @@ -275,7 +276,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 @@ -398,7 +399,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) @@ -565,8 +566,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); @@ -575,9 +576,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 @@ -610,16 +612,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 */ @@ -648,7 +650,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; @@ -675,7 +677,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; @@ -699,7 +701,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); @@ -720,7 +722,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; @@ -742,7 +744,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; @@ -765,7 +767,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; @@ -790,7 +792,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; @@ -839,7 +841,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; @@ -1330,7 +1332,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); @@ -1459,7 +1461,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; } @@ -1726,7 +1728,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); } @@ -1746,7 +1749,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 @@ -1902,7 +1906,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.51.2 From nobody Sun Feb 8 02:08:28 2026 Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46]) (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 04A272DCBFA for ; Sun, 9 Nov 2025 11:06:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762686382; cv=none; b=Jt9hvYVTc7Yyu9FQ0FCfdOUS/AORW4TP27KU54iVpqDFYqf0P9xLAeCQjP765ByheLsM1/JQco3XVBUorL7OjtIaKTp1xPi301MMpx1KZCEVkHMKl1qJIJOXUTUQh0WyprSntqfpzmJqT5p2/S+axXErQOT7qYgM2JQvoptp11A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762686382; c=relaxed/simple; bh=Sl57n5h3qnQFQNcmwKkS4S8dI3DCYu3TXVSej6Ds+H8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=fWvrxj5xpcKhsQyafgMccxlmTWpB0rd5uYAKYPe0QsFGH5leimcOMbfs480m33aVgNjY8p4r9Bijcqjk+V+I9X5bUwLHhIYZhXlPiPJDmYWG5yicrWh/z7ojr+d+3s+JCD9FvaNpC2up24JUVz+XG24ZQ/avlPu/wRQgwx4357g= 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=hJFs75lf; arc=none smtp.client-ip=209.85.221.46 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="hJFs75lf" Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-42b387483bbso183159f8f.1 for ; Sun, 09 Nov 2025 03:06:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762686379; x=1763291179; 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=85FBK1N7968Zf3zmy7BJUL2wfVMtCnOsN9wdrJDgfgc=; b=hJFs75lfTSw6dZ9ude0fkIzdZfEXfXOneUe+NdXfnS/ZG1l21Ppofl+AXJUrdPKvwo nEr3PTun0Kkmvrh//hhyJBanf2bPN8xIVyrWQVTitZk1Nv3bTMN/MyUuTcLlt3vK63yU RajnY7mQJv7TYrE4tIHcqo/wsl/58Nhuba+RQQDYC5LuVd1wO1TOS7o00VZBKz64eyoG /vsY79s9uO9y5FZK0+F6FPRjZI7zcoZWR39/BTgVAjUVR6XqgFqreSkmdMIM9Oa3lRd0 Da1vT1dZNJFtw1v55W5X7YQc1X3vpR+yLVHwvMuISCQPqqgLGlsF0KrLvMVFyxQoLObF l1kQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762686379; x=1763291179; 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=85FBK1N7968Zf3zmy7BJUL2wfVMtCnOsN9wdrJDgfgc=; b=SdY+hkCTnmypuVhEqAkVL8y/p956PO6LuKds2zi6DqUKtDnG3Lyf4X8PNYvzjAXrcs YDODQbdo90ICFu/cSvvAjZHAH39IghAJdN7AF5V779aUFEw1Z0mU6+I+Ef7oc1mdqTqN Qrn1hu95s8Fhqy4CEwQl+XaMglGlRcnffYC8lLu+Pn2qDQg4SRueV30WKqwroa4aZ7dJ G1S34praNZzIY+FAVv3NqxVBq0XvcywzEEkrHKy838yW2iM6uifidnCOb9f8jlQG8cda w7axTB+jy5LVbEes8wyjeOcmkVQk4Z0GhjQ+Uc/T147ZqT9YxkLbj5tzDKnWT1gCDomD AcwQ== X-Forwarded-Encrypted: i=1; AJvYcCXE/M/zhQwpRzs6ltSko6Kz/aXfnK0OTxlPl4sRpSiAocfw/GWEQcfvteLYfEfOx+PT7gXWl/yofsfg/xY=@vger.kernel.org X-Gm-Message-State: AOJu0YyylptFWEEd4cyJSdJ+1C/q2KoVG9vCZykl8GmWlY3xcw5UY162 0m3ZFmeoUhxfYYqB7AQDLZsMwOwFUpp+6KGmL9Nh63fwYcTOovzLcpyv X-Gm-Gg: ASbGnctazPzKZX1upJCUhBkpOPw2+NtH6yQm7yZidsdV9ikXK3MhpKqLd3Ms8pV5xNc i4csfsfqL2QNde7H4iES7v0CnknlTH7eQfbmV2dqTJiS4vaa1Zwol3Ek1t5r3MG7kejyJA1dIRe WAMZ6c+/QveVZnWiYDIEOeThBxkqauGx1o5bwrJrgkPQ54s8hw4TKAU7WOMt2JV6jt8aSlAVeKK rtexPPKy7e4u05O1kGhJZvAQU0f31jKEqcrPFHfWisEZxWbwSUFax9RGjASPSitfORWp6ZfGLbd Cd1VR+hflHw4VEJjnkZ6gLqjdTvECGZtlCX4KIf3Se9PFCSckz1NNMxpjvwbjYpN7JeO5FSgXp9 izhdgIM4iayMmoLwD8WdVzOHg46C/jozTIDxX8hyx4thKYYO9JKCjFk4QLgYuZgbccNHLyP+dzg yzUI4x X-Google-Smtp-Source: AGHT+IHFIeiuJChm/jLLid7Ik0+NY4IPeqhmAps90p1OjDHbjatYqMo8FhZ3+4mJG2x/qi9W+hfY8A== X-Received: by 2002:a05:6000:2912:b0:42b:3ace:63cc with SMTP id ffacd0b85a97d-42b3ace6596mr20172f8f.35.1762686379085; Sun, 09 Nov 2025 03:06:19 -0800 (PST) Received: from [192.168.1.243] ([143.58.192.81]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42b316775f2sm6354925f8f.16.2025.11.09.03.06.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Nov 2025 03:06:18 -0800 (PST) From: Andre Carvalho Date: Sun, 09 Nov 2025 11:05:53 +0000 Subject: [PATCH net-next v3 3/6] 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: <20251109-netcons-retrigger-v3-3-1654c280bbe6@gmail.com> References: <20251109-netcons-retrigger-v3-0-1654c280bbe6@gmail.com> In-Reply-To: <20251109-netcons-retrigger-v3-0-1654c280bbe6@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=1762686373; l=2028; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=C8sdELlfliWx0wFIHhmVjWXm2jGpSIoVSQHcSClL97Y=; b=VosP6vA0UGMteFuPJJrdAB8s4fo0qd1/JQ+Q+l3P3elVqVgg7+IR5SyFib/tuF7ioDch2jzq2 PLd4XS9fShgDELOMFlnJkQ5b97MLBXZXZgrG/Qc6y8rZBZr0oy34OK2 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. Mark the device that is down due to NETDEV_UNREGISTER as STATE_DEACTIVATED, this, should be the same as STATE_DISABLED from a code perspective. Signed-off-by: Breno Leitao Signed-off-by: Andre Carvalho --- drivers/net/netconsole.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 2d15f7ab7235..5a374e6d178d 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -120,6 +120,7 @@ enum sysdata_feature { enum target_state { STATE_DISABLED, STATE_ENABLED, + STATE_DEACTIVATED, }; =20 /** @@ -575,6 +576,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) { @@ -1461,7 +1470,7 @@ static int netconsole_netdev_event(struct notifier_bl= ock *this, case NETDEV_RELEASE: case NETDEV_JOIN: case NETDEV_UNREGISTER: - nt->state =3D STATE_DISABLED; + nt->state =3D STATE_DEACTIVATED; list_move(&nt->list, &target_cleanup_list); stopped =3D true; } --=20 2.51.2 From nobody Sun Feb 8 02:08:28 2026 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (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 64DE32DC337 for ; Sun, 9 Nov 2025 11:06:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762686385; cv=none; b=kY8lDdRQ33SBvcw1CzKA4j56zB2m19GxA1nXdFLHU4JWcobodDBTdrFNaxwb0sKwY3q+QnJ+kdjTT+mg4Ci4HysB9NfJj60mc1w/pufPwhf5kmfoRg+6wR90aWKAo/MpM1NFEJR5WpdeDRvGFUsl084zvh/9e9S25yNN6/pgySk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762686385; c=relaxed/simple; bh=FIaU/PJYhFPVOHbBtyegMmwlEvrKVznPXH2gtLOtgG4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ju9xi20qofDWee0YDjd//Y4Xj8XRrQ7LdjXdzJCtekQous9ANpaF+i4sbAo7TpG4fpSf3Phl6s0Q6zZKE/NiSInoul14pjwqrjpDHncDQAc/u8FnvjNW/R7/5R7grDotaOLXRYfChruwHIcIP4ZQ7NeqQT8Imujy6MZJFsJpPLw= 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=V9yDI2YE; arc=none smtp.client-ip=209.85.128.51 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="V9yDI2YE" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-47728f914a4so12320025e9.1 for ; Sun, 09 Nov 2025 03:06:22 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762686381; x=1763291181; 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=FlM4y0l3wFyRG1MmirgQHO9XDWEVNYNhEnXHnpOtmJ8=; b=V9yDI2YElAdYboNrz58iBbVmo+HkAlBMPmr4ZIdodbONCW6/K5YCzXiG/BTwPf6V5u lJNdEWTuq+qJStLDuCdKb8C8JHR5wfgWZtojWjPfqx6FnwanUEX3U+s6HnKxu7TVCO0C XGyjhUiKrw3OEl+XExNWSpl5HeWwz986iln5uUxkfc93Wby1IqreLLq2i5ii9BQk5GQQ RFGfgZTOiONEL8MBNd6xN1gi8an7sSL8Vyrw+kVsW7JnGzUBjLKYV3M9Ex2cVyxNn2BL GHMgc4k81Z/wzq6l/IX4tuY8F+FYkMT/nPxN+ZVBUCSAp+g7uD/do/3+b7L4dLSPUCFo WnHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762686381; x=1763291181; 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=FlM4y0l3wFyRG1MmirgQHO9XDWEVNYNhEnXHnpOtmJ8=; b=ZF9wnUABxo1KWyE8WLsIpKiAcFmfFUpwiAOjgHBOHgO+u/0BKFR4DjT/yxWkfl/hUF eZcDz1wmfjwBUdwfLT64fYxSTrrix4HjtEGEquKiAq8Dz1W131vREFnlrYMeZRts+izh dVsXm8h1cKFW1FqkyWJQydfCmzHdhA7vOwm9nI4jbfn0CYO83V+MswYln9/geO8un7Bi ZbwMpGYhe/lKc2jhn0F8usTdDLzg3hBkj+zk3fuINxYn+WeZcPPycTT0OzCKcxN4E7CA Io3ozB88lrki6F9sCc2JTRypFdVrI+uUhqGl+pf7Dwu4qUQqBh7+SyfdHA9YE3im6Jzg Wzaw== X-Forwarded-Encrypted: i=1; AJvYcCU1NhRgORaoH08bzajLMz/NYOa1rr3Wum1CoJQ02TPo3tnj/RP+LChonGc8r3gyyigDjEnajhm1ZZyIMAU=@vger.kernel.org X-Gm-Message-State: AOJu0YxCpE3iwl2OmdDoseK8p9OtmA+7+y9Afrgg6fnDOiBvbz0grFor IGs8lb6V/VeBwSagOLXpvQVZ1FW4noQjj0ZxZS/cgUeJM0NT0P6lnxFo X-Gm-Gg: ASbGncuRjP9VtREyoPMlG3v8cHIIqZNJpv3HXQyVhuauIl3AobOYmynysCOH0B1tnKF JJC3C0xvBkjp4s/KbpGiFbjq6GKls9khaVqF6ONK2+F+rXGl76e80PziAXdDEtqRTgqUaZaHAQA jZnDOVOxZhH0DWD/UgeEI+DDJFzXGJ+4Cu+rDVKP7xVN7CDbg338U2KqZmhgiwCB7rRpw1Hm0Eg ymXgTsidMgJdbWJN1Rmh090OBetha8SvoHU8hX3IJZmCwGtJ8/e4+Oe3WsCe4V08PQbN6PYNixP 46OpOWknV+ml0eQDI+3/wMG3QJDF2jwLI0T1+W8PodZfzv9ziFq+4LaOYZqv3Vpz4lqr40n7NOT dGq1qAT3ENgdVIHeE/zjIO6reEcwbv1WxPBI5N/lV3ZUfnYkORaM1Ue4kTBZW10aUkcp8cxSQeP ymR3mp67hb+6TRGkg= X-Google-Smtp-Source: AGHT+IGXNMTWbs/Y2C5fmQZcxJt3PJhVxlTT7teM44/vsz2vWDHEnObq/JmjatlT9IiI9Ya7rMuK8A== X-Received: by 2002:a05:600c:19d1:b0:477:7b16:5f88 with SMTP id 5b1f17b1804b1-4777b1661d5mr5895245e9.6.1762686380556; Sun, 09 Nov 2025 03:06:20 -0800 (PST) Received: from [192.168.1.243] ([143.58.192.81]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42b316775f2sm6354925f8f.16.2025.11.09.03.06.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Nov 2025 03:06:19 -0800 (PST) From: Andre Carvalho Date: Sun, 09 Nov 2025 11:05:54 +0000 Subject: [PATCH net-next v3 4/6] netpoll: add wrapper around __netpoll_setup with dev reference 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: <20251109-netcons-retrigger-v3-4-1654c280bbe6@gmail.com> References: <20251109-netcons-retrigger-v3-0-1654c280bbe6@gmail.com> In-Reply-To: <20251109-netcons-retrigger-v3-0-1654c280bbe6@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=1762686373; l=2197; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=FIaU/PJYhFPVOHbBtyegMmwlEvrKVznPXH2gtLOtgG4=; b=jqGwvMXsnTh9gpF8WtcivNejALws/gY5MNBLZJyu5aLSo39/iLcPs/94CM5o+F+o51AXr06CO z7GYtxtPn5aC/n5whqJ3xdlIxlszErnaJM35XyWt8rFvodzV+oaW5Fn X-Developer-Key: i=asantostc@gmail.com; a=ed25519; pk=eWre+RwFHCxkiaQrZLsjC67mZ/pZnzSM/f7/+yFXY4Q= Introduce __netpoll_setup_hold() which wraps __netpoll_setup() and on success holds a reference to the device. This helper requires caller to already hold RNTL and should be paired with netpoll_cleanup to ensure proper handling of the reference. This helper is going to be used by netconsole to setup netpoll in response to a NETDEV_UP event. Since netconsole always perform cleanup using netpoll_cleanup, this will ensure that reference counting is correct and handled entirely inside netpoll. Signed-off-by: Andre Carvalho --- include/linux/netpoll.h | 1 + net/core/netpoll.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/netpoll.h b/include/linux/netpoll.h index f22eec466040..345e74112674 100644 --- a/include/linux/netpoll.h +++ b/include/linux/netpoll.h @@ -69,6 +69,7 @@ static inline void netpoll_poll_enable(struct net_device = *dev) { return; } =20 int netpoll_send_udp(struct netpoll *np, const char *msg, int len); int __netpoll_setup(struct netpoll *np, struct net_device *ndev); +int __netpoll_setup_hold(struct netpoll *np, struct net_device *ndev); int netpoll_setup(struct netpoll *np); void __netpoll_free(struct netpoll *np); void netpoll_cleanup(struct netpoll *np); diff --git a/net/core/netpoll.c b/net/core/netpoll.c index c85f740065fc..4d25ba422d81 100644 --- a/net/core/netpoll.c +++ b/net/core/netpoll.c @@ -605,6 +605,26 @@ int __netpoll_setup(struct netpoll *np, struct net_dev= ice *ndev) } EXPORT_SYMBOL_GPL(__netpoll_setup); =20 +/* + * Wrapper around __netpoll_setup that holds a reference to the device. + * The caller must pair this with netpoll_cleanup() to release the referen= ce. + */ +int __netpoll_setup_hold(struct netpoll *np, struct net_device *ndev) +{ + int err; + + ASSERT_RTNL(); + + err =3D __netpoll_setup(np, ndev); + if (err) + return err; + + netdev_hold(ndev, &np->dev_tracker, GFP_KERNEL); + + return 0; +} +EXPORT_SYMBOL_GPL(__netpoll_setup_hold); + /* * Returns a pointer to a string representation of the identifier used * to select the egress interface for the given netpoll instance. buf --=20 2.51.2 From nobody Sun Feb 8 02:08:28 2026 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 CB9242DECB4 for ; Sun, 9 Nov 2025 11:06:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762686385; cv=none; b=ocuLgc6rCW30wUsCFlIsdvJOe5wwreD7a6ODE005llFH93/wXQ6uSN3vwefvZi1x5cBqIHuSDOUQz7Kw2JzQ9/2ct9Ox4ZazOe4JZRBnaxzOL3acUEZEHOiXoh5U+gJug23N+keb84PiK+h5lmjDZsEcIB7yC3OY+SXpQ6PF1i0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762686385; c=relaxed/simple; bh=9cnt0djUO8JMRLcFmi+xdYZfECvsjjDzxRKEBkD5M50=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=sK80EUf8u5ai49qVuXONggfl95VnRiOSMGJuVonRjc+Ryhb1jYFZQeeWDOgDein1reL46qXE5c45LdtDK10oFlAnppdeBFdaWwQ0Ex62z2RSXt0oEWj7DVmHR1wLA2C0pJFzikLlzChqqM2g7mg1cTDTYdFgoYlyx9Z1fsHdP34= 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=agqh7DzN; arc=none smtp.client-ip=209.85.221.51 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="agqh7DzN" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-42b31c610fcso645874f8f.0 for ; Sun, 09 Nov 2025 03:06:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762686382; x=1763291182; 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=X2+JaghnusHQ5195f+mHqwHveTs9ZCK/yCVn0nawZBU=; b=agqh7DzNf9srld/vkBJxJL/rX1frVCUFny7EE6Uub1ugHqQL6jJWTiFXOg1b4Wo1cf uGoapt2PwntWpJDPiqwk9wfhsgqwgldfgO8IQlbp7LvrH20WewYMohw/t0ogASxtRKn2 pId8yunyhXUoKAmQj6SIALsPaOLpgzRka57UwjNsCjOUdBHxcihPnb1k/YOX6cr7TZYb aYajHIQIX6Vk4klFGfz0WSDRyPaDDBpubGmSNy4c0AO4qnreVWrZqbMotU5ir2QdZf8H S0P/+Pkm4v9CSZr2ybe2OTGU7utK/4UGkW/CX1/7qKXBF2aBld9Xz93ykL3ihJ7rI4qY FjBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762686382; x=1763291182; 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=X2+JaghnusHQ5195f+mHqwHveTs9ZCK/yCVn0nawZBU=; b=PzLN04PRbXeUFVrsw90eB++sStRQV9MEeqg3/aSmXBZaL72IFEjeTUeQK2OJ0j+TDv MzTjUiXy+oBM4RPHBltaCmscD+rWLAzqjtaQgjTubnqZNsHnFMncrt80DepReqJ2eGne xUX0/MVgg9MFAtZyjc7a+SYBtinZ1WihUYO4tb+GU7FGmAIYfdieKWuIBYAEVU7FbNP0 Zt9v6ElDJyEMUO/vJOERpVKLy14lifW7g4SOz/aDGh1D8ODPzAaS5F9rRA5bRLHuHJCI cWk6IQO6ZjcWETJbY/Ur7WY/lXhyXRBanZKm/yJSlDLWdB6/yGYZT2ypJ1c4BWIouO5/ XWSQ== X-Forwarded-Encrypted: i=1; AJvYcCWSeZ3f3cfqbOaa9DAdlADzde2ReNFo1VU2neHUoRqs6IjKMaMkx7fk3JL2CaWI7Agu755lEZ7ysvB45cM=@vger.kernel.org X-Gm-Message-State: AOJu0YwKSUjlRbSu/Q/KTVcdMRSjR+W1SNRcBteuR7ElYfLvv+DDtXuA cLSmdNG+uqV6giyA7jxwqgRAntN0XtB3Qtcfm8ZVCKnOBSxDjHwiTewl X-Gm-Gg: ASbGncuZiqz9em+ZvX1UCgEN4kGTz6nUbX6bbMxZ/YejBui29zn8WXJzHFos1GlmCHT jaYIh6J6juZLei6oG6UwMHOdMChUrNn2chyBEuMgCogCj6wuMLzQuM489wAMW4bHwDsnJ2vhA0F pC3i9BvaYz9UVyYbWP6BBTuz0oAuPGuYPzuzAOraGl3odUMbeckvJ2p7wZH4r8ST3HM2LUHlff2 8yhMNELhvbd1C0ZVEQbLGsRTQX62wdqGtFoaMXlPGQwoRcZrse8+KT/Ie1xqNMGNct5w8CAageS Ip/odpPz8SB1eXyKuksmFUr55LZGxzcJLPgP/Pnal2zf3GNWUOmFalUsSP3niwbU5MwAE3ciytP HuuvddzaKH2QHFc+KTKN1h8TyHvChgmCF+scujpRwwXiV2fSnKuYo7HRibhxViDvbEWFl4zAxl2 3W/gUU X-Google-Smtp-Source: AGHT+IE2l9dVnKOvGwUJcC3n+1EPzSK1kOENPu25VX1LP3N9NDrShgiRVJ9RZrWo8xw0UIcSYg6kCg== X-Received: by 2002:a05:6000:1acb:b0:42b:32a0:3484 with SMTP id ffacd0b85a97d-42b32a03626mr2142456f8f.45.1762686381898; Sun, 09 Nov 2025 03:06:21 -0800 (PST) Received: from [192.168.1.243] ([143.58.192.81]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42b316775f2sm6354925f8f.16.2025.11.09.03.06.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Nov 2025 03:06:21 -0800 (PST) From: Andre Carvalho Date: Sun, 09 Nov 2025 11:05:55 +0000 Subject: [PATCH net-next v3 5/6] 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: <20251109-netcons-retrigger-v3-5-1654c280bbe6@gmail.com> References: <20251109-netcons-retrigger-v3-0-1654c280bbe6@gmail.com> In-Reply-To: <20251109-netcons-retrigger-v3-0-1654c280bbe6@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=1762686373; l=4767; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=9cnt0djUO8JMRLcFmi+xdYZfECvsjjDzxRKEBkD5M50=; b=pNaI95w3bEi2PMT/QZLOFwdJ/5DWGD1iyWEpW6PUTOqocGVcermhyxdP5+sJcEKUBs7sJz9e4 SkbLdo7vxV0DLmYfGx+Nw/jCJDVilkf+tk9EAgMFTB8eY0EsnMiSSpr 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_UP event is received) by calling __netpoll_setup_hold 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 are candidates for resuming are removed from the target list and added to a temporarily list, as __netpoll_setup_hold might allocate. __netpoll_setup_hold assumes RTNL is held (which is guaranteed to be the case when handling the event) and holds a reference to the device in case of success. This reference will be removed upon target (or netconsole) removal by netpoll_cleanup. Target transitions to STATE_DISABLED in case of failures resuming it to avoid retrying the same target indefinitely. Signed-off-by: Andre Carvalho --- drivers/net/netconsole.c | 62 +++++++++++++++++++++++++++++++++++++++++++-= ---- 1 file changed, 56 insertions(+), 6 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 5a374e6d178d..50d6df101c20 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -135,10 +135,12 @@ 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 netpoll the latter is + * due to interface state changes and may recover automatically. * 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. @@ -1445,17 +1447,50 @@ static int prepare_extradata(struct netconsole_targ= et *nt) } #endif /* CONFIG_NETCONSOLE_DYNAMIC */ =20 +/* Attempts to resume logging to a deactivated target. */ +static void maybe_resume_target(struct netconsole_target *nt, + struct net_device *ndev) +{ + int ret; + + ret =3D __netpoll_setup_hold(&nt->np, ndev); + if (ret) { + /* netpoll fails setup once, do not try again. */ + nt->state =3D STATE_DISABLED; + } else { + nt->state =3D STATE_ENABLED; + pr_info("network logging resumed on interface %s\n", + nt->np.dev_name); + } +} + +/* 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); +} + +/* Checks if a target matches a device. */ +static bool target_match(struct netconsole_target *nt, struct net_device *= ndev) +{ + 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); +} + /* Handle network interface device notifications */ 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; + LIST_HEAD(resume_list); 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_UP)) goto done; =20 mutex_lock(&target_cleanup_list_lock); @@ -1475,11 +1510,26 @@ static int netconsole_netdev_event(struct notifier_= block *this, stopped =3D true; } } + if (nt->state =3D=3D STATE_DEACTIVATED && event =3D=3D NETDEV_UP && + target_match(nt, dev)) + list_move(&nt->list, &resume_list); netconsole_target_put(nt); } spin_unlock_irqrestore(&target_list_lock, flags); mutex_unlock(&target_cleanup_list_lock); =20 + list_for_each_entry_safe(nt, tmp, &resume_list, list) { + maybe_resume_target(nt, dev); + + /* 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_move(&nt->list, &target_list); + spin_unlock_irqrestore(&target_list_lock, flags); + } + if (stopped) { const char *msg =3D "had an event"; =20 --=20 2.51.2 From nobody Sun Feb 8 02:08:28 2026 Received: from mail-wr1-f51.google.com (mail-wr1-f51.google.com [209.85.221.51]) (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 5881F2DFF18 for ; Sun, 9 Nov 2025 11:06:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.51 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762686387; cv=none; b=XS4csLDA/rvwpr4+y2pi64F5s8HPlEJL9IFFYYHdTUdoh2hv7nlF9wh3mLdyNXxJxjv+H3XIjVwKELIKan1WhRW92HeygRgYgbeVA5EvW1T+1wRSqKckEsbpVSHSdrC+C/lGDDPlvElPxz8tg+AF5itkYgwsmX9NjQL3FedezDM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762686387; c=relaxed/simple; bh=UvRQaBE+xBWDjEoTvma8nwauXFhwx/8Rb4iPAQ5Y+mI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=XSaiNnyH+eaejtj5eSGgYUUlD3yYwvtyjw4hkMZkHXobF9Upr0kC8lHbks3kXALBHAzgc9+n1tzMYnDsTt9wQOEncJKuqDo2yNrDsnZ4U8lJqrbWAmUK63aM59YiSl1Q4Wkx9AqaHLo52HzN/7MdgfmKhJSPEq3k4VlMmFnPEAo= 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=RhfXtBun; arc=none smtp.client-ip=209.85.221.51 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="RhfXtBun" Received: by mail-wr1-f51.google.com with SMTP id ffacd0b85a97d-429b895458cso1011217f8f.1 for ; Sun, 09 Nov 2025 03:06:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762686384; x=1763291184; 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=e+hYRYhUCbZd/x0skNNMpBqkY/5tBkO38vfAM3Du2Qw=; b=RhfXtBun2NIt/w9RhohkzRGSorw8FN5Hi9T9CGuwhB0pLKA5wMtwygaHD2YE4iVm4p 9bnLXueZvBF358A2rGdMbTpyvbuWfFbhZfEGKRtryWF3qnslTvKc0KZHdpa5cai+IcOX GsztNZLvGjBV1dp9clbjeBLv6juB/vlBF1pjfJhR3Q18hL8fBvKLBDyk8neU6pXDC3LY dUgQ/voCzbRzqe+g+1TU2gSSoYMPBrtwUZmwNglWjC01e/uiVVtFRbZVUl7Gcq9fTcnV JVFNqYbhGkGSGhBdZAJmIwzmqqYySU9O8pufu0RqVS85Pt68ysDhIs8c3ptX0TpyrqVh dfIA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762686384; x=1763291184; 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=e+hYRYhUCbZd/x0skNNMpBqkY/5tBkO38vfAM3Du2Qw=; b=MLelty/pH08hiUNbHQKrv+2NN83stVVZeChH3CUVeab6/ggqueSaNGIZjUwIthJAWj wB6HSL79OJ9Q9zoIs1hIdmNb4Ig/yIUOOBQ/yYNghAuPI93uHEI0dpwpopzIzyz+CUuq rHOzF3jromLUnJjz1TDMwSPD4LCJTLWAbcWMUGdnPPpbeY+5/XJtfnne84X09X/PVdta h4ZUGDhF7yag2KjL59mC6dAPCOhqCo5buy+LhM3LhuT19WYgMoXSucxQ1l4/RfC5II6W iKUTwxLWTDvYxsZce6/Kdu0Sw0gayE/299N4z5HUumeIdKTUSypE0mg6Acij4NlDnonA /UhQ== X-Forwarded-Encrypted: i=1; AJvYcCXXWJv+1lFHic//0wIxJJ0fl1+yHiyeQrIUSgCml1sEMmCXEwCb5FyffiVCvyZ89XV2zLjU14cghtxm5MU=@vger.kernel.org X-Gm-Message-State: AOJu0YxKJ1KSOIx0g++PCgm99ArTwTtUU3BXAIzkCuSdtS5nmQ1Vvs9M XrZ+QZ4PmMlhVhLskY2xmHuLnW3bcTG5qf33UuTlpb6IZuYDPePa59gX X-Gm-Gg: ASbGnct5OvATCeGrOvqod2G7mfCEduqHW/RFzfdTsL+1QNn8VUS2FHeKjJgk9anPPuy kE6utD0F2rGdOi/hHm1lx2Dn0fe+PFkUYadfiNV/pC5ZzwG+bMvVDF0qI1Irysa8MYDP4dCf5xK 8xDUO4z6lYu2Y0EyWGIkIefYBswJ3AX2h7WmoXEJgJS6fZrnEpTFBT0jz3VRfHmFlhJM+3SImpy JsYh9SMFMwt7sVOqQx/ir6dwkGkw5JFp2FyzrseTJIJyH1muTvxWPpktDa9K1fYIQ9W6hW0b36p 9yj+Ai5ju5vfRfcOSJ47zl2ak+BwDcLKMw0KU+XAof/o4Ux2vht36tVitttBT8jn8DfkM/Ktj3p b2uB/LcIYcAx5t6H0Bmd4lm/qXgac3n2TJ1r1WMmdCVqUz8uF51G7TGm5VH1woA/9+PSzQOaG20 jBhamgLQ60oK6IcbQ= X-Google-Smtp-Source: AGHT+IH92q5QOXzI4WZ4CJLmbmLqEP8LnnpB979AA8pp1DpotusvDsiCb5AlA0AXesNOD4EDvj76Ww== X-Received: by 2002:a05:6000:2313:b0:42b:30f9:79b6 with SMTP id ffacd0b85a97d-42b30f97cabmr2472285f8f.58.1762686383589; Sun, 09 Nov 2025 03:06:23 -0800 (PST) Received: from [192.168.1.243] ([143.58.192.81]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-42b316775f2sm6354925f8f.16.2025.11.09.03.06.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 09 Nov 2025 03:06:22 -0800 (PST) From: Andre Carvalho Date: Sun, 09 Nov 2025 11:05:56 +0000 Subject: [PATCH net-next v3 6/6] 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: <20251109-netcons-retrigger-v3-6-1654c280bbe6@gmail.com> References: <20251109-netcons-retrigger-v3-0-1654c280bbe6@gmail.com> In-Reply-To: <20251109-netcons-retrigger-v3-0-1654c280bbe6@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=1762686373; l=6066; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=UvRQaBE+xBWDjEoTvma8nwauXFhwx/8Rb4iPAQ5Y+mI=; b=Eb0IHEBBAkQPP9Q1S+7s8n9lVkGxOwxJABGurHAOtNTpg37S2wv8wVq4+JLgHqVDrahkZ9cp0 wu2PefKD3ZsCc7ly9N818FVmcPMlbA8hZoJcWoLoiF3N0WEZ9aPHkZp 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. Signed-off-by: Andre Carvalho --- tools/testing/selftests/drivers/net/Makefile | 1 + .../selftests/drivers/net/lib/sh/lib_netcons.sh | 30 ++++++- .../selftests/drivers/net/netcons_resume.sh | 92 ++++++++++++++++++= ++++ 3 files changed, 120 insertions(+), 3 deletions(-) diff --git a/tools/testing/selftests/drivers/net/Makefile b/tools/testing/s= elftests/drivers/net/Makefile index 68e0bb603a9d..fbd81bec66cd 100644 --- a/tools/testing/selftests/drivers/net/Makefile +++ b/tools/testing/selftests/drivers/net/Makefile @@ -17,6 +17,7 @@ TEST_PROGS :=3D \ netcons_cmdline.sh \ netcons_fragmented_msg.sh \ netcons_overflow.sh \ + netcons_resume.sh \ netcons_sysdata.sh \ netpoll_basic.py \ ping.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 8e1085e89647..88b4bdfa84cf 100644 --- a/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh +++ b/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh @@ -186,12 +186,13 @@ function do_cleanup() { } =20 function cleanup() { + local TARGETPATH=3D${1:-${NETCONS_PATH}} # delete netconsole dynamic reconfiguration - echo 0 > "${NETCONS_PATH}"/enabled + echo 0 > "${TARGETPATH}"/enabled # Remove all the keys that got created during the selftest - find "${NETCONS_PATH}/userdata/" -mindepth 1 -type d -delete + find "${TARGETPATH}/userdata/" -mindepth 1 -type d -delete # Remove the configfs entry - rmdir "${NETCONS_PATH}" + rmdir "${TARGETPATH}" =20 do_cleanup } @@ -350,6 +351,29 @@ function check_netconsole_module() { fi } =20 +function wait_target_state() { + local TARGET=3D${1} + local STATE=3D${2} + local FILE=3D"${NETCONS_CONFIGFS}"/"${TARGET}"/"enabled" + + if [ "${STATE}" =3D=3D "enabled" ] + then + ENABLED=3D1 + else + ENABLED=3D0 + fi + + if [ ! -f "$FILE" ]; then + echo "FAIL: Target does not exist." >&2 + exit "${ksft_fail}" + fi + + slowwait 2 sh -c "test -n \"\$(grep \"${ENABLED}\" \"${FILE}\")\"" || { + 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..404df7abef1b --- /dev/null +++ b/tools/testing/selftests/drivers/net/netcons_resume.sh @@ -0,0 +1,92 @@ +#!/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 + +modprobe netdevsim 2> /dev/null || true +rmmod netconsole 2> /dev/null || true + +check_netconsole_module + +# 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 + trap do_cleanup EXIT + + # 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" + trap 'cleanup "${NETCONS_CONFIGFS}"/cmdline0' EXIT + + # Target should be enabled + wait_target_state "cmdline0" "enabled" + + # Remove low level module + rmmod netdevsim + # Target should be disabled + wait_target_state "cmdline0" "disabled" + + # Add back low level module + modprobe netdevsim + # Recreate namespace and two interfaces + set_network + # Target should be enabled again + 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 "${NETCONS_CONFIGFS}/cmdline0" + rmmod netconsole + trap - EXIT + + echo "${BINDMODE} : Test passed" >&2 +done + +exit "${ksft_pass}" --=20 2.51.2