From nobody Mon Dec 1 22:04:08 2025 Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) (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 E5BFB2E6CA6 for ; Fri, 28 Nov 2025 22:08:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.174 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764367699; cv=none; b=draafic4sqxUCOTFsju9YK6z5v7t55qZ2+vkBRmqFhqYBawy5jl3+NYvJaGi4GMJ+81vePTPWIdccKdrVxrVqARMdJRwaDAS/ELK2NCN6NUDgrmZ2OnjqEs4avLyTnN/2d9ILMYEY2OaK4Fr0a3Qs4BrjjBAp5+CpxobAckDK2E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764367699; c=relaxed/simple; bh=xTW7lVbfJsgnlziO9m7HRTBaTgvYhjTEK5XGbQnoB3Q=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=kMl2WRDYnX1RXnXEKzvQpCsCv97CMUQyDLEJanaeRc20thg8Y60Tl8ymKcfwAkBByVq87NDC0MlfJr/lrE05s/oHbGNd+6BGZcuX6kyXqXT5yjVTuRg+YS2kcH1h5n07K8TmWLlwXohGrU+9Mhs0QmxyAVfWuDAVknkt7Qb3msM= 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=lw56JsIU; arc=none smtp.client-ip=209.85.210.174 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="lw56JsIU" Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-7bb710d1d1dso3613309b3a.1 for ; Fri, 28 Nov 2025 14:08:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764367697; x=1764972497; 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=lw56JsIUvRfUzKE1d5p1NT9t5PT3FOx5kpDVfPjqP7xZgiO5K62KGeii5dJzuciG3q 4Jd37AqbQKcEYCM+/B5QIAwoQGJKockq8hmzTqpdakqsrEnlc2vXiSEqX7r1YHbDWLU3 UEvzBByZRG76sJEbrU3wtqYB1Tc+8eFxDjarVOjF/5PEsYIVtS1FiD38SyMTJ1q3njoe ObuNwFWi29D/thUpWr/fMFkFJKjRzLhHLkh/h/xroww8RE5jb8nr3moi4Z9PQID3U15z zjc4XnwLGQJsKQ0VYCRKuiKZerb4jkQpAH2xGFmHSOTOBcxkKHqL3KDzwWMrlGcsyJeH SV2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764367697; x=1764972497; 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=McmXbgfJcyf8uIG4v79Z7E4ScSCN971HWlzdxabgYYz6fCCKDxX7MeOBKEOCbSM1cN ZYqy+Kyi2m7zXLPVVVOmsHC86CU7LNX2F4bNntFqtAJ7lYwLP32+UKwlUD45j3py7YUI 9DlJo71Qr/5uO07o+id/ixylOlpbt4I8Z/h7ulsCCtIPXcFMUrRY+TIbzxLAcZ9EzWpo 0RM0Fwl+O13hqWtiQmfOML0JuBmcatvZidVx/0CZEICMJsrqg3v5b/GU8KhPbV7eZS3Z Q7DRtEgO1ZL+IwkSpH3Hc9WLHz2shkmxPx12q5w98EZZ3lj8bW7uIcbfHT+/Xhju5Hrx YjFA== X-Forwarded-Encrypted: i=1; AJvYcCXfxzR8pqsX6/MLpkjRrQI5UM8a3NC/Ktr2SFe+maipF9lvGHcavzPuL1L394bHIdnd8Br9nI8UGCh5xL0=@vger.kernel.org X-Gm-Message-State: AOJu0Yw2ZlNS8fJy98A2kl5MZtDHZNyla1NYsQvroM+XHXForPTgmy1n iK1UF3aB8FqyiG49PdnvDVivIp1PRuMe2XTZtHi36CFaBeYR1MhfDP3G X-Gm-Gg: ASbGncsI08pd7cQxj6QV/g8d9vCMra7vRC2S5CNZd05HXCX6JKcslDj3gmYbFpXMIBE qmMklY8N2VLOKR3wHP3mcOFtJj7O2qr5zan8ImTAR/C2L6CzAJ+p3+MYmILc+wpMh9IAyJCHSwh H0Fwe8hmlZ49kZyNSjUjuh+q5iUEJeuAOa9Jtkg+CTRy45NDuCsf3af6zV03HDNKqAu4PqB+bU+ 1YBgK9Icl5i4HZgUy5L/fMYzneEJQWF8U6tW+VVL8bjQ1nD6CvaQZl1L0qi0Ezlm0EoPhnpTiS2 NCg7piMywddscnPg5TwYAC9/lR8xVtB+VUGv4xQgcAmTx1qC1EIsApVClpiJ++3sV9RoyeXOQGm paHPVZmgup9PzmDFLzZqDi+K9kxYo/4FxQXuzDMP0i1h6PHM0Xxt1X+yFKFWlBiUptVVFUbPG57 OnyGOdL3Rzd0aW2t8ZjRksP/vGA811 X-Google-Smtp-Source: AGHT+IG96Ew3wIHjHCSFXG9Xfo5v4F9/EYogTuGNipjIquk4InZHh8U4hQ73L9WUMm2Wlf1t2d5moA== X-Received: by 2002:a05:7023:a8c:b0:11b:9386:7ecc with SMTP id a92af1059eb24-11cbba4d5camr10969807c88.41.1764367697082; Fri, 28 Nov 2025 14:08:17 -0800 (PST) Received: from [192.168.15.94] ([2804:7f1:ebc3:752f:12e1:8eff:fe46:88b8]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-11dcaee660asm26824205c88.3.2025.11.28.14.08.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 14:08:16 -0800 (PST) From: Andre Carvalho Date: Fri, 28 Nov 2025 22:08:00 +0000 Subject: [PATCH net-next v8 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: <20251128-netcons-retrigger-v8-1-0bccbf4c6385@gmail.com> References: <20251128-netcons-retrigger-v8-0-0bccbf4c6385@gmail.com> In-Reply-To: <20251128-netcons-retrigger-v8-0-0bccbf4c6385@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=1764367687; l=747; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=BLduFEel2At1ZpRoHzUB/43M6t0wpDLHJLh+eokOBeA=; b=OIwF8snp4GEFauU1eSsb5+HvWSBdPkP2AKY060QPoCIQ7XBogHbro5wfv+xHyX55HsWfAML6f AiOvBn4hEymBD92Ca9fBwjontME3X+tV4w+vxvBaULW90eNoORn+H+m 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 Mon Dec 1 22:04:08 2025 Received: from mail-pj1-f44.google.com (mail-pj1-f44.google.com [209.85.216.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 75A6D2E6125 for ; Fri, 28 Nov 2025 22:08:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764367705; cv=none; b=cAOJw9Qkf9gdK7dPALM20U7fJuSbaViyEqAB6otArVR9BwWp55VQpKGEuXqf01oO8hB5jzTtzAhCbQc93qaDDxyycXgx2J/ReAF0bPTZuFHAqHaIk0bLwpEr6sbrXVgz5Ii9MhEmD+4Yz/Tkt9omAl/tcHCkQShhgd49FPLiUXg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764367705; c=relaxed/simple; bh=ptkTe+cYKKYMyCNyu+hE6VVzhConXnPLG7fL2BaD9jQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=RDgmAg276MGa8TwaDVyQygcMwpdGVu0sfeU9U7JiJWM2VH5LITUu1jD9ihXyMJvs8xI/LNYEMiGaL/OGhlh069krD0soSrgEMheHRHbXMWOgbAhs8uvMfEvtM6G9D2pZXyYup18Dd9/05ClWxBmjD87tPyjgGoj3s7SD1rJx9ko= 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=g9lCEasz; arc=none smtp.client-ip=209.85.216.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="g9lCEasz" Received: by mail-pj1-f44.google.com with SMTP id 98e67ed59e1d1-343806688c5so1653715a91.0 for ; Fri, 28 Nov 2025 14:08:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764367703; x=1764972503; 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=g9lCEaszO/pNpq3lFIzmi5aixTsMV2ACZ8W61KmeqZCn3oSldMSayTy5vDeJIGiLE0 xk/2QGs/6jJEU3+t2nwGmU4xhRAKloVtLPu01tL7ccCXC4SnbtE6Ph8o3R5trQnYv4qy fWW70tfP20K72g4lx3+/BgvOsGQevZuz7q3antVYwxSfQtV3qj8XKGYM6Z56hNtMvXmJ le7cbXz08AHMifxzgV4czvzsrT4MxsFA5fB8/rE7reUHgDke3BT5e3pxM+/NHEWZ0bIA lmZHtHIMQHWqQKk+1AYrm/EWOMO+zyD231AHeBRahAomJIbU1PdMDvRpnHCN/kbuUnnw Jk6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764367703; x=1764972503; 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=wWNG0PIWAsM/cSAhsCZm7aVHbGrXpoCayT/P4JR+UZMwB58t3FNEIaOrzZKyxOdZeM cPv4tdnCYz0VgZrni1Smzyh2b3u+fHNgl8kZdzdX4LA5GLHrLh9l2+21hGjV8VIVUC+1 PVlMkGLpDHdEY3p9mh8Oi8jMX4tkSvjuwsSbnXuK5VmaLrrpWEJGCThZ9nn5u171qzDX ZNTABXM+vLuQaD/nhYCfxS4IoTQrQ3rP4RgI0ggV5mBl79OiK302PuG188MYmgu7qGFl bWpsQssgASPCvwjPnJVC/CoDJifGCYHH5DpVElx4d51FZ0lViAWS5rmZqz+8ZL9qLdcZ fRNg== X-Forwarded-Encrypted: i=1; AJvYcCXWaUyDvn09z4tNOc032MQqO12fk3kQjkOnSC7kYbS1HBTJpxUom62gc5al0wPWsQ6bshmVXKxP0rc/WOs=@vger.kernel.org X-Gm-Message-State: AOJu0YwiLlnlUiChNMreZUE8c7b5baHjqiJGtBoVOLpLX5JkPQnAxfD7 HW5SBx3gJpk9mk9r5bwryIHWhaoZR3oWgL6YVXk/gqP4Miw2MHx0DqlG X-Gm-Gg: ASbGncvX+a2gHeek+jqViXYSmbzhMlUr5Mp3HCR2MLDLjLtiAmlwoWki3wtyxeV9abY cvya8oF2L+ltCQR1ZR/hIrM8qwSabY6tTHSg3U9R0qeB+Nwm5Bm5hJaRAmjqgW3NuThdXHP6fjL ZlsiCfEu7iDy+LQ7aaRo03QSZtjAmtKK/V8J4Zan/JtDU4a/DljTvcZAREhMlpeZK/347iQNsDL 3wxo1y/WQp4D8Yb4bPmAxh+oxnydOpFdOXiF0G5TJHScItw4nVWRu5BRd+MbGDymviz5V6l7+oW SQuwsOD4fU7patLnKI0EkCf9T9MPGAhgogqOaLzmuFeQqg2UEuMnxA/cF+A6eRqtGWLJ1idO/dY 2speg6E2pXeK34XxtLRSfkuXWdQ7icQv9WhJq39D7Epi13iSxCyQLKRwIFsx910sSYFyqqgBPHB 8fJtsEMTmB+iotelpgmw== X-Google-Smtp-Source: AGHT+IFCyPkXqNys6uAkZE+IJh35Rc08N/3N8vJyNWXKGWOKVH7Xr53Z83YRRQ0woDnmCyry7S9QNQ== X-Received: by 2002:a05:7022:208f:b0:11b:9e5e:1a40 with SMTP id a92af1059eb24-11cb3ef2589mr7078926c88.15.1764367702419; Fri, 28 Nov 2025 14:08:22 -0800 (PST) Received: from [192.168.15.94] ([2804:7f1:ebc3:752f:12e1:8eff:fe46:88b8]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-11dcaee660asm26824205c88.3.2025.11.28.14.08.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 14:08:21 -0800 (PST) From: Andre Carvalho Date: Fri, 28 Nov 2025 22:08:01 +0000 Subject: [PATCH net-next v8 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: <20251128-netcons-retrigger-v8-2-0bccbf4c6385@gmail.com> References: <20251128-netcons-retrigger-v8-0-0bccbf4c6385@gmail.com> In-Reply-To: <20251128-netcons-retrigger-v8-0-0bccbf4c6385@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=1764367687; l=8948; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=ptkTe+cYKKYMyCNyu+hE6VVzhConXnPLG7fL2BaD9jQ=; b=N0iC28pdKpOX3PQnWuxgH4YK5Zy/KLhIszq7lgKe9xQ0sGuzSr3sPWnLAHjOcE0gqR4gPES5N 62pO073zvwUCus1qPNaaQhS+hoZxDcPxe9jH5b3U8fa/nmdQ5Z+rgfy 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 Mon Dec 1 22:04:08 2025 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.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 73CFA2E8E0E for ; Fri, 28 Nov 2025 22:08:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764367710; cv=none; b=IxaB7Dkx9KGwini9rG5LLoUshDXwx/b2JQufcxZ0D7rI6xrVLgQCfHBhgHZwbkj1IEwjNSP+zoS3lgl0Oovz5uE3Tsumg+C4LdXrgcImZetiNcxa4M5AHFnCcob6JTQMGFxVVB01mq9DVllyoy7PZs6xCWpybPuvpMa5AX32rtw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764367710; c=relaxed/simple; bh=oZlSrKc5HSf8OTgk8Y9zCO1ND/6B7m7anVTBiZTQDCE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MrgQ90Qkzb7V1RKgCToph0LzWHlu40aF85Z0tErzbjTkEmFl6b3egWDZWlW886kvrLLNuFj/Dpq49luhIizBAL1APo9h41YOpVa7ftQVcTOitlLo21cw9XRjZiH6rUsL+ZVZSVi5KKTsCMxCK1xD88t8mvO6n+JhfxR4iSDoLuE= 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=dGXJVnti; arc=none smtp.client-ip=209.85.210.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="dGXJVnti" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-7a9c64dfa8aso1930347b3a.3 for ; Fri, 28 Nov 2025 14:08:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764367708; x=1764972508; 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=dGXJVntiSZZidJaEYQWYuCXXdwg4QByX3kDzwShDuhfPI6XVLwcgUtmaN9qZbF5+wT Lw+x8n5rBVq91z55Q5bpvj2VClxgbo5oVz1HqtWViBrbRuZe8QppnsOmCLfBVuabEcsr BS1ByUHd+mc2eNZyUyi+OEgejnsULwit/q7wtX0O7l47kPKc6kaMRv99qVRh0Kn6kxAv 6HkAKiaGByk1Dwd6jTrE+Br2V3eh0xA8h/GLSEJ9+cdFoo7rJfqX6Vv5NdHdJLw0Q1HU 3nzQw4dZQgJNu7ISRaXqELscEzdNrTcgdhTbFAEjkkFe0MpPiS2yPurG8/dk3S/GHI54 OEqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764367708; x=1764972508; 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=DLml1wJm4LpxwOs/cJ2LsT2Xy1VoEpdNRbmZ+w8LL3ob0Js+/91iJFUVuf9a5Qirzd yh8uwknZUPStJEeVmDgS5s1MftNSAaTQmQuKcgPUIzKsHm4HhI69ZDz9VswyM586+D2A y6c5t8cMmJv3rKjcMvjp0LW50wIYX3r2d2KpGmZM2T+ei8dqzREiIyJXd64zEo3dSftU e+Djav19N7zE34oHdz4+1hrQo1xO2rwoA2zJSz0NhwQR+5KVcFLi8y7vrjCqYWk7aC12 D0gzBGxzzvkIPx6wmWrgfVtS9NrO9HDsLxut6fgLQ8AY96ZitplW2ZStnBLBa47+puAx tZAg== X-Forwarded-Encrypted: i=1; AJvYcCWeiRpZt3PlDGj1GJh94PqUVZzFvQK+P9fWH0ljAa4HbzTSYG+rbR4cqaYIJvxlkSHL13RyDJCPkhUsNoE=@vger.kernel.org X-Gm-Message-State: AOJu0YyA/p/LFwsTcQFFOGxe/mgThvXttW6HAnirqQLhOb6jz4blMOe1 N5nUWIaGNqZeeOS+4du5VcySQ2U0usQ44HQl1TJuEQ5s8WamKb0xIkRt X-Gm-Gg: ASbGncufIogjYDCdit1UutmTnnW0+J8aPUZXQZdNgSZ3Q419Q1jBcXnUIFCdbgdHJlr 6+LIROMadRUBTDbNZy39/8HGp583Gz7MB1OL8NLCk6MbGG8y3keSM3DVZKFb+JeAyhcSY9Do+MX nftNW6Hl18orilpnxexl7CGatOtxKc+ktTvVBOLBFtP4YqrWPVn86WMwCEUuIPiKb68+YWXrvL2 ElPbZhO8hiC3O76/GlIjyasnSkWEbY1ZX8SHx3HRmluEmMHDAVonuXSyXKXa2TycUZzh7n5ItWn SUBGc4hwILkZG1veu1JSNxqMxFcpZVu1SKmRI+h5e0Q5dN2r/o9HmQvPvHU5rOW6phXmvIAie+T DRjBx3OCIu36V+qBlYt0dj1+ezADRS8dYnzEZih+Rw4M+bFbpgOnpzKsJp8PuIHIKGN7cn2i0qZ Fttvdy+mHCee4kUyNNAA== X-Google-Smtp-Source: AGHT+IHP9cacM3sLthbsJDzciAEys52jMWZBJESkwrB9/1Buq/1iB5QinbxCfCe5nE75YPOMpByUNQ== X-Received: by 2002:a05:7022:1506:b0:119:e55a:9c06 with SMTP id a92af1059eb24-11cbba6f374mr13160663c88.34.1764367707518; Fri, 28 Nov 2025 14:08:27 -0800 (PST) Received: from [192.168.15.94] ([2804:7f1:ebc3:752f:12e1:8eff:fe46:88b8]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-11dcaee660asm26824205c88.3.2025.11.28.14.08.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 14:08:26 -0800 (PST) From: Andre Carvalho Date: Fri, 28 Nov 2025 22:08:02 +0000 Subject: [PATCH net-next v8 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: <20251128-netcons-retrigger-v8-3-0bccbf4c6385@gmail.com> References: <20251128-netcons-retrigger-v8-0-0bccbf4c6385@gmail.com> In-Reply-To: <20251128-netcons-retrigger-v8-0-0bccbf4c6385@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=1764367687; l=2409; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=Bc0ee9DYK1oiSRrahxYGeDv2Y4gYudwUsG3FQq7nt2Y=; b=OKYBLhWd1IZ93XaJ9r5FNHNxrv9gpqahkExk6+Sfgd6RO3fy3SSFjwyesY0i0145zbiJbCC8N kESIR+0Us6cCG4UmGvJUiw55zckCUS23UxCkJ2i8G9SSdcO+03E87C7 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 Mon Dec 1 22:04:08 2025 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 0D0302F0C7B for ; Fri, 28 Nov 2025 22:08:33 +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=1764367716; cv=none; b=mb8Ai9za4jJMhsvfTLImPZWTwpEHFIDJi6Jut2uiHopFXq32elCNoaZ1HdK819cI4KO640WNDKzyXMGh7epJgf3AXRIM2A8xO1U4fh0LFSwgENGqGvTGkCoyut8DNO4N1sNEmnzXf/IV59EWkAdDz/YOt7CalnecNzu7F+iHIHI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764367716; c=relaxed/simple; bh=uRxi3ExLlnech7TAng7vW1n1AwVuV0imGtM6odd89oA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Rh5em1ABRssA0hbZXmG5Pk+nZ45n9Ujr8GT9SP4o2G17K56YL0Xz9uP9HmPVLHgG0hzjTR/dfOsV+5HBcCANXWnR1FtasDPVCWv4faqnrjPJIiVnKscbz6pFV4qF9dqRjWyt3sAlQGA6G6icaYE1WN4bCqn4QS3zur6nrrw6dS8= 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=OvR96LBC; 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="OvR96LBC" Received: by mail-pf1-f182.google.com with SMTP id d2e1a72fcca58-7baf61be569so2706227b3a.3 for ; Fri, 28 Nov 2025 14:08:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764367713; x=1764972513; 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=qDEZdi1tgBa9T8trLOVAUVe2SLe1h53tBsuf6xYe7Gw=; b=OvR96LBCEuLEs9iorkIUlykmtzVgQZKMsTfp0lY38ObY/tNzfC5c7imFzwRpQPvK6R AikL4RQ5uCA7xW2ZAJvz2KEQAhdB6g1vj81edaGpNAciBDTHBdNyBIb9bhXt+JptWYmz jIVZL9AH7mj2ISVXowiHaOOGDDp2FojHW6r9/Uwik1FDIfzKqFxSICn94wJWPrAOdqDA p6yTXiWenkjOpUR4uxpnTo6/4tSku0BTfDhGEyyYWZ6jXXpd5s5KS854TEcsGk5FAkti ia30q87LvhiPkMTNcry2DmJYYtGmGjtYnpcnQNhb7x8TDL9HicRPbg3nuKu3TOiH6CdJ YNOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764367713; x=1764972513; 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=qDEZdi1tgBa9T8trLOVAUVe2SLe1h53tBsuf6xYe7Gw=; b=b3O3ffRL90+CXUxmUpWJfWTgd4mB1Qd8C/vtFosTa6Q+R8KyGGzqS17thkw2QT33uZ S63l0wmR2iZQnmDls/fZEp4EFKgR4bzFCAWRmgDDyzDnU4qot0mSsfeoNbTevj3t5o+Z mn9Q9mvnD+P7PB7utWZ8iGz172Kle5N6PCA4TNl2xqgCKYIL9apVbu0BzqIbbK6iIX76 f6sHFh92vDLvy0aT7Ul+Qzd1Uiysg9lfY3bzyxULiFCWVvv6e5ZOVzl/sKW7FkBQhTr4 e8/GuWOMVGSLFhT28vhl9Dai6Q/TtZDUd+qHywXMKInMc67Wn4WSLHf8MEJihThZsE5I J2lQ== X-Forwarded-Encrypted: i=1; AJvYcCVt9ODizRTHTxGPMtO2fxe2MQ/uwU9bN6o/NRfDRL26OLTT98tMR1QI+++WxHqd1abPm9kmHmtaZIfddk8=@vger.kernel.org X-Gm-Message-State: AOJu0YwDYljzmbCEPKIc8K0wuJVEpZZ+zv8zC+yHWzOTAN55n9imN+1m 4X3KKHqe4uaQs5KwqY2EDAjLM9e4Srv+a92tGaf7oILJ4k1Z8ijnLnHL X-Gm-Gg: ASbGncujYghD2F8p86tNYKuIBOD7gyjKdezDjEv0bvgvMWifQGAZeedFnziBmVm9mhT rlbvgQPZsjZtEQlJzfpcNYe4gXZI+NyJxCMyz/gcNSG2wHSpFZxxt3QRaiwSynksUExxhINft+t y9guTCvqG6cO0NIHL4yhmcSCTX+UxFiXvtE91lj03xt0K3B6UkclWmEMVsq47Q6jbfAUnCObhJi /rMy0n/LnjYlp7z5aMoy022Z7ek9qKFn7H+DeG0Ji78XMS5DPo4Z74EoSRppScpsMSHCR+XX5OC V3n2Xe54AojK2supMzVK2zFPCrrsN5bRh3jLQUqJ2egW7CKUCBX1Jknz94w0olhhX9cqeNRPC7o dju5idFZ7x9SxAKTsIU4l3cAPqzc9eC0kdwgVnXbPR4DIJb39kkWH4wVaOnNhOcQtoL37bpp0OU lPN9HpyMztEhzKwLNFZQ== X-Google-Smtp-Source: AGHT+IFA9W0tMqiQpDtVLv/EbbD8yYhv0beq+7UKoKsKuyIshhuFT7CV1u/tP795KYKT7Al+rnAVxw== X-Received: by 2002:a05:7022:e19:b0:119:e569:f262 with SMTP id a92af1059eb24-11c9d7185c7mr23676868c88.11.1764367713091; Fri, 28 Nov 2025 14:08:33 -0800 (PST) Received: from [192.168.15.94] ([2804:7f1:ebc3:752f:12e1:8eff:fe46:88b8]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-11dcaee660asm26824205c88.3.2025.11.28.14.08.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 14:08:32 -0800 (PST) From: Andre Carvalho Date: Fri, 28 Nov 2025 22:08:03 +0000 Subject: [PATCH net-next v8 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: <20251128-netcons-retrigger-v8-4-0bccbf4c6385@gmail.com> References: <20251128-netcons-retrigger-v8-0-0bccbf4c6385@gmail.com> In-Reply-To: <20251128-netcons-retrigger-v8-0-0bccbf4c6385@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=1764367687; l=6908; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=uRxi3ExLlnech7TAng7vW1n1AwVuV0imGtM6odd89oA=; b=w3CNQpU1d93HMFlJIEbcCmw4xQefnx6kAgjeL7PNL7v2SW3IdsAcZMJzYuuaAGa0ZVkmwlMrp ISLZAq7BdS8C3Vvg3+B6oERZ7/3BwR4XG2LEP4vPgdYbEeUCcO8Xgcb 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 | 98 ++++++++++++++++++++++++++++++++++++++++++++= +--- 1 file changed, 92 insertions(+), 6 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 7a1e5559fc0d..b31762f2ee45 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 @@ -242,6 +249,75 @@ 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); +} + +/* 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; + + if (bound_by_mac(nt)) + /* ensure netpoll_setup will retrieve device by mac */ + memset(&nt->np.dev_name, 0, IFNAMSIZ); + + 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; + + /* 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); +} + /* Allocate and initialize with defaults. * Note that these targets get their config_item fields zeroed-out. */ @@ -264,6 +340,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; } @@ -1434,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); @@ -1469,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); @@ -1937,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 Mon Dec 1 22:04:08 2025 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.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 D94D02E8B7C for ; Fri, 28 Nov 2025 22:08:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764367721; cv=none; b=LaIukGaW++kwD8OWWLuk4OCob1Z+i67Wiow5s6ap1RI+a02ijkgK0OzJ3m/l/NJnGzdHXGF5xueT/gaMMN2opNfPxIMeYVN9lQsGxvgXEr/h9TF8huC7szCrF9ydfQ3uRTj01EElNxvzCtMCFCCzZK7HLSNUKbzihsRa1GsA2Pc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764367721; c=relaxed/simple; bh=hn/kxg8v9iI6fPhbZcD8Tj+G//s0QmgoWLVA/hu8hV4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LSCuLxWG2hNLr18BkIyZDiiD6mUGJihzHm0yFNCIbtYzq9ZyvnXK8FOUGVF+rU6tKjdqcujFbMAJv+vRHrbu3tFNJsfIgXAckr1ywYe2XLC63GuJos2vA7BOzxE4BdTU1O6hhNUYBfewD4A/JjHviKVuhHV8Ju1WGrF2XG1hyog= 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=E+qFHD+U; arc=none smtp.client-ip=209.85.210.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="E+qFHD+U" Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-7aae5f2633dso2737638b3a.3 for ; Fri, 28 Nov 2025 14:08:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764367719; x=1764972519; 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=3/fAPe5zn1MJUzjr0NdBaLTd5ohKsQq+JKoQHPiFo9E=; b=E+qFHD+U3Qx0NvVgJkjGAto3C4uPyVjVbHCApsEOUSyV/H2yKoelUWvpnua3NnA2uS R6QWxiSj9Hep8AieHC4c+WF4ZzLU2YjMGk8+aTkCWTvhc+em6Qx4spq73sqtFrJvcLY5 afV9jsvgyTYK2V1C8hyeVOPlbXdmO/FdLpgcQMKWR2LvxktBW2LX+FzCWqu2SyOGHH+W 2SH5kC4TV0G9Jgb9T3m3JG+DdQzjLSMHYfq2ImIQHYBM5cq/tPWcM0Qv949FCc8M3YtS JIdcCvroOHLsj3f6krgjSb5Jej0lrJT3seXVUXoLIN5JfazcvMjH5ZFkp1FATlJzWZ3a 3C2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764367719; x=1764972519; 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=3/fAPe5zn1MJUzjr0NdBaLTd5ohKsQq+JKoQHPiFo9E=; b=FDGdr4H/Y7Ss1rz8FaQetO5Z4cktsH48Io/+WdPunBBxJ2Snqh80cTa4bU1HymIGjW dsQ3d+Uu2MgZCWi9etnfsTzixJXqe46gKxMex7AdSP5PMduyYj66Nh1JLyYtXI4CgmF2 DIRig2sS86uegO86HX7NcAlT9RX9Ek1PUY+xgblEyyxHYbvO96Y6uIa7xvWZI5tzdRcr dziUngLalXsRo+8HMtpM3dn6Bn/UJyKpGxIBpuyo9YG41rop2kglyKBJB96dyD5clTUN vL9ylO2/YcV/Ki++LnXy6469ZG71uzQB9ZEy0YmBoqj6DHSn7NvYZyyQVnLBxJYzFevb 64/A== X-Forwarded-Encrypted: i=1; AJvYcCXxuMz0NFZnMORmMJ4hGFKxyLbPAL9dF/umyvosEAlA/ThSWqVve9FACJe69HK4i0DWppDA3vPVxY1BeNY=@vger.kernel.org X-Gm-Message-State: AOJu0Yyq96LOWhQXENBmGy+WPAR1T39qP0QLLgvGCLDDb+Na35Ia1ytD 8T/Ayf6GihGPboMS8EuYS3oxG5OtmqmiA46r2ztmIZG+Hn/gYFjRJ+Ux X-Gm-Gg: ASbGncuLC3qQ9C0ZhZ+A8/MQcPubvqu5EuhZFzRngUBHlRqgn2LeRBk8/jTtsiGKIPO yr4SdPMWMlJZvd8f4KmlwRKIs4O2jRBk8dld8YqiSiNWPDGzA833j8bfOEKd473WfgIHHmwQCm2 0aeBk882QGwI+93fU6ksrtT2gU1LKB4c6vYdVND1Rg1nGrk6Xqk0iQAUhzJksJ5114z/G34UYf+ 01+b7Crib0TBSsMvmR09Vi8XCco3oayFW9J2P5fAnI40lJemlQgwL45+xbWDzBB/bVVOg3sepSr 0ogUYGgoTGGCVlrjw6PwXcyEZaVMx5avz5nemhTjCESPmGtY/+QBU/bk3Fdg120GlIBr0InGFka NsJeTsI451Bbd+N1xW+RBb08kGKJoaUpfGmaSDmeIMBbKYch3KqIGY3IoESX0k9Qby/KkzBIqFz ipYNYQMnYv8ig2+yz1yQ== X-Google-Smtp-Source: AGHT+IGHZEWFQ0KjoUVeTZE930c9/q5lskB5MxuqjPefp4lXxRMi5yyhmjD7WBYkTxgYnWwGS6AQuA== X-Received: by 2002:a05:7022:f691:b0:119:e569:fba1 with SMTP id a92af1059eb24-11c9d717970mr22737261c88.16.1764367718821; Fri, 28 Nov 2025 14:08:38 -0800 (PST) Received: from [192.168.15.94] ([2804:7f1:ebc3:752f:12e1:8eff:fe46:88b8]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-11dcaee660asm26824205c88.3.2025.11.28.14.08.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Nov 2025 14:08:38 -0800 (PST) From: Andre Carvalho Date: Fri, 28 Nov 2025 22:08:04 +0000 Subject: [PATCH net-next v8 5/5] 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: <20251128-netcons-retrigger-v8-5-0bccbf4c6385@gmail.com> References: <20251128-netcons-retrigger-v8-0-0bccbf4c6385@gmail.com> In-Reply-To: <20251128-netcons-retrigger-v8-0-0bccbf4c6385@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=1764367687; l=6537; i=asantostc@gmail.com; s=20250807; h=from:subject:message-id; bh=hn/kxg8v9iI6fPhbZcD8Tj+G//s0QmgoWLVA/hu8hV4=; b=VBxaoFHaw3juwU/yfhuN3hXGZCPa6kWgBe5dOdchPvA9SX5oc+t8abLbQaC4QQ/ZJ/0ZDfq3+ wGabWcqagPaChRFU4W0zBmvb/ijfQ9oxfLm1jS4CsFar1iUVhOsE6yz 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 87f89fd92f8c..239f44d4a45d 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