diff options
author | Henning Brauer <henning@cvs.openbsd.org> | 2004-01-17 18:05:47 +0000 |
---|---|---|
committer | Henning Brauer <henning@cvs.openbsd.org> | 2004-01-17 18:05:47 +0000 |
commit | 7653b17b00ffe6885bd43a1640bf2b151c6a1a43 (patch) | |
tree | 6b40794cfb9e60267ca1720a7e6162050cc56e1b /usr.sbin/bgpd | |
parent | c87463830faa4cc3b817372cce447bd58c8b3bca (diff) |
allow the interfaces as bgpd sees 'em to be queried via imsgs
Diffstat (limited to 'usr.sbin/bgpd')
-rw-r--r-- | usr.sbin/bgpd/bgpd.c | 3 | ||||
-rw-r--r-- | usr.sbin/bgpd/bgpd.h | 10 | ||||
-rw-r--r-- | usr.sbin/bgpd/control.c | 3 | ||||
-rw-r--r-- | usr.sbin/bgpd/kroute.c | 24 | ||||
-rw-r--r-- | usr.sbin/bgpd/session.c | 3 |
5 files changed, 29 insertions, 14 deletions
diff --git a/usr.sbin/bgpd/bgpd.c b/usr.sbin/bgpd/bgpd.c index 23faaf536de..39a8e73eab8 100644 --- a/usr.sbin/bgpd/bgpd.c +++ b/usr.sbin/bgpd/bgpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.c,v 1.66 2004/01/11 22:01:13 henning Exp $ */ +/* $OpenBSD: bgpd.c,v 1.67 2004/01/17 18:05:46 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -441,6 +441,7 @@ dispatch_imsg(struct imsgbuf *ibuf, int idx, struct mrt_head *mrtc) case IMSG_CTL_KROUTE: case IMSG_CTL_KROUTE_ADDR: case IMSG_CTL_SHOW_NEXTHOP: + case IMSG_CTL_SHOW_INTERFACE: if (idx != PFD_PIPE_SESSION) logit(LOG_CRIT, "kroute request not from SE"); else diff --git a/usr.sbin/bgpd/bgpd.h b/usr.sbin/bgpd/bgpd.h index fabf97eff75..39615654dc2 100644 --- a/usr.sbin/bgpd/bgpd.h +++ b/usr.sbin/bgpd/bgpd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bgpd.h,v 1.68 2004/01/13 13:45:49 claudio Exp $ */ +/* $OpenBSD: bgpd.h,v 1.69 2004/01/17 18:05:46 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -176,7 +176,8 @@ enum imsg_type { IMSG_CTL_NEIGHBOR_DOWN, IMSG_CTL_KROUTE, IMSG_CTL_KROUTE_ADDR, - IMSG_CTL_SHOW_NEXTHOP + IMSG_CTL_SHOW_NEXTHOP, + IMSG_CTL_SHOW_INTERFACE }; struct imsg_hdr { @@ -226,6 +227,11 @@ struct kroute_nexthop { struct kroute kr; }; +struct kif { + u_short ifindex; + int flags; +}; + struct session_up { u_int32_t remote_bgpid; struct bgpd_addr local_addr; diff --git a/usr.sbin/bgpd/control.c b/usr.sbin/bgpd/control.c index 20e28337965..efdffa93881 100644 --- a/usr.sbin/bgpd/control.c +++ b/usr.sbin/bgpd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.16 2004/01/11 02:35:14 henning Exp $ */ +/* $OpenBSD: control.c,v 1.17 2004/01/17 18:05:46 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -269,6 +269,7 @@ control_dispatch_msg(struct pollfd *pfd, int i) case IMSG_CTL_KROUTE: case IMSG_CTL_KROUTE_ADDR: case IMSG_CTL_SHOW_NEXTHOP: + case IMSG_CTL_SHOW_INTERFACE: c->ibuf.pid = imsg.hdr.pid; imsg_compose_parent(imsg.hdr.type, imsg.hdr.pid, imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); diff --git a/usr.sbin/bgpd/kroute.c b/usr.sbin/bgpd/kroute.c index 7012ff7ed70..e561a0c2c8f 100644 --- a/usr.sbin/bgpd/kroute.c +++ b/usr.sbin/bgpd/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.70 2004/01/17 15:35:09 henning Exp $ */ +/* $OpenBSD: kroute.c,v 1.71 2004/01/17 18:05:46 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -62,8 +62,7 @@ LIST_HEAD(kif_kr_head, kif_kr); struct kif_node { RB_ENTRY(kif_node) entry; - u_short ifindex; - int flags; + struct kif k; struct kif_kr_head kroute_l; }; @@ -311,6 +310,7 @@ kr_show_route(struct imsg *imsg) int flags; struct ctl_show_nexthop snh; struct knexthop_node *h; + struct kif_node *kif; switch (imsg->hdr.type) { case IMSG_CTL_KROUTE: @@ -349,9 +349,15 @@ kr_show_route(struct imsg *imsg) &snh, sizeof(snh)); } break; + case IMSG_CTL_SHOW_INTERFACE: + RB_FOREACH(kif, kif_tree, &kit) + send_imsg_session(IMSG_CTL_SHOW_INTERFACE, + imsg->hdr.pid, &kif->k, sizeof(kif->k)); + break; default: /* nada */ break; } + send_imsg_session(IMSG_CTL_END, imsg->hdr.pid, NULL, 0); } @@ -404,7 +410,7 @@ knexthop_compare(struct knexthop_node *a, struct knexthop_node *b) int kif_compare(struct kif_node *a, struct kif_node *b) { - return (b->ifindex - a->ifindex); + return (b->k.ifindex - a->k.ifindex); } @@ -527,7 +533,7 @@ kif_find(int ifindex) struct kif_node *kif, s; bzero(&s, sizeof(s)); - s.ifindex = ifindex; + s.k.ifindex = ifindex; if ((kif = RB_FIND(kif_tree, &kit, &s)) != NULL) return (kif); @@ -804,7 +810,7 @@ if_change(u_short ifindex, int flags) return; } - kif->flags = flags; + kif->k.flags = flags; LIST_FOREACH(kkr, &kif->kroute_l, entry) { if (flags & IFF_UP) @@ -845,7 +851,7 @@ if_announce(void *msg) return; } - kif->ifindex = ifan->ifan_index; + kif->k.ifindex = ifan->ifan_index; kif_insert(kif); break; case IFAN_DEPARTURE: @@ -1054,8 +1060,8 @@ fetchifs(int ifindex) return (-1); } - kif->ifindex = ifm->ifm_index; - kif->flags = ifm->ifm_flags; + kif->k.ifindex = ifm->ifm_index; + kif->k.flags = ifm->ifm_flags; kif_insert(kif); } return (0); diff --git a/usr.sbin/bgpd/session.c b/usr.sbin/bgpd/session.c index 526022863f6..650d4c9abd4 100644 --- a/usr.sbin/bgpd/session.c +++ b/usr.sbin/bgpd/session.c @@ -1,4 +1,4 @@ -/* $OpenBSD: session.c,v 1.87 2004/01/13 13:34:56 claudio Exp $ */ +/* $OpenBSD: session.c,v 1.88 2004/01/17 18:05:46 henning Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -1467,6 +1467,7 @@ session_dispatch_imsg(struct imsgbuf *ibuf, int idx) case IMSG_CTL_KROUTE: case IMSG_CTL_KROUTE_ADDR: case IMSG_CTL_SHOW_NEXTHOP: + case IMSG_CTL_SHOW_INTERFACE: case IMSG_CTL_END: if (idx != PFD_PIPE_MAIN) fatalx("ctl kroute request not from parent"); |