summaryrefslogtreecommitdiff
path: root/proto
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2012-01-01 12:02:20 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2012-01-01 12:14:42 +0100
commit69a8259c5e438f949bd58b1a2f8e1d12a49f9216 (patch)
tree5d685368ce58732ce4a9133b5f5bc43b20b78476 /proto
parentc32c3f88f0c8788118ed3701c11a5aea2aaf9356 (diff)
Allows sticky link-local neighbors.
Allows using NEF_STICKY neighbors with link-local addresses. This is used for static route nexthops, they can be specified like fe80::1%eth0 .
Diffstat (limited to 'proto')
-rw-r--r--proto/bgp/bgp.c2
-rw-r--r--proto/static/config.Y6
-rw-r--r--proto/static/static.c14
-rw-r--r--proto/static/static.h1
4 files changed, 12 insertions, 11 deletions
diff --git a/proto/bgp/bgp.c b/proto/bgp/bgp.c
index 28396a52..6bd18f09 100644
--- a/proto/bgp/bgp.c
+++ b/proto/bgp/bgp.c
@@ -804,7 +804,7 @@ bgp_start_locked(struct object_lock *lock)
return;
}
- if (p->neigh->iface)
+ if (p->neigh->scope > 0)
bgp_start_neighbor(p);
else
BGP_TRACE(D_EVENTS, "Waiting for %I to become my neighbor", cf->remote_ip);
diff --git a/proto/static/config.Y b/proto/static/config.Y
index 621fdf9b..f8e84f92 100644
--- a/proto/static/config.Y
+++ b/proto/static/config.Y
@@ -48,11 +48,12 @@ stat_route0: ROUTE prefix {
;
stat_multipath1:
- VIA ipa {
+ VIA ipa ipa_scope {
last_srt_nh = this_srt_nh;
this_srt_nh = cfg_allocz(sizeof(struct static_route));
this_srt_nh->dest = RTD_NONE;
this_srt_nh->via = $2;
+ this_srt_nh->via_if = $3;
this_srt_nh->if_name = (void *) this_srt; /* really */
}
| stat_multipath1 WEIGHT expr {
@@ -67,9 +68,10 @@ stat_multipath:
;
stat_route:
- stat_route0 VIA ipa {
+ stat_route0 VIA ipa ipa_scope {
this_srt->dest = RTD_ROUTER;
this_srt->via = $3;
+ this_srt->via_if = $4;
}
| stat_route0 VIA TEXT {
this_srt->dest = RTD_DEVICE;
diff --git a/proto/static/static.c b/proto/static/static.c
index e5b293c0..3323c7ee 100644
--- a/proto/static/static.c
+++ b/proto/static/static.c
@@ -138,12 +138,10 @@ static_decide(struct static_config *cf, struct static_route *r)
/* r->dest != RTD_MULTIPATH, but may be RTD_NONE (part of multipath route)
the route also have to be valid (r->neigh != NULL) */
- struct iface *ifa = r->neigh->iface;
-
- if (!ifa)
+ if (r->neigh->scope < 0)
return 0;
- if (cf->check_link && !(ifa->flags & IF_LINK_UP))
+ if (cf->check_link && !(r->neigh->iface->flags & IF_LINK_UP))
return 0;
return 1;
@@ -158,7 +156,7 @@ static_add(struct proto *p, struct static_config *cf, struct static_route *r)
{
case RTD_ROUTER:
{
- struct neighbor *n = neigh_find(p, &r->via, NEF_STICKY);
+ struct neighbor *n = neigh_find2(p, &r->via, r->via_if, NEF_STICKY);
if (n)
{
r->chain = n->data;
@@ -187,7 +185,7 @@ static_add(struct proto *p, struct static_config *cf, struct static_route *r)
for (r2 = r->mp_next; r2; r2 = r2->mp_next)
{
- struct neighbor *n = neigh_find(p, &r2->via, NEF_STICKY);
+ struct neighbor *n = neigh_find2(p, &r2->via, r2->via_if, NEF_STICKY);
if (n)
{
r2->chain = n->data;
@@ -385,7 +383,7 @@ static_same_dest(struct static_route *x, struct static_route *y)
switch (x->dest)
{
case RTD_ROUTER:
- return ipa_equal(x->via, y->via);
+ return ipa_equal(x->via, y->via) && (x->via_if == y->via_if);
case RTD_DEVICE:
return !strcmp(x->if_name, y->if_name);
@@ -394,7 +392,7 @@ static_same_dest(struct static_route *x, struct static_route *y)
for (x = x->mp_next, y = y->mp_next;
x && y;
x = x->mp_next, y = y->mp_next)
- if (!ipa_equal(x->via, y->via))
+ if (!ipa_equal(x->via, y->via) || (x->via_if != y->via_if))
return 0;
return !x && !y;
diff --git a/proto/static/static.h b/proto/static/static.h
index 775743cf..eb87ddec 100644
--- a/proto/static/static.h
+++ b/proto/static/static.h
@@ -27,6 +27,7 @@ struct static_route {
int masklen; /* Mask length */
int dest; /* Destination type (RTD_*) */
ip_addr via; /* Destination router */
+ struct iface *via_if; /* Destination iface, for link-local vias */
struct neighbor *neigh;
byte *if_name; /* Name for RTD_DEVICE routes */
struct static_route *mp_next; /* Nexthops for RTD_MULTIPATH routes */