diff options
-rw-r--r-- | usr.sbin/ospf6d/ospf6d.h | 3 | ||||
-rw-r--r-- | usr.sbin/ospf6d/ospfe.c | 3 | ||||
-rw-r--r-- | usr.sbin/ospf6d/rde.c | 40 | ||||
-rw-r--r-- | usr.sbin/ospf6d/rde.h | 4 | ||||
-rw-r--r-- | usr.sbin/ospf6d/rde_lsdb.c | 22 | ||||
-rw-r--r-- | usr.sbin/ospf6d/rde_spf.c | 8 |
6 files changed, 51 insertions, 29 deletions
diff --git a/usr.sbin/ospf6d/ospf6d.h b/usr.sbin/ospf6d/ospf6d.h index f8904428ca4..9bd40eb3319 100644 --- a/usr.sbin/ospf6d/ospf6d.h +++ b/usr.sbin/ospf6d/ospf6d.h @@ -1,4 +1,4 @@ -/* $OpenBSD: ospf6d.h,v 1.10 2007/11/27 11:29:34 claudio Exp $ */ +/* $OpenBSD: ospf6d.h,v 1.11 2007/11/27 12:23:06 claudio Exp $ */ /* * Copyright (c) 2004, 2007 Esben Norby <norby@openbsd.org> @@ -115,6 +115,7 @@ enum imsg_type { IMSG_CTL_FIB_COUPLE, IMSG_CTL_FIB_DECOUPLE, IMSG_CTL_AREA, + IMSG_CTL_IFACE, IMSG_CTL_KROUTE, IMSG_CTL_KROUTE_ADDR, IMSG_CTL_IFINFO, diff --git a/usr.sbin/ospf6d/ospfe.c b/usr.sbin/ospf6d/ospfe.c index bf33527b445..f3bdeab6095 100644 --- a/usr.sbin/ospf6d/ospfe.c +++ b/usr.sbin/ospf6d/ospfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfe.c,v 1.6 2007/11/27 11:29:34 claudio Exp $ */ +/* $OpenBSD: ospfe.c,v 1.7 2007/11/27 12:23:06 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -621,6 +621,7 @@ ospfe_dispatch_rde(int fd, short event, void *bula) } break; case IMSG_CTL_AREA: + case IMSG_CTL_IFACE: case IMSG_CTL_END: case IMSG_CTL_SHOW_DATABASE: case IMSG_CTL_SHOW_DB_EXT: diff --git a/usr.sbin/ospf6d/rde.c b/usr.sbin/ospf6d/rde.c index 88f63289cb1..99656a614d6 100644 --- a/usr.sbin/ospf6d/rde.c +++ b/usr.sbin/ospf6d/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.8 2007/11/27 11:29:34 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.9 2007/11/27 12:23:06 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -42,6 +42,7 @@ void rde_sig_handler(int sig, short, void *); void rde_shutdown(void); void rde_dispatch_imsg(int, short, void *); void rde_dispatch_parent(int, short, void *); +void rde_dump_area(struct area *, int, pid_t); void rde_send_summary(pid_t); void rde_send_summary_area(struct area *, pid_t); @@ -309,7 +310,7 @@ rde_dispatch_imsg(int fd, short event, void *bula) memcpy(&lsa_hdr, buf, sizeof(lsa_hdr)); buf += sizeof(lsa_hdr); - v = lsa_find(nbr->area, lsa_hdr.type, + v = lsa_find(nbr->iface, lsa_hdr.type, lsa_hdr.ls_id, lsa_hdr.adv_rtr); if (v == NULL) db_hdr = NULL; @@ -346,7 +347,7 @@ rde_dispatch_imsg(int fd, short event, void *bula) memcpy(&req_hdr, buf, sizeof(req_hdr)); buf += sizeof(req_hdr); - if ((v = lsa_find(nbr->area, + if ((v = lsa_find(nbr->iface, ntohl(req_hdr.type), req_hdr.ls_id, req_hdr.adv_rtr)) == NULL) { imsg_compose(ibuf_ospfe, IMSG_LS_BADREQ, @@ -378,7 +379,7 @@ rde_dispatch_imsg(int fd, short event, void *bula) break; } - v = lsa_find(nbr->area, lsa->hdr.type, lsa->hdr.ls_id, + v = lsa_find(nbr->iface, lsa->hdr.type, lsa->hdr.ls_id, lsa->hdr.adv_rtr); if (v == NULL) db_hdr = NULL; @@ -472,7 +473,7 @@ rde_dispatch_imsg(int fd, short event, void *bula) if (rde_nbr_loading(nbr->area)) break; - v = lsa_find(nbr->area, lsa_hdr.type, lsa_hdr.ls_id, + v = lsa_find(nbr->iface, lsa_hdr.type, lsa_hdr.ls_id, lsa_hdr.adv_rtr); if (v == NULL) db_hdr = NULL; @@ -499,10 +500,7 @@ rde_dispatch_imsg(int fd, short event, void *bula) } if (imsg.hdr.len == IMSG_HEADER_SIZE) { LIST_FOREACH(area, &rdeconf->area_list, entry) { - imsg_compose(ibuf_ospfe, IMSG_CTL_AREA, - 0, imsg.hdr.pid, area, - sizeof(*area)); - lsa_dump(&area->lsa_tree, imsg.hdr.type, + rde_dump_area(area, imsg.hdr.type, imsg.hdr.pid); } lsa_dump(&asext_tree, imsg.hdr.type, @@ -510,10 +508,7 @@ rde_dispatch_imsg(int fd, short event, void *bula) } 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, area, - sizeof(*area)); - lsa_dump(&area->lsa_tree, imsg.hdr.type, + rde_dump_area(area, imsg.hdr.type, imsg.hdr.pid); if (!area->stub) lsa_dump(&asext_tree, @@ -701,6 +696,25 @@ rde_dispatch_parent(int fd, short event, void *bula) } } +void +rde_dump_area(struct area *area, int imsg_type, pid_t pid) +{ + struct iface *iface; + + /* dump header */ + imsg_compose(ibuf_ospfe, IMSG_CTL_AREA, 0, pid, area, sizeof(*area)); + + /* dump link local lsa */ + LIST_FOREACH(iface, &area->iface_list, entry) { + imsg_compose(ibuf_ospfe, IMSG_CTL_IFACE, + 0, pid, iface, sizeof(*iface)); + lsa_dump(&iface->lsa_tree, imsg_type, pid); + } + + /* dump area lsa */ + lsa_dump(&area->lsa_tree, imsg_type, pid); +} + u_int32_t rde_router_id(void) { diff --git a/usr.sbin/ospf6d/rde.h b/usr.sbin/ospf6d/rde.h index 6796b087d30..c3b2e1b42f4 100644 --- a/usr.sbin/ospf6d/rde.h +++ b/usr.sbin/ospf6d/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.4 2007/11/27 11:29:34 claudio Exp $ */ +/* $OpenBSD: rde.h,v 1.5 2007/11/27 12:23:06 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Esben Norby <norby@openbsd.org> @@ -130,7 +130,7 @@ int lsa_self(struct rde_nbr *, struct lsa *, struct vertex *); int lsa_add(struct rde_nbr *, struct lsa *); void lsa_del(struct rde_nbr *, struct lsa_hdr *); void lsa_age(struct vertex *); -struct vertex *lsa_find(struct area *, u_int16_t, u_int32_t, u_int32_t); +struct vertex *lsa_find(struct iface *, u_int16_t, u_int32_t, u_int32_t); struct vertex *lsa_find_net(struct area *area, u_int32_t); u_int16_t lsa_num_links(struct vertex *); void lsa_snap(struct area *, u_int32_t); diff --git a/usr.sbin/ospf6d/rde_lsdb.c b/usr.sbin/ospf6d/rde_lsdb.c index c78e7719c9c..1880f7d844f 100644 --- a/usr.sbin/ospf6d/rde_lsdb.c +++ b/usr.sbin/ospf6d/rde_lsdb.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_lsdb.c,v 1.7 2007/11/27 11:29:34 claudio Exp $ */ +/* $OpenBSD: rde_lsdb.c,v 1.8 2007/11/27 12:23:06 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -157,7 +157,6 @@ lsa_newer(struct lsa_hdr *a, struct lsa_hdr *b) int lsa_check(struct rde_nbr *nbr, struct lsa *lsa, u_int16_t len) { - struct area *area = nbr->area; u_int32_t metric; if (len < sizeof(lsa->hdr)) { @@ -255,7 +254,7 @@ lsa_check(struct rde_nbr *nbr, struct lsa *lsa, u_int16_t len) return (0); } /* AS-external-LSA are silently discarded in stub areas */ - if (area->stub) + if (nbr->area->stub) return (0); break; default: @@ -264,9 +263,9 @@ lsa_check(struct rde_nbr *nbr, struct lsa *lsa, u_int16_t len) } /* MaxAge handling */ - if (lsa->hdr.age == htons(MAX_AGE) && !nbr->self && lsa_find(area, + if (lsa->hdr.age == htons(MAX_AGE) && !nbr->self && lsa_find(nbr->iface, lsa->hdr.type, lsa->hdr.ls_id, lsa->hdr.adv_rtr) == NULL && - !rde_nbr_loading(area)) { + !rde_nbr_loading(nbr->area)) { /* * if no neighbor in state Exchange or Loading * ack LSA but don't add it. Needs to be a direct ack. @@ -462,7 +461,7 @@ lsa_del(struct rde_nbr *nbr, struct lsa_hdr *lsa) struct vertex *v; struct timeval tv; - v = lsa_find(nbr->area, lsa->type, lsa->ls_id, lsa->adv_rtr); + v = lsa_find(nbr->iface, lsa->type, lsa->ls_id, lsa->adv_rtr); if (v == NULL) return; @@ -504,7 +503,8 @@ lsa_age(struct vertex *v) } struct vertex * -lsa_find(struct area *area, u_int16_t type, u_int32_t ls_id, u_int32_t adv_rtr) +lsa_find(struct iface *iface, u_int16_t type, u_int32_t ls_id, + u_int32_t adv_rtr) { struct vertex key; struct vertex *v; @@ -514,10 +514,14 @@ lsa_find(struct area *area, u_int16_t type, u_int32_t ls_id, u_int32_t adv_rtr) key.adv_rtr = ntohl(adv_rtr); key.type = ntohs(type); - if (type == LSA_TYPE_EXTERNAL) + if (LSA_IS_SCOPE_AS(key.type)) tree = &asext_tree; + else if (LSA_IS_SCOPE_AREA(key.type)) + tree = &iface->area->lsa_tree; + else if (LSA_IS_SCOPE_LLOCAL(key.type)) + tree = &iface->lsa_tree; else - tree = &area->lsa_tree; + fatalx("unknown scope type"); v = RB_FIND(lsa_tree, tree, &key); diff --git a/usr.sbin/ospf6d/rde_spf.c b/usr.sbin/ospf6d/rde_spf.c index daa0aa8123c..a95fa2083e7 100644 --- a/usr.sbin/ospf6d/rde_spf.c +++ b/usr.sbin/ospf6d/rde_spf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_spf.c,v 1.4 2007/10/16 21:36:19 claudio Exp $ */ +/* $OpenBSD: rde_spf.c,v 1.5 2007/11/27 12:23:06 claudio Exp $ */ /* * Copyright (c) 2005 Esben Norby <norby@openbsd.org> @@ -64,7 +64,8 @@ spf_calc(struct area *area) cand_list_clr(); /* initialize SPF tree */ - if ((v = spf_root = lsa_find(area, LSA_TYPE_ROUTER, rde_router_id(), + if ((v = spf_root = lsa_find(LIST_FIRST(&area->iface_list), /* XXX */ + LSA_TYPE_ROUTER, rde_router_id(), rde_router_id())) == NULL) /* empty area because no interface is active */ return; @@ -102,7 +103,8 @@ spf_calc(struct area *area) case LSA_TYPE_NETWORK: net_link = get_net_link(v, i); /* find router LSA */ - w = lsa_find(area, LSA_TYPE_ROUTER, + w = lsa_find(LIST_FIRST(&area->iface_list), /* XXX */ + LSA_TYPE_ROUTER, net_link->att_rtr, net_link->att_rtr); break; default: |