diff options
Diffstat (limited to 'sysdep')
-rw-r--r-- | sysdep/linux/krt-scan.Y | 4 | ||||
-rw-r--r-- | sysdep/linux/krt-scan.c | 42 | ||||
-rw-r--r-- | sysdep/linux/krt-scan.h | 7 |
3 files changed, 30 insertions, 23 deletions
diff --git a/sysdep/linux/krt-scan.Y b/sysdep/linux/krt-scan.Y index d02df113..58339895 100644 --- a/sysdep/linux/krt-scan.Y +++ b/sysdep/linux/krt-scan.Y @@ -20,11 +20,11 @@ CF_ADDTO(kern_proto, kern_proto krt_scan_item ';') krt_scan_item: LEARN bool { - ((struct krt_proto *) this_proto)->scanopt.learn = $2; + ((struct krt_config *) this_proto)->scanopt.learn = $2; } | ROUTE SCAN TIME expr { /* Scan time of 0 means scan on startup only */ - ((struct krt_proto *) this_proto)->scanopt.scan_time = $4; + ((struct krt_config *) this_proto)->scanopt.scan_time = $4; } ; diff --git a/sysdep/linux/krt-scan.c b/sysdep/linux/krt-scan.c index f1c00908..55ba3a86 100644 --- a/sysdep/linux/krt-scan.c +++ b/sysdep/linux/krt-scan.c @@ -1,7 +1,7 @@ /* * BIRD -- Linux Routing Table Scanning * - * (c) 1998 Martin Mares <mj@ucw.cz> + * (c) 1998--1999 Martin Mares <mj@ucw.cz> * * Can be freely distributed and used under the terms of the GNU GPL. */ @@ -23,7 +23,8 @@ #include "lib/unix.h" #include "lib/krt.h" -#define SCANOPT struct krt_scan_params *p = &x->scanopt +#define SCANOPT struct krt_scan_params *p = &(((struct krt_config *)(x->p.cf))->scanopt) +#define SCANSTAT struct krt_scan_status *s = &x->scanstat static int krt_scan_fd = -1; @@ -33,15 +34,16 @@ struct iface * krt_temp_iface(struct krt_proto *x, char *name) { SCANOPT; + SCANSTAT; struct iface *i; - WALK_LIST(i, p->temp_ifs) + WALK_LIST(i, s->temp_ifs) if (!strcmp(i->name, name)) return i; i = mb_alloc(x->p.pool, sizeof(struct iface)); bzero(i, sizeof(*i)); strcpy(i->name, name); - add_tail(&p->temp_ifs, &i->n); + add_tail(&s->temp_ifs, &i->n); return i; } @@ -64,8 +66,9 @@ krt_uptodate(rte *k, rte *e) } static void -krt_parse_entry(byte *ent, struct krt_proto *p) +krt_parse_entry(byte *ent, struct krt_proto *x) { + SCANOPT; u32 dest0, gw0, mask0; ip_addr dest, gw, mask; unsigned int flags, verdict; @@ -118,7 +121,7 @@ krt_parse_entry(byte *ent, struct krt_proto *p) return; } - a.proto = &p->p; + a.proto = &x->p; a.source = RTS_INHERIT; a.scope = SCOPE_UNIVERSE; a.cast = RTC_UNICAST; @@ -129,7 +132,7 @@ krt_parse_entry(byte *ent, struct krt_proto *p) if (flags & RTF_GATEWAY) { - neighbor *ng = neigh_find(&p->p, &gw, 0); + neighbor *ng = neigh_find(&x->p, &gw, 0); if (ng) a.iface = ng->iface; else @@ -147,7 +150,7 @@ krt_parse_entry(byte *ent, struct krt_proto *p) { a.dest = RTD_DEVICE; a.gw = IPA_NONE; - a.iface = krt_temp_iface(p, iface); + a.iface = krt_temp_iface(x, iface); } else { @@ -167,7 +170,7 @@ krt_parse_entry(byte *ent, struct krt_proto *p) else verdict = KRF_UPDATE; } - else if (p->scanopt.learn && !net->routes) + else if (p->learn && !net->routes) verdict = KRF_LEARN; else verdict = KRF_DELETE; @@ -305,33 +308,34 @@ void krt_scan_ifaces_done(struct krt_proto *x) { SCANOPT; + SCANSTAT; - p->accum_time += x->ifopt.scan_time; - if (p->scan_time && p->accum_time >= p->scan_time) + s->accum_time += p->scan_time; + if (p->scan_time && s->accum_time >= p->scan_time) { - p->accum_time %= p->scan_time; + s->accum_time %= p->scan_time; if (krt_scan_proc(x)) krt_prune(x); } } void -krt_scan_preconfig(struct krt_proto *x) +krt_scan_preconfig(struct krt_config *c) { - SCANOPT; - - p->scan_time = 1; - p->learn = 0; - init_list(&p->temp_ifs); + c->scanopt.scan_time = 1; + c->scanopt.learn = 0; } void krt_scan_start(struct krt_proto *x) { SCANOPT; + SCANSTAT; /* Force krt scan after first interface scan */ - p->accum_time = p->scan_time - x->ifopt.scan_time; + s->accum_time = p->scan_time - ((struct krt_config *) x->p.cf)->ifopt.scan_time; + + init_list(&s->temp_ifs); } void diff --git a/sysdep/linux/krt-scan.h b/sysdep/linux/krt-scan.h index fe41d46c..ef1f7290 100644 --- a/sysdep/linux/krt-scan.h +++ b/sysdep/linux/krt-scan.h @@ -1,7 +1,7 @@ /* * BIRD -- Linux Kernel Route Syncer -- Scanning Parameters * - * (c) 1998 Martin Mares <mj@ucw.cz> + * (c) 1998--1999 Martin Mares <mj@ucw.cz> * * Can be freely distributed and used under the terms of the GNU GPL. */ @@ -11,8 +11,11 @@ struct krt_scan_params { int learn; /* Should we learn routes from the kernel? */ - list temp_ifs; /* Temporary interfaces */ int scan_time; /* How often should we scan krt, 0=only on startup */ +}; + +struct krt_scan_status { + list temp_ifs; /* Temporary interfaces */ int accum_time; /* Accumulated scanning time */ }; |