Skip to content

Commit

Permalink
Fix external packing calculation for ospf3
Browse files Browse the repository at this point in the history
  • Loading branch information
Hannes Gredler committed Sep 20, 2023
1 parent f47538a commit c93c028
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions code/lspgen/src/lspgen.c
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,7 @@ lspgen_gen_ospf3_attr(struct lsdb_ctx_ *ctx)
struct lsdb_attr_ attr_template;
dict_itor *itor;
__uint128_t addr, inc, ext_addr6, ext_incr6, addr_offset;
uint32_t ext_per_node, metric;
uint32_t ext_per_node, metric, nodes_left, ext_left;

/*
* Walk the node DB.
Expand All @@ -746,6 +746,9 @@ lspgen_gen_ospf3_attr(struct lsdb_ctx_ *ctx)
ext_addr6 = lspgen_load_addr((uint8_t*)&ctx->ipv6_ext_prefix.address, IPV6_ADDR_LEN);
ext_incr6 = lspgen_get_prefix_inc(AF_INET6, ctx->ipv6_ext_prefix.len);

nodes_left = ctx->num_nodes;
ext_left = ctx->num_ext;

do {
node = *dict_itor_datum(itor);

Expand Down Expand Up @@ -787,7 +790,8 @@ lspgen_gen_ospf3_attr(struct lsdb_ctx_ *ctx)
#endif

/* external prefixes */
ext_per_node = ctx->num_ext / ctx->num_nodes;
ext_per_node = ext_left / nodes_left;
ext_left -= ext_per_node;
while (ext_per_node--) {
/* ipv6 external prefix */
lsdb_reset_attr_template(&attr_template);
Expand Down Expand Up @@ -879,6 +883,7 @@ lspgen_gen_ospf3_attr(struct lsdb_ctx_ *ctx)
#endif
}

nodes_left--;
} while (dict_itor_next(itor));

dict_itor_free(itor);
Expand Down

0 comments on commit c93c028

Please sign in to comment.