Skip to content

sync-dns: LWS_SERVER_OPTION_DISABLE_IPV6 does not suppress AAAA #3625

Description

@zzblydia

** What version of lws **

v4.3.3 and v4.5.2 (both verified on the wire); same logic on current main.

** What platform and arch? **

Ubuntu 24.04 x86_64, built with -DLWS_WITH_IPV6=ON -DLWS_WITH_SYS_ASYNC_DNS=ON.

** What parts of lws does it involve? **

websocket client with async-dns (lib/system/async-dns/async-dns.c)

** Describe the bug **

Two observations, confirmed by capturing qtypes at the nameserver.

1. The AAAA query is sent before A

Observed: wire order is AAAA(28), A(1), contradicting both the in-code comment in
lws_async_dns_query() and READMEs/README.async-dns.md ("it always requests first
A and then immediately afterwards AAAA"
).

Cause: in lws_async_dns_writeable(), on the first send both counters are 0, so
which evaluates to 1 (= AAAA):

	which = q->sent[0] >= q->sent[1];   /* 0 >= 0 -> 1, AAAA goes first */

2. LWS_SERVER_OPTION_DISABLE_IPV6 does not suppress AAAA queries

Observed: a context created with LWS_SERVER_OPTION_DISABLE_IPV6 still emits AAAA
queries.

Cause: the A/AAAA decision in lws_async_dns_writeable() is guarded only by
compile-time LWS_WITH_IPV6; the runtime option is never consulted in the async
resolver:

#if defined(LWS_WITH_IPV6)
	if (!q->responded) {
		/* must pick between ipv6 and ipv4 */
		which = q->sent[0] >= q->sent[1];
		...
		q->asked = 3; /* want results for 4 & 6 before done */
	}
	...
#else
	which = 0;
	q->asked = 1;
#endif

Are these intended design or bugs? If the latter, I'd like to try providing a patch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    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