Introduce a new flag to identify "self" neighbors attached to local interfaces.
authorrenato <renato@openbsd.org>
Tue, 27 Oct 2015 03:25:55 +0000 (03:25 +0000)
committerrenato <renato@openbsd.org>
Tue, 27 Oct 2015 03:25:55 +0000 (03:25 +0000)
usr.sbin/eigrpd/neighbor.c
usr.sbin/eigrpd/rde.h
usr.sbin/eigrpd/rde_dual.c

index d0f8bfc..f54d498 100644 (file)
@@ -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 <renato@openbsd.org>
@@ -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,
index 7235bde..a08394f 100644 (file)
@@ -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 <renato@openbsd.org>
@@ -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;
index b1df17e..d8ab6bc 100644 (file)
@@ -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 <renato@openbsd.org>
@@ -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;