Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1428801rdb; Mon, 2 Oct 2023 09:12:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHRB/KtUiUJCnU9AnBAMTSQ3WCu+EVIqj1psfhXWet48eRLh7ekd2J/CgUucjscnUR4i8Yq X-Received: by 2002:a17:90b:4b4b:b0:271:78a0:8ab2 with SMTP id mi11-20020a17090b4b4b00b0027178a08ab2mr24321pjb.24.1696263140260; Mon, 02 Oct 2023 09:12:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696263140; cv=none; d=google.com; s=arc-20160816; b=u6CXFJp1qxMs7kBrC6zdx1o2AqmwlgAQjZtNtDuo3oOL3uNMYcMclCaxIOGgUP7POi N2c+A6OF50ylQIBoZ3KHr1Wn6FGvPQNiuV2ie1kpXyTrsnFJ2Ze4gdLdecWCdY0GGkfv 3gVeBfv67oa7AL45t+wXH7AB2ZSOGl7fgyH8Wqg77XKi1W9qb6jo8DNUHs8PO4rZVQXL KcNTSWXukCaoNxR7cCCwimY4gZEDbPa9xqiymoiZ6hFXaTC8HT3YNNHWNPifiW7sX/hN FKAd4txjGwtnSTPqER/IJWAxn+pSsbpexy7nipBtkIdUkb4UebFRCvQNXgFbIot0pAHN uogQ== 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=+dB3Fa+xaQmqZtxLPNwQ8zqx2W86fDzE1tsm/B4ppuQ=; fh=t3kfgQuaGyM84gKNjjnNISmg23a5dmENm6EBz3YSRHQ=; b=ZUtfRQdbFA0Fq3omrv4oskjNLh+1t1hov7y/uUqc1MsJkoyzsr3Xldz6p3T0Z+NrnF fPtOFoIv2rlPkA2RiEtCYhqIGy6jFf1kN/qxQKI0VuuX5gH+WijrbY7ht76pb75KnCMw 5dkqe0iRiGTOj9lrQzdymJ3oK8NPq9ucP6ojNVUw/RTK1BMxrKgdSfhxydPEeN5gz8Uu aQvqD7ZDhYuiQzdt7p/WnpXyMvN6tE4+63Cf0PLoCFl/12dksMjhOndPhyI/cPuT5i8j JcoiNEanFRUM1SL5IwC4cm7tl2kFt2C2c2O9ajvzsBk/+9yHA6aGdWhjGktBxRwf1v99 IFbg== 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:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id ie2-20020a17090b400200b0027660aac61asi7735270pjb.114.2023.10.02.09.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 09:12:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id AAC2C8058A17; Mon, 2 Oct 2023 08:56:37 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238273AbjJBPzq (ORCPT + 99 others); Mon, 2 Oct 2023 11:55:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238278AbjJBPzo (ORCPT ); Mon, 2 Oct 2023 11:55:44 -0400 Received: from mail-lf1-f53.google.com (mail-lf1-f53.google.com [209.85.167.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C632AC; Mon, 2 Oct 2023 08:55:41 -0700 (PDT) Received: by mail-lf1-f53.google.com with SMTP id 2adb3069b0e04-503397ee920so25279412e87.1; Mon, 02 Oct 2023 08:55:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696262139; x=1696866939; 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=+dB3Fa+xaQmqZtxLPNwQ8zqx2W86fDzE1tsm/B4ppuQ=; b=TMMU2FvuLFxPwXEBCAUEi4NO8oNlWEuf/KT84R/bTb0NZRsd0fQc1Cn8JEiC+MDOXk 26vP6NszPkHj8AmKvNvQwXxzTnkcQu4qWyTzngmQYr+/e+3zTydWGN14eafR2TTVKhd2 urRMZnAryCRVnQOcsb0buopkXtLhKX+vy7fMPs0smNLAg3Gu3tyV+by0NZQybnGzpy1l Yxb0rwMjdUHMOssS/utD7+QApRXkeIjqRH3rH6/y6NxlWpWbszpplb3JmN5HupkKczir wVc5djKfhI5fTTHO9Aqy6FnegT8zudAtaLzVzr+HH9VqzMG9wc4Oc40gPLPuPH+Dk6zF HwUw== X-Gm-Message-State: AOJu0Yx5XzC7swe86e5BI6dQuF4GssllWkAjF+AnC0O/XCn8yzD24xa1 T+7XKTNYBTK08moZdHJ3gHY= X-Received: by 2002:ac2:57c6:0:b0:505:70dd:d594 with SMTP id k6-20020ac257c6000000b0050570ddd594mr5844378lfo.49.1696262139348; Mon, 02 Oct 2023 08:55:39 -0700 (PDT) Received: from localhost (fwdproxy-cln-017.fbsv.net. [2a03:2880:31ff:11::face:b00c]) by smtp.gmail.com with ESMTPSA id j5-20020aa7c405000000b00537708be5c6sm5419783edq.73.2023.10.02.08.55.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 08:55:39 -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 1/3] netconsole: Initialize configfs_item for default targets Date: Mon, 2 Oct 2023 08:53:47 -0700 Message-Id: <20231002155349.2032826-2-leitao@debian.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231002155349.2032826-1-leitao@debian.org> References: <20231002155349.2032826-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 groat.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 (groat.vger.email [0.0.0.0]); Mon, 02 Oct 2023 08:56:38 -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..b68456054a0c 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 DEFAULT_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", + DEFAULT_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