Message ID | 20230801100533.3350037-1-leitao@debian.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:918b:0:b0:3e4:2afc:c1 with SMTP id s11csp2578520vqg; Tue, 1 Aug 2023 03:43:17 -0700 (PDT) X-Google-Smtp-Source: APBJJlGDtgI4MoRd+Frk+Zzllx9K47DyGbFqdXtAuB4mGWZYOjHsU+ELznnJgY/O+IwlzXdzd7+R X-Received: by 2002:a05:6870:471f:b0:1b0:60ff:b73f with SMTP id b31-20020a056870471f00b001b060ffb73fmr13611587oaq.8.1690886597532; Tue, 01 Aug 2023 03:43:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1690886597; cv=none; d=google.com; s=arc-20160816; b=KSXvDZrfE/fGPlVUVx/DZAsDZygOKonchSx3mnnf968YbQCosleAMmnPXFvIhSE7rQ ujafzh9I4A6WuTrLUdZULsXe5bR8rkkuXtedmdPvnQQB6ZD1jK5G8HMovNqjr/5F6QLM +vcvAqitDVXOCMPux4/beZgJj7vVldO9j0shoAnqSdS1zUQqfqBiLKZfX+ShgXkE2fXc j45k5TX6Q+UhMnD54i5yceUVPWdiz8/OlbCHTI0VsJYsmJZkRUyhWMZ74ySBd0KMczcn af32/JoeJeS/BaSSSC0AmkGhC8q7eADi3aIblHtokFMvrKVPCcaJhSVaCkAsObQreMhQ 9Skg== 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 :message-id:date:subject:cc:to:from; bh=kKJch/Gc+6Pg2T8wuibMxmyZDdXQuXrYO2iuSwSbYeo=; fh=Rzo9bn7JAQZ4SUrEpm3Wz0VAADuc1Lmj2PEe+zeCulw=; b=oPPFDSGNqdjqTRY5TDn7hkg5M1JWN+s0pYjCT0y8j2j1yoF/vHozxVX8/2ldhCp0PC ta/f/LsU4pjju51V8y9Pf0matsJX+gUKMjs4pkNei8GG9MQ/GH+yt8CSuMGtqr2S+DbE Dq4SgGkQIGy75/jP1hGg7kwMqp09G57ISHC0pNFFLfnHIeZ3DvO6/JtMxQrE5WGRdK5D 8XejZN4NXlJobdHx0X4SnecpEQFa8c64Kt6HiytnJaUIJVPUoh4wpW+QwPUy52PrMSfx 84jQcur/5jtjk7ClzOUJZNMKIXkxLNbhVuc56mvsZhzrVEiN4GSuuHADeGkBsbFHgxHL XfLA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v185-20020a6389c2000000b0053eef60f940si8796096pgd.765.2023.08.01.03.43.04; Tue, 01 Aug 2023 03:43:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232427AbjHAKGx (ORCPT <rfc822;maxi.paulin@gmail.com> + 99 others); Tue, 1 Aug 2023 06:06:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233780AbjHAKGp (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 1 Aug 2023 06:06:45 -0400 Received: from mail-ed1-f47.google.com (mail-ed1-f47.google.com [209.85.208.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 522A510B; Tue, 1 Aug 2023 03:06:42 -0700 (PDT) Received: by mail-ed1-f47.google.com with SMTP id 4fb4d7f45d1cf-52222562f1eso8073818a12.3; Tue, 01 Aug 2023 03:06:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690884401; x=1691489201; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kKJch/Gc+6Pg2T8wuibMxmyZDdXQuXrYO2iuSwSbYeo=; b=k74oqOrjVWqB6iXCQ44//yN6aoHmP0eYIJPuEw9oAYvngOTjZsdMCBhZNhr91WiI7U ygj3qNicpAs2D0WoNs1oSiX92LdPKE/PuVORhD6o96l/fDvSsPX94fnxtD6ubbbfNyn1 iV9Iutm6jkqXSAoqeD0K1C8+d401YeCRssbYfbg0vzJ6cA0zZhAqIih6QJyKUm9PRmLL iaBKrwFRLQj5EOoYsC1+TB4/W9CjqRDA1yW3GuMwg6mhiRPGJqMFcv8ssaeJ7rJ65tAG W5oPk2WlDukNCNE3SsbmUpbtgNltBrhXiqrnHfWYp5gFvaA1ffl+RNoDzcuE21QSaJVB DiIw== X-Gm-Message-State: ABy/qLaXEHS6FsuTy7kiJRqmTvcUteOFuhNRjtAjpj4eM7rYwItqR3h8 txXf6rVbdI2/w6OH013aJ4Q= X-Received: by 2002:a17:907:78d8:b0:99b:d068:9504 with SMTP id kv24-20020a17090778d800b0099bd0689504mr2141316ejc.2.1690884400524; Tue, 01 Aug 2023 03:06:40 -0700 (PDT) Received: from localhost (fwdproxy-cln-016.fbsv.net. [2a03:2880:31ff:10::face:b00c]) by smtp.gmail.com with ESMTPSA id pk15-20020a170906d7af00b0099bd6026f45sm7387545ejb.198.2023.08.01.03.06.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 01 Aug 2023 03:06:40 -0700 (PDT) From: Breno Leitao <leitao@debian.org> To: rdunlap@infradead.org, benjamin.poirier@gmail.com, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com> Cc: leit@meta.com, netdev@vger.kernel.org (open list:NETWORKING DRIVERS), linux-kernel@vger.kernel.org (open list) Subject: [PATCH net-next v3] netconsole: Enable compile time configuration Date: Tue, 1 Aug 2023 03:05:32 -0700 Message-Id: <20230801100533.3350037-1-leitao@debian.org> X-Mailer: git-send-email 2.34.1 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,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773023104786957124 X-GMAIL-MSGID: 1773023104786957124 |
Series |
[net-next,v3] netconsole: Enable compile time configuration
|
|
Commit Message
Breno Leitao
Aug. 1, 2023, 10:05 a.m. UTC
Enable netconsole features to be set at compilation time. Create two
Kconfig options that allow users to set extended logs and release
prepending features at compilation time.
Right now, the user needs to pass command line parameters to netconsole,
such as "+"/"r" to enable extended logs and version prepending features.
With these two options, the user could set the default values for the
features at compile time, and don't need to pass it in the command line
to get them enabled, simplifying the command line.
Signed-off-by: Breno Leitao <leitao@debian.org>
---
v1 -> v2:
* Improvements in the Kconfig help section.
v2 -> v3:
* Honour the Kconfig settings when creating sysfs targets
* Add "by default" in a Kconfig help.
---
drivers/net/Kconfig | 22 ++++++++++++++++++++++
drivers/net/netconsole.c | 10 ++++++++++
2 files changed, 32 insertions(+)
Comments
On Tue, Aug 1, 2023 at 12:06 PM Breno Leitao <leitao@debian.org> wrote: > > Enable netconsole features to be set at compilation time. Create two > Kconfig options that allow users to set extended logs and release > prepending features at compilation time. > > Right now, the user needs to pass command line parameters to netconsole, > such as "+"/"r" to enable extended logs and version prepending features. > > With these two options, the user could set the default values for the > features at compile time, and don't need to pass it in the command line > to get them enabled, simplifying the command line. > > Signed-off-by: Breno Leitao <leitao@debian.org> > --- > v1 -> v2: > * Improvements in the Kconfig help section. > v2 -> v3: > * Honour the Kconfig settings when creating sysfs targets > * Add "by default" in a Kconfig help. > --- > drivers/net/Kconfig | 22 ++++++++++++++++++++++ > drivers/net/netconsole.c | 10 ++++++++++ > 2 files changed, 32 insertions(+) > > diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig > index 368c6f5b327e..55fb9509bcae 100644 > --- a/drivers/net/Kconfig > +++ b/drivers/net/Kconfig > @@ -332,6 +332,28 @@ config NETCONSOLE_DYNAMIC > at runtime through a userspace interface exported using configfs. > See <file:Documentation/networking/netconsole.rst> for details. > > +config NETCONSOLE_EXTENDED_LOG > + bool "Set kernel extended message by default" > + depends on NETCONSOLE > + default n > + help > + Set extended log support for netconsole message. If this option is > + set, log messages are transmitted with extended metadata header in a > + format similar to /dev/kmsg. See > + <file:Documentation/networking/netconsole.rst> for details. > + > +config NETCONSOLE_PREPEND_RELEASE > + bool "Prepend kernel release version in the message by default" > + depends on NETCONSOLE_EXTENDED_LOG > + default n > + help > + Set kernel release to be prepended to each netconsole message by > + default. If this option is set, the kernel release is prepended into > + the first field of every netconsole message, so, the netconsole > + server/peer can easily identify what kernel release is logging each > + message. See <file:Documentation/networking/netconsole.rst> for > + details. > + > config NETPOLL > def_bool NETCONSOLE > > diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c > index 87f18aedd3bd..e3b6155f4529 100644 > --- a/drivers/net/netconsole.c > +++ b/drivers/net/netconsole.c > @@ -181,6 +181,11 @@ static struct netconsole_target *alloc_param_target(char *target_config) > if (!nt) > goto fail; > > + if (IS_ENABLED(CONFIG_NETCONSOLE_EXTENDED_LOG)) > + nt->extended = true; > + if (IS_ENABLED(CONFIG_NETCONSOLE_PREPEND_RELEASE)) > + nt->release = true; > + > nt->np.name = "netconsole"; > strscpy(nt->np.dev_name, "eth0", IFNAMSIZ); > nt->np.local_port = 6665; > @@ -681,6 +686,11 @@ static struct config_item *make_netconsole_target(struct config_group *group, > nt->np.remote_port = 6666; > eth_broadcast_addr(nt->np.remote_mac); > > + if (IS_ENABLED(CONFIG_NETCONSOLE_EXTENDED_LOG)) > + nt->extended = true; > + if (IS_ENABLED(CONFIG_NETCONSOLE_PREPEND_RELEASE)) > + nt->release = true; > + Instead of duplicating these, what about adding a preliminary helper in a separate patch ? Something like this: drivers/net/netconsole.c | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 87f18aedd3bd7b3da9d2481dc9898e94dd75917b..a022ceaa2e3c4783ca0ea61c1c7b9f911d087abc 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -167,26 +167,32 @@ static void netconsole_target_put(struct netconsole_target *nt) #endif /* CONFIG_NETCONSOLE_DYNAMIC */ +/* + * Allocate and initialize with defaults. + * Note that these targets get their config_item fields zeroed-out. + */ +static struct netconsole_target *alloc_and_init(void) +{ + struct netconsole_target *nt = kzalloc(sizeof(*nt), GFP_KERNEL); + + if (nt) { + nt->np.name = "netconsole"; + strscpy(nt->np.dev_name, "eth0", IFNAMSIZ); + nt->np.local_port = 6665; + nt->np.remote_port = 6666; + eth_broadcast_addr(nt->np.remote_mac); + } + return nt; +} + /* Allocate new target (from boot/module param) and setup netpoll for it */ static struct netconsole_target *alloc_param_target(char *target_config) { + struct netconsole_target *nt = alloc_and_init(); int err = -ENOMEM; - struct netconsole_target *nt; - /* - * Allocate and initialize with defaults. - * Note that these targets get their config_item fields zeroed-out. - */ - nt = kzalloc(sizeof(*nt), GFP_KERNEL); if (!nt) goto fail; - - nt->np.name = "netconsole"; - strscpy(nt->np.dev_name, "eth0", IFNAMSIZ); - nt->np.local_port = 6665; - nt->np.remote_port = 6666; - eth_broadcast_addr(nt->np.remote_mac); - if (*target_config == '+') { nt->extended = true; target_config++; @@ -664,23 +670,12 @@ static const struct config_item_type netconsole_target_type = { static struct config_item *make_netconsole_target(struct config_group *group, const char *name) { + struct netconsole_target *nt = alloc_and_init(); unsigned long flags; - struct netconsole_target *nt; - /* - * Allocate and initialize with defaults. - * Target is disabled at creation (!enabled). - */ - nt = kzalloc(sizeof(*nt), GFP_KERNEL); if (!nt) return ERR_PTR(-ENOMEM); - nt->np.name = "netconsole"; - strscpy(nt->np.dev_name, "eth0", IFNAMSIZ); - nt->np.local_port = 6665; - nt->np.remote_port = 6666; - eth_broadcast_addr(nt->np.remote_mac); - /* Initialize the config_item member */ config_item_init_type_name(&nt->item, name, &netconsole_target_type);
On Thu, Aug 03, 2023 at 09:47:43AM +0200, Eric Dumazet wrote: > On Tue, Aug 1, 2023 at 12:06 PM Breno Leitao <leitao@debian.org> wrote: > > > > Enable netconsole features to be set at compilation time. Create two > > Kconfig options that allow users to set extended logs and release > > prepending features at compilation time. > > > > Right now, the user needs to pass command line parameters to netconsole, > > such as "+"/"r" to enable extended logs and version prepending features. > > > > With these two options, the user could set the default values for the > > features at compile time, and don't need to pass it in the command line > > to get them enabled, simplifying the command line. > > > > Signed-off-by: Breno Leitao <leitao@debian.org> > > --- > > v1 -> v2: > > * Improvements in the Kconfig help section. > > v2 -> v3: > > * Honour the Kconfig settings when creating sysfs targets > > * Add "by default" in a Kconfig help. > > --- > > drivers/net/Kconfig | 22 ++++++++++++++++++++++ > > drivers/net/netconsole.c | 10 ++++++++++ > > 2 files changed, 32 insertions(+) > > > > diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig > > index 368c6f5b327e..55fb9509bcae 100644 > > --- a/drivers/net/Kconfig > > +++ b/drivers/net/Kconfig > > @@ -332,6 +332,28 @@ config NETCONSOLE_DYNAMIC > > at runtime through a userspace interface exported using configfs. > > See <file:Documentation/networking/netconsole.rst> for details. > > > > +config NETCONSOLE_EXTENDED_LOG > > + bool "Set kernel extended message by default" > > + depends on NETCONSOLE > > + default n > > + help > > + Set extended log support for netconsole message. If this option is > > + set, log messages are transmitted with extended metadata header in a > > + format similar to /dev/kmsg. See > > + <file:Documentation/networking/netconsole.rst> for details. > > + > > +config NETCONSOLE_PREPEND_RELEASE > > + bool "Prepend kernel release version in the message by default" > > + depends on NETCONSOLE_EXTENDED_LOG > > + default n > > + help > > + Set kernel release to be prepended to each netconsole message by > > + default. If this option is set, the kernel release is prepended into > > + the first field of every netconsole message, so, the netconsole > > + server/peer can easily identify what kernel release is logging each > > + message. See <file:Documentation/networking/netconsole.rst> for > > + details. > > + > > config NETPOLL > > def_bool NETCONSOLE > > > > diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c > > index 87f18aedd3bd..e3b6155f4529 100644 > > --- a/drivers/net/netconsole.c > > +++ b/drivers/net/netconsole.c > > @@ -181,6 +181,11 @@ static struct netconsole_target *alloc_param_target(char *target_config) > > if (!nt) > > goto fail; > > > > + if (IS_ENABLED(CONFIG_NETCONSOLE_EXTENDED_LOG)) > > + nt->extended = true; > > + if (IS_ENABLED(CONFIG_NETCONSOLE_PREPEND_RELEASE)) > > + nt->release = true; > > + > > nt->np.name = "netconsole"; > > strscpy(nt->np.dev_name, "eth0", IFNAMSIZ); > > nt->np.local_port = 6665; > > @@ -681,6 +686,11 @@ static struct config_item *make_netconsole_target(struct config_group *group, > > nt->np.remote_port = 6666; > > eth_broadcast_addr(nt->np.remote_mac); > > > > + if (IS_ENABLED(CONFIG_NETCONSOLE_EXTENDED_LOG)) > > + nt->extended = true; > > + if (IS_ENABLED(CONFIG_NETCONSOLE_PREPEND_RELEASE)) > > + nt->release = true; > > + > > Instead of duplicating these, what about adding a preliminary helper > in a separate patch ? That is a good idea, I will update. Thanks!
diff --git a/drivers/net/Kconfig b/drivers/net/Kconfig index 368c6f5b327e..55fb9509bcae 100644 --- a/drivers/net/Kconfig +++ b/drivers/net/Kconfig @@ -332,6 +332,28 @@ config NETCONSOLE_DYNAMIC at runtime through a userspace interface exported using configfs. See <file:Documentation/networking/netconsole.rst> for details. +config NETCONSOLE_EXTENDED_LOG + bool "Set kernel extended message by default" + depends on NETCONSOLE + default n + help + Set extended log support for netconsole message. If this option is + set, log messages are transmitted with extended metadata header in a + format similar to /dev/kmsg. See + <file:Documentation/networking/netconsole.rst> for details. + +config NETCONSOLE_PREPEND_RELEASE + bool "Prepend kernel release version in the message by default" + depends on NETCONSOLE_EXTENDED_LOG + default n + help + Set kernel release to be prepended to each netconsole message by + default. If this option is set, the kernel release is prepended into + the first field of every netconsole message, so, the netconsole + server/peer can easily identify what kernel release is logging each + message. See <file:Documentation/networking/netconsole.rst> for + details. + config NETPOLL def_bool NETCONSOLE diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c index 87f18aedd3bd..e3b6155f4529 100644 --- a/drivers/net/netconsole.c +++ b/drivers/net/netconsole.c @@ -181,6 +181,11 @@ static struct netconsole_target *alloc_param_target(char *target_config) if (!nt) goto fail; + if (IS_ENABLED(CONFIG_NETCONSOLE_EXTENDED_LOG)) + nt->extended = true; + if (IS_ENABLED(CONFIG_NETCONSOLE_PREPEND_RELEASE)) + nt->release = true; + nt->np.name = "netconsole"; strscpy(nt->np.dev_name, "eth0", IFNAMSIZ); nt->np.local_port = 6665; @@ -681,6 +686,11 @@ static struct config_item *make_netconsole_target(struct config_group *group, nt->np.remote_port = 6666; eth_broadcast_addr(nt->np.remote_mac); + if (IS_ENABLED(CONFIG_NETCONSOLE_EXTENDED_LOG)) + nt->extended = true; + if (IS_ENABLED(CONFIG_NETCONSOLE_PREPEND_RELEASE)) + nt->release = true; + /* Initialize the config_item member */ config_item_init_type_name(&nt->item, name, &netconsole_target_type);