summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2009-06-03 20:20:11 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2009-06-03 20:20:11 +0000
commit0b6e9657245d93f3e1c5790c41c680d9d1e62ef1 (patch)
tree840c7d295acf486955f1f4b12f30fc0323a26271
parentd16494e671a562d11f65fe2295b4a32f3b3b0642 (diff)
Initial stab at rib_free() until now unused.
-rw-r--r--usr.sbin/bgpd/rde_rib.c37
1 files changed, 33 insertions, 4 deletions
diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c
index b637d2949dc..4d98efa027a 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.110 2009/06/03 20:17:59 claudio Exp $ */
+/* $OpenBSD: rde_rib.c,v 1.111 2009/06/03 20:20:10 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org>
@@ -85,8 +85,38 @@ rib_new(u_int16_t id, char *name, u_int16_t flags)
void
rib_free(struct rib *rib)
{
- /* XXX */
- //bzero(rib, sizeof(struct rib));
+ struct rib_context *ctx, *next;
+ struct rib_entry *re, *xre;
+ struct prefix *p, *np;
+
+ for (ctx = LIST_FIRST(&rib_dump_h); ctx != NULL; ctx = next) {
+ next = LIST_NEXT(ctx, entry);
+ if (ctx->ctx_rib == rib) {
+ LIST_REMOVE(ctx, entry);
+ if (ctx->ctx_done)
+ ctx->ctx_done(ctx->ctx_arg);
+ else
+ free(ctx);
+ }
+ }
+
+ for (re = RB_MIN(rib_tree, &rib->rib); re != NULL; re = xre) {
+ xre = RB_NEXT(rib_tree, &rib->rib, re);
+
+ for (p = LIST_FIRST(&re->prefix_h); p != NULL; p = np) {
+ np = LIST_NEXT(p, path_l);
+ if (p->aspath->pftableid) {
+ struct bgpd_addr addr;
+
+ pt_getaddr(p->prefix, &addr);
+ /* Commit is done in peer_down() */
+ rde_send_pftable(p->aspath->pftableid, &addr,
+ p->prefix->prefixlen, 1);
+ }
+ prefix_destroy(p);
+ }
+ }
+ bzero(rib, sizeof(struct rib));
}
int
@@ -436,7 +466,6 @@ path_remove(struct rde_aspath *asp)
rde_send_pftable(p->aspath->pftableid, &addr,
p->prefix->prefixlen, 1);
}
-
prefix_destroy(p);
}
}