Skip to content

Commit

Permalink
ovn-northd: Fix memory leak and incorrect limiting of ECMP routes.
Browse files Browse the repository at this point in the history
If route count reaches UINT16_MAX, ecmp_groups_add_route() will leak the
allocated route structure.  Also, since group->route_count incremented
unconditionally, next attempt to add new route will succeed, because the
value of 'route_count' is zero now and out of sync with the real number
of routes.

Fixes: 4e53974 ("ovn-northd: Support ECMP routes.")
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
Acked-by: Mark Michelson <mmichels@redhat.com>
Signed-off-by: Han Zhou <hzhou@ovn.org>
  • Loading branch information
igsilya authored and hzhou8 committed May 5, 2020
1 parent 6ec0b82 commit 4052d48
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions northd/ovn-northd.c
Original file line number Diff line number Diff line change
Expand Up @@ -7194,15 +7194,15 @@ static void
ecmp_groups_add_route(struct ecmp_groups_node *group,
const struct parsed_route *route)
{
struct ecmp_route_list_node *er = xmalloc(sizeof *er);
er->route = route;
er->id = ++group->route_count;
if (er->id == 0) {
if (group->route_count == UINT16_MAX) {
static struct vlog_rate_limit rl = VLOG_RATE_LIMIT_INIT(5, 1);
VLOG_WARN_RL(&rl, "too many routes in a single ecmp group.");
return;
}

struct ecmp_route_list_node *er = xmalloc(sizeof *er);
er->route = route;
er->id = ++group->route_count;
ovs_list_insert(&group->route_list, &er->list_node);
}

Expand Down

0 comments on commit 4052d48

Please sign in to comment.