From patchwork Sun Feb 4 23:27:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wood X-Patchwork-Id: 196593 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp571843dyb; Sun, 4 Feb 2024 15:28:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEUVpLOjQpbKAUYvU20xeTYgdsjuj0M5WzUefDCPDZ+29Ix0lwkf7dKO1c91F8hjsUgduAs X-Received: by 2002:aa7:d8d3:0:b0:560:24e:3ca2 with SMTP id k19-20020aa7d8d3000000b00560024e3ca2mr3415723eds.4.1707089323961; Sun, 04 Feb 2024 15:28:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707089323; cv=pass; d=google.com; s=arc-20160816; b=zI6suIZb/hMiOWICcaRKDr2V6721imHohBksGYv51JQ8Iv+tvbFfz12fB2C+wfA+dN zq7a46ARqr+g6hO205DErPwGURzsG+gbN7BaOn8g0C44Zz5+UasqjJLKqPnh0OTgui6A bt/SDvHIO6i3QAY7rX14SouRPi3DUwIBxzunXGVtgfonZa+0UPrzZcMt6s2IlSGFyryP 602bStMBedYJeI+BVlk859FW4jIo6Jnuqd5TodncOesM3dcJXICbSeTEI/LUzWhCm5wr J9LAe9GEhNSCzE0utFZKap3N5KG0g+520rZE1QDomxMoPyi5zGQ9i4mJA2YK9REwTAcx cPLw== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=vyCq+IsPoW1cFeL3otUPd5WJOAaYH3GsmKkRPvUde5E=; fh=dOzJjqUsPRT92K48KmOJzXQfaoFcYpWDBzsffk8SxaQ=; b=HDvMIbgR9HF3nbpabGqp2DKeFo2o61x4pA6RflsreYauNzQruRjqabp6drcoAePviG UbFtJnrCod7udJUTugx5ObXIiWv15gRhAWdKoFueVPA4YsZA3hFf2DwkEUpDweJJlrIB i/pdLYFcABoNGJEQEasZMNelfNpaIHPjP2wl8fV28MEq+zCm57d5P6OnSkIb2p0QwGkE yVx94j2BrcJqFSM4eoPzBYENJL4P7rfv6TBWcIBuGtPEcusuyuj9XW7hSOBBEp3IrQ2f 1WZ40mbz7kXqRhyfZbHdMp61VRrEN8tukoK9bBCSOMNqGRicWuHSYA7SRZYl8mp/htuh K8hQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aOniHsaw; 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-51934-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51934-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCXgRQ0U7MkG7GjFANoNia7WxqX5+9xW8ww3rli7Sq3alSgsFfh7dSyIW7iFfvuAeu1JKuHdWBs1U/tVhrvRJu2amfodPQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s8-20020a056402520800b0056020716747si1978119edd.178.2024.02.04.15.28.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 15:28:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51934-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=aOniHsaw; 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-51934-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51934-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 8F2F01F21CDD for ; Sun, 4 Feb 2024 23:28:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 50B4E11700; Sun, 4 Feb 2024 23:27:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aOniHsaw" Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) (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 E7894BA57; Sun, 4 Feb 2024 23:27:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.171 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707089271; cv=none; b=g7+CKDsU7C0eYwiXnE2F1AheWQVuJCeQjZ8l1CfXMQnhW3RLN4pjFqb91Wafo2ecWKKFIDRNw7R7derB0k43iRiM7PGgrrzwQTNeMuyanvFs/q1MsSxfdNj7xRhbmZxEb3BvSZgpIBFfkkr4yxaRd/70jrC/c+3wdtwLoSuBZYw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707089271; c=relaxed/simple; bh=hCS2aSunhFrD9DEGkpc79H6g2xpOiEG3QZMlbosGi98=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=oHVVxRGcJSQ1p9v0Qt5I77U5vZ6KMYmfesrJhN8lcI7xsnTbdqwILFjfznEX7IQ9xi3uqy03szZgUTZV7sncRdBU9LDRuTDS6+HI2+4lP6O75mlQOnt0KXcIDTUp+cLFtjudmqh7J7hj/TYpWC3eZevvcQ2sX8vLfoSQmD1ZzPo= 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=aOniHsaw; arc=none smtp.client-ip=209.85.210.171 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-f171.google.com with SMTP id d2e1a72fcca58-6e03b32dfcbso79742b3a.3; Sun, 04 Feb 2024 15:27:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707089269; x=1707694069; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vyCq+IsPoW1cFeL3otUPd5WJOAaYH3GsmKkRPvUde5E=; b=aOniHsawCFgnn5n0e7fbt4jZ1nsnDWMGbIzJdOmZKEP7JgPk1nDevcQw5tFDNTcezN Bh3+aORG+0/EJHaRfB1KBPr39/JzHLzZU1+XShluiQnx5ts0LUU6N0Fi0Rtg1TuvcFSz vzWcyE+ud5xOnXBzpC+NSh+OIFz+G15eWoydP1/OpsIjcmcaFveu9LZgNcL7lzyp288I 5LvkxdlzyH6SwRSgcHceTu9J7BDmuoLV9BxyYzCNRSkXdaGkJ8aBIwAlfYHS+o9dolbY JfQHvUBi6MZoCAq5TQDYspSxsi7v42mJVP85mLVlN7K8XfeQX9e831ku5vMkvf0kQiT3 rPQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707089269; x=1707694069; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vyCq+IsPoW1cFeL3otUPd5WJOAaYH3GsmKkRPvUde5E=; b=r4WCbfb+/9y9kJIty8gtwiJgdcYOl1QgZLETDXqEs0YGc6FciW6OspA6M/9ZPRB1Yw mSS1T+0RtV8SE2Wzi2falaFBlxsa8fwUwFAxiInIDOt7J2+RkweVZir8NiP/nYINn/9S THjJCSusOuUWqzc7gb/Q3jHOH7DU1VikrWgF8ApqIN4Gg7Tb4MruSCrObo3NUB8S1fUa NP6+46M9ydiG27KEBX+zpXanqDZlrWC6CEcyQ+pygN0sjIHXDnO8gaAASv7tzf0Qxh4C 7nSS86FdgX8AmwY+4FiGnQOrndriG9D7ZDE4K93IzdryqXjn5qrULQJHxcj3X/C5HyoJ o33g== X-Gm-Message-State: AOJu0YzuoPmS/7SIokTXputIA4YwpiHOg7OO6q4Ki53iOt7HnrB8VmJa yxdy6kBcSqAp2bu8x1RopHd3kAxq1CxLcAHnLeXor/8/G076asmL X-Received: by 2002:a05:6a20:d044:b0:19c:a2ec:64f with SMTP id hv4-20020a056a20d04400b0019ca2ec064fmr7332654pzb.2.1707089269056; Sun, 04 Feb 2024 15:27:49 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCWOnkq7M4FaqNjLECzIvb8+DPDQ658/5RdxsRHkxVlT8bnGyzNypM4SOPMje4e0tQB+IoDVQ+fwrQMvtr/Y+FGxJHmrKQA0FllzltGZolQEZVBfDMKr7ZFtwMmF0ffgxkrhflSaQTV4Kn8qUoLBI4SjcTCtYGEcuLbRTiB5nJyQIjk/GnsmqMwCJyCatszo6L2GfDSp8XokR9n/dG56 Received: from localhost ([2601:644:9380:8cd0::7fb4]) by smtp.gmail.com with ESMTPSA id s17-20020a632151000000b005cd8044c6fesm5620442pgm.23.2024.02.04.15.27.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 15:27:48 -0800 (PST) From: Matthew Wood To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Breno Leitao , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 1/8] net: netconsole: cleanup formatting lints Date: Sun, 4 Feb 2024 15:27:32 -0800 Message-ID: <20240204232744.91315-2-thepacketgeek@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240204232744.91315-1-thepacketgeek@gmail.com> References: <20240204232744.91315-1-thepacketgeek@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790012894605987971 X-GMAIL-MSGID: 1790012894605987971 Address checkpatch lint suggestions in preparation for later changes Signed-off-by: Matthew Wood Reviewed-by: Breno Leitao --- drivers/net/netconsole.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 6e14ba5e06c8..93fc3b509706 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -49,7 +49,7 @@ static char config[MAX_PARAM_LENGTH]; module_param_string(netconsole, config, MAX_PARAM_LENGTH, 0); MODULE_PARM_DESC(netconsole, " netconsole=[src-port]@[src-ip]/[dev],[tgt-port]@/[tgt-macaddr]"); -static bool oops_only = false; +static bool oops_only; module_param(oops_only, bool, 0600); MODULE_PARM_DESC(oops_only, "Only log oops messages"); @@ -501,6 +501,7 @@ static ssize_t local_ip_store(struct config_item *item, const char *buf, if (strnchr(buf, count, ':')) { const char *end; + if (in6_pton(buf, count, nt->np.local_ip.in6.s6_addr, -1, &end) > 0) { if (*end && *end != '\n') { pr_err("invalid IPv6 address at: <%c>\n", *end); @@ -510,9 +511,9 @@ static ssize_t local_ip_store(struct config_item *item, const char *buf, } else goto out_unlock; } else { - if (!nt->np.ipv6) { + if (!nt->np.ipv6) nt->np.local_ip.ip = in_aton(buf); - } else + else goto out_unlock; } @@ -537,6 +538,7 @@ static ssize_t remote_ip_store(struct config_item *item, const char *buf, if (strnchr(buf, count, ':')) { const char *end; + if (in6_pton(buf, count, nt->np.remote_ip.in6.s6_addr, -1, &end) > 0) { if (*end && *end != '\n') { pr_err("invalid IPv6 address at: <%c>\n", *end); @@ -546,9 +548,9 @@ static ssize_t remote_ip_store(struct config_item *item, const char *buf, } else goto out_unlock; } else { - if (!nt->np.ipv6) { + if (!nt->np.ipv6) nt->np.remote_ip.ip = in_aton(buf); - } else + else goto out_unlock; } @@ -781,6 +783,7 @@ static int netconsole_netdev_event(struct notifier_block *this, spin_unlock_irqrestore(&target_list_lock, flags); if (stopped) { const char *msg = "had an event"; + switch (event) { case NETDEV_UNREGISTER: msg = "unregistered"; From patchwork Sun Feb 4 23:27:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wood X-Patchwork-Id: 196594 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp572183dyb; Sun, 4 Feb 2024 15:30:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYqNboUlBx0/I3kg0N8E7WxbAlx4Bsq7orccqgpKF149OwKTOM6DTqod70DknTZgCADGAZ X-Received: by 2002:a05:6358:d09b:b0:175:7a57:81ed with SMTP id jc27-20020a056358d09b00b001757a5781edmr10126391rwb.23.1707089404973; Sun, 04 Feb 2024 15:30:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707089404; cv=pass; d=google.com; s=arc-20160816; b=VketVUbGxQaRUJ/uNTo2dk3ZCei9e6MaDAxR+9f+d14IpAVVtLtDm8MzH9Btp1VWPW BOuLGoYlKw1MG2IqrP1ZLU7RWsrxHpnZYjCQ0O4TY21qlOQLdNIdU6+8Yrs+8O9dtfGl SiCBjP7Xlt1Rs/CWHeyufCXpi6MGyUpVkEVd+HFfyDIsJlyjLPCUK3PaWUHeYQRC6sQO S/Ti8y8HKTi4TkmXWm4DcM9ZtzXWk7ire/wSQZUweC4McNdEpFhgzC9PSTWgxApKFWA0 XgGLd8sRUUSU0YJrN+eRPz/PT3EWiZ1IrIRfGcGggOp7zffIxUlgr86W3o4jiKzig3FM 98cw== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=FUUoKdZN1IuRsIaFfQ05cFLLrwH0tLTS4XTxE2edstM=; fh=+sn7L3/CRqCev+UD972u6J4dXTbVOVFqZG2xdfACD6w=; b=SLGaXwHapEpLHnPMhGDctN8lN5jcLGkb74p9/T8FZw2zAM52aS6hxF6GcHMngqeAp2 XrVgmQ1KYzn10u/bPC8VqP2vjXMMTe3h85gJrbuP4gUu9JNEH4gj9Q3vMh4UsOjOurNC wIT6+QYGVvU9mmjpgxPuYLH3X/crg2k+sQwkiib0W+DcJYyLcXf/V7kaYA6usADdRuE6 S6OiVZyDcqNKCvYQO1+P3Nw4uXi8V11L59UWxRovUpqzLukTxYNgj3/qzc6CSQLKhsGy NQnx1YRQ5PQZaxcSi1+p2/FMad7fpynhVUgwDcqrGMyfJyrY3WFECxUkTSV3JhYTaGcd JQXg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SpI8B8u1; 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-51937-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51937-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCWfDwnZoJwGTK3WpO4fLpR+PW3Zy5UUviOK7W1YsBYLezsGH69TTtXmQdw/BD2fCbgujSQx0Uku873hfwM+rooeVnIzbw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f9-20020a056a00238900b006e03f93de5csi1106162pfc.30.2024.02.04.15.30.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 15:30:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51937-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=SpI8B8u1; 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-51937-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51937-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id AF8E628103B for ; Sun, 4 Feb 2024 23:30:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D117714A91; Sun, 4 Feb 2024 23:28:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="SpI8B8u1" Received: from mail-oa1-f50.google.com (mail-oa1-f50.google.com [209.85.160.50]) (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 840E512B96; Sun, 4 Feb 2024 23:27:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.50 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707089279; cv=none; b=q1+2FxlKSVhHTZCtvioYZ2uhJAtj3qTA4kpe8IbHqALhwypecVBCrosaNpsNiJpXcU49pIdKu3TzPN90Wfy12IF2ieUrgBkfEJHke9jpifDkjQFY/UoKq1EZISHKQj1SsmniAbTzUUjpuM+JRysPhbhzoHKOI6ow3DQR1bfelz0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707089279; c=relaxed/simple; bh=/n7gte7+g5iz4O3gD/aRaektVHW/cg++aK2ocK/HCRo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XAPcW5VFtUCTMgQZyXhjkhy4MlId/q2lg1yO8ncmmtE2Yas9lyrQ6zhBEHfaKS0vtK67vFZbyYFPw7J7b2+OUUxcu52H8+v8F33HKJKxhZjUiGwu1b9jWO0sZPREs8DUhgbiGhmx26YsB2vH95ivKvGwDgPugJzG5PPPPNIRb/s= 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=SpI8B8u1; arc=none smtp.client-ip=209.85.160.50 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-oa1-f50.google.com with SMTP id 586e51a60fabf-21920f89441so1599589fac.2; Sun, 04 Feb 2024 15:27:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707089275; x=1707694075; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=FUUoKdZN1IuRsIaFfQ05cFLLrwH0tLTS4XTxE2edstM=; b=SpI8B8u1khiz/lkWadE5Bv5yLDamClLhTKLXYEa29+Q53cazsGIiKCetJHWgUDJg4g 3z0Rm00ToXSSJGr3sYeFDguHddNZ/aWdTLnNzJ+xifWKCKhwYtwnVKIkL4xQgeLc+Zkc xtDwWkNCFcG4D7mlpcnHzgzpR67AClRZUsVcfoHgIwhu9MsJKEgLsShXEJbUO1YQFynP jh9qyzaH7BCfK/JP0OW2TTCPbKOKr31gFLlu4XxqVrYhR44plQCUTedfaNKbIHS5K/7L jHQagtSeGcBurEUDJKpHkyS2oWKLkk1HG64J+AlFjES59gkVzFTqaqwt2L8uWU2SMmoj QyOw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707089275; x=1707694075; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FUUoKdZN1IuRsIaFfQ05cFLLrwH0tLTS4XTxE2edstM=; b=d67b5ETlOUEwsjJ4NG+hMqx4hrZwKUY5NGDS0KFGocN+F11Ws3T3pVZsY45DV2lXd/ yBqTbBK6fjb53VFus/OrGe078qxLkZ66I6Qy+tGlBhndJ4eIt012V5ZDqSVddRAXfLFX 0X2x9vbSZgdVPpthkufM8iIKJS3tF3TWWldxiOI5Mh7ESo2OQNyvOlpHhJj90mvFv4rn xbxIRsRDjkNjaNlpJtaiPXc9f9JqIwupxMq+3Z+R1zjJPdcNXNNfEtEvQsL+1n4/jptI lQou/tevvV0yHHFQqFUzmvkUXfe9cuutX+CFDNLXjwi77S16W0i6PRLx0Wf7IHcMuNVm 09ZQ== X-Gm-Message-State: AOJu0YyS1Myw+5q7otRkJIP525qzkw3+CDp8rCvN/DKveZ3VqOnQtcU+ Hbqxwr/ZCN40YSWm/jb1Y83YyAE63MRPAf4Rw9yIMhgIcpIUc+Ov X-Received: by 2002:a05:6871:e717:b0:219:6ced:9500 with SMTP id qa23-20020a056871e71700b002196ced9500mr3396519oac.56.1707089275316; Sun, 04 Feb 2024 15:27:55 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCXTKeT1GHDnGjlk8MnbVTUCDxJMW8cZox1BLrs21FZvkB3rWtj2e2NcosF+j2XFwGOheh+Ia3ZBIRCqooMv3HaIeAO224SkFsqSLnON1CyeJNicJweVJrOCJ4GaH/hEMPCe3A6hX+enN3Zr3TBRF3wPEwE/9qvCMAIYU7Cv/EcU72fDS84zGvgmxQhbQ/gSBidbOI2OcQl0M04egfButJdmwG2KsNYEumyWbDtQYnHf8+oBSYRNIWMV6bGwODmg18zycIhpHa2Q6g== Received: from localhost ([2601:644:9380:8cd0::7fb4]) by smtp.gmail.com with ESMTPSA id l37-20020a635725000000b005d66caee3d0sm5612417pgb.22.2024.02.04.15.27.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 15:27:55 -0800 (PST) From: Matthew Wood To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet Cc: Breno Leitao , netdev@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 4/8] net: netconsole: add docs for appending netconsole user data Date: Sun, 4 Feb 2024 15:27:35 -0800 Message-ID: <20240204232744.91315-5-thepacketgeek@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240204232744.91315-1-thepacketgeek@gmail.com> References: <20240204232744.91315-1-thepacketgeek@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790012979917416201 X-GMAIL-MSGID: 1790012979917416201 Add a new User Data section to the netconsole docs to describe the appending of user data capability (for netconsole dynamic configuration) with usage and netconsole output examples. Co-developed-by: Breno Leitao Signed-off-by: Breno Leitao Signed-off-by: Matthew Wood --- Documentation/networking/netconsole.rst | 66 +++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/Documentation/networking/netconsole.rst b/Documentation/networking/netconsole.rst index 390730a74332..b28c525e5d1e 100644 --- a/Documentation/networking/netconsole.rst +++ b/Documentation/networking/netconsole.rst @@ -15,6 +15,8 @@ Extended console support by Tejun Heo , May 1 2015 Release prepend support by Breno Leitao , Jul 7 2023 +Userdata append support by Matthew Wood , Jan 22 2024 + Please send bug reports to Matt Mackall Satyam Sharma , and Cong Wang @@ -171,6 +173,70 @@ You can modify these targets in runtime by creating the following targets:: cat cmdline1/remote_ip 10.0.0.3 +Append User Data +---------------- + +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 +data in `userdata//value` are limited to 200 bytes:: + + cd /sys/kernel/config/netconsole && mkdir cmdline0 + cd cmdline0 + mkdir userdata/foo + echo bar > userdata/foo/value + mkdir userdata/qux + echo baz > userdata/qux/value + +Messages will now include this additional user data:: + + echo "This is a message" > /dev/kmsg + +Sends:: + + 12,607,22085407756,-;This is a message + foo=bar + qux=baz + +Preview the userdata that will be appended with:: + + cd /sys/kernel/config/netconsole/cmdline0/userdata + for f in `ls userdata`; do echo $f=$(cat userdata/$f/value); done + +If a `userdata` entry is created but no data is written to the `value` file, +the entry will be omitted from netconsole messages:: + + cd /sys/kernel/config/netconsole && mkdir cmdline0 + cd cmdline0 + mkdir userdata/foo + echo bar > userdata/foo/value + mkdir userdata/qux + +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 + +Delete `userdata` entries with `rmdir`:: + + rmdir /sys/kernel/config/netconsole/cmdline0/userdata/qux + +.. warning:: + When writing strings to user data values, input is broken up per line in + configfs store calls and this can cause confusing behavior:: + + mkdir userdata/testing + printf "val1\nval2" > userdata/testing/value + # userdata store value is called twice, first with "val1\n" then "val2" + # so "val2" is stored, being the last value stored + cat userdata/testing/value + val2 + + It is recommended to not write user data values with newlines. + Extended console: ================= From patchwork Sun Feb 4 23:27:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wood X-Patchwork-Id: 196595 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp572287dyb; Sun, 4 Feb 2024 15:30:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IEzw2fHAbfjJp5W/XJ/ODmP0f/jyhFFwppZD5171hK/anYCz++DTbHm5J+oSB1X0J4MwFgr X-Received: by 2002:a05:6512:2388:b0:511:4253:3a8b with SMTP id c8-20020a056512238800b0051142533a8bmr3944123lfv.42.1707089418425; Sun, 04 Feb 2024 15:30:18 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707089418; cv=pass; d=google.com; s=arc-20160816; b=UaWcP0M5z7VtM7PYGjts2aIq8360WR4NMb3vAHZGdDBHgfg6eYekhEjGQpwTMbdi8T Mt4i/+KuxH/b2c+2Z9A7VSDct26o7nkpx2gVtZLkTSqArsR6UtYCz8RBpDmGE7gXuHD3 GMb//VW/LZHAX5SqvZ5STCx5szW0wrOPEQm5c+cQPbgB3SRmIyRM8YOJc+YA7CW1cPUz ZecrCJxXNgsIwFP0sX3eiJh8XSr1mIOJ9VgAzEg6nIo8SBybjW6aQyUCGt5m9xbMeWvj HJgdSpnMXMp65xYRA1857+Y0fk08TICuwRL0Hg2T6lHgQyxy9ZffttrqDcn1FhAvzamK mwwg== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=yCYkAExjd+SThE20it4/Y+M6eEB7vekvWXl2VDrzmho=; fh=QuGATMw580lwLd28krj6qBQRJIyZhKuaf3UC7LLvbk4=; b=qLgWV6JGrN7w0r43zF6LCdap/uEmgZekLklB0AID4euALO5/onHzDUUB3jziVZ+RgQ Q7zzygLRCbGg0kCdLWdUgGDXYpvtlwdd5RDwAi5BYgHTGtfj4RWXcqJpAhgVormQyRAY MfkFhttcj7Xw4eyIYk3gUjipANun1Opeeo44ZlvMHj8O8p5huxjRdI/jCjAzQVeKqfQx smnT6G5ba8SzJALVRGrmtO14lx65WM2mwRLxtJBIhrianhMSVKaSW4hRTKmAtJrgJ159 WcMEQzy4byEX1D9RJWlbUDaJ+igFAcToxm97z0R7Rb/+th2rc6YZY9NRKz6oz4fnmOVj b3dw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="WrvaH/MK"; 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-51938-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51938-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCUfZN3S54VZIkgpRwi24ieh5i+njm+EOshbxAdY/aY9Bv966OnNcEgFpvHRK8ijm7ktE8clexultGylZiAE1pwGlBa/rg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id u19-20020a1709064ad300b00a36c7edb72bsi3283057ejt.826.2024.02.04.15.30.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 15:30:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51938-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="WrvaH/MK"; 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-51938-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51938-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id D67FD1F21E2F for ; Sun, 4 Feb 2024 23:30:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BBB8714015; Sun, 4 Feb 2024 23:28:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WrvaH/MK" Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (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 1CBB2134AC; Sun, 4 Feb 2024 23:27:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707089279; cv=none; b=HIPZeAaQijGkMncxiToZh8aBKqRW2Df8ncWx7OQesnj+Kn0J/EODM+A9e0EdAFShnMIomiYDSkX3+3TvLYrdyqKEA+QdvyWSrGXyJEeGEvEOHopBbRgTklXVMsUXJxIPGEY3URbudQvPvDHkQ2uI0HCNZ/pkaiGcFC9s7qNDGlI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707089279; c=relaxed/simple; bh=EsPfvCdyb9fqotxxhnjVd1pr2sFgS3Srf7o6hv/vts4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kOEbXLmaSW2jmR0UO/2NCEE6zgSzjtgpZabp6Nu3PYGU/gxrlNCMiNqke1czWicy0N9VmHRoxboVVkv4bQ8369P+fi9ev5zbePExltjlP10pIZVE0uhpVSrrAnKZQdufhPKn6OLJrUZecZ7+fVUWiNUYq2QSyY9Jpuys1o9PoYQ= 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=WrvaH/MK; arc=none smtp.client-ip=209.85.215.180 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-pg1-f180.google.com with SMTP id 41be03b00d2f7-5d3907ff128so3375408a12.3; Sun, 04 Feb 2024 15:27:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707089277; x=1707694077; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yCYkAExjd+SThE20it4/Y+M6eEB7vekvWXl2VDrzmho=; b=WrvaH/MKzafEnN+Eg1/tU9hhxjiT2TJyUpylOd0w7avZSz0H907YJZwe+ywNlJTyWy PnITU/d4B59wNdOxnmu2tWa81i6PV2Uyho4uvp9Rq3orDdC4WzZZNCobrT4NptYNs+4d 2K9EEu78Za0nqozXHQ95w2xiaOwEm67aQChcALzCYi1tLqlwyVgYOuAFLO9ueTKZpDhf FHNPcEScGE803LLkf1IbIKqd1r6k+uQOwK9zX4ARI5Y5uEsMGGOPEIjwFyqSyXGeZuC4 OTfUtLtMH58Q+Iub+ruziccfzXeRsdV2tBXtszu9DEw5AA5fGn3rWrbrD8fIR0qF7uhe RvYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707089277; x=1707694077; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yCYkAExjd+SThE20it4/Y+M6eEB7vekvWXl2VDrzmho=; b=a/F4LjAoMdGo6Lmu/vGjgp4r6yvRCctR2XjQeNbhCp4w3Tk77NX/t381JVYDQaI8h2 ogAuCvkCGxVckCpjx5CJovDd4c1UYq3ky5UrrQU9IXsl8BwJJWV/KNtuabxbwVx1fk9T VpZaFNBjLG7MCEj0mFQCcstIq0mPsxgt9hdK3XF3/Ye3+3Spa0G2phbuu3rNEDGFLBKN 9O+5rmfa6cfsLDboCOHsPVjcfaAjlJBhn+M2BCAattfYfnB4x7RPPoSUcZezYhTrqtb1 JaLzzwltCJTha2DUF2j7cSiMoGV8T+7BqGldacx62C6Hfh4DLWOQgIxEcYjPSuJ6ELk8 cvNQ== X-Gm-Message-State: AOJu0YzWaZ5K1rIfYk9aSgNscXsL3ydScX3lmfaZGge87gHF8p0p5MgC VyTmKv7/9NJl4AMSzhN139Q0HeKXCvH/zvrw7JpA6R4cjySruhYh X-Received: by 2002:a05:6a21:7894:b0:19c:90fc:f0d3 with SMTP id bf20-20020a056a21789400b0019c90fcf0d3mr18585019pzc.46.1707089277381; Sun, 04 Feb 2024 15:27:57 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVc2TwKkeTGLPigddVr0b0eC3edBaEPR9HcIUn3F/Ik3bk837MccfsopJPEsVyTylGomwEO070IhyKFJ29OyuwqGGxuu9s1K1Y/No3UV4JmSu8TOpqY8NUSUBYqnIENfPZ2HI/SCIZ3NZn+zExodPWKWC0SNz1OU1mEqYmxCJNupXBtSylmU5qTo4DZK106jGIYuZ62MPo9EL1L//PD Received: from localhost ([2601:644:9380:8cd0::7fb4]) by smtp.gmail.com with ESMTPSA id h4-20020a056a00000400b006e04233b0d1sm814831pfk.54.2024.02.04.15.27.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 15:27:57 -0800 (PST) From: Matthew Wood To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Breno Leitao , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 5/8] net: netconsole: add a userdata config_group member to netconsole_target Date: Sun, 4 Feb 2024 15:27:36 -0800 Message-ID: <20240204232744.91315-6-thepacketgeek@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240204232744.91315-1-thepacketgeek@gmail.com> References: <20240204232744.91315-1-thepacketgeek@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790012994066070710 X-GMAIL-MSGID: 1790012994066070710 Create configfs machinery for netconsole userdata appending, which depends on CONFIG_NETCONSOLE_DYNAMIC (for configfs interface). Add a userdata config_group to netconsole_target for managing userdata entries as a tree under the netconsole configfs subsystem. Directory names created under the userdata directory become userdatum keys; the userdatum value is the content of the value file. Include the minimum-viable-changes for userdata configfs config_group. init_target_config_group() ties in the complete configfs machinery to avoid unused func/variable errors during build. Initializing the netconsole_target->group is moved to init_target_config_group, which will also init and add the userdata config_group. Each userdatum entry has a limit of 256 bytes (54 for the key/directory, 200 for the value, and 2 for '=' and '\n' characters), which is enforced by the configfs functions for updating the userdata config_group. When a new netconsole_target is created, initialize the userdata config_group and add it as a default group for netconsole_target config_group, allowing the userdata configfs sub-tree to be presented in the netconsole configfs tree under the userdata directory. Co-developed-by: Breno Leitao Signed-off-by: Breno Leitao Signed-off-by: Matthew Wood --- drivers/net/netconsole.c | 147 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 142 insertions(+), 5 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index e6c3b15fe95d..3618b9ebcce4 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -43,6 +43,10 @@ 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_USERDATA_ENTRY_LENGTH 256 +#define MAX_USERDATA_ITEMS 16 #define MAX_PRINT_CHUNK 1000 static char config[MAX_PARAM_LENGTH]; @@ -80,6 +84,7 @@ static struct console netconsole_ext; * struct netconsole_target - Represents a configured netconsole target. * @list: Links this target into the target_list. * @group: Links us into the configfs subsystem hierarchy. + * @userdata_group: Links to the userdata configfs hierarchy * @enabled: On / off knob to enable / disable target. * Visible from userspace (read-write). * We maintain a strict 1:1 correspondence between this and @@ -103,6 +108,7 @@ struct netconsole_target { struct list_head list; #ifdef CONFIG_NETCONSOLE_DYNAMIC struct config_group group; + struct config_group userdata_group; #endif bool enabled; bool extended; @@ -215,6 +221,10 @@ static struct netconsole_target *alloc_and_init(void) * | remote_ip * | local_mac * | remote_mac + * | userdata/ + * | / + * | value + * | ... * | * /... */ @@ -596,6 +606,123 @@ static ssize_t remote_mac_store(struct config_item *item, const char *buf, return -EINVAL; } +struct userdatum { + struct config_item item; + char value[MAX_USERDATA_VALUE_LENGTH]; +}; + +static struct userdatum *to_userdatum(struct config_item *item) +{ + return container_of(item, struct userdatum, item); +} + +struct userdata { + struct config_group group; +}; + +static struct userdata *to_userdata(struct config_item *item) +{ + return container_of(to_config_group(item), struct userdata, group); +} + +static struct netconsole_target *userdata_to_target(struct userdata *ud) +{ + struct config_group *netconsole_group; + + netconsole_group = to_config_group(ud->group.cg_item.ci_parent); + return to_target(&netconsole_group->cg_item); +} + +static ssize_t userdatum_value_show(struct config_item *item, char *buf) +{ + return sysfs_emit(buf, "%s\n", &(to_userdatum(item)->value[0])); +} + +static ssize_t userdatum_value_store(struct config_item *item, const char *buf, + size_t count) +{ + struct userdatum *udm = to_userdatum(item); + int ret; + + if (count > MAX_USERDATA_VALUE_LENGTH) + return -EMSGSIZE; + + mutex_lock(&dynamic_netconsole_mutex); + + ret = strscpy(udm->value, buf, sizeof(udm->value)); + if (ret < 0) + goto out_unlock; + trim_newline(udm->value, sizeof(udm->value)); + + mutex_unlock(&dynamic_netconsole_mutex); + return count; +out_unlock: + mutex_unlock(&dynamic_netconsole_mutex); + return ret; +} + +CONFIGFS_ATTR(userdatum_, value); + +static struct configfs_attribute *userdatum_attrs[] = { + &userdatum_attr_value, + NULL, +}; + +static void userdatum_release(struct config_item *item) +{ + kfree(to_userdatum(item)); +} + +static struct configfs_item_operations userdatum_ops = { + .release = userdatum_release, +}; + +static const struct config_item_type userdatum_type = { + .ct_item_ops = &userdatum_ops, + .ct_attrs = userdatum_attrs, + .ct_owner = THIS_MODULE, +}; + +static struct config_item *userdatum_make_item(struct config_group *group, + const char *name) +{ + struct netconsole_target *nt; + struct userdatum *udm; + struct userdata *ud; + size_t child_count; + + if (strlen(name) > MAX_USERDATA_NAME_LENGTH) + return ERR_PTR(-ENAMETOOLONG); + + ud = to_userdata(&group->cg_item); + nt = userdata_to_target(ud); + child_count = list_count_nodes(&nt->userdata_group.cg_children); + if (child_count >= MAX_USERDATA_ITEMS) + return ERR_PTR(-ENOSPC); + + udm = kzalloc(sizeof(*udm), GFP_KERNEL); + if (!udm) + return ERR_PTR(-ENOMEM); + + config_item_init_type_name(&udm->item, name, &userdatum_type); + return &udm->item; +} + +static struct configfs_attribute *userdata_attrs[] = { + NULL, +}; + +static struct configfs_group_operations userdata_ops = { + .make_item = userdatum_make_item, +}; + +static struct config_item_type userdata_type = { + .ct_item_ops = &userdatum_ops, + .ct_group_ops = &userdata_ops, + .ct_attrs = userdata_attrs, + .ct_owner = THIS_MODULE, +}; + CONFIGFS_ATTR(, enabled); CONFIGFS_ATTR(, extended); CONFIGFS_ATTR(, dev_name); @@ -640,6 +767,15 @@ static const struct config_item_type netconsole_target_type = { .ct_owner = THIS_MODULE, }; +static void init_target_config_group(struct netconsole_target *nt, + const char *name) +{ + config_group_init_type_name(&nt->group, name, &netconsole_target_type); + config_group_init_type_name(&nt->userdata_group, "userdata", + &userdata_type); + configfs_add_default_group(&nt->userdata_group, &nt->group); +} + static struct netconsole_target *find_cmdline_target(const char *name) { struct netconsole_target *nt, *ret = NULL; @@ -674,16 +810,18 @@ static struct config_group *make_netconsole_target(struct config_group *group, if (!strncmp(name, NETCONSOLE_PARAM_TARGET_PREFIX, strlen(NETCONSOLE_PARAM_TARGET_PREFIX))) { nt = find_cmdline_target(name); - if (nt) + if (nt) { + init_target_config_group(nt, name); return &nt->group; + } } nt = alloc_and_init(); if (!nt) return ERR_PTR(-ENOMEM); - /* Initialize the config_item member */ - config_group_init_type_name(&nt->group, name, &netconsole_target_type); + /* Initialize the config_group member */ + init_target_config_group(nt, name); /* Adding, but it is disabled */ spin_lock_irqsave(&target_list_lock, flags); @@ -740,8 +878,7 @@ static void populate_configfs_item(struct netconsole_target *nt, snprintf(target_name, sizeof(target_name), "%s%d", NETCONSOLE_PARAM_TARGET_PREFIX, cmdline_count); - config_group_init_type_name(&nt->group, target_name, - &netconsole_target_type); + init_target_config_group(nt, target_name); } #endif /* CONFIG_NETCONSOLE_DYNAMIC */ From patchwork Sun Feb 4 23:27:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wood X-Patchwork-Id: 196596 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp572393dyb; Sun, 4 Feb 2024 15:30:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IEAPtcej4ihIv7tmb4KbsT1SKtPcJh7urCOGuRHnGOgujvdjfZjxmtg/yEpe0ITM0rNELDO X-Received: by 2002:a17:90a:be0b:b0:290:ee5:5ef0 with SMTP id a11-20020a17090abe0b00b002900ee55ef0mr11602508pjs.43.1707089435022; Sun, 04 Feb 2024 15:30:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707089435; cv=pass; d=google.com; s=arc-20160816; b=t3Qq1ZJc7kH8enGUMZddARhiyDSQHhNVQhzR0Ul3r+J4Ny6cazycBzamg3dcwbtujs fPOwnwiZdvSxras+aHAdckXaYbDGqO5zMnKuAMpGZs2O6AK+K4xCJKJeJIwvsU9eID9y HKWzf3uWW+Cu+cMlwmOse2UhXzk6bNSuoiRmJjWGvlT1hyep4HGgyf6iUrnrRnn66QV+ 7usAKACwa9cIg5mag6KIVnkj3AHIUCyVQR9+xy+0re1L11bgwmgDMuPmT0x0340XYX7I AjufcP2+WISiCV6LQb/TAc5gW2o3Gn+bCcTU9aSGIIjOngo6ub4WpU9srsyPtrDMaylq 5kww== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=TW8QValFS/0zkKjvlP3DgdGfC9w7hSQMfOI/aFj5gPQ=; fh=1YjW4zQoXgcF09qXRRuwi1f7WK2XRamvzUUiVr8R3Fs=; b=QsYoNsrudp4Kei2701EzD0Bi23FlwFLf5l7HsVpbu6BvBESbBiKQBTcqyCpqXL6KFS eMeA4sojjkkwJx+AO276Sb8mALjTBwyboX2xTKlU+LZqWZSes9DUCLzFknEpHVmbJRa7 AtXORRGT6pg3qT7yzQ3D3TtMCWICIW+t4d0ziR9pB6CkpMRLWT8iN9E0mAFC3KRDVSu4 Y7Ar/pndzj9XgzT8XE8hOiU1aZ4Fa0+9JBVoBQWjyIMHJonn8jmN7u10wxSIaDqUM1ZI TeKzpmU6qUG8/UNCRioRIfOTRBw36FW9mJ8q9KoWT9rZlbatWB2xQZJQL42J0i6u8eKc h3tA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Dlhv7RTb; 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-51939-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51939-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCUJLG8gUgh+acHVHpC2soabfZoPGt8unIB3F6uCSlH368GR/aPgdyZXO+p6VRo/YNeq4CGAAyFVKqVWFQv9NmpEs880dg== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id kb5-20020a17090ae7c500b00296a5ca1a5asi148974pjb.66.2024.02.04.15.30.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 15:30:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51939-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=Dlhv7RTb; 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-51939-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51939-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id C5527281B9D for ; Sun, 4 Feb 2024 23:30:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 56607BA29; Sun, 4 Feb 2024 23:28:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Dlhv7RTb" Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 22575125D8; Sun, 4 Feb 2024 23:27:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707089281; cv=none; b=UtNcBf8LzmEGHfR/JMAPiU3AJI30dzCuA/xeWjDgSb1YwipT3oa53jFg1Yfo5wFEe9wF19pHRuQwP/ePf46D1LVgiD4+S4cbAvh5z6Vg71XlaMdnIMzv5pAlOzqhQbOro+wj9gkxw5UxgIQGdZ87TtyaPsFOGGNxeW8bUWGOqAk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707089281; c=relaxed/simple; bh=5GwH1PqDWl2CwGmvij6Qd6cD1bi7HcM6jD/BhS8N5sM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ORMremUX6MWJhw+zwN4fMjYu/gGkqQZfjyLkLQtjmBrnQaCjEHVmAEcHTTNb+CERUAyTPR5h4SKrULmyqGoosH3FHVSByMcOWjcDBQgGQjMlriuCzWmV9gzLJpjzGGPdtCSViPU2x4tPkTgH5m6wRmltgvq5jm/HRrc7bLmwYM8= 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=Dlhv7RTb; arc=none smtp.client-ip=209.85.214.170 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-pl1-f170.google.com with SMTP id d9443c01a7336-1d953fa3286so26511075ad.2; Sun, 04 Feb 2024 15:27:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707089279; x=1707694079; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=TW8QValFS/0zkKjvlP3DgdGfC9w7hSQMfOI/aFj5gPQ=; b=Dlhv7RTbF24pNtn3fNKmRcfBfJlBKXhdTYo/viYKnAmM5hlEq1hd0XYSmxEpMfTXK/ vHqKHxodIzI86158FnrkZScJVCvTG8HqkgAKHTod/8fhdmg8AjINXE/SuKjWaoKKkKh4 klIFa4lwUsqgz7Y4Ah7j8TGjI/LFXa/Ofai8R3SQFNi311Wu/WenMjZflgSMQQaIG2j0 h4AFEuhnrKCNoW4QwKcE5Ax7dyvKQ7e79KEq/fm4DYzcct9gHzs638er6QarLAjkIw4D u5Lt4NC7XfXvhFFjrFXBvUqoYtV1WdViPxLEPdJwIqJVJ6oOCZcBrYptXGI3MyoKIItx MOxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707089279; x=1707694079; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=TW8QValFS/0zkKjvlP3DgdGfC9w7hSQMfOI/aFj5gPQ=; b=m6NJmcZkOc640HZU2UARQO1f59aCtDQe4fMBuiWeTmW13fPgmh2ddLLjgS63FjHb+h R7uUyxVxyrYPb5gt0MggBHuOOLm6nIRRPY5Xq04gy/Zv3AjIBZuCtDoahXE7KwMutr7I cf4jXq2u7ljHYno/w0HMLKgdyjW+AeBoiUgA8lWArtnpUwsNcyvdfj/bDhkFNT0o5dgq LcMRxh1RadR4UQztARxYtrtXQnx+9EM10RWx7XPg+037YA6n5HUNoUYkYXUQtccf9s5h YW300+/yRGILgZ4qaq3ZF7ve4v31kn98KhqSaPjw91msDe6A4nPVsUpVFX31AsTRmO4i eB7A== X-Gm-Message-State: AOJu0YxzpPXBNH0uaphbpcGJRdxj29tBbK8JUK1iWDkU7TzqqxIqCR6v vvL5xR4mTwuAqSWShtSPyVlfpbwS6OzHgWOngdKCO4+ewkXPD66y X-Received: by 2002:a17:902:d643:b0:1d4:dddc:d38e with SMTP id y3-20020a170902d64300b001d4dddcd38emr11540531plh.61.1707089279406; Sun, 04 Feb 2024 15:27:59 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCUBv7M40ptsPLrNXXgFRSvX+nrqEcP2r3wDxtSX6b60T8P/zChU1jFziUN7IahUhq1+o6zazQdTjAM7aF88D9swox/zJ0TSnXOm/PtzZSPM/PdWBNA53/j73BYxHxLkqiiqKs0J4nvAEXM32PUkSbXHl8n1kG2hkoXZWVYobSkJleNF+8+ozk8A+0A86u8Jb0gZpgi8aE+M/jBjmwJv Received: from localhost ([2601:644:9380:8cd0::7fb4]) by smtp.gmail.com with ESMTPSA id w18-20020a170902d11200b001d8ee19ab34sm5072156plw.29.2024.02.04.15.27.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 15:27:59 -0800 (PST) From: Matthew Wood To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Breno Leitao , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 6/8] net: netconsole: cache userdata formatted string in netconsole_target Date: Sun, 4 Feb 2024 15:27:37 -0800 Message-ID: <20240204232744.91315-7-thepacketgeek@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240204232744.91315-1-thepacketgeek@gmail.com> References: <20240204232744.91315-1-thepacketgeek@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790013011082989259 X-GMAIL-MSGID: 1790013011082989259 Store a formatted string for userdata that will be appended to netconsole messages. The string has a capacity of 4KB, as calculated by the userdatum entry length of 256 bytes and a max of 16 userdata entries. Update the stored netconsole_target->userdata_complete string with the new formatted userdata values when a userdatum is created, edited, or removed. Each userdata entry contains a trailing newline, which will be formatted as such in netconsole messages:: 6.7.0-rc8-virtme,12,500,1646292204,-;test release=foo something=bar 6.7.0-rc8-virtme,12,500,1646292204,-;another test release=foo something=bar Enforcement of MAX_USERDATA_ITEMS is done in userdatum_make_item; update_userdata will not check for this case but will skip any userdata children over the limit of MAX_USERDATA_ITEMs. If a userdata entry/dir is created but no value is provided, that entry will be skipped. This is in part because update_userdata() can't be called in userdatum_make_item() since the item will not have been added to the userdata config_group children yet. To preserve the experience of adding an empty userdata that doesn't show up in the netconsole messages, purposefully skip empty userdata items even when update_userdata() can be called. Co-developed-by: Breno Leitao Signed-off-by: Breno Leitao Signed-off-by: Matthew Wood --- drivers/net/netconsole.c | 61 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 3618b9ebcce4..e4d6ba0b50ef 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -85,6 +85,8 @@ static struct console netconsole_ext; * @list: Links this target into the target_list. * @group: Links us into the configfs subsystem hierarchy. * @userdata_group: Links to the userdata configfs hierarchy + * @userdata_complete: Cached, formatted string of append + * @userdata_length: String length of userdata_complete * @enabled: On / off knob to enable / disable target. * Visible from userspace (read-write). * We maintain a strict 1:1 correspondence between this and @@ -109,6 +111,8 @@ struct netconsole_target { #ifdef CONFIG_NETCONSOLE_DYNAMIC struct config_group group; struct config_group userdata_group; + char userdata_complete[MAX_USERDATA_ENTRY_LENGTH * MAX_USERDATA_ITEMS]; + size_t userdata_length; #endif bool enabled; bool extended; @@ -638,10 +642,48 @@ static ssize_t userdatum_value_show(struct config_item *item, char *buf) return sysfs_emit(buf, "%s\n", &(to_userdatum(item)->value[0])); } +static void update_userdata(struct netconsole_target *nt) +{ + int complete_idx = 0, child_count = 0; + struct list_head *entry; + + /* Clear the current string in case the last userdatum was deleted */ + nt->userdata_length = 0; + nt->userdata_complete[0] = 0; + + list_for_each(entry, &nt->userdata_group.cg_children) { + struct userdatum *udm_item; + struct config_item *item; + + if (child_count >= MAX_USERDATA_ITEMS) + break; + child_count++; + + item = container_of(entry, struct config_item, ci_entry); + udm_item = to_userdatum(item); + + /* Skip userdata with no value set */ + if (strnlen(udm_item->value, MAX_USERDATA_VALUE_LENGTH) == 0) + continue; + + /* This doesn't overflow userdata_complete since it will write + * one entry length (1/MAX_USERDATA_ITEMS long), entry count is + * 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", + item->ci_name, udm_item->value); + } + nt->userdata_length = strnlen(nt->userdata_complete, + sizeof(nt->userdata_complete)); +} + static ssize_t userdatum_value_store(struct config_item *item, const char *buf, size_t count) { struct userdatum *udm = to_userdatum(item); + struct netconsole_target *nt; + struct userdata *ud; int ret; if (count > MAX_USERDATA_VALUE_LENGTH) @@ -654,6 +696,10 @@ static ssize_t userdatum_value_store(struct config_item *item, const char *buf, goto out_unlock; trim_newline(udm->value, sizeof(udm->value)); + ud = to_userdata(item->ci_parent); + nt = userdata_to_target(ud); + update_userdata(nt); + mutex_unlock(&dynamic_netconsole_mutex); return count; out_unlock: @@ -708,12 +754,27 @@ static struct config_item *userdatum_make_item(struct config_group *group, return &udm->item; } +static void userdatum_drop(struct config_group *group, struct config_item *item) +{ + struct netconsole_target *nt; + struct userdata *ud; + + ud = to_userdata(&group->cg_item); + nt = userdata_to_target(ud); + + mutex_lock(&dynamic_netconsole_mutex); + update_userdata(nt); + config_item_put(item); + mutex_unlock(&dynamic_netconsole_mutex); +} + static struct configfs_attribute *userdata_attrs[] = { NULL, }; static struct configfs_group_operations userdata_ops = { .make_item = userdatum_make_item, + .drop_item = userdatum_drop, }; static struct config_item_type userdata_type = { From patchwork Sun Feb 4 23:27:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wood X-Patchwork-Id: 196597 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp572478dyb; Sun, 4 Feb 2024 15:30:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEugQh1ffP3rIj5i3kxeAGZ1j4OZl59XMjG1Z8uFhQLcHGhTuBJT9TA9gTuheQQSo7ZLNmG X-Received: by 2002:a17:902:76c7:b0:1d9:5596:ffe8 with SMTP id j7-20020a17090276c700b001d95596ffe8mr9254001plt.66.1707089449040; Sun, 04 Feb 2024 15:30:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707089449; cv=pass; d=google.com; s=arc-20160816; b=pIYxYDDGBob/Ow+DN8TlPRdt80oPF1PiEpeFxwXqetGKRr1+DxhGrWP/m+y5+ql+5Q IkwG9FffShevnPML6bS7AnQiGjPAd/rnV9aLRJwKBHeosQ9rRSDh9VAJbA7zYMIztPRq r9HcnKLUYgcnaVmS72OzmW/gQSiJ8yJ3/+4nfZUtIw7odP2Tb+G/nwgJ93qsCDbc2MbL JGnLRD7dXeqY1kGF9EApZAotKW6yRDZbRp9Mii9irHVj+S3eT0Nrd6vDGBeYY4R863OC NEuY+Mtf0kY5GbeHA/1DH+0pt+R1wEDSNNK9H4YwFhwrvKaIwuID70y0OZDqpYbQg/gJ 5MhQ== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=a0HZ0i+aKOW3O7O1Lv3dQCatPUXng62ahBaIh3AoxzA=; fh=Vnlb2spaG98MXqGyPfC9FqL9hOOMEVj4DPgQtQUFGTw=; b=Bny1gaaVAaK7Fk1DUqsnsnebERsbCj7D307pTQ9wLoHkf33UXh6R20eIh27X45LFSz EtluCMNYPItJdA1Set56hoSgxKoYv8GHqNfEAPlQPX5WKjAEPlz0w9akgQK7RBxCXjxI oDznsQNTDTOJ9AD936D0mgpQ1mWjGc72z71kxrppSLgolt2MfrX6js+mB50M8fNzHJOE sGvMOdvShnXcp3QP19ECIk6EtP+0IOT6cIn2NGEAuKG8ia35Es3YqDkRstzB/6ahdF5g CCTka9MmyAokFj5D5wOJMLd2pY57mcXH9j9BuV2IbXgt5pcxQnEdnr9vc1n7KQSsnEWb sVqA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=al7FGddi; 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-51940-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51940-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCVd8JIeKItdtd7/mssjk/py+WEc7FxcvYisABEaE/Bests7ZRbXa8LzEyFGO2TiOg9tu4Sq+4Yyy4WF2UDGw9T9YMn5jQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id n10-20020a170902e54a00b001d9bd98670asi308655plf.424.2024.02.04.15.30.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 15:30:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51940-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=al7FGddi; 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-51940-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51940-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B1F50281EC4 for ; Sun, 4 Feb 2024 23:30:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6CED7286BD; Sun, 4 Feb 2024 23:28:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="al7FGddi" Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 07DE014013; Sun, 4 Feb 2024 23:28:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707089283; cv=none; b=nmLYVGnwCKMer0RqZSt38J05P1VVxK2qMC0e2pqUUvYabXGIni+bmYde+UAVYuYDn+GZKL4A15VF48umOaoaRJL5c+TCyWcwaSTx9iMYTbLCAUI7rLCJ5JWFTxUmVAp3TwhrJTmd4889t3Viiyx3IQIN09f2c8+7M23oNAhYAGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707089283; c=relaxed/simple; bh=aB8zRROFhVWYDcYHzNZj+S0JB99XcbF6R0qYvHS67kQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ukjCrfmFwzNNTiWgSxcIPVzlFBys/Mb3f2OmWiDlOa1LGcP5Tk5aiWS7hUf5j8osxlGQY29+LdB7EKllG1rJsUTw1rcy3D3ZU5sFttI/aHpWQX8NyllJ8hqvtk57ieQoofny3Pu0TjMC6Hr8m3C9Rd+2vtaSfXpZOD6aHU/XDQU= 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=al7FGddi; arc=none smtp.client-ip=209.85.214.175 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-pl1-f175.google.com with SMTP id d9443c01a7336-1d91397bd22so29101395ad.0; Sun, 04 Feb 2024 15:28:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707089281; x=1707694081; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=a0HZ0i+aKOW3O7O1Lv3dQCatPUXng62ahBaIh3AoxzA=; b=al7FGddi9Qedf7EDw/7Oyts4kIAnoH+B80VVyfrjR3zwonEYJO4Z7rl7yycA4wYV4M k8OOX5upS20kONHxPWB2bn9WAegBqZpvByyoXDgePyJpdEN83+4GjJRSmUtK+z8D1IoL pYqaKQ1OnJ7cMhg4Yzy5FH8XAYxN+Cm+7STNSplsbzgbzVJU4OSCwFxSTkBRC8Dex8Ln FOw9T7k/227ai1p4SvZO4G5gT39JW4kgNS++WTY/XWVpYGHhC46+6ltH7FDBJBfj6vlD lu9lW4f5AxNuaENC0EyPXyin+HQ+XfMyuqPsHCVlmKN0iaOoCrBfRYD6Vhpg3ApDSURw dTbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707089281; x=1707694081; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=a0HZ0i+aKOW3O7O1Lv3dQCatPUXng62ahBaIh3AoxzA=; b=KOxiTV1h8iI8S9pwispzSw1a9jEGywvTfm/drDl39OWcw42pRvsGei+Hqhvuw1YiMV nChqVsWBQ6t0LZrnQontj1TQEPPVyAQybnRU1YPm40ES2w4p6HHtAmKebrvutRRzHZoc yyqAOaeVX2+49XTN4bmDEkWWS5PQzzjWRs/GFx/BBc47o/L7jd85MyOo0dLIgvqtIUum iD1A/d/DMRss+OXCHr3QcNUKxJUammpxsSm3KK5eczbDjlM0k7cBN+P3vR7tftmTE100 pm+2E3nwH1G8rzy438gxn/dIReAgMyk9RygxV0QxMYH1kuH1TFJuyLvO6krtFPyhmvz9 KPWA== X-Gm-Message-State: AOJu0YyNezy3/RlYHUzIkk6pQqqmDTMtE+UAb7g0Y/DLULr0nJ8lxSNM JGiWcrwcDafzRb1aZy3izY9P62uM7A2qkiguxLtSGxDSqpgxVDmVGCUd+2On X-Received: by 2002:a17:902:d548:b0:1d9:3f27:42ed with SMTP id z8-20020a170902d54800b001d93f2742edmr18030547plf.1.1707089281433; Sun, 04 Feb 2024 15:28:01 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVLiIrIdj6Zlh3BPbV/OmVPoWBcbXAQ0PHsotFXEABJ2t6bSKQE1IhsGI2Dp6I8ytOKCqbZJgBljWss/+jUmssEbil5qcmR+3MoufPJAeht3+dfeEBcATBIMP8txOt/MwYz3j/KA9eGbo8DPI0ec/vzEWwE8FmC3C2ruEVeOg+RkxQ4D2TYAMPs6Lcm9c86DetWx/C0s+Jf3YI8nLTS Received: from localhost ([2601:644:9380:8cd0::7fb4]) by smtp.gmail.com with ESMTPSA id r17-20020a170903015100b001d705b43724sm5046081plc.169.2024.02.04.15.28.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 15:28:01 -0800 (PST) From: Matthew Wood To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Breno Leitao , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 7/8] net: netconsole: append userdata to netconsole messages Date: Sun, 4 Feb 2024 15:27:38 -0800 Message-ID: <20240204232744.91315-8-thepacketgeek@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240204232744.91315-1-thepacketgeek@gmail.com> References: <20240204232744.91315-1-thepacketgeek@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790013026118663545 X-GMAIL-MSGID: 1790013026118663545 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 Signed-off-by: Breno Leitao Signed-off-by: Matthew Wood --- drivers/net/netconsole.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index e4d6ba0b50ef..d53bb1172336 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -1034,19 +1034,34 @@ static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg, const char *msg_ready = msg; 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 <= MAX_PRINT_CHUNK) { + 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; - msg_ready = buf; + } else { + memcpy(buf, msg, msg_len); } + + if (userdata) + msg_len += scnprintf(&buf[msg_len], + MAX_PRINT_CHUNK - msg_len, + "%s", userdata); + + msg_ready = buf; netpoll_send_udp(&nt->np, msg_ready, msg_len); return; } From patchwork Sun Feb 4 23:27:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wood X-Patchwork-Id: 196598 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp572557dyb; Sun, 4 Feb 2024 15:31:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IE+zdFnI1WPykggTbrgu1dHWZwxz8AUft5NumT/QNj/vtjfvoUEymL/0yNL7C8CT4WlyeXG X-Received: by 2002:a05:6871:528e:b0:218:de13:e11e with SMTP id hu14-20020a056871528e00b00218de13e11emr7017648oac.22.1707089461529; Sun, 04 Feb 2024 15:31:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707089461; cv=pass; d=google.com; s=arc-20160816; b=jhE2bYR8fKf+RH0dmCJUOrfnAUa+FD7kT/SeTVUe4FM+2upJ0jjQzYx5kvlpmb24DA JH/wDJKdwcqu5o+kjlhOY9O1nO71Og/cFu8WuHyg/sZrzBEA5GeMk0LITkc4gqIZpdgz u51idlUdi99ydF5BodSE3j5Jbbm6eASTuF+kiN907h4EXBRXxnNMwkwdm3VHbW+1aesk 3H6QF5TbLzswXy/DDWlGIr/RS3cjCKzCSVk4egjgPekaikYFnlRnMqTUnZD2WdikacQe HpE9rsGaosxg4AtHtOm/ZtTlSoXKluXi8DucZvCswqCVBvK/5LV5MEv/GBI43WmUjKYz /8ow== 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:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=yXl72+2pLCBU+d11ILW3XEAr8eYnZKYv5qLeQI8w0AM=; fh=3OxhOxdpWuyBEXZrVS8Q6Jg9UMQcvf70v/BhQd1jllo=; b=pbIfh7Er1q2sLs7wBCJ/M0bEhofuS+z3I1BNdcZAUvk3BzhUUxvToD4s2NjzHXO22d Dd35ExdkyZ5G3whXM6HTK3Cfck/FjI0psxwsH5gWZel53A1uBXXScHciOtBC9/k3cR0U 1WEzGPr3M4C5F7WugBAiBY2Z7Jdp0e9g6L0lXqdibq6KKmMVSBT3B3uH53mUKyBld5sn WHe8VosjgCH6T/E3W8+AhECzFxJ7leg6CBnbieCdsgL4y/QPVtnkHkNa3fRRjrhCn3CQ 88aT/B/VLNkc6XOzpIwT+FE/YEtOKYYcszaI8hdV3SMsyVLc0xrfy+JOSxMiQpPfBe95 /GWg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kVXDo6PX; 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-51941-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51941-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCWpVw/AnBr2DWjYBX6A3mv+zQdEjU5sXDzTU7AFjVCXjySQdwfTXjOzfkKNGgFpcTxb2PtpVuaJX5Aj10fOzjo6SuAaqw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d12-20020a05622a05cc00b0042a53f687a1si7073944qtb.754.2024.02.04.15.31.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 15:31:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51941-ouuuleilei=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=kVXDo6PX; 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-51941-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51941-ouuuleilei=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 52FDA1C20A7F for ; Sun, 4 Feb 2024 23:31:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6CF7433082; Sun, 4 Feb 2024 23:28:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kVXDo6PX" Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 189F51DA32; Sun, 4 Feb 2024 23:28:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707089285; cv=none; b=G/2IdFA7tl1n0CHfXfDCc0raJ4tU4RPUfKZHF30Dg9JXxzA/XVoPLU1b4WtPYsDVC7PQa425At6yWocSkTy0EQ2tAhpGFbbKICqoIhrIkS4fOV1oTZMh7wok7RQ4njD+HGc2k+Z3MA+bF8g01htSzpyAYo3rH3EvbHP/4+wwnT4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707089285; c=relaxed/simple; bh=SSARsMhAO/CnotTOTu32poP3ZTXfjxsFKPzvMvSGpmw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NJNhKyrXjNUOUeeQETPBGxHMUklPwac4NuG1vdLqVqG+L15QEJP9MLE3HcXoYn7qIPo7Vl+Nj/4eh2LnFthfnst41JA2rNo5U9OIHms2mdpi9BVPunZq0323D7LEhXk+iYjS1FnuxPNdp5LqOU1RnYeGqqoOFayevwd7V3jRvYY= 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=kVXDo6PX; arc=none smtp.client-ip=209.85.214.169 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-pl1-f169.google.com with SMTP id d9443c01a7336-1d7431e702dso31522935ad.1; Sun, 04 Feb 2024 15:28:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707089283; x=1707694083; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=yXl72+2pLCBU+d11ILW3XEAr8eYnZKYv5qLeQI8w0AM=; b=kVXDo6PX3WisPT4+K/SpZCPksqBhx4MK0IsaSMiXQLNaRulQ+FED6xree4iNCPgsH7 Xl5CnydzmApkTWS+dg1hOuZuVqTTga8qNRBkMjBF+ogdAfhfyFTgeyry3qwYyIhGAUmV 41RILtRK9Srk9BdESftS9hc2FK4aQSD709LcwhLRp8kdDyweYpXC/9YaZRxbF9p8oI8P 3ujl0A0euVBrzFWBQ+VIT8Vvcy17AOL8bU6RJe4wRtUP8ojSGc+tksBU2uKN3bZpwkxH wjl4ww9BAqUEa5dy+uxtu7Ru09jqmvHDJM854L4ooYRtJebZnNKOwlR5aTeSr683DFYr Pi0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707089283; x=1707694083; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=yXl72+2pLCBU+d11ILW3XEAr8eYnZKYv5qLeQI8w0AM=; b=aMj4ve4r6DhKtvjZQqfb4C5f6R0NVzGR3KtcyECAsTiSthBfpbyhBO9+/oWMhdFT7z YHGQmBeQMp0XdOtM3aM4bf2uMIGqDF97aGSuqFiTyTKJ/GoREV7CETiKTQa//1ka3doZ ShAhPPqapoC0rA5e/veMLW8WINBsO8Z2Pfx+DhDbplWa2/XK/Em6dJ5osc9cn9oFpmFI 4c8mn3wub4KobRc9KU9c9RtHBe0JTllyfo8grRiz3rk5kttceymi0boCfrnKRCW2A6Tv veNPm81uia2HBbYElHRQe/feQDk9SKZw5RSjk3xWqIrhp6qwxpL4mjpGgiJKjGYmcdO2 QHeg== X-Gm-Message-State: AOJu0YwjUeC19aXULl6w+quYH0v7ZVTisbLHex2lV10/po66VRFhbYA8 wiyFgoryZOc9DyHkRDZACCzzLA55/B9IG/46aIeCVUyfPEkvPGUt X-Received: by 2002:a17:902:f811:b0:1d9:5038:f116 with SMTP id ix17-20020a170902f81100b001d95038f116mr10955622plb.34.1707089283351; Sun, 04 Feb 2024 15:28:03 -0800 (PST) X-Forwarded-Encrypted: i=0; AJvYcCVllZG6ovWYFRpf45jxUip1i/3By1OUOv+jD20x5+U2NbHMT4IZgLz4CKn5a5q6vF6+HHINBn2Yl1IEd9jGdG/4/GlOUytxdyjeSTNmJp6pIisorjcCnX9ejrxjLPfKSZ1/4b7pueyHmVxghcmdca+atdvevcaBPX9ufXStpEfNl+ezaLvvmVvziLR6UdIyxuTVERuoZ8dKJGBINd1O Received: from localhost ([2601:644:9380:8cd0::7fb4]) by smtp.gmail.com with ESMTPSA id x10-20020a170902ec8a00b001d9a40f50c4sm1494063plg.301.2024.02.04.15.28.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 15:28:03 -0800 (PST) From: Matthew Wood To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: Breno Leitao , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v3 8/8] net: netconsole: append userdata to fragmented netconsole messages Date: Sun, 4 Feb 2024 15:27:39 -0800 Message-ID: <20240204232744.91315-9-thepacketgeek@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240204232744.91315-1-thepacketgeek@gmail.com> References: <20240204232744.91315-1-thepacketgeek@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790013039259583617 X-GMAIL-MSGID: 1790013039259583617 Regardless of whether the original message body or formatted userdata exceeds the MAX_PRINT_CHUNK, append userdata to the netconsole message starting with the first chunk that has available space after writing the body. Co-developed-by: Breno Leitao Signed-off-by: Breno Leitao Signed-off-by: Matthew Wood --- drivers/net/netconsole.c | 50 +++++++++++++++++++++++++++++----------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index d53bb1172336..0de108a1c0c8 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -1085,24 +1085,48 @@ static void send_ext_msg_udp(struct netconsole_target *nt, const char *msg, memcpy(buf + release_len, header, header_len); header_len += release_len; - while (offset < body_len) { + while (offset < body_len + userdata_len) { int this_header = header_len; - int this_chunk; + int this_offset = 0; + int this_chunk = 0; this_header += scnprintf(buf + this_header, sizeof(buf) - this_header, - ",ncfrag=%d/%d;", offset, body_len); - - this_chunk = min(body_len - offset, - MAX_PRINT_CHUNK - this_header); - if (WARN_ON_ONCE(this_chunk <= 0)) - return; - - memcpy(buf + this_header, body + offset, this_chunk); - - netpoll_send_udp(&nt->np, buf, this_header + this_chunk); + ",ncfrag=%d/%d;", offset, + body_len + userdata_len); + + /* Not all body data has been written yet */ + if (offset < body_len) { + this_chunk = min(body_len - offset, + MAX_PRINT_CHUNK - this_header); + if (WARN_ON_ONCE(this_chunk <= 0)) + return; + memcpy(buf + this_header, body + 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 >= body_len && + offset + this_offset < userdata_len + body_len) { + int sent_userdata = (offset + this_offset) - body_len; + int preceding_bytes = this_chunk + this_header; + + if (WARN_ON_ONCE(sent_userdata < 0)) + return; + + this_chunk = min(userdata_len - sent_userdata, + MAX_PRINT_CHUNK - preceding_bytes); + if (WARN_ON_ONCE(this_chunk <= 0)) + return; + memcpy(buf + this_header + this_offset, + userdata + sent_userdata, + this_chunk); + this_offset += this_chunk; + } - offset += this_chunk; + netpoll_send_udp(&nt->np, buf, this_header + this_offset); + offset += this_offset; } }