aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo Luiz Duarte <[email protected]>2025-06-16 17:08:37 +0000
committerDavid S. Miller <[email protected]>2025-06-18 09:46:10 +0000
commitc5efaabd45ad1c93679c2529f778569cb2b828c6 (patch)
tree6112361dda640af40e5338ffbfdee45eff62f5b2
parentnetconsole: implement configfs for msgid_enabled (diff)
downloadkernel-c5efaabd45ad1c93679c2529f778569cb2b828c6.tar.gz
kernel-c5efaabd45ad1c93679c2529f778569cb2b828c6.zip
netconsole: append msgid to sysdata
Add msgcounter to the netconsole_target struct to generate message IDs. If the msgid_enabled attribute is true, increment msgcounter and append msgid=<msgcounter> to sysdata buffer before sending the message. Signed-off-by: Gustavo Luiz Duarte <[email protected]> Reviewed-by: Breno Leitao <[email protected]> Signed-off-by: David S. Miller <[email protected]>
-rw-r--r--drivers/net/netconsole.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 5e66a568954f..e3722de08ea9 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -125,6 +125,7 @@ enum sysdata_feature {
* @extradata_complete: Cached, formatted string of append
* @userdata_length: String length of usedata in extradata_complete.
* @sysdata_fields: Sysdata features enabled.
+ * @msgcounter: Message sent counter.
* @stats: Packet send stats for the target. Used for debugging.
* @enabled: On / off knob to enable / disable target.
* Visible from userspace (read-write).
@@ -155,6 +156,8 @@ struct netconsole_target {
size_t userdata_length;
/* bit-wise with sysdata_feature bits */
u32 sysdata_fields;
+ /* protected by target_list_lock */
+ u32 msgcounter;
#endif
struct netconsole_target_stats stats;
bool enabled;
@@ -1362,6 +1365,14 @@ static int sysdata_append_release(struct netconsole_target *nt, int offset)
init_utsname()->release);
}
+static int sysdata_append_msgid(struct netconsole_target *nt, int offset)
+{
+ wrapping_assign_add(nt->msgcounter, 1);
+ return scnprintf(&nt->extradata_complete[offset],
+ MAX_EXTRADATA_ENTRY_LEN, " msgid=%u\n",
+ nt->msgcounter);
+}
+
/*
* prepare_extradata - append sysdata at extradata_complete in runtime
* @nt: target to send message to
@@ -1384,6 +1395,8 @@ static int prepare_extradata(struct netconsole_target *nt)
extradata_len += sysdata_append_taskname(nt, extradata_len);
if (nt->sysdata_fields & SYSDATA_RELEASE)
extradata_len += sysdata_append_release(nt, extradata_len);
+ if (nt->sysdata_fields & SYSDATA_MSGID)
+ extradata_len += sysdata_append_msgid(nt, extradata_len);
WARN_ON_ONCE(extradata_len >
MAX_EXTRADATA_ENTRY_LEN * MAX_EXTRADATA_ITEMS);