diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2011-07-07 17:10:49 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2011-07-07 17:10:49 +0000 |
commit | 17394042f0155b02f95b5527cd23c123c725bad7 (patch) | |
tree | c33c3f97c86832a240618e8227d2a6f1ac1aaaf1 /usr.sbin | |
parent | ea216f90f426a5ff8058ae9b1145dcd0aa8f1896 (diff) |
Rework the distribution of link state and iface FSM state changes.
Link state changes are sent from the parent to both childs and
iface FSM state changes are sent from the ospfe to the rde.
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ospf6d/interface.c | 10 | ||||
-rw-r--r-- | usr.sbin/ospf6d/kroute.c | 9 | ||||
-rw-r--r-- | usr.sbin/ospf6d/ospfe.c | 7 | ||||
-rw-r--r-- | usr.sbin/ospf6d/rde.c | 66 |
4 files changed, 52 insertions, 40 deletions
diff --git a/usr.sbin/ospf6d/interface.c b/usr.sbin/ospf6d/interface.c index ad86e2a0fe9..c1b1f744f19 100644 --- a/usr.sbin/ospf6d/interface.c +++ b/usr.sbin/ospf6d/interface.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interface.c,v 1.18 2011/07/04 04:34:14 claudio Exp $ */ +/* $OpenBSD: interface.c,v 1.19 2011/07/07 17:10:48 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -145,12 +145,12 @@ if_fsm(struct iface *iface, enum iface_event event) if (iface->state != old_state) { orig_rtr_lsa(iface); orig_link_lsa(iface); + + /* state change inform RDE */ + ospfe_imsg_compose_rde(IMSG_IFINFO, iface->self->peerid, 0, + &iface->state, sizeof(iface->state)); } - /* Inform RDE in any case since the link state may have changed */ - ospfe_imsg_compose_rde(IMSG_IFINFO, - iface->self->peerid, 0, iface, sizeof(struct iface)); - if (old_state & (IF_STA_MULTI | IF_STA_POINTTOPOINT) && (iface->state & (IF_STA_MULTI | IF_STA_POINTTOPOINT)) == 0) ospfe_demote_iface(iface, 0); diff --git a/usr.sbin/ospf6d/kroute.c b/usr.sbin/ospf6d/kroute.c index 18522e208eb..3f7f4d0ae79 100644 --- a/usr.sbin/ospf6d/kroute.c +++ b/usr.sbin/ospf6d/kroute.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kroute.c,v 1.34 2011/07/07 17:06:51 claudio Exp $ */ +/* $OpenBSD: kroute.c,v 1.35 2011/07/07 17:10:48 claudio Exp $ */ /* * Copyright (c) 2004 Esben Norby <norby@openbsd.org> @@ -812,10 +812,13 @@ if_change(u_short ifindex, int flags, struct if_data *ifd) if (wasvalid == isvalid) return; /* nothing changed wrt validity */ - /* notify ospfe about interface link state */ - if (iface->cflags & F_IFACE_CONFIGURED) + /* inform engine and rde about state change if interface is used */ + if (iface->cflags & F_IFACE_CONFIGURED) { main_imsg_compose_ospfe(IMSG_IFINFO, 0, iface, sizeof(struct iface)); + main_imsg_compose_rde(IMSG_IFINFO, 0, iface, + sizeof(struct iface)); + } /* update redistribute list */ RB_FOREACH(kr, kroute_tree, &krt) { diff --git a/usr.sbin/ospf6d/ospfe.c b/usr.sbin/ospf6d/ospfe.c index e026d150d2a..42c96d91cec 100644 --- a/usr.sbin/ospf6d/ospfe.c +++ b/usr.sbin/ospf6d/ospfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfe.c,v 1.36 2011/07/07 04:13:23 claudio Exp $ */ +/* $OpenBSD: ospfe.c,v 1.37 2011/07/07 17:10:48 claudio Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -286,9 +286,10 @@ ospfe_dispatch_main(int fd, short event, void *bula) iface = if_find(ifp->ifindex); if (iface == NULL) fatalx("interface lost in ospfe"); - iface->flags = ifp->flags; - iface->linkstate = ifp->linkstate; + if_update(iface, ifp->mtu, ifp->flags, ifp->media_type, + ifp->linkstate, ifp->baudrate); + if ((iface->flags & IFF_UP) && LINK_STATE_IS_UP(iface->linkstate)) { if_fsm(iface, IF_EVT_UP); diff --git a/usr.sbin/ospf6d/rde.c b/usr.sbin/ospf6d/rde.c index fd3f770cacd..cee9a87c753 100644 --- a/usr.sbin/ospf6d/rde.c +++ b/usr.sbin/ospf6d/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.57 2011/07/07 04:37:56 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.58 2011/07/07 17:10:48 claudio Exp $ */ /* * Copyright (c) 2004, 2005 Claudio Jeker <claudio@openbsd.org> @@ -252,7 +252,6 @@ rde_dispatch_imsg(int fd, short event, void *bula) struct lsa *lsa; struct area *area; struct vertex *v; - struct iface *iface, *ifp; char *buf; ssize_t n; time_t now; @@ -578,32 +577,16 @@ rde_dispatch_imsg(int fd, short event, void *bula) break; case IMSG_IFINFO: if (imsg.hdr.len != IMSG_HEADER_SIZE + - sizeof(struct iface)) + sizeof(int)) fatalx("IFINFO imsg with wrong len"); - ifp = imsg.data; - - iface = if_find(ifp->ifindex); - if (iface == NULL) - fatalx("interface lost in rde"); - - /* - * Resend LSAs if interface flags change - - * carp/passive interfaces can come up and down - * without changing OSPF state. - */ - if ((iface->state != ifp->state) || - (iface->linkstate != ifp->linkstate) || - (iface->flags != ifp->flags)) { - iface->state = ifp->state; - iface->flags = ifp->flags; - iface->linkstate = ifp->linkstate; + nbr = rde_nbr_find(imsg.hdr.peerid); + if (nbr == NULL) + fatalx("IFINFO imsg with bad peerid"); + memcpy(&nbr->iface->state, imsg.data, sizeof(int)); - area = area_find(rdeconf, iface->area_id); - if (!area) - fatalx("interface lost area"); - orig_intra_area_prefix_lsas(area); - } + /* Resend LSAs if interface state changes. */ + orig_intra_area_prefix_lsas(nbr->area); break; case IMSG_CTL_LOG_VERBOSE: /* already checked by ospfe */ @@ -632,7 +615,7 @@ rde_dispatch_parent(int fd, short event, void *bula) { static struct area *narea; struct area *area; - struct iface *iface; + struct iface *iface, *ifp; struct ifaddrchange *ifc; struct iface_addr *ia, *nia; struct imsg imsg; @@ -644,7 +627,7 @@ rde_dispatch_parent(int fd, short event, void *bula) struct vertex *v; struct rt_node *rn; ssize_t n; - int shut = 0; + int shut = 0, wasvalid; unsigned int ifindex; if (event & EV_READ) { @@ -715,8 +698,33 @@ rde_dispatch_parent(int fd, short event, void *bula) rde_send_change_kroute(rn); else /* should not happen */ - imsg_compose_event(iev_main, IMSG_KROUTE_DELETE, 0, - 0, -1, &kr, sizeof(kr)); + imsg_compose_event(iev_main, IMSG_KROUTE_DELETE, + 0, 0, -1, &kr, sizeof(kr)); + break; + case IMSG_IFINFO: + if (imsg.hdr.len != IMSG_HEADER_SIZE + + sizeof(struct iface)) + fatalx("IFINFO imsg with wrong len"); + + ifp = imsg.data; + iface = if_find(ifp->ifindex); + if (iface == NULL) + fatalx("interface lost in rde"); + + wasvalid = (iface->flags & IFF_UP) && + LINK_STATE_IS_UP(iface->linkstate); + + if_update(iface, ifp->mtu, ifp->flags, ifp->media_type, + ifp->linkstate, ifp->baudrate); + + /* Resend LSAs if interface state changes. */ + if (wasvalid != (iface->flags & IFF_UP) && + LINK_STATE_IS_UP(iface->linkstate)) { + area = area_find(rdeconf, iface->area_id); + if (!area) + fatalx("interface lost area"); + orig_intra_area_prefix_lsas(area); + } break; case IMSG_IFADD: if ((iface = malloc(sizeof(struct iface))) == NULL) |