From e1217a8eae85a6fee4335dbdd63014714e193e30 Mon Sep 17 00:00:00 2001 From: Claudio Jeker Date: Mon, 1 Jun 2009 23:54:51 +0000 Subject: Use only one list to queue the dump contextes on. Use the list in struct rib_context instead of the ctl specific rde_dump_ctx to make it more general. --- usr.sbin/bgpd/rde.c | 19 +++++++++---------- usr.sbin/bgpd/rde.h | 15 +++++++-------- usr.sbin/bgpd/rde_rib.c | 3 +-- 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index fa423adabf6..ae4405bb554 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.246 2009/05/27 06:58:15 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.247 2009/06/01 23:54:49 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer @@ -119,13 +119,12 @@ struct mrt *mrt; struct rde_memstats rdemem; struct rde_dump_ctx { - TAILQ_ENTRY(rde_dump_ctx) entry; struct rib_context ribctx; struct ctl_show_rib_request req; sa_family_t af; }; -TAILQ_HEAD(, rde_dump_ctx) rde_dump_h = TAILQ_HEAD_INITIALIZER(rde_dump_h); +LIST_HEAD(, rib_context) rde_dump_h = LIST_HEAD_INITIALIZER(rde_dump_h); void rde_sighdlr(int sig) @@ -1940,7 +1939,7 @@ rde_dump_ctx_new(struct ctl_show_rib_request *req, pid_t pid, ctx->ribctx.ctx_arg = ctx; ctx->ribctx.ctx_af = ctx->req.af; - TAILQ_INSERT_TAIL(&rde_dump_h, ctx, entry); + LIST_INSERT_HEAD(&rde_dump_h, &ctx->ribctx, entry); } void @@ -1950,25 +1949,25 @@ rde_dump_done(void *arg) imsg_compose(ibuf_se_ctl, IMSG_CTL_END, 0, ctx->req.pid, -1, NULL, 0); - TAILQ_REMOVE(&rde_dump_h, ctx, entry); + LIST_REMOVE(&ctx->ribctx, entry); free(ctx); } void rde_dump_runner(void) { - struct rde_dump_ctx *ctx, *next; + struct rib_context *ctx, *next; - for (ctx = TAILQ_FIRST(&rde_dump_h); ctx != NULL; ctx = next) { - next = TAILQ_NEXT(ctx, entry); - rib_dump_r(&ctx->ribctx); + for (ctx = LIST_FIRST(&rde_dump_h); ctx != NULL; ctx = next) { + next = LIST_NEXT(ctx, entry); + rib_dump_r(ctx); } } int rde_dump_pending(void) { - return (!TAILQ_EMPTY(&rde_dump_h)); + return (!LIST_EMPTY(&rde_dump_h)); } /* diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h index ba05caf5186..8ce9a738c23 100644 --- a/usr.sbin/bgpd/rde.h +++ b/usr.sbin/bgpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.112 2009/06/01 22:49:06 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.113 2009/06/01 23:54:50 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker and @@ -241,14 +241,14 @@ struct pt_entry6 { }; struct rib_context { - LIST_ENTRY(rib_context) entry; - struct rib_entry *ctx_re; - struct rib *ctx_rib; + LIST_ENTRY(rib_context) entry; + struct rib_entry *ctx_re; + struct rib *ctx_rib; void (*ctx_upcall)(struct rib_entry *, void *); void (*ctx_done)(void *); - void *ctx_arg; - unsigned int ctx_count; - sa_family_t ctx_af; + void *ctx_arg; + unsigned int ctx_count; + sa_family_t ctx_af; }; struct rib_entry { @@ -269,7 +269,6 @@ enum rib_state { struct rib { char name[PEER_DESCR_LEN]; struct rib_tree rib; - LIST_HEAD(, rib_context) ctxts; enum rib_state state; u_int16_t flags; u_int16_t id; diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c index 630307d585a..eaa67d84f69 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.106 2009/06/01 22:54:02 claudio Exp $ */ +/* $OpenBSD: rde_rib.c,v 1.107 2009/06/01 23:54:50 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker @@ -224,7 +224,6 @@ rib_dump_r(struct rib_context *ctx) if (ctx->ctx_re == NULL) { re = RB_MIN(rib_tree, &ctx->ctx_rib->rib); - LIST_INSERT_HEAD(&ctx->ctx_rib->ctxts, ctx, entry); } else re = rib_restart(ctx); -- cgit v1.2.3