[PATCH 0/5] Split DNS code and fix systemd-resolved tethering

Jussi Laakkonen <[email protected]> Fri, 8 May 2026 19:05:34 +0300
Newsgroups dev.linux.lists.connman
Message-ID <[email protected]>
This set of patches splits the DNS code into shared/dns.c from dnsproxy.c to be
used also by dns-systemd-resolved.c. Only the caching of dnsproxy.c is kept and
callbacks are utilized to use caching from shared/dns.c. The splitting of the
DNS code is done to avoid code duplication and to make both work in similar
fashion regarding DNS requests for all uses.

The splitting of the DNS code was imperative to make dns-systemd-resolved.c to
work with tethering clients. By design systemd-resolved does not allow the DNS
requests from anywhere else than localhost and requests originating from any
other sources are treated as martians. To solve this dns-systemd-resolved.c 
roxying the DNS requests similarly to what dnsproxy.c is doing. The tethering
interface is listened for DNS requests and they are then proxied to the
systemd-resolved server (using the same code dnsproxy.c did already use to
this) to make the requests look like coming from the local machine.

The changes related to dns-systemd-resolved.c have been use in Sailfish OS for
over a year in internal use and are included in the next, upcoming 5.1 release,
which is now in public beta testing. These changes have been also tested with
ConnMan 2.0 using latest AntiX (for regression testing, as AntiX uses no
systemd) and Debian stable (with and without systemd-resolved) - no new issues
were found and tethering worked on both internal and systemd-resolved DNS.

The work for making these patches available for ConnMan upstream has been
funded by NLnet foundation grant. The changes are also available at
https://github.com/LaakkonenJussi/connman_ng/pull/1

Jussi Laakkonen (5):
  dns: Split generic DNS functionality with cache cb support
  systemd-resolved: Proxy tethering client DNS requests to resolved
  build: Define DNS server addresses in Makefile.
  dns: Use compile time defined DNS for listener
  gresolv: Use compile time defined DNS with lookup + UDP connect

 Makefile.am                 |   27 +-
 gweb/gresolv.c              |   11 +-
 src/dns-systemd-resolved.c  |   32 +-
 src/dnsproxy.c              | 3010 +++--------------------------------
 src/shared/dns.c            | 2570 ++++++++++++++++++++++++++++++
 src/shared/dns.h            |  232 +++
 tools/dnsproxy-standalone.c |    1 +
 7 files changed, 3102 insertions(+), 2781 deletions(-)
 create mode 100644 src/shared/dns.c
 create mode 100644 src/shared/dns.h

-- 
2.47.3