diff options
author | Esben Norby <norby@cvs.openbsd.org> | 2005-05-12 19:10:13 +0000 |
---|---|---|
committer | Esben Norby <norby@cvs.openbsd.org> | 2005-05-12 19:10:13 +0000 |
commit | 87af8df0cfa319a592cd86ee0f15a509f7f68f4e (patch) | |
tree | 87e7d594ec73db7e00fb2c6f56e1a330fc16f031 /usr.sbin/ospfd | |
parent | 0d2ea09ba3d08079bffd80802508fce862db44e6 (diff) |
Add "show database asbr/external/network/router/self-originate/summary"
to ospfctl.
Show detailed information about the LSAs in the Link State Database.
ok claudio@
Diffstat (limited to 'usr.sbin/ospfd')
-rw-r--r-- | usr.sbin/ospfd/control.c | 8 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfd.h | 8 | ||||
-rw-r--r-- | usr.sbin/ospfd/ospfe.c | 8 | ||||
-rw-r--r-- | usr.sbin/ospfd/rde.c | 22 | ||||
-rw-r--r-- | usr.sbin/ospfd/rde.h | 4 | ||||
-rw-r--r-- | usr.sbin/ospfd/rde_lsdb.c | 42 |
6 files changed, 77 insertions, 15 deletions
diff --git a/usr.sbin/ospfd/control.c b/usr.sbin/ospfd/control.c index bbd8231e6e0..3c7dab95fe0 100644 --- a/usr.sbin/ospfd/control.c +++ b/usr.sbin/ospfd/control.c @@ -1,4 +1,4 @@ -/* $OpenBSD: control.c,v 1.10 2005/03/26 13:35:16 claudio Exp $ */ +/* $OpenBSD: control.c,v 1.11 2005/05/12 19:10:12 norby Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -244,6 +244,12 @@ control_dispatch_imsg(int fd, short event, void *bula) } break; case IMSG_CTL_SHOW_DATABASE: + case IMSG_CTL_SHOW_DB_EXT: + case IMSG_CTL_SHOW_DB_NET: + case IMSG_CTL_SHOW_DB_RTR: + case IMSG_CTL_SHOW_DB_SELF: + case IMSG_CTL_SHOW_DB_SUM: + case IMSG_CTL_SHOW_DB_ASBR: c->ibuf.pid = imsg.hdr.pid; ospfe_imsg_compose_rde(imsg.hdr.type, 0, imsg.hdr.pid, imsg.data, imsg.hdr.len - IMSG_HEADER_SIZE); diff --git a/usr.sbin/ospfd/ospfd.h b/usr.sbin/ospfd/ospfd.h index 62d366660cc..e1ceb4df09b 100644 --- a/usr.sbin/ospfd/ospfd.h +++ b/usr.sbin/ospfd/ospfd.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfd.h,v 1.28 2005/05/12 08:55:39 claudio Exp $ */ +/* $OpenBSD: ospfd.h,v 1.29 2005/05/12 19:10:12 norby Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -99,6 +99,12 @@ enum imsg_type { IMSG_CTL_RELOAD, IMSG_CTL_SHOW_INTERFACE, IMSG_CTL_SHOW_DATABASE, + IMSG_CTL_SHOW_DB_EXT, + IMSG_CTL_SHOW_DB_NET, + IMSG_CTL_SHOW_DB_RTR, + IMSG_CTL_SHOW_DB_SELF, + IMSG_CTL_SHOW_DB_SUM, + IMSG_CTL_SHOW_DB_ASBR, IMSG_CTL_SHOW_NBR, IMSG_CTL_SHOW_RIB, IMSG_CTL_SHOW_SUM, diff --git a/usr.sbin/ospfd/ospfe.c b/usr.sbin/ospfd/ospfe.c index b3ebe1572ae..2952929f5bb 100644 --- a/usr.sbin/ospfd/ospfe.c +++ b/usr.sbin/ospfd/ospfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfe.c,v 1.19 2005/05/12 08:55:39 claudio Exp $ */ +/* $OpenBSD: ospfe.c,v 1.20 2005/05/12 19:10:12 norby Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -549,6 +549,12 @@ ospfe_dispatch_rde(int fd, short event, void *bula) case IMSG_CTL_AREA: case IMSG_CTL_END: case IMSG_CTL_SHOW_DATABASE: + case IMSG_CTL_SHOW_DB_EXT: + case IMSG_CTL_SHOW_DB_NET: + case IMSG_CTL_SHOW_DB_RTR: + case IMSG_CTL_SHOW_DB_SELF: + case IMSG_CTL_SHOW_DB_SUM: + case IMSG_CTL_SHOW_DB_ASBR: case IMSG_CTL_SHOW_RIB: case IMSG_CTL_SHOW_SUM: case IMSG_CTL_SHOW_SUM_AREA: diff --git a/usr.sbin/ospfd/rde.c b/usr.sbin/ospfd/rde.c index 5fb7d8b5047..74d9274d002 100644 --- a/usr.sbin/ospfd/rde.c +++ b/usr.sbin/ospfd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.16 2005/05/11 20:07:04 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.17 2005/05/12 19:10:12 norby Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -463,6 +463,12 @@ rde_dispatch_imsg(int fd, short event, void *bula) lsa_del(nbr, &lsa_hdr); break; case IMSG_CTL_SHOW_DATABASE: + case IMSG_CTL_SHOW_DB_EXT: + case IMSG_CTL_SHOW_DB_NET: + case IMSG_CTL_SHOW_DB_RTR: + case IMSG_CTL_SHOW_DB_SELF: + case IMSG_CTL_SHOW_DB_SUM: + case IMSG_CTL_SHOW_DB_ASBR: if (imsg.hdr.len != IMSG_HEADER_SIZE && imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(aid)) { log_warnx("rde_dispatch: wrong imsg len"); @@ -473,18 +479,22 @@ rde_dispatch_imsg(int fd, short event, void *bula) imsg_compose(ibuf_ospfe, IMSG_CTL_AREA, 0, imsg.hdr.pid, -1, area, sizeof(*area)); - lsa_dump(&area->lsa_tree, imsg.hdr.pid); + lsa_dump(&area->lsa_tree, imsg.hdr.type, + imsg.hdr.pid); } - lsa_dump(&rdeconf->lsa_tree, imsg.hdr.pid); + lsa_dump(&rdeconf->lsa_tree, imsg.hdr.type, + imsg.hdr.pid); } else { memcpy(&aid, imsg.data, sizeof(aid)); if ((area = area_find(rdeconf, aid)) != NULL) { imsg_compose(ibuf_ospfe, IMSG_CTL_AREA, 0, imsg.hdr.pid, -1, area, sizeof(*area)); - lsa_dump(&area->lsa_tree, imsg.hdr.pid); + lsa_dump(&area->lsa_tree, imsg.hdr.type, + imsg.hdr.pid); if (!area->stub) lsa_dump(&rdeconf->lsa_tree, + imsg.hdr.type, imsg.hdr.pid); } } @@ -862,7 +872,7 @@ rde_req_list_free(struct rde_nbr *nbr) while ((le = TAILQ_FIRST(&nbr->req_list)) != NULL) { TAILQ_REMOVE(&nbr->req_list, le, entry); free(le); - } + } } /* @@ -994,7 +1004,7 @@ orig_asext_lsa(struct kroute *kr, u_int16_t age) * TODO ls_id must be unique, for overlapping routes this may * not be true. In this case it a hack needs to be done to * make the ls_id unique. - */ + */ lsa->hdr.ls_id = kr->prefix.s_addr; lsa->data.asext.mask = prefixlen2mask(kr->prefixlen); diff --git a/usr.sbin/ospfd/rde.h b/usr.sbin/ospfd/rde.h index 41b7ffef224..7ebba97a7db 100644 --- a/usr.sbin/ospfd/rde.h +++ b/usr.sbin/ospfd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.10 2005/05/08 19:58:51 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.11 2005/05/12 19:10:12 norby Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -106,7 +106,7 @@ struct vertex *lsa_find(struct area *, u_int8_t, u_int32_t, u_int32_t); struct vertex *lsa_find_net(struct area *area, u_int32_t); int lsa_num_links(struct vertex *); void lsa_snap(struct area *, u_int32_t); -void lsa_dump(struct lsa_tree *, pid_t); +void lsa_dump(struct lsa_tree *, int, pid_t); void lsa_merge(struct rde_nbr *, struct lsa *, struct vertex *); /* rde_spf.c */ diff --git a/usr.sbin/ospfd/rde_lsdb.c b/usr.sbin/ospfd/rde_lsdb.c index cb799c1060c..3f426af9305 100644 --- a/usr.sbin/ospfd/rde_lsdb.c +++ b/usr.sbin/ospfd/rde_lsdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_lsdb.c,v 1.11 2005/04/12 10:26:09 deraadt Exp $ */ +/* $OpenBSD: rde_lsdb.c,v 1.12 2005/05/12 19:10:12 norby Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -479,14 +479,48 @@ lsa_snap(struct area *area, u_int32_t peerid) } void -lsa_dump(struct lsa_tree *tree, pid_t pid) +lsa_dump(struct lsa_tree *tree, int imsg_type, pid_t pid) { struct vertex *v; RB_FOREACH(v, lsa_tree, tree) { lsa_age(v); - rde_imsg_compose_ospfe(IMSG_CTL_SHOW_DATABASE, 0, pid, - &v->lsa->hdr, ntohs(v->lsa->hdr.len)); + switch (imsg_type) { + case IMSG_CTL_SHOW_DATABASE: + rde_imsg_compose_ospfe(IMSG_CTL_SHOW_DATABASE, 0, pid, + &v->lsa->hdr, ntohs(v->lsa->hdr.len)); + continue; + case IMSG_CTL_SHOW_DB_SELF: + if (v->lsa->hdr.adv_rtr == rde_router_id()) + break; + continue; + case IMSG_CTL_SHOW_DB_EXT: + if (v->type == LSA_TYPE_EXTERNAL) + break; + continue; + case IMSG_CTL_SHOW_DB_NET: + if (v->type == LSA_TYPE_NETWORK) + break; + continue; + case IMSG_CTL_SHOW_DB_RTR: + if (v->type == LSA_TYPE_ROUTER) + break; + continue; + case IMSG_CTL_SHOW_DB_SUM: + if (v->type == LSA_TYPE_SUM_NETWORK) + break; + continue; + case IMSG_CTL_SHOW_DB_ASBR: + if (v->type == LSA_TYPE_SUM_ROUTER) + break; + continue; + default: + log_debug("%d", imsg_type); + log_warnx("lsa_dump: unknown imsg type"); + return; + } + rde_imsg_compose_ospfe(imsg_type, 0, pid, &v->lsa->hdr, + ntohs(v->lsa->hdr.len)); } } |