Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp344398rdb; Thu, 5 Oct 2023 07:36:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGhEYt560CHQF8I0RsCt9Ahr9kMbYrLnYUWppGg4k1DnfHRkXzn7xWVQak98sfZgVQ9NKFs X-Received: by 2002:a17:902:da84:b0:1c1:ed61:e058 with SMTP id j4-20020a170902da8400b001c1ed61e058mr6328865plx.16.1696516617788; Thu, 05 Oct 2023 07:36:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696516617; cv=none; d=google.com; s=arc-20160816; b=GUoTukGiz80u+9mIOnyjs4/v0JJo5TqS4ns3llLvx4TCZQOw2u3tMe3qFdAOZm49GK Wo6DsWqPHdcV7QBjwuZ0VrgY0YeRDqKSCQZyV40XLR2HpTO6G8SbFT8W6zizrUbe5LCg U95rY1NfbiHc9oOlBgjF15iY18ZDnmoerWaYwFp4aLYg3l/GUtHrGUxf01OqoEBIhtHn zdn9nTquVELZ3F7Wd8GuJvuU3cpDVc0GfcNjJTDEBMa3KeWr+5+3SwN+Q1KKN/xyT+id UqeGSO7emejzic8ii2ZTlIak80qptMDdoS2T5nx5gZ8Mpmq+u1gw1oLFGGsNjYuq+nep fQfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=evoVQq8sZfXXqhKGthgDih8IbsSodAMl/ul/GSH8ebw=; fh=t3kfgQuaGyM84gKNjjnNISmg23a5dmENm6EBz3YSRHQ=; b=gorq0tUddwB1T+xecd96BdO4XuCXOirZ9HxaHoZuZqsUsjFOa3eYTguVWr4W4Rkecg 4aU1zTZmGI3nIgrFqRmoaCZSXV3y4cMB2PlSrJCFkaayCkMnuRNLOumehE18hf3d8Z/A rV5xaiN+lieOx2LkiECZbPBM2Okd6bhKV4ha/l8V+sUtfilLshbnafqwrQsLUwjaQX0K jdE/c59rQpIAQ+1gAoRpOFGcH38Hnhd1QDXuIL2fl4/msuNNWtdvtVU0R+acOwI8hRL9 Lm6qU6sV45JalPnyQaCxRivj2io5ix0sQO1WfJ3xgyBmqM4aB9ZSz89uHwBZ77MY8JXD yBLw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [23.128.96.34]) by mx.google.com with ESMTPS id c9-20020a170903234900b001bf1973eafcsi1742647plh.571.2023.10.05.07.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 07:36:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) client-ip=23.128.96.34; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.34 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 0B899827AF94; Thu, 5 Oct 2023 07:36:18 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235563AbjJEOfo (ORCPT + 99 others); Thu, 5 Oct 2023 10:35:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38584 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235360AbjJEOeQ (ORCPT ); Thu, 5 Oct 2023 10:34:16 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 49D6726A4C; Thu, 5 Oct 2023 05:37:13 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id 4fb4d7f45d1cf-536b39daec1so1538302a12.2; Thu, 05 Oct 2023 05:37:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696509431; x=1697114231; 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=evoVQq8sZfXXqhKGthgDih8IbsSodAMl/ul/GSH8ebw=; b=sNzx7w5KPKtur6My5QhL+eb2fpJeXOQci7YtcpzPrkqnXhZYt4UfQBDHONkUDa6MC/ tIyfbo9gu9aJY9vY1u7f4FEfg/nfRUj7mRTvO55IeM8moySHXD+kua1ev7btZ3Ilqihg 3hdX958objluz4N2CxTes2OIZNFLFYq0PMmaG5EwIe8P6FxIBRvfdmZZnXNhmOBbgOTq Yyu5hUyJZeAkUOxkKxWm2jxLARhgksDJZ+d1QUd/doa82Hr7ucYHOxn9zcUamrPkrwZF EP57zAVtBFUi4kldGCPSyQ02okZMBNmVzq4DpYKF4NsnMeKG54HjtQ1QEc+16BBd+hEa Wy4Q== X-Gm-Message-State: AOJu0YxD2G5TZLOJrC+q78Paxk1coKxtxyBMZUkYPNk1okW7MN7sr2k1 1132ENJAfTbsno6wGcl1cWk= X-Received: by 2002:a17:906:714a:b0:9b2:b9ad:ddd1 with SMTP id z10-20020a170906714a00b009b2b9adddd1mr4885066ejj.28.1696509430566; Thu, 05 Oct 2023 05:37:10 -0700 (PDT) Received: from localhost (fwdproxy-cln-007.fbsv.net. [2a03:2880:31ff:7::face:b00c]) by smtp.gmail.com with ESMTPSA id gq7-20020a170906e24700b00993664a9987sm1131147ejb.103.2023.10.05.05.37.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 05:37:10 -0700 (PDT) From: Breno Leitao To: jlbec@evilplan.org, kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, Eric Dumazet Cc: hch@lst.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, horms@kernel.org Subject: [PATCH net-next v2 1/3] netconsole: Initialize configfs_item for default targets Date: Thu, 5 Oct 2023 05:36:34 -0700 Message-Id: <20231005123637.2685334-2-leitao@debian.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231005123637.2685334-1-leitao@debian.org> References: <20231005123637.2685334-1-leitao@debian.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 05 Oct 2023 07:36:18 -0700 (PDT) For netconsole targets allocated during the boot time (passing netconsole=... argument), netconsole_target->item is not initialized. That is not a problem because it is not used inside configfs. An upcoming patch will be using it, thus, initialize the targets with the name 'cmdline' plus a counter starting from 0. This name will match entries in the configfs later. Suggested-by: Joel Becker Signed-off-by: Breno Leitao --- drivers/net/netconsole.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 3111e1648592..7c46cf1c923e 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -53,6 +53,8 @@ static bool oops_only = false; module_param(oops_only, bool, 0600); MODULE_PARM_DESC(oops_only, "Only log oops messages"); +#define NETCONSOLE_PARAM_TARGET_NAME "cmdline" + #ifndef MODULE static int __init option_setup(char *opt) { @@ -108,6 +110,8 @@ struct netconsole_target { struct netpoll np; }; +static void populate_configfs_item(struct netconsole_target *nt, + int cmdline_count); #ifdef CONFIG_NETCONSOLE_DYNAMIC static struct configfs_subsystem netconsole_subsys; @@ -165,6 +169,10 @@ static void netconsole_target_put(struct netconsole_target *nt) { } +static void populate_configfs_item(struct netconsole_target *nt, + int cmdline_count) +{ +} #endif /* CONFIG_NETCONSOLE_DYNAMIC */ /* Allocate and initialize with defaults. @@ -193,7 +201,8 @@ static struct netconsole_target *alloc_and_init(void) } /* Allocate new target (from boot/module param) and setup netpoll for it */ -static struct netconsole_target *alloc_param_target(char *target_config) +static struct netconsole_target *alloc_param_target(char *target_config, + int cmdline_count) { struct netconsole_target *nt; int err; @@ -228,6 +237,7 @@ static struct netconsole_target *alloc_param_target(char *target_config) if (err) goto fail; + populate_configfs_item(nt, cmdline_count); nt->enabled = true; return nt; @@ -740,6 +750,17 @@ static struct configfs_subsystem netconsole_subsys = { }, }; +static void populate_configfs_item(struct netconsole_target *nt, + int cmdline_count) +{ + char target_name[16]; + + snprintf(target_name, sizeof(target_name), "%s%d", + NETCONSOLE_PARAM_TARGET_NAME, cmdline_count); + config_item_init_type_name(&nt->item, target_name, + &netconsole_target_type); +} + #endif /* CONFIG_NETCONSOLE_DYNAMIC */ /* Handle network interface device notifications */ @@ -954,6 +975,7 @@ static int __init init_netconsole(void) { int err; struct netconsole_target *nt, *tmp; + unsigned int count = 0; bool extended = false; unsigned long flags; char *target_config; @@ -961,7 +983,7 @@ static int __init init_netconsole(void) if (strnlen(input, MAX_PARAM_LENGTH)) { while ((target_config = strsep(&input, ";"))) { - nt = alloc_param_target(target_config); + nt = alloc_param_target(target_config, count); if (IS_ERR(nt)) { err = PTR_ERR(nt); goto fail; @@ -977,6 +999,7 @@ static int __init init_netconsole(void) spin_lock_irqsave(&target_list_lock, flags); list_add(&nt->list, &target_list); spin_unlock_irqrestore(&target_list_lock, flags); + count++; } } -- 2.34.1