From nobody Thu Jan 8 00:13:53 2026 Received: from mail-dl1-f53.google.com (mail-dl1-f53.google.com [74.125.82.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 3243D30FC2A for ; Sun, 4 Jan 2026 18:41:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767552104; cv=none; b=ZfOHbU1pug1dpULPAFR0acLtYsC7k3oioLiuPPyUfqHPkuV7qnSUbS/L5q8ktDGymO083+OGTdIp/EdcFclRsFyzPCF1XF+q9d22fCiFG1e4N9mt/IHdRhY78nXDRqZ/HwIJ+O5Fgoa8LGkgA6FUNTT8J6QoCY+3ls2qLxfGj1o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767552104; c=relaxed/simple; bh=xTW7lVbfJsgnlziO9m7HRTBaTgvYhjTEK5XGbQnoB3Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GnNAMktZTJUE2ndipdDiI6UWbwV4IWrPJSsSy+Nfu0A0W01JEOUAdyC07IwaqUIo4Uz+rTTBHF0IBjlkdMGEkbsWrzLq0RQIsXnuVKaeedZGPNBFVomoZTfNmeMBVU85+fWdw+a+wX7PNeYRFbmsNN9IcyRSL+3UwdaVuJMZYbk= 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=EFs6Qzgh; arc=none smtp.client-ip=74.125.82.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="EFs6Qzgh" Received: by mail-dl1-f53.google.com with SMTP id a92af1059eb24-11beb0a7bd6so1563393c88.1 for ; Sun, 04 Jan 2026 10:41:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767552101; x=1768156901; 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=EFs6Qzghey7xQ6Fcur0QLwvI940WJB8GnGr2SNvRWe39WZsSBZRiAl9SmSMEQkR+GQ 70BZndiK56RDqkzGfMIUraEGzKAr4MdJjXOzpct3kVrPq9aj1LwXU/inH9NqI4o28FGC 4dPjNRt4sP9HCT8eCJgcOTQ7wJdalG7Sq4UWPzJMX4K7KBSQb0Ed4lxRRDgliGHHdONn Ydv5NqPb58INBhoP98o2ja+AGm8HN9rcz+Og2TgklpV45Nb/G+BI9q8nOS37EV96apX+ iKUfeHAQJs0XcO9ZsPxnqK4BlRsLGDMzqtO0VTPanIm+OyzHrTs54Fm9MANeXxkcB1j4 mcfQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767552101; x=1768156901; 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=FJdyxmVa6hAOeGPjsKT0RhxikAicBrH/8FqCmgt8S4wmeU32h0gxs1zWju5wfwDSvz Hv/mzH3uhtKx3JLxf9iZs6bb5iZ7rGntQC+l1FC7vXQwtlR6owTj2E+O2QiCkfmjIW3t tkslq7lTozu7M2al8wncFgKB6Ss4VQvvToBhwnbaaIX2U02WUq6susNT9dAiSwOFM1iD 69iQEMSF/7FLewMK1LdVskAmwWZL6jfbDZV2D1c63sVqK4Uj4paQqqH97Zo5u4h+tJI6 YD4M6D6Ek7Ma5OY4jj7VBbHNDAcSW6f8vKqC+FtbjSWxM+5FeaVN7fxgk8HIOyspbbeo d9qg== X-Forwarded-Encrypted: i=1; AJvYcCUX3v3yV0cAN7tRWvk/n1UUaw6jLsUYTwTJQOuZkCdbl0CTOoiY2uj5KQ2oyO7PPMECTWvSVga76DaT+To=@vger.kernel.org X-Gm-Message-State: AOJu0YzRLsP3RkWowxpOwVMGBxDP3CNllp6MvtE/XKlYqf7sVKGeU8MC QrV/8W9tpaIHRbtoM9dG1OSthtfMWHY3k5OBfn6+p6izf7lFv9edSCZO X-Gm-Gg: AY/fxX52JckoD3ah33ThwoCwLujpbmNrnWh19O8QpSVfZ5hWLMly2GLmeQt9g5AaHkE xCVWQpVM4kEvF7mgDYa4/6HuuPY1sHpUJGws49Jb44E15NTuRvf3uLKx2xsJuSTw5oMgwCNfU/u OMsZBb3VjtfAVTjlbjyHtdx/WcQAVD2l8jFPJuQ20g5Fy7d+Dy3DT8J9CKynB4mZBSx+NCynCFf YXQGyh6/CKNzNi5kdZ84FWJ0DLlo7kQ/j+cwfUQ1a1r7Pf8YGXHsesml5l4EcbZVN4J8UDrWk/P 0pycOmduPJNPDWmFEBQ0Zzbs/ingvDVLQ+S9ODNoQiQyoSBipQfqeEZOYzeAb22xAauSVbmBVvo n+oNbsZVb5F1lYZVFe17ajXgFxNPyaWwe3yMeJ6/de9FpeZ+wZAyR0aUm97KjUCYS7cZCP5ldzs cRuViERegMUrdQWAv+ X-Google-Smtp-Source: AGHT+IEkrerLkA/4ixjyUlfOE1XXFSRLs3hEvRo2xtxXa3LLm+JllqO1Z2sjIR8HVARMLkkwliMMxg== X-Received: by 2002:a05:7022:4589:b0:11e:3e9:3e91 with SMTP id a92af1059eb24-121d80da9a4mr5164433c88.26.1767552101038; Sun, 04 Jan 2026 10:41:41 -0800 (PST) Received: from [192.168.15.94] ([179.181.255.35]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1217254c734sm170975553c88.13.2026.01.04.10.41.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jan 2026 10:41:40 -0800 (PST) From: Andre Carvalho Date: Sun, 04 Jan 2026 18:41:11 +0000 Subject: [PATCH net-next v9 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: <20260104-netcons-retrigger-v9-1-38aa643d2283@gmail.com> References: <20260104-netcons-retrigger-v9-0-38aa643d2283@gmail.com> In-Reply-To: <20260104-netcons-retrigger-v9-0-38aa643d2283@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=1767552086; l=747; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=BLduFEel2At1ZpRoHzUB/43M6t0wpDLHJLh+eokOBeA=; b=16wxTenr+y86Rt/Ag3RI3x399WrHWTY/kIyhlsFlYOMk5zACPlbx+jeBwuMORyjOODyzqYAE4 84+KGlB10dsDrvpVh1t3elftkyBxiXuobe8zN7mpmcowQZ0MWrnvM+N 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 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 Thu Jan 8 00:13:53 2026 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 559DE2848BE for ; Sun, 4 Jan 2026 18:41:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767552111; cv=none; b=m+ruCCZpnRxMwR6KP/rS6jjVQRd4xZtKHjGFO5OrHiijSdvSaNkTDpwTQT+3itON374t9LJJesasRHMJCYBagtMQIDwjHhvONd65JvCdLRYz0BOqhYN0esEdrOmVf66UkGlnXiaRmxaOhyJIPGKXs3fDXTOIXTj3iaZRI4LJZSQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767552111; c=relaxed/simple; bh=ptkTe+cYKKYMyCNyu+hE6VVzhConXnPLG7fL2BaD9jQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IxDoi5/x+y2LXvDhFzvzTqcZlShbxz6Hg/FXvPyDrvESi/RY8hUsPHQbF0ra2JAa7tMY14ddQRm/3PQOnDMAMQ/Ust6PrWLWdpKczkhDBhIfmGh9N82F7/qt0TSB2GOlWPAWNAZH6CivavRAZ/MS2LUTtEcEtCiR6/qzk3D6wLc= 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=nKXWqbD9; arc=none smtp.client-ip=209.85.214.178 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="nKXWqbD9" Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-2a09757004cso169887025ad.3 for ; Sun, 04 Jan 2026 10:41:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767552108; x=1768156908; 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=nKXWqbD94BMqeS6Lss1jvxhGjc/1ETi6piBtQWfElFYVOMIHli48EtS0UOD+DOjZto Pf2r8PuFvGbupMDso+P/dSr49EKXst5VygAgbWhFlyDBet4eCqDHMpBWOwUEGfD0FEsY 29wLbr260PAVm6nq+vyC8P4G5PCkXyk+D4uUYl415ObM4nA8pI4oIIbsUE5RH1nvxkIz lKBouysm8L/dYx/v26xkfKc4xuExnbT6i5eXJ2lDRuEkl7u7tZhg8lYSdiN5rZzuWcbk LFbs3ak69/2FXg0/Mphvy+1+pwQoAT6vhxMDJnth8zJ7yX9WMO7VxwDfctgOj6Wyv1ki FvrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767552108; x=1768156908; 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=XEtFAujv+5/EpLZAPx/ya8rxOICm4d4NABgZk/x0ZD02f7OeOfIZO2M9/QAU5ddYkC mFQdIMfvxhhbJiLVxToOcXl9dG9ovcYSkYDJPtbBKr/MJhB7PUFt9Cd6CK+rHz/aDbhS 40/2K2q7Canymvq3K1k2kG2Sym4UQnbkPYzvBlSRKkxPegE1xgO4PlwSI+RjEUhP0gcZ iI8sehRzGth0GYC3Tpng7IcyA3rWhtg5mT/+SLUCLzgyFSR2f6UrIw9jDrFqmkQdXWbt L43OsE87LoS+fC00gvyuaXFDKvFfdv+HKvwUyzytkKJbKT7xwAuLIdgBVjMOcHqQd0uo UTsQ== X-Forwarded-Encrypted: i=1; AJvYcCVOcwfWya+DL7G5r9VXFiXP+5ryeY5grdtjPckWmq+t1mCNQMQ3h22x4gUWgV41erOPQNoAOTSVyiz/go8=@vger.kernel.org X-Gm-Message-State: AOJu0Yyz48v1JHDgyKiPCxqiLED1SkGrOfBTDa7bnQgnzgaj+HSQFU0k uuybI7xfawjijQ+0rwWP51XR4+oSxFzSnf6/6QbhsJTvz2q1NfyKchLF X-Gm-Gg: AY/fxX5ituaMFMf+OxtSlUmhFmqj5Cw+V53y8bvB8PKvDgB3Gve50lGS5Fw257WFg5y 2G6dwST9cz+pyMzBSv/TyimaTgbn2XY7dACzUAOUMjx1ssWN2bpPBX1duj3aRu1KnGt4ZvIUiZ/ JpFHbM7mIbx/plJ7DZ00aO0oRH6ePlvsVkOubUyO8JxE2Eqf83ZIUGJdd9nNkCYL+L7xFCT35g+ MNavRGFeexmsDxT6VajV2c5DrfYAL343Epo3ODofjMRj3SEMexbbleFAgQ3eYjvwpuHhb33HuLA FQL5XXxvWkHJ6KEXgmnKWuOLwVll8aIAtxyoVLLwUsH7wKWDGb5sk2MS8ES67r1esv1KthzUXzN nOokbtLyYyqx+zpd2rdDHdh6sZVCaU5RBOCSUSjzxebOh4a56+GzpJL1ac/QYQ5k+HyWD2G5LiM PQ3pYVwvIgsBjOcV4U X-Google-Smtp-Source: AGHT+IHdUEJsTG/UrAL6MmlJo25SvRp6Mo+4LEbJxkUmHg7eX0xVPdbQb18yA46SWxrsvVBwDIDCxA== X-Received: by 2002:a05:7022:910:b0:11b:82b8:40ae with SMTP id a92af1059eb24-121722b5005mr40323883c88.18.1767552108263; Sun, 04 Jan 2026 10:41:48 -0800 (PST) Received: from [192.168.15.94] ([179.181.255.35]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1217254c734sm170975553c88.13.2026.01.04.10.41.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jan 2026 10:41:47 -0800 (PST) From: Andre Carvalho Date: Sun, 04 Jan 2026 18:41:12 +0000 Subject: [PATCH net-next v9 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: <20260104-netcons-retrigger-v9-2-38aa643d2283@gmail.com> References: <20260104-netcons-retrigger-v9-0-38aa643d2283@gmail.com> In-Reply-To: <20260104-netcons-retrigger-v9-0-38aa643d2283@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=1767552086; l=8948; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=ptkTe+cYKKYMyCNyu+hE6VVzhConXnPLG7fL2BaD9jQ=; b=d5eyZpJDzq8vHKwVepc4DHhoMhYmLnIbooQK58MeiAippIYEVKH6pgrOvzGqukKC/xiXJMImh sxzrxhkAs3iAMu1FQFO/ChRCXUZZTGzSM8j7e/Pq8q7hsQCUQLHWU4j 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 --- 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 Thu Jan 8 00:13:53 2026 Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 213012737F6 for ; Sun, 4 Jan 2026 18:41:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767552116; cv=none; b=fPZcZspsKPJQeY7SluBL6ibiIbsSdmbtYtzI/FHKHcHB+bjQIS6618nS9yg4yNivBaocCAHC/6mNlBAbpfImi7S7/1acjWPq8e1+ERrHO1nPUKzobiTPsV7yE6lY6WMhemqtZRtZnzB6Vnb9Yhk62xmV0HzGFdWevWY9dFYHYrY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767552116; c=relaxed/simple; bh=oZlSrKc5HSf8OTgk8Y9zCO1ND/6B7m7anVTBiZTQDCE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=JP5vx1ug/BvgdCIaKdeRH1TYg8wiMXBKqsii/+Ur8rAaEdIIuMTN7RMUbcKcL8W3Mm4lyksreDdvkK6wW+hhFFw8HAr5eiZSpO2bxJ3fpXOAKBcmtwXKWYLwsMurWByItrAHO7jwFJIp9XFDaTejMi2QIJmqb7yolfMGGeRm6k4= 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=jtckQmtq; arc=none smtp.client-ip=209.85.214.169 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="jtckQmtq" Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-2a0d52768ccso166613445ad.1 for ; Sun, 04 Jan 2026 10:41:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767552113; x=1768156913; 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=jtckQmtq+Z0flE/4z9TctNvX9W9LWLunJWaNZjTtukk+oNHZfnwiUiDy8aFq1Lodin abW8vXQwIBx/6IFCeqO73GdkEWfdna1tto32eniSu50sS3b3UG/+bARuvPrCeoWFEZIZ /TByR3xbQvRIbejFJ734q5VpyY+OLVgGK72IXQYHNJOKfF61THsLN2RCJwwX4+oLqidD 5lqU76x4TVbqVhAtH9j1CIpY5IfdSkzeVpvrkE9GIWmyKvkFXotcyeJUolpdNwPSndDf qozu1y5wZtwQ0JYZXVJjVGRNwzoQNO9Ht3FkmSQAB1sIvUM289+WrPKr9ikvapI0GXiN uRFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767552113; x=1768156913; 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=Fef4lA0L7wSKG9JfHQYe5n1oKx1KREQ80jM9rb8B7HEAITaiCPZdh8cehpP/NYTIfV Oa2iT4Q4m+RJrB4tztksZ2YqNz5r646WQXEyO3rtgv0g7j/sZX+J9xxxguYx/yRYWWix 2wNcWWkV90UO1pPSfrWuT9fnD4ga11/fEGOyEdvZ2CjqboHE6XnD+ZBz0XgacFMf2XQm RWSU8fYsuIrJ+ejYnlm1L+WTpMc43hZz8YI3sAZ/65VtLxSJ3C6W3NnfX6FLlpwf/iEN ag6ZXLgqwTQjY+ZpJUM1b21ZtkDY6TQUEyNnbRFpVY0gjTGzlSzVCQBx814+DOfVfCJb yp1w== X-Forwarded-Encrypted: i=1; AJvYcCXjo8p+fAXP6lRVOprRZGYNIJA990d6VqrpZhVSfp+K8qGOqQ3LFDqKk85HJbwqokocbfAPAEzNyoEImds=@vger.kernel.org X-Gm-Message-State: AOJu0YzCm+N4yjE+dsIm1N1kVzvW+bPcYn6P6/avr3/PvYMyK96tbHOV JJ6+27ZW8hA2NiVdp8K82kNjfpWmR/yBFOEarUCoDtMLO02nYsesTifxqli+HFeg X-Gm-Gg: AY/fxX4GNbvPB73cIUneuyd50/h2avvH4Pkb3c6ou8t3K0yzytle1BErUFYyTKW/rEF zpPZJe8Jy6D66EXa3lk7hqXB5FaBy6R9nWw7F52eVnHG0n3+mi9zeBag9r73hSlwZRKekIpnt2Z 6qMwopOy2h2g5QL1qHrnJKC4phpW0InNPWZPMiHBDzdpEeBjes8xJ/DzzgBxipEPjQaoJUERLy5 w+8KrSXcJWMr7YxtSW4JGn8t92uXehJOpz29dnJjJDbye4yEU/cODvaqO00c13g6J8A5WX9pTMq +KLDoktuPt7pcNYsJwokQkhDskh79eAzUyAThv4Ihh7vPKhx7/6dh9adoN/nAKVuBG7QuRrmkWY YqHrkucbU9jzIMsdHQcHtzZUG/3NjR2PGY3duU4EKyObYNt/eve2zj955VHBKm/QRhSKZxyMP6P TZFhHUyH6gc3x9hNa+ X-Google-Smtp-Source: AGHT+IEQqPsuEeqSwJnEmQG6HRSkHTjK4rOFxwa+Org4QKZJRNkBh+LEQ9iqbFn0O6b3i5bQUEEUxw== X-Received: by 2002:a05:7022:f307:b0:11d:ef84:6cff with SMTP id a92af1059eb24-12172308947mr41968866c88.37.1767552113327; Sun, 04 Jan 2026 10:41:53 -0800 (PST) Received: from [192.168.15.94] ([179.181.255.35]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1217254c734sm170975553c88.13.2026.01.04.10.41.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jan 2026 10:41:52 -0800 (PST) From: Andre Carvalho Date: Sun, 04 Jan 2026 18:41:13 +0000 Subject: [PATCH net-next v9 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: <20260104-netcons-retrigger-v9-3-38aa643d2283@gmail.com> References: <20260104-netcons-retrigger-v9-0-38aa643d2283@gmail.com> In-Reply-To: <20260104-netcons-retrigger-v9-0-38aa643d2283@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=1767552086; l=2409; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=Bc0ee9DYK1oiSRrahxYGeDv2Y4gYudwUsG3FQq7nt2Y=; b=9BWcXu9Fg7r9j3L7E5V0TBCP14D0o6QF69OAWDX50MoYWCkS/CfIzLkCaOhni/6GXsEDKlWxP g+k4/TDEhnfCR/UNaLWnaqv7wSY6dpVpZqpB15KHJCnGq5BdslcaI/M 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 --- 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 Thu Jan 8 00:13:53 2026 Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) (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 8441C1DEFE8 for ; Sun, 4 Jan 2026 18:42:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767552122; cv=none; b=J22awMavAmdADDOtzAKwpqMGCXp0s7rZ1hl+L79hdAs5Z9QfgVKXo1VVzMpdWQc+292fGyk/vnsZy46lS09uBTxBQS/XOTYF6XKCUa6IC/oanc8DCRSpnt6Wof6au+N1YgOJS9751VmhvyNZcUmonCyA7opENwDRa3GRK/ss33s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767552122; c=relaxed/simple; bh=2IR9K9fFwUyb3vK1T1dQvAvM/jN1tGrfN72mQMj/cpo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=NDoFdCpC44zPAgUU7Cw1E67M75JgbAamAG15Lb01XNEGnvls9cQamolI/Rn6EG4rKMU8/x8uSCsso8rYua4sIi4antxjqDLhcQwTUT2Znrf+k2r4qPVjHm3pSxwph/fIpJTQIParTgHiaomCsS28eCa7Ejhs9mQE6e5ENKfvn7w= 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=jHXbcN5B; arc=none smtp.client-ip=209.85.210.181 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="jHXbcN5B" Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-7b9387df58cso21547085b3a.3 for ; Sun, 04 Jan 2026 10:42:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767552121; x=1768156921; 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=jHXbcN5BfSHJn4YS2srysffTX6KMaF/yndSGIRWKdjzIbxTbFSnYtpmOdWdjjrQAgs SIlhy/0CJq4syO8pdMKtVPi+RezG8PHvxpkgVElsRsLR289Qe5fYO0JpaJJ6X/2KuPxG xxpKJyCNL9fG7vCU2/YBYyU/cPtcp0tEHq45tRYgd/bT0WSxfV+vILlrjhV1/9DXGaZu B8axy1cRtRA2G4B/I7yyH9ra7UXj+jNfglKNAjpUi4uBfdBERd3SG2w4c0Vfem82Wwt7 ONBIfSlgGUYugZUq1s8SZLs9htaa1ODiZmoPHQDr2K1+1lEjxxolCRW7jO8oCVbBT1Qw qERA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767552121; x=1768156921; 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=p0KQhi9aMpN1lUXO0YHj29aKcYRkFbMg418LbcMdk7ULUuT/diy0GsT9+KGKmGn1qe 7j17/PUBMbg7bo2SgFLPbuanXVG1EejMF8sz4BvilCDJk5LyQghugnT9NFtsVSe3oeW7 2WME1q91RIVynAKFK5njxAIDI5Lux/PB5s8L/QgJbzwlpvxxLJ1X++in/v4h+K+3WGvU N8yEij4XQ4PxWtFnUnRhdIANa0qzcAfmCtuYSH+TO5ZniEBV8qDEW9iV+NITLn9orLxd DeRQX0D6UsYMmYIV192kIBSc5vPmUHtsMAaifMm8OTWT8FF4OiWMjEnlL1HSQrZaKh6N v3eQ== X-Forwarded-Encrypted: i=1; AJvYcCVDHAEmHdilElbwBjE8T/gdIX0XLBZyJUB842TjLJYa95czcvoSn8cx8SYQXAUver5vgdtXNP9JydsDExg=@vger.kernel.org X-Gm-Message-State: AOJu0Yy6I38mdNvL96nKQbBGExEKVTQ8928utI2PPFi0f/z44Rng4jsR n8rSY527Tv6CTEddeql4BhOqXlQeZFpcXSKU2eqsYNwaYWdo+xGQZ14i X-Gm-Gg: AY/fxX4ugrTipETMJOwXhe6Mexpfwpj30SD/WCM8wm0XK+Kpace+0xTuFHPAOVyRWhX HFr0CIDoQHXey4nxDEnYpVXm8tHVctgyo38k44HTAkU5Wi82YoHR3N+S81NHZotMSrL9gE0NXQU xSThOgfx1kbK26Lhaz6kJ/H6dSduRPImNRpKaZ8QLDrU3Bd3KCfL1CMrX2xpF32sbWmYE/66xQx tBAwtNpOF4D2FFEKVIjP7taPVYa5FaKkgPinAQFVxIcaTRFVFE+WfJ3xa+yizFIKfWvxp2rOvX7 2kBCaTfRXgR6fw/WjNCBPAsYCDtLO4oxcC/sriL/3D+nvitNSWHDbwRUsoYYsDeCJiQx0apjmit NaZp1FC4MHla8NdesWvD/fNtvK8ISoWwSTo05vtCfOCsaZ8AuMxXhhC0NFdzjZMA/+y6gYHWgis pbAn29k+beel42IILl X-Google-Smtp-Source: AGHT+IFgDO13laBgR4LGNEYbaTLIFrlJZEzUic2bWc2F0XYpOVbwq5tHYtyBT4UbpixuVU/XuYD9zg== X-Received: by 2002:a05:701b:208a:b0:11d:f81b:b212 with SMTP id a92af1059eb24-121722b27edmr35673494c88.17.1767552120496; Sun, 04 Jan 2026 10:42:00 -0800 (PST) Received: from [192.168.15.94] ([179.181.255.35]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1217254c734sm170975553c88.13.2026.01.04.10.41.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jan 2026 10:41:59 -0800 (PST) From: Andre Carvalho Date: Sun, 04 Jan 2026 18:41:14 +0000 Subject: [PATCH net-next v9 4/6] 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: <20260104-netcons-retrigger-v9-4-38aa643d2283@gmail.com> References: <20260104-netcons-retrigger-v9-0-38aa643d2283@gmail.com> In-Reply-To: <20260104-netcons-retrigger-v9-0-38aa643d2283@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=1767552086; l=1518; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=2IR9K9fFwUyb3vK1T1dQvAvM/jN1tGrfN72mQMj/cpo=; b=HHavGEkPJ8xbid2UCwSa5wsmGmUarwYg/Ad0iqOlkjCOIfK6OXlsEqlCquKnMu2uLZkvF5k82 KjqfTUYkqz6DFl0o+9FlBaLmWTrXO83gFkEGDI5/Lfde1OTihiC74hS 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 --- 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 Thu Jan 8 00:13:53 2026 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) (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 5A9B0288C86 for ; Sun, 4 Jan 2026 18:42:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767552130; cv=none; b=OD3rZVDsZvBDNH8L44eBMZfQhRR3GHudxdlQroAlPoNzNYCCZTXESF0j1OFvxerZ4n6G3QVkoWxj7obbquSfFM+BEGcs2ILVMlR/uIhcaa1IS9m1qqundD+peby5kaBrlQPljNgG8KoPfNb7ZaKG8gCK9rfpP/spRUDl8YEFyxE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767552130; c=relaxed/simple; bh=Rne9OenFktgXKd2Im5X8TmkYvMetTiWE8HD7UVp+a2Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gSMr5PDBX+LM5Kn9/7EdqEc11DOS4rnPsq/KMwV4Or0zUPltEI6HIjYJpW+1Wk7I1/mkgpHV/Q+CX4vQIP7KG7EGlI6uije7hMWbKpxaFOBZwp3zXxyiD3MY4rmPpIwpJQ1KB9dOzbLL+9nDdEkwhcWVghzFeYXluG/6NAMgNqQ= 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=PD4H8B+x; arc=none smtp.client-ip=209.85.214.172 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="PD4H8B+x" Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-2a099233e8dso112601135ad.3 for ; Sun, 04 Jan 2026 10:42:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767552126; x=1768156926; 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=yMN7Y5N+F4OSqpZa8xhlO1pyo5Mfe7uJut7gn4eIGGY=; b=PD4H8B+xHGWV9WpmPgvzIqlEsyZhwemaNpDcaqqc9XpyL26Mlvy5bgNLieHES9BqRc kqebjE6To0Ht2KzcxUFGCDf8c838a7mGQSv0ofFrLytQWFL4/7zAy3xCEMff0JjyC3DA o8PcagspRBBIx05yi8Xfvf3OD/uzgiHaVY0kotYdBvSLhAqCpEcgeOfZ0ul6fzQspfbO M9VG7KvEEpiyNxZtRJs01XcTpQB9j80hA7U9zj5H31x6zpKVwTXQuDKAYmqpqNy9HMP+ w2OqeAl3WztpFnUiNGhg0N2x3JIaZKxrFj9MJYqQFZSXpwcKUG2L/ef+OERV1aH9MpYg r1Fg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767552126; x=1768156926; 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=yMN7Y5N+F4OSqpZa8xhlO1pyo5Mfe7uJut7gn4eIGGY=; b=GlQAdP3HyI63CDqlBClQhCfRgE3EDmJ37aNZPghFfsl8oWw8X8CRSvHtq56nfjTqDX tWeFli6Kv6gvgkvFUWFqmVQYKF99v8vyDsujq42s+bl2G4d1MFXqtIUyQvwW71lCjPYV DUQzN9vqCsGAcP+GSkhLSyU3/V5D42V8vZUsGlcDr7PTK/H1qPkkZ9iK23Q6SD9dE1+s xQxgml3/QEz76vTt4sTp/6Ep31HwCTeEGR8yKRa/T11xSH00jlZmhAjLliWIk7vWbSdg snojdm3JOk0fmuaqiNGDEzQID8NQzK/Ez/APnsQUlNN0SOFxQGQjGwk8nm8ogsthqv4l rAew== X-Forwarded-Encrypted: i=1; AJvYcCV3oJKjG052EyovfPtTsVnt49B+7vA1Nf9kixQd2vwYC8E7B0xN2U8r+s35vjKOCOC/hCmLnW6bzUjdBVo=@vger.kernel.org X-Gm-Message-State: AOJu0YxsYE/gAy4lnBFeaHJavsFgDb38ZQO2hKukLCJdxW2r/8lTKB59 UWaKKLK+9v4qhWRP+LnZDwytqhlSrM7VSWvTVldj4xXt/qe0CeeMNICk X-Gm-Gg: AY/fxX4BFVHRqh8exUwZlTU3DtSUcCQ1POh6W+EhCH163xTgzGAYTSAXP2njsIgPheN Qgi/kVhIBTYaQEcTo69fmwLDsONW/HceTbxDdjOX7MMjrUcxHJVojQlGB5suv3YEi3HoKcuvSom sSUBYGMz2cW1RuRXUcsGElvdzDLjkXbkK9p8TD/IbLnl4s7XHTkhwZ/8ha+V0+Ks9chviMa8OD2 nSbsvopzQyyp2XXO6IiBNUSmPsUlVUK0tjhLekH7WWdUOQk4b9SvNB6J+9MLTJNA8NUpXYPdVBp MlFtrTiVDnDbVly3T9uym8mlflThPaAFQAQgi7Us1KSyY5yTkALD/uunOkYR9pdLa29V/27W+xj 1TfL6IUMOIfVtDb19JoC3ovzeaS+zFg8rn5l0cLgsUaNUBAZjXPCI7FKDSedSqYQj0/F/dnv6TO 5Sor3e411dBJLIDMW6 X-Google-Smtp-Source: AGHT+IGXskVPcGTm924WxFu9BX5uvR5Jg0oTJC4tonpKGeHiLitwUWK9O7FFgK0Ro1T8HPRCIBb2HA== X-Received: by 2002:a05:7022:6992:b0:11b:d6f2:a6d6 with SMTP id a92af1059eb24-121722eb8e6mr52895123c88.34.1767552126164; Sun, 04 Jan 2026 10:42:06 -0800 (PST) Received: from [192.168.15.94] ([179.181.255.35]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1217254c734sm170975553c88.13.2026.01.04.10.42.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jan 2026 10:42:05 -0800 (PST) From: Andre Carvalho Date: Sun, 04 Jan 2026 18:41:15 +0000 Subject: [PATCH net-next v9 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: <20260104-netcons-retrigger-v9-5-38aa643d2283@gmail.com> References: <20260104-netcons-retrigger-v9-0-38aa643d2283@gmail.com> In-Reply-To: <20260104-netcons-retrigger-v9-0-38aa643d2283@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=1767552086; l=6691; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=Rne9OenFktgXKd2Im5X8TmkYvMetTiWE8HD7UVp+a2Y=; b=LvGxaQCn3OAjWyeq/IXZVPrtLUpW0uZIIYRXXnetqVaBOzkWx6f497hk2SAnQsBS30pfMuJGw Qg8g2n4SzbJBN0aImd9JGRzZREJ5UAsP5e/afUHQ+JDQq2oJr578JSV 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 resume_wq, so that netpoll_setup is able to force the device UP. 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 | 90 ++++++++++++++++++++++++++++++++++++++++++++= ---- 1 file changed, 84 insertions(+), 6 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 02a3463e8d24..489fef5c3407 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"); @@ -138,10 +139,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 +160,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 +183,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 @@ -248,6 +255,67 @@ 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) +{ + int ret; + + /* check if target is still deactivated as it may have been disabled + * while resume was being scheduled. + */ + if (nt->state !=3D STATE_DEACTIVATED) + return; + + ret =3D netpoll_setup(&nt->np); + if (ret) { + /* 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 =3D + container_of(work, struct netconsole_target, resume_wq); + unsigned long flags; + + mutex_lock(&dynamic_netconsole_mutex); + /* resume_target is IRQ unsafe, remove target from + * target_list in order to resume it with IRQ enabled. + */ + spin_lock_irqsave(&target_list_lock, flags); + 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); + mutex_unlock(&dynamic_netconsole_mutex); +} + /* Allocate and initialize with defaults. * Note that these targets get their config_item fields zeroed-out. */ @@ -270,6 +338,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; } @@ -1442,13 +1511,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); @@ -1477,6 +1547,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. + */ + schedule_work(&nt->resume_wq); netconsole_target_put(nt); } spin_unlock_irqrestore(&target_list_lock, flags); @@ -1945,6 +2022,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); --=20 2.52.0 From nobody Thu Jan 8 00:13:53 2026 Received: from mail-pf1-f182.google.com (mail-pf1-f182.google.com [209.85.210.182]) (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 7AE1C3101B7 for ; Sun, 4 Jan 2026 18:42:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.182 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767552138; cv=none; b=I+KD4mvhqvfCEKBSJR62e/FufX+TZ1AJACxYrpS9ZGeiib92zhP3XcW4anfxSj6xd4ndzddnTYbw5dg13KQgr88ViNVfYkJTHClkdkBcklMELg9to3SL0KNaYK+G2NnCd9fuzEKWDRqN6V27ipZ2A6hNH72NiT0OX0pZeqBd7EI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767552138; c=relaxed/simple; bh=KSC8Nj3DiK31fDmZ4/PzcbAzUlQgw1PwPAvmb/6l8Os=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=ATF0a4aKc0Y7cJqtTg2vARs7FnVGmDL5sMidg/gc/zkItEIhKirzGgoOpQAxgKha03sQm1KMTljDHjiEUspdNoBsNw0eHVlMsRFyVSv4ZWJiwIPHx06MxFqqMJwc3TkN8E6dl9N6pZ1qniyvT7ehl4tEyTWXS4Lm1sdq76VY9o0= 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=Pl/OU6jS; arc=none smtp.client-ip=209.85.210.182 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="Pl/OU6jS" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-7a9c64dfa8aso10031997b3a.3 for ; Sun, 04 Jan 2026 10:42:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1767552134; x=1768156934; 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=2RFEABt6Iiak9nuJmj7Wxw5Z8I9sCXd9qm2gCXqcVTA=; b=Pl/OU6jSJ/bs4oHkZTu9BHcp1V02qksP1a+IAAjFwv25UZ/xlTvhV/kPRobqW64z0y h+nVNck7HBsRNHhPPf1Mp8IN+oXlswndWauKRgipWAYRi/BCWvMpTiEv8YpAcnWu0qMr opJDVHwDcBVO0lhMz3HRwF+vIwIoLvaZabZgJxDZ0k7Z8TOOXBb7UfwR8js6ueCddRfw +dHrpoZwFDF2qi0qtT0JPrq5qwPOEKX9BKYb3SeZFBaTnrWwxlZzfy2kmrnPs1IiAvN4 LfsXtRXst7i9FrPRJPdZaLLbrKbFv9GF02KrUJUoCfgjcAIfBgGvCQct5Ro6z67ym44h UpfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1767552134; x=1768156934; 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=2RFEABt6Iiak9nuJmj7Wxw5Z8I9sCXd9qm2gCXqcVTA=; b=rOYbfpjgZOhwBd7MEY0L+5KhqUK4XJU83I/bhOnWzqKHMYeEDifrCnNMTvCsMSoAch 03qJvoG66b60/6ArZPUo3viMRU0q/oIr327K5OVD5wUmI6vEUev3zm2KwET9lkMkMYct Ex++SbPeeXqrJCdYgpAaP8FlKSK3uFP/7N485cZtZQ708n0Ed9fjCDxRRILsi7iF2+yj 2WWYxf/bNYCI9eSd6TAJ+Xo/FGc3JEoEt9qzzlmQ3UeDUDqLenbFumSfD5hhpq2uJRDT KNFd9ywlbi1WRr0Czvb16BgKTu8P5IZkxoplXiJv0uQTnHbEmMWWb3IYHumROTrcyplu ypyg== X-Forwarded-Encrypted: i=1; AJvYcCWph2C0LNpS/15zTHOBnTmCDl1M75X057alxWmgvXbK2D04Oi3eYRGEJSlYNqVUqK0eeSgjddlQA2XahaQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyeBGOzCvySGvslSgzppPZdyVrnALxbM75onxRnBxjWgPdnbeCt ELibG7FrSyYgsrRiO03FiucGd/CXlv4tLGGoJEk5Kg1UogvLn9CHR4LB X-Gm-Gg: AY/fxX6zVzcU69mW5IcW/VTk5QrB2vINvmN9jLgQS/eLwAQen1tStf9PIKicf6nGKAg Y6cDROj9tO4Zhi2AhiveOHZ0DRfNRHDUtx1yYdTXFPmvcqZJUc6diu/h8WxvbIrDg6sd96JmXMt HWI6NzSHu86fsCuZad82+/95iptyYu5yWTNzkEJVeZQTBNvpDU8JsRXEz5Hp0Nfk602+VekWg4W YDQZKothBjyx2y9Imla3NUMdVjcttyuEFKU2pZTM9LULakBFUcfDipm6fx1DvbexY1ECpr2AQH3 6YusU02d/xSWvAIrFZamp5MH/OrpZfnT3P3BGh62kFBFcq065vkwBDe5rlQ2Z/XSWrh+tFm2D7T D1e9igGUkC1XisUd03B9sXkPJUgdx33ReE0SRG4u4AADu8BM8xqp5A+dAV9NAlTl1Xc3bBFqYoN 61tjgeby7jjDoFkcb9 X-Google-Smtp-Source: AGHT+IFnwIpqXZbzNWeV+xcKxHrl4l/R98bpocjGoxRMFG3stXib8Diu/GTPyxwiD4FcLrZEpn6o6g== X-Received: by 2002:a05:7022:670b:b0:11a:fec5:d005 with SMTP id a92af1059eb24-121721aab84mr42485113c88.10.1767552134246; Sun, 04 Jan 2026 10:42:14 -0800 (PST) Received: from [192.168.15.94] ([179.181.255.35]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1217254c734sm170975553c88.13.2026.01.04.10.42.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Jan 2026 10:42:13 -0800 (PST) From: Andre Carvalho Date: Sun, 04 Jan 2026 18:41:16 +0000 Subject: [PATCH net-next v9 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: <20260104-netcons-retrigger-v9-6-38aa643d2283@gmail.com> References: <20260104-netcons-retrigger-v9-0-38aa643d2283@gmail.com> In-Reply-To: <20260104-netcons-retrigger-v9-0-38aa643d2283@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=1767552086; l=6537; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=KSC8Nj3DiK31fDmZ4/PzcbAzUlQgw1PwPAvmb/6l8Os=; b=PgSfxa9US0mdGHwEc+hU6mfJVmj91v5553z6D5A4D99LsDPMgmzV88AP3TyeZcM60Jy5nRZFu 21PaxEXyvnjDX5xPuPeBGwpUak25DWSp/ZimN9zTFXjz+q26KEZQhdn 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 --- tools/testing/selftests/drivers/net/Makefile | 1 + .../selftests/drivers/net/lib/sh/lib_netcons.sh | 35 ++++++-- .../selftests/drivers/net/netcons_resume.sh | 97 ++++++++++++++++++= ++++ 3 files changed, 128 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..383ad1149271 --- /dev/null +++ b/tools/testing/selftests/drivers/net/netcons_resume.sh @@ -0,0 +1,97 @@ +#!/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 + +function cleanup() { + cleanup_netcons "${NETCONS_CONFIGFS}/cmdline0" + do_cleanup + rmmod netconsole +} + +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" + + # 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 + + echo "${BINDMODE} : Test passed" >&2 +done + +trap - EXIT +exit "${EXIT_STATUS}" --=20 2.52.0