From: Breno Leitao <leitao@debian.org>
To: Breno Leitao <leitao@debian.org>,
Jakub Kicinski <kuba@kernel.org>,
horms@kernel.org, efault@gmx.de, john.ogness@linutronix.de,
pmladek@suse.com
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Paolo Abeni <pabeni@redhat.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
calvin@wbinvd.org, asml.silence@gmail.com, kernel-team@meta.com,
gustavold@gmail.com, asantostc@gmail.com
Subject: [PATCH RFC net-next 1/2] netconsole: extract message fragmentation into write_msg_target()
Date: Fri, 21 Nov 2025 03:26:07 -0800 [thread overview]
Message-ID: <20251121-nbcon-v1-1-503d17b2b4af@debian.org> (raw)
In-Reply-To: <20251121-nbcon-v1-0-503d17b2b4af@debian.org>
Refactor the message fragmentation logic in write_msg() by extracting it
into a separate write_msg_target() helper function. This makes the code
more maintainable and prepares for future reuse in nbcon support for
non-extended consoles.
The helper function takes a target, message, and length, then handles
splitting the message into MAX_PRINT_CHUNK-sized fragments for sending
via send_udp().
No functional change intended.
Signed-off-by: Breno Leitao <leitao@debian.org>
---
drivers/net/netconsole.c | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index bb6e03a92956..f4b1706fb081 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1559,6 +1559,20 @@ static void append_release(char *buf)
scnprintf(buf, MAX_PRINT_CHUNK, "%s,", release);
}
+static void write_msg_target(struct netconsole_target *nt, const char *msg,
+ unsigned int len)
+{
+ const char *tmp = msg;
+ int frag, left = len;
+
+ while (left > 0) {
+ frag = min(left, MAX_PRINT_CHUNK);
+ send_udp(nt, tmp, frag);
+ tmp += frag;
+ left -= frag;
+ }
+}
+
static void send_fragmented_body(struct netconsole_target *nt,
const char *msgbody, int header_len,
int msgbody_len, int extradata_len)
@@ -1728,10 +1742,8 @@ static void write_ext_msg(struct console *con, const char *msg,
static void write_msg(struct console *con, const char *msg, unsigned int len)
{
- int frag, left;
- unsigned long flags;
struct netconsole_target *nt;
- const char *tmp;
+ unsigned long flags;
if (oops_only && !oops_in_progress)
return;
@@ -1748,13 +1760,7 @@ static void write_msg(struct console *con, const char *msg, unsigned int len)
* at least one target if we die inside here, instead
* of unnecessarily keeping all targets in lock-step.
*/
- tmp = msg;
- for (left = len; left;) {
- frag = min(left, MAX_PRINT_CHUNK);
- send_udp(nt, tmp, frag);
- tmp += frag;
- left -= frag;
- }
+ write_msg_target(nt, msg, len);
}
}
spin_unlock_irqrestore(&target_list_lock, flags);
--
2.47.3
next prev parent reply other threads:[~2025-11-21 11:26 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-21 11:26 [PATCH RFC net-next 0/2] netconsole: NBCON Infrastructure Support Breno Leitao
2025-11-21 11:26 ` Breno Leitao [this message]
2025-11-24 13:08 ` [PATCH RFC net-next 1/2] netconsole: extract message fragmentation into write_msg_target() Petr Mladek
2025-11-21 11:26 ` [PATCH RFC net-next 2/2] netconsole: add CONFIG_NETCONSOLE_NBCON for nbcon support Breno Leitao
2025-11-24 13:55 ` Petr Mladek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251121-nbcon-v1-1-503d17b2b4af@debian.org \
--to=leitao@debian.org \
--cc=andrew+netdev@lunn.ch \
--cc=asantostc@gmail.com \
--cc=asml.silence@gmail.com \
--cc=calvin@wbinvd.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=efault@gmx.de \
--cc=gustavold@gmail.com \
--cc=horms@kernel.org \
--cc=john.ogness@linutronix.de \
--cc=kernel-team@meta.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pmladek@suse.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®