Received: by 2002:a05:7412:5112:b0:fa:6e18:a558 with SMTP id fm18csp1274324rdb; Wed, 24 Jan 2024 09:51:31 -0800 (PST) X-Google-Smtp-Source: AGHT+IHRoP5axyiRJlbkwzvZQIPt4TXv+2mZwNosBdTEhPiGjFPGjHEbIgKgYVaiBa91z9FtfHO0 X-Received: by 2002:a05:6512:3b09:b0:510:1438:4ff0 with SMTP id f9-20020a0565123b0900b0051014384ff0mr408550lfv.186.1706118691032; Wed, 24 Jan 2024 09:51:31 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706118691; cv=pass; d=google.com; s=arc-20160816; b=A9QKuLOg5ItJ4XBQgpKnB66X0FqcFDderIcgPFrCxTX9qpxP2RwvmZSEBbvSsw7Flu tWoaEnvUfTck8HsKQZNS61RHmWg9yTfJIXaMLCI+uMpIMvrZ+zsQLtD7fiwIVfYDptZy 2Mi9kGWhPPg3fMZazpydgzXYBAvGyFQ1rIoaxOE5IpYMNRicW5BBWg5SlBClGPaZXeqt KrwDvbkS64VSvVF2KjPg4DMPYAgZ4+0Wd5fjSUfNu3KJDFsgDv7jzxDQrH+/VKcCyoO3 a00dP2d6IRv7Jx62U5Bla8PdDblxMbMo00rbr2G3k4mixkOfFblEYyr4LD9Ab7asH0Uc ciQg== 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=DjKj9EzdAuWyK4cN+spXyTYM3d7/eJ9KCYgY9YiMv00=; fh=+EB6oBnXtBrxaPMIm1rb1kOyvjkddCLSgL4/UeSWQvM=; b=jPSWdVC/ELoX+AY9g1NhMsSgSJcuDQaKOqA0BN5n+BrWl3ghke3oRJZlXMsaIQITV+ UjKx5uLMufodYSlnhX5V9a99deGfSqD9ChBDNcyK0+SV7SeiblU5cbAqTJ8C3bp+zekN AYFypfEeG+2RDBfSSe1kMXvoDPcuLlpHGWAXQpas9XcRNdZdHzwWpK2xQR5BJh6y8U+V 3pVw89mt34OrFDtyf7qd4QQQ2vhuR29+E1A5ipOKPOWuTvkX/4WJZ2PwH/vHfPeU+Bw1 2tmSFSSInVyEqpqGnLr+oiuty2QtP6zKNGu9giqm5MjJq+6fymguQbLgYj7bD5gCsP1F WQ4A== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=HFLgSbjF; 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-37463-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37463-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id h12-20020a1709063c0c00b00a2c840217f7si100122ejg.834.2024.01.24.09.51.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 09:51:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-37463-linux.lists.archive=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=HFLgSbjF; 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-37463-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-37463-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 1EB891F21E6A for ; Wed, 24 Jan 2024 17:51:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E1B2E12C52C; Wed, 24 Jan 2024 17:47:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HFLgSbjF" Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.45]) (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 861DC12BF1C; Wed, 24 Jan 2024 17:47:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706118451; cv=none; b=eTWWb/w1oD8WTxZPvt0L14wgMVGjvPcll3zaNugRzHWmW8ZOd3Nc0+IArcJHCp/Mk69aeEnq/5qWTO7985oT00mW/itIlPLrAvDpvm61Nb/V1iEf2NEw05o0YHIfUuXyfECE0m3/ivveRGg+YM+Ffw1O8byOC/1VdpfL/jATZyw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706118451; c=relaxed/simple; bh=lbjcvJlqREfcesgrRYGDA24BL5PppwaqOFgHWCceX3A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r6nee3ySPvwEu4+JdqdyqpE10vqbGsemuoWeoTTm1dTJ429DocqsBdepyG623hSgXGVR3/yk9PVqWy2vW1EYqCLXzDScFrzFUX4w13VUCG6xwBMSeOoGhEVizHNwuIFtGpAckLk+PGSg0KnHPngDcUVWBErajGm8jISpbZhTM6k= 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=HFLgSbjF; arc=none smtp.client-ip=209.85.161.45 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-oo1-f45.google.com with SMTP id 006d021491bc7-59612e4a21eso2317880eaf.3; Wed, 24 Jan 2024 09:47:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706118448; x=1706723248; 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=DjKj9EzdAuWyK4cN+spXyTYM3d7/eJ9KCYgY9YiMv00=; b=HFLgSbjFUqCtWfBfxpQzrrPVNmc6+r3ZgTrqiPk3+dHQkdx23Y6HL8COkFD8o5aL+0 iUwkU35UjiWCkRn+vHwgFBy6SVyhwmgQsxAziHNSyqrVSREoiutdzlBjkE+fod87woNM 7d2XxwOLuuNzgjZHy1045m2gDsTn50jTa+Yhz/cWNt3c1rrqS/yv5AQkV6acqVyMXMXZ FN9tqY+RWs7fHuutgbNgpIOKXjb2zQjGGup9fUyEJbWg7hFSgUaDYIoUUIhVobukabze yO8gJ9O5xerPPzkXRCN+FKt5m34vdosCkXbDcS+cbTI39UCbZM30/Tz860n2R/kraPQj aSKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706118448; x=1706723248; 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=DjKj9EzdAuWyK4cN+spXyTYM3d7/eJ9KCYgY9YiMv00=; b=Km+3oBXCDF8+H5qTUvFOE+3BffV/hZUoo6oLXUegdU18x8YT7QjkH2GLAdwEJcrLbU ybHNdqPmgyfXCq4qEiMgzzJoVi1FsocW8rjZ8N8lvwWDM6NUQ2OH8PRuZ/MQAz9yMcfD ne+ESvZbJg27ofVdOC9fYqFvab4OlHajmt3n+P1MNqzgM5BZGkPLRT2z2ffkfirgM3ZJ PS2c2hMZsBk374NXFOE0PI1NnYqqq6Egu+u6JZD6uIPw0zAUkDW3QkaeI5a9GDVxde7A mmSh/MC+yWEkWOcTWzM+i1kLBmvA80rhLBsqFiHjmbOqYJxqOjtgaPJPU76OgFEK3Caf ynuA== X-Gm-Message-State: AOJu0YzDSpgKXGu5tOfm5QKEirc2qOFvWAl3BsNzvkI3B03uP19L12y0 5FOlDGc3KwPQxMeZOSk2EpA5jcX1zLKG7ieLycjnym75QR4vWeVa X-Received: by 2002:a05:6358:ee46:b0:176:277d:3487 with SMTP id ik6-20020a056358ee4600b00176277d3487mr3703332rwb.24.1706118448348; Wed, 24 Jan 2024 09:47:28 -0800 (PST) Received: from localhost ([2601:644:9380:8cd0::7fb4]) by smtp.gmail.com with ESMTPSA id z17-20020a63c051000000b005cfbe445a85sm8446564pgi.70.2024.01.24.09.47.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 09:47:28 -0800 (PST) From: Matthew Wood To: "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: leitao@debian.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v1 7/8] net: netconsole: append userdata to netconsole messages Date: Wed, 24 Jan 2024 09:47:05 -0800 Message-ID: <20240124174711.1906102-8-thepacketgeek@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240124174711.1906102-1-thepacketgeek@gmail.com> References: <20240124174711.1906102-1-thepacketgeek@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 7de693d0773f..8df3932ef4fc 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -1032,19 +1032,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; } -- 2.43.0