public inbox for iwd@lists.linux.dev
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: Bryce Johnson <bryce@redpinelabs.com>, iwd@lists.linux.dev
Subject: Re: [RFC] netconfig: Global option to send hostname with dhcp request for all networks
Date: Fri, 28 Feb 2025 05:58:26 -0800	[thread overview]
Message-ID: <2c244463-921e-42bc-8618-aea86e28d075@gmail.com> (raw)
In-Reply-To: <CADXxVS+UQfrbWFfsDnW1QvkpvmEnkxMdv+OPBy=XpPXEFdcU8Q@mail.gmail.com>

Hi Bryce,

On 2/27/25 1:42 PM, Bryce Johnson wrote:
> Add global option to send hostname with dhcp always with
> [IPv4].SendHostnameAlways so the first DHCP request will include the
> hostname on first connection and don't need to modify the .psk files
> to add SendHostname after they are created.
>
> ---
> diff --git a/src/iwd.config.rst b/src/iwd.config.rst
> index 4ba7b4e7..4f473e07 100644
> --- a/src/iwd.config.rst
> +++ b/src/iwd.config.rst
> @@ -429,6 +429,11 @@ The group ``[IPv4]`` contains settings related to
> IPv4 network configuration.
>          will limit the number of access points that can be running
>          simultaneously on different interfaces.
>
> +   * - SendHostnameAlways
> +     - Values: true, **false**
> +
> +       Always send the hostname in the DHCP request for all networks.
NIT: You could probably just shorten this to "SendHostname". I 
personally don't mind if settings have the same name between main.conf 
and network profiles.
> +
>   DriverQuirks
>   ------------
>
> diff --git a/src/netconfig.c b/src/netconfig.c
> index cd19217c..5959a5ac 100644
> --- a/src/netconfig.c
> +++ b/src/netconfig.c
> @@ -375,7 +375,9 @@ gateway:
>      }
>
>   send_hostname:
> -   if (l_settings_has_key(active_settings, "IPv4", "SendHostname") &&
> +   l_settings_get_bool(iwd_get_config(), "IPv4",
> "SendHostnameAlways", &send_hostname);
> +
> +   if (!send_hostname && l_settings_has_key(active_settings, "IPv4",
> "SendHostname") &&
>              !l_settings_get_bool(active_settings, "IPv4",
>                          "SendHostname",
>                          &send_hostname)) {
> @@ -391,13 +393,20 @@ send_hostname:
>          goto mdns;
>      }
>
> -   if (send_hostname &&
> -           !l_netconfig_set_hostname(netconfig->nc, hostname)) {
> -       l_error("netconfig: l_netconfig_set_hostname() failed");
> -       success = false;
> -       goto mdns;
> +   if (send_hostname) {
> +       if (!l_netconfig_set_hostname(netconfig->nc, hostname)) {
> +           l_error("netconfig: l_netconfig_set_hostname() failed");
> +           success = false;
> +       } else {
> +           l_debug("netconfig: Hostname '%s' will be sent in DHCP
> requests", hostname);
> +       }
> +   } else {
> +       l_debug("netconfig: No hostname will be sent in DHCP requests");
It probably seemed consistent, but l_error() actually doesn't include 
the file/function which is why those all have "netconfig:" in them. For 
debug prints we actually don't need to prefix with "netconfig:" since it 
will always include the file and function name.
>      }
>
> +   goto mdns;
> +
> +
>   mdns:
>      /* If the networks has this set take that over the global */
>      if (l_settings_has_key(active_settings, "Network", "MulticastDNS")) {
>
Thanks,

James


  reply	other threads:[~2025-02-28 13:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-27 21:42 [RFC] netconfig: Global option to send hostname with dhcp request for all networks Bryce Johnson
2025-02-28 13:58 ` James Prestwood [this message]
2025-02-28 15:21   ` Bryce Johnson
2025-02-28 15:43     ` James Prestwood

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2c244463-921e-42bc-8618-aea86e28d075@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=bryce@redpinelabs.com \
    --cc=iwd@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox