Skip to content

Commit b4ab4f2

Browse files
thepacketgeekdavem330
authored andcommitted
net: netconsole: append userdata to netconsole messages
Append userdata to outgoing unfragmented (<1000 bytes) netconsole messages. When sending messages the userdata string is already formatted and stored in netconsole_target->userdata_complete. Always write the outgoing message to buf, so userdata can be appended in a standard fashion. This is a change from only using buf when the release needs to be prepended to the message. Co-developed-by: Breno Leitao <[email protected]> Signed-off-by: Breno Leitao <[email protected]> Signed-off-by: Matthew Wood <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent df03f83 commit b4ab4f2

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

drivers/net/netconsole.c

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1034,19 +1034,34 @@ static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg,
10341034
const char *msg_ready = msg;
10351035
const char *release;
10361036
int release_len = 0;
1037+
int userdata_len = 0;
1038+
char *userdata = NULL;
1039+
1040+
#ifdef CONFIG_NETCONSOLE_DYNAMIC
1041+
userdata = nt->userdata_complete;
1042+
userdata_len = nt->userdata_length;
1043+
#endif
10371044

10381045
if (nt->release) {
10391046
release = init_utsname()->release;
10401047
release_len = strlen(release) + 1;
10411048
}
10421049

1043-
if (msg_len + release_len <= MAX_PRINT_CHUNK) {
1050+
if (msg_len + release_len + userdata_len <= MAX_PRINT_CHUNK) {
10441051
/* No fragmentation needed */
10451052
if (nt->release) {
10461053
scnprintf(buf, MAX_PRINT_CHUNK, "%s,%s", release, msg);
10471054
msg_len += release_len;
1048-
msg_ready = buf;
1055+
} else {
1056+
memcpy(buf, msg, msg_len);
10491057
}
1058+
1059+
if (userdata)
1060+
msg_len += scnprintf(&buf[msg_len],
1061+
MAX_PRINT_CHUNK - msg_len,
1062+
"%s", userdata);
1063+
1064+
msg_ready = buf;
10501065
netpoll_send_udp(&nt->np, msg_ready, msg_len);
10511066
return;
10521067
}

0 commit comments

Comments
 (0)