mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-11-17 08:38:42 +00:00
Learn static device routes from the kernel (temporary until we can make
such things configurable).
This commit is contained in:
parent
feb6abe009
commit
756b86dea3
@ -29,7 +29,37 @@ static int krt_scan_fd = -1;
|
|||||||
/* FIXME: Filtering */
|
/* FIXME: Filtering */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
krt_parse_entry(byte *e)
|
krt_magic_route(struct krt_proto *p, net *net, ip_addr gw)
|
||||||
|
{
|
||||||
|
neighbor *ng;
|
||||||
|
rta a, *t;
|
||||||
|
rte *e;
|
||||||
|
|
||||||
|
ng = neigh_find(&p->p, &gw, 0);
|
||||||
|
if (!ng)
|
||||||
|
{
|
||||||
|
log(L_ERR "Kernel told us to use non-neighbor %I for %I/%d\n", gw, net->n.prefix, net->n.pxlen);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
a.proto = &p->p;
|
||||||
|
a.source = RTS_INHERIT;
|
||||||
|
a.scope = SCOPE_UNIVERSE;
|
||||||
|
a.cast = RTC_UNICAST;
|
||||||
|
a.dest = RTD_ROUTER;
|
||||||
|
a.tos = 0;
|
||||||
|
a.flags = 0;
|
||||||
|
a.gw = gw;
|
||||||
|
a.from = IPA_NONE;
|
||||||
|
a.iface = ng->iface;
|
||||||
|
a.attrs = NULL;
|
||||||
|
t = rta_lookup(&a);
|
||||||
|
e = rte_get_temp(t);
|
||||||
|
e->net = net;
|
||||||
|
rte_update(net, &p->p, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
krt_parse_entry(byte *e, struct krt_proto *p)
|
||||||
{
|
{
|
||||||
u32 dest0, gw0, mask0;
|
u32 dest0, gw0, mask0;
|
||||||
ip_addr dest, gw, mask;
|
ip_addr dest, gw, mask;
|
||||||
@ -101,13 +131,17 @@ krt_parse_entry(byte *e)
|
|||||||
return;
|
return;
|
||||||
#endif
|
#endif
|
||||||
DBG("krt_parse_entry: kernel reporting unknown route %I/%d\n", dest, masklen);
|
DBG("krt_parse_entry: kernel reporting unknown route %I/%d\n", dest, masklen);
|
||||||
/* FIXME: should be able to learn kernel routes */
|
#if 1
|
||||||
|
/* FIXME: should be configurable */
|
||||||
|
if (flags & RTF_GATEWAY)
|
||||||
|
krt_magic_route(p, net, gw);
|
||||||
|
#endif
|
||||||
net->n.flags |= KRF_UPDATE;
|
net->n.flags |= KRF_UPDATE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
krt_scan_proc(void)
|
krt_scan_proc(struct krt_proto *p)
|
||||||
{
|
{
|
||||||
byte buf[32768];
|
byte buf[32768];
|
||||||
int l, seen_hdr;
|
int l, seen_hdr;
|
||||||
@ -136,7 +170,7 @@ krt_scan_proc(void)
|
|||||||
while (l >= 128)
|
while (l >= 128)
|
||||||
{
|
{
|
||||||
if (seen_hdr++)
|
if (seen_hdr++)
|
||||||
krt_parse_entry(z);
|
krt_parse_entry(z, p);
|
||||||
z += 128;
|
z += 128;
|
||||||
l -= 128;
|
l -= 128;
|
||||||
}
|
}
|
||||||
@ -190,7 +224,9 @@ krt_prune(void)
|
|||||||
static void
|
static void
|
||||||
krt_scan_fire(timer *t)
|
krt_scan_fire(timer *t)
|
||||||
{
|
{
|
||||||
if (krt_scan_proc())
|
struct krt_proto *p = t->data;
|
||||||
|
|
||||||
|
if (krt_scan_proc(p))
|
||||||
krt_prune();
|
krt_prune();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user