iwd.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* MulticastDNS for all connections
@ 2022-10-29 15:16 Andrea Pappacoda
  2022-11-01 20:54 ` James Prestwood
  0 siblings, 1 reply; 6+ messages in thread
From: Andrea Pappacoda @ 2022-10-29 15:16 UTC (permalink / raw)
  To: iwd

Hi all!

I have a question regarding the usage of iwd, specifically about the 
MulticastDNS option. Is it possible to enable it for all the networks?

The iwd.network(5) manual page mentions that one can enable 
MulticastDNS for a particular network, but it also says that "The group 
[Network] contains general network settings and any network specific 
overrides for global defaults defined in the main iwd configuration 
file.". Unfortunately though, setting MulticastDNS=true in 
/etc/iwd/main.conf does not lead to my desired result.

I'm not using neither systemd-networkd, ConnMan nor NetworkManager.

If this is not the most appropriate place where to discuss about 
feature requests, feel free to redirect me to the right place :)

Thanks!



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: MulticastDNS for all connections
  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
  0 siblings, 1 reply; 6+ messages in thread
From: James Prestwood @ 2022-11-01 20:54 UTC (permalink / raw)
  To: Andrea Pappacoda, iwd

On Sat, 2022-10-29 at 17:16 +0200, Andrea Pappacoda wrote:
> Hi all!
> 
> I have a question regarding the usage of iwd, specifically about the 
> MulticastDNS option. Is it possible to enable it for all the
> networks?
> 
> The iwd.network(5) manual page mentions that one can enable 
> MulticastDNS for a particular network, but it also says that "The
> group 
> [Network] contains general network settings and any network specific 
> overrides for global defaults defined in the main iwd configuration 
> file.". Unfortunately though, setting MulticastDNS=true in 
> /etc/iwd/main.conf does not lead to my desired result.
> 
> I'm not using neither systemd-networkd, ConnMan nor NetworkManager.
> 
> If this is not the most appropriate place where to discuss about 
> feature requests, feel free to redirect me to the right place :)
> 
> Thanks!

First, I don't know much about mDNS :) but anyways...

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...

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?

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).

[1] https://www.freedesktop.org/software/systemd/man/resolved.conf.html
> 
> 
> 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: MulticastDNS for all connections
  2022-11-01 20:54 ` James Prestwood
@ 2022-11-02 20:23   ` Andrea Pappacoda
  2022-11-02 20:47     ` James Prestwood
  0 siblings, 1 reply; 6+ messages in thread
From: Andrea Pappacoda @ 2022-11-02 20:23 UTC (permalink / raw)
  To: James Prestwood; +Cc: iwd

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.

diff --git a/src/netconfig.c b/src/netconfig.c
index 4a70b0ca..3e3c36a9 100644
--- a/src/netconfig.c
+++ b/src/netconfig.c
@@ -95,6 +95,7 @@ static struct l_queue *netconfig_list;
  */
 static uint32_t ROUTE_PRIORITY_OFFSET;
 static bool ipv6_enabled;
+static char* mdns_global;

 static void do_debug(const char *str, void *user_data)
 {
@@ -1432,6 +1433,11 @@ bool netconfig_load_settings(struct netconfig 
*netconfig,

 	mdns = l_settings_get_string(active_settings,
 					"Network", "MulticastDNS");
+	if (!mdns) {
+		const size_t mdns_global_size = strlen(mdns_global) + 1;
+		mdns = malloc(mdns_global_size);
+		memcpy(mdns, mdns_global, mdns_global_size);
+	}

 	if (l_settings_has_key(active_settings, "IPv4", "Address")) {
 		v4_address = netconfig_get_static4_address(active_settings);
@@ -1757,6 +1763,8 @@ static int netconfig_init(void)
 					&ipv6_enabled))
 		ipv6_enabled = false;

+	mdns_global = l_settings_get_string(iwd_get_config(), "Network", 
"MulticastDNS");
+
 	netconfig_list = l_queue_new();

 	return 0;



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: MulticastDNS for all connections
  2022-11-02 20:23   ` Andrea Pappacoda
@ 2022-11-02 20:47     ` James Prestwood
  2022-11-02 21:55       ` Andrea Pappacoda
  0 siblings, 1 reply; 6+ messages in thread
From: James Prestwood @ 2022-11-02 20:47 UTC (permalink / raw)
  To: Andrea Pappacoda; +Cc: iwd

[-- 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: MulticastDNS for all connections
  2022-11-02 20:47     ` James Prestwood
@ 2022-11-02 21:55       ` Andrea Pappacoda
  2022-11-02 22:06         ` James Prestwood
  0 siblings, 1 reply; 6+ messages in thread
From: Andrea Pappacoda @ 2022-11-02 21:55 UTC (permalink / raw)
  To: James Prestwood; +Cc: iwd

Il giorno mer 2 nov 2022 alle 13:47:57 -07:00:00, James Prestwood 
<prestwoj@gmail.com> ha scritto:
> 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.

Thanks James, I can confirm that this works for me too.

I'll be using this patch locally for the time being, but it would be 
great to get this merged; I can update the documentation too and submit 
everything as a patch to the mailing list if you want (of course, you 
could do this yourself if you prefer) :)

Thanks again!



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: MulticastDNS for all connections
  2022-11-02 21:55       ` Andrea Pappacoda
@ 2022-11-02 22:06         ` James Prestwood
  0 siblings, 0 replies; 6+ messages in thread
From: James Prestwood @ 2022-11-02 22:06 UTC (permalink / raw)
  To: Andrea Pappacoda; +Cc: iwd

On Wed, 2022-11-02 at 22:55 +0100, Andrea Pappacoda wrote:
> Il giorno mer 2 nov 2022 alle 13:47:57 -07:00:00, James Prestwood 
> <prestwoj@gmail.com> ha scritto:
> > 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.
> 
> Thanks James, I can confirm that this works for me too.
> 
> I'll be using this patch locally for the time being, but it would be 
> great to get this merged; I can update the documentation too and
> submit 
> everything as a patch to the mailing list if you want (of course, you
> could do this yourself if you prefer) :)

I think Denis could merge the patch I attached, if he's ok with it of
course. If you want to do the documentation go for it! If not I'll get
around to it this week.

Thanks,
James

> 
> Thanks again!
> 
> 



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-11-02 22:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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
2022-11-02 21:55       ` Andrea Pappacoda
2022-11-02 22:06         ` James Prestwood

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).