diff --git a/zebra/redistribute.c b/zebra/redistribute.c index 9f63aeb4e9..5a0d4a563e 100644 --- a/zebra/redistribute.c +++ b/zebra/redistribute.c @@ -552,10 +552,7 @@ zebra_add_import_table_entry (struct route_node *rn, struct route_entry *re, con newre->nexthop_num = 0; newre->uptime = time(NULL); newre->instance = re->table; - - /* Assuming these routes are never recursive */ - for (nhop = re->nexthop; nhop; nhop = nhop->next) - route_entry_copy_nexthops(newre, nhop); + route_entry_copy_nexthops(newre, re->nexthop); rib_add_multipath(AFI_IP, SAFI_UNICAST, &p, NULL, newre); } diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 7016292ac0..e6341efaf0 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -198,21 +198,10 @@ route_entry_nexthop_add (struct route_entry *re, struct nexthop *nexthop) void route_entry_copy_nexthops (struct route_entry *re, struct nexthop *nh) { - struct nexthop *nexthop; - - nexthop = nexthop_new(); - nexthop->flags = nh->flags; - nexthop->type = nh->type; - nexthop->ifindex = nh->ifindex; - memcpy(&(nexthop->gate), &(nh->gate), sizeof(union g_addr)); - memcpy(&(nexthop->src), &(nh->src), sizeof(union g_addr)); - if (nh->nh_label) - nexthop_add_labels (nexthop, nh->nh_label_type, nh->nh_label->num_labels, - &nh->nh_label->label[0]); - nexthop->rparent = NULL; - route_entry_nexthop_add(re, nexthop); - if (CHECK_FLAG(nh->flags, NEXTHOP_FLAG_RECURSIVE)) - copy_nexthops(&nexthop->resolved, nh->resolved, nexthop); + assert(!re->nexthop); + copy_nexthops(&re->nexthop, nh, NULL); + for (struct nexthop *nexthop = nh; nh; nh = nh->next) + re->nexthop_num++; } /* Delete specified nexthop from the list. */ diff --git a/zebra/zebra_rnh.c b/zebra/zebra_rnh.c index 880002b2d0..c6fa800e0f 100644 --- a/zebra/zebra_rnh.c +++ b/zebra/zebra_rnh.c @@ -830,7 +830,6 @@ static void copy_state (struct rnh *rnh, struct route_entry *re, struct route_node *rn) { struct route_entry *state; - struct nexthop *nh; if (rnh->state) { @@ -845,8 +844,7 @@ copy_state (struct rnh *rnh, struct route_entry *re, struct route_node *rn) state->type = re->type; state->metric = re->metric; - for (nh = re->nexthop; nh; nh = nh->next) - route_entry_copy_nexthops(state, nh); + route_entry_copy_nexthops(state, re->nexthop); rnh->state = state; }