diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-07-17 12:07:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-17 12:07:39 +0200 |
commit | 52f4b5ac8a046172aacf3fa441e89997445b80ed (patch) | |
tree | 47c9c619c6ac2b8408c32fde3d66ac36b2193c8f /src/shared | |
parent | d34a40082db3ffca8de66bfa4df50951101bdae5 (diff) | |
parent | 217246a990cc34155f02fcecce1df95ca2e1abed (diff) | |
download | systemd-52f4b5ac8a046172aacf3fa441e89997445b80ed.tar.gz systemd-52f4b5ac8a046172aacf3fa441e89997445b80ed.tar.bz2 systemd-52f4b5ac8a046172aacf3fa441e89997445b80ed.zip |
Merge pull request #12675 from yuwata/network-set-dns
resolvectl: support to modify interfaces managed by networkd
Diffstat (limited to 'src/shared')
-rw-r--r-- | src/shared/resolve-util.c | 13 | ||||
-rw-r--r-- | src/shared/resolve-util.h | 6 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/shared/resolve-util.c b/src/shared/resolve-util.c index b433cd24bc..3d14410e32 100644 --- a/src/shared/resolve-util.c +++ b/src/shared/resolve-util.c @@ -28,3 +28,16 @@ static const char* const dns_over_tls_mode_table[_DNS_OVER_TLS_MODE_MAX] = { [DNS_OVER_TLS_YES] = "yes", }; DEFINE_STRING_TABLE_LOOKUP_WITH_BOOLEAN(dns_over_tls_mode, DnsOverTlsMode, DNS_OVER_TLS_YES); + +bool dns_server_address_valid(int family, const union in_addr_union *sa) { + + /* Refuses the 0 IP addresses as well as 127.0.0.53 (which is our own DNS stub) */ + + if (in_addr_is_null(family, sa)) + return false; + + if (family == AF_INET && sa->in.s_addr == htobe32(INADDR_DNS_STUB)) + return false; + + return true; +} diff --git a/src/shared/resolve-util.h b/src/shared/resolve-util.h index 6ce2508466..cf097dfaa3 100644 --- a/src/shared/resolve-util.h +++ b/src/shared/resolve-util.h @@ -2,8 +2,12 @@ #pragma once #include "conf-parser.h" +#include "in-addr-util.h" #include "macro.h" +/* 127.0.0.53 in native endian */ +#define INADDR_DNS_STUB ((in_addr_t) 0x7f000035U) + typedef enum ResolveSupport ResolveSupport; typedef enum DnssecMode DnssecMode; typedef enum DnsOverTlsMode DnsOverTlsMode; @@ -61,3 +65,5 @@ DnssecMode dnssec_mode_from_string(const char *s) _pure_; const char* dns_over_tls_mode_to_string(DnsOverTlsMode p) _const_; DnsOverTlsMode dns_over_tls_mode_from_string(const char *s) _pure_; + +bool dns_server_address_valid(int family, const union in_addr_union *sa); |