Skip to content

Commit eaf35bc

Browse files
leitaokuba-moo
authored andcommitted
netconsole: extract message fragmentation into send_msg_udp()
Extract the message fragmentation logic from write_msg() into a dedicated send_msg_udp() function. This improves code readability and prepares for future enhancements. The new send_msg_udp() function handles splitting messages that exceed MAX_PRINT_CHUNK into smaller fragments and sending them sequentially. This function is placed before send_ext_msg_udp() to maintain a logical ordering of related functions. No functional changes - this is purely a refactoring commit. Reviewed-by: Petr Mladek <pmladek@suse.com> Reviewed-by: Simon Horman <horms@kernel.org> Reviewed-by: John Ogness <john.ogness@linutronix.de> Signed-off-by: Breno Leitao <leitao@debian.org> Link: https://patch.msgid.link/20260206-nbcon-v7-2-62bda69b1b41@debian.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 60325c2 commit eaf35bc

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

drivers/net/netconsole.c

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1876,12 +1876,24 @@ static void write_ext_msg(struct console *con, const char *msg,
18761876
spin_unlock_irqrestore(&target_list_lock, flags);
18771877
}
18781878

1879+
static void send_msg_udp(struct netconsole_target *nt, const char *msg,
1880+
unsigned int len)
1881+
{
1882+
const char *tmp = msg;
1883+
int frag, left = len;
1884+
1885+
while (left > 0) {
1886+
frag = min(left, MAX_PRINT_CHUNK);
1887+
send_udp(nt, tmp, frag);
1888+
tmp += frag;
1889+
left -= frag;
1890+
}
1891+
}
1892+
18791893
static void write_msg(struct console *con, const char *msg, unsigned int len)
18801894
{
1881-
int frag, left;
18821895
unsigned long flags;
18831896
struct netconsole_target *nt;
1884-
const char *tmp;
18851897

18861898
if (oops_only && !oops_in_progress)
18871899
return;
@@ -1899,13 +1911,7 @@ static void write_msg(struct console *con, const char *msg, unsigned int len)
18991911
* at least one target if we die inside here, instead
19001912
* of unnecessarily keeping all targets in lock-step.
19011913
*/
1902-
tmp = msg;
1903-
for (left = len; left;) {
1904-
frag = min(left, MAX_PRINT_CHUNK);
1905-
send_udp(nt, tmp, frag);
1906-
tmp += frag;
1907-
left -= frag;
1908-
}
1914+
send_msg_udp(nt, msg, len);
19091915
}
19101916
}
19111917
spin_unlock_irqrestore(&target_list_lock, flags);

0 commit comments

Comments
 (0)