iwd.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
From: James Prestwood <prestwoj@gmail.com>
To: Andrea Pappacoda <andrea@pappacoda.it>
Cc: iwd@lists.linux.dev
Subject: Re: MulticastDNS for all connections
Date: Wed, 02 Nov 2022 13:47:57 -0700	[thread overview]
Message-ID: <c1a5ac7f3d1efb63c66218c147d6188e3e8ebc51.camel@gmail.com> (raw)
In-Reply-To: <CZLQKR.DUWHOW09XS8D@pappacoda.it>

[-- Attachment #1: Type: text/plain, Size: 2950 bytes --]

On Wed, 2022-11-02 at 21:23 +0100, Andrea Pappacoda wrote:
> Hi James, thanks for your reply :)
> 
> Il giorno mar 1 nov 2022 alle 13:54:36 -07:00:00, James Prestwood 
> <prestwoj@gmail.com> ha scritto:
> > Currently the MulticastDNS option is only per-network, but systemd-
> > resolved has a global setting itself according to the docs [1].
> > 
> > But I actually wonder if event setting MulticastDNS in IWD is doing
> > anything:
> > 
> > "Multicast DNS will be enabled on a link only if the per-link and
> > the
> > global setting is on."
> > 
> > This would imply you need to set /etc/systemd/resolved.conf with
> > MulticastDNS=true to even use mDNS at all? Or maybe you have
> > already
> > done this? And I see the problem, per-link settings are only in
> > systemd-networkd, which you don't use...
> 
> Yes, MulticastDNS needs to be enabled globally in resolved.conf (it
> is 
> enabled by default) and also be enabled by whoever is managing the 
> network interface.
> 
> Enabling mDNS in specific networks by adding MulticastDNS=true in 
> /var/lib/iwd/network-name works as expected.
> 
> > Like I said, I don't know much about mDNS but would a global option
> > 'break' networks which don't support mDNS? Are you frequently
> > connecting to many networks and needed to add this option to the
> > profile each time?
> 
> I used to have mDNS globally enabled in NetworkManager, and it never 
> created issues. As far as I understand, enabling mDNS simply allows
> you 
> do to Multicast DNS queries on that network; it shouldn't interfere 
> with non-multicast queries. I use mDNS every once in a while (on
> three 
> different networks since last week), so I'd like to simply enable the
> global setting and forget about it.
> 
> > The fact that this depends on setting systemd-resolved's global
> > option
> > and the per-link option I would say this really should stay in 
> > systemd-
> > * itself. The IWD setting is kinda useless without the global
> > option
> > anyways. Plus systemd-networkd is much more flexible, you can match
> > based on all kinds of things where IWD is very rigid (global or
> > per-
> > network).
> 
> iwd has an option that enables it to replace other network managers
> for 
> simple use cases, EnableNetworkConfiguration=true, so it seems 
> reasonable for somebody to not have any other connection manager 
> installed, and for those use cases I'd say that iwd's coarseness is 
> fine. I've applied a quick and dirty patch on top of version 1.30,
> and 
> it seems to work without issues; mdns_global probably leaks, but this
> can't be applied on master anyway and I was just trying to figure out
> how easy it would be to add this feature.
> 

I've attached a patch if you want to try it out. I quickly tested only
that "resolvectl status" showed +mDNS or -mDNS depending on what it was
set to. In actuality this is probably enough since all we do is set the
value to systemd and let it handle it.


[-- Attachment #2: 0001-netconfig-add-global-MulticastDNS-option.patch --]
[-- Type: text/x-patch, Size: 2027 bytes --]

From 67ca889a3075f59b03f857e2ae548a21e7738349 Mon Sep 17 00:00:00 2001
From: James Prestwood <prestwoj@gmail.com>
Date: Wed, 2 Nov 2022 13:35:53 -0700
Subject: [PATCH] netconfig: add global MulticastDNS option

Adds the MulticastDNS option globally to main.conf. If set all
network connections (when netconfig is enabled) will set mDNS
support into the resolver. Note that an individual network profile
can still override the global value if it sets MulticastDNS.
---
 src/netconfig.c | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/src/netconfig.c b/src/netconfig.c
index e6779d7c..8b798e0b 100644
--- a/src/netconfig.c
+++ b/src/netconfig.c
@@ -56,6 +56,7 @@
  */
 static uint32_t ROUTE_PRIORITY_OFFSET;
 static bool ipv6_enabled;
+static char *mdns_global;
 
 static void do_debug(const char *str, void *user_data)
 {
@@ -396,13 +397,16 @@ send_hostname:
 	}
 
 mdns:
-	if (l_settings_has_key(active_settings, "Network", "MulticastDNS") &&
-			!(mdns = l_settings_get_string(active_settings,
-							"Network",
-							"MulticastDNS"))) {
-		l_error("netconfig: Can't load Network.MulticastDNS");
-		success = false;
-	}
+	/* If the networks has this set take that over the global */
+	if (l_settings_has_key(active_settings, "Network", "MulticastDNS")) {
+		mdns = l_settings_get_string(active_settings, "Network",
+							"MulticastDNS");
+		if (!mdns) {
+			l_error("netconfig: Can't load Network.MulticastDNS");
+			success = false;
+		}
+	} else if (mdns_global)
+		mdns = l_strdup(mdns_global);
 
 	if (mdns && !L_IN_STRSET(mdns, "true", "false", "resolve")) {
 		l_error("netconfig: Bad Network.MulticastDNS value '%s'", mdns);
@@ -753,11 +757,15 @@ static int netconfig_init(void)
 					&ipv6_enabled))
 		ipv6_enabled = false;
 
+	mdns_global = l_settings_get_string(iwd_get_config(), "Network",
+						"MulticastDNS");
+
 	return 0;
 }
 
 static void netconfig_exit(void)
 {
+	l_free(mdns_global);
 }
 
 IWD_MODULE(netconfig, netconfig_init, netconfig_exit)
-- 
2.34.3


  reply	other threads:[~2022-11-02 20:47 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-29 15:16 MulticastDNS for all connections Andrea Pappacoda
2022-11-01 20:54 ` James Prestwood
2022-11-02 20:23   ` Andrea Pappacoda
2022-11-02 20:47     ` James Prestwood [this message]
2022-11-02 21:55       ` Andrea Pappacoda
2022-11-02 22:06         ` 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=c1a5ac7f3d1efb63c66218c147d6188e3e8ebc51.camel@gmail.com \
    --to=prestwoj@gmail.com \
    --cc=andrea@pappacoda.it \
    --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;
as well as URLs for NNTP newsgroup(s).