Skip to content

Conversation

enr0n
Copy link
Contributor

@enr0n enr0n commented Oct 4, 2024

/cc @yuwata

Opening this as a draft to get initial comments on the general approach. Is this an acceptable option to add to systemd-networkd-wait-online? And, in the cases where systemd-resolved is active, is checking sd_network_link_get_dns() sufficient?

Proposal:

Add a new flag, --dns, to systemd-networkd-wait-online to allow waiting for DNS to be configured. The --dns flag respects the --ipv4 and --ipv6 flags, as well as --interface= and --any.

When systemd-resolved is running, we check for DNS by checking the link state file (i.e. by calling sd_network_link_get_dns()). When systemd-resolved is not active, we fallback to parsing /etc/resolv.conf.

@bluca
Copy link
Member

bluca commented Oct 4, 2024

I like the idea - do we need to bother with resolv.conf? For the other wait-online we only support networkd, and it's up to other implementations to provide a service that uses the wait-online target, we could just do the same here?

Copy link
Member

@yuwata yuwata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also check that a DNS server is accessible.
E.g. if DNS server 8.8.8.8 is configured, but the interface has only IPv4 link-local address, then we cannot access the server.

Also, please check if resolved already acquired the server. Even if networkd saves DNS servers to the state file, resolved may not read the file yet.

@poettering
Copy link
Member

Hmm, the problem with this approach is that it is racy: afaics you are only subscribing to changes from networkd, but not resolved. Thus, it might happen that networkd gets a valid config, you then check resolved, but it hasn't processed the request yet, and you hence say "not online", and you'll never notice once resolved has caught up.

I think the correct, race-free fix would be if we teach resolved's varlink interface a new call SubscribeDNS() which would be one of those methods that Varlink allows to have multiple replies. It's first reply would be the status qup, and then it would fire an event whenever the manager or per-link DNS server list changes (or search domain list). It would return a complete description of the DNS config, i.e. one object that contains subobjects for the global config and for each link config.

wait-online could then issue that, and simply wait until it gets a non-empty reply.

I think the patch for that wouldn't even be too involved at all.

@enr0n
Copy link
Contributor Author

enr0n commented Oct 7, 2024

Hmm, the problem with this approach is that it is racy: afaics you are only subscribing to changes from networkd, but not resolved. Thus, it might happen that networkd gets a valid config, you then check resolved, but it hasn't processed the request yet, and you hence say "not online", and you'll never notice once resolved has caught up.

My understanding is that when resolved configures/modifies per-link DNS, this does end up recorded in networkd's link state, and hence an event is emitted. Testing locally seems to confirm this, too.

On the other hand, @yuwata did mention above that just because networkd's link state records the DNS server, that does not mean resolved has picked it up yet (e.g. I guess DNS servers issued via DHCP would be reflected in the networkd state immediately).

I think the correct, race-free fix would be if we teach resolved's varlink interface a new call SubscribeDNS() which would be one of those methods that Varlink allows to have multiple replies. It's first reply would be the status qup, and then it would fire an event whenever the manager or per-link DNS server list changes (or search domain list). It would return a complete description of the DNS config, i.e. one object that contains subobjects for the global config and for each link config.

wait-online could then issue that, and simply wait until it gets a non-empty reply.

I think the patch for that wouldn't even be too involved at all.

That does sound like a more concrete approach this. And it's more generic/re-usable. I will work on something to that extent.

Thanks for reviewing!

@enr0n
Copy link
Contributor Author

enr0n commented Oct 7, 2024

Please also check that a DNS server is accessible. E.g. if DNS server 8.8.8.8 is configured, but the interface has only IPv4 link-local address, then we cannot access the server.

Also, please check if resolved already acquired the server. Even if networkd saves DNS servers to the state file, resolved may not read the file yet.

Thanks for reviewing! Both of those points make sense, and I will address them in my next version.

@poettering
Copy link
Member

My understanding is that when resolved configures/modifies per-link DNS, this does end up recorded in networkd's link state, and hence an event is emitted. Testing locally seems to confirm this, too.

It's the other way round: networkd learns DNS from DHCP/IPv6LL and such like and then resolved picks it up from there. But this is asynchronous (it's actually implemented via inotify). resolved might take a bit until it see networkd's changes.

@poettering
Copy link
Member

Please also check that a DNS server is accessible.
E.g. if DNS server 8.8.8.8 is configured, but the interface has only IPv4 link-local address, then we cannot access the server.

Note that this is a really tough problem btw, because routing might make surprising stuff connectible, that the network configuration otherwise suggests wouldn't be allowed. i.e. you could route 8.8.8.8 or some subnet covering it to some ipv4ll host and it would work.

It might be OK'ish as an approximation would be to allocate an UDP socket, then issue connect() towards the DNS server address. This forces a routing decision without actually sending any traffic. This should fail if there are no routes to that host, but succeed if there are. And that's the info you need. You never actually send any traffic over that socket, but immediately close it.

