summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2009-09-30 14:37:12 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2009-09-30 14:37:12 +0000
commit661ea77a13d50cc4311f6765df79f1c3cc1adb9e (patch)
tree1ed5cb59392e4ae9c7cda42e74d60d41a108d85f
parentb4648baa97f7c784e1f651df117ced31370faafc (diff)
Announce a stub network LSA for backup carp interfaces. This should help
when fail-over happens, since removing the better route will not result in a blackhole until the update from the new master is processed. Tested, OK and input sthen@, phessler@
-rw-r--r--usr.sbin/ospfd/interface.c8
-rw-r--r--usr.sbin/ospfd/neighbor.c7
-rw-r--r--usr.sbin/ospfd/ospfe.c40
3 files changed, 42 insertions, 13 deletions
diff --git a/usr.sbin/ospfd/interface.c b/usr.sbin/ospfd/interface.c
index 32844a5ef8d..784acdf9161 100644
--- a/usr.sbin/ospfd/interface.c
+++ b/usr.sbin/ospfd/interface.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interface.c,v 1.64 2009/08/09 23:04:16 claudio Exp $ */
+/* $OpenBSD: interface.c,v 1.65 2009/09/30 14:37:11 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -139,11 +139,9 @@ if_fsm(struct iface *iface, enum iface_event event)
if (iface->state != old_state)
orig_rtr_lsa(iface->area);
- if (old_state & (IF_STA_MULTI | IF_STA_POINTTOPOINT) &&
- (iface->state & (IF_STA_MULTI | IF_STA_POINTTOPOINT)) == 0)
+ if (old_state & IF_STA_MULTI && (iface->state & IF_STA_MULTI) == 0)
ospfe_demote_iface(iface, 0);
- if ((old_state & (IF_STA_MULTI | IF_STA_POINTTOPOINT)) == 0 &&
- iface->state & (IF_STA_MULTI | IF_STA_POINTTOPOINT))
+ if ((old_state & IF_STA_MULTI) == 0 && iface->state & IF_STA_MULTI)
ospfe_demote_iface(iface, 1);
log_debug("if_fsm: event %s resulted in action %s and changing "
diff --git a/usr.sbin/ospfd/neighbor.c b/usr.sbin/ospfd/neighbor.c
index 08fbf1c16cc..7cd6796fb48 100644
--- a/usr.sbin/ospfd/neighbor.c
+++ b/usr.sbin/ospfd/neighbor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: neighbor.c,v 1.37 2008/02/11 12:37:37 norby Exp $ */
+/* $OpenBSD: neighbor.c,v 1.38 2009/09/30 14:37:11 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -211,6 +211,11 @@ nbr_fsm(struct nbr *nbr, enum nbr_event event)
gettimeofday(&now, NULL);
nbr->uptime = now.tv_sec;
+
+ /* demote P2P links if the neighbor resets */
+ if (nbr->iface->type == IF_TYPE_POINTOPOINT)
+ ospfe_demote_iface(nbr->iface,
+ !(old_state & NBR_STA_FULL));
}
/* bidirectional communication lost */
diff --git a/usr.sbin/ospfd/ospfe.c b/usr.sbin/ospfd/ospfe.c
index 70e34aa07a2..69ef57dff3e 100644
--- a/usr.sbin/ospfd/ospfe.c
+++ b/usr.sbin/ospfd/ospfe.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ospfe.c,v 1.72 2009/09/30 14:30:24 claudio Exp $ */
+/* $OpenBSD: ospfe.c,v 1.73 2009/09/30 14:37:11 claudio Exp $ */
/*
* Copyright (c) 2005 Claudio Jeker <claudio@openbsd.org>
@@ -827,12 +827,21 @@ orig_rtr_lsa(struct area *area)
}
}
- if ((iface->flags & IFF_UP) == 0 ||
- iface->linkstate == LINK_STATE_DOWN ||
- (!LINK_STATE_IS_UP(iface->linkstate) &&
- iface->media_type == IFT_CARP))
+ /*
+ * do not add a stub net LSA for interfaces that are:
+ * - down
+ * - have a linkstate which is down and are not carp
+ * - have a linkstate unknown and are carp
+ * carp uses linkstate down for backup and unknown
+ * in cases where a major fubar happend.
+ */
+ if (!(iface->flags & IFF_UP) ||
+ (iface->media_type != IFT_CARP &&
+ !(LINK_STATE_IS_UP(iface->linkstate) ||
+ iface->linkstate == LINK_STATE_UNKNOWN)) ||
+ (iface->media_type == IFT_CARP &&
+ iface->linkstate == LINK_STATE_UNKNOWN))
continue;
-
log_debug("orig_rtr_lsa: stub net, "
"interface %s", iface->name);
@@ -840,7 +849,21 @@ orig_rtr_lsa(struct area *area)
iface->addr.s_addr & iface->mask.s_addr;
rtr_link.data = iface->mask.s_addr;
rtr_link.type = LINK_TYPE_STUB_NET;
- break;
+
+ rtr_link.num_tos = 0;
+ /*
+ * backup carp interfaces are anounced with high metric
+ * for faster failover.
+ */
+ if (iface->media_type == IFT_CARP &&
+ iface->linkstate == LINK_STATE_DOWN)
+ rtr_link.metric = MAX_METRIC;
+ else
+ rtr_link.metric = htons(iface->metric);
+ num_links++;
+ if (buf_add(buf, &rtr_link, sizeof(rtr_link)))
+ fatalx("orig_rtr_lsa: buf_add failed");
+ continue;
case IF_TYPE_VIRTUALLINK:
LIST_FOREACH(nbr, &iface->nbr_list, entry) {
if (nbr != iface->self &&
@@ -1124,5 +1147,8 @@ ospfe_demote_iface(struct iface *iface, int active)
else
dmsg.level = 1;
+ log_warnx("ospfe_demote_iface: group %s level %d", dmsg.demote_group,
+ dmsg.level);
+
ospfe_imsg_compose_parent(IMSG_DEMOTE, 0, &dmsg, sizeof(dmsg));
}