summaryrefslogtreecommitdiff
path: root/usr.sbin/bgpd
diff options
context:
space:
mode:
authorHenning Brauer <henning@cvs.openbsd.org>2005-09-20 13:31:54 +0000
committerHenning Brauer <henning@cvs.openbsd.org>2005-09-20 13:31:54 +0000
commit4b998adf5a4f9c33605e7b845f32488ca5da5f37 (patch)
treef2f5cdde7c4a86afd5bab3c591be30dba684ea9a /usr.sbin/bgpd
parentd7217b0449288745240ac55e088b86cf94ab2b15 (diff)
let "bgpctl network show" print v6 addresses correctly
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r--usr.sbin/bgpd/bgpd.h3
-rw-r--r--usr.sbin/bgpd/rde.c28
-rw-r--r--usr.sbin/bgpd/session.c3
3 files changed, 27 insertions, 7 deletions
diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h
index b4d330104d7..6e8a73f0c49 100644
--- a/usr.sbin/bgpd/bgpd.h
+++ b/usr.sbin/bgpd/bgpd.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: bgpd.h,v 1.176 2005/08/09 20:27:25 claudio Exp $ */
+/* $OpenBSD: bgpd.h,v 1.177 2005/09/20 13:31:53 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -313,6 +313,7 @@ enum imsg_type {
IMSG_CTL_SHOW_RIB_AS,
IMSG_CTL_SHOW_RIB_PREFIX,
IMSG_CTL_SHOW_NETWORK,
+ IMSG_CTL_SHOW_NETWORK6,
IMSG_REFRESH,
IMSG_IFINFO
};
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c
index 0565e7935d1..56e0cd525e8 100644
--- a/usr.sbin/bgpd/rde.c
+++ b/usr.sbin/bgpd/rde.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rde.c,v 1.170 2005/09/19 15:58:43 henning Exp $ */
+/* $OpenBSD: rde.c,v 1.171 2005/09/20 13:31:53 henning Exp $ */
/*
* Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org>
@@ -280,6 +280,7 @@ rde_dispatch_imsg_session(struct imsgbuf *ibuf)
struct filter_set *s;
pid_t pid;
int n;
+ sa_family_t af = AF_UNSPEC;
if ((n = imsg_read(ibuf)) == -1)
fatal("rde_dispatch_imsg_session: imsg_read error");
@@ -378,12 +379,13 @@ rde_dispatch_imsg_session(struct imsgbuf *ibuf)
TAILQ_INSERT_TAIL(session_set, s, entry);
break;
case IMSG_CTL_SHOW_NETWORK:
- if (imsg.hdr.len != IMSG_HEADER_SIZE) {
+ if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(af)) {
log_warnx("rde_dispatch: wrong imsg len");
break;
}
pid = imsg.hdr.pid;
- pt_dump(network_dump_upcall, &pid, AF_UNSPEC);
+ memcpy(&af, imsg.data, sizeof(af));
+ pt_dump(network_dump_upcall, &pid, af);
imsg_compose(ibuf_se, IMSG_CTL_END, 0, pid, -1,
NULL, 0);
break;
@@ -2234,13 +2236,16 @@ network_dump_upcall(struct pt_entry *pt, void *ptr)
{
struct prefix *p;
struct kroute k;
+ struct kroute6 k6;
struct bgpd_addr addr;
pid_t pid;
memcpy(&pid, ptr, sizeof(pid));
- LIST_FOREACH(p, &pt->prefix_h, prefix_l)
- if (p->aspath->flags & F_PREFIX_ANNOUNCED) {
+ LIST_FOREACH(p, &pt->prefix_h, prefix_l) {
+ if (!(p->aspath->flags & F_PREFIX_ANNOUNCED))
+ continue;
+ if (p->prefix->af == AF_INET) {
bzero(&k, sizeof(k));
pt_getaddr(p->prefix, &addr);
k.prefix.s_addr = addr.v4.s_addr;
@@ -2252,6 +2257,19 @@ network_dump_upcall(struct pt_entry *pt, void *ptr)
log_warnx("network_dump_upcall: "
"imsg_compose error");
}
+ if (p->prefix->af == AF_INET6) {
+ bzero(&k6, sizeof(k6));
+ pt_getaddr(p->prefix, &addr);
+ memcpy(&k6.prefix, &addr.v6, sizeof(k6.prefix));
+ k6.prefixlen = p->prefix->prefixlen;
+ if (p->peer == &peerself)
+ k6.flags = F_KERNEL;
+ if (imsg_compose(ibuf_se, IMSG_CTL_SHOW_NETWORK6, 0,
+ pid, -1, &k6, sizeof(k6)) == -1)
+ log_warnx("network_dump_upcall: "
+ "imsg_compose error");
+ }
+ }
}
void
diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c
index 4901d585f5c..8dce21ff482 100644
--- a/usr.sbin/bgpd/session.c
+++ b/usr.sbin/bgpd/session.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: session.c,v 1.234 2005/09/19 16:15:54 henning Exp $ */
+/* $OpenBSD: session.c,v 1.235 2005/09/20 13:31:53 henning Exp $ */
/*
* Copyright (c) 2003, 2004, 2005 Henning Brauer <henning@openbsd.org>
@@ -2318,6 +2318,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_NETWORK6:
case IMSG_CTL_SHOW_NEIGHBOR:
if (idx != PFD_PIPE_ROUTE)
fatalx("ctl rib request not from RDE");