@poettering poettering added resolve reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels Oct 8, 2024
@enr0n
Copy link
Contributor Author

enr0n commented Oct 9, 2024

I pushed a new version with the following changes:

  • I dropped the /etc/resolv.conf fallback. I would rather add something later if there is a stronger need for it.
  • I added io.systemd.Resolve.Monitor.SubscribeDNSConfiguration to make resolved the source of truth.
  • I added logic to check if DNS servers are "accessible" on the interface, using the suggestion above.

A couple things I am not sure of yet:

  • How/when should the global DNS servers be considered for an interface?
  • Related to that, how should FallbackDNS= come in to play?

If we immediately check global DNS when a link does not its own DNS servers yet, and fallback DNS are configured, then we would usually just immediately use fallback to determine if a link is configured. That doesn't feel quite right, but I am not sure.

@enr0n enr0n requested review from poettering and yuwata October 10, 2024 16:32
@github-actions github-actions bot added please-review PR is ready for (re-)review by a maintainer and removed reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks labels Jan 28, 2025
@enr0n
Copy link
Contributor Author

enr0n commented Jan 28, 2025

@yuwata Besides the resolved serialization, I believe I addressed all other comments.

Copy link
Member

@yuwata yuwata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more request. LGTM except for that.

@yuwata yuwata added good-to-merge/with-minor-suggestions and removed please-review PR is ready for (re-)review by a maintainer labels Jan 28, 2025
Copy link
Member

@yuwata yuwata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

@yuwata yuwata added good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed and removed good-to-merge/with-minor-suggestions labels Jan 28, 2025
@bluca
Copy link
Member

bluca commented Jan 28, 2025

This looks related @enr0n can you double check?

