Skip to content

Failure to connect on mDNS hostnames which resolve to an IPv6 link local address #21669

@bartelsielski

Description

@bartelsielski

I did this

When connecting to a device via an mDNS hostname which resolves to an IPv6 link local address connection fails after a timeout.

I ran curl with strace and there you can see that the connect syscall is called without sin6_scope_id field set.

...
setsockopt(5, SOL_TCP, TCP_KEEPIDLE, [60], 4) = 0
setsockopt(5, SOL_TCP, TCP_KEEPINTVL, [60], 4) = 0
setsockopt(5, SOL_TCP, TCP_KEEPCNT, [9], 4) = 0
connect(5, {sa_family=AF_INET6, sin6_port=htons(80), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "fe80::d269:9eff:fe9d:ffdc", &sin6_addr), sin6_scope_id=0}, 28) = -1 EINVAL (Invalid argument)
getsockname(5, {sa_family=AF_INET6, sin6_port=htons(0), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "::", &sin6_addr), sin6_scope_id=0}, [128 => 28]) = 0
getsockname(5, {sa_family=AF_INET6, sin6_port=htons(0), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "::", &sin6_addr), sin6_scope_id=0}, [128 => 28]) = 0
close(5)                                = 0
rt_sigaction(SIGPIPE, {sa_handler=SIG_IGN, sa_mask=[PIPE], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7f90b7c3e8f0}, NULL, 8) = 0
poll([{fd=3, events=POLLIN}, {fd=3, events=POLLIN}], 2, 1000) = 0 (Timeout)
...

This seems the be a regression in version 8.20.0. It used to work in 8.19.0. What might be relevant is that I am using systemd-resolved as the mDNS resolver.

I expected the following

No response

curl/libcurl version

curl 8.20.0 (upstream Arch Linux package version 8.20.0-7)

operating system

Arch Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions