* [PATCH net-next v2 00/10] netconsole refactoring and warning fix
@ 2024-09-09 13:07 Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 01/10] net: netconsole: remove msg_ready variable Breno Leitao
` (9 more replies)
0 siblings, 10 replies; 15+ messages in thread
From: Breno Leitao @ 2024-09-09 13:07 UTC (permalink / raw)
To: kuba, davem, edumazet, pabeni
Cc: thepacketgeek, horms, netdev, linux-kernel, davej, vlad.wing, max
The netconsole driver was showing a warning related to userdata
information, depending on the message size being transmitted:
------------[ cut here ]------------
WARNING: CPU: 13 PID: 3013042 at drivers/net/netconsole.c:1122 write_ext_msg+0x3b6/0x3d0
? write_ext_msg+0x3b6/0x3d0
console_flush_all+0x1e9/0x330
...
Identifying the cause of this warning proved to be non-trivial due to:
* The write_ext_msg() function being over 100 lines long
* Extensive use of pointer arithmetic
* Inconsistent naming conventions and concept application
The send_ext_msg() function grew organically over time:
* Initially, the UDP packet consisted of a header and body
* Later additions included release prepend and userdata
* Naming became inconsistent (e.g., "body" excludes userdata, "header"
excludes prepended release)
This lack of consistency made investigating issues like the above warning
more challenging than what it should be.
To address these issues, the following steps were taken:
* Breaking down write_ext_msg() into smaller functions with clear scopes
* Improving readability and reasoning about the code
* Simplifying and clarifying naming conventions
Warning Fix
-----------
The warning occurred when there was insufficient buffer space to append
userdata. While this scenario is acceptable (as userdata can be sent in a
separate packet later), the kernel was incorrectly raising a warning. A
one-line fix has been implemented to resolve this issue.
A self-test was developed to write messages of every possible length
This test will be submitted in a separate patchset
Changelog:
v2:
* Separated the userdata variable move to the tail function into a
separated fix (Simon)
* Reformated the patches to fit in 80-lines. Only one not respecting
this is a copy from previous commit.
v1:
* https://lore.kernel.org/all/20240903140757.2802765-1-leitao@debian.org/
Breno Leitao (10):
net: netconsole: remove msg_ready variable
net: netconsole: split send_ext_msg_udp() function
net: netconsole: separate fragmented message handling in send_ext_msg
net: netconsole: rename body to msg_body
net: netconsole: introduce variable to track body length
net: netconsole: track explicitly if msgbody was written to buffer
net: netconsole: extract release appending into separate function
net: netconsole: do not pass userdata up to the tail
net: netconsole: split send_msg_fragmented
net: netconsole: fix wrong warning
drivers/net/netconsole.c | 206 ++++++++++++++++++++++++++-------------
1 file changed, 140 insertions(+), 66 deletions(-)
--
2.43.5
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH net-next v2 01/10] net: netconsole: remove msg_ready variable
2024-09-09 13:07 [PATCH net-next v2 00/10] netconsole refactoring and warning fix Breno Leitao
@ 2024-09-09 13:07 ` Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 02/10] net: netconsole: split send_ext_msg_udp() function Breno Leitao
` (8 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Breno Leitao @ 2024-09-09 13:07 UTC (permalink / raw)
To: kuba, davem, edumazet, pabeni
Cc: thepacketgeek, horms, netdev, linux-kernel, davej, vlad.wing, max
Variable msg_ready is useless, since it does not represent anything. Get
rid of it, using buf directly instead.
Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Simon Horman <horms@kernel.org>
---
drivers/net/netconsole.c | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 01cf33fa7503..03150e513cb2 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1075,7 +1075,6 @@ static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg,
const char *header, *body;
int offset = 0;
int header_len, body_len;
- const char *msg_ready = msg;
const char *release;
int release_len = 0;
int userdata_len = 0;
@@ -1105,8 +1104,7 @@ static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg,
MAX_PRINT_CHUNK - msg_len,
"%s", userdata);
- msg_ready = buf;
- netpoll_send_udp(&nt->np, msg_ready, msg_len);
+ netpoll_send_udp(&nt->np, buf, msg_len);
return;
}
--
2.43.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next v2 02/10] net: netconsole: split send_ext_msg_udp() function
2024-09-09 13:07 [PATCH net-next v2 00/10] netconsole refactoring and warning fix Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 01/10] net: netconsole: remove msg_ready variable Breno Leitao
@ 2024-09-09 13:07 ` Breno Leitao
2024-09-09 15:58 ` Simon Horman
2024-09-09 13:07 ` [PATCH net-next v2 03/10] net: netconsole: separate fragmented message handling in send_ext_msg Breno Leitao
` (7 subsequent siblings)
9 siblings, 1 reply; 15+ messages in thread
From: Breno Leitao @ 2024-09-09 13:07 UTC (permalink / raw)
To: kuba, davem, edumazet, pabeni
Cc: thepacketgeek, horms, netdev, linux-kernel, davej, vlad.wing, max
The send_ext_msg_udp() function has become quite large, currently
spanning 102 lines. Its complexity, along with extensive pointer and
offset manipulation, makes it difficult to read and error-prone.
The function has evolved over time, and it’s now due for a refactor.
To improve readability and maintainability, isolate the case where no
message fragmentation occurs into a separate function, into a new
send_msg_no_fragmentation() function. This scenario covers about 95% of
the messages.
Signed-off-by: Breno Leitao <leitao@debian.org>
---
drivers/net/netconsole.c | 46 +++++++++++++++++++++++++---------------
1 file changed, 29 insertions(+), 17 deletions(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 03150e513cb2..d31ac47b496a 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1058,6 +1058,32 @@ static struct notifier_block netconsole_netdev_notifier = {
.notifier_call = netconsole_netdev_event,
};
+static void send_msg_no_fragmentation(struct netconsole_target *nt,
+ const char *msg,
+ const char *userdata,
+ int msg_len,
+ int release_len)
+{
+ static char buf[MAX_PRINT_CHUNK]; /* protected by target_list_lock */
+ const char *release;
+
+ if (release_len) {
+ release = init_utsname()->release;
+
+ scnprintf(buf, MAX_PRINT_CHUNK, "%s,%s", release, msg);
+ msg_len += release_len;
+ } else {
+ memcpy(buf, msg, msg_len);
+ }
+
+ if (userdata)
+ msg_len += scnprintf(&buf[msg_len],
+ MAX_PRINT_CHUNK - msg_len,
+ "%s", userdata);
+
+ netpoll_send_udp(&nt->np, buf, msg_len);
+}
+
/**
* send_ext_msg_udp - send extended log message to target
* @nt: target to send message to
@@ -1090,23 +1116,9 @@ static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg,
release_len = strlen(release) + 1;
}
- if (msg_len + release_len + userdata_len <= MAX_PRINT_CHUNK) {
- /* No fragmentation needed */
- if (nt->release) {
- scnprintf(buf, MAX_PRINT_CHUNK, "%s,%s", release, msg);
- msg_len += release_len;
- } else {
- memcpy(buf, msg, msg_len);
- }
-
- if (userdata)
- msg_len += scnprintf(&buf[msg_len],
- MAX_PRINT_CHUNK - msg_len,
- "%s", userdata);
-
- netpoll_send_udp(&nt->np, buf, msg_len);
- return;
- }
+ if (msg_len + release_len + userdata_len <= MAX_PRINT_CHUNK)
+ return send_msg_no_fragmentation(nt, msg, userdata, msg_len,
+ release_len);
/* need to insert extra header fields, detect header and body */
header = msg;
--
2.43.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next v2 03/10] net: netconsole: separate fragmented message handling in send_ext_msg
2024-09-09 13:07 [PATCH net-next v2 00/10] netconsole refactoring and warning fix Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 01/10] net: netconsole: remove msg_ready variable Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 02/10] net: netconsole: split send_ext_msg_udp() function Breno Leitao
@ 2024-09-09 13:07 ` Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 04/10] net: netconsole: rename body to msg_body Breno Leitao
` (6 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Breno Leitao @ 2024-09-09 13:07 UTC (permalink / raw)
To: kuba, davem, edumazet, pabeni
Cc: thepacketgeek, horms, netdev, linux-kernel, davej, vlad.wing, max
Following the previous change, where the non-fragmented case was moved
to its own function, this update introduces a new function called
send_msg_fragmented to specifically manage scenarios where message
fragmentation is required.
Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Simon Horman <horms@kernel.org>
---
drivers/net/netconsole.c | 78 ++++++++++++++++++++++++----------------
1 file changed, 48 insertions(+), 30 deletions(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index d31ac47b496a..8faea9422ea1 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1084,41 +1084,20 @@ static void send_msg_no_fragmentation(struct netconsole_target *nt,
netpoll_send_udp(&nt->np, buf, msg_len);
}
-/**
- * send_ext_msg_udp - send extended log message to target
- * @nt: target to send message to
- * @msg: extended log message to send
- * @msg_len: length of message
- *
- * Transfer extended log @msg to @nt. If @msg is longer than
- * MAX_PRINT_CHUNK, it'll be split and transmitted in multiple chunks with
- * ncfrag header field added to identify them.
- */
-static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg,
- int msg_len)
+static void send_msg_fragmented(struct netconsole_target *nt,
+ const char *msg,
+ const char *userdata,
+ int msg_len,
+ int release_len)
{
static char buf[MAX_PRINT_CHUNK]; /* protected by target_list_lock */
+ int offset = 0, userdata_len = 0;
const char *header, *body;
- int offset = 0;
int header_len, body_len;
const char *release;
- int release_len = 0;
- int userdata_len = 0;
- char *userdata = NULL;
-
-#ifdef CONFIG_NETCONSOLE_DYNAMIC
- userdata = nt->userdata_complete;
- userdata_len = nt->userdata_length;
-#endif
- if (nt->release) {
- release = init_utsname()->release;
- release_len = strlen(release) + 1;
- }
-
- if (msg_len + release_len + userdata_len <= MAX_PRINT_CHUNK)
- return send_msg_no_fragmentation(nt, msg, userdata, msg_len,
- release_len);
+ if (userdata)
+ userdata_len = nt->userdata_length;
/* need to insert extra header fields, detect header and body */
header = msg;
@@ -1134,11 +1113,18 @@ static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg,
* Transfer multiple chunks with the following extra header.
* "ncfrag=<byte-offset>/<total-bytes>"
*/
- if (nt->release)
+ if (release_len) {
+ release = init_utsname()->release;
scnprintf(buf, MAX_PRINT_CHUNK, "%s,", release);
+ }
+
+ /* Copy the header into the buffer */
memcpy(buf + release_len, header, header_len);
header_len += release_len;
+ /* for now on, the header will be persisted, and the body
+ * will be replaced
+ */
while (offset < body_len + userdata_len) {
int this_header = header_len;
int this_offset = 0;
@@ -1184,6 +1170,38 @@ static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg,
}
}
+/**
+ * send_ext_msg_udp - send extended log message to target
+ * @nt: target to send message to
+ * @msg: extended log message to send
+ * @msg_len: length of message
+ *
+ * Transfer extended log @msg to @nt. If @msg is longer than
+ * MAX_PRINT_CHUNK, it'll be split and transmitted in multiple chunks with
+ * ncfrag header field added to identify them.
+ */
+static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg,
+ int msg_len)
+{
+ char *userdata = NULL;
+ int userdata_len = 0;
+ int release_len = 0;
+
+#ifdef CONFIG_NETCONSOLE_DYNAMIC
+ userdata = nt->userdata_complete;
+ userdata_len = nt->userdata_length;
+#endif
+
+ if (nt->release)
+ release_len = strlen(init_utsname()->release) + 1;
+
+ if (msg_len + release_len + userdata_len <= MAX_PRINT_CHUNK)
+ return send_msg_no_fragmentation(nt, msg, userdata, msg_len,
+ release_len);
+
+ return send_msg_fragmented(nt, msg, userdata, msg_len, release_len);
+}
+
static void write_ext_msg(struct console *con, const char *msg,
unsigned int len)
{
--
2.43.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next v2 04/10] net: netconsole: rename body to msg_body
2024-09-09 13:07 [PATCH net-next v2 00/10] netconsole refactoring and warning fix Breno Leitao
` (2 preceding siblings ...)
2024-09-09 13:07 ` [PATCH net-next v2 03/10] net: netconsole: separate fragmented message handling in send_ext_msg Breno Leitao
@ 2024-09-09 13:07 ` Breno Leitao
2024-09-09 16:03 ` Simon Horman
2024-09-09 13:07 ` [PATCH net-next v2 05/10] net: netconsole: introduce variable to track body length Breno Leitao
` (5 subsequent siblings)
9 siblings, 1 reply; 15+ messages in thread
From: Breno Leitao @ 2024-09-09 13:07 UTC (permalink / raw)
To: kuba, davem, edumazet, pabeni
Cc: thepacketgeek, horms, netdev, linux-kernel, davej, vlad.wing, max
With the introduction of the userdata concept, the term body has become
ambiguous and less intuitive.
To improve clarity, body is renamed to msg_body, making it clear that
the body is not the only content following the header.
In an upcoming patch, the term body_len will also be revised for further
clarity.
The current packet structure is as follows:
release, header, body, [msg_body + userdata]
Here, [msg_body + userdata] collectively forms what is currently
referred to as "body." This renaming helps to distinguish and better
understand each component of the packet.
Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Simon Horman <horms@kernel.org>
---
drivers/net/netconsole.c | 48 +++++++++++++++++++++++-----------------
1 file changed, 28 insertions(+), 20 deletions(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 8faea9422ea1..c312ad6d5cf8 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1092,22 +1092,22 @@ static void send_msg_fragmented(struct netconsole_target *nt,
{
static char buf[MAX_PRINT_CHUNK]; /* protected by target_list_lock */
int offset = 0, userdata_len = 0;
- const char *header, *body;
- int header_len, body_len;
+ const char *header, *msgbody;
+ int header_len, msgbody_len;
const char *release;
if (userdata)
userdata_len = nt->userdata_length;
- /* need to insert extra header fields, detect header and body */
+ /* need to insert extra header fields, detect header and msgbody */
header = msg;
- body = memchr(msg, ';', msg_len);
- if (WARN_ON_ONCE(!body))
+ msgbody = memchr(msg, ';', msg_len);
+ if (WARN_ON_ONCE(!msgbody))
return;
- header_len = body - header;
- body_len = msg_len - header_len - 1;
- body++;
+ header_len = msgbody - header;
+ msgbody_len = msg_len - header_len - 1;
+ msgbody++;
/*
* Transfer multiple chunks with the following extra header.
@@ -1122,10 +1122,10 @@ static void send_msg_fragmented(struct netconsole_target *nt,
memcpy(buf + release_len, header, header_len);
header_len += release_len;
- /* for now on, the header will be persisted, and the body
+ /* for now on, the header will be persisted, and the msgbody
* will be replaced
*/
- while (offset < body_len + userdata_len) {
+ while (offset < msgbody_len + userdata_len) {
int this_header = header_len;
int this_offset = 0;
int this_chunk = 0;
@@ -1133,23 +1133,31 @@ static void send_msg_fragmented(struct netconsole_target *nt,
this_header += scnprintf(buf + this_header,
sizeof(buf) - this_header,
",ncfrag=%d/%d;", offset,
- body_len + userdata_len);
+ msgbody_len + userdata_len);
- /* Not all body data has been written yet */
- if (offset < body_len) {
- this_chunk = min(body_len - offset,
+ /* Not all msgbody data has been written yet */
+ if (offset < msgbody_len) {
+ this_chunk = min(msgbody_len - offset,
MAX_PRINT_CHUNK - this_header);
if (WARN_ON_ONCE(this_chunk <= 0))
return;
- memcpy(buf + this_header, body + offset, this_chunk);
+ memcpy(buf + this_header, msgbody + offset, this_chunk);
this_offset += this_chunk;
}
- /* Body is fully written and there is pending userdata to write,
- * append userdata in this chunk
+
+ if (offset + this_offset >= msgbody_len)
+ /* msgbody was finally written, either in the previous
+ * messages and/or in the current buf. Time to write
+ * the userdata.
+ */
+ msgbody_written = true;
+
+ /* Msg body is fully written and there is pending userdata to
+ * write, append userdata in this chunk
*/
- if (offset + this_offset >= body_len &&
- offset + this_offset < userdata_len + body_len) {
- int sent_userdata = (offset + this_offset) - body_len;
+ if (offset + this_offset >= msgbody_len &&
+ offset + this_offset < userdata_len + msgbody_len) {
+ int sent_userdata = (offset + this_offset) - msgbody_len;
int preceding_bytes = this_chunk + this_header;
if (WARN_ON_ONCE(sent_userdata < 0))
--
2.43.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next v2 05/10] net: netconsole: introduce variable to track body length
2024-09-09 13:07 [PATCH net-next v2 00/10] netconsole refactoring and warning fix Breno Leitao
` (3 preceding siblings ...)
2024-09-09 13:07 ` [PATCH net-next v2 04/10] net: netconsole: rename body to msg_body Breno Leitao
@ 2024-09-09 13:07 ` Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 06/10] net: netconsole: track explicitly if msgbody was written to buffer Breno Leitao
` (4 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Breno Leitao @ 2024-09-09 13:07 UTC (permalink / raw)
To: kuba, davem, edumazet, pabeni
Cc: thepacketgeek, horms, netdev, linux-kernel, davej, vlad.wing, max
This new variable tracks the total length of the data to be sent,
encompassing both the message body (msgbody) and userdata, which is
collectively called body.
By explicitly defining body_len, the code becomes clearer and easier to
reason about, simplifying offset calculations and improving overall
readability of the function.
Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Simon Horman <horms@kernel.org>
---
drivers/net/netconsole.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index c312ad6d5cf8..e3350016db0d 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1090,10 +1090,10 @@ static void send_msg_fragmented(struct netconsole_target *nt,
int msg_len,
int release_len)
{
+ int header_len, msgbody_len, body_len;
static char buf[MAX_PRINT_CHUNK]; /* protected by target_list_lock */
int offset = 0, userdata_len = 0;
const char *header, *msgbody;
- int header_len, msgbody_len;
const char *release;
if (userdata)
@@ -1122,10 +1122,11 @@ static void send_msg_fragmented(struct netconsole_target *nt,
memcpy(buf + release_len, header, header_len);
header_len += release_len;
+ body_len = msgbody_len + userdata_len;
/* for now on, the header will be persisted, and the msgbody
* will be replaced
*/
- while (offset < msgbody_len + userdata_len) {
+ while (offset < body_len) {
int this_header = header_len;
int this_offset = 0;
int this_chunk = 0;
@@ -1133,7 +1134,7 @@ static void send_msg_fragmented(struct netconsole_target *nt,
this_header += scnprintf(buf + this_header,
sizeof(buf) - this_header,
",ncfrag=%d/%d;", offset,
- msgbody_len + userdata_len);
+ body_len);
/* Not all msgbody data has been written yet */
if (offset < msgbody_len) {
@@ -1156,7 +1157,7 @@ static void send_msg_fragmented(struct netconsole_target *nt,
* write, append userdata in this chunk
*/
if (offset + this_offset >= msgbody_len &&
- offset + this_offset < userdata_len + msgbody_len) {
+ offset + this_offset < body_len) {
int sent_userdata = (offset + this_offset) - msgbody_len;
int preceding_bytes = this_chunk + this_header;
--
2.43.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next v2 06/10] net: netconsole: track explicitly if msgbody was written to buffer
2024-09-09 13:07 [PATCH net-next v2 00/10] netconsole refactoring and warning fix Breno Leitao
` (4 preceding siblings ...)
2024-09-09 13:07 ` [PATCH net-next v2 05/10] net: netconsole: introduce variable to track body length Breno Leitao
@ 2024-09-09 13:07 ` Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 07/10] net: netconsole: extract release appending into separate function Breno Leitao
` (3 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Breno Leitao @ 2024-09-09 13:07 UTC (permalink / raw)
To: kuba, davem, edumazet, pabeni
Cc: thepacketgeek, horms, netdev, linux-kernel, davej, vlad.wing, max
The current check to determine if the message body was fully sent is
difficult to follow. To improve clarity, introduce a variable that
explicitly tracks whether the message body (msgbody) has been completely
sent, indicating when it's time to begin sending userdata.
Additionally, add comments to make the code more understandable for
others who may work with it.
Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Simon Horman <horms@kernel.org>
---
drivers/net/netconsole.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index e3350016db0d..1366b948bcbf 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1128,6 +1128,7 @@ static void send_msg_fragmented(struct netconsole_target *nt,
*/
while (offset < body_len) {
int this_header = header_len;
+ bool msgbody_written = false;
int this_offset = 0;
int this_chunk = 0;
@@ -1156,9 +1157,12 @@ static void send_msg_fragmented(struct netconsole_target *nt,
/* Msg body is fully written and there is pending userdata to
* write, append userdata in this chunk
*/
- if (offset + this_offset >= msgbody_len &&
- offset + this_offset < body_len) {
+ if (msgbody_written && offset + this_offset < body_len) {
+ /* Track how much user data was already sent. First
+ * time here, sent_userdata is zero
+ */
int sent_userdata = (offset + this_offset) - msgbody_len;
+ /* offset of bytes used in current buf */
int preceding_bytes = this_chunk + this_header;
if (WARN_ON_ONCE(sent_userdata < 0))
--
2.43.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next v2 07/10] net: netconsole: extract release appending into separate function
2024-09-09 13:07 [PATCH net-next v2 00/10] netconsole refactoring and warning fix Breno Leitao
` (5 preceding siblings ...)
2024-09-09 13:07 ` [PATCH net-next v2 06/10] net: netconsole: track explicitly if msgbody was written to buffer Breno Leitao
@ 2024-09-09 13:07 ` Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 08/10] net: netconsole: do not pass userdata up to the tail Breno Leitao
` (2 subsequent siblings)
9 siblings, 0 replies; 15+ messages in thread
From: Breno Leitao @ 2024-09-09 13:07 UTC (permalink / raw)
To: kuba, davem, edumazet, pabeni
Cc: thepacketgeek, horms, netdev, linux-kernel, davej, vlad.wing, max
Refactor the code by extracting the logic for appending the
release into the buffer into a separate function.
The goal is to reduce the size of send_msg_fragmented() and improve
code readability.
Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Simon Horman <horms@kernel.org>
---
drivers/net/netconsole.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 1366b948bcbf..2cdd2d6a2a18 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1084,6 +1084,14 @@ static void send_msg_no_fragmentation(struct netconsole_target *nt,
netpoll_send_udp(&nt->np, buf, msg_len);
}
+static void append_release(char *buf)
+{
+ const char *release;
+
+ release = init_utsname()->release;
+ scnprintf(buf, MAX_PRINT_CHUNK, "%s,", release);
+}
+
static void send_msg_fragmented(struct netconsole_target *nt,
const char *msg,
const char *userdata,
@@ -1094,7 +1102,6 @@ static void send_msg_fragmented(struct netconsole_target *nt,
static char buf[MAX_PRINT_CHUNK]; /* protected by target_list_lock */
int offset = 0, userdata_len = 0;
const char *header, *msgbody;
- const char *release;
if (userdata)
userdata_len = nt->userdata_length;
@@ -1113,10 +1120,8 @@ static void send_msg_fragmented(struct netconsole_target *nt,
* Transfer multiple chunks with the following extra header.
* "ncfrag=<byte-offset>/<total-bytes>"
*/
- if (release_len) {
- release = init_utsname()->release;
- scnprintf(buf, MAX_PRINT_CHUNK, "%s,", release);
- }
+ if (release_len)
+ append_release(buf);
/* Copy the header into the buffer */
memcpy(buf + release_len, header, header_len);
--
2.43.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next v2 08/10] net: netconsole: do not pass userdata up to the tail
2024-09-09 13:07 [PATCH net-next v2 00/10] netconsole refactoring and warning fix Breno Leitao
` (6 preceding siblings ...)
2024-09-09 13:07 ` [PATCH net-next v2 07/10] net: netconsole: extract release appending into separate function Breno Leitao
@ 2024-09-09 13:07 ` Breno Leitao
2024-09-09 16:05 ` Simon Horman
2024-09-09 13:07 ` [PATCH net-next v2 09/10] net: netconsole: split send_msg_fragmented Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 10/10] net: netconsole: fix wrong warning Breno Leitao
9 siblings, 1 reply; 15+ messages in thread
From: Breno Leitao @ 2024-09-09 13:07 UTC (permalink / raw)
To: kuba, davem, edumazet, pabeni
Cc: thepacketgeek, horms, netdev, linux-kernel, davej, vlad.wing, max
Do not pass userdata to send_msg_fragmented, since we can get it later.
This will be more useful in the next patch, where send_msg_fragmented()
will be split even more, and userdata is only necessary in the last
function.
Suggested-by: Simon Horman <horms@kernel.org>
Signed-off-by: Breno Leitao <leitao@debian.org>
---
drivers/net/netconsole.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 2cdd2d6a2a18..4044a6307d44 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1060,13 +1060,17 @@ static struct notifier_block netconsole_netdev_notifier = {
static void send_msg_no_fragmentation(struct netconsole_target *nt,
const char *msg,
- const char *userdata,
int msg_len,
int release_len)
{
static char buf[MAX_PRINT_CHUNK]; /* protected by target_list_lock */
+ const char *userdata = NULL;
const char *release;
+#ifdef CONFIG_NETCONSOLE_DYNAMIC
+ userdata = nt->userdata_complete;
+#endif
+
if (release_len) {
release = init_utsname()->release;
@@ -1094,7 +1098,6 @@ static void append_release(char *buf)
static void send_msg_fragmented(struct netconsole_target *nt,
const char *msg,
- const char *userdata,
int msg_len,
int release_len)
{
@@ -1103,8 +1106,10 @@ static void send_msg_fragmented(struct netconsole_target *nt,
int offset = 0, userdata_len = 0;
const char *header, *msgbody;
- if (userdata)
- userdata_len = nt->userdata_length;
+#ifdef CONFIG_NETCONSOLE_DYNAMIC
+ userdata = nt->userdata_complete;
+ userdata_len = nt->userdata_length;
+#endif
/* need to insert extra header fields, detect header and msgbody */
header = msg;
@@ -1201,12 +1206,10 @@ static void send_msg_fragmented(struct netconsole_target *nt,
static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg,
int msg_len)
{
- char *userdata = NULL;
int userdata_len = 0;
int release_len = 0;
#ifdef CONFIG_NETCONSOLE_DYNAMIC
- userdata = nt->userdata_complete;
userdata_len = nt->userdata_length;
#endif
@@ -1214,10 +1217,9 @@ static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg,
release_len = strlen(init_utsname()->release) + 1;
if (msg_len + release_len + userdata_len <= MAX_PRINT_CHUNK)
- return send_msg_no_fragmentation(nt, msg, userdata, msg_len,
- release_len);
+ return send_msg_no_fragmentation(nt, msg, msg_len, release_len);
- return send_msg_fragmented(nt, msg, userdata, msg_len, release_len);
+ return send_msg_fragmented(nt, msg, msg_len, release_len);
}
static void write_ext_msg(struct console *con, const char *msg,
--
2.43.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next v2 09/10] net: netconsole: split send_msg_fragmented
2024-09-09 13:07 [PATCH net-next v2 00/10] netconsole refactoring and warning fix Breno Leitao
` (7 preceding siblings ...)
2024-09-09 13:07 ` [PATCH net-next v2 08/10] net: netconsole: do not pass userdata up to the tail Breno Leitao
@ 2024-09-09 13:07 ` Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 10/10] net: netconsole: fix wrong warning Breno Leitao
9 siblings, 0 replies; 15+ messages in thread
From: Breno Leitao @ 2024-09-09 13:07 UTC (permalink / raw)
To: kuba, davem, edumazet, pabeni
Cc: thepacketgeek, horms, netdev, linux-kernel, davej, vlad.wing, max
Refactor the send_msg_fragmented() function by extracting the logic for
sending the message body into a new function called
send_fragmented_body().
Now, send_msg_fragmented() handles appending the release and header, and
then delegates the task of breaking up the body and sending the
fragments to send_fragmented_body().
This is the final flow now:
When send_ext_msg_udp() is called to send a message, it will:
- call send_msg_no_fragmentation() if no fragmentation is needed
or
- call send_msg_fragmented() if fragmentation is needed
* send_msg_fragmented() appends the header to the buffer, which is
be persisted until the function returns
* call send_fragmented_body() to iterate and populate the body of
the message. It will not touch the header, and it will only
replace the body, writing the msgbody and/or userdata.
Also add some comment to make the code easier to review.
Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Simon Horman <horms@kernel.org>
---
drivers/net/netconsole.c | 82 +++++++++++++++++++++++++---------------
1 file changed, 51 insertions(+), 31 deletions(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 4044a6307d44..6a778a8690c3 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1096,45 +1096,30 @@ static void append_release(char *buf)
scnprintf(buf, MAX_PRINT_CHUNK, "%s,", release);
}
-static void send_msg_fragmented(struct netconsole_target *nt,
- const char *msg,
- int msg_len,
- int release_len)
+static void send_fragmented_body(struct netconsole_target *nt, char *buf,
+ const char *msgbody, int header_len,
+ int msgbody_len)
{
- int header_len, msgbody_len, body_len;
- static char buf[MAX_PRINT_CHUNK]; /* protected by target_list_lock */
- int offset = 0, userdata_len = 0;
- const char *header, *msgbody;
+ int body_len, offset = 0;
+ const char *userdata = NULL;
+ int userdata_len = 0;
#ifdef CONFIG_NETCONSOLE_DYNAMIC
userdata = nt->userdata_complete;
userdata_len = nt->userdata_length;
#endif
- /* need to insert extra header fields, detect header and msgbody */
- header = msg;
- msgbody = memchr(msg, ';', msg_len);
- if (WARN_ON_ONCE(!msgbody))
- return;
-
- header_len = msgbody - header;
- msgbody_len = msg_len - header_len - 1;
- msgbody++;
-
- /*
- * Transfer multiple chunks with the following extra header.
- * "ncfrag=<byte-offset>/<total-bytes>"
+ /* boy_len represents the number of bytes that will be sent. This is
+ * bigger than MAX_PRINT_CHUNK, thus, it will be split in multiple
+ * packets
*/
- if (release_len)
- append_release(buf);
-
- /* Copy the header into the buffer */
- memcpy(buf + release_len, header, header_len);
- header_len += release_len;
-
body_len = msgbody_len + userdata_len;
- /* for now on, the header will be persisted, and the msgbody
- * will be replaced
+
+ /* In each iteration of the while loop below, we send a packet
+ * containing the header and a portion of the body. The body is
+ * composed of two parts: msgbody and userdata. We keep track of how
+ * many bytes have been sent so far using the offset variable, which
+ * ranges from 0 to the total length of the body.
*/
while (offset < body_len) {
int this_header = header_len;
@@ -1143,7 +1128,7 @@ static void send_msg_fragmented(struct netconsole_target *nt,
int this_chunk = 0;
this_header += scnprintf(buf + this_header,
- sizeof(buf) - this_header,
+ MAX_PRINT_CHUNK - this_header,
",ncfrag=%d/%d;", offset,
body_len);
@@ -1193,6 +1178,41 @@ static void send_msg_fragmented(struct netconsole_target *nt,
}
}
+static void send_msg_fragmented(struct netconsole_target *nt,
+ const char *msg,
+ int msg_len,
+ int release_len)
+{
+ static char buf[MAX_PRINT_CHUNK]; /* protected by target_list_lock */
+ int header_len, msgbody_len;
+ const char *msgbody;
+
+ /* need to insert extra header fields, detect header and msgbody */
+ msgbody = memchr(msg, ';', msg_len);
+ if (WARN_ON_ONCE(!msgbody))
+ return;
+
+ header_len = msgbody - msg;
+ msgbody_len = msg_len - header_len - 1;
+ msgbody++;
+
+ /*
+ * Transfer multiple chunks with the following extra header.
+ * "ncfrag=<byte-offset>/<total-bytes>"
+ */
+ if (release_len)
+ append_release(buf);
+
+ /* Copy the header into the buffer */
+ memcpy(buf + release_len, msg, header_len);
+ header_len += release_len;
+
+ /* for now on, the header will be persisted, and the msgbody
+ * will be replaced
+ */
+ send_fragmented_body(nt, buf, msgbody, header_len, msgbody_len);
+}
+
/**
* send_ext_msg_udp - send extended log message to target
* @nt: target to send message to
--
2.43.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH net-next v2 10/10] net: netconsole: fix wrong warning
2024-09-09 13:07 [PATCH net-next v2 00/10] netconsole refactoring and warning fix Breno Leitao
` (8 preceding siblings ...)
2024-09-09 13:07 ` [PATCH net-next v2 09/10] net: netconsole: split send_msg_fragmented Breno Leitao
@ 2024-09-09 13:07 ` Breno Leitao
9 siblings, 0 replies; 15+ messages in thread
From: Breno Leitao @ 2024-09-09 13:07 UTC (permalink / raw)
To: kuba, davem, edumazet, pabeni, Matthew Wood
Cc: horms, netdev, linux-kernel, davej, vlad.wing, max
A warning is triggered when there is insufficient space in the buffer
for userdata. However, this is not an issue since userdata will be sent
in the next iteration.
Current warning message:
------------[ cut here ]------------
WARNING: CPU: 13 PID: 3013042 at drivers/net/netconsole.c:1122 write_ext_msg+0x3b6/0x3d0
? write_ext_msg+0x3b6/0x3d0
console_flush_all+0x1e9/0x330
The code incorrectly issues a warning when this_chunk is zero, which is
a valid scenario. The warning should only be triggered when this_chunk
is negative.
Signed-off-by: Breno Leitao <leitao@debian.org>
Fixes: 1ec9daf95093 ("net: netconsole: append userdata to fragmented netconsole messages")
---
drivers/net/netconsole.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 6a778a8690c3..7d2e021f04f4 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -1165,8 +1165,14 @@ static void send_fragmented_body(struct netconsole_target *nt, char *buf,
this_chunk = min(userdata_len - sent_userdata,
MAX_PRINT_CHUNK - preceding_bytes);
- if (WARN_ON_ONCE(this_chunk <= 0))
+ if (WARN_ON_ONCE(this_chunk < 0))
+ /* this_chunk could be zero if all the previous
+ * message used all the buffer. This is not a
+ * problem, userdata will be sent in the next
+ * iteration
+ */
return;
+
memcpy(buf + this_header + this_offset,
userdata + sent_userdata,
this_chunk);
--
2.43.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH net-next v2 02/10] net: netconsole: split send_ext_msg_udp() function
2024-09-09 13:07 ` [PATCH net-next v2 02/10] net: netconsole: split send_ext_msg_udp() function Breno Leitao
@ 2024-09-09 15:58 ` Simon Horman
0 siblings, 0 replies; 15+ messages in thread
From: Simon Horman @ 2024-09-09 15:58 UTC (permalink / raw)
To: Breno Leitao
Cc: kuba, davem, edumazet, pabeni, thepacketgeek, netdev,
linux-kernel, davej, vlad.wing, max
On Mon, Sep 09, 2024 at 06:07:43AM -0700, Breno Leitao wrote:
> The send_ext_msg_udp() function has become quite large, currently
> spanning 102 lines. Its complexity, along with extensive pointer and
> offset manipulation, makes it difficult to read and error-prone.
>
> The function has evolved over time, and it’s now due for a refactor.
>
> To improve readability and maintainability, isolate the case where no
> message fragmentation occurs into a separate function, into a new
> send_msg_no_fragmentation() function. This scenario covers about 95% of
> the messages.
>
> Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next v2 04/10] net: netconsole: rename body to msg_body
2024-09-09 13:07 ` [PATCH net-next v2 04/10] net: netconsole: rename body to msg_body Breno Leitao
@ 2024-09-09 16:03 ` Simon Horman
0 siblings, 0 replies; 15+ messages in thread
From: Simon Horman @ 2024-09-09 16:03 UTC (permalink / raw)
To: Breno Leitao
Cc: kuba, davem, edumazet, pabeni, thepacketgeek, netdev,
linux-kernel, davej, vlad.wing, max
On Mon, Sep 09, 2024 at 06:07:45AM -0700, Breno Leitao wrote:
> With the introduction of the userdata concept, the term body has become
> ambiguous and less intuitive.
>
> To improve clarity, body is renamed to msg_body, making it clear that
> the body is not the only content following the header.
>
> In an upcoming patch, the term body_len will also be revised for further
> clarity.
>
> The current packet structure is as follows:
>
> release, header, body, [msg_body + userdata]
>
> Here, [msg_body + userdata] collectively forms what is currently
> referred to as "body." This renaming helps to distinguish and better
> understand each component of the packet.
>
> Signed-off-by: Breno Leitao <leitao@debian.org>
> Reviewed-by: Simon Horman <horms@kernel.org>
> ---
> drivers/net/netconsole.c | 48 +++++++++++++++++++++++-----------------
> 1 file changed, 28 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
> index 8faea9422ea1..c312ad6d5cf8 100644
> --- a/drivers/net/netconsole.c
> +++ b/drivers/net/netconsole.c
> @@ -1092,22 +1092,22 @@ static void send_msg_fragmented(struct netconsole_target *nt,
> {
> static char buf[MAX_PRINT_CHUNK]; /* protected by target_list_lock */
> int offset = 0, userdata_len = 0;
> - const char *header, *body;
> - int header_len, body_len;
> + const char *header, *msgbody;
> + int header_len, msgbody_len;
> const char *release;
>
> if (userdata)
> userdata_len = nt->userdata_length;
>
> - /* need to insert extra header fields, detect header and body */
> + /* need to insert extra header fields, detect header and msgbody */
> header = msg;
> - body = memchr(msg, ';', msg_len);
> - if (WARN_ON_ONCE(!body))
> + msgbody = memchr(msg, ';', msg_len);
> + if (WARN_ON_ONCE(!msgbody))
> return;
>
> - header_len = body - header;
> - body_len = msg_len - header_len - 1;
> - body++;
> + header_len = msgbody - header;
> + msgbody_len = msg_len - header_len - 1;
> + msgbody++;
>
> /*
> * Transfer multiple chunks with the following extra header.
> @@ -1122,10 +1122,10 @@ static void send_msg_fragmented(struct netconsole_target *nt,
> memcpy(buf + release_len, header, header_len);
> header_len += release_len;
>
> - /* for now on, the header will be persisted, and the body
> + /* for now on, the header will be persisted, and the msgbody
> * will be replaced
> */
> - while (offset < body_len + userdata_len) {
> + while (offset < msgbody_len + userdata_len) {
> int this_header = header_len;
> int this_offset = 0;
> int this_chunk = 0;
> @@ -1133,23 +1133,31 @@ static void send_msg_fragmented(struct netconsole_target *nt,
> this_header += scnprintf(buf + this_header,
> sizeof(buf) - this_header,
> ",ncfrag=%d/%d;", offset,
> - body_len + userdata_len);
> + msgbody_len + userdata_len);
>
> - /* Not all body data has been written yet */
> - if (offset < body_len) {
> - this_chunk = min(body_len - offset,
> + /* Not all msgbody data has been written yet */
> + if (offset < msgbody_len) {
> + this_chunk = min(msgbody_len - offset,
> MAX_PRINT_CHUNK - this_header);
> if (WARN_ON_ONCE(this_chunk <= 0))
> return;
> - memcpy(buf + this_header, body + offset, this_chunk);
> + memcpy(buf + this_header, msgbody + offset, this_chunk);
> this_offset += this_chunk;
> }
> - /* Body is fully written and there is pending userdata to write,
> - * append userdata in this chunk
> +
> + if (offset + this_offset >= msgbody_len)
> + /* msgbody was finally written, either in the previous
> + * messages and/or in the current buf. Time to write
> + * the userdata.
> + */
> + msgbody_written = true;
Something went a bit wrong somewhere, msgbody_written isn't declared
in this scope.
> +
> + /* Msg body is fully written and there is pending userdata to
> + * write, append userdata in this chunk
> */
> - if (offset + this_offset >= body_len &&
> - offset + this_offset < userdata_len + body_len) {
> - int sent_userdata = (offset + this_offset) - body_len;
> + if (offset + this_offset >= msgbody_len &&
> + offset + this_offset < userdata_len + msgbody_len) {
> + int sent_userdata = (offset + this_offset) - msgbody_len;
> int preceding_bytes = this_chunk + this_header;
>
> if (WARN_ON_ONCE(sent_userdata < 0))
--
pw-bot: cr
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next v2 08/10] net: netconsole: do not pass userdata up to the tail
2024-09-09 13:07 ` [PATCH net-next v2 08/10] net: netconsole: do not pass userdata up to the tail Breno Leitao
@ 2024-09-09 16:05 ` Simon Horman
2024-09-10 9:44 ` Breno Leitao
0 siblings, 1 reply; 15+ messages in thread
From: Simon Horman @ 2024-09-09 16:05 UTC (permalink / raw)
To: Breno Leitao
Cc: kuba, davem, edumazet, pabeni, thepacketgeek, netdev,
linux-kernel, davej, vlad.wing, max
On Mon, Sep 09, 2024 at 06:07:49AM -0700, Breno Leitao wrote:
> Do not pass userdata to send_msg_fragmented, since we can get it later.
>
> This will be more useful in the next patch, where send_msg_fragmented()
> will be split even more, and userdata is only necessary in the last
> function.
>
> Suggested-by: Simon Horman <horms@kernel.org>
> Signed-off-by: Breno Leitao <leitao@debian.org>
...
> @@ -1094,7 +1098,6 @@ static void append_release(char *buf)
>
> static void send_msg_fragmented(struct netconsole_target *nt,
> const char *msg,
> - const char *userdata,
> int msg_len,
> int release_len)
> {
> @@ -1103,8 +1106,10 @@ static void send_msg_fragmented(struct netconsole_target *nt,
> int offset = 0, userdata_len = 0;
> const char *header, *msgbody;
>
> - if (userdata)
> - userdata_len = nt->userdata_length;
> +#ifdef CONFIG_NETCONSOLE_DYNAMIC
> + userdata = nt->userdata_complete;
> + userdata_len = nt->userdata_length;
> +#endif
userdata does not appear to be declared in this scope :(
.../netconsole.c:1110:9: error: 'userdata' undeclared (first use in this function)
1110 | userdata = nt->userdata_complete;
>
> /* need to insert extra header fields, detect header and msgbody */
> header = msg;
...
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH net-next v2 08/10] net: netconsole: do not pass userdata up to the tail
2024-09-09 16:05 ` Simon Horman
@ 2024-09-10 9:44 ` Breno Leitao
0 siblings, 0 replies; 15+ messages in thread
From: Breno Leitao @ 2024-09-10 9:44 UTC (permalink / raw)
To: Simon Horman
Cc: kuba, davem, edumazet, pabeni, thepacketgeek, netdev,
linux-kernel, davej, vlad.wing, max
On Mon, Sep 09, 2024 at 05:05:28PM +0100, Simon Horman wrote:
> On Mon, Sep 09, 2024 at 06:07:49AM -0700, Breno Leitao wrote:
> > Do not pass userdata to send_msg_fragmented, since we can get it later.
> >
> > This will be more useful in the next patch, where send_msg_fragmented()
> > will be split even more, and userdata is only necessary in the last
> > function.
> >
> > Suggested-by: Simon Horman <horms@kernel.org>
> > Signed-off-by: Breno Leitao <leitao@debian.org>
>
> ...
>
> > @@ -1094,7 +1098,6 @@ static void append_release(char *buf)
> >
> > static void send_msg_fragmented(struct netconsole_target *nt,
> > const char *msg,
> > - const char *userdata,
> > int msg_len,
> > int release_len)
> > {
> > @@ -1103,8 +1106,10 @@ static void send_msg_fragmented(struct netconsole_target *nt,
> > int offset = 0, userdata_len = 0;
> > const char *header, *msgbody;
> >
> > - if (userdata)
> > - userdata_len = nt->userdata_length;
> > +#ifdef CONFIG_NETCONSOLE_DYNAMIC
> > + userdata = nt->userdata_complete;
> > + userdata_len = nt->userdata_length;
> > +#endif
>
> userdata does not appear to be declared in this scope :(
>
> .../netconsole.c:1110:9: error: 'userdata' undeclared (first use in this function)
> 1110 | userdata = nt->userdata_complete;
Oh, during my rebase, I moved the declaration to a patch forward, and I
didn't catch this because I was just compiling and testing with the
whole patchset applied.
Thanks for catching it. I will send an updated version.
--breno
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2024-09-10 9:44 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-09 13:07 [PATCH net-next v2 00/10] netconsole refactoring and warning fix Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 01/10] net: netconsole: remove msg_ready variable Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 02/10] net: netconsole: split send_ext_msg_udp() function Breno Leitao
2024-09-09 15:58 ` Simon Horman
2024-09-09 13:07 ` [PATCH net-next v2 03/10] net: netconsole: separate fragmented message handling in send_ext_msg Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 04/10] net: netconsole: rename body to msg_body Breno Leitao
2024-09-09 16:03 ` Simon Horman
2024-09-09 13:07 ` [PATCH net-next v2 05/10] net: netconsole: introduce variable to track body length Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 06/10] net: netconsole: track explicitly if msgbody was written to buffer Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 07/10] net: netconsole: extract release appending into separate function Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 08/10] net: netconsole: do not pass userdata up to the tail Breno Leitao
2024-09-09 16:05 ` Simon Horman
2024-09-10 9:44 ` Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 09/10] net: netconsole: split send_msg_fragmented Breno Leitao
2024-09-09 13:07 ` [PATCH net-next v2 10/10] net: netconsole: fix wrong warning Breno Leitao
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).