Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp2838179rdb; Wed, 4 Oct 2023 13:02:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH+TIAMUXrwvPQU9jMMCWPovusR87xuW7VN0W80a6jP4ZqeVz6gy0QvHcbs+zj0MbBx+rDs X-Received: by 2002:a92:c24b:0:b0:34f:c7f7:18b with SMTP id k11-20020a92c24b000000b0034fc7f7018bmr4119181ilo.2.1696449776491; Wed, 04 Oct 2023 13:02:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696449776; cv=none; d=google.com; s=arc-20160816; b=ow/BThgYZOgtQCX2I6R3k199A7hsGqNUzinHh0D5XT40FXa4CEYVdD7w/cJ+dNwhpG YWEnV8FnfnR4UyoSnRvElhPh09dI9Nm572Fz3v1lL5KggOBrxrshV26Gz3jLMHY8L1VT siDym3EqalAXcZDu/ew47VJ2eFBSouPUlqXt4qZPDtH2WijanTuBtdS8jtuXtyQjQ/fJ vhDWkATtNXboI6pbkdJY5uHn4Z9dHQZnQ9yueCFylq7mv1vNUwYU/kaTcz/wLsSGMVDm 06C4qi27WNh0OnIkIMOHFr1IzVyJMm3QWV0j841SY/mLeVYHT4Rko2d1jewdpWjgxjte c47g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:mail-followup-to:message-id:subject:cc:to :from:date:dkim-signature; bh=MEDpCLtA6saV273n9QbcI2SdIbI0BMgImtkzhlafRjs=; fh=tdgJDcMEMk0ZJAcPsr5CWaTtgA3Ce8/hJz5lncKLUck=; b=T0W1+LEp6TYQ/9pcXTbrGMP714MMLu89YfmBnWqOa9YPBCHg5ker2z31bqrIsWvJx4 fPqFgqBlyfcHwdujVoeWtywFZU5B4ygz3EJ55i4WePf8fWwT1qhu4mD4H/0DenvnbP5j 5584P6PrujU3bWwBnikuiSzNuianz9Ocylmb2kBaRcsMKjWqvOXiC7LZZzWD3tvm/vS4 YActSxIBm7PJBbVcklOZBtUbF+kZgwoGBaNi6FFyxxjVg0X/8vlOd3rcQv8YLpBBGoXk Nk8JkmnIrlQWjbIC/W3VZa/ZnyW1H/bVOLJDPJH38uQQ2JLUcPodmr4qevWPJatLvkHo 5UVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@infradead.org header.s=zeniv-20220401 header.b=haqQaiCb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id h70-20020a638349000000b00565ecee8793si4315268pge.875.2023.10.04.13.02.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Oct 2023 13:02:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=temperror (no key for signature) header.i=@infradead.org header.s=zeniv-20220401 header.b=haqQaiCb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 5839184A9010; Wed, 4 Oct 2023 13:02:53 -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 S243904AbjJDUCx (ORCPT + 99 others); Wed, 4 Oct 2023 16:02:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48168 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233759AbjJDUCw (ORCPT ); Wed, 4 Oct 2023 16:02:52 -0400 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [IPv6:2a03:a000:7:0:5054:ff:fe1c:15ff]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4B2DAD; Wed, 4 Oct 2023 13:02:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=zeniv-20220401; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=MEDpCLtA6saV273n9QbcI2SdIbI0BMgImtkzhlafRjs=; b=haqQaiCbgNfx9MLqPT6W8jhO7K JEVhl8TGbPhoNHqFMYUrjcD63PDSQ7/zJO48daapSPsR3Q6xIXyPnvOh8YJHtokW/xl0mzstSwvKt YTjl/M4/Hk5mT8JntCjGewR+Ggny35NWm15L8cGiT0HiIy/c2e9zIvyqtx/Tj3K7G10Pzbprb8vjx xzpLmF0K8jfh+ETxNPuME7H9XiK4+kZmAgZUCQtCT3i3lZMdk4ruZp4DbL1e93j2/JrAIpk5mYKNP kIwGBryenk63kLXf0pUHpd4TtRiwkk8zusr6mMYtPf1qIfTxY8DXTfcSwbo7qcPU0oFmOrxVLsQOX lzv3l5pg==; Received: from jlbec by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1qo84m-00Fp66-0x; Wed, 04 Oct 2023 20:02:32 +0000 Date: Wed, 4 Oct 2023 13:02:29 -0700 From: Joel Becker To: Breno Leitao Cc: kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, Eric Dumazet , hch@lst.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, horms@kernel.org Subject: Re: [PATCH 2/3] netconsole: Attach cmdline target to dynamic target Message-ID: Mail-Followup-To: Breno Leitao , kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, Eric Dumazet , hch@lst.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, horms@kernel.org References: <20231002155349.2032826-1-leitao@debian.org> <20231002155349.2032826-3-leitao@debian.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231002155349.2032826-3-leitao@debian.org> X-Burt-Line: Trees are cool. X-Red-Smith: Ninety feet between bases is perhaps as close as man has ever come to perfection. Sender: Joel Becker X-Spam-Status: No, score=-1.4 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED 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]); Wed, 04 Oct 2023 13:02:53 -0700 (PDT) On Mon, Oct 02, 2023 at 08:53:48AM -0700, Breno Leitao wrote: > Enable the attachment of a dynamic target to the target created during > boot time. The boot-time targets are named as "cmdline\d", where "\d" is > a number starting at 0. > > If the user creates a dynamic target named "cmdline0", it will attach to > the first target created at boot time (as defined in the > `netconsole=...` command line argument). `cmdline1` will attach to the > second target and so forth. > > If there is no netconsole target created at boot time, then, the target > name could be reused. > > Relevant design discussion: > https://lore.kernel.org/all/ZRWRal5bW93px4km@gmail.com/ > > Suggested-by: Joel Becker > Signed-off-by: Breno Leitao > --- > drivers/net/netconsole.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c > index b68456054a0c..6235f56dc652 100644 > --- a/drivers/net/netconsole.c > +++ b/drivers/net/netconsole.c > @@ -685,6 +685,23 @@ static const struct config_item_type netconsole_target_type = { > .ct_owner = THIS_MODULE, > }; > > +static struct netconsole_target *find_cmdline_target(const char *name) > +{ > + struct netconsole_target *nt, *ret = NULL; > + unsigned long flags; > + > + spin_lock_irqsave(&target_list_lock, flags); > + list_for_each_entry(nt, &target_list, list) { > + if (!strcmp(nt->item.ci_name, name)) { > + ret = nt; > + break; > + } > + } > + spin_unlock_irqrestore(&target_list_lock, flags); > + > + return ret; > +} > + > /* > * Group operations and type for netconsole_subsys. > */ > @@ -695,6 +712,13 @@ static struct config_item *make_netconsole_target(struct config_group *group, > struct netconsole_target *nt; > unsigned long flags; > > + /* Checking if there is a target created populated at boot time */ Perhaps a little clearer: ``` /* Checking if a target by this name was created at boot time. If so, attach a configfs entry to that target. This enables dynamic control. */ ``` > + if (!strncmp(name, DEFAULT_TARGET_NAME, strlen(DEFAULT_TARGET_NAME))) { > + nt = find_cmdline_target(name); > + if (nt) > + return &nt->item; > + } > + Thanks, Joel -- Life's Little Instruction Book #356 "Be there when people need you." http://www.jlbec.org/ jlbec@evilplan.org