summaryrefslogtreecommitdiff
path: root/nest/neighbor.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2019-07-24 15:08:03 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2019-07-24 15:08:03 +0200
commit18f70a6229f586d5e4f387075be42d7a1ef5d269 (patch)
treeaa4f99f5eb0dbb62e36f820dea5e53b7522fd1b4 /nest/neighbor.c
parent048c2f0e8cc1451b1fa48e915e0bb5e124aa9d26 (diff)
Nest: VRF of protocol can be explicitly specified as 'default'
Protocol can have specified VRF, in such case it is restricted to a set of ifaces associated with the VRF, otherwise it can use all interfaces. The patch allows to specify VRF as 'default', in which case it is restricted to a set of iface not associated with any VRF.
Diffstat (limited to 'nest/neighbor.c')
-rw-r--r--nest/neighbor.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/nest/neighbor.c b/nest/neighbor.c
index 87253857..00a8e8a5 100644
--- a/nest/neighbor.c
+++ b/nest/neighbor.c
@@ -116,7 +116,7 @@ if_connected(ip_addr a, struct iface *i, struct ifa **ap, uint flags)
}
static inline int
-if_connected_any(ip_addr a, struct iface *vrf, struct iface **iface, struct ifa **addr, uint flags)
+if_connected_any(ip_addr a, struct iface *vrf, uint vrf_set, struct iface **iface, struct ifa **addr, uint flags)
{
struct iface *i;
struct ifa *b;
@@ -127,7 +127,7 @@ if_connected_any(ip_addr a, struct iface *vrf, struct iface **iface, struct ifa
/* Get first match, but prefer SCOPE_HOST to other matches */
WALK_LIST(i, iface_list)
- if ((!vrf || vrf == i->master) && ((s = if_connected(a, i, &b, flags)) >= 0))
+ if ((!vrf_set || vrf == i->master) && ((s = if_connected(a, i, &b, flags)) >= 0))
if ((scope < 0) || ((scope > SCOPE_HOST) && (s == SCOPE_HOST)))
{
*iface = i;
@@ -192,7 +192,7 @@ neigh_find(struct proto *p, ip_addr a, struct iface *iface, uint flags)
iface = (scope < 0) ? NULL : iface;
}
else
- scope = if_connected_any(a, p->vrf, &iface, &addr, flags);
+ scope = if_connected_any(a, p->vrf, p->vrf_set, &iface, &addr, flags);
/* scope < 0 means i don't know neighbor */
/* scope >= 0 <=> iface != NULL */
@@ -309,6 +309,7 @@ neigh_free(neighbor *n)
void
neigh_update(neighbor *n, struct iface *iface)
{
+ struct proto *p = n->proto;
struct ifa *ifa = NULL;
int scope = -1;
@@ -317,14 +318,14 @@ neigh_update(neighbor *n, struct iface *iface)
return;
/* VRF-bound neighbors ignore changes in other VRFs */
- if (n->proto->vrf && (n->proto->vrf != iface->master))
+ if (p->vrf_set && (p->vrf != iface->master))
return;
scope = if_connected(n->addr, iface, &ifa, n->flags);
/* When neighbor is going down, try to respawn it on other ifaces */
if ((scope < 0) && (n->scope >= 0) && !n->ifreq && (n->flags & NEF_STICKY))
- scope = if_connected_any(n->addr, n->proto->vrf, &iface, &ifa, n->flags);
+ scope = if_connected_any(n->addr, p->vrf, p->vrf_set, &iface, &ifa, n->flags);
/* No change or minor change - ignore or notify */
if ((scope == n->scope) && (iface == n->iface))