[ovs-dev] [PATCH ovn] ovn-northd: Fix memory leak and incorrect limiting of ECMP routes.
Ilya Maximets
i.maximets at ovn.org
Tue May 5 11:08:50 UTC 2020
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: 4e53974bdc4e ("ovn-northd: Support ECMP routes.")
Signed-off-by: Ilya Maximets <i.maximets at ovn.org>
---
northd/ovn-northd.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/northd/ovn-northd.c b/northd/ovn-northd.c
index 742aad85e..6c9e8148f 100644
--- a/northd/ovn-northd.c
+++ b/northd/ovn-northd.c
@@ -7178,15 +7178,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);
}
--
2.25.3
More information about the dev
mailing list