diff options
author | Ondrej Zajicek <santiago@crfreenet.org> | 2009-02-26 14:23:54 +0100 |
---|---|---|
committer | Ondrej Zajicek <santiago@crfreenet.org> | 2009-02-26 14:23:54 +0100 |
commit | cb5303927188de9504a6e18aedec299956a22b6f (patch) | |
tree | 0d8ac146c9d84b85e382fb994d9e10688c2e3e36 /sysdep/unix/krt.c | |
parent | a9dc5e1ef2fd08c53bceb54690f6dac83ddf0c81 (diff) |
Rate limit for most abundant log messages
Diffstat (limited to 'sysdep/unix/krt.c')
-rw-r--r-- | sysdep/unix/krt.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/sysdep/unix/krt.c b/sysdep/unix/krt.c index fded9abe..816eb444 100644 --- a/sysdep/unix/krt.c +++ b/sysdep/unix/krt.c @@ -183,18 +183,18 @@ struct protocol proto_unix_iface = { * Tracing of routes */ -static void -krt_trace_in_print(struct krt_proto *p, rte *e, char *msg) +static inline void +krt_trace_in(struct krt_proto *p, rte *e, char *msg) { - DBG("KRT: %I/%d: %s\n", e->net->n.prefix, e->net->n.pxlen, msg); - log(L_TRACE "%s: %I/%d: %s", p->p.name, e->net->n.prefix, e->net->n.pxlen, msg); + if (p->p.debug & D_PACKETS) + log(L_TRACE "%s: %I/%d: %s", p->p.name, e->net->n.prefix, e->net->n.pxlen, msg); } static inline void -krt_trace_in(struct krt_proto *p, rte *e, char *msg) +krt_trace_in_rl(struct rate_limit *rl, struct krt_proto *p, rte *e, char *msg) { if (p->p.debug & D_PACKETS) - krt_trace_in_print(p, e, msg); + log_rl(rl, L_TRACE "%s: %I/%d: %s", p->p.name, e->net->n.prefix, e->net->n.pxlen, msg); } /* @@ -203,6 +203,8 @@ krt_trace_in(struct krt_proto *p, rte *e, char *msg) #ifdef KRT_ALLOW_LEARN +static struct rate_limit rl_alien_seen, rl_alien_updated, rl_alien_created, rl_alien_ignored; + static inline int krt_same_key(rte *a, rte *b) { @@ -249,20 +251,20 @@ krt_learn_scan(struct krt_proto *p, rte *e) { if (krt_uptodate(m, e)) { - krt_trace_in(p, e, "[alien] seen"); + krt_trace_in_rl(&rl_alien_seen, p, e, "[alien] seen"); rte_free(e); m->u.krt.seen = 1; } else { - krt_trace_in(p, e, "[alien] updated"); + krt_trace_in_rl(&rl_alien_updated, p, e, "[alien] updated"); *mm = m->next; rte_free(m); m = NULL; } } else - krt_trace_in(p, e, "[alien] created"); + krt_trace_in_rl(&rl_alien_created, p, e, "[alien] created"); if (!m) { e->attrs = rta_lookup(e->attrs); @@ -516,7 +518,7 @@ krt_got_route(struct krt_proto *p, rte *e) krt_learn_scan(p, e); else { - krt_trace_in(p, e, "alien route, ignored"); + krt_trace_in_rl(&rl_alien_ignored, p, e, "alien route, ignored"); rte_free(e); } return; |