summaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2009-06-03 20:22:05 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2009-06-03 20:22:05 +0000
commit2376cca67a1626af282043f0a52d62211d9c58a9 (patch)
tree8127c9ac0d4fa460eed81f13a63e7f68ecb3fa48 /usr.sbin
parent0b6e9657245d93f3e1c5790c41c680d9d1e62ef1 (diff)
Allocate all rib contextes for tree walks and don't use static stack memory.
This will make interruptable walks a lot easier.
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/bgpd/rde_rib.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c
index 4d98efa027a..b023c3c7fca 100644
--- a/usr.sbin/bgpd/rde_rib.c
+++ b/usr.sbin/bgpd/rde_rib.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde_rib.c,v 1.111 2009/06/03 20:20:10 claudio Exp $ */
+/* $OpenBSD: rde_rib.c,v 1.112 2009/06/03 20:22:04 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -227,14 +227,15 @@ void
rib_dump(struct rib *rib, void (*upcall)(struct rib_entry *, void *),
void *arg, sa_family_t af)
{
- struct rib_context ctx;
-
- bzero(&ctx, sizeof(ctx));
- ctx.ctx_rib = rib;
- ctx.ctx_upcall = upcall;
- ctx.ctx_arg = arg;
- ctx.ctx_af = af;
- rib_dump_r(&ctx);
+ struct rib_context *ctx;
+
+ if ((ctx = calloc(1, sizeof(*ctx))) == NULL)
+ fatal("rib_dump");
+ ctx->ctx_rib = rib;
+ ctx->ctx_upcall = upcall;
+ ctx->ctx_arg = arg;
+ ctx->ctx_af = af;
+ rib_dump_r(ctx);
}
void
@@ -265,6 +266,8 @@ rib_dump_r(struct rib_context *ctx)
LIST_REMOVE(ctx, entry);
if (ctx->ctx_done)
ctx->ctx_done(ctx->ctx_arg);
+ else
+ free(ctx);
}
struct rib_entry *