diff options
author | David Lamparter <equinox@diac24.net> | 2019-12-11 13:33:36 +0100 |
---|---|---|
committer | David Lamparter <equinox@diac24.net> | 2019-12-11 13:33:36 +0100 |
commit | 3286ca0750dc837d5e3e0d1a38aef64ea93c70a5 (patch) | |
tree | ee643a572b7c20c56b2f2e218b48c3ff0c3a9d17 /lib | |
parent | bgpd/bmp: actually print uptime (diff) | |
download | frr-3286ca0750dc837d5e3e0d1a38aef64ea93c70a5.tar.xz frr-3286ca0750dc837d5e3e0d1a38aef64ea93c70a5.zip |
lib,nhrpd,bgpd/bmp: pass resolver failure details
To keep the calling code agnostic of the DNS resolver libary used, pass
a strerror-style string instead of a status code that would need extra
handling.
Signed-off-by: David Lamparter <equinox@diac24.net>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/resolver.c | 19 | ||||
-rw-r--r-- | lib/resolver.h | 6 |
2 files changed, 15 insertions, 10 deletions
diff --git a/lib/resolver.c b/lib/resolver.c index 938ebd414..1be47bd6e 100644 --- a/lib/resolver.c +++ b/lib/resolver.c @@ -145,7 +145,8 @@ static void ares_address_cb(void *arg, int status, int timeouts, { struct resolver_query *query = (struct resolver_query *)arg; union sockunion addr[16]; - void (*callback)(struct resolver_query *, int, union sockunion *); + void (*callback)(struct resolver_query *, const char *, int, + union sockunion *); size_t i; callback = query->callback; @@ -153,9 +154,10 @@ static void ares_address_cb(void *arg, int status, int timeouts, if (status != ARES_SUCCESS) { if (resolver_debug) - zlog_debug("[%p] Resolving failed", query); + zlog_debug("[%p] Resolving failed (%s)", + query, ares_strerror(status)); - callback(query, -1, NULL); + callback(query, ares_strerror(status), -1, NULL); return; } @@ -177,25 +179,26 @@ static void ares_address_cb(void *arg, int status, int timeouts, if (resolver_debug) zlog_debug("[%p] Resolved with %d results", query, (int)i); - callback(query, i, &addr[0]); + callback(query, NULL, i, &addr[0]); } static int resolver_cb_literal(struct thread *t) { struct resolver_query *query = THREAD_ARG(t); - void (*callback)(struct resolver_query *, int, union sockunion *); + void (*callback)(struct resolver_query *, const char *, int, + union sockunion *); callback = query->callback; query->callback = NULL; - callback(query, 1, &query->literal_addr); + callback(query, ARES_SUCCESS, 1, &query->literal_addr); return 0; } void resolver_resolve(struct resolver_query *query, int af, const char *hostname, - void (*callback)(struct resolver_query *, int, - union sockunion *)) + void (*callback)(struct resolver_query *, const char *, + int, union sockunion *)) { int ret; diff --git a/lib/resolver.h b/lib/resolver.h index a418377a2..59bf0d0f5 100644 --- a/lib/resolver.h +++ b/lib/resolver.h @@ -14,7 +14,8 @@ #include "sockunion.h" struct resolver_query { - void (*callback)(struct resolver_query *, int n, union sockunion *); + void (*callback)(struct resolver_query *, const char *errstr, int n, + union sockunion *); /* used to immediate provide the result if IP literal is passed in */ union sockunion literal_addr; @@ -24,6 +25,7 @@ struct resolver_query { void resolver_init(struct thread_master *tm); void resolver_resolve(struct resolver_query *query, int af, const char *hostname, void (*cb)(struct resolver_query *, - int, union sockunion *)); + const char *, int, + union sockunion *)); #endif /* _FRR_RESOLVER_H */ |