summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2017-09-12 15:49:36 +0200
committerOndrej Zajicek (work) <santiago@crfreenet.org>2017-09-12 15:49:36 +0200
commit9f4908fe78cb3e5191bca721588ee1acb10876e3 (patch)
tree93a6d5858e941ebec3b7acc99e6225b5011176bc
parent943478b00f585725c3e7406909ee867dcfac5f87 (diff)
Nest: VRF support for neighbor cache and olock code
Actually much simpler than expected.
-rw-r--r--nest/locks.c1
-rw-r--r--nest/locks.h1
-rw-r--r--nest/neighbor.c8
-rw-r--r--proto/bgp/bgp.c1
-rw-r--r--proto/radv/radv.c1
5 files changed, 8 insertions, 4 deletions
diff --git a/nest/locks.c b/nest/locks.c
index 84b8b0ae..86c9ff14 100644
--- a/nest/locks.c
+++ b/nest/locks.c
@@ -45,6 +45,7 @@ olock_same(struct object_lock *x, struct object_lock *y)
return
x->type == y->type &&
x->iface == y->iface &&
+ x->vrf == y->vrf &&
x->port == y->port &&
x->inst == y->inst &&
ipa_equal(x->addr, y->addr);
diff --git a/nest/locks.h b/nest/locks.h
index 3d58c8ed..37026c68 100644
--- a/nest/locks.h
+++ b/nest/locks.h
@@ -30,6 +30,7 @@ struct object_lock {
uint port; /* ... port number */
uint inst; /* ... instance ID */
struct iface *iface; /* ... interface */
+ struct iface *vrf; /* ... or VRF (if iface is unknown) */
void (*hook)(struct object_lock *); /* Called when the lock succeeds */
void *data; /* User data */
/* ... internal to lock manager, don't touch ... */
diff --git a/nest/neighbor.c b/nest/neighbor.c
index d974fa51..f8159d35 100644
--- a/nest/neighbor.c
+++ b/nest/neighbor.c
@@ -30,7 +30,8 @@
* when the protocol has explicitly requested it via the %NEF_STICKY
* flag because it wishes to be notified when the node will again become
* a neighbor. Such entries are enqueued in a special list which is walked
- * whenever an interface changes its state to up.
+ * whenever an interface changes its state to up. Neighbor entry VRF
+ * association is implied by respective protocol.
*
* When a neighbor event occurs (a neighbor gets disconnected or a sticky
* inactive neighbor becomes connected), the protocol hook neigh_notify()
@@ -152,8 +153,9 @@ neigh_find2(struct proto *p, ip_addr *a, struct iface *ifa, unsigned flags)
}
else
WALK_LIST(i, iface_list)
- if ((scope = if_connected(a, i, &addr)) >= 0)
- {
+ if ((!p->vrf || p->vrf == i->master) &&
+ ((scope = if_connected(a, i, &addr)) >= 0))
+ {
ifa = i;
break;
}
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index 913685a4..8a6b2f02 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -1181,6 +1181,7 @@ bgp_start(struct proto *P)
lock->addr = p->cf->remote_ip;
lock->port = p->cf->remote_port;
lock->iface = p->cf->iface;
+ lock->vrf = p->cf->iface ? NULL : p->p.vrf;
lock->type = OBJLOCK_TCP;
lock->hook = bgp_start_locked;
lock->data = p;
diff --git a/proto/radv/radv.c b/proto/radv/radv.c
index 227c8ef6..c53a0a95 100644
--- a/proto/radv/radv.c
+++ b/proto/radv/radv.c
@@ -321,7 +321,6 @@ radv_iface_new(struct radv_proto *p, struct iface *iface, struct radv_iface_conf
ifa->timer = tm;
struct object_lock *lock = olock_new(pool);
- lock->addr = IPA_NONE;
lock->type = OBJLOCK_IP;
lock->port = ICMPV6_PROTO;
lock->iface = iface;