summaryrefslogtreecommitdiffhomepage
path: root/libs/rpcd-mod-luci/src/luci.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-02-12 22:22:05 +0100
committerJo-Philipp Wich <jo@mein.io>2020-02-13 19:26:33 +0100
commit3702e13f544a0b5478d8e0bacd8b28fe55709a57 (patch)
tree33f7a194cab1d82f312ddbda80aaedf3f49c0862 /libs/rpcd-mod-luci/src/luci.c
parentc1aeb300f6976086e48dd90aac1504f38b73cdf9 (diff)
rpcd-mod-luci: honour dhcp leases without ip address for host hints
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'libs/rpcd-mod-luci/src/luci.c')
-rw-r--r--libs/rpcd-mod-luci/src/luci.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/libs/rpcd-mod-luci/src/luci.c b/libs/rpcd-mod-luci/src/luci.c
index 5dc436164d..951de5c46d 100644
--- a/libs/rpcd-mod-luci/src/luci.c
+++ b/libs/rpcd-mod-luci/src/luci.c
@@ -1283,14 +1283,14 @@ rpc_luci_get_host_hints_uci(struct reply_context *rctx)
ptr.option = "ip";
ptr.o = NULL;
- if (uci_lookup_ptr(uci, &ptr, NULL, true) || ptr.o == NULL)
- continue;
-
- if (ptr.o->type != UCI_TYPE_STRING)
- continue;
+ if (!uci_lookup_ptr(uci, &ptr, NULL, true) && ptr.o != NULL &&
+ ptr.o->type != UCI_TYPE_STRING)
+ n = ptr.o->v.string;
+ else
+ n = NULL;
- if (inet_pton(AF_INET, ptr.o->v.string, &in) != 1)
- continue;
+ if (!n || inet_pton(AF_INET, n, &in) != 1)
+ in.s_addr = 0;
ptr.option = "name";
ptr.o = NULL;
@@ -1316,7 +1316,7 @@ rpc_luci_get_host_hints_uci(struct reply_context *rctx)
if (!hint)
continue;
- if (hint->ip.s_addr == 0)
+ if (hint->ip.s_addr == 0 && in.s_addr != 0)
hint->ip = in;
if (n && !hint->hostname)
@@ -1330,7 +1330,7 @@ rpc_luci_get_host_hints_uci(struct reply_context *rctx)
if (!hint)
continue;
- if (hint->ip.s_addr == 0)
+ if (hint->ip.s_addr == 0 && in.s_addr != 0)
hint->ip = in;
if (n && !hint->hostname)