[   98.549876] systemd-networkd-tests.py[691]:   File "/usr/lib64/python3.13/subprocess.py", line 508, in check_returncode
[   98.551901] systemd-networkd-tests.py[691]:     raise CalledProcessError(self.returncode, self.args, self.stdout,
[   98.5529[45](https://github.com/systemd/systemd/actions/runs/13002269118/job/36263024103?pr=34640#step:12:46)] systemd-networkd-tests.py[691]:                              self.stderr)
[   98.553440] systemd-networkd-tests.py[691]: subprocess.CalledProcessError: Command '['/usr/lib/systemd/systemd-networkd-wait-online', '--timeout=20s', '--interface=veth99:routable', '--ignore=sit0', '--ignore=ifb1', '--ignore=gre0', '--ignore=ifb0', '--ignore=lo', '--ignore=ip6tnl0', '--ignore=ip_vti0', '--ignore=ip6_vti0', '--ignore=teql0', '--ignore=ip6gre0', '--ignore=tunl0', '--ignore=gretap0', '--ignore=erspan0', '--dns']' returned non-zero exit status 1.
[   98.553822] systemd-networkd-tests.py[691]: During handling of the above exception, another exception occurred:
[   98.554372] systemd-networkd-tests.py[691]: Traceback (most recent call last):
[   98.554753] systemd-networkd-tests.py[691]:   File "/usr/lib/systemd/tests/testdata/test-network/systemd-networkd-tests.py", line 1696, in test_wait_online_dns_global
[   98.555136] systemd-networkd-tests.py[691]:     self.do_test_wait_online_dns(
[   98.555498] systemd-networkd-tests.py[691]:     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
[   98.556420] systemd-networkd-tests.py[691]:         global_dns='192.168.5.1',
[   98.557201] systemd-networkd-tests.py[691]:         ^^^^^^^^^^^^^^^^^^^^^^^^^
[   98.557664] systemd-networkd-tests.py[691]:     ...<3 lines>...
[   98.558110] systemd-networkd-tests.py[691]:         )
[   98.558487] systemd-networkd-tests.py[691]:         ^
[   98.558915] systemd-networkd-tests.py[691]:     )
[   98.560310] systemd-networkd-tests.py[691]:     ^
[   98.560550] systemd-networkd-tests.py[691]:   File "/usr/lib/systemd/tests/testdata/test-network/systemd-networkd-tests.py", line 1680, in do_test_wait_online_dns
[   98.561222] systemd-networkd-tests.py[691]:     self.fail(
[   98.561760] systemd-networkd-tests.py[691]:     ~~~~~~~~~^
[   98.562273] systemd-networkd-tests.py[691]:         f'Command timed out:\n{e.output}'
[   98.563223] systemd-networkd-tests.py[691]:         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[   98.563939] systemd-networkd-tests.py[691]:     )
[   98.565661] systemd-networkd-tests.py[691]:     ^
[   98.566276] systemd-networkd-tests.py[691]: AssertionError: Command timed out:
[   98.566815] systemd-networkd-tests.py[691]: Found link lo(1)
[   98.567342] systemd-networkd-tests.py[691]: Found link gre0(5)
[   98.567937] systemd-networkd-tests.py[691]: Found link gretap0(6)
[   98.568335] systemd-networkd-tests.py[691]: Found link erspan0(7)
[   98.568862] systemd-networkd-tests.py[691]: Found link veth-peer(24)
[   98.569808] systemd-networkd-tests.py[691]: Found link veth99(25)
[   98.570069] systemd-networkd-tests.py[691]: varlink: Setting state idle-client
[   98.570320] systemd-networkd-tests.py[691]: varlink: Sending message: {"method":"io.systemd.Resolve.Monitor.SubscribeDNSConfiguration","parameters":{"allowInteractiveAuthentication":false},"more":true}
[   98.571360] systemd-networkd-tests.py[691]: varlink: Changing state idle-client → awaiting-reply-more
[   98.571583] systemd-networkd-tests.py[691]: veth99: link is being processed by networkd: setup state is configuring.
[   98.571942] systemd-networkd-tests.py[691]: varlink: Received message: {"parameters":{"configuration":[{"currentServer":{"address":[192,168,5,1],"family":2,"port":53,"accessible":true},"servers":[{"address":[192,168,5,1],"family":2,"port":53,"accessible":true}]},{"ifname":"erspan0","ifindex":7,"defaultRoute":false},{"ifname":"gretap0","ifindex":6,"defaultRoute":false},{"ifname":"lo","ifindex":1,"defaultRoute":false},{"ifname":"veth-peer","ifindex":24,"defaultRoute":false},{"ifname":"gre0","ifindex":5,"defaultRoute":false},{"ifname":"veth99","ifindex":25,"defaultRoute":false}]},"continues":true}
[   98.572421] systemd-networkd-tests.py[691]: varlink: Changing state awaiting-reply-more → processing-reply
[   98.572728] systemd-networkd-tests.py[691]: veth99: link is being processed by networkd: setup state is configuring.
[   98.572917] systemd-networkd-tests.py[691]: varlink: Changing state processing-reply → awaiting-reply-more
[   98.573826] systemd-networkd-tests.py[691]: veth99: link is being processed by networkd: setup state is configuring.
[   98.574218] systemd-networkd-tests.py[691]: veth99: link is being processed by networkd: setup state is configuring.
[   98.574457] systemd-networkd-tests.py[691]: veth99: link is configured by networkd and online.
[   98.574745] systemd-networkd-tests.py[691]: varlink: Changing state awaiting-reply-more → disconnected
[   98.574951] systemd-networkd-tests.py[691]: =================================================================
[   98.575850] systemd-networkd-tests.py[691]: ==1299==ERROR: LeakSanitizer: detected memory leaks
[   98.576255] systemd-networkd-tests.py[691]: Direct leak of 5 byte(s) in 1 object(s) allocated from:
[   98.576530] systemd-networkd-tests.py[691]:     #0 0x7f4542ed4d53  (/usr/lib/clang/19/lib/x86_64-redhat-linux-gnu/libclang_rt.asan.so+0xd4d53) (BuildId: 1afad417992f0eb55159b853d8ca03bff039a365)
[   98.577619] systemd-networkd-tests.py[691]:     #1 0x7f45428e2a84  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xae2a84) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.578075] systemd-networkd-tests.py[691]:     #2 0x7f4542914e75  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xb14e75) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.579288] systemd-networkd-tests.py[691]:     #3 0x55d9da6d697e  (/usr/lib/systemd/systemd-networkd-wait-online+0xa97e) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.580138] systemd-networkd-tests.py[691]:     #4 0x55d9da6d705e  (/usr/lib/systemd/systemd-networkd-wait-online+0xb05e) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.580554] systemd-networkd-tests.py[691]:     #5 0x7f4542914e75  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xb14e75) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.581752] systemd-networkd-tests.py[691]:     #6 0x55d9da6d5ec0  (/usr/lib/systemd/systemd-networkd-wait-online+0x9ec0) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.581992] systemd-networkd-tests.py[691]:     #7 0x55d9da6e251f  (/usr/lib/systemd/systemd-networkd-wait-online+0x1651f) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.582993] systemd-networkd-tests.py[691]:     #8 0x7f4542922987  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xb22987) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.583303] systemd-networkd-tests.py[691]:     #9 0x7f454293fc09  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xb3fc09) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.583808] systemd-networkd-tests.py[691]:     #10 0x7f454279c151  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0x99c151) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.584065] systemd-networkd-tests.py[691]:     #11 0x7f454279a500  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0x99a500) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.592601] systemd-networkd-tests.py[691]:     #12 0x7f454279e698  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0x99e698) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.595089] systemd-networkd-tests.py[691]:     #13 0x7f454279ef0d  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0x99ef0d) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.596302] systemd-networkd-tests.py[691]:     #14 0x55d9da6e3b[46](https://github.com/systemd/systemd/actions/runs/13002269118/job/36263024103?pr=34640#step:12:47)  (/usr/lib/systemd/systemd-networkd-wait-online+0x17b46) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.597675] systemd-networkd-tests.py[691]:     #15 0x7f4541c105f4  (/lib64/libc.so.6+0x35f4) (BuildId: be08f175fb99297415ecc80c9ee7a33b56cbd355)
[   98.598375] systemd-networkd-tests.py[691]:     #16 0x7f4541c106a7  (/lib64/libc.so.6+0x36a7) (BuildId: be08f175fb99297415ecc80c9ee7a33b56cbd355)
[   98.598922] systemd-networkd-tests.py[691]:     #17 0x55d9da6d59b4  (/usr/lib/systemd/systemd-networkd-wait-online+0x99b4) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.599437] systemd-networkd-tests.py[691]: Direct leak of 5 byte(s) in 1 object(s) allocated from:
[   98.600881] systemd-networkd-tests.py[691]:     #0 0x7f4542ed4d53  (/usr/lib/clang/19/lib/x86_64-redhat-linux-gnu/libclang_rt.asan.so+0xd4d53) (BuildId: 1afad417992f0eb55159b853d8ca03bff039a365)
[   98.601267] systemd-networkd-tests.py[691]:     #1 0x7f45428e2a84  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xae2a84) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.601624] systemd-networkd-tests.py[691]:     #2 0x7f4542914e75  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xb14e75) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.602109] systemd-networkd-tests.py[691]:     #3 0x55d9da6d697e  (/usr/lib/systemd/systemd-networkd-wait-online+0xa97e) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.602996] systemd-networkd-tests.py[691]:     #4 0x7f4542914e75  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xb14e75) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.603412] systemd-networkd-tests.py[691]:     #5 0x55d9da6d5ec0  (/usr/lib/systemd/systemd-networkd-wait-online+0x9ec0) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.606660] systemd-networkd-tests.py[691]:     #6 0x55d9da6e251f  (/usr/lib/systemd/systemd-networkd-wait-online+0x1651f) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.607090] systemd-networkd-tests.py[691]:     #7 0x7f4542922987  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xb22987) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.607459] systemd-networkd-tests.py[691]:     #8 0x7f454293fc09  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xb3fc09) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.607936] systemd-networkd-tests.py[691]:     #9 0x7f454279c151  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0x99c151) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.608363] systemd-networkd-tests.py[691]:     #10 0x7f454279a500  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0x99a500) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.608861] systemd-networkd-tests.py[691]:     #11 0x7f454279e698  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0x99e698) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.609252] systemd-networkd-tests.py[691]:     #12 0x7f454279ef0d  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0x99ef0d) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.609686] systemd-networkd-tests.py[691]:     #13 0x55d9da6e3b46  (/usr/lib/systemd/systemd-networkd-wait-online+0x17b46) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.610089] systemd-networkd-tests.py[691]:     #14 0x7f4541c105f4  (/lib64/libc.so.6+0x35f4) (BuildId: be08f175fb99297415ecc80c9ee7a33b56cbd355)
[   98.6104[48](https://github.com/systemd/systemd/actions/runs/13002269118/job/36263024103?pr=34640#step:12:49)] systemd-networkd-tests.py[691]:     #15 0x7f4541c106a7  (/lib64/libc.so.6+0x36a7) (BuildId: be08f175fb99297415ecc80c9ee7a33b56cbd355)
[   98.610952] systemd-networkd-tests.py[691]:     #16 0x55d9da6d59b4  (/usr/lib/systemd/systemd-networkd-wait-online+0x99b4) (BuildId: 5f84a9682ff2e9c[50](https://github.com/systemd/systemd/actions/runs/13002269118/job/36263024103?pr=34640#step:12:51)2fbe8c5761f118a9b6860f5)
[   98.611442] systemd-networkd-tests.py[691]: SUMMARY: AddressSanitizer: 10 byte(s) leaked in 2 allocation(s).
[   98.611990] systemd-networkd-tests.py[691]: ----------------------------------------------------------------------
[   98.612383] systemd-networkd-tests.py[691]: Ran 5 tests in 70.632s
[   98.612862] systemd-networkd-tests.py[691]: FAILED (failures=2)

@evverx
Copy link
Member

evverx commented Jan 28, 2025

That backtrace is unsymbolized. The symbolized backtrace is

Direct leak of 10 byte(s) in 2 object(s) allocated from:                                                                                                      
    #0 0x7f1a1fac2897 in malloc (/lib64/libasan.so.8+0xc2897) (BuildId: 0505b45e5a5d9a6c8ecb1d529aaaf13cd21fbe4e)                                             
    #1 0x7f1a1e6c8b1d in malloc_multiply ../src/src/basic/alloc-util.h:119                                                                                    
    #2 0x7f1a1e6c9f95 in json_dispatch_byte_array_iovec ../src/src/libsystemd/sd-json/json-util.c:49                                                          
    #3 0x7f1a1e707a9d in sd_json_dispatch_full ../src/src/libsystemd/sd-json/sd-json.c:5229                                                                   
    #4 0x7f1a1e70847b in sd_json_dispatch ../src/src/libsystemd/sd-json/sd-json.c:5301                                                                        
    #5 0x556be8c367b9 in dispatch_dns_server ../src/src/network/wait-online/dns-configuration.c:49                                                            
    #6 0x556be8c36f26 in dispatch_dns_server_array ../src/src/network/wait-online/dns-configuration.c:72                                                      
    #7 0x7f1a1e707a9d in sd_json_dispatch_full ../src/src/libsystemd/sd-json/sd-json.c:5229
    #8 0x7f1a1e70847b in sd_json_dispatch ../src/src/libsystemd/sd-json/sd-json.c:5301
    #9 0x556be8c3845c in dispatch_dns_configuration ../src/src/network/wait-online/dns-configuration.c:189
    #10 0x556be8c386b6 in dns_configuration_from_json ../src/src/network/wait-online/dns-configuration.c:199
    #11 0x556be8c45976 in on_dns_configuration_event ../src/src/network/wait-online/manager.c:440
    #12 0x7f1a1e72525b in varlink_dispatch_reply ../src/src/libsystemd/sd-varlink/sd-varlink.c:1154
    #13 0x7f1a1e728a00 in sd_varlink_process ../src/src/libsystemd/sd-varlink/sd-varlink.c:1455
    #14 0x7f1a1e73fa67 in defer_callback ../src/src/libsystemd/sd-varlink/sd-varlink.c:2950
    #15 0x7f1a1e52bccf in source_dispatch ../src/src/libsystemd/sd-event/sd-event.c:4241
    #16 0x7f1a1e535121 in sd_event_dispatch ../src/src/libsystemd/sd-event/sd-event.c:4830
    #17 0x7f1a1e53638e in sd_event_run ../src/src/libsystemd/sd-event/sd-event.c:4891
    #18 0x7f1a1e5367b6 in sd_event_loop ../src/src/libsystemd/sd-event/sd-event.c:4912
    #19 0x556be8c4af1e in run ../src/src/network/wait-online/wait-online.c:236
    #20 0x556be8c4b3db in main ../src/src/network/wait-online/wait-online.c:248 
    #21 0x7f1a1d210247 in __libc_start_call_main (/lib64/libc.so.6+0x3247) (BuildId: 515c33a35f41020661fea8ac4eb995e26ccd6b00)
    #22 0x7f1a1d21030a in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x330a) (BuildId: 515c33a35f41020661fea8ac4eb995e26ccd6b00)
    #23 0x556be8c35fd4 in _start (/usr/lib/systemd/systemd-networkd-wait-online+0x1fd4) (BuildId: a9ba5539dfad2ed308377349965131730fc74687)

Direct leak of 10 byte(s) in 2 object(s) allocated from:
    #0 0x7f1a1fac2897 in malloc (/lib64/libasan.so.8+0xc2897) (BuildId: 0505b45e5a5d9a6c8ecb1d529aaaf13cd21fbe4e)
    #1 0x7f1a1e6c8b1d in malloc_multiply ../src/src/basic/alloc-util.h:119
    #2 0x7f1a1e6c9f95 in json_dispatch_byte_array_iovec ../src/src/libsystemd/sd-json/json-util.c:49
    #3 0x7f1a1e707a9d in sd_json_dispatch_full ../src/src/libsystemd/sd-json/sd-json.c:5229
    #4 0x7f1a1e70847b in sd_json_dispatch ../src/src/libsystemd/sd-json/sd-json.c:5301
    #5 0x556be8c367b9 in dispatch_dns_server ../src/src/network/wait-online/dns-configuration.c:49
    #6 0x7f1a1e707a9d in sd_json_dispatch_full ../src/src/libsystemd/sd-json/sd-json.c:5229
    #7 0x7f1a1e70847b in sd_json_dispatch ../src/src/libsystemd/sd-json/sd-json.c:5301
    #8 0x556be8c3845c in dispatch_dns_configuration ../src/src/network/wait-online/dns-configuration.c:189
    #9 0x556be8c386b6 in dns_configuration_from_json ../src/src/network/wait-online/dns-configuration.c:199
    #10 0x556be8c45976 in on_dns_configuration_event ../src/src/network/wait-online/manager.c:440
    #11 0x7f1a1e72525b in varlink_dispatch_reply ../src/src/libsystemd/sd-varlink/sd-varlink.c:1154
    #12 0x7f1a1e728a00 in sd_varlink_process ../src/src/libsystemd/sd-varlink/sd-varlink.c:1455
    #13 0x7f1a1e73fa67 in defer_callback ../src/src/libsystemd/sd-varlink/sd-varlink.c:2950
    #14 0x7f1a1e52bccf in source_dispatch ../src/src/libsystemd/sd-event/sd-event.c:4241
    #15 0x7f1a1e535121 in sd_event_dispatch ../src/src/libsystemd/sd-event/sd-event.c:4830
    #16 0x7f1a1e53638e in sd_event_run ../src/src/libsystemd/sd-event/sd-event.c:4891
    #17 0x7f1a1e5367b6 in sd_event_loop ../src/src/libsystemd/sd-event/sd-event.c:4912
    #18 0x556be8c4af1e in run ../src/src/network/wait-online/wait-online.c:236
    #19 0x556be8c4b3db in main ../src/src/network/wait-online/wait-online.c:248 
    #20 0x7f1a1d210247 in __libc_start_call_main (/lib64/libc.so.6+0x3247) (BuildId: 515c33a35f41020661fea8ac4eb995e26ccd6b00)
    #21 0x7f1a1d21030a in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x330a) (BuildId: 515c33a35f41020661fea8ac4eb995e26ccd6b00)
    #22 0x556be8c35fd4 in _start (/usr/lib/systemd/systemd-networkd-wait-online+0x1fd4) (BuildId: a9ba5539dfad2ed308377349965131730fc74687)

SUMMARY: AddressSanitizer: 20 byte(s) leaked in 4 allocation(s).

@yuwata yuwata added the ci-fails/needs-rework 🔥 Please rework this, the CI noticed an issue with the PR label Jan 28, 2025
enr0n added 4 commits January 28, 2025 08:49
Add a new flag to systemd-networkd-wait-online, --dns, to allow waiting
for DNS to be configured.

DNS is considered configured when at least one DNS server is accessible.
If a link has the property DefaultRoute=yes (either by explicit
configuration, or because there are no routing-only domains), or if the
search domain '.' is configured, wait for link-specific DNS to be
configured. Otherwise, global DNS servers may be considered.
@enr0n
Copy link
Contributor Author

enr0n commented Jan 28, 2025

This looks related @enr0n can you double check?

[   98.549876] systemd-networkd-tests.py[691]:   File "/usr/lib64/python3.13/subprocess.py", line 508, in check_returncode
[   98.551901] systemd-networkd-tests.py[691]:     raise CalledProcessError(self.returncode, self.args, self.stdout,
[   98.5529[45](https://github.com/systemd/systemd/actions/runs/13002269118/job/36263024103?pr=34640#step:12:46)] systemd-networkd-tests.py[691]:                              self.stderr)
[   98.553440] systemd-networkd-tests.py[691]: subprocess.CalledProcessError: Command '['/usr/lib/systemd/systemd-networkd-wait-online', '--timeout=20s', '--interface=veth99:routable', '--ignore=sit0', '--ignore=ifb1', '--ignore=gre0', '--ignore=ifb0', '--ignore=lo', '--ignore=ip6tnl0', '--ignore=ip_vti0', '--ignore=ip6_vti0', '--ignore=teql0', '--ignore=ip6gre0', '--ignore=tunl0', '--ignore=gretap0', '--ignore=erspan0', '--dns']' returned non-zero exit status 1.
[   98.553822] systemd-networkd-tests.py[691]: During handling of the above exception, another exception occurred:
[   98.554372] systemd-networkd-tests.py[691]: Traceback (most recent call last):
[   98.554753] systemd-networkd-tests.py[691]:   File "/usr/lib/systemd/tests/testdata/test-network/systemd-networkd-tests.py", line 1696, in test_wait_online_dns_global
[   98.555136] systemd-networkd-tests.py[691]:     self.do_test_wait_online_dns(
[   98.555498] systemd-networkd-tests.py[691]:     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
[   98.556420] systemd-networkd-tests.py[691]:         global_dns='192.168.5.1',
[   98.557201] systemd-networkd-tests.py[691]:         ^^^^^^^^^^^^^^^^^^^^^^^^^
[   98.557664] systemd-networkd-tests.py[691]:     ...<3 lines>...
[   98.558110] systemd-networkd-tests.py[691]:         )
[   98.558487] systemd-networkd-tests.py[691]:         ^
[   98.558915] systemd-networkd-tests.py[691]:     )
[   98.560310] systemd-networkd-tests.py[691]:     ^
[   98.560550] systemd-networkd-tests.py[691]:   File "/usr/lib/systemd/tests/testdata/test-network/systemd-networkd-tests.py", line 1680, in do_test_wait_online_dns
[   98.561222] systemd-networkd-tests.py[691]:     self.fail(
[   98.561760] systemd-networkd-tests.py[691]:     ~~~~~~~~~^
[   98.562273] systemd-networkd-tests.py[691]:         f'Command timed out:\n{e.output}'
[   98.563223] systemd-networkd-tests.py[691]:         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[   98.563939] systemd-networkd-tests.py[691]:     )
[   98.565661] systemd-networkd-tests.py[691]:     ^
[   98.566276] systemd-networkd-tests.py[691]: AssertionError: Command timed out:
[   98.566815] systemd-networkd-tests.py[691]: Found link lo(1)
[   98.567342] systemd-networkd-tests.py[691]: Found link gre0(5)
[   98.567937] systemd-networkd-tests.py[691]: Found link gretap0(6)
[   98.568335] systemd-networkd-tests.py[691]: Found link erspan0(7)
[   98.568862] systemd-networkd-tests.py[691]: Found link veth-peer(24)
[   98.569808] systemd-networkd-tests.py[691]: Found link veth99(25)
[   98.570069] systemd-networkd-tests.py[691]: varlink: Setting state idle-client
[   98.570320] systemd-networkd-tests.py[691]: varlink: Sending message: {"method":"io.systemd.Resolve.Monitor.SubscribeDNSConfiguration","parameters":{"allowInteractiveAuthentication":false},"more":true}
[   98.571360] systemd-networkd-tests.py[691]: varlink: Changing state idle-client → awaiting-reply-more
[   98.571583] systemd-networkd-tests.py[691]: veth99: link is being processed by networkd: setup state is configuring.
[   98.571942] systemd-networkd-tests.py[691]: varlink: Received message: {"parameters":{"configuration":[{"currentServer":{"address":[192,168,5,1],"family":2,"port":53,"accessible":true},"servers":[{"address":[192,168,5,1],"family":2,"port":53,"accessible":true}]},{"ifname":"erspan0","ifindex":7,"defaultRoute":false},{"ifname":"gretap0","ifindex":6,"defaultRoute":false},{"ifname":"lo","ifindex":1,"defaultRoute":false},{"ifname":"veth-peer","ifindex":24,"defaultRoute":false},{"ifname":"gre0","ifindex":5,"defaultRoute":false},{"ifname":"veth99","ifindex":25,"defaultRoute":false}]},"continues":true}
[   98.572421] systemd-networkd-tests.py[691]: varlink: Changing state awaiting-reply-more → processing-reply
[   98.572728] systemd-networkd-tests.py[691]: veth99: link is being processed by networkd: setup state is configuring.
[   98.572917] systemd-networkd-tests.py[691]: varlink: Changing state processing-reply → awaiting-reply-more
[   98.573826] systemd-networkd-tests.py[691]: veth99: link is being processed by networkd: setup state is configuring.
[   98.574218] systemd-networkd-tests.py[691]: veth99: link is being processed by networkd: setup state is configuring.
[   98.574457] systemd-networkd-tests.py[691]: veth99: link is configured by networkd and online.
[   98.574745] systemd-networkd-tests.py[691]: varlink: Changing state awaiting-reply-more → disconnected
[   98.574951] systemd-networkd-tests.py[691]: =================================================================
[   98.575850] systemd-networkd-tests.py[691]: ==1299==ERROR: LeakSanitizer: detected memory leaks
[   98.576255] systemd-networkd-tests.py[691]: Direct leak of 5 byte(s) in 1 object(s) allocated from:
[   98.576530] systemd-networkd-tests.py[691]:     #0 0x7f4542ed4d53  (/usr/lib/clang/19/lib/x86_64-redhat-linux-gnu/libclang_rt.asan.so+0xd4d53) (BuildId: 1afad417992f0eb55159b853d8ca03bff039a365)
[   98.577619] systemd-networkd-tests.py[691]:     #1 0x7f45428e2a84  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xae2a84) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.578075] systemd-networkd-tests.py[691]:     #2 0x7f4542914e75  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xb14e75) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.579288] systemd-networkd-tests.py[691]:     #3 0x55d9da6d697e  (/usr/lib/systemd/systemd-networkd-wait-online+0xa97e) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.580138] systemd-networkd-tests.py[691]:     #4 0x55d9da6d705e  (/usr/lib/systemd/systemd-networkd-wait-online+0xb05e) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.580554] systemd-networkd-tests.py[691]:     #5 0x7f4542914e75  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xb14e75) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.581752] systemd-networkd-tests.py[691]:     #6 0x55d9da6d5ec0  (/usr/lib/systemd/systemd-networkd-wait-online+0x9ec0) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.581992] systemd-networkd-tests.py[691]:     #7 0x55d9da6e251f  (/usr/lib/systemd/systemd-networkd-wait-online+0x1651f) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.582993] systemd-networkd-tests.py[691]:     #8 0x7f4542922987  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xb22987) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.583303] systemd-networkd-tests.py[691]:     #9 0x7f454293fc09  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xb3fc09) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.583808] systemd-networkd-tests.py[691]:     #10 0x7f454279c151  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0x99c151) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.584065] systemd-networkd-tests.py[691]:     #11 0x7f454279a500  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0x99a500) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.592601] systemd-networkd-tests.py[691]:     #12 0x7f454279e698  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0x99e698) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.595089] systemd-networkd-tests.py[691]:     #13 0x7f454279ef0d  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0x99ef0d) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.596302] systemd-networkd-tests.py[691]:     #14 0x55d9da6e3b[46](https://github.com/systemd/systemd/actions/runs/13002269118/job/36263024103?pr=34640#step:12:47)  (/usr/lib/systemd/systemd-networkd-wait-online+0x17b46) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.597675] systemd-networkd-tests.py[691]:     #15 0x7f4541c105f4  (/lib64/libc.so.6+0x35f4) (BuildId: be08f175fb99297415ecc80c9ee7a33b56cbd355)
[   98.598375] systemd-networkd-tests.py[691]:     #16 0x7f4541c106a7  (/lib64/libc.so.6+0x36a7) (BuildId: be08f175fb99297415ecc80c9ee7a33b56cbd355)
[   98.598922] systemd-networkd-tests.py[691]:     #17 0x55d9da6d59b4  (/usr/lib/systemd/systemd-networkd-wait-online+0x99b4) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.599437] systemd-networkd-tests.py[691]: Direct leak of 5 byte(s) in 1 object(s) allocated from:
[   98.600881] systemd-networkd-tests.py[691]:     #0 0x7f4542ed4d53  (/usr/lib/clang/19/lib/x86_64-redhat-linux-gnu/libclang_rt.asan.so+0xd4d53) (BuildId: 1afad417992f0eb55159b853d8ca03bff039a365)
[   98.601267] systemd-networkd-tests.py[691]:     #1 0x7f45428e2a84  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xae2a84) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.601624] systemd-networkd-tests.py[691]:     #2 0x7f4542914e75  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xb14e75) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.602109] systemd-networkd-tests.py[691]:     #3 0x55d9da6d697e  (/usr/lib/systemd/systemd-networkd-wait-online+0xa97e) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.602996] systemd-networkd-tests.py[691]:     #4 0x7f4542914e75  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xb14e75) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.603412] systemd-networkd-tests.py[691]:     #5 0x55d9da6d5ec0  (/usr/lib/systemd/systemd-networkd-wait-online+0x9ec0) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.606660] systemd-networkd-tests.py[691]:     #6 0x55d9da6e251f  (/usr/lib/systemd/systemd-networkd-wait-online+0x1651f) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.607090] systemd-networkd-tests.py[691]:     #7 0x7f4542922987  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xb22987) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.607459] systemd-networkd-tests.py[691]:     #8 0x7f454293fc09  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0xb3fc09) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.607936] systemd-networkd-tests.py[691]:     #9 0x7f454279c151  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0x99c151) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.608363] systemd-networkd-tests.py[691]:     #10 0x7f454279a500  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0x99a500) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.608861] systemd-networkd-tests.py[691]:     #11 0x7f454279e698  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0x99e698) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.609252] systemd-networkd-tests.py[691]:     #12 0x7f454279ef0d  (/usr/lib64/systemd/libsystemd-shared-258-devel.so+0x99ef0d) (BuildId: e538e087c19b2620eedc017e63e73cf668e4f137)
[   98.609686] systemd-networkd-tests.py[691]:     #13 0x55d9da6e3b46  (/usr/lib/systemd/systemd-networkd-wait-online+0x17b46) (BuildId: 5f84a9682ff2e9c502fbe8c5761f118a9b6860f5)
[   98.610089] systemd-networkd-tests.py[691]:     #14 0x7f4541c105f4  (/lib64/libc.so.6+0x35f4) (BuildId: be08f175fb99297415ecc80c9ee7a33b56cbd355)
[   98.6104[48](https://github.com/systemd/systemd/actions/runs/13002269118/job/36263024103?pr=34640#step:12:49)] systemd-networkd-tests.py[691]:     #15 0x7f4541c106a7  (/lib64/libc.so.6+0x36a7) (BuildId: be08f175fb99297415ecc80c9ee7a33b56cbd355)
[   98.610952] systemd-networkd-tests.py[691]:     #16 0x55d9da6d59b4  (/usr/lib/systemd/systemd-networkd-wait-online+0x99b4) (BuildId: 5f84a9682ff2e9c[50](https://github.com/systemd/systemd/actions/runs/13002269118/job/36263024103?pr=34640#step:12:51)2fbe8c5761f118a9b6860f5)
[   98.611442] systemd-networkd-tests.py[691]: SUMMARY: AddressSanitizer: 10 byte(s) leaked in 2 allocation(s).
[   98.611990] systemd-networkd-tests.py[691]: ----------------------------------------------------------------------
[   98.612383] systemd-networkd-tests.py[691]: Ran 5 tests in 70.632s
[   98.612862] systemd-networkd-tests.py[691]: FAILED (failures=2)

I was missing an iovec_done() in dns_server_free().

@github-actions github-actions bot removed the ci-fails/needs-rework 🔥 Please rework this, the CI noticed an issue with the PR label Jan 28, 2025
@enr0n
Copy link
Contributor Author

enr0n commented Jan 28, 2025

Okay, I believe the remaining failures are unrelated now.

@bluca bluca merged commit 103bf54 into systemd:main Jan 28, 2025
44 of 47 checks passed
@github-actions github-actions bot removed the good-to-merge/waiting-for-ci 👍 PR is good to merge, but CI hasn't passed at time of review. Please merge if you see CI has passed label Jan 28, 2025
if (set_isempty(m->varlink_dns_configuration_subscription))
manager_stop_dns_configuration_monitor(m);


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spurious double empty line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spurious double empty line

#36216

slyon added a commit to slyon/netplan that referenced this pull request Feb 3, 2025
slyon added a commit to canonical/netplan that referenced this pull request Mar 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

5 participants