diff options
author | remi <remi@cvs.openbsd.org> | 2018-02-05 12:11:29 +0000 |
---|---|---|
committer | remi <remi@cvs.openbsd.org> | 2018-02-05 12:11:29 +0000 |
commit | d42b3d1b4aef8e6c5d75a18bb6c4ee79476ad019 (patch) | |
tree | 0ef89e91143034e35f52f5d27215d7b3b58c9ec0 /usr.sbin/ospfd/ospfe.c | |
parent | 95c71a012cf89c5f801281d5f82e4e8fdc3db0ec (diff) |
Introduce "depend on". This allows ospfd to set the metric dependent
on the status of another interface.
in collaboration with benno@ jca@
OK benno@ jca@
Diffstat (limited to 'usr.sbin/ospfd/ospfe.c')
-rw-r--r-- | usr.sbin/ospfd/ospfe.c | 36 |
1 files changed, 29 insertions, 7 deletions
diff --git a/usr.sbin/ospfd/ospfe.c b/usr.sbin/ospfd/ospfe.c index 86f7e796c40..693e3a6d5a9 100644 --- a/usr.sbin/ospfd/ospfe.c +++ b/usr.sbin/ospfd/ospfe.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ospfe.c,v 1.99 2017/01/24 04:24:25 benno Exp $ */ +/* $OpenBSD: ospfe.c,v 1.100 2018/02/05 12:11:28 remi Exp $ */ /* * Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org> @@ -181,10 +181,7 @@ ospfe(struct ospfd_conf *xconf, int pipe_parent2ospfe[2], int pipe_ospfe2rde[2], event_add(&oeconf->ev, NULL); /* remove unneeded config stuff */ - while ((r = SIMPLEQ_FIRST(&oeconf->redist_list)) != NULL) { - SIMPLEQ_REMOVE_HEAD(&oeconf->redist_list, entry); - free(r); - } + conf_clear_redist_list(&oeconf->redist_list); LIST_FOREACH(area, &oeconf->area_list, entry) { while ((r = SIMPLEQ_FIRST(&area->redist_list)) != NULL) { SIMPLEQ_REMOVE_HEAD(&area->redist_list, entry); @@ -346,6 +343,21 @@ ospfe_dispatch_main(int fd, short event, void *bula) iface->name); } } + if (strcmp(kif->ifname, + iface->dependon) == 0) { + log_warnx("interface %s" + " changed state, %s" + " depends on it", + kif->ifname, + iface->name); + iface->depend_ok = + ifstate_is_up(kif); + + if ((iface->flags & + IFF_UP) && + LINK_STATE_IS_UP(iface->linkstate)) + orig_rtr_lsa(iface->area); + } } } break; @@ -847,6 +859,9 @@ orig_rtr_lsa(struct area *area) if (oeconf->flags & OSPFD_FLAG_STUB_ROUTER || oe_nofib) rtr_link.metric = MAX_METRIC; + else if (iface->dependon[0] != '\0' && + iface->depend_ok == 0) + rtr_link.metric = MAX_METRIC; else rtr_link.metric = htons(iface->metric); num_links++; @@ -916,12 +931,16 @@ orig_rtr_lsa(struct area *area) rtr_link.num_tos = 0; /* - * backup carp interfaces are anounced with high metric - * for faster failover. + * backup carp interfaces and interfaces that depend + * on an interface that is down are announced with + * high metric for faster failover. */ if (iface->if_type == IFT_CARP && iface->linkstate == LINK_STATE_DOWN) rtr_link.metric = MAX_METRIC; + else if (iface->dependon[0] != '\0' && + iface->depend_ok == 0) + rtr_link.metric = MAX_METRIC; else rtr_link.metric = htons(iface->metric); num_links++; @@ -978,6 +997,9 @@ orig_rtr_lsa(struct area *area) if (oe_nofib || oeconf->flags & OSPFD_FLAG_STUB_ROUTER) rtr_link.metric = MAX_METRIC; + else if (iface->dependon[0] != '\0' && + iface->depend_ok == 0) + rtr_link.metric = MAX_METRIC; else rtr_link.metric = htons(iface->metric); |