From: Tim Kourt <tim.a.kourt@linux.intel.com>
To: iwd@lists.01.org
Subject: [PATCH v3 5/5] netconfig: Install IPv6 DNS
Date: Tue, 01 Oct 2019 09:31:24 -0700 [thread overview]
Message-ID: <20191001163124.1179-5-tim.a.kourt@linux.intel.com> (raw)
In-Reply-To: <20191001163124.1179-1-tim.a.kourt@linux.intel.com>
[-- Attachment #1: Type: text/plain, Size: 2175 bytes --]
---
src/netconfig.c | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 55 insertions(+), 1 deletion(-)
diff --git a/src/netconfig.c b/src/netconfig.c
index cbbe9b3a..0144aa5f 100644
--- a/src/netconfig.c
+++ b/src/netconfig.c
@@ -323,6 +323,50 @@ static char *netconfig_ipv6_get_gateway(struct netconfig *netconfig)
return NULL;
}
+static char **netconfig_ipv6_get_dns(struct netconfig *netconfig, uint8_t proto)
+{
+ struct in6_addr in6_addr;
+ char **dns_list;
+ char **p;
+
+ switch (proto) {
+ case RTPROT_STATIC:
+ if (!netconfig->active_settings)
+ return NULL;
+
+ p = dns_list =
+ l_settings_get_string_list(netconfig->active_settings,
+ "IPv6", "dns", ' ');
+
+ if (!dns_list || !*dns_list) {
+ l_strv_free(dns_list);
+
+ return NULL;
+ }
+
+ for (; *p; p++) {
+ if (inet_pton(AF_INET6, *p, &in6_addr) == 1)
+ continue;
+
+ l_error("netconfig: Invalid IPv6 DNS address %s is "
+ "provided in network configuration file.", *p);
+
+ l_strv_free(dns_list);
+
+ return NULL;
+ }
+
+ return dns_list;
+
+ case RTPROT_DHCP:
+ /* TODO */
+
+ return NULL;
+ }
+
+ return NULL;
+}
+
static bool netconfig_ifaddr_match(const void *a, const void *b)
{
const struct netconfig_ifaddr *entry = a;
@@ -671,6 +715,7 @@ static void netconfig_ipv6_ifaddr_add_cmd_cb(int error, uint16_t type,
void *user_data)
{
struct netconfig *netconfig = user_data;
+ char **dns;
if (error && error != -EEXIST) {
l_error("netconfig: Failed to add IPv6 address. "
@@ -684,7 +729,16 @@ static void netconfig_ipv6_ifaddr_add_cmd_cb(int error, uint16_t type,
return;
}
- /* TODO Install DNS */
+ dns = netconfig_ipv6_get_dns(netconfig, netconfig->rtm_v6_protocol);
+ if (!dns) {
+ l_error("netconfig: Failed to obtain the DNS addresses from "
+ "%s.", netconfig->rtm_v6_protocol == RTPROT_STATIC ?
+ "setting file" : "DHCPv6 lease");
+ return;
+ }
+
+ resolve_add_dns(netconfig->ifindex, AF_INET6, dns);
+ l_strv_free(dns);
}
static void netconfig_install_address(struct netconfig *netconfig,
--
2.13.6
prev parent reply other threads:[~2019-10-01 16:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-01 16:31 [PATCH v3 1/5] netconfig: Subscribe for IPv6 address changes Tim Kourt
2019-10-01 16:31 ` [PATCH v3 2/5] netconfig: Request all known IPv6 addresses Tim Kourt
2019-10-01 16:31 ` [PATCH v3 3/5] netconfig: Add IPv6 static address installation/removal Tim Kourt
2019-10-01 16:31 ` [PATCH v3 4/5] netconfig: Install IPv6 default route Tim Kourt
2019-10-01 16:31 ` Tim Kourt [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191001163124.1179-5-tim.a.kourt@linux.intel.com \
--to=tim.a.kourt@linux.intel.com \
--cc=iwd@lists.01.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox