Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp231666rdg; Thu, 12 Oct 2023 04:16:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHHIXvx2M1cxX9NcV8kQ+8e7dMiJqHgKXQHmj+zOptwj1Wl6JoWe0dY1E2HV/xgtnYUoEXN X-Received: by 2002:a05:6358:9042:b0:142:efb8:5295 with SMTP id f2-20020a056358904200b00142efb85295mr28973517rwf.19.1697109368001; Thu, 12 Oct 2023 04:16:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697109367; cv=none; d=google.com; s=arc-20160816; b=pwrA3jqhZUnsEbLeVV/u2U5A0ZT8IWgZg1x1+Ob4xJ5y4Jaha3D1yx0Mlqaasz/077 DEqWxCgNUqHV0AI4LC//+7zo/Bl44YaNMuvwFkuWDeEiuqwgVo/IkCOY0ladQk8UnrL+ UhNKKgCTaKarYovb965w7d6wEbdR/ucw6hXyHRF3VRArlmZS3taWLP9Z+skJ62UDvgm8 yi+RWAIXApIjAWlarjnj35gslJC0FcOoYFAVq4MUyjiX2JzZgBfoVabmHZJ/ypxrAWw/ Vy0lBEHO6uulKFFY00XYWHuQFSKovr0SgdF2KF960js0qdqX5I0g8iVbdSH2CzPKenWZ fSAw== 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=azlBm1bMHX5sI/cuS/oB85eLn/m2Im3cX9O78MhWE54=; fh=t3kfgQuaGyM84gKNjjnNISmg23a5dmENm6EBz3YSRHQ=; b=XVYEZQvfsur+0jNTA7ytc0yNzxaWD8s/RGruiRGvEkQ/dnDHgEC0Ub/DKSBjRear57 wP0whJuu65eDNDusUpBpF5SXHIrBDEZV3SAK+PZoPrJ57/K5VFXV0UtavlCwfZ+H/wIE CBoHIf/rms8PktZhSp2yvUeqI66DonAVIxbimLJHFE0CwPJKDVy7kRpKdZcItDs1G15D 8QOwaMRbTVUrk03NsOQuCZHTczbXGA/tSMbnlnCyz7EL6iJdJAs0Yi0Q8DuBDstGQhzo 6vjpyMyl2a/iDRXzXaV9VGTSruOCDEO8zVo6j6BFEw26R7LC36bxlg4DL8bwRKpa6Cwn Hryw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id bq25-20020a056a000e1900b0069339f19f7dsi14001369pfb.199.2023.10.12.04.16.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:16:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 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 pete.vger.email (Postfix) with ESMTP id B75B781A7D05; Thu, 12 Oct 2023 04:15:06 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378218AbjJLLOf (ORCPT + 99 others); Thu, 12 Oct 2023 07:14:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232490AbjJLLO2 (ORCPT ); Thu, 12 Oct 2023 07:14:28 -0400 Received: from mail-ej1-f49.google.com (mail-ej1-f49.google.com [209.85.218.49]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 061A0C6; Thu, 12 Oct 2023 04:14:26 -0700 (PDT) Received: by mail-ej1-f49.google.com with SMTP id a640c23a62f3a-9a645e54806so129367266b.0; Thu, 12 Oct 2023 04:14:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697109264; x=1697714064; 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=azlBm1bMHX5sI/cuS/oB85eLn/m2Im3cX9O78MhWE54=; b=bro8zqXcehwrO4ezI3RZmUzadTXDhiL1ZDgtyvkNuIEAsez50/uTu3RKK94j9/I94f KUYMZKUZWY4gn3QO7M/hgEAfdz4T6gzY6RfRSP6FLseDY9ljjnOdfvg0+SHYnaPsLNsE lcYWVyfKVKg8clz68w2Xc9UneQS1FNN/aZ8JDI1LfGiaEhdh4LCRSogZKpgEtLkuM8H6 c+dwq8rqGOz8+4TEJ15kl6jgTe3t4qQ5IWJroTn0chFb1wV3opPAGdZzabVihlqF2XxA WdIdlUx4NT/BRobcVam2j4QvV3uV3ompu9lwipw9DF6jvfKlWxU0nV0+MNjsqSWIIZ8V J3uA== X-Gm-Message-State: AOJu0YyIiUblXJE2aex6tIsZfgMnXwBZNtk8z/5CkPGJjNS5MYScYjL3 H/ba+cygxHsd/LrczWa4urI= X-Received: by 2002:a17:907:2711:b0:9b2:6c58:87a2 with SMTP id w17-20020a170907271100b009b26c5887a2mr19986752ejk.29.1697109264354; Thu, 12 Oct 2023 04:14:24 -0700 (PDT) Received: from localhost (fwdproxy-cln-018.fbsv.net. [2a03:2880:31ff:12::face:b00c]) by smtp.gmail.com with ESMTPSA id x26-20020a170906711a00b0099329b3ab67sm10945121ejj.71.2023.10.12.04.14.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 12 Oct 2023 04:14:23 -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 v4 2/4] netconsole: Initialize configfs_item for default targets Date: Thu, 12 Oct 2023 04:13:59 -0700 Message-Id: <20231012111401.333798-3-leitao@debian.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231012111401.333798-1-leitao@debian.org> References: <20231012111401.333798-1-leitao@debian.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email 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 (pete.vger.email [0.0.0.0]); Thu, 12 Oct 2023 04:15:07 -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 | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index d609fb59cf99..e153bce4dee4 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_PREFIX "cmdline" + #ifndef MODULE static int __init option_setup(char *opt) { @@ -165,6 +167,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. @@ -688,6 +694,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_PREFIX, cmdline_count); + config_item_init_type_name(&nt->item, target_name, + &netconsole_target_type); +} + #endif /* CONFIG_NETCONSOLE_DYNAMIC */ /* Handle network interface device notifications */ @@ -887,7 +904,8 @@ static void write_msg(struct console *con, const char *msg, unsigned int len) } /* 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; @@ -922,6 +940,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; @@ -954,6 +973,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 +981,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 +997,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