From nobody Thu Oct 2 22:51:15 2025 Received: from mail-lf1-f45.google.com (mail-lf1-f45.google.com [209.85.167.45]) (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 8E92E2571A5; Tue, 9 Sep 2025 21:12:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757452366; cv=none; b=jQDkmJ0wHBDObpB2B1geR+B0P0uSESr3x6t39AdH46eKDGK2sNm1/6Zxu10jCU1OJPUIaltYzM/pJTBCN8Pfz7kpIyH9zSX6b7zSLT26ar5Qz3wBP1frRjl17KT5nX/j2kdNptDSk7J6etyT1XQ7DEkuyX5KyBqjxi4yM0lp7tc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757452366; c=relaxed/simple; bh=b3zVpKcWVRzzAV4PoKPYfkAzAKs5wqpx9sDSqMK2hLM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Dk2Ue6RTlWrq1xahf7cgKcEw43vFkGWzqgDhBXlQP97r7oUPJafH/TpeVuUbC+oQ0CsGecpEeItFRl3M/uKUNo4q1/yViLQQnw1o3f0Q6GEXhNAW2fkD0yqXHbiNbgXkUuGvb41L/Ws5v2pCkiEYumWlANIaV50Y/6Jd5P47OAk= 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=I2qCwLhd; arc=none smtp.client-ip=209.85.167.45 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="I2qCwLhd" Received: by mail-lf1-f45.google.com with SMTP id 2adb3069b0e04-55f98e7782bso31905e87.0; Tue, 09 Sep 2025 14:12:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757452363; x=1758057163; 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=EhtGHWyefO4/6V0Mfz8aoHHvCaYrHjSgfLtudKA9GGM=; b=I2qCwLhd3VWcySHrlHPOb4XkqrKSYDzr5+V7z22y6kexGumGzRDOz+T4DY61HCkEXp txccNNQbezeP1WiEVR5amZatWl9PLhs6etlCVXDGaCbgr3HyGFCbgR20bkdEYIoJKhDK LH8rgYGjWEyBVI4x4k8KFU0gToITXBZL0Kfg1RW6IYkwJfrDu4k8qP2BNikZkSAhitM0 eDbDARlKGTG/8aRi9pnav8yQxNdPQaigDQYgzmZKne6GU2++mqfABGlLxxHwaQzDjTKD WciyRaTyKTnJ5lageMCXQgXnQhX60bHkx04Uhx6MEsrQv+bfsxaJPLWv/3ZhSzw8JRV9 rRnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757452363; x=1758057163; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EhtGHWyefO4/6V0Mfz8aoHHvCaYrHjSgfLtudKA9GGM=; b=HGmY/rRlkWlrxTApiJSl0uuC/+G9mjADvuqCcOeuqOSqwOEUWcQbv9CbplyFL88URg TSsbOEK8iGO6b0Z5C5Pof27E3dPPF3eZylKkAzAO1Y4HJRBqYCNBizdM1mY/ktmI+dFw 1c55+9UHO4wgCStdxJBsxcLfRZPZnX1gcbhOa8N5Fb2i1curvWuInrKZqVGcoYMPCLqi dmOcxfFmmrpvL9BPjUt6fergJxgYEnT0hY8gm/Z1rd2MqyoxEVYiccqtFkj/4wSVKxWx JAnqGEI1UUnkUZ0NBHB2f/a3rhwm+xt6Xsf5DIVfX9p3Sv36O8VmWWW06fg+88or2/8z PHNQ== X-Forwarded-Encrypted: i=1; AJvYcCVDRkWGTWLl3GWZyYcrnXpe2DzcSQjeWHoERM36iSX0ZTx9t8Jcup+W+pYilcYKbNxQSt9YKcBOt8N9GSU=@vger.kernel.org, AJvYcCWF79xBQm0NA7LJg0MJIetbZoO9cz2wLuUGCTckraNDm+oXYJQC1uFdpcf6V5QxAUjRiUfND7lcUP8c+ygQaIG1@vger.kernel.org X-Gm-Message-State: AOJu0YyNyZRgfEx5UgdWYd5JIdmGkcySXZylpHV226Yl3NIaThG8yThu SAmGH3zihC8Od9ymssgSdpp++fUmQzzY2G95+RnWMp4h48ncFQ/BVDDq X-Gm-Gg: ASbGnct6Ig2mO70PX0joaqsfyQeVIKNEBxWJUHEbIR7rwGn/GFiWNUlEEfSTsMX0XYy Ms+/gynbjo0Zaz/lOxVkJgc8HljCAF9vPU+tojIyN+B2Vg2HLQCKW4tZXac+AMEePwk30rGGf/A 7AgbNHhlgN+Kpv2s57uTfI309Ktr4ZW8EWAHOiP9zSo1466lHUQ/udEhNC0+GPqz+0RghucQSpB v4LcK4Nnorf8B3An/Twf6GfrjYFPFW6C3vr8wBuARSe4YTCbcQS45VyAMetJxh31YcBrMCiQXwn rwO4BqOtoo3oIKweVu2QRW+44J8MHNSrKvNMZ4Fv6VOvVqf87YL80Ad5L6HZBRCv8K9oh+LBtYH mH0No+2iPf/BYuKbuVYqI3fPIj6M= X-Google-Smtp-Source: AGHT+IESClFExStOcpY/3lxx/WxtfMGI3So+QT5Y61P7ufuKUl8U0bqCOUUb3NvlKXF073U65HqoKA== X-Received: by 2002:a05:6512:2215:b0:55f:6b08:e60 with SMTP id 2adb3069b0e04-56099434b54mr5833970e87.5.1757452362268; Tue, 09 Sep 2025 14:12:42 -0700 (PDT) Received: from [192.168.1.243] ([143.58.192.81]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5680c424fc9sm757025e87.9.2025.09.09.14.12.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Sep 2025 14:12:41 -0700 (PDT) From: Andre Carvalho Date: Tue, 09 Sep 2025 22:12:12 +0100 Subject: [PATCH net-next 1/5] 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: <20250909-netcons-retrigger-v1-1-3aea904926cf@gmail.com> References: <20250909-netcons-retrigger-v1-0-3aea904926cf@gmail.com> In-Reply-To: <20250909-netcons-retrigger-v1-0-3aea904926cf@gmail.com> To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Andre Carvalho X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1757452359; l=804; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=8V6SGnkKJouMeVLTzdn4Y5ZWQGfJsCbNdTJXQi+AdQs=; b=J1AS/rPSRm3utMfKLZvtLtQk3W/MP54Fzy3m7kB+++kyLXjVisgPm25oGYufz2sB57wPWN+WK NFvs+655aP5B3cU7Xiq3dcXr2BynL+YrXZ8g+3lI8Y8uSrk5fF8K1Wf 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 194570443493b1417570d3fe3250281cffe01316..b5e6a9fdc3155196d1fd7e81def= 584360ecbc3d2 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.0 From nobody Thu Oct 2 22:51:15 2025 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.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 EC719257841; Tue, 9 Sep 2025 21:12:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757452369; cv=none; b=NoD4Bm7+MvaymnsdIUGtlp7bMSebPgydF09Db8gVIEElF9eYd5U1J3Mzqx5xR6kGPLTypLeRC0MH44f/nGtSrnkaLQSE9O1zuwukOEg/CoxumTG/sql8hd2cpeoC8mabhC+Hox5IFJCele95Ois8rIDDzadsJEDA0robuVKu4oc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757452369; c=relaxed/simple; bh=4+rg/Gz1eysCw1FZDc5FEYkSkFXM3WUQDHMPBqpsv/g=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=g/KfFBlLV8SC7A3WeDPa/xegI7kyZoy3n65iiu4tATdllPi5ljaFLSCSObAo6jbEpE3Kc3IWuPVAKLJRtiKVdAX05iYdB1pfD0hX1y9vSQrEDCnvzsWgigCtgGx4IWdIgLexQu34BUUPraqLv/5/JxPaBnHguts3hqeBWr0zEy8= 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=bQnqVEnR; arc=none smtp.client-ip=209.85.208.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="bQnqVEnR" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-336d3e4df3eso48310461fa.0; Tue, 09 Sep 2025 14:12:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757452365; x=1758057165; 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=n+8+LQrrI546X3g2e/jgKl85KVqcdJ2/SBcOSdSAmgA=; b=bQnqVEnR6slQzAC/+tQERGj54BDW3HB0FSH1WxBxdizYSNP0FpokKPhdr2ez45fHQ7 UIswaoBUR6Ics2xmBW6DdbgHMV3/w8OpmXMSM6J1a0FH5x3rNzobt/pcKf4fh46aO+JD vosqRri5xzEYp7o7+MBRzIS1S6vALKeO+wuwfsvgwN6m2PCUJFqc0USciBBTIvGg52ti iOQZX9YHvzb83D2OLYb3SzInLeN4MPmOq4bCKbgH+yOMPYWLeRb/hxoZnmeEiVMBGcy/ HUCwtZ9lMBr9aF94zCDDCR9zidwJQPZOK/fLvZoBF0qiQCQ+eAbqLm6bN6Bn2BlxScUK 4myQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757452365; x=1758057165; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=n+8+LQrrI546X3g2e/jgKl85KVqcdJ2/SBcOSdSAmgA=; b=V/r7PRIkkq+nVRNUkScN/RV01tzAJZicaVZPrKsEezQkkDx5CygoQdI2zwaUNom778 zcYazMzRyD69p6P0XqksNcM/L+x2i6ko+I682nm+Ml8VA92x3jJZ9aX8NcbxCjGtF/fq H6zP6icUp1XD0TyT5i+Hk+kIVgkPIIGE6s3MwB9ZSR7WSbHRgN3gZ7/bj7yXMVChGZw8 MPLtRjd+3tqBU+ReqbIEVI768k/00emXVOPCpET7MRi5rWdkYEZBNBFQo7eQajEXe/ja YPl8d2VkCPEN+dOFZR4hLqnnT6pMkQZMfjb6KQNXUeGBa0KOqPgEHXgRUj/HlfqAFM5u quhg== X-Forwarded-Encrypted: i=1; AJvYcCVFCwA9TH1FNyjomJG87Jxabjmb73B/eQ2FP1qjHd66egfPDyPWgK97IPGuFeFrHcx0SmJagMzGG0ILkM+/hdqR@vger.kernel.org, AJvYcCWgJVMdYD5Yl+opRkCXNwxC2SSGJF+cNsirDlZQEGnXmaEo2c+d4s/f2xWpWxR78qMwP2ZfserM2wDCMNw=@vger.kernel.org X-Gm-Message-State: AOJu0YxLVeAZKBj2SH371XkHTds4vDfU9aPxqLFT/vJ70XuTcd9xfaia BuECGl50e0CK11hNb2GZixzZTH1RJtzsVgrK1LY/2LWqrHs72kupA1/H X-Gm-Gg: ASbGncs7goXT1bGNEArJhqHmVmcMITCQenHBH5gKkILkzZXZQn4JUBqVEvTWEZBPGfj jIyKoi7icaOYkC2synPt1k2gSC3X7p7JWmABZyFc99FYDqw01pvn66VFwQPh43qfmv2VJ+O+Ft6 PgS03eFv/q3Cu6S24M2WgEefyLWJnyIOnJl9hbRpyxV2rZHhuOUssuovifBf4dOjcRKHJGLHUwX IeFLSebM/abmkAA6p71vfnJz61MSQ4DPQSue+vqke6xZVVuBoeas3GlgVpzUuucFS1jjrbn6Gzd J4jntkXAzrGCrgqxqDebQ6S6mzI5ZxpWZGUHcSArJNd9ednREsO1Eq1bW3M2mNJrzu/WdTLjXnY IliLSwykbIt1h6Tfb/Cu6h4ZnSLF4D/1cdWADbw== X-Google-Smtp-Source: AGHT+IFNdnuSlcCf9z5tlEG4Y+joIUPcoc8wEZ2rqt5baB6HDPfj6AWR9UB3RDUwC665DYY0yF21PA== X-Received: by 2002:a05:6512:1289:b0:560:98e4:c986 with SMTP id 2adb3069b0e04-5625ee79705mr3899930e87.11.1757452363844; Tue, 09 Sep 2025 14:12:43 -0700 (PDT) Received: from [192.168.1.243] ([143.58.192.81]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5680c424fc9sm757025e87.9.2025.09.09.14.12.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Sep 2025 14:12:43 -0700 (PDT) From: Andre Carvalho Date: Tue, 09 Sep 2025 22:12:13 +0100 Subject: [PATCH net-next 2/5] 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: <20250909-netcons-retrigger-v1-2-3aea904926cf@gmail.com> References: <20250909-netcons-retrigger-v1-0-3aea904926cf@gmail.com> In-Reply-To: <20250909-netcons-retrigger-v1-0-3aea904926cf@gmail.com> To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Andre Carvalho X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1757452359; l=8957; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=4+rg/Gz1eysCw1FZDc5FEYkSkFXM3WUQDHMPBqpsv/g=; b=2rxZt7WzGX4NPc/Vtrz6pbHcle5yTQBQ7lceEbPuE/xcblIIQ7w8/0BQbJGMYGSz3N8DS/Dih o1ysjeGuCQcAET40BsnZOpgxxA3CY9oezDqBREZvkt/WGYIqBQkKL1V 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 b5e6a9fdc3155196d1fd7e81def584360ecbc3d2..688ed670b37b56ab4a03d43fb3d= e94ca0e6a8360 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; @@ -1315,7 +1317,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; } @@ -1711,7 +1713,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); } @@ -1731,7 +1734,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 @@ -1887,7 +1891,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.0 From nobody Thu Oct 2 22:51:15 2025 Received: from mail-lf1-f54.google.com (mail-lf1-f54.google.com [209.85.167.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 7907425A62E; Tue, 9 Sep 2025 21:12:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757452369; cv=none; b=qfLO5K07eUrbnaClDPvmvy3bd2lKz55+ZhtmfMcpC/Qhsb3TaAiVbV0Sx24CqbHKTQ5cKZfotHhRR8WFvJz+PSLksslP8d47Aib/nvB5txCZyo+TpznSj7qfX7TR8Kr+VE/gE0BzRykftJuMKcOFZ4Ylilyr4kn94mSHPhLKlaY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757452369; c=relaxed/simple; bh=5mhr6jsCmNwNcnFO+5SOJs2r7HZGP3JEvC2ipj5IjA4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=WzYrtC3bSASn1pvWT9hZO9QS6ADzujpd7HoPUGbnFq4ljPx2UDWFtdDbqynYrFNDRDYXmYXmD0EzQU3SWm5O6yT6rU37XkPpV9FnC71NgsecQ6oc/TNrFfGYNZQTVHaTnEOOwimG/yMcsTDzGQeWUgdoYSQkwD5K0Pu/SRi9blo= 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=SYjPMnwK; arc=none smtp.client-ip=209.85.167.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="SYjPMnwK" Received: by mail-lf1-f54.google.com with SMTP id 2adb3069b0e04-55f7039a9fdso6231147e87.1; Tue, 09 Sep 2025 14:12:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757452366; x=1758057166; 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=LIdf/p+W7Ujz2zhxctFos5mKw5BeHeIDmEYf9Zo81XM=; b=SYjPMnwK682ZuA2TcnyPLms77IfgjBOpZZRuab/IdwxmcOiDzhM1+0Nsi4tFWEQ38p /RLUZa2CuGK9qtHWXFfftIWgKHbMxjvvmrkJfEry6Q+or1XvsX2ebPhbWCtpjU5hYEog +BeP7k+X1+pqXET85jhGR2uRA3n/sJhavgchQ8TN1xvKLwPGVKG4HbMRTYDiaqL7Y7es V2PLAB4gpZr39D9BBfWpbO+IZH0RKZq5hsrhflQ2BDeBIDX6KPZRspCvHPZvyP/LNJmI v45jOAMqJ0rvTXHl9YG7Tbx+5ejshPsDixpeEfJuJgq8QmfEvMk8M7hsDih1gsHGdsuf JoqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757452366; x=1758057166; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=LIdf/p+W7Ujz2zhxctFos5mKw5BeHeIDmEYf9Zo81XM=; b=xHLw+xE4buBIxTIZCkplp6xBBJdADcSlaZPU6p+G7GmyYFQOI7DW95VqtNWYAo0DTG Q1U6Fve7vS04pqggP93Iyp6u9aSJfVwlTmzC7/I2hzCg4+Ebg3KaLKoVHZNVX682E4Um DDC/NCKYQaUrRJpIPEKKEeusM48zJCUpJWuSrybDwKvkJPiHgLpX2WA6BKL5vDbJE01E 7CARw9Yz28b/vbWSV4PTn5y2ozZBfIeWH8N+6PzpvccggnXzT7Fuzd8AbzSTA/HvUSqN ExmhjdWah+ZUcRiHmQfPAWICPCDBcq/rL+sfaoHeQ5IS/YhVbkjqEoC5y71+jIFI4mlV oQGQ== X-Forwarded-Encrypted: i=1; AJvYcCUh2O+y5XKINbeENo18fg1QjW/ndIjdTkURYBBMRcbb5FtT7wS0QKI6dLAe/VAo2LP5KvJxakOmPzF86YI=@vger.kernel.org, AJvYcCXSdjFimwlh6sBH2dV2LbyBkrVUNmDC4eg+MTToccHDh0FthVAKsAVkWkrlSiEZd2fIAgZBpuJe3Jq4CkFQ3SCM@vger.kernel.org X-Gm-Message-State: AOJu0YzMaik/826w3GTNnlFNSmhC8UNU72OxGuQsN5KT+Y2VuV0fHspG KQPDzemF4i45OCnjh4quxbPxX173mUTpcbL4zmU/UBLhkw9viYzG+LXo X-Gm-Gg: ASbGnctTapnAFdCF9KmUKbA/f8VrTU8UcNfQgDgL7xmsQV4JxxR57o+7Z+eTuOD89xn ml1KZjon18eV47E0Gmri1aqGcTM//vFMuNLpI4ZaLY7qn3y/y1Xoiz6hoF9LXb8oHQBnTC3E3kG bqo4YYR1++u6gCp3R/9dYAsgQ8DY44GEBaoZL++2n20XoableTn6lBZQNuvm8wLSVXQQ5tQCHRy Fm686yUZLCqhLLQG+W6V6JfBk+Jd5wcXYDr5i7Sd6S6UtaoXRr5DLmZ/VniPGrS4fgtTTl+d7Z9 U4Qe0AGw2UKSUz9IH2O+Y0ds0/+A1bmO91D3hjKmk5i6xi7/lZ2HWyOyDosw9odAg40peFOEKEl 50YS3cxYuTOtp56iUD5FGXz9e9p0= X-Google-Smtp-Source: AGHT+IGkS8M26oiTUzvMr7ORIYYPv/MeKzCIZU5cLq+2zoMS0nEwouvNC7V9RVhOpu4yqOc0tVYHvA== X-Received: by 2002:a05:6512:3b0c:b0:55f:63ef:b2bc with SMTP id 2adb3069b0e04-562603a1050mr4195005e87.8.1757452365319; Tue, 09 Sep 2025 14:12:45 -0700 (PDT) Received: from [192.168.1.243] ([143.58.192.81]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5680c424fc9sm757025e87.9.2025.09.09.14.12.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Sep 2025 14:12:44 -0700 (PDT) From: Andre Carvalho Date: Tue, 09 Sep 2025 22:12:14 +0100 Subject: [PATCH net-next 3/5] 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: <20250909-netcons-retrigger-v1-3-3aea904926cf@gmail.com> References: <20250909-netcons-retrigger-v1-0-3aea904926cf@gmail.com> In-Reply-To: <20250909-netcons-retrigger-v1-0-3aea904926cf@gmail.com> To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Andre Carvalho X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1757452359; l=2084; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=WsXzbr4oh2tgdkoPqzROUayYBAGNEehpMnq5WhfJccU=; b=vpgDxwm731pl/VFL86I19YSmMCpS/grtOYL8otH5BwuOPXYutjtSvN4NzDi//Eo+clm+XKdzV MmGITkIhGMPDLPu7a7hSnbQJQ0LWZ/8lVhV5TPmnutO2yAd85PfOPAD 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 688ed670b37b56ab4a03d43fb3de94ca0e6a8360..59d770bb4baa5f9616b10c0dfb3= 9ed45a4eb7710 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) { @@ -1446,7 +1455,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.0 From nobody Thu Oct 2 22:51:15 2025 Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E3C46255F57; Tue, 9 Sep 2025 21:12:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757452370; cv=none; b=fc6E4oNfLW99pyNZeSEpUjoZHf15Y16rm2RiE01DrXpqKNb1lWjmE25QWMQlC9r34jac8v53J/Y9xNxb1ufxHageuIKU18ZcLSSPAp0lc+JPu+dz1Rs4LppBEf3wxxGdDosTZseBk5zoIM5R9KlvDNpxABautzWse+05lvhwRvE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757452370; c=relaxed/simple; bh=opQUQP9zUqOgPxXg26hq+yrVXAyCG9IkDejdHA+WJ14=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=o1vVoS8UV6W10wCrpkcE4So3Gqlo+ky5a/vlfaeYDA5FdMXv9v6J7ptRnc67ePGw/uCT6+SCLgD5no3arwZn+AJa30RVdOfSn3/oirytqT81uROR73294rLCzOpL96ms0EXDnWCZeZuLPz42IVgLlclk83gmnQ79jg524/NQx3c= 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=jiq9GFnU; arc=none smtp.client-ip=209.85.167.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="jiq9GFnU" Received: by mail-lf1-f50.google.com with SMTP id 2adb3069b0e04-55f78e3cdf9so7430629e87.1; Tue, 09 Sep 2025 14:12:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757452367; x=1758057167; 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=MVyHAPg3FO0HjHYvN/1HgPTa9DwQTlAlNLzU4rc7wAc=; b=jiq9GFnU5aWchRuJ+SM6RTh//7K9q/8cd4I6qV6eMIEbriAGCodB5ySeq7ssgH1eUO Me3MFYyzsDXg+BE5P37ue8+LaXTFaPOqj2wORMeEmpWRX16/H0Ov9+8wN4Mf25W34lr7 dVJQ5f6VQwOo1psyG8ph8uarcjM5bVC22ZnCygFEG6fVlltKgwolszj1o7e5n85Ih+Rc INzVMYSJ8P4tt7MGbUGwz0HtPbxJX8NQHSA7I/7e45d/85lKoRpwr3Pl+RTDmGlbhm9R 8GFm5SPSWeRW46k5ne17HhVoie80K71Dp2Al1KsoKwIugYeoueXcXvZ+8+zVRbi1JOF9 3lIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757452367; x=1758057167; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MVyHAPg3FO0HjHYvN/1HgPTa9DwQTlAlNLzU4rc7wAc=; b=QuXahBj11b5b5EinDtzLQsNQAE3ZIVdn2byUf8fLT7HaEg0c4TmPoYgsSjA6x6ILlh xwEJ2/M0cCTzyyKpKQ4JXKU0nCFfyiUQEYLXedHAtNLm9sixslBtK3dkryHiBYgYqWyg 0OXGROlL4WWV0fVd7l7PDIULj2WCQm5lWb3wrj6O9PXNiOIB10VS3qxhzh8ykhMlwuKh w7fXA1Tz1sS3WoadOMXCFwt8RfX4vUUJDtWfD4ZSof9VpPmG6uMrrxG4rkbBdC+vt6A+ VhLmiTNmbp6klbWU8KEHZhQ3eohYOukaXlmMksSrw5DWoeci4NLRND8NDtYN3TElQKOV 1Bug== X-Forwarded-Encrypted: i=1; AJvYcCVjmngqW3V+Lz7rqHdedu3TZ3+98wKZECP1YPEZ77hnK9O4Zxdm8H3Bk52/yeYLrGCJwzj5U0uXdqMxOAU=@vger.kernel.org, AJvYcCWAhIT/s5Fkmfi8psSlB7buMNl1KQNwQ7Izp6EcV/TtbUm6hB3LOvsYBQF4kN6IJFWCsZhGdVCUzBN4DnnhdhGO@vger.kernel.org X-Gm-Message-State: AOJu0YyzhrK51w+VTWXFlPz1Sc3dyzh3vqwk2RGgZlMPcdifb72B/KaX yLZgaLMyJtz37D14vCA6RHIHIZ73igHHASDKN7qa2R3vtrLwAfu2dqzS X-Gm-Gg: ASbGncsFr17n7pV6MJRPqEYe9RcRc5kNrsjPmCoiKClbvlCccjXZKNv83f/Xh7P25bZ UvCqkHSmgsCWYBef2z9HByh4TDrzkFqRQmJne1tzJPFswPIhr8hO4r5438eQdWegm8fvaAxPMmZ zY/+5ETk6rvo0tdkiUj6nv2450lZznD0moxoGRWqKGnimBqABp/iOyZmiVr6IvqywoYQ1oNgWZA EDd8MQhRKwQ0oQfdVA1SpkMYvUhqYmPZAs1Wch7wzoFXtc13e4+QauTBHOJS7Jz19syHjYVgPDL gdGCuDuNK4KoN+ywMrLdL/6DPXVBU+YVJfN8YEKIhOSCOoSduzEtR2WgR2amgGjPrPolpgBZGLN GbUxy3vvvJ7pUSoSUh480RRe92fc= X-Google-Smtp-Source: AGHT+IFN90FouCWG5RAA3sTPY0LKbR6LqVwS75kzpWSAJhnYf/xIkcgYADcBYOiCQRNWlcNz5qCUKg== X-Received: by 2002:a05:6512:1589:b0:55c:c937:1106 with SMTP id 2adb3069b0e04-562636d5e48mr4204786e87.28.1757452366752; Tue, 09 Sep 2025 14:12:46 -0700 (PDT) Received: from [192.168.1.243] ([143.58.192.81]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5680c424fc9sm757025e87.9.2025.09.09.14.12.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Sep 2025 14:12:46 -0700 (PDT) From: Andre Carvalho Date: Tue, 09 Sep 2025 22:12:15 +0100 Subject: [PATCH net-next 4/5] 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: <20250909-netcons-retrigger-v1-4-3aea904926cf@gmail.com> References: <20250909-netcons-retrigger-v1-0-3aea904926cf@gmail.com> In-Reply-To: <20250909-netcons-retrigger-v1-0-3aea904926cf@gmail.com> To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Andre Carvalho X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1757452359; l=4008; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=opQUQP9zUqOgPxXg26hq+yrVXAyCG9IkDejdHA+WJ14=; b=VE8vG+mqtHDU2xhEgKx3nupTyYDeJi70qtU7Qp3UhB22sBJDqQXvXGxZhGSeM957dlLj72td7 4oV7MA5OYtvCSGTXBPllXZMgohHylfwKRHYoGPr5YF+FhFqJkcek5oM 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). 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 | 46 ++++++++++++++++++++++++++++++++++++++++++--= -- 1 file changed, 42 insertions(+), 4 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 59d770bb4baa5f9616b10c0dfb39ed45a4eb7710..397e6543b3d9aeda6da450823ad= ee09cb3e9ae70 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. @@ -172,6 +174,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 @@ -237,6 +240,33 @@ static void populate_configfs_item(struct netconsole_t= arget *nt, } #endif /* CONFIG_NETCONSOLE_DYNAMIC */ =20 +/* Attempts to resume logging to a deactivated target. */ +static void resume_target(struct netconsole_target *nt) +{ + int ret; + + if (nt->state !=3D STATE_DEACTIVATED) + return; + + ret =3D netpoll_setup(&nt->np); + if (ret) { + /* netpoll fails to register once, do not try again. */ + nt->state =3D STATE_DISABLED; + } else { + pr_info("network logging resumed on interface %s\n", + nt->np.dev_name); + nt->state =3D STATE_ENABLED; + } +} + +static void resume_work_handler(struct work_struct *work) +{ + struct netconsole_target *nt =3D + container_of(work, struct netconsole_target, resume_wq); + + resume_target(nt); +} + /* Allocate and initialize with defaults. * Note that these targets get their config_item fields zeroed-out. */ @@ -260,6 +290,8 @@ static struct netconsole_target *alloc_and_init(void) eth_broadcast_addr(nt->np.remote_mac); nt->state =3D STATE_DISABLED; =20 + INIT_WORK(&nt->resume_wq, resume_work_handler); + return nt; } =20 @@ -1440,7 +1472,8 @@ static int netconsole_netdev_event(struct notifier_bl= ock *this, bool stopped =3D false; =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); @@ -1460,6 +1493,10 @@ static int netconsole_netdev_event(struct notifier_b= lock *this, stopped =3D true; } } + if (nt->state =3D=3D STATE_DEACTIVATED && event =3D=3D NETDEV_UP) { + if (!strncmp(nt->np.dev_name, dev->name, IFNAMSIZ)) + schedule_work(&nt->resume_wq); + } netconsole_target_put(nt); } spin_unlock_irqrestore(&target_list_lock, flags); @@ -1915,6 +1952,7 @@ static struct netconsole_target *alloc_param_target(c= har *target_config, static void free_param_target(struct netconsole_target *nt) { netpoll_cleanup(&nt->np); + cancel_work_sync(&nt->resume_wq); kfree(nt); } =20 --=20 2.51.0 From nobody Thu Oct 2 22:51:15 2025 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.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 763C4261B62; Tue, 9 Sep 2025 21:12:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.53 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757452372; cv=none; b=rpo/OHRccaj1W3E55kypLHx6htuLEwsQSbGD4uhVYsD/edxNoNqvinYypfhETqyXw80n31i4YhUgMbBEytbRlgq8S1SnZhu01QOhFLxACeH5q5rbCkpKCCxyIyRx94lKuPLfv4X0YS4k+CfqYAusPy5We4H/vsu2+tS9QkeC7K8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1757452372; c=relaxed/simple; bh=65r5Q30rEGislckJZUxh/W9mjPAujYvYiGkilVFpCfc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IeK+dgoHKRjgRamvHPGOxwk2PAQ5RbmtlU8GeXje/4wvWD3PUrQXsX5YCy4bZpJn6RtYdldlibVXCKLDVZYIw7cm+dwIAnUvQ+efIGPH/kaZhgrUBmOM4qnmto4v0Gy/5JkTI7uMHozrY6eJQ0GYjBmU9U7QTVecC69Nr0fD69g= 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=IcPoK4II; arc=none smtp.client-ip=209.85.167.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="IcPoK4II" Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-5608d792558so6658196e87.0; Tue, 09 Sep 2025 14:12:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1757452369; x=1758057169; 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=DtOqibUwz5tngZUvPo7icyfPskkpVVJBzNaUCRYuMOE=; b=IcPoK4IIANi6kWm9kcoS2ZcTirpPVzsoK8hSyoIWHho/FeDZT2ToK2xgp9aL52G4ZO SXIaKcEgJ4aLW1vuywnEGGnUIa1L1PD4VTzZd037EZEoCeMjqEe1RvqcYMbPdIwzd6ex SLx5aWglrUbecbKg9y1NDIoI+huRFOsnTbRgfTi0X32z75sCV3hqrdU65/H/4oo/pTYf 8fMrEWmuiuey/iQCvC7iE4Ht+h77WQEsUUPrzDN56tBRdfSDAa197lb8bdhwz+OkrMie /jCmINoAm+sHJv1PyjzA5shj4hLnwIJyQBqOmDGxPSRel0FIYwsbJKv4bilIZ4Ne4ZgV 39rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1757452369; x=1758057169; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DtOqibUwz5tngZUvPo7icyfPskkpVVJBzNaUCRYuMOE=; b=dQ6CrV0FJTSw1aoKP8BPtM0P411CwdCTNzTewB3FFXKzpybiWJwzM/hcTkY0bcky/O NgSKHCLB+udjfEzCozhp5dphuNpNBf50lq9sc+K0nFpf4e6Dcb9TrLdybXil6T8yJYwg FfhnVaNtNeUbr2+WvpGAtCx1c/0hIm9cWQdQYAYESClUbJDHtlPkl6XX8RDm7p23J7EB eJ7ySElq7YMZA6LTjpsTKS+0q/GGsUhiGEykUZ/ZDwWKIi/+JY5a7FAMk1Ot9LJLXw6d JM4PfzNO3xtqwRuTH9MnogA9P0wKfkevxC++gHHFD/EVaw+EBSCnzSMnNiXDiDLg5W9X fXOw== X-Forwarded-Encrypted: i=1; AJvYcCV3P4JFM9kQf6sH4BGNWGv8ZZnx+5xtyD/OZEGxP8R+J3CI6YypRo+L5jG4yKivElgEaZLcZ9Jca4C7H6jIEPZf@vger.kernel.org, AJvYcCWtRuDuEidgu6ZDwmiWgdOCkd17QwZqqwX7xahL9tNvj79oQIsNcr2NLAvdpkVWtlctyFZafHvo7JkBXfs=@vger.kernel.org X-Gm-Message-State: AOJu0YwOzGVg7dCjU8cPlwUr883xlWO89h25MYEQ9cfUbyjXSFv5JC1b dOiI5pB9bxsu6Nl83PXmN11Gn7oysaawKWt9fiEcDcGjwP6KiPz7nJI8 X-Gm-Gg: ASbGncuqbQqJfbp+jUtFIFIs6tWjEBvGihrSwFyEDPT9s76wy+aMSbfvBw8saunT4IS JmVqxchOGzc1RYOaxyYVbCZwhC6D+BFiykrRIDVInUgEF5+2HIgAP3CfixuuvkluA/CgMItVor9 aY4ONX+s2io0X3hGTCuLiHN97y/IsouLPg3F1/eiUh1skoGr0HplYZHUhpy+FpL/Wf1fE08lLzs fSsyxFFwcJ7VgrT4j0zNBdpKC2dXdA8cjF5vYwQUCNMO1WD3P6TwVeZxy8EsEJvSCyT6z84S8Uk kJMhOKUyg7ZDEtt3MieIuSt8chYi/zWnCL8kf481UaGKLacPb+3ssqmtCQ3YEBX1SxDkxr9FwKg HBh7zEp9BamGXEbUuixj1lUESmCE= X-Google-Smtp-Source: AGHT+IF38s9lxfZU8G7P7mNg2kejHM6ZDeNW2psHHku97+fDx/sloeupxoCrsOVOWsnx59K9tuGcSg== X-Received: by 2002:a05:6512:1589:b0:55f:3f25:f03d with SMTP id 2adb3069b0e04-56260e42ab1mr3957629e87.32.1757452368272; Tue, 09 Sep 2025 14:12:48 -0700 (PDT) Received: from [192.168.1.243] ([143.58.192.81]) by smtp.gmail.com with ESMTPSA id 2adb3069b0e04-5680c424fc9sm757025e87.9.2025.09.09.14.12.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Sep 2025 14:12:47 -0700 (PDT) From: Andre Carvalho Date: Tue, 09 Sep 2025 22:12:16 +0100 Subject: [PATCH net-next 5/5] selftests: netconsole: validate target reactivation 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: <20250909-netcons-retrigger-v1-5-3aea904926cf@gmail.com> References: <20250909-netcons-retrigger-v1-0-3aea904926cf@gmail.com> In-Reply-To: <20250909-netcons-retrigger-v1-0-3aea904926cf@gmail.com> To: Breno Leitao , Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Shuah Khan Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, Andre Carvalho X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1757452359; l=4794; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=65r5Q30rEGislckJZUxh/W9mjPAujYvYiGkilVFpCfc=; b=ymDJeSULC8JJf+tNqHagtFdnz6Op111esKWv7VDiuiVJdtJGfLQukER03uPfkXQBkvNur32Pg X49B70l7ur8BoQ5OywnjaGh6w9A4g3AfHystfjhb1nz6H/Z+4y+GmHg 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. Signed-off-by: Andre Carvalho --- tools/testing/selftests/drivers/net/Makefile | 1 + .../selftests/drivers/net/lib/sh/lib_netcons.sh | 23 ++++++++ .../selftests/drivers/net/netcons_resume.sh | 68 ++++++++++++++++++= ++++ 3 files changed, 92 insertions(+) diff --git a/tools/testing/selftests/drivers/net/Makefile b/tools/testing/s= elftests/drivers/net/Makefile index 984ece05f7f92e836592107ba4c692da6d8ce1b3..f47c4d57f7b4ce82b0b59bee4c8= 7a9660819675e 100644 --- a/tools/testing/selftests/drivers/net/Makefile +++ b/tools/testing/selftests/drivers/net/Makefile @@ -17,6 +17,7 @@ TEST_PROGS :=3D \ netcons_fragmented_msg.sh \ netcons_overflow.sh \ netcons_sysdata.sh \ + netcons_resume.sh \ netpoll_basic.py \ ping.py \ queues.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 8e1085e896472d5c87ec8b236240878a5b2d00d2..ba7c865b1be3b60f53ea548aba2= 69059ca74aee6 100644 --- a/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh +++ b/tools/testing/selftests/drivers/net/lib/sh/lib_netcons.sh @@ -350,6 +350,29 @@ function check_netconsole_module() { fi } =20 +function wait_target_state() { + local TARGET=3D${1} + local STATE=3D${2} + local FILENAME=3D"${NETCONS_CONFIGFS}"/"${TARGET}"/"enabled" + + if [ "${STATE}" =3D=3D "enabled" ] + then + ENABLED=3D1 + else + ENABLED=3D0 + fi + + if [ ! -f "$FILENAME" ]; then + echo "FAIL: Target does not exist." >&2 + exit "${ksft_fail}" + fi + + slowwait 2 sh -c 'test -n "$(grep '"'${ENABLED}'"' '"'${FILENAME}'"')"' |= | { + 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 0000000000000000000000000000000000000000..7e8ea74821fffdac8be0c3db2f1= aa7953b4d5bd5 --- /dev/null +++ b/tools/testing/selftests/drivers/net/netcons_resume.sh @@ -0,0 +1,68 @@ +#!/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. +# +# The test configures a netconsole dynamic target and then removes netdevs= im +# module to cause the interface to disappear. The test veries that the tar= get +# 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 +modprobe netconsole 2> /dev/null || true + +# The content of kmsg will be save to the following file +OUTPUT_FILE=3D"/tmp/${TARGET}" + +# Check for basic system dependency and exit if not found +check_for_dependencies + +# Set current loglevel to KERN_INFO(6), and default to KERN_NOTICE(5) +echo "6 5" > /proc/sys/kernel/printk +# Remove the namespace, interfaces and netconsole target on exit +trap cleanup EXIT + +# Create one namespace and two interfaces +set_network +# Create a dynamic target for netconsole +create_dynamic_target + +# Remove low level module +rmmod netdevsim +# Target should be disabled +wait_target_state "${TARGET}" "disabled" + +# Add back low level module +modprobe netdevsim +# Recreate namespace and two interfaces +set_network +# Target should be enabled again +wait_target_state "${TARGET}" "enabled" + +# Listed 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 + +exit "${ksft_pass}" --=20 2.51.0