diff options
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/bgpd/bgpd.c | 5 | ||||
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 7 | ||||
-rw-r--r-- | usr.sbin/bgpd/control.c | 5 | ||||
-rw-r--r-- | usr.sbin/bgpd/kroute.c | 35 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.c | 3 |
5 files changed, 41 insertions, 14 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index 173ea585360..23f439cea98 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.60 2004/01/09 13:47:07 henning Exp $ */ +/* $OpenBSD: bgpd.c,v 1.61 2004/01/09 19:08:50 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -438,10 +438,11 @@ dispatch_imsg(struct imsgbuf *ibuf, int idx, struct mrt_head *mrtc) kr_fib_decouple(); break; case IMSG_CTL_KROUTE: + case IMSG_CTL_KROUTE_ADDR: if (idx != PFD_PIPE_SESSION) logit(LOG_CRIT, "kroute request not from SE"); else - kr_show_route(imsg.hdr.pid); + kr_show_route(&imsg); break; default: break; diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index c3b7b9a8c7b..1e0aca93c5b 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.60 2004/01/09 14:10:06 henning Exp $ */ +/* $OpenBSD: bgpd.h,v 1.61 2004/01/09 19:08:50 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -160,7 +160,8 @@ enum imsg_type { IMSG_CTL_FIB_DECOUPLE, IMSG_CTL_NEIGHBOR_UP, IMSG_CTL_NEIGHBOR_DOWN, - IMSG_CTL_KROUTE + IMSG_CTL_KROUTE, + IMSG_CTL_KROUTE_ADDR }; struct imsg_hdr { @@ -256,7 +257,7 @@ void kr_fib_decouple(void); int kr_dispatch_msg(void); int kr_nexthop_add(in_addr_t); void kr_nexthop_delete(in_addr_t); -void kr_show_route(pid_t); +void kr_show_route(struct imsg *); /* control.c */ int control_init(void); diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c index 817dca5969a..92865d759e8 100644 --- a/usr.sbin/bgpd/control.c +++ b/usr.sbin/bgpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.14 2004/01/09 13:47:07 henning Exp $ */ +/* $OpenBSD: control.c,v 1.15 2004/01/09 19:08:50 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -267,8 +267,9 @@ control_dispatch_msg(struct pollfd *pfd, int i) "with wrong length"); break; case IMSG_CTL_KROUTE: + case IMSG_CTL_KROUTE_ADDR: c->ibuf.pid = imsg.hdr.pid; - imsg_compose_parent(IMSG_CTL_KROUTE, imsg.hdr.pid, + imsg_compose_parent(imsg.hdr.type, imsg.hdr.pid, imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); break; default: diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c index 1498d83b3d2..929d5bfda7a 100644 --- a/usr.sbin/bgpd/kroute.c +++ b/usr.sbin/bgpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.60 2004/01/09 14:10:06 henning Exp $ */ +/* $OpenBSD: kroute.c,v 1.61 2004/01/09 19:08:50 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -298,14 +298,37 @@ kr_nexthop_delete(in_addr_t key) } void -kr_show_route(pid_t pid) +kr_show_route(struct imsg *imsg) { struct kroute_node *kr; + struct bgpd_addr *addr; + int flags; - RB_FOREACH(kr, kroute_tree, &krt) - send_imsg_session(IMSG_CTL_KROUTE, pid, &kr->r, sizeof(kr->r)); - - send_imsg_session(IMSG_CTL_END, pid, NULL, 0); + if (imsg->hdr.type == IMSG_CTL_KROUTE) { + if (imsg->hdr.len != IMSG_HEADER_SIZE + sizeof(flags)) { + logit(LOG_CRIT, "kr_show_route: wrong imsg len"); + return; + } + memcpy(&flags, imsg->data, sizeof(flags)); + RB_FOREACH(kr, kroute_tree, &krt) + if (!flags || kr->r.flags & flags) + send_imsg_session(IMSG_CTL_KROUTE, + imsg->hdr.pid, &kr->r, sizeof(kr->r)); + } else if (imsg->hdr.type == IMSG_CTL_KROUTE_ADDR) { + if (imsg->hdr.len != IMSG_HEADER_SIZE + + sizeof(struct bgpd_addr)) { + logit(LOG_CRIT, "kr_show_route: wrong imsg len"); + return; + } + addr = imsg->data; + kr = NULL; + if (addr->af == AF_INET) + kr = kroute_match(addr->v4.s_addr); + if (kr != NULL) + send_imsg_session(IMSG_CTL_KROUTE, imsg->hdr.pid, + &kr->r, sizeof(kr->r)); + } + send_imsg_session(IMSG_CTL_END, imsg->hdr.pid, NULL, 0); } /* diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index 1a3fc706951..2a2d915ab8c 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.76 2004/01/09 13:47:08 henning Exp $ */ +/* $OpenBSD: session.c,v 1.77 2004/01/09 19:08:50 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -1411,6 +1411,7 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx) } break; case IMSG_CTL_KROUTE: + case IMSG_CTL_KROUTE_ADDR: case IMSG_CTL_END: if (idx != PFD_PIPE_MAIN) fatalx("reconf request not from parent"); |