From nobody Fri Sep 25 10:05:11 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5D92635DA79; Mon, 14 Sep 2026 12:10:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789387840; cv=none; b=BC/z+nf46Sf9tb86yiK3KH9Jr9tb+efqjYmrUN9d70Qdt9UKdzV6zR0pdVDfZuvoaa6ayF5GKGa9eOR3Atb/vmKecvXD+URpTd4lw373ebnJKYpR7aqeSwGjtjaMs7bTrFQ9zTAci6EK+MW0zDq3rwHj3dJSl/UpGdsWczbSBp4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789387840; c=relaxed/simple; bh=F1mp269SJrZ9Pvz2cWbJ0FKS4STF7zDk96eGRxgxnrY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EDIF2m6CrXdrr1i+rnX5T8+uR+2b+3JY3P37gjCyzxKUFU4c/xK7qC9mpamMRQNeYUcsZL7mQHrr2N27IJLA1bkGQXE3zqtpau5Ykiib3FEel5cio069W+hZxhGKeGuJ0EcXZNtdhyt6FsiO7Ge/a4LucQvw3m54Jv/eRyi9jYg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=tJ3Jkwnt; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="tJ3Jkwnt" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=mZu/Vs5nOQG7irnIZ5aI4mnkQoQp5lbpNJctZOHfslc=; b=tJ3JkwntiFYK6DWmvACoCteIuO x0xBT1R1VCVqe6fAsFwr9S+Os9ReN4udNHvFJg/vefrRUNM1LzhRM4PnPeQC70jAi32HBcsScF5vV 8NloT92J4TgJh2/SrYQmUee+1HsIoBznAfuIC4OltQVUnSUPoAeYYQrbJgg47yoM9W2fUhCPzuqL9 DgbV38UpTgWzx5ZgakgFBVr8bZ2JO/fpXjD2eQeH8UtcGsDFkLlv5U/DpOlGSbun9RZ7f3CKf1tLW sCuTbfHzktQOF4167gc4CB6FvpI9nYFPLn3iMfWyO8kDMtyo29IexqwBv9QZq0EnWD1ivXuownh+y qsTUKKGg==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1x65W8-003bYq-0k; Mon, 14 Sep 2026 12:10:36 +0000 From: Breno Leitao Date: Mon, 14 Sep 2026 05:09:51 -0700 Subject: [PATCH net-next v3 1/5] netconsole: send the oops when oops_only is set 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: <20260914-netcons_ratelimit-v3-1-8e81b789ab37@debian.org> References: <20260914-netcons_ratelimit-v3-0-8e81b789ab37@debian.org> In-Reply-To: <20260914-netcons_ratelimit-v3-0-8e81b789ab37@debian.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan , Shuah Khan Cc: Randy Dunlap , paulmck@kernel.org, gustavold@gmail.com, asantostc@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-f8e9d X-Developer-Signature: v=1; a=openpgp-sha256; l=2809; i=leitao@debian.org; h=from:subject:message-id; bh=F1mp269SJrZ9Pvz2cWbJ0FKS4STF7zDk96eGRxgxnrY=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqp+Qxup9S5bWbD7lHUgfQFCPZDlDcmeyK7qufo VdqUxbP86GJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaqfkMQAKCRA1o5Of/Hh3 bWq0D/wJBOePDkhusz+9f+T76E90flKTzGSNyRgmzJvCBCyYuQuBzRy2Nj1ErNZT8dItZlZBVUB yJtEuiNm9GAdFHfLP2ghsTqrztMHV+Do1P+U8sKSHaM9Ir0cHvA2drhAZT8gcbXljnPNjR6P5HJ N22QWIVS/FWKGNaPaGN4jh2YIp+q33WuYjhp0I980kU+wZuzkdnH1HL8PC66RkiZtztb545RVef TLXEVMIWBPHM5RU/0CtSa7ygecQcG0Asu0FRxsIYx+PAHI/h5PS9Gwt0lWpSuSis2m2iok8aTMW 5mYt0vBL2/el4Eu4nBKWUrgsFPX/ustMxhnbDBV8v4AEvoiM4d7YDuBLcTcHvhz8E3xzzo9PEyv 9W+pn/wE47DBhI5ME6yxg5xfij35+G9yiZQX2gsQsZLe1l+fhUxXpjCvPfvPWrq/QcGI/2V2DtY ytO/rh1iqHHC5/XP+0q74i+P9WZppO/wGCzSPAhLf7U3cVzJzzrRxNdf4CTZA0iJ/wE0gttdfRt 9/iKNJboKGrQ9W1LnCs1qMxWiqzcOH3rHCqvkrcUP5LG1Fg+nuH5nyDEEA66hZb/T7uX5JMqNk+ Ixsw2Ab4gOBZ0X0JYVd60fpF8qmnWVh+f8I0suglZRMzwkjpMnijeG/+lywMcPhhJo2/Yp9VW5B NO8M5dPj1atGVIA== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao A target running with oops_only=3D1 receives nothing when the kernel oopses, which is the one thing the option exists for. Only a panic still gets through. netconsole_write() bails out unless oops_in_progress is set, and that flag is already gone by the time netconsole runs. netconsole is CON_NBCON_ATOMIC_UNSAFE, so console_is_usable() keeps it out of the emergency flush an oops prints in, and the records only leave the box once the printer thread runs. die() wakes that thread from oops_exit(), by which point bust_spinlocks(0) has cleared oops_in_progress again. TAINT_DIE is set in between, so test that as well, behind a helper. With oops_only=3D1 on a netdevsim target, an lkdtm EXCEPTION produces 44 lines of oops. The receiver gets none of them before this change and all of them after it, while ordinary messages stay suppressed. The taint never clears, so from the first oops on, an oops_only target sends everything instead of going quiet again. Sending the aftermath of a crash beats sending nothing. Fixes: 7eab73b18630 ("netconsole: convert to NBCON console infrastructure") Signed-off-by: Breno Leitao Reviewed-by: Gustavo Luiz Duarte --- drivers/net/netconsole.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index b358e5c3673510..833da29717ed1d 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -83,7 +83,8 @@ MODULE_PARM_DESC(netconsole, " netconsole=3D[src-port]@[s= rc-ip]/[dev],[tgt-port]@< =20 static bool oops_only; module_param(oops_only, bool, 0600); -MODULE_PARM_DESC(oops_only, "Only log oops messages"); +MODULE_PARM_DESC(oops_only, + "Only log oops messages, everything once the kernel died"); =20 #define NETCONSOLE_PARAM_TARGET_PREFIX "cmdline" =20 @@ -96,6 +97,17 @@ static int __init option_setup(char *opt) __setup("netconsole=3D", option_setup); #endif /* MODULE */ =20 +/* The kernel is dying, or has died. + * + * oops_in_progress only spans the printing of the crash. netconsole is + * CON_NBCON_ATOMIC_UNSAFE, so the records reach the target later, from the + * printer thread, with the flag already cleared. TAINT_DIE outlives it. + */ +static bool netconsole_kernel_dying(void) +{ + return oops_in_progress || test_taint(TAINT_DIE); +} + /* Linked list of all configured targets */ static LIST_HEAD(target_list); /* target_cleanup_list is used to track targets that need to be cleaned ou= tside @@ -2474,7 +2486,7 @@ static void netconsole_write(struct nbcon_write_conte= xt *wctxt, bool extended) { struct netconsole_target *nt; =20 - if (oops_only && !oops_in_progress) + if (oops_only && !netconsole_kernel_dying()) return; =20 list_for_each_entry(nt, &target_list, list) { --=20 2.53.0-Meta From nobody Fri Sep 25 10:05:11 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1E90444A72C; Mon, 14 Sep 2026 12:10:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789387846; cv=none; b=fTtZ9E2BruOOrhGbXHtDBt1LcN67RAOV5hxu4n5lFDx+UtSx9cfBtics46fnDuFiUsbb/U6jY0LQaah9Km7aq3WEGU6gwmGFESwrFcB7JuMLRfjsB8ckvpk2GO/hVhu/BvFbCTOLllKUeHTeu6K8/YBZ/OXs/VyuwnVGNvpAIB8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789387846; c=relaxed/simple; bh=cpmQcxGuCsqpL2FWjhLOvXk3o+1MsiFVU+67fFK602Y=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=BljqBWCLKErLVcIyDsgKK1x9JuewfJUOh4p2uIxSl2nQ9Hmgwhkc/qekhbRIlcruKSS4ygx6ppXyPmElmr3rYhkzjty90E/Jua/x6OYlFA0hC+AHQFWJAZrfLmevBV96o1axDsfK0B2/DBIJ8mDa+r6GgB1SWhXrJ5Dp+Pf8noI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=RMtoEGG8; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="RMtoEGG8" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=v6GxCrbwntxQGiCi6ExZJmvVyBpKpf0qD6c1T1VcByc=; b=RMtoEGG8t/4TlO1cuQyRhc+I5n ia8fG3oFvEdmVI+Iq6rKKBroFFtMUd3jlJzo/NdAgW9Ex89qioepbuyq18DZCkJatoueleYENcAUr 9vzMqWmTDSQoX/3mjkJWwnmi5lQ1zbm2VqddU7Q+1uVkobG7mM0s8trCBRQvEdoOs+laWG8Nhdt8P dILNlDNNNqXJJl9woc17N+FwuRD21oOsJeTn1gkIz97VVmavhuPRZuMZZRy46RmN4U26P/UdOBDhZ QQ+42qkdlSDox6+7mJ264DXNbNzFJKrk7FKNJ71JkR51Xl3Xc9R2KtmHPoSQ9IS1+CyEdL1a4coNP g1ATNlQQ==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1x65WD-003bYw-0w; Mon, 14 Sep 2026 12:10:41 +0000 From: Breno Leitao Date: Mon, 14 Sep 2026 05:09:52 -0700 Subject: [PATCH net-next v3 2/5] netconsole: add a per-target message rate limit 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: <20260914-netcons_ratelimit-v3-2-8e81b789ab37@debian.org> References: <20260914-netcons_ratelimit-v3-0-8e81b789ab37@debian.org> In-Reply-To: <20260914-netcons_ratelimit-v3-0-8e81b789ab37@debian.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan , Shuah Khan Cc: Randy Dunlap , paulmck@kernel.org, gustavold@gmail.com, asantostc@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-f8e9d X-Developer-Signature: v=1; a=openpgp-sha256; l=4127; i=leitao@debian.org; h=from:subject:message-id; bh=cpmQcxGuCsqpL2FWjhLOvXk3o+1MsiFVU+67fFK602Y=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqp+QxtS9uEIDU3gN2gXsniyP3CBrK3X7wrbX1a xzj6DdmeACJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaqfkMQAKCRA1o5Of/Hh3 bQhzEACs1hVz1YViAq+iVDXuSAAsuyd5wcgTsrUcIZkgjQU4w0jZa0On06Kcs0qlS8Rfgrink7n U59r7dBSxupI6E4YPB5zCuSHunM3UVxUigsoqz5Z/AoQZNj08zxuCzfr/BuEsZ7QCzuty+q2i6Q FoHGfas6VRwxV9faDlis8uKibC279LYpnItRGKN4FN+d05feGj2J3GWwklR8ghSHrEFV/e9oPe1 8/YueIffwTLzOWw4QW+sBHZrImjEJLqXPVXuFGDg1cqCYbsoBb7/FT5cqNfh+ifTR8TCPGL5GmP xxjo2TqFBj+xrc9t2xDKEMXMh0ytizYsCvEUoU/KvvnBoY9MZHrsbgfH4mDApfY/lEsyGKokM91 xRIqSCcfMiTS/EXav27BEgQl2tWxHatYdKeQKXLtUr9T+bRw1Odt36c8fe4xC0OIxKbySoYBbzM cweVNb3uK+yNIztLBv5YZp7rZEtvyKoxPhciLzIjfwmYKPfOJQlZn+eFtYIzSq5l4dGzmaobQRH +V4Y0ILuFfb0LifYq3PGLxB3A9Kd9rIkZKDJ8qXGFN7xZeVEvsxbav85FZXma+JDZKpIQojgi9c upu4pia74hJPnhQHb8ARVZ1UOF4cW/MEdHXnLszQKyBXHvOcwQioCqn6WTEwbQylLNmCqTYSjqb yaLe3pAYqpsXwnQ== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao Give each target a token bucket and consult it once per message in netconsole_write(). The bucket is created with a zero interval, which struct ratelimit_state treats as unlimited, and nothing can set a nonzero one yet, so no target changes behaviour. Skip the bucket while the kernel is dying, reusing the helper the oops_only fix added, so a limit configured for steady-state logging never truncates an oops, BUG() or panic(). The configfs files that expose it come next. ___ratelimit() only trylocks its own raw spinlock, so it is safe with target_list_lock held and interrupts disabled, and safe from NMI. Set RATELIMIT_MSG_ON_RELEASE so it does not report the suppressed count itself, which would printk() from inside the console being serviced. Signed-off-by: Breno Leitao Reviewed-by: Gustavo Luiz Duarte --- drivers/net/netconsole.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 833da29717ed1d..c1c92413c0a5c5 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -49,6 +49,7 @@ #include #include #include +#include =20 MODULE_AUTHOR("Matt Mackall "); MODULE_DESCRIPTION("Console driver for network interfaces"); @@ -187,6 +188,7 @@ struct netcons_userdata { * @sysdata: Cached, formatted string of append * @sysdata_fields: Sysdata features enabled. * @msgcounter: Message sent counter. + * @ratelimit: Token bucket used to rate limit messages * @stats: Packet send stats for the target. Used for debugging. * @state: State of the target. * Visible from userspace (read-write). @@ -231,6 +233,8 @@ struct netconsole_target { u32 sysdata_fields; /* protected by target_list_lock */ u32 msgcounter; + /* carries its own lock, writers hold dynamic_netconsole_mutex */ + struct ratelimit_state ratelimit; #endif struct netconsole_target_stats stats; enum target_state state; @@ -294,6 +298,26 @@ static void dynamic_netconsole_mutex_unlock(void) mutex_unlock(&dynamic_netconsole_mutex); } =20 +static void netconsole_ratelimit_init(struct netconsole_target *nt) +{ + ratelimit_state_init(&nt->ratelimit, 0, DEFAULT_RATELIMIT_BURST); + /* The flag keeps ___ratelimit() from reporting the suppressed count + * itself, which would printk() from inside the console being + * serviced. Nothing calls ratelimit_state_exit(), so the count is + * never reported on release either. + */ + ratelimit_set_flags(&nt->ratelimit, RATELIMIT_MSG_ON_RELEASE); +} + +static bool netconsole_ratelimited(struct netconsole_target *nt) +{ + /* A limit meant for steady-state logging must not eat a crash dump. */ + if (netconsole_kernel_dying()) + return false; + + return !__ratelimit(&nt->ratelimit); +} + #else /* !CONFIG_NETCONSOLE_DYNAMIC */ =20 static int __init dynamic_netconsole_init(void) @@ -330,6 +354,15 @@ static void dynamic_netconsole_mutex_unlock(void) { } =20 +static void netconsole_ratelimit_init(struct netconsole_target *nt) +{ +} + +static bool netconsole_ratelimited(struct netconsole_target *nt) +{ + return false; +} + #endif /* CONFIG_NETCONSOLE_DYNAMIC */ =20 /* Check if the target was bound by mac address. */ @@ -698,6 +731,7 @@ static struct netconsole_target *alloc_and_init(void) nt->remote_port =3D 6666; eth_broadcast_addr(nt->remote_mac); nt->state =3D STATE_DISABLED; + netconsole_ratelimit_init(nt); INIT_WORK(&nt->resume_wq, process_resume_target); /* Set up the skb pool primitives once; enabling only refills it. */ skb_queue_head_init(&nt->skb_pool); @@ -2494,6 +2528,9 @@ static void netconsole_write(struct nbcon_write_conte= xt *wctxt, bool extended) !netif_running(nt->np.dev)) continue; =20 + if (netconsole_ratelimited(nt)) + continue; + /* If nbcon_enter_unsafe() fails, just return given netconsole * lost the ownership, and iterating over the targets will not * be able to re-acquire. --=20 2.53.0-Meta From nobody Fri Sep 25 10:05:11 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85FCC46C4DF; Mon, 14 Sep 2026 12:10:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789387850; cv=none; b=GzH2NifhM4nXfo7IocxKDbdjPPt3TuEqYxb5q+eBWa6XJAeXpdGYApT+cfDNOaM7yqKZGHTB8YXAHYwqAL8g2q5wVNLRJ9I21hj1aSIYfcAmAvdR0WvpVISEwCZwX82O3wuJLDIPp7bTQNFJQuAkTJlYJkesfql3HZd05m7vPD8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789387850; c=relaxed/simple; bh=vIGkiylmy9t40EZOeJRY1ap/teiPp9QU6ZMsk+qBM+A=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bqOsPrOHv7vnQaTwk8/vqxZ92QwADxgsmI6GWXF5rWqXHcXagGvoe6RhXYES6WtpY7GXqZlvUXQdmkDeDoEanip06MyWwpW7QHRzdHnyxhAklG5sxMds3You6oV/OojOfFBqOOkAay/r9+BXUeQzv6tjYEOCgSnTvX3uJGrITo0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=oYMOHtlb; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="oYMOHtlb" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=fIABMr7eHwYcEaguutUoj/lfdfqUz7CoJUcQ0BuphlE=; b=oYMOHtlbbiQn8ts1/0P+0MrsLv b0uMynE1rr+CHU2fSHmVHPp7UWJDoiNBvBSE172Jo/WcF1FMEQGgeCQ8lRN2DCpCFlwx1vBs6Jzla 1wAQCjjYIiFKiwN21uWmIhGb/nq1skcHPwJKGV9VIE1Au3qs1vypdQ0tyuRKC6q2+4mGvcWXGn5aD OOWuuiIZRSv+9u6666ym3+xM8i2R/+umBGXWcxVoraaaL5OBTFcGj67JtmaiMmCZPGv3G5R96uWeN hDwdcNhc9OdnoYIVlctnxcEditY8ZoMF2oPnjn/nE8B6cDhtU6J2cYr34CxuAwkghp73hpIiPUcI4 PBiEmYOQ==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1x65WI-003bZH-0i; Mon, 14 Sep 2026 12:10:46 +0000 From: Breno Leitao Date: Mon, 14 Sep 2026 05:09:53 -0700 Subject: [PATCH net-next v3 3/5] netconsole: allow configuring the rate limit interval through configfs 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: <20260914-netcons_ratelimit-v3-3-8e81b789ab37@debian.org> References: <20260914-netcons_ratelimit-v3-0-8e81b789ab37@debian.org> In-Reply-To: <20260914-netcons_ratelimit-v3-0-8e81b789ab37@debian.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan , Shuah Khan Cc: Randy Dunlap , paulmck@kernel.org, gustavold@gmail.com, asantostc@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-f8e9d X-Developer-Signature: v=1; a=openpgp-sha256; l=3163; i=leitao@debian.org; h=from:subject:message-id; bh=vIGkiylmy9t40EZOeJRY1ap/teiPp9QU6ZMsk+qBM+A=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqp+QxaUnbwmp6BHkhaGDjMKNNVGyuFoFzYON1I 2oR2VQS3KGJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaqfkMQAKCRA1o5Of/Hh3 bV9AD/90MDsf8XUFTSB6aUW/2b6AYxnWJiatWfaSNOheFh7Q7nWCnB0+hkcpoduV08LS4mZNoIl WViaJ/u53glL9RopcjczjOGDG92fO8HpQCLIuUPEdu+Lvk8Pd4XZWGZA0hYq5OGO0XGXQNqFnW7 4R8/eqIctTTOW6yAanBvIgvjY3X951wS0poIpsN1/LFysWioWU8QsK1gEJGEEJX4MNwZ5AbYAIb dJFiib6G/ATz+hes+UOxKZ5fm2F72eXBL9cHgEyyIaasXP9/+GfTVyDOhHDXFx2A3MLWQd6r/FX +68YbbypRifLGYxLb1N0Mw3yy7J0LPvyVSx3RJrnganKeOQ1XC8sUVFtJMW9ax+AtZXXewmj0M0 kHt8u5Y1WcTcYUO68L1GG0GkQM84W+AEtta57BURJB2G5hoiuu5XNz5yeXviMaTLxGKU4FyuiCL vhiYkTo3Gokv/EL5SEm4qzZlYELrQ5zux/mrXUAmZl0xJJZ16s3PB2WHx4Q8wL5dvD8jXIBmJKn Udu2+iOk5Sf6Rut6JlIq99s54h/I+2vMHH1lGIEtl8zbzqtDglsw65mo+AxUFTRboqFHYQ61hTg gJAI3FxAMZlEKZ3X3XHMvifmUyXwFedxJhXzfv7qwvDl+k8Zm+BkkCYhLYxzDM7lL4NaK7tmwX8 zgUWIq/SCXMWmbg== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao The per-target token bucket has no interface, so every target is still unlimited. Expose the interval as ratelimit_interval_ms through configfs. It defaults to zero, so a target stays unlimited until an administrator sets one. The write restarts the interval instead of only publishing the new value. A target is configured while it floods, by which point the bucket is empty, and ___ratelimit() only refills it once the interval it was set with has elapsed. Reject more than INT_MAX milliseconds. msecs_to_jiffies() saturates at MAX_JIFFY_OFFSET, which is below INT_MAX on 32-bit, so checking only the jiffies value would take a write there that a 64-bit kernel turns down. Signed-off-by: Breno Leitao Reviewed-by: Gustavo Luiz Duarte --- drivers/net/netconsole.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index c1c92413c0a5c5..d4e3ac272e9b4a 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -958,6 +958,14 @@ static ssize_t transmit_errors_show(struct config_item= *item, char *buf) return sysfs_emit(buf, "%llu\n", xmit_drop_count + enomem_count); } =20 +static ssize_t ratelimit_interval_ms_show(struct config_item *item, char *= buf) +{ + struct netconsole_target *nt =3D to_target(item); + + return sysfs_emit(buf, "%u\n", + jiffies_to_msecs(READ_ONCE(nt->ratelimit.interval))); +} + /* configfs helper to display if cpu_nr sysdata feature is enabled */ static ssize_t sysdata_cpu_nr_enabled_show(struct config_item *item, char = *buf) { @@ -1353,6 +1361,35 @@ static ssize_t remote_mac_store(struct config_item *= item, const char *buf, return ret; } =20 +static ssize_t ratelimit_interval_ms_store(struct config_item *item, + const char *buf, size_t count) +{ + struct netconsole_target *nt =3D to_target(item); + unsigned int interval; + unsigned long jifs; + ssize_t ret; + + ret =3D kstrtouint(buf, 10, &interval); + if (ret) + return ret; + + /* msecs_to_jiffies() saturates below INT_MAX on 32-bit, so the + * jiffies value alone does not bound what userspace wrote. + */ + jifs =3D msecs_to_jiffies(interval); + if (interval > INT_MAX || jifs > INT_MAX) + return -ERANGE; + + /* Restart the interval, so a target that is already flooding picks + * the new limit up now rather than at the next refill. + */ + dynamic_netconsole_mutex_lock(); + ratelimit_state_reset_interval(&nt->ratelimit, jifs); + dynamic_netconsole_mutex_unlock(); + + return count; +} + struct userdatum { struct config_item item; char value[MAX_EXTRADATA_VALUE_LEN]; @@ -1717,6 +1754,7 @@ CONFIGFS_ATTR_RO(, local_mac); CONFIGFS_ATTR(, remote_mac); CONFIGFS_ATTR(, release); CONFIGFS_ATTR_RO(, transmit_errors); +CONFIGFS_ATTR(, ratelimit_interval_ms); =20 static struct configfs_attribute *netconsole_target_attrs[] =3D { &attr_enabled, @@ -1730,6 +1768,7 @@ static struct configfs_attribute *netconsole_target_a= ttrs[] =3D { &attr_local_mac, &attr_remote_mac, &attr_transmit_errors, + &attr_ratelimit_interval_ms, NULL, }; =20 --=20 2.53.0-Meta From nobody Fri Sep 25 10:05:11 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 32E5746D2D3; Mon, 14 Sep 2026 12:10:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789387854; cv=none; b=C0SjOzOOdpttXvu2p4wo6u+DdUq9QqearDqYjZSg7ce6VHEKCSUv3yZPDzKZFUEGQ+qsrKgvFeIMz3fnpS7FdFHj9WsGp5zh9pp9yvumt5bG3nFuVS1uRw6p5XSP93ftfWwuaT5mYHwwKKCtaaJdlwaCh34RYMpS8BmIarUFLT8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789387854; c=relaxed/simple; bh=xC9eheCbPDQeFe5WhOtC4rtGUt7ob8GpONmRkWiUHW0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=cegT0DyHCyWcDZHwRP6K9jKuwjJCBF0QZ0fMEY4VMU9MekCE97s+Wn2rmk0wpXwlnYCakyX1m3v6HKwRzGTc8amLD3ar9HDSGAHt1uFJfJe7sCp/UIafhyc/XUjl09KDcYsBoWmerXN2aU1pWrnr+zJ99ioYgizqQ1yDWn5LWDQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=SNf5UG+2; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="SNf5UG+2" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=cO9ZFId8nWTm2pkBnUuRRfsysKyuNOHqLKO3CRNHOpc=; b=SNf5UG+2BPkzNDLlQWZmew0JrP Dh64DSeilcG5MS84NP0oooVflYV1iseaTOZP89TcWXpllDZ+y83EAhZ5DRPeH/wKJtiS9GaBMzkf6 VWHzH3lcp/Q7L/YZqRaUqFPA4wAwI6JGQkUz7H3qMHBo+agIerj1RmHYHkYK1M+1LGBggk50gYvq9 D6ktThDZM32aKaQR2DOf4ew2FmvrMgUqdpCAKIWVArspAokw6RQNR9jXbxkwYo4yL7NNCAOrZwGZh j14v7oy+G/zKIk+7FidLBsac+6X1bQ/xDf2uMIXKM4VTgrXk6eDDG0E1r5HaUmx0ePG45fx0BXJwx l8Vn/UTw==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1x65WN-003bZc-0e; Mon, 14 Sep 2026 12:10:51 +0000 From: Breno Leitao Date: Mon, 14 Sep 2026 05:09:54 -0700 Subject: [PATCH net-next v3 4/5] netconsole: allow configuring the rate limit burst through configfs 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: <20260914-netcons_ratelimit-v3-4-8e81b789ab37@debian.org> References: <20260914-netcons_ratelimit-v3-0-8e81b789ab37@debian.org> In-Reply-To: <20260914-netcons_ratelimit-v3-0-8e81b789ab37@debian.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan , Shuah Khan Cc: Randy Dunlap , paulmck@kernel.org, gustavold@gmail.com, asantostc@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-f8e9d X-Developer-Signature: v=1; a=openpgp-sha256; l=2684; i=leitao@debian.org; h=from:subject:message-id; bh=xC9eheCbPDQeFe5WhOtC4rtGUt7ob8GpONmRkWiUHW0=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqp+QxZxcjH8L/FUUiAVQliS5LzhsYn6S+Xilr2 qqMwfADScaJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaqfkMQAKCRA1o5Of/Hh3 bexND/9DzB4We+mgke/j/cgzfJRaBV76T6fl2CcK0UXVB5a2m8iZQD9NshPhLZbeypcwFDVZzVh lIkfRZakXJ3JoAuJRPxXQlomnFasa+/XnUkD/L9Lc6XHpO4BFRN/rLhNjzvmEEzwAkh/C9an9lW jvrdHSYrBGWuX/40uo38Uj78b/yVGFV5pvVgJfyabjI0M2gSOwHWyhxXBiZcoADP70LunHqJzpF lUTNm9LDlR6/8o6yRyQmjGWdKztknL1CnVZejYZCYLhCtTSULbtXfV1XioAA56OGj+ZPm7x5W7l 2EjKUm9lIDEqHPTL9xw27p+dVvmtOaaVMXXxaBRP/NEbd/vXKd9DZgteymslmyfNBFvP3sN4Xw+ yqGJ/V8bLbm4kRfsWmV+oL4gtahHDJIbO9HT15+HTIVyx5BIE/qUFtEwMDvqKCmYzrnO52baC8Y mrH2DZyeyNlX4bAoFZFNvfvaUhso7YtO+FwSQ7gsJTLNgtVXOfzFcKM6wMVS5rvN0EpwuARb7Yp t4XuH7B/gU5OrrwKn14VPW0Wr4PZkS+jlP/kBdZbpyaTe6kFd1BKqAhDijVQvn8iFrlLvy7qir6 if2yZTC29NSpSEGkidYs3oJq5z5yrpLZRgrKnluIa8j6HKNtj0RhB9/OD4bN+Tnh28BD12Tag3M mVSSZ8fBMHSs/dw== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao A target that sets ratelimit_interval_ms runs with the ratelimit default of 10 messages per interval, which is either too coarse or too generous depending on how chatty the target is. Expose it as ratelimit_burst through configfs. Restart the interval on write, as ratelimit_interval_ms_store() does. Raising the burst of a target that has already drained the bucket otherwise buys nothing until the interval in flight ends. Signed-off-by: Breno Leitao Reviewed-by: Gustavo Luiz Duarte --- drivers/net/netconsole.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index d4e3ac272e9b4a..691a97c931a3a9 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -966,6 +966,13 @@ static ssize_t ratelimit_interval_ms_show(struct confi= g_item *item, char *buf) jiffies_to_msecs(READ_ONCE(nt->ratelimit.interval))); } =20 +static ssize_t ratelimit_burst_show(struct config_item *item, char *buf) +{ + struct netconsole_target *nt =3D to_target(item); + + return sysfs_emit(buf, "%d\n", READ_ONCE(nt->ratelimit.burst)); +} + /* configfs helper to display if cpu_nr sysdata feature is enabled */ static ssize_t sysdata_cpu_nr_enabled_show(struct config_item *item, char = *buf) { @@ -1390,6 +1397,31 @@ static ssize_t ratelimit_interval_ms_store(struct co= nfig_item *item, return count; } =20 +static ssize_t ratelimit_burst_store(struct config_item *item, const char = *buf, + size_t count) +{ + struct netconsole_target *nt =3D to_target(item); + unsigned int burst; + ssize_t ret; + + ret =3D kstrtouint(buf, 10, &burst); + if (ret) + return ret; + + if (burst > INT_MAX) + return -ERANGE; + + /* Restart the interval as ratelimit_interval_ms_store() does, so the + * new burst is spendable right away. + */ + dynamic_netconsole_mutex_lock(); + WRITE_ONCE(nt->ratelimit.burst, burst); + ratelimit_state_reset_interval(&nt->ratelimit, nt->ratelimit.interval); + dynamic_netconsole_mutex_unlock(); + + return count; +} + struct userdatum { struct config_item item; char value[MAX_EXTRADATA_VALUE_LEN]; @@ -1755,6 +1787,7 @@ CONFIGFS_ATTR(, remote_mac); CONFIGFS_ATTR(, release); CONFIGFS_ATTR_RO(, transmit_errors); CONFIGFS_ATTR(, ratelimit_interval_ms); +CONFIGFS_ATTR(, ratelimit_burst); =20 static struct configfs_attribute *netconsole_target_attrs[] =3D { &attr_enabled, @@ -1769,6 +1802,7 @@ static struct configfs_attribute *netconsole_target_a= ttrs[] =3D { &attr_remote_mac, &attr_transmit_errors, &attr_ratelimit_interval_ms, + &attr_ratelimit_burst, NULL, }; =20 --=20 2.53.0-Meta From nobody Fri Sep 25 10:05:11 2026 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 30D0E463B86; Mon, 14 Sep 2026 12:10:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789387860; cv=none; b=Ql8rDV6fDEDO2DNCTxsvRjGbMcZqfPN0sQUxnwLdyPv4oy7MUxEsX6Mnm24WZdpZwx3jqZHcjXUxqvyvF5z9j2XLy43/sFB+pi4nHGRsKcj2ogrxKs7SpBsStAHpzoWW/3HhMYbNfqABKxCf+B/y3QyIehQvuCQuqhWUAI+JvY0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789387860; c=relaxed/simple; bh=tbCmJto27lZvoHrdaDlAjBK2u9Sy9ypdNQr9qyG8YAs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=V/3P76nRurIqe/R1rMFkfYFNyWMkAHh5HPohv496r22ge6Ehp+w9HAl5OEyxLs/LqQsDxx3AigpUBkUDwmofePRusRYLrPtir+mG2yJAnr3oaphcCTYrIzLOW4kTXTizzC+5pdg+WFz4UffD+XCzD3/4uB19hgSaBV1CCn8qPBs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org; spf=pass smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=t8hcCBD8; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="t8hcCBD8" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:Cc:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Content-ID:Content-Description; bh=DFvyBMTDpflO+4J/qxAqOv/mmKbukWTA8t09UNH9jao=; b=t8hcCBD8GHn6vMKWb2/55BbkJ8 aMzYCAypnWhxBmpimfdrxRksKGtFApdfm/E1D2gUfpcIn1tJ8k1pV/TBCSu/pPMcGUgtL9JYT/eeM UxtvLr+s5zBlr8qaGxfUXEw1bM+MJxZVPGgnNDZHj6KzffCv66+uzOYqEQDkop0I5R8NFrYfGeHV9 BIpH7V0Pj6TVatI9G2+xefLgxM0p0P5+cR2N3zUlSLk3/MfpWLLqq7vdOnU3NBrBM5Q6i7DNi0rkn AjKLEbzQ5vXjmlUwEV1F+ZB5xzzmP2lScToXs9F/wk26Bk6Q0vezqPTzdN6+CpJYMNqkJwCihVjl2 slcwuPiA==; Received: from authenticated-user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.96) (envelope-from ) id 1x65WS-003bZs-05; Mon, 14 Sep 2026 12:10:56 +0000 From: Breno Leitao Date: Mon, 14 Sep 2026 05:09:55 -0700 Subject: [PATCH net-next v3 5/5] docs: netconsole: document rate limit feature 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: <20260914-netcons_ratelimit-v3-5-8e81b789ab37@debian.org> References: <20260914-netcons_ratelimit-v3-0-8e81b789ab37@debian.org> In-Reply-To: <20260914-netcons_ratelimit-v3-0-8e81b789ab37@debian.org> To: Andrew Lunn , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Simon Horman , Jonathan Corbet , Shuah Khan , Shuah Khan Cc: Randy Dunlap , paulmck@kernel.org, gustavold@gmail.com, asantostc@gmail.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, linux-kselftest@vger.kernel.org, Breno Leitao , kernel-team@meta.com X-Mailer: b4 0.16-dev-f8e9d X-Developer-Signature: v=1; a=openpgp-sha256; l=5831; i=leitao@debian.org; h=from:subject:message-id; bh=tbCmJto27lZvoHrdaDlAjBK2u9Sy9ypdNQr9qyG8YAs=; b=owEBbQKS/ZANAwAIATWjk5/8eHdtAcsmYgBqp+QxCVKz6qJI7mRuYe7t79aBjF/GzvIAZFkCQ rJeSdto32WJAjMEAAEIAB0WIQSshTmm6PRnAspKQ5s1o5Of/Hh3bQUCaqfkMQAKCRA1o5Of/Hh3 bYQXD/9mN6CJiqY6kF0foFIajYJrRoW+V5LMGGgzd+OL4csJYaIGkVtIXqK3/eQmpppm0FYLbl2 85rl/bdR9Je6m3xhJsODsIb7AIvDyVxRjk2cMSmAFsRI1f82c0X65gKkl2p8RUEr43+Z3MFR/Zt JW40RFFVVxF6ApMkeH0ZCxW6fLPxfTkNLU2ThKwfjB+B1cXWQHKo6PR+I23UiQp80Pst+mlF1Ru 0J5/ASEpd3+li0jITGSaaiJAZeLHE10x5vi0Vc7CfE94nXkg4aGVxBEY5Qx82b3WEJoORoBQ3DG VjwLR6PyEknlSMG7rKwcvejY7sB46zjtQnlFaKoeicVo55/G0lu2AddYErHP/nKdK6LSwpjV3Lv itKVtoXKIh/6HYs+SA1QNdwVfxZC4YbdqXPwFx0FYFVfnQuyKa2E0m5Y0EG+A+koaDOXzFDeUB0 zB13x2dE8/FR0cMcnV3u80y2f4y7AMgZg5RbjOF9QbM4QG8wrWw5BUi0qguSk6k5uJ6fMbERVRw PrAmSmFFOVMNHpnCi0RRT1b+kc2VbYG2hL8sLjHFs2SdgWZGrBXPpB7p2Or4e0rgyvyQhJWi0P9 RzA/+J85As+JXRxcr9slTq8W6Y2yc/aGzNXWaTSh7ktyzTRtwb4CiNwez4jv2zTzrCXCzbgsncv wBXZ1CkwhHJ1bbw== X-Developer-Key: i=leitao@debian.org; a=openpgp; fpr=AC8539A6E8F46702CA4A439B35A3939FFC78776D X-Debian-User: leitao Describe the per-target token bucket and the two configfs files that drive it: ratelimit_interval_ms and ratelimit_burst. Spell out the two properties that are not obvious from the file names. The limit is accounted per message rather than per packet, so a message split into several ncfrag packets is never truncated by the bucket running dry halfway through. List both files in the target parameter table too, and qualify the rule underneath it. Only a disabled target can have its parameters updated, these two aside. Note in the message ID section that a message the bucket discards never reaches the counter, so those drops leave no gap in the IDs. Signed-off-by: Breno Leitao Reviewed-by: Gustavo Luiz Duarte --- Documentation/networking/netconsole.rst | 71 ++++++++++++++++++++++++++---= ---- 1 file changed, 57 insertions(+), 14 deletions(-) diff --git a/Documentation/networking/netconsole.rst b/Documentation/networ= king/netconsole.rst index 4ab5d7b05cf102..9fe4888fe136b3 100644 --- a/Documentation/networking/netconsole.rst +++ b/Documentation/networking/netconsole.rst @@ -127,23 +127,26 @@ To remove a target:: =20 The interface exposes these parameters of a netconsole target to userspace: =20 - =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - enabled Is this target currently enabled? (read-write) - extended Extended mode enabled (read-write) - release Prepend kernel release to message (read-write) - dev_name Local network interface name (read-write) - local_port Source UDP port to use (read-write) - remote_port Remote agent's UDP port (read-write) - local_ip Source IP address to use (read-write) - remote_ip Remote agent's IP address (read-write) - local_mac Local interface's MAC address (read-only) - remote_mac Remote agent's MAC address (read-write) - transmit_errors Number of packet send errors (read-only) - =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + enabled Is this target currently enabled? (read-write) + extended Extended mode enabled (read-write) + release Prepend kernel release to message (read-write) + dev_name Local network interface name (read-write) + local_port Source UDP port to use (read-write) + remote_port Remote agent's UDP port (read-write) + local_ip Source IP address to use (read-write) + remote_ip Remote agent's IP address (read-write) + local_mac Local interface's MAC address (read-only) + remote_mac Remote agent's MAC address (read-write) + transmit_errors Number of packet send errors (read-only) + ratelimit_interval_ms Rate limit interval, milliseconds (read-write) + ratelimit_burst Messages allowed per interval (read-write) + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =20 The "enabled" attribute is also used to control whether the parameters of a target can be updated or not -- you can modify the parameters of only -disabled targets (i.e. if "enabled" is 0). +disabled targets (i.e. if "enabled" is 0). The two rate limit parameters +are the exception, see `Rate limiting`_. =20 To update a target's parameters:: =20 @@ -177,6 +180,43 @@ You can modify these targets in runtime by creating th= e following targets:: cat cmdline1/remote_ip 10.0.0.3 =20 +Rate limiting +------------- + +Netconsole hands every console message to every enabled target, so a host = that +logs continuously can saturate the receiving agent. Each target carries a = token +bucket that drops messages once the configured rate is exceeded, controlle= d by +two files in the target directory: + + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + ratelimit_interval_ms Length of the accounting interval, in + milliseconds. Zero, the default, sends + everything. + ratelimit_burst Messages allowed per interval. Defaults to + 10; zero drops every message once an + interval is set. + =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Unlike most target parameters, both knobs can be written while the target = is +enabled, which is when a flooding target most likely needs them. Either wr= ite +restarts the interval with a full burst, so a new limit applies from that +moment on. + +The limit is applied per message, not per packet, so a message big enough = to be +split into several `ncfrag` packets is either sent whole or not at all. + +Crash output bypasses the bucket. Every message is sent while a panic is in +progress, and an oops or a BUG() turns the limit off for the rest of the b= oot, +so a small burst cannot cost you part of a crash dump. + +A drop leaves nothing on the wire. On an extended target it shows up as a = gap +in the sequence number the header carries; a basic target has no such mark= er. + +Capping a target at 500 messages a minute:: + + echo 60000 > ratelimit_interval_ms + echo 500 > ratelimit_burst + Append User Data ---------------- =20 @@ -359,6 +399,9 @@ indicate that a message was dropped during transmission= , as it may never have been sent via netconsole. The message ID, on the other hand, is only assig= ned to messages that are actually transmitted via netconsole. =20 +A message the target's rate limit discards is dropped before the ID is +assigned, so those drops leave no gap in the sequence of IDs either. + Example:: =20 echo "This is message #1" > /dev/kmsg --=20 2.53.0-Meta