Fixed processing of !krt_capable() routes. Converted device route decisions

to the krt_capable mechanism as well.
This commit is contained in:
Martin Mares 1999-03-04 19:00:31 +00:00
parent e16155ae4a
commit 111213f0b6
3 changed files with 17 additions and 25 deletions

View file

@ -430,6 +430,8 @@ krt_capable(rte *e)
if (a->cast != RTC_UNICAST) /* FIXME: For IPv6, we might support anycasts as well */ if (a->cast != RTC_UNICAST) /* FIXME: For IPv6, we might support anycasts as well */
return 0; return 0;
if (a->source == RTS_DEVICE) /* Kernel takes care of device routes itself */
return 0;
switch (a->dest) switch (a->dest)
{ {
case RTD_ROUTER: case RTD_ROUTER:
@ -501,9 +503,9 @@ nl_send_route(rte *e, int new)
void void
krt_set_notify(struct proto *p, net *n, rte *new, rte *old) krt_set_notify(struct proto *p, net *n, rte *new, rte *old)
{ {
if (old && old->attrs->source == RTS_DEVICE) /* Device routes are left to the kernel */ if (old && !krt_capable(old))
old = NULL; old = NULL;
if (new && new->attrs->source == RTS_DEVICE) if (new && !krt_capable(new))
new = NULL; new = NULL;
if (old && new && old->attrs->tos == new->attrs->tos) if (old && new && old->attrs->tos == new->attrs->tos)
{ {

View file

@ -26,6 +26,10 @@ krt_capable(rte *e)
{ {
rta *a = e->attrs; rta *a = e->attrs;
#ifdef CONFIG_AUTO_ROUTES
if (a->source == RTS_DEVICE)
return 0;
#endif
return return
a->cast == RTC_UNICAST && a->cast == RTC_UNICAST &&
(a->dest == RTD_ROUTER (a->dest == RTD_ROUTER
@ -37,18 +41,6 @@ krt_capable(rte *e)
!a->tos; !a->tos;
} }
static inline int
krt_capable_op(rte *e)
{
rta *a = e->attrs;
#ifdef CONFIG_AUTO_ROUTES
if (a->source == RTS_DEVICE)
return 0;
#endif
return krt_capable(e);
}
static void static void
krt_ioctl(int ioc, rte *e, char *name) krt_ioctl(int ioc, rte *e, char *name)
{ {
@ -84,12 +76,12 @@ krt_ioctl(int ioc, rte *e, char *name)
log(L_ERR "%s(%I/%d): %m", name, net->n.prefix, net->n.pxlen); log(L_ERR "%s(%I/%d): %m", name, net->n.prefix, net->n.pxlen);
} }
static void static inline void
krt_remove_route(rte *old) krt_remove_route(rte *old)
{ {
net *net = old->net; net *net = old->net;
if (!krt_capable_op(old)) if (!krt_capable(old))
{ {
DBG("krt_remove_route(ignored %I/%d)\n", net->n.prefix, net->n.pxlen); DBG("krt_remove_route(ignored %I/%d)\n", net->n.prefix, net->n.pxlen);
return; return;
@ -98,12 +90,12 @@ krt_remove_route(rte *old)
krt_ioctl(SIOCDELRT, old, "SIOCDELRT"); krt_ioctl(SIOCDELRT, old, "SIOCDELRT");
} }
static void static inline void
krt_add_route(rte *new) krt_add_route(rte *new)
{ {
net *net = new->net; net *net = new->net;
if (!krt_capable_op(new)) if (!krt_capable(new))
{ {
DBG("krt_add_route(ignored %I/%d)\n", net->n.prefix, net->n.pxlen); DBG("krt_add_route(ignored %I/%d)\n", net->n.prefix, net->n.pxlen);
return; return;
@ -115,7 +107,6 @@ krt_add_route(rte *new)
void void
krt_set_notify(struct proto *x, net *net, rte *new, rte *old) krt_set_notify(struct proto *x, net *net, rte *new, rte *old)
{ {
/* FIXME: Fold remove/add route here */
if (old) if (old)
krt_remove_route(old); krt_remove_route(old);
if (new) if (new)

View file

@ -88,12 +88,11 @@ krt_got_route(struct krt_proto *p, rte *e)
return; return;
} }
old = net->routes; if (old = net->routes)
if (old && !krt_capable(old))
old = NULL;
if (old)
{ {
if (krt_uptodate(e, net->routes)) if (!krt_capable(old))
verdict = krt_capable(e) ? KRF_DELETE : KRF_SEEN;
else if (krt_uptodate(e, net->routes))
verdict = KRF_SEEN; verdict = KRF_SEEN;
else else
verdict = KRF_UPDATE; verdict = KRF_UPDATE;
@ -156,7 +155,7 @@ krt_prune(struct krt_proto *p)
DBG("krt_prune: removing inherited %I/%d\n", n->n.prefix, n->n.pxlen); DBG("krt_prune: removing inherited %I/%d\n", n->n.prefix, n->n.pxlen);
rte_update(n, pp, NULL); rte_update(n, pp, NULL);
} }
else else if (krt_capable(new))
{ {
DBG("krt_prune: reinstalling %I/%d\n", n->n.prefix, n->n.pxlen); DBG("krt_prune: reinstalling %I/%d\n", n->n.prefix, n->n.pxlen);
krt_set_notify(pp, n, new, NULL); krt_set_notify(pp, n, new, NULL);