summaryrefslogtreecommitdiffstats
path: root/nhrpd/nhrp_route.c
diff options
context:
space:
mode:
authorJafar Al-Gharaibeh <Jafaral@users.noreply.github.com>2021-02-12 20:34:40 +0100
committerGitHub <noreply@github.com>2021-02-12 20:34:40 +0100
commitb1b277fbd284a30090caf1ad3094b6ee6cf308d2 (patch)
treebb84591c3cb8de155a97eaae6aa240ff977cc2ff /nhrpd/nhrp_route.c
parentMerge pull request #8039 from m-varasteh/master (diff)
parentnhrpd: replace nhrp route nexthop with onlink route when prefix=nh (diff)
downloadfrr-b1b277fbd284a30090caf1ad3094b6ee6cf308d2.tar.xz
frr-b1b277fbd284a30090caf1ad3094b6ee6cf308d2.zip
Merge pull request #7764 from pguibert6WIND/nhrp_shortcut_routes
nhrp: fix shortcut routes
Diffstat (limited to 'nhrpd/nhrp_route.c')
-rw-r--r--nhrpd/nhrp_route.c26
1 files changed, 20 insertions, 6 deletions
diff --git a/nhrpd/nhrp_route.c b/nhrpd/nhrp_route.c
index ce2b1fe2f..334f468c1 100644
--- a/nhrpd/nhrp_route.c
+++ b/nhrpd/nhrp_route.c
@@ -98,6 +98,7 @@ void nhrp_route_announce(int add, enum nhrp_cache_type type,
{
struct zapi_route api;
struct zapi_nexthop *api_nh;
+ union sockunion *nexthop_ref = (union sockunion *)nexthop;
if (zclient->sock < 0)
return;
@@ -133,8 +134,14 @@ void nhrp_route_announce(int add, enum nhrp_cache_type type,
switch (api.prefix.family) {
case AF_INET:
- if (nexthop) {
- api_nh->gate.ipv4 = nexthop->sin.sin_addr;
+ if (api.prefix.prefixlen == IPV4_MAX_BITLEN &&
+ nexthop_ref &&
+ memcmp(&nexthop_ref->sin.sin_addr, &api.prefix.u.prefix4,
+ sizeof(struct in_addr)) == 0) {
+ nexthop_ref = NULL;
+ }
+ if (nexthop_ref) {
+ api_nh->gate.ipv4 = nexthop_ref->sin.sin_addr;
api_nh->type = NEXTHOP_TYPE_IPV4;
}
if (ifp) {
@@ -146,8 +153,14 @@ void nhrp_route_announce(int add, enum nhrp_cache_type type,
}
break;
case AF_INET6:
- if (nexthop) {
- api_nh->gate.ipv6 = nexthop->sin6.sin6_addr;
+ if (api.prefix.prefixlen == IPV6_MAX_BITLEN &&
+ nexthop_ref &&
+ memcmp(&nexthop_ref->sin6.sin6_addr, &api.prefix.u.prefix6,
+ sizeof(struct in6_addr)) == 0) {
+ nexthop_ref = NULL;
+ }
+ if (nexthop_ref) {
+ api_nh->gate.ipv6 = nexthop_ref->sin6.sin6_addr;
api_nh->type = NEXTHOP_TYPE_IPV6;
}
if (ifp) {
@@ -170,8 +183,9 @@ void nhrp_route_announce(int add, enum nhrp_cache_type type,
zlog_debug(
"Zebra send: route %s %pFX nexthop %s metric %u count %d dev %s",
add ? "add" : "del", &api.prefix,
- nexthop ? inet_ntop(api.prefix.family, &api_nh->gate,
- buf, sizeof(buf))
+ nexthop_ref ? inet_ntop(api.prefix.family,
+ &api_nh->gate,
+ buf, sizeof(buf))
: "<onlink>",
api.metric, api.nexthop_num, ifp ? ifp->name : "none");
}