DISPATCH-335 - Added code to balance link routes over remote routers
(cherry picked from commit 2b284971d5c3dcc7d379809f0a1fe753e561e72d)
diff --git a/src/router_core/forwarder.c b/src/router_core/forwarder.c
index 836bc02..43c966f 100644
--- a/src/router_core/forwarder.c
+++ b/src/router_core/forwarder.c
@@ -559,12 +559,29 @@
//
// Look for a next-hop we can use to forward the link-attach.
//
- int router_bit;
qdr_node_t *next_node;
- if (qd_bitmask_first_set(addr->rnodes, &router_bit)) {
- qdr_node_t *rnode = core->routers_by_mask_bit[router_bit];
+ if (addr->cost_epoch != core->cost_epoch) {
+ addr->next_remote = -1;
+ addr->cost_epoch = core->cost_epoch;
+ }
+
+ if (addr->next_remote < 0) {
+ qd_bitmask_first_set(addr->rnodes, &addr->next_remote);
+ }
+
+ if (addr->next_remote >= 0) {
+
+ qdr_node_t *rnode = core->routers_by_mask_bit[addr->next_remote];
+
if (rnode) {
+ //
+ // Advance the addr->next_remote so there will be link balance across containers
+ //
+ _qdbm_next(addr->rnodes, &addr->next_remote);
+ if (addr->next_remote == -1)
+ qd_bitmask_first_set(addr->rnodes, &addr->next_remote);
+
if (rnode->next_hop)
next_node = rnode->next_hop;
else