diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2004-08-06 11:51:20 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2004-08-06 11:51:20 +0000 |
commit | 6c5e2cd730f34c5e2681abeaff3974e2f90b9e6f (patch) | |
tree | 12bd8070ef4bc9b6afbb1bbcddc4e9bde5eb64c8 /usr.sbin | |
parent | 2d765fced7152c0bd320d04a9ef80968c7abd476 (diff) |
Forward IMSG_CTL_SHOW_NEIGHBOR messages to the rde so that we can report
the current and max prefix count back to bgpctl. OK henning@
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/control.c | 17 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde.c | 21 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.c | 3 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.h | 3 |
4 files changed, 33 insertions, 11 deletions
diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c index db33c759868..2ea682a9b2b 100644 --- a/usr.sbin/bgpd/control.c +++ b/usr.sbin/bgpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.33 2004/06/20 18:35:12 henning Exp $ */ +/* $OpenBSD: control.c,v 1.34 2004/08/06 11:51:19 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -217,20 +217,21 @@ control_dispatch_msg(struct pollfd *pfd, u_int *ctl_cnt) switch (imsg.hdr.type) { case IMSG_CTL_SHOW_NEIGHBOR: + c->ibuf.pid = imsg.hdr.pid; if (imsg.hdr.len == IMSG_HEADER_SIZE + sizeof(struct bgpd_addr)) { addr = imsg.data; p = getpeerbyaddr(addr); if (p != NULL) - imsg_compose(&c->ibuf, - IMSG_CTL_SHOW_NEIGHBOR, - 0, p, sizeof(struct peer)); + imsg_compose_rde(imsg.hdr.type, + imsg.hdr.pid, + p, sizeof(struct peer)); } else for (p = peers; p != NULL; p = p->next) - imsg_compose(&c->ibuf, - IMSG_CTL_SHOW_NEIGHBOR, - 0, p, sizeof(struct peer)); - imsg_compose(&c->ibuf, IMSG_CTL_END, 0, NULL, 0); + imsg_compose_rde(imsg.hdr.type, + imsg.hdr.pid, + p, sizeof(struct peer)); + imsg_compose_rde(IMSG_CTL_END, imsg.hdr.pid, NULL, 0); break; case IMSG_CTL_RELOAD: case IMSG_CTL_FIB_COUPLE: diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index f8f54f18cca..22f51212ceb 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.137 2004/08/05 21:01:38 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.138 2004/08/06 11:51:19 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -256,7 +256,9 @@ rde_dispatch_imsg_session(struct imsgbuf *ibuf) { struct imsg imsg; struct session_up sup; + struct peer p; struct rrefresh r; + struct rde_peer *peer; pid_t pid; int n; @@ -353,6 +355,23 @@ rde_dispatch_imsg_session(struct imsgbuf *ibuf) rde_dump_prefix(imsg.data, pid); imsg_compose_pid(&ibuf_se, IMSG_CTL_END, pid, NULL, 0); break; + case IMSG_CTL_SHOW_NEIGHBOR: + if (imsg.hdr.len - IMSG_HEADER_SIZE != + sizeof(struct peer)) { + log_warnx("rde_dispatch: wrong imsg len"); + break; + } + memcpy(&p, imsg.data, sizeof(struct peer)); + peer = peer_get(p.conf.id); + if (peer != NULL) + p.stats.prefix_cnt = peer->prefix_cnt; + imsg_compose_pid(&ibuf_se, IMSG_CTL_SHOW_NEIGHBOR, + imsg.hdr.pid, &p, sizeof(struct peer)); + break; + case IMSG_CTL_END: + imsg_compose_pid(&ibuf_se, IMSG_CTL_END, imsg.hdr.pid, + NULL, 0); + break; default: break; } diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index d70829e880a..a4c212a320e 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.184 2004/08/04 12:41:48 henning Exp $ */ +/* $OpenBSD: session.c,v 1.185 2004/08/06 11:51:19 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -2217,6 +2217,7 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx, u_int *listener_cnt) case IMSG_CTL_SHOW_RIB: case IMSG_CTL_SHOW_RIB_PREFIX: case IMSG_CTL_SHOW_NETWORK: + case IMSG_CTL_SHOW_NEIGHBOR: if (idx != PFD_PIPE_ROUTE) fatalx("ctl rib request not from RDE"); control_imsg_relay(&imsg); diff --git a/usr.sbin/bgpd/session.h b/usr.sbin/bgpd/session.h index 764c1f157f6..259ecc238d7 100644 --- a/usr.sbin/bgpd/session.h +++ b/usr.sbin/bgpd/session.h @@ -1,4 +1,4 @@ -/* $OpenBSD: session.h,v 1.60 2004/08/05 21:01:38 claudio Exp $ */ +/* $OpenBSD: session.h,v 1.61 2004/08/06 11:51:19 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -150,6 +150,7 @@ struct peer_stats { u_int64_t msg_sent_rrefresh; time_t last_updown; time_t last_read; + u_int32_t prefix_cnt; }; struct peer_capa { |