Received: by 2002:a05:7412:bbc7:b0:fc:a2b0:25d7 with SMTP id kh7csp2100017rdb; Sun, 4 Feb 2024 15:30:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IHOl90mP7AQH3zp0J3sliBQzZ5FYVnoiPDpv3Vzajyym7EORB7x2JcAy+JaE6ZjVGo1jdS2 X-Received: by 2002:aa7:d894:0:b0:55f:e543:b006 with SMTP id u20-20020aa7d894000000b0055fe543b006mr4730432edq.13.1707089426141; Sun, 04 Feb 2024 15:30:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707089426; cv=pass; d=google.com; s=arc-20160816; b=bcLVGOW0e12xHz9fA6FxVzS/9eq7KnCZP2g4yE0PQGa9AraACJczbzXN42U5vfXEh6 p9dfg/0jUtPOK3KKz6vlFgEGJXTTH+xNtsbL7ZPvSud8FyJ/3wVRaoYHH+SCbdELsN1M 0skOqO/xKP42sHYjSwT4+sN0fkfTuYgOvcMSrm86Kgv1V2wSbOBf8dpyuGBr6EwMu5Y2 rL1JZ04KWma5xyXod0Y7LchJv4+8Fo0/QBAQmDK7G3GNb9KKY3gTS/xxrCviCZw3BHTo XgjVSsa3ikKySurWiWjOAWSE84E8vFaM3WGE2SifW5erFeU5+eqw8RBYrBXyERPTIxnf fQuQ== 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=VeJVCkg50SEO/W4Ha/djWGQKw9KnaZBFtRZZ8ihYrnM=; b=sZ9MdcCHabBVNNvt9e5GC8nQvQWb+IhVDMEZ51x0BYq0U61pgjbGQ/v4Zx85D535/U 4XH1ZpNhkXBvxhTLOZe6Ciw6kjHrl2hBlL7mDGX2ryxwZgQ4WnF4SIWhDnlY3Ig2WtbU E6h1CGBNKPIQkGV+xjxmRhOGghawaeRP2cx74q52VkIBxPo9uerzUUoa/tmJdalgUHTN zMvlolUl0VMXH7nlvWIQOuUJerQLdZwqmV3AFf8CvSHW0N1CRoylzDeDeVkgWbp+O76n yVrnAwqRMJzWoTEw6pY9q6jXowmhOoz0FBRmExKUtcBOTsyCotTdomEZhgmAmpxOmZIC sAUQ==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51940-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com X-Forwarded-Encrypted: i=1; AJvYcCXhz+kE0ThmIrinWcTsO6MNnxCdDHk7OiAPTBHXYOBeNe7ztpZqZR1FfnnCVeMbL45Y8OffiX2/GDBlVXrVbeq7pVLHES+N4Kt9YbSWSw== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id g5-20020a50d5c5000000b0055ef4fb4170si3329097edj.56.2024.02.04.15.30.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Feb 2024 15:30:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-51940-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=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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-51940-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 DD6AC1F21CF4 for ; Sun, 4 Feb 2024 23:30:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D0471DA5F; Sun, 4 Feb 2024 23:28:04 +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 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 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; } -- 2.43.0