mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-09 13:19:17 +00:00
Merge pull request #7764 from pguibert6WIND/nhrp_shortcut_routes
nhrp: fix shortcut routes
This commit is contained in:
commit
b1b277fbd2
@ -98,6 +98,7 @@ void nhrp_route_announce(int add, enum nhrp_cache_type type,
|
|||||||
{
|
{
|
||||||
struct zapi_route api;
|
struct zapi_route api;
|
||||||
struct zapi_nexthop *api_nh;
|
struct zapi_nexthop *api_nh;
|
||||||
|
union sockunion *nexthop_ref = (union sockunion *)nexthop;
|
||||||
|
|
||||||
if (zclient->sock < 0)
|
if (zclient->sock < 0)
|
||||||
return;
|
return;
|
||||||
@ -133,8 +134,14 @@ void nhrp_route_announce(int add, enum nhrp_cache_type type,
|
|||||||
|
|
||||||
switch (api.prefix.family) {
|
switch (api.prefix.family) {
|
||||||
case AF_INET:
|
case AF_INET:
|
||||||
if (nexthop) {
|
if (api.prefix.prefixlen == IPV4_MAX_BITLEN &&
|
||||||
api_nh->gate.ipv4 = nexthop->sin.sin_addr;
|
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;
|
api_nh->type = NEXTHOP_TYPE_IPV4;
|
||||||
}
|
}
|
||||||
if (ifp) {
|
if (ifp) {
|
||||||
@ -146,8 +153,14 @@ void nhrp_route_announce(int add, enum nhrp_cache_type type,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case AF_INET6:
|
case AF_INET6:
|
||||||
if (nexthop) {
|
if (api.prefix.prefixlen == IPV6_MAX_BITLEN &&
|
||||||
api_nh->gate.ipv6 = nexthop->sin6.sin6_addr;
|
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;
|
api_nh->type = NEXTHOP_TYPE_IPV6;
|
||||||
}
|
}
|
||||||
if (ifp) {
|
if (ifp) {
|
||||||
@ -170,7 +183,8 @@ void nhrp_route_announce(int add, enum nhrp_cache_type type,
|
|||||||
zlog_debug(
|
zlog_debug(
|
||||||
"Zebra send: route %s %pFX nexthop %s metric %u count %d dev %s",
|
"Zebra send: route %s %pFX nexthop %s metric %u count %d dev %s",
|
||||||
add ? "add" : "del", &api.prefix,
|
add ? "add" : "del", &api.prefix,
|
||||||
nexthop ? inet_ntop(api.prefix.family, &api_nh->gate,
|
nexthop_ref ? inet_ntop(api.prefix.family,
|
||||||
|
&api_nh->gate,
|
||||||
buf, sizeof(buf))
|
buf, sizeof(buf))
|
||||||
: "<onlink>",
|
: "<onlink>",
|
||||||
api.metric, api.nexthop_num, ifp ? ifp->name : "none");
|
api.metric, api.nexthop_num, ifp ? ifp->name : "none");
|
||||||
|
@ -51,18 +51,26 @@ static int nhrp_shortcut_do_expire(struct thread *t)
|
|||||||
static void nhrp_shortcut_cache_notify(struct notifier_block *n,
|
static void nhrp_shortcut_cache_notify(struct notifier_block *n,
|
||||||
unsigned long cmd)
|
unsigned long cmd)
|
||||||
{
|
{
|
||||||
|
char buf2[PREFIX_STRLEN];
|
||||||
|
|
||||||
struct nhrp_shortcut *s =
|
struct nhrp_shortcut *s =
|
||||||
container_of(n, struct nhrp_shortcut, cache_notifier);
|
container_of(n, struct nhrp_shortcut, cache_notifier);
|
||||||
|
struct nhrp_cache *c = s->cache;
|
||||||
|
|
||||||
|
if (c)
|
||||||
|
sockunion2str(&c->remote_addr, buf2, sizeof(buf2));
|
||||||
|
else
|
||||||
|
snprintf(buf2, sizeof(buf2), "(unspec)");
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case NOTIFY_CACHE_UP:
|
case NOTIFY_CACHE_UP:
|
||||||
if (!s->route_installed) {
|
if (!s->route_installed) {
|
||||||
debugf(NHRP_DEBUG_ROUTE,
|
debugf(NHRP_DEBUG_ROUTE,
|
||||||
"Shortcut: route install %pFX nh (unspec) dev %s",
|
"Shortcut: route install %pFX nh %s dev %s",
|
||||||
s->p, s->cache->ifp->name);
|
s->p, buf2, c && c->ifp ?
|
||||||
|
c->ifp->name : "<unk>");
|
||||||
|
|
||||||
nhrp_route_announce(1, s->type, s->p, s->cache->ifp,
|
nhrp_route_announce(1, s->type, s->p, c ? c->ifp : NULL,
|
||||||
&s->cache->remote_addr, 0);
|
c ? &c->remote_addr : NULL, 0);
|
||||||
s->route_installed = 1;
|
s->route_installed = 1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
Loading…
Reference in New Issue
Block a user