diff options
author | Tim Harvey <tharvey@gateworks.com> | 2025-05-30 08:38:25 -0700 |
---|---|---|
committer | Jerome Forissier <jerome.forissier@linaro.org> | 2025-07-08 11:05:29 +0200 |
commit | a383869d6b58b3d66a91460a8b1a6fdcc09a1fe9 (patch) | |
tree | 09b85b5d95f66bf1f8d02c9605386e8e61816bde /net/lwip/dns.c | |
parent | e4e97f70526dd9f367f54a38f38115726336cd6a (diff) |
net: lwip: move dns init to common function
move the dns init including setting the dns servers from env vars to a
common function as other commands that support hostname lookups will
need this.
Signed-off-by: Tim Harvey <tharvey@gateworks.com>
[jf: add CMD_DNS conditional to support NET_LWIP && !CMD_DNS]
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
Diffstat (limited to 'net/lwip/dns.c')
-rw-r--r-- | net/lwip/dns.c | 20 |
1 files changed, 1 insertions, 19 deletions
diff --git a/net/lwip/dns.c b/net/lwip/dns.c index 3c9867902db..fe70bdb4828 100644 --- a/net/lwip/dns.c +++ b/net/lwip/dns.c @@ -45,12 +45,9 @@ static void dns_cb(const char *name, const ip_addr_t *ipaddr, void *arg) static int dns_loop(struct udevice *udev, const char *name, const char *var) { struct dns_cb_arg dns_cb_arg = { }; - bool has_server = false; struct netif *netif; ip_addr_t ipaddr; - ip_addr_t ns; ulong start; - char *nsenv; int ret; dns_cb_arg.var = var; @@ -59,22 +56,7 @@ static int dns_loop(struct udevice *udev, const char *name, const char *var) if (!netif) return CMD_RET_FAILURE; - dns_init(); - - nsenv = env_get("dnsip"); - if (nsenv && ipaddr_aton(nsenv, &ns)) { - dns_setserver(0, &ns); - has_server = true; - } - - nsenv = env_get("dnsip2"); - if (nsenv && ipaddr_aton(nsenv, &ns)) { - dns_setserver(1, &ns); - has_server = true; - } - - if (!has_server) { - log_err("No valid name server (dnsip/dnsip2)\n"); + if (net_lwip_dns_init()) { net_lwip_remove_netif(netif); return CMD_RET_FAILURE; } |