From patchwork Mon Oct 2 15:53:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13406431 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B98C21CFAA for ; Mon, 2 Oct 2023 15:55:43 +0000 (UTC) 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-Google-Smtp-Source: AGHT+IFahUsF8lfZQEc0Tr+vmMmhPqswaS+fb02WQIercOaELGNPoWeghdUtmUsqK5A5ENSij+S3JA== 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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org 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++; } } From patchwork Mon Oct 2 15:53:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13406433 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4F411D6A7 for ; Mon, 2 Oct 2023 15:55:46 +0000 (UTC) Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B70ECE; Mon, 2 Oct 2023 08:55:42 -0700 (PDT) Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-9a9d82d73f9so2279293066b.3; Mon, 02 Oct 2023 08:55:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696262140; x=1696866940; 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=aVA8+4Ag1gceWiVP2I9j+CrDamJhnQG/Ib4pWtjPquA=; b=NC3X17Hm6TbXzEoKpGMKlllx3HIwjaxuQKC+K+dogwBAaai9lXPlwKBnmWsmhdraiV h8NYlt6mVUSur7fGhnrhr/JFVwnhZaWR7P9TArLlHJv0TZvCgGBAgsasvtAsOJTzZWES uCImysrwRnQTgQofMKrZ+y2lIYhGNEoO44EJPbL9wM+Nt0tDbemfKbxUIGYbxCQ2jnv7 1LeMlbk9B+GxyRJiEOPdUstOAYTmAHWOyizpT0TAIFZ0NJV6x6ufXGzW1B4shLGeUiN7 KsF40LUXGiPg09bnTQL0Q5U/idE13OSPf0mKGvwNNutrnvgbDNDFNTnprJq2vDli5Run wZXg== X-Gm-Message-State: AOJu0Yw8sbpLrzRhN9oZfvYx8izhR9WNxvEhK+H/9ne2dVTQ6XTbT2po KAo1riAex6O0x4zYIGfVhZU= X-Google-Smtp-Source: AGHT+IE+Zi8Fb98oyNB30KZKRnjdjfsN0mmOs28H0s1tQhD48OcMlFkU/4MM58tfTOCHacC5c6t+Bw== X-Received: by 2002:a17:906:3019:b0:9b2:73b3:29a1 with SMTP id 25-20020a170906301900b009b273b329a1mr11631013ejz.23.1696262140597; Mon, 02 Oct 2023 08:55:40 -0700 (PDT) Received: from localhost (fwdproxy-cln-118.fbsv.net. [2a03:2880:31ff:76::face:b00c]) by smtp.gmail.com with ESMTPSA id t20-20020a170906949400b0099bd5d28dc4sm17289237ejx.195.2023.10.02.08.55.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 08:55:40 -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 2/3] netconsole: Attach cmdline target to dynamic target Date: Mon, 2 Oct 2023 08:53:48 -0700 Message-Id: <20231002155349.2032826-3-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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org 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 */ + if (!strncmp(name, DEFAULT_TARGET_NAME, strlen(DEFAULT_TARGET_NAME))) { + nt = find_cmdline_target(name); + if (nt) + return &nt->item; + } + nt = alloc_and_init(); if (!nt) return ERR_PTR(-ENOMEM); From patchwork Mon Oct 2 15:53:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Breno Leitao X-Patchwork-Id: 13406432 X-Patchwork-Delegate: kuba@kernel.org Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9A1A1CFAA for ; Mon, 2 Oct 2023 15:55:46 +0000 (UTC) Received: from mail-wr1-f54.google.com (mail-wr1-f54.google.com [209.85.221.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2740D7; Mon, 2 Oct 2023 08:55:43 -0700 (PDT) Received: by mail-wr1-f54.google.com with SMTP id ffacd0b85a97d-31fa15f4cc6so16121024f8f.2; Mon, 02 Oct 2023 08:55:43 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696262142; x=1696866942; 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=8qeLc5XrOrdKAgQ/hYZGbkV5o1+THk+DVcDdslRirRs=; b=sThS+KoMhoVPhLbQBjB+90FGaBixvEviv93n/T/SSzm/bIZhe/T1dXQgXHHJHM4dw8 J7O6GKLmIKfTtcH6XFNJlBQ2CXcCwNZ9FBhBH7/IBqwNd40HX0/rXmtWhhl3RZMGvFD5 C8hv9rYdqLPY5LFkqYa5kLcTpLuvgaGthzs6KypjhPm8zr1mQqKuwf094CM4pUUTxKGe gwb/YY8PWLIPV8xJy7I8Uv4p7EeCKUdF0y/gHjnqJbwVApgqGu+I1l5rl6nT7JFJOaqp OlVbFVpL2HUNoioGJwbPLPruE6Bfz4lxivdnD5bTAVPVGBVnmfnHiqTpLWe3+TsHN2Eq Fxzg== X-Gm-Message-State: AOJu0YwA0fHurVBJvWqywiZ9lYjcGc1RbgmD+AUY555iDZDQH0CJd2/+ 1NMcZVe1JEEHAnxwz/1Smfw= X-Google-Smtp-Source: AGHT+IElr8isCQxA77cREJ8dEkc1vgGlgie+whLG6+nuVdHqPbgUppOA/S2iuV/DdyjLs1cV1u9bNA== X-Received: by 2002:adf:fd10:0:b0:317:69d2:35be with SMTP id e16-20020adffd10000000b0031769d235bemr10430834wrr.30.1696262141860; Mon, 02 Oct 2023 08:55:41 -0700 (PDT) Received: from localhost (fwdproxy-cln-017.fbsv.net. [2a03:2880:31ff:11::face:b00c]) by smtp.gmail.com with ESMTPSA id ec20-20020a0564020d5400b005346a263bb1sm9430244edb.63.2023.10.02.08.55.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 08:55:41 -0700 (PDT) From: Breno Leitao To: jlbec@evilplan.org, kuba@kernel.org, davem@davemloft.net, pabeni@redhat.com, Eric Dumazet , Jonathan Corbet Cc: hch@lst.de, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, horms@kernel.org, linux-doc@vger.kernel.org (open list:DOCUMENTATION) Subject: [PATCH 3/3] Documentation: netconsole: add support for cmdline targets Date: Mon, 2 Oct 2023 08:53:49 -0700 Message-Id: <20231002155349.2032826-4-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> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net X-Patchwork-Delegate: kuba@kernel.org With the previous patches, there is no more limitation at modifying the targets created at boot time (or module load time). Document the way on how to create the configfs directories to be able to modify these netconsole targets. The design discussion about this topic could be found at: https://lore.kernel.org/all/ZRWRal5bW93px4km@gmail.com/ Signed-off-by: Breno Leitao --- Documentation/networking/netconsole.rst | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/Documentation/networking/netconsole.rst b/Documentation/networking/netconsole.rst index 7a9de0568e84..b25c89608e50 100644 --- a/Documentation/networking/netconsole.rst +++ b/Documentation/networking/netconsole.rst @@ -99,9 +99,6 @@ Dynamic reconfiguration: Dynamic reconfigurability is a useful addition to netconsole that enables remote logging targets to be dynamically added, removed, or have their parameters reconfigured at runtime from a configfs-based userspace interface. -[ Note that the parameters of netconsole targets that were specified/created -from the boot/module option are not exposed via this interface, and hence -cannot be modified dynamically. ] To include this feature, select CONFIG_NETCONSOLE_DYNAMIC when building the netconsole module (or kernel, if netconsole is built-in). @@ -155,6 +152,24 @@ You can also update the local interface dynamically. This is especially useful if you want to use interfaces that have newly come up (and may not have existed when netconsole was loaded / initialized). +You can control and modify the targets defined at boot time (or module load +time) by creating special targets names. These special targets are named +`cmdline` concatenated to an integer, example: `cmdline0`. + +Let's suppose you have two netconsole targets defined at boot time:: + + netconsole=4444@10.0.0.1/eth1,9353@10.0.0.2/12:34:56:78:9a:bc;4444@10.0.0.1/eth1,9353@10.0.0.3/12:34:56:78:9a:bc + +You can modify these targets in runtime by creating the following targets:: + + mkdir cmdline0 + cat cmdline0/remote_ip + 10.0.0.2 + + mkdir cmdline1 + cat cmdline1/remote_ip + 10.0.0.3 + Extended console: =================