Skip to content

Commit

Permalink
fix(dns): Config for dynamic DNS sorting so AF_UNSPEC works in IPv6-o…
Browse files Browse the repository at this point in the history
…nly network

This fix adds an option to dynamically set the order based on whether
an the host has a global (or ULA) IPv6 address, allowing a device
with both IPv4 and IPv6 enabled to work in any network configuration,
including IPv4-only, IPv6-only, and dual-stack.
  • Loading branch information
sgryphon committed Feb 25, 2024
1 parent 495183a commit fd85a79
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
10 changes: 10 additions & 0 deletions components/lwip/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -1104,6 +1104,16 @@ menu "LWIP"
help
This option allows you to config dns fallback server address.

config LWIP_DNS_DYNAMIC_SORT
bool "Dynamically sort DNS results"
default n
help
Dynamically sorts DNS results by available source addresses (based on RFC 6724).
This allows a device to return results based on the current network
and work across IPv4-only, IPv6-only, and dual-stack networks.
If this option is disabled, DNS results have a static preference for IPv4,
which will work in most cases but fails for some network configurations

endmenu # DNS

config LWIP_BRIDGEIF_MAX_PORTS
Expand Down
2 changes: 1 addition & 1 deletion components/lwip/lwip
Submodule lwip updated 1 files
+27 −0 src/api/netdb.c
10 changes: 10 additions & 0 deletions components/lwip/port/include/lwipopts.h
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,16 @@ static inline uint32_t timeout_from_offered(uint32_t lease, uint32_t min)
#define LWIP_DNS_SUPPORT_MDNS_QUERIES 0
#endif

/**
* LWIP_DNS_DYNAMIC_SORT==1: Dynamically sorts DNS results by available source addresses.
* This option is set via menuconfig.
*/
#ifdef CONFIG_LWIP_DNS_DYNAMIC_SORT
#define LWIP_DNS_DYNAMIC_SORT 1
#else
#define LWIP_DNS_DYNAMIC_SORT 0
#endif

/*
---------------------------------
---------- UDP options ----------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,16 @@ menu "Example Connection Configuration"
Note that the dhcpv6 client has to be started using dhcp6_enable_stateless(netif);
Note that the stateful address autoconfiguration is not supported.

config LWIP_DNS_DYNAMIC_SORT
bool "Dynamically sort DNS results"
default y
help
Dynamically sorts DNS results by available source addresses (based on RFC 6724).
This allows a device to return results based on the current network
and work across IPv4-only, IPv6-only, and dual-stack networks.
If this option is disabled, DNS results have a static preference for IPv4,
which will work in most cases but fails for some network configurations

endif


Expand Down

0 comments on commit fd85a79

Please sign in to comment.