diff options
author | Claudio Jeker <claudio@cvs.openbsd.org> | 2006-01-13 13:04:34 +0000 |
---|---|---|
committer | Claudio Jeker <claudio@cvs.openbsd.org> | 2006-01-13 13:04:34 +0000 |
commit | 4766c36ded8cac683f5f5ec72fb72b60f5d3b1af (patch) | |
tree | 3fedb28577087357610ed439c7a470a3a1aaebb0 | |
parent | 86b6893b3c3439b7e1cb614235b5c0471c266990 (diff) |
Simplify evaluation process. Instead of checking the reachability of a prefix
at many different places do it once. This simplifies the logic and makes it
easier to extend it for upcomming Adj-RIB-In addition. OK Henning.
-rw-r--r-- | usr.sbin/bgpd/rde.c | 20 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_decide.c | 18 | ||||
-rw-r--r-- | usr.sbin/bgpd/rde_update.c | 5 |
3 files changed, 19 insertions, 24 deletions
diff --git a/usr.sbin/bgpd/rde.c b/usr.sbin/bgpd/rde.c index 00498b8765b..3d42f8b1407 100644 --- a/usr.sbin/bgpd/rde.c +++ b/usr.sbin/bgpd/rde.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.c,v 1.191 2006/01/12 14:05:13 claudio Exp $ */ +/* $OpenBSD: rde.c,v 1.192 2006/01/13 13:04:33 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Henning Brauer <henning@openbsd.org> @@ -1550,19 +1550,14 @@ rde_send_kroute(struct prefix *new, struct prefix *old) enum imsg_type type; /* - * If old is != NULL we know it was active and should be removed. - * On the other hand new may be UNREACH and then we should not - * generate an update. + * Make sure that self announce prefixes are not commited to the + * FIB. If both prefixes are unreachable no update is needed. */ if ((old == NULL || old->aspath->flags & F_PREFIX_ANNOUNCED) && - (new == NULL || new->aspath->nexthop == NULL || - new->aspath->nexthop->state != NEXTHOP_REACH || - new->aspath->flags & F_PREFIX_ANNOUNCED)) + (new == NULL || new->aspath->flags & F_PREFIX_ANNOUNCED)) return; - if (new == NULL || new->aspath->nexthop == NULL || - new->aspath->nexthop->state != NEXTHOP_REACH || - new->aspath->flags & F_PREFIX_ANNOUNCED) { + if (new == NULL || new->aspath->flags & F_PREFIX_ANNOUNCED) { type = IMSG_KROUTE_DELETE; p = old; } else { @@ -1747,11 +1742,10 @@ rde_generate_updates(struct prefix *new, struct prefix *old) /* * If old is != NULL we know it was active and should be removed. - * On the other hand new may be UNREACH and then we should not + * If new is != NULL we know it is reachable and then we should * generate an update. */ - if (old == NULL && (new == NULL || (new->aspath->nexthop != NULL && - new->aspath->nexthop->state != NEXTHOP_REACH))) + if (old == NULL && new == NULL) return; LIST_FOREACH(peer, &peerlist, peer_l) { diff --git a/usr.sbin/bgpd/rde_decide.c b/usr.sbin/bgpd/rde_decide.c index a50b09717f4..e4895538c07 100644 --- a/usr.sbin/bgpd/rde_decide.c +++ b/usr.sbin/bgpd/rde_decide.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_decide.c,v 1.44 2006/01/04 12:50:31 claudio Exp $ */ +/* $OpenBSD: rde_decide.c,v 1.45 2006/01/13 13:04:33 claudio Exp $ */ /* * Copyright (c) 2003, 2004 Claudio Jeker <claudio@openbsd.org> @@ -230,7 +230,13 @@ prefix_evaluate(struct prefix *p, struct pt_entry *pte) } } } + xp = LIST_FIRST(&pte->prefix_h); + if (xp == NULL || (xp->aspath->nexthop != NULL && + xp->aspath->nexthop->state != NEXTHOP_REACH)) + /* xp is ineligible */ + xp = NULL; + if (pte->active != xp) { /* need to generate an update */ if (pte->active != NULL) @@ -246,12 +252,8 @@ prefix_evaluate(struct prefix *p, struct pt_entry *pte) rde_generate_updates(xp, pte->active); rde_send_kroute(xp, pte->active); - if (xp == NULL || (xp->aspath->nexthop != NULL && - xp->aspath->nexthop->state != NEXTHOP_REACH)) - pte->active = NULL; - else { - pte->active = xp; - pte->active->aspath->active_cnt++; - } + pte->active = xp; + if (xp != NULL) + xp->aspath->active_cnt++; } } diff --git a/usr.sbin/bgpd/rde_update.c b/usr.sbin/bgpd/rde_update.c index 9593430bd64..f78d33762da 100644 --- a/usr.sbin/bgpd/rde_update.c +++ b/usr.sbin/bgpd/rde_update.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_update.c,v 1.48 2006/01/12 14:05:13 claudio Exp $ */ +/* $OpenBSD: rde_update.c,v 1.49 2006/01/13 13:04:33 claudio Exp $ */ /* * Copyright (c) 2004 Claudio Jeker <claudio@openbsd.org> @@ -406,8 +406,7 @@ up_generate_updates(struct filter_head *rules, struct rde_peer *peer, if (peer->state != PEER_UP) return; - if (new == NULL || (new->aspath->nexthop != NULL && - new->aspath->nexthop->state != NEXTHOP_REACH)) { + if (new == NULL) { if (up_test_update(peer, old) != 1) return; |