diff options
| author | Philippe Guibert <philippe.guibert@6wind.com> | 2019-08-29 16:27:00 +0200 |
|---|---|---|
| committer | Philippe Guibert <philippe.guibert@6wind.com> | 2021-11-23 09:02:23 +0100 |
| commit | c742573b67f9b1be953da8f67f417182e7e5dbcb (patch) | |
| tree | ef43653783f7113fbcbdfeeadf9d3bae09f39aec /lib/resolver.c | |
| parent | 56cc2c987d323b97a2229d536fbc8ef88dd6bfc7 (diff) | |
lib: resolver per vrf support
add a parameter to resolver api that is the vrf identifier. this permits
to make resolution self to each vrf. in case vrf netns backend is used,
this is very practical, since resolution can happen on one netns, while
it is not the case in an other one.
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
Diffstat (limited to 'lib/resolver.c')
| -rw-r--r-- | lib/resolver.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/resolver.c b/lib/resolver.c index e3dba5f8ae..29138bbc8d 100644 --- a/lib/resolver.c +++ b/lib/resolver.c @@ -21,6 +21,7 @@ #include "resolver.h" #include "command.h" #include "xref.h" +#include "vrf.h" XREF_SETUP(); @@ -244,7 +245,7 @@ static int resolver_cb_literal(struct thread *t) return 0; } -void resolver_resolve(struct resolver_query *query, int af, +void resolver_resolve(struct resolver_query *query, int af, vrf_id_t vrf_id, const char *hostname, void (*callback)(struct resolver_query *, const char *, int, union sockunion *)) @@ -279,7 +280,18 @@ void resolver_resolve(struct resolver_query *query, int af, if (resolver_debug) zlog_debug("[%p] Resolving '%s'", query, hostname); + ret = vrf_switch_to_netns(vrf_id); + if (ret < 0) { + flog_err_sys(EC_LIB_SOCKET, "%s: Can't switch to VRF %u (%s)", + __func__, vrf_id, safe_strerror(errno)); + return; + } ares_gethostbyname(state.channel, hostname, af, ares_address_cb, query); + ret = vrf_switchback_to_initial(); + if (ret < 0) + flog_err_sys(EC_LIB_SOCKET, + "%s: Can't switchback from VRF %u (%s)", __func__, + vrf_id, safe_strerror(errno)); resolver_update_timeouts(&state); } |
