diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-06-02 00:09:03 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2009-06-02 00:09:03 +0000 |
commit | 91b65a13e6f13562d5bf9d4316852b58117eae36 (patch) | |
tree | 031d50627c7035334d524d61ef1802d2fc4c9476 /usr.sbin/bgpd | |
parent | 2b91b760441f05ccee1184ef7c4bbf0c4c8a4860 (diff) |
Move the rest of the rib dump functions into rde_rib.c where it belongs.
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/rde.c | 31 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.h | 4 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_rib.c | 22 |
3 files changed, 28 insertions, 29 deletions
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index ae4405bb554..e0065fa936b 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.247 2009/06/01 23:54:49 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.248 2009/06/02 00:09:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -79,8 +79,6 @@ void rde_dump_community(struct ctl_show_rib_request *); void rde_dump_ctx_new(struct ctl_show_rib_request *, pid_t, enum imsg_type); void rde_dump_done(void *); -void rde_dump_runner(void); -int rde_dump_pending(void); void rde_up_dump_upcall(struct rib_entry *, void *); void rde_softreconfig_out(struct rib_entry *, void *); @@ -124,8 +122,6 @@ struct rde_dump_ctx { sa_family_t af; }; -LIST_HEAD(, rib_context) rde_dump_h = LIST_HEAD_INITIALIZER(rde_dump_h); - void rde_sighdlr(int sig) { @@ -262,7 +258,7 @@ rde_main(struct bgpd_config *config, struct peer *peer_l, pfd[PFD_PIPE_SESSION_CTL].events = POLLIN; if (ibuf_se_ctl->w.queued > 0) pfd[PFD_PIPE_SESSION_CTL].events |= POLLOUT; - else if (rde_dump_pending()) + else if (rib_dump_pending()) timeout = 0; i = 3; @@ -314,7 +310,7 @@ rde_main(struct bgpd_config *config, struct peer *peer_l, rde_update_queue_runner(); rde_update6_queue_runner(); if (ibuf_se_ctl->w.queued <= 0) - rde_dump_runner(); + rib_dump_runner(); } /* do not clean up on shutdown on production, it takes ages. */ @@ -1938,8 +1934,7 @@ rde_dump_ctx_new(struct ctl_show_rib_request *req, pid_t pid, ctx->ribctx.ctx_done = rde_dump_done; ctx->ribctx.ctx_arg = ctx; ctx->ribctx.ctx_af = ctx->req.af; - - LIST_INSERT_HEAD(&rde_dump_h, &ctx->ribctx, entry); + rib_dump_r(&ctx->ribctx); } void @@ -1949,27 +1944,9 @@ rde_dump_done(void *arg) imsg_compose(ibuf_se_ctl, IMSG_CTL_END, 0, ctx->req.pid, -1, NULL, 0); - LIST_REMOVE(&ctx->ribctx, entry); free(ctx); } -void -rde_dump_runner(void) -{ - struct rib_context *ctx, *next; - - 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 (!LIST_EMPTY(&rde_dump_h)); -} - /* * kroute specific functions */ diff --git a/usr.sbin/bgpd/rde.h b/usr.sbin/bgpd/rde.h index 8ce9a738c23..22f7418fa09 100644 --- a/usr.sbin/bgpd/rde.h +++ b/usr.sbin/bgpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.113 2009/06/01 23:54:50 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.114 2009/06/02 00:09:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> and @@ -353,6 +353,8 @@ struct rib_entry *rib_lookup(struct rib *, struct bgpd_addr *); void rib_dump(struct rib *, void (*)(struct rib_entry *, void *), void *, sa_family_t); void rib_dump_r(struct rib_context *); +void rib_dump_runner(void); +int rib_dump_pending(void); void path_init(u_int32_t); void path_shutdown(void); diff --git a/usr.sbin/bgpd/rde_rib.c b/usr.sbin/bgpd/rde_rib.c index eaa67d84f69..49ff1c24934 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.107 2009/06/01 23:54:50 claudio Exp $ */ +/* $OpenBSD: rde_rib.c,v 1.108 2009/06/02 00:09:02 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -36,6 +36,8 @@ u_int16_t rib_size; struct rib *ribs; +LIST_HEAD(, rib_context) rib_dump_h = LIST_HEAD_INITIALIZER(rib_dump_h); + struct rib_entry *rib_add(struct rib *, struct bgpd_addr *, int); int rib_compare(const struct rib_entry *, const struct rib_entry *); void rib_remove(struct rib_entry *); @@ -224,6 +226,7 @@ rib_dump_r(struct rib_context *ctx) if (ctx->ctx_re == NULL) { re = RB_MIN(rib_tree, &ctx->ctx_rib->rib); + LIST_INSERT_HEAD(&rib_dump_h, ctx, entry); } else re = rib_restart(ctx); @@ -264,6 +267,23 @@ rib_restart(struct rib_context *ctx) return (re); } +void +rib_dump_runner(void) +{ + struct rib_context *ctx, *next; + + for (ctx = LIST_FIRST(&rib_dump_h); ctx != NULL; ctx = next) { + next = LIST_NEXT(ctx, entry); + rib_dump_r(ctx); + } +} + +int +rib_dump_pending(void) +{ + return (!LIST_EMPTY(&rib_dump_h)); +} + /* used to bump correct prefix counters */ #define PREFIX_COUNT(x, op) \ do { \ |