From: Tim Kourt <tim.a.kourt@linux.intel.com>
To: iwd@lists.01.org
Subject: [PATCH 1/2] netconfig: Allow to override IPv4 DHCP DNSs with static addresses
Date: Thu, 03 Oct 2019 13:48:50 -0700 [thread overview]
Message-ID: <20191003204851.9781-1-tim.a.kourt@linux.intel.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1885 bytes --]
---
src/netconfig.c | 37 +++++++++++++++++++++++++++++--------
1 file changed, 29 insertions(+), 8 deletions(-)
diff --git a/src/netconfig.c b/src/netconfig.c
index 285d5fef..51d06ce1 100644
--- a/src/netconfig.c
+++ b/src/netconfig.c
@@ -207,14 +207,37 @@ static char *netconfig_ipv4_get_gateway(struct netconfig *netconfig)
static char **netconfig_ipv4_get_dns(struct netconfig *netconfig, uint8_t proto)
{
const struct l_dhcp_lease *lease;
+ struct in_addr in_addr;
+ char **dns_list;
+ char **p;
- switch (proto) {
- case RTPROT_STATIC:
-
- return l_settings_get_string_list(netconfig->active_settings,
+ p = dns_list = l_settings_get_string_list(netconfig->active_settings,
"IPv4", "dns", ' ');
+ if (dns_list && *dns_list) {
+ for (; *p; p++) {
+ if (inet_pton(AF_INET, *p, &in_addr) == 1)
+ continue;
- case RTPROT_DHCP:
+ l_error("netconfig: Invalid IPv4 DNS address '%s' is "
+ "provided in network configuration file.", *p);
+
+ l_strv_free(dns_list);
+
+ return NULL;
+ }
+
+ /* Allow to override the DHCP DNSs with static addressing. */
+ return dns_list;
+ } else if (dns_list) {
+ l_error("netconfig: No IPv4 DNS address is provided in network "
+ "configuration file.");
+
+ l_strv_free(dns_list);
+
+ return NULL;
+ }
+
+ if (proto == RTPROT_DHCP) {
lease = l_dhcp_client_get_lease(netconfig->dhcp_client);
if (!lease)
return NULL;
@@ -662,9 +685,7 @@ static void netconfig_ipv4_ifaddr_add_cmd_cb(int error, uint16_t type,
dns = netconfig_ipv4_get_dns(netconfig, netconfig->rtm_protocol);
if (!dns) {
- l_error("netconfig: Failed to obtain DNS addresses from %s.",
- netconfig->rtm_protocol == RTPROT_STATIC ?
- "setting file" : "DHCPv4 lease");
+ l_error("netconfig: Failed to obtain DNS addresses.");
goto done;
}
--
2.13.6
next reply other threads:[~2019-10-03 20:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-03 20:48 Tim Kourt [this message]
2019-10-03 20:48 ` [PATCH 2/2] netconfig: Allow to override IPv6 DHCP DNSs with static addresses Tim Kourt
2019-10-04 17:14 ` [PATCH 1/2] netconfig: Allow to override IPv4 " Denis Kenzior
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=20191003204851.9781-1-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