From 4b35c2f5395719ecdc4f88b27e0b9af7370adb87 Mon Sep 17 00:00:00 2001 From: renato Date: Tue, 27 Oct 2015 03:25:55 +0000 Subject: [PATCH] Introduce a new flag to identify "self" neighbors attached to local interfaces. --- usr.sbin/eigrpd/neighbor.c | 4 ++-- usr.sbin/eigrpd/rde.h | 7 ++++--- usr.sbin/eigrpd/rde_dual.c | 22 ++++++++++------------ 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/usr.sbin/eigrpd/neighbor.c b/usr.sbin/eigrpd/neighbor.c index d0f8bfc7955..f54d4989a89 100644 --- a/usr.sbin/eigrpd/neighbor.c +++ b/usr.sbin/eigrpd/neighbor.c @@ -1,4 +1,4 @@ -/* $OpenBSD: neighbor.c,v 1.2 2015/10/04 23:00:10 renato Exp $ */ +/* $OpenBSD: neighbor.c,v 1.3 2015/10/27 03:25:55 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -143,7 +143,7 @@ nbr_init(struct nbr *nbr) memcpy(&rnbr.addr, &nbr->addr, sizeof(rnbr.addr)); rnbr.ifaceid = nbr->ei->ifaceid; if (nbr->flags & F_EIGRP_NBR_SELF) - rnbr.flags = F_RDE_NBR_SELF; + rnbr.flags = F_RDE_NBR_SELF|F_RDE_NBR_LOCAL; /* rde is not aware of pending nbrs */ eigrpe_imsg_compose_rde(IMSG_NEIGHBOR_UP, nbr->peerid, 0, &rnbr, diff --git a/usr.sbin/eigrpd/rde.h b/usr.sbin/eigrpd/rde.h index 7235bdeae9c..a08394f7076 100644 --- a/usr.sbin/eigrpd/rde.h +++ b/usr.sbin/eigrpd/rde.h @@ -1,4 +1,4 @@ -/* $OpenBSD: rde.h,v 1.4 2015/10/21 03:52:12 renato Exp $ */ +/* $OpenBSD: rde.h,v 1.5 2015/10/27 03:25:55 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -47,8 +47,9 @@ struct rde_nbr { * routes. */ #define F_RDE_NBR_SELF 0x01 -#define F_RDE_NBR_REDIST 0x02 -#define F_RDE_NBR_SUMMARY 0x04 +#define F_RDE_NBR_LOCAL 0x02 +#define F_RDE_NBR_REDIST 0x04 +#define F_RDE_NBR_SUMMARY 0x08 struct reply_node { TAILQ_ENTRY(reply_node) rn_entry; diff --git a/usr.sbin/eigrpd/rde_dual.c b/usr.sbin/eigrpd/rde_dual.c index b1df17ecaf9..d8ab6bceb79 100644 --- a/usr.sbin/eigrpd/rde_dual.c +++ b/usr.sbin/eigrpd/rde_dual.c @@ -1,4 +1,4 @@ -/* $OpenBSD: rde_dual.c,v 1.9 2015/10/25 00:42:02 renato Exp $ */ +/* $OpenBSD: rde_dual.c,v 1.10 2015/10/27 03:25:55 renato Exp $ */ /* * Copyright (c) 2015 Renato Westphal @@ -565,16 +565,19 @@ rinfo_fill_infinite(struct rt_node *rn, enum route_type type, struct rinfo *ri) void rt_update_fib(struct rt_node *rn) { - uint8_t maximum_paths = rn->eigrp->maximum_paths; - uint8_t variance = rn->eigrp->variance; + struct eigrp *eigrp = rn->eigrp; + uint8_t maximum_paths = eigrp->maximum_paths; + uint8_t variance = eigrp->variance; int installed = 0; struct eigrp_route *route; if (rn->state == DUAL_STA_PASSIVE) { - TAILQ_FOREACH(route, &rn->routes, entry) { - if (route->nbr->flags & F_RDE_NBR_SELF) - continue; + /* no multipath for attached networks. */ + if (rn->successor.nbr && + (rn->successor.nbr->flags & F_RDE_NBR_LOCAL)) + return; + TAILQ_FOREACH(route, &rn->routes, entry) { /* * only feasible successors and the successor itself * are elegible to be installed. @@ -582,11 +585,6 @@ rt_update_fib(struct rt_node *rn) if (route->rdistance > rn->successor.fdistance) goto uninstall; - /* no multipath for attached networks. */ - if (rn->successor.rdistance == 0 && - route->distance > 0) - goto uninstall; - if (route->distance > (rn->successor.fdistance * variance)) goto uninstall; @@ -661,7 +659,7 @@ rt_get_successor_fc(struct rt_node *rn) * connected routes should always be prefered over * received routes independent of the metric. */ - if (route->rdistance == 0) + if (route->nbr->flags & F_RDE_NBR_LOCAL) return (route); external_only = 0; -- 2.20.1