summaryrefslogtreecommitdiff
path: root/zebra
diff options
context:
space:
mode:
authorDenis Ovsienko <linux@pilot.org.ua>2007-08-14 09:46:48 +0000
committerDenis Ovsienko <linux@pilot.org.ua>2007-08-14 09:46:48 +0000
commit03e232a4588187992f3538985d541289dc272464 (patch)
tree6bb2c36ccb39c678b49d29fd3d379e0de313a17d /zebra
parentdc95824ae13d65156dd873a6e784d9a0eed2f39f (diff)
Merged own patch for bug #390 (rewrite zebra/zebra_rib.c:nexthop_active_update())
Diffstat (limited to 'zebra')
-rw-r--r--zebra/ChangeLog5
-rw-r--r--zebra/zebra_rib.c29
2 files changed, 22 insertions, 12 deletions
diff --git a/zebra/ChangeLog b/zebra/ChangeLog
index 17e929ee..7a23ace4 100644
--- a/zebra/ChangeLog
+++ b/zebra/ChangeLog
@@ -1,3 +1,8 @@
+2007-08-14 Denis Ovsienko
+
+ * zebra_rib.c: (nexthop_active_update) Added a comment
+ and rewrote nexthop iteration.
+
2007-08-13 Denis Ovsienko
* kernel_socket.c: normalize rtm_type_str so it can be handled
diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c
index f61cbe31..e5cce1e8 100644
--- a/zebra/zebra_rib.c
+++ b/zebra/zebra_rib.c
@@ -881,27 +881,32 @@ nexthop_active_check (struct route_node *rn, struct rib *rib,
return CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
}
+/* Iterate over all nexthops of the given RIB entry and refresh their
+ * ACTIVE flag. rib->nexthop_active_num is updated accordingly. If any
+ * nexthop is found to toggle the ACTIVE flag, the whole rib structure
+ * is flagged with ZEBRA_FLAG_CHANGED. The 4th 'set' argument is
+ * transparently passed to nexthop_active_check().
+ *
+ * Return value is the new number of active nexthops.
+ */
+
static int
nexthop_active_update (struct route_node *rn, struct rib *rib, int set)
{
struct nexthop *nexthop;
- int active;
+ int prev_active, new_active;
rib->nexthop_active_num = 0;
UNSET_FLAG (rib->flags, ZEBRA_FLAG_CHANGED);
for (nexthop = rib->nexthop; nexthop; nexthop = nexthop->next)
- {
- active = CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
-
- nexthop_active_check (rn, rib, nexthop, set);
- if ((MULTIPATH_NUM == 0 || rib->nexthop_active_num < MULTIPATH_NUM)
- && active != CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
- SET_FLAG (rib->flags, ZEBRA_FLAG_CHANGED);
-
- if (CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE))
- rib->nexthop_active_num++;
- }
+ {
+ prev_active = CHECK_FLAG (nexthop->flags, NEXTHOP_FLAG_ACTIVE);
+ if ((new_active = nexthop_active_check (rn, rib, nexthop, set)))
+ rib->nexthop_active_num++;
+ if (prev_active != new_active)
+ SET_FLAG (rib->flags, ZEBRA_FLAG_CHANGED);
+ }
return rib->nexthop_active_num;
}