nhrpd: Create route to private spoke-spoke network correctly

Currently when the first traffic to a private network causes a shortcut, an
on-link route to the private network is created on the gre interface, along
with the cache entry.

When connecting to a second IP in the same network, the kernel tries to resolve
the public IP for this private network via query to NHRP. nhrpd sees no entry
in the cache, so the packet is dropped.

The fix to this solution can be instead of creating an on-link route, create an
off-link route to private network, with the next-hop being the remote tunnel's
gre IP address.

Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
This commit is contained in:
Gaurav Goyal 2020-11-02 12:11:19 +13:00 committed by Reuben Dowle
parent ddd8d8c845
commit ac95bcefe4

View File

@ -62,7 +62,7 @@ static void nhrp_shortcut_cache_notify(struct notifier_block *n,
s->p, s->cache->ifp->name);
nhrp_route_announce(1, s->type, s->p, s->cache->ifp,
NULL, 0);
&s->cache->remote_addr, 0);
s->route_installed = 1;
}
break;
@ -207,6 +207,7 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid,
struct nhrp_extension_header *ext;
struct nhrp_cie_header *cie;
struct nhrp_cache *c = NULL;
struct nhrp_cache *c_dst_proto = NULL;
union sockunion *proto, cie_proto, *nbma, cie_nbma, nat_nbma;
struct prefix prefix, route_prefix;
struct zbuf extpl;
@ -304,6 +305,22 @@ static void nhrp_shortcut_recv_resolution_rep(struct nhrp_reqid *reqid,
debugf(NHRP_DEBUG_COMMON,
"Shortcut: no cache for nbma %s", buf[2]);
}
/* Update cache binding for dst_proto as well */
if (proto != &pp->dst_proto) {
c_dst_proto = nhrp_cache_get(pp->ifp, &pp->dst_proto, 1);
if (c_dst_proto) {
debugf(NHRP_DEBUG_COMMON,
"Shortcut: cache found, update binding");
nhrp_cache_update_binding(c_dst_proto, NHRP_CACHE_DYNAMIC,
holding_time,
nhrp_peer_get(pp->ifp, nbma),
htons(cie->mtu), nbma);
} else {
debugf(NHRP_DEBUG_COMMON,
"Shortcut: no cache for nbma %s", buf[2]);
}
}
}
/* Update shortcut entry for subnet to protocol gw binding */