summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd/control.c
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2006-08-23 08:13:05 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2006-08-23 08:13:05 +0000
commitae64b77bf4c8892086dffe7f47515b2fd04d0f1d (patch)
tree9f37556320791fc746d0db017d23a0e8de183b74 /usr.sbin/bgpd/control.c
parentce7a8ba8c04f6be11323324c248d6e8299d590fc (diff)
Extend show rib interface code so that it is possible to show the adj-rib-in
and adj-rib-out. Additionally it is now possible to limit the output to a specified peer. OK henning@
Diffstat (limited to 'usr.sbin/bgpd/control.c')
-rw-r--r--usr.sbin/bgpd/control.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c
index d3a2ab64d0f..95d47958c7b 100644
--- a/usr.sbin/bgpd/control.c
+++ b/usr.sbin/bgpd/control.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: control.c,v 1.52 2006/05/27 21:24:36 claudio Exp $ */
+/* $OpenBSD: control.c,v 1.53 2006/08/23 08:13:04 claudio Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -193,6 +193,7 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt)
int n;
struct peer *p;
struct ctl_neighbor *neighbor;
+ struct ctl_show_rib_request *ribreq;
if ((c = control_connbyfd(pfd->fd)) == NULL) {
log_warn("control_dispatch_msg: fd %d: not found", pfd->fd);
@@ -331,6 +332,46 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt)
case IMSG_CTL_SHOW_RIB:
case IMSG_CTL_SHOW_RIB_AS:
case IMSG_CTL_SHOW_RIB_PREFIX:
+ if (imsg.hdr.len == IMSG_HEADER_SIZE +
+ sizeof(struct ctl_show_rib_request)) {
+ ribreq = imsg.data;
+ neighbor = &ribreq->neighbor;
+ neighbor->descr[PEER_DESCR_LEN - 1] = 0;
+ ribreq->peerid = 0;
+ p = NULL;
+ if (neighbor->addr.af) {
+ p = getpeerbyaddr(&neighbor->addr);
+ if (p == NULL) {
+ control_result(c,
+ CTL_RES_NOSUCHPEER);
+ break;
+ }
+ ribreq->peerid = p->conf.id;
+ } else if (neighbor->descr[0]) {
+ p = getpeerbydesc(neighbor->descr);
+ if (p == NULL) {
+ control_result(c,
+ CTL_RES_NOSUCHPEER);
+ break;
+ }
+ ribreq->peerid = p->conf.id;
+ }
+ if ((ribreq->flags & F_CTL_ADJ_IN) && p &&
+ !p->conf.softreconfig_in) {
+ /*
+ * if no neighbor was specified we
+ * try our best.
+ */
+ control_result(c, CTL_RES_NOCAP);
+ break;
+ }
+ c->ibuf.pid = imsg.hdr.pid;
+ imsg_compose_rde(imsg.hdr.type, imsg.hdr.pid,
+ imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE);
+ } else
+ log_warnx("got IMSG_CTL_SHOW_RIB with "
+ "wrong length");
+ break;
case IMSG_CTL_SHOW_RIB_MEM:
case IMSG_CTL_SHOW_NETWORK:
c->ibuf.pid = imsg.hdr.pid;