Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp240438lqc; Thu, 7 Mar 2024 16:25:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXdB6GiTOX6VreXZK5s4uhYJ2iYYSIqIDNNSL0MpHdWatjA+GCvBR4AoafHC0gYaVJs56OZfw0u4b8TjeM3qz55wMHREaQWi1kH2NberA== X-Google-Smtp-Source: AGHT+IErLrMm+5/ScAgGO3t6V9PI1hs1t8XWDv5NvMzrW/3SMHF6X2jDFFr9molE2ql0UD9p9GSu X-Received: by 2002:a05:620a:13c7:b0:788:1f35:3700 with SMTP id g7-20020a05620a13c700b007881f353700mr8880305qkl.70.1709857544104; Thu, 07 Mar 2024 16:25:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709857544; cv=pass; d=google.com; s=arc-20160816; b=E2nlLy05JGXsM87JXPCj56qyl4Xdh0QqxDSIH7fce029B63YRbUjJDpK2XgkWBa6Mj e3IGv/wSb8jyL+JPbIDt7aSy6M2Kp8bEQqW23zqsAlJE434lgpD3373x71HB1JGpgm83 FodlGjbcTCLQqsxZs7PoId07hcFSoqs2mIw0W1uRW/wOjPK46K0pt3NsZ9pa/sWrRRKa lNgruTDKEgrBaFoTObFvGv5l9v1hXMNndYKRfpjsWf8diaxEb/cwY3ChsmixWaAFqHFt uZpqajziAYPMEauCwDB2DMJ1+wjaWhHmTNjfPpKi4+jBmq+5/hTRvppfkM/wjUSfF+PN nLwQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=fGA5+tZzMeOjlHUhcX3WLJZzgdRHTP/pyb/RcLBJvao=; fh=4ti4CPqH+AYHBh3xbtkjg6iYq98Z5SCxvm5K1yzLHxI=; b=OAzTYd9wavuNhRsC6z2U2w+unODJQ19y/M1v/J2q7oXkpoRctOzlV8B0pdveLDOC5Q tiQLyaAmiL4/PmPE37HFNoib9s50nAXAebb1xO8KOwz4wf/JwCga2PKGTIRkewABMgyT EaLaMUmMSUe8UQeKEovdxIk6/Msh8ePJRiqI0bQgAo1X7bALK9X7jTY3j5oZc0gmf+36 OqMgMJCFaseM7ck6V/VPnjEZjoRJf2PJMl45R+FpI80PmjmzL4LU+0+ewaDDeyvBUAvV wHueGejeZyOQV7mmrAX12PG2PXi71uVjJt7D9oSvX8iw4cJGwAgIjuavV/jn++z4Lrqc oaMQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RHvKvv5h; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-96392-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96392-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id c19-20020a05620a11b300b0078819573ce5si13140819qkk.576.2024.03.07.16.25.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 16:25:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96392-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=RHvKvv5h; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-96392-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96392-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 73C1C1C20F4C for ; Fri, 8 Mar 2024 00:25:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 32EDC1103; Fri, 8 Mar 2024 00:25:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RHvKvv5h" Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EDD6E163; Fri, 8 Mar 2024 00:25:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709857531; cv=none; b=l5RsBzneC67X1x5IJOcCiSAZVdnIcS5uPDqr8YguD8id6aNZBQReTE5DOCbAlxpAdMh45qncE1IIGZqpR1JHaN1QyDkEfcr7N6E9MBdL+db9lN1IyKYbaacuQ5lQZBo8aPWVBV/K5YtKSOrzBdxjTVGB2WkW2kAenyUoCI90aOc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709857531; c=relaxed/simple; bh=NoWiEoGffuJezyZWQ17Um+qaB1+8zBLrVs97fy9ve34=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=BDSHklF7/qBACaj/PdG6StH+WFOQhwGh/7/yVq97ycYHiRflhxhG4q+F62/SaMO1QPSSiuHS2AykjK4T3ycSjtMA/giJAVNm1weQTfFdW/BUJdbakXNRqvzsZ6fRLUwnFY/92eZCC/tsJCu5bvPKm1vN9JF2l4CQMPIjHPxjJy4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=RHvKvv5h; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-6e55b33ad14so943978b3a.1; Thu, 07 Mar 2024 16:25:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1709857527; x=1710462327; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fGA5+tZzMeOjlHUhcX3WLJZzgdRHTP/pyb/RcLBJvao=; b=RHvKvv5hWIpIKkiqAgBaX/3R7rCX9f48N4UK193aoLf8F5L+SZ+cbwpnO5cJBnmSEL zWFF4maCXqwirfq53NZh6M3OPxVvBl9ZEAOxpHzyZm6p7klv36q2y76kFA+VpwQZDBRO adYWmQKPJY23DbHTmTHmzVsB45MQkyUusQoGA6SexiPVgSkeJvxH8aNAQeqsB6DJCYkk +U2sdCC0Whb7qIFFXHiXVs5FPMRMSjNxdqPs/sssTN2uGSVUCODwwfiZ8529rNagXa36 vd9jAUBEoAftRboSFJwcw2oA2QOfk+YgDJ1y92ASq4glDOccga1bptS0abt147696cCH BWPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709857527; x=1710462327; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fGA5+tZzMeOjlHUhcX3WLJZzgdRHTP/pyb/RcLBJvao=; b=TyuhsAPuo2L2vCbFNgDzeciNTjDOZEkglShFZ5WMaQIBSZoglShqaT1ikYg7izeFAq pz7AqMrXqbnrHDz18KmWu37vwZVl/L9/rKUwN2GQ7dy/4aBvy8mtp7+eib92lqd2KMC8 z9p4UisYphZskiVFKGgXLppUNMCDMlcL1LW6ASgJb9b6RjPMHlLzKjZrVzWv3Gj7ysPf H738axSAUB+l734Mbx7jbdo5TlvYKhv9suQnQLiiSG84S3xguJzsh64bl+oTv/W4DNDQ jCJH9h2uSelkqNrxxc9S74PxDD3WX3ubug9EyafXzl9SwR4Ek33yJT7aAxZ+TFlSY0sU OhkQ== X-Forwarded-Encrypted: i=1; AJvYcCXdyRljzXFUxt+LFFXIDW/ZGJIqASgeLgbsPjq+JIo6rJb0+8kj9cKfruekijicZzCsKQut9E/VKfrwZxX+YmDxmAE3hjyPPV6oXjWbb97h70H+adiyOoUdPzj+tkuN5laurBIAAkBl X-Gm-Message-State: AOJu0YyC57z/NdYkLdoiI4i2/RfUnan4WD93kEfPj71anfNqJGtT1U04 kAbXIspsO1ZjPi4WIoBvMAYqAk4ZZYxHmoLN9dbOFf3oyPFGtUmI X-Received: by 2002:a05:6a20:a106:b0:1a1:82fc:94e2 with SMTP id q6-20020a056a20a10600b001a182fc94e2mr145477pzk.44.1709857527115; Thu, 07 Mar 2024 16:25:27 -0800 (PST) Received: from localhost ([2601:644:9381:2f20::5510]) by smtp.gmail.com with ESMTPSA id p12-20020aa7860c000000b006e50e79f155sm13050105pfn.60.2024.03.07.16.25.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 16:25:26 -0800 (PST) From: Matthew Wood To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Breno Leitao Cc: netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v4] net: netconsole: Add continuation line prefix to userdata messages Date: Thu, 7 Mar 2024 16:25:24 -0800 Message-ID: <20240308002525.248672-1-thepacketgeek@gmail.com> X-Mailer: git-send-email 2.44.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add a space (' ') prefix to every userdata line to match docs for dev-kmsg. To account for this extra character in each userdata entry, reduce userdata entry names (directory name) from 54 characters to 53. According to the dev-kmsg docs, a space is used for subsequent lines to mark them as continuation lines. > A line starting with ' ', is a continuation line, adding > key/value pairs to the log message, which provide the machine > readable context of the message, for reliable processing in > userspace. Testing for this patch:: cd /sys/kernel/config/netconsole && mkdir cmdline0 cd cmdline0 mkdir userdata/test && echo "hello" > userdata/test/value mkdir userdata/test2 && echo "hello2" > userdata/test2/value echo "message" > /dev/kmsg Outputs:: 6.8.0-rc5-virtme,12,493,231373579,-;message test=hello test2=hello2 And I confirmed all testing works as expected from the original patchset Fixes: df03f830d099 ("net: netconsole: cache userdata formatted string in netconsole_target") Signed-off-by: Matthew Wood --- Documentation/networking/netconsole.rst | 8 ++++---- drivers/net/netconsole.c | 12 +++++++----- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Documentation/networking/netconsole.rst b/Documentation/networking/netconsole.rst index b28c525e5d1e..d55c2a22ec7a 100644 --- a/Documentation/networking/netconsole.rst +++ b/Documentation/networking/netconsole.rst @@ -180,7 +180,7 @@ Custom user data can be appended to the end of messages with netconsole dynamic configuration enabled. User data entries can be modified without changing the "enabled" attribute of a target. -Directories (keys) under `userdata` are limited to 54 character length, and +Directories (keys) under `userdata` are limited to 53 character length, and data in `userdata//value` are limited to 200 bytes:: cd /sys/kernel/config/netconsole && mkdir cmdline0 @@ -197,8 +197,8 @@ Messages will now include this additional user data:: Sends:: 12,607,22085407756,-;This is a message - foo=bar - qux=baz + foo=bar + qux=baz Preview the userdata that will be appended with:: @@ -218,7 +218,7 @@ The `qux` key is omitted since it has no value:: echo "This is a message" > /dev/kmsg 12,607,22085407756,-;This is a message - foo=bar + foo=bar Delete `userdata` entries with `rmdir`:: diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 0de108a1c0c8..d7070dd4fe73 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -42,12 +42,14 @@ MODULE_AUTHOR("Maintainer: Matt Mackall "); MODULE_DESCRIPTION("Console driver for network interfaces"); MODULE_LICENSE("GPL"); -#define MAX_PARAM_LENGTH 256 -#define MAX_USERDATA_NAME_LENGTH 54 -#define MAX_USERDATA_VALUE_LENGTH 200 +#define MAX_PARAM_LENGTH 256 #define MAX_USERDATA_ENTRY_LENGTH 256 +#define MAX_USERDATA_VALUE_LENGTH 200 +/* The number 3 comes from userdata entry format characters (' ', '=', '\n') */ +#define MAX_USERDATA_NAME_LENGTH (MAX_USERDATA_ENTRY_LENGTH - \ + MAX_USERDATA_VALUE_LENGTH - 3) #define MAX_USERDATA_ITEMS 16 -#define MAX_PRINT_CHUNK 1000 +#define MAX_PRINT_CHUNK 1000 static char config[MAX_PARAM_LENGTH]; module_param_string(netconsole, config, MAX_PARAM_LENGTH, 0); @@ -671,7 +673,7 @@ static void update_userdata(struct netconsole_target *nt) * checked to not exceed MAX items with child_count above */ complete_idx += scnprintf(&nt->userdata_complete[complete_idx], - MAX_USERDATA_ENTRY_LENGTH, "%s=%s\n", + MAX_USERDATA_ENTRY_LENGTH, " %s=%s\n", item->ci_name, udm_item->value); } nt->userdata_length = strnlen(nt->userdata_complete, -- 2.44.0