Fixed a couple of bugs in static protocol. All static routes except device

ones seem to work well.
This commit is contained in:
Martin Mares 1998-12-08 18:31:31 +00:00
parent 618533af91
commit 980297d289
2 changed files with 29 additions and 16 deletions

View file

@ -65,30 +65,42 @@ static_start(struct proto *P)
DBG("Static: take off!\n"); DBG("Static: take off!\n");
WALK_LIST(r, p->other_routes) WALK_LIST(r, p->other_routes)
if (r->dest == RTD_ROUTER) switch (r->dest)
{ {
struct neighbor *n = neigh_find(P, &r->via, NEF_STICKY); case RTD_ROUTER:
if (n) {
{ struct neighbor *n = neigh_find(P, &r->via, NEF_STICKY);
n->data = r; if (n)
r->neigh = n; {
static_install(p, r, n->iface); r->chain = n->data;
} n->data = r;
else r->neigh = n;
log(L_ERR "Static route destination %I is invalid. Ignoring.\n", r->via); static_install(p, r, n->iface);
}
else
log(L_ERR "Static route destination %I is invalid. Ignoring.\n", r->via);
break;
}
case RTD_DEVICE:
die("Static device routes are not supported");
/* FIXME: Static device routes */
default:
static_install(p, r, NULL);
} }
else
static_install(p, r, NULL);
} }
static void static void
static_neigh_notify(struct neighbor *n) static_neigh_notify(struct neighbor *n)
{ {
struct static_proto *p = (struct static_proto *) n->proto;
struct static_route *r;
DBG("Static: neighbor notify for %I: iface %p\n", n->addr, n->iface); DBG("Static: neighbor notify for %I: iface %p\n", n->addr, n->iface);
if (n->iface) for(r=n->data; r; r=r->chain)
static_install((struct static_proto *) n->proto, n->data, n->iface); if (n->iface)
else static_install(p, r, n->iface);
static_remove((struct static_proto *) n->proto, n->data); else
static_remove(p, r);
} }
static void static void

View file

@ -19,6 +19,7 @@ void static_init_instance(struct static_proto *);
struct static_route { struct static_route {
node n; node n;
struct static_route *chain; /* Next for the same neighbor */
ip_addr net; /* Network we route */ ip_addr net; /* Network we route */
int masklen; /* Mask length */ int masklen; /* Mask length */
int dest; /* Destination type (RTD_*) */ int dest; /* Destination type (RTD_*) */