diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-05 09:55:46 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-05 09:55:46 +0000 |
commit | 4f40546c96c6aeaa4371161dca9db21071bcc5d2 (patch) | |
tree | 41199f3c71bb1b62bdee8e83577351f6ee70d031 /lib | |
parent | Adding upstream version 10.0. (diff) | |
download | frr-4f40546c96c6aeaa4371161dca9db21071bcc5d2.tar.xz frr-4f40546c96c6aeaa4371161dca9db21071bcc5d2.zip |
Adding upstream version 10.0.1.upstream/10.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/command.c | 2 | ||||
-rw-r--r-- | lib/libfrr.c | 2 | ||||
-rw-r--r-- | lib/nexthop.c | 8 | ||||
-rw-r--r-- | lib/nexthop.h | 4 | ||||
-rw-r--r-- | lib/resolver.c | 67 | ||||
-rw-r--r-- | lib/vrf.c | 2 |
6 files changed, 72 insertions, 13 deletions
diff --git a/lib/command.c b/lib/command.c index fa26072..8f780d0 100644 --- a/lib/command.c +++ b/lib/command.c @@ -1356,7 +1356,7 @@ DEFUN (disable, } /* Down vty node level. */ -DEFUN (config_exit, +DEFUN_YANG (config_exit, config_exit_cmd, "exit", "Exit current mode and down to previous mode\n") diff --git a/lib/libfrr.c b/lib/libfrr.c index 9e47205..2861ebe 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -957,8 +957,6 @@ static void frr_daemonize(void) } close(fds[1]); - nb_terminate(); - yang_terminate(); frr_daemon_wait(fds[0]); } diff --git a/lib/nexthop.c b/lib/nexthop.c index 4ddb53c..243b52d 100644 --- a/lib/nexthop.c +++ b/lib/nexthop.c @@ -1150,11 +1150,7 @@ static ssize_t printfrr_nh(struct fbuf *buf, struct printfrr_eargs *ea, return -1; } -bool nexthop_is_ifindex_type(const struct nexthop *nh) +bool nexthop_is_blackhole(const struct nexthop *nh) { - if (nh->type == NEXTHOP_TYPE_IFINDEX || - nh->type == NEXTHOP_TYPE_IPV4_IFINDEX || - nh->type == NEXTHOP_TYPE_IPV6_IFINDEX) - return true; - return false; + return nh->type == NEXTHOP_TYPE_BLACKHOLE; } diff --git a/lib/nexthop.h b/lib/nexthop.h index bed6447..958d06a 100644 --- a/lib/nexthop.h +++ b/lib/nexthop.h @@ -240,8 +240,8 @@ extern struct nexthop *nexthop_dup(const struct nexthop *nexthop, extern struct nexthop *nexthop_dup_no_recurse(const struct nexthop *nexthop, struct nexthop *rparent); -/* Check nexthop of IFINDEX type */ -extern bool nexthop_is_ifindex_type(const struct nexthop *nh); +/* Is this nexthop a blackhole? */ +extern bool nexthop_is_blackhole(const struct nexthop *nh); /* * Parse one or more backup index values, as comma-separated numbers, diff --git a/lib/resolver.c b/lib/resolver.c index d8245e3..901ccf8 100644 --- a/lib/resolver.c +++ b/lib/resolver.c @@ -104,7 +104,7 @@ static void resolver_cb_timeout(struct event *t) { struct resolver_state *r = EVENT_ARG(t); - ares_process(r->channel, NULL, NULL); + ares_process_fd(r->channel, ARES_SOCKET_BAD, ARES_SOCKET_BAD); resolver_update_timeouts(r); } @@ -179,7 +179,56 @@ static void ares_socket_cb(void *data, ares_socket_t fd, int readable, resolver_fd_drop_maybe(resfd); } +#if (ARES_VERSION >= 0x011c00) +static void ares_address_cb(void *arg, int status, int timeouts, + struct ares_addrinfo *result) +{ + struct resolver_query *query = (struct resolver_query *)arg; + union sockunion addr[16]; + void (*callback)(struct resolver_query *q, const char *err, int ret, + union sockunion *s); + size_t i; + struct ares_addrinfo_node *node; + callback = query->callback; + query->callback = NULL; + + if (status != ARES_SUCCESS) { + if (resolver_debug) + zlog_debug("[%p] Resolving failed (%s)", + query, ares_strerror(status)); + + callback(query, ares_strerror(status), -1, NULL); + if (result) + ares_freeaddrinfo(result); + return; + } + + + node = result->nodes; + for (i = 0; i < array_size(addr) && node; i++) { + memset(&addr[i], 0, sizeof(addr[i])); + addr[i].sa.sa_family = node->ai_family; + switch (node->ai_family) { + case AF_INET: + memcpy(&addr[i].sin.sin_addr, node->ai_addr, + node->ai_addrlen); + break; + case AF_INET6: + memcpy(&addr[i].sin6.sin6_addr, node->ai_addr, + node->ai_addrlen); + break; + } + node = node->ai_next; + } + + if (resolver_debug) + zlog_debug("[%p] Resolved with %d results", query, (int)i); + + callback(query, NULL, i, &addr[0]); + ares_freeaddrinfo(result); +} +#else static void ares_address_cb(void *arg, int status, int timeouts, struct hostent *he) { @@ -222,6 +271,8 @@ static void ares_address_cb(void *arg, int status, int timeouts, callback(query, NULL, i, &addr[0]); } +#endif + static void resolver_cb_literal(struct event *t) { struct resolver_query *query = EVENT_ARG(t); @@ -240,6 +291,14 @@ void resolver_resolve(struct resolver_query *query, int af, vrf_id_t vrf_id, int, union sockunion *)) { int ret; +#if (ARES_VERSION >= 0x011c00) + struct ares_addrinfo_hints hints = { + .ai_flags = 0, + .ai_family = af, + .ai_socktype = 0, /* any of SOCK_STREAM or SOCK_DGRAM */ + .ai_protocol = 0 /* any protocol */ + }; +#endif if (hostname == NULL) return; @@ -278,7 +337,13 @@ void resolver_resolve(struct resolver_query *query, int af, vrf_id_t vrf_id, __func__, vrf_id, safe_strerror(errno)); return; } + +#if (ARES_VERSION >= 0x011c00) + ares_getaddrinfo(state.channel, hostname, NULL, &hints, ares_address_cb, + query); +#else ares_gethostbyname(state.channel, hostname, af, ares_address_cb, query); +#endif ret = vrf_switchback_to_initial(); if (ret < 0) flog_err_sys(EC_LIB_SOCKET, @@ -636,7 +636,7 @@ int vrf_configure_backend(enum vrf_backend_type backend) } /* vrf CLI commands */ -DEFUN_NOSH(vrf_exit, +DEFUN_YANG_NOSH (vrf_exit, vrf_exit_cmd, "exit-vrf", "Exit current mode and down to previous mode\n") |