Received: by 2002:a05:7412:3290:b0:fa:6e18:a558 with SMTP id ev16csp913133rdb; Fri, 26 Jan 2024 15:16:15 -0800 (PST) X-Google-Smtp-Source: AGHT+IHU7RO5VSWw74qCNw56b3TTWnLZRHT56RqeMhtyXleO28EQGd8s9XTTwCxx7dKTkG7ldI1J X-Received: by 2002:a05:6214:1d2e:b0:686:1e2:747d with SMTP id f14-20020a0562141d2e00b0068601e2747dmr1082187qvd.38.1706310975707; Fri, 26 Jan 2024 15:16:15 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706310975; cv=pass; d=google.com; s=arc-20160816; b=fzQ81BNHJBp4y2emr8hsiKuwA/MwJ+32+wxUmZ4XJliEIDSQDMxWxifTEyOv4W1PPv d+2HqhnKl7VwTlDmEQj1OEqUuxpk3VIh3LV5PVtsQmjrTSfbiWD+AYVi/4umbol8vRyJ +RGBlF+TuDsJlUO6mU3hIdpH5YyuQWgeyto/YHU+sGUrxoM3M4ttvQr0XZalamHVB1tk Xx8FU8hGjqwDNGxmLo1UYaxzJ0IQMpHbDK/dUJp5+4WPpOW3PDCdoe1BTuec+jsTHrSR 75qhg4BGfeaHKUDb3jgMyHPGBnkXuhjFkFCC5PhZ+S66epClx0RwO3qPJk+Z8E8wXwN7 T/mw== 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=je2dXIpj4nMvLmLfnHTiHfBkXHkQg5LdUrpAF1wy3tM=; fh=+EB6oBnXtBrxaPMIm1rb1kOyvjkddCLSgL4/UeSWQvM=; b=dgIblw0XogBIrn7yYuYK7dUh36VhEr86BB/kDhDzTUvv2i7UmpOcTyh/Uw+zyq6hXh NUuu7X72Be5hxGf9JQdMvw0+MF999NwWc0k81kxcUJs57wV4h5GY5x9BHSGhylYvwlam LhZDaRMXrZq2Qc7s1sgMyFYzN7ja6RwenwTPh5QmtNPjeu8HkK7l1GBzTkxMXm4DqvcD h4ZjtVaUT71WhyglfZQ6UouDgoZYx2mang7G79kSPyqNAuP76qUIebJAQr1PV0dGuBeW WTd+AM6YcuViuVPpdjriM52xRzo240xlGJr5JiAEzg2+WbqZfkwL8sBOx4qAuxilrbeL lZtw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=P5tZxgUi; 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-40814-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40814-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 z6-20020a056214040600b0068059cc9998si2250748qvx.481.2024.01.26.15.16.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 15:16:15 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-40814-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=P5tZxgUi; 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-40814-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-40814-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 686021C226B9 for ; Fri, 26 Jan 2024 23:16:15 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 869445D90A; Fri, 26 Jan 2024 23:14:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="P5tZxgUi" Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.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 4571D5BAE5; Fri, 26 Jan 2024 23:14:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706310849; cv=none; b=WJa7yp6/Xt2fl3gCIih8QijgeUE/Rmi0JJsXAe10PWyOQKXZFAAgcRGIqJR34ncUXS3vDTgz1vZk8VwBH9Zooth3xZeHjaWcRFE/jSH5KRt7o0he4C4WZwPuijw/AnwjKrSweTBpGypfvO4n7si0pJ2KsVMWsUKVOB7E9wWWZok= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706310849; c=relaxed/simple; bh=aKiWzgmFK3XS1BsGpO2cXonb0cWCM59n3esPDJ++t1o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AIFnnaF44X4ARCLGbHVLlfFrBc5h9fnMg5DxKXs9OjQxolzAOqh1lSNF2muKrQ6DRhGZqHGkII+OKfWB1Yz1/qY/UbSDjdeTZmaXP1PluKD5G/YGd2JR+HlL/sB2/iIL559Rga7fTBQeiG5PRlMbpyKKRIsvdWGhu6ZbFU4K0Ek= 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=P5tZxgUi; arc=none smtp.client-ip=209.85.210.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-pf1-f169.google.com with SMTP id d2e1a72fcca58-6db0fdd2b8fso552024b3a.2; Fri, 26 Jan 2024 15:14:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706310847; x=1706915647; 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=je2dXIpj4nMvLmLfnHTiHfBkXHkQg5LdUrpAF1wy3tM=; b=P5tZxgUid81mNNLCbZ/QlNMPUoQ4itwQzaOKdrTe7ytzhsGJoh2w3L/eMDn+D/N3T7 2KBdZHqcLHtX0HL4DHQ+H931hYyxXUeTYkzN1ba69kImBDIDBxe4VdX23toDYqH3ncdt fShm6u1YhmgtA9z89mM3QxiC28PTeHJWWyaZ1PDV8o9W0Y/ChIjqOYW8A/gigjnWvjdQ 8REiq4yHF+C7B2lwbqwrSoqmGcXiHtQXjhhuTA/nsU/LzChJBYUxsrMi4MLo0D+0BLmN n1/qazU9fTbCFjg3F6AQavRvOz9PaXH7dg/IlDokqmVF6zeP/VWITGur7X4feIjfROY/ 4ZPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706310847; x=1706915647; 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=je2dXIpj4nMvLmLfnHTiHfBkXHkQg5LdUrpAF1wy3tM=; b=NGx9RIia+XztDKEoC3fx13Qm4B56zfuZSvGEnabHmSP5siOKzypQbuUT3pnrR/EpWn 7hdSR+HKXSh/TLFv/ZQL5XAdvk2Wpqo5hL6DU038V85H0UShlPDK7I4iP3IVuWlMvUTl Rur0bKnQSfJTfnQspSaxvwPKeAbF5PCFiNbAII47ay0yfek1euYlUqM8612/TDoU9Wel nrcrmK9C9ZqOXdkRCWZmUp5S8zFVxXLHg1rFEydKFBvjPP1kG8V5tPbNWRIu+3/EYsZ7 ZU/ashLdmYEw5LMZMjjF6ua0mIfiqW8T+v77jUuSjlTggGmM0DMCalv4uS87L2/3sOT+ ZgGQ== X-Gm-Message-State: AOJu0YzTBHRBaLMFifBW7jj8aJRt7y2vT+qCW1vZ294gM6Q/vZwsjBar ngZaJ656XASpz0RJdHcC8+FL0XKy6e2ed1SO5tAeKKliiJH6tzRI X-Received: by 2002:a17:902:c70c:b0:1d7:38fc:1272 with SMTP id p12-20020a170902c70c00b001d738fc1272mr587369plp.75.1706310847695; Fri, 26 Jan 2024 15:14:07 -0800 (PST) Received: from localhost ([2601:644:9380:8cd0::7fb4]) by smtp.gmail.com with ESMTPSA id o2-20020a170902e00200b001d748fac506sm1446405plo.82.2024.01.26.15.14.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Jan 2024 15:14:07 -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 v2 7/8] net: netconsole: append userdata to netconsole messages Date: Fri, 26 Jan 2024 15:13:42 -0800 Message-ID: <20240126231348.281600-8-thepacketgeek@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240126231348.281600-1-thepacketgeek@gmail.com> References: <20240126231348.281600-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 73feba0b3c93..de668a0794b1 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -1035,19 +1035,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