From 54d70d3ebb20c36f483cde9d7d5b877772d4884e Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Thu, 23 Jul 2009 22:21:17 +0200 Subject: Fixes compiler warning in OFFSETOF(). --- lib/birdlib.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/birdlib.h b/lib/birdlib.h index b7cd6b4..12a581b 100644 --- a/lib/birdlib.h +++ b/lib/birdlib.h @@ -13,7 +13,7 @@ /* Ugly structure offset handling macros */ -#define OFFSETOF(s, i) ((unsigned int)&((s *)0)->i) +#define OFFSETOF(s, i) ((size_t) &((s *)0)->i) #define SKIP_BACK(s, i, p) ((s *)((char *)p - OFFSETOF(s, i))) #define BIRD_ALIGN(s, a) (((s)+a-1)&~(a-1)) -- cgit v1.2.3 From daeeb8e982a3463f4a866e805b64f214d9f44160 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Fri, 4 Sep 2009 11:24:08 +0200 Subject: Clear memory allocated by ralloc(). This also fixes bug that timer->recurrent was not cleared in tm_new() and unexpected recurrence of startup timer in BGP confused state machine and caused crash. --- lib/event.c | 4 ---- lib/mempool.c | 4 ---- lib/resource.c | 5 +++-- 3 files changed, 3 insertions(+), 10 deletions(-) (limited to 'lib') diff --git a/lib/event.c b/lib/event.c index 55a9c48..d556cd0 100644 --- a/lib/event.c +++ b/lib/event.c @@ -63,10 +63,6 @@ event * ev_new(pool *p) { event *e = ralloc(p, &ev_class); - - e->hook = NULL; - e->data = NULL; - e->n.next = NULL; return e; } diff --git a/lib/mempool.c b/lib/mempool.c index e6f277b..03a6e6b 100644 --- a/lib/mempool.c +++ b/lib/mempool.c @@ -64,13 +64,9 @@ linpool *lp_new(pool *p, unsigned blk) { linpool *m = ralloc(p, &lp_class); - m->ptr = m->end = NULL; - m->first = m->current = NULL; m->plast = &m->first; - m->first_large = NULL; m->chunk_size = blk; m->threshold = 3*blk/4; - m->total = m->total_large = 0; return m; } diff --git a/lib/resource.c b/lib/resource.c index 8f91450..a4d8751 100644 --- a/lib/resource.c +++ b/lib/resource.c @@ -183,13 +183,14 @@ rdump(void *res) * * This function is called by the resource classes to create a new * resource of the specified class and link it to the given pool. - * Size of the resource structure is taken from the @size field - * of the &resclass. + * Allocated memory is zeroed. Size of the resource structure is taken + * from the @size field of the &resclass. */ void * ralloc(pool *p, struct resclass *c) { resource *r = xmalloc(c->size); + bzero(r, c->size); r->class = c; add_tail(&p->inside, &r->n); -- cgit v1.2.3 From 46eb80d5d50a2b284cae19444149d57d857a8e02 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Thu, 17 Sep 2009 17:52:36 +0200 Subject: Fixes headers for uintptr_t (and build on NetBSD). --- lib/mempool.c | 1 + lib/resource.c | 1 + lib/slab.c | 1 + 3 files changed, 3 insertions(+) (limited to 'lib') diff --git a/lib/mempool.c b/lib/mempool.c index 03a6e6b..0cb06b5 100644 --- a/lib/mempool.c +++ b/lib/mempool.c @@ -19,6 +19,7 @@ */ #include +#include #include "nest/bird.h" #include "lib/resource.h" diff --git a/lib/resource.c b/lib/resource.c index a4d8751..5ba23f1 100644 --- a/lib/resource.c +++ b/lib/resource.c @@ -8,6 +8,7 @@ #include #include +#include #include "nest/bird.h" #include "lib/resource.h" diff --git a/lib/slab.c b/lib/slab.c index 17511d2..8cce52f 100644 --- a/lib/slab.c +++ b/lib/slab.c @@ -26,6 +26,7 @@ */ #include +#include #include "nest/bird.h" #include "lib/resource.h" -- cgit v1.2.3 From ea89da381fc682155e7d08d6ad3d4ac8aa5fe115 Mon Sep 17 00:00:00 2001 From: Ondrej Zajicek Date: Sun, 11 Oct 2009 18:56:16 +0200 Subject: Workaround for stupid callback scheduler. There is no reak callback scheduler and previous behavior causes bad things during hard congestion (like BGP hold timeouts). Smart callback scheduler is still missing, but main loop was changed such that it first processes all tx callbacks (which are fast enough) (but max 4* per socket) + rx callbacks for CLI, and in the second phase it processes one rx callback per socket up to four sockets (as rx callback can be slow when there are too many protocols, because route redistribution is done synchronously inside rx callback). If there is event callback ready, second phase is skipped in 90% of iterations (to speed up CLI during congestion). --- lib/socket.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lib') diff --git a/lib/socket.h b/lib/socket.h index f192260..53e89ed 100644 --- a/lib/socket.h +++ b/lib/socket.h @@ -51,6 +51,7 @@ void sk_reallocate(sock *); /* Free and allocate tbuf & rbuf */ void sk_dump_all(void); int sk_set_ttl(sock *s, int ttl); /* Set TTL for given socket */ int sk_set_md5_auth(sock *s, ip_addr a, char *passwd); /* Add or remove security associations for given passive socket */ +int sk_rx_ready(sock *s); static inline int sk_send_buffer_empty(sock *sk) -- cgit v1.2.3