Skip to content

Commit 6f955a9

Browse files
almusildceara
authored andcommitted
route: Prevent memory leak with service monitor index.
Make sure the index is freed every time we are done with it. Fixes: 4bba54f ("controller: Skip LB route install when Service_Monitor is offline.") Signed-off-by: Ales Musil <amusil@redhat.com> Signed-off-by: Dumitru Ceara <dceara@redhat.com>
1 parent 12f3549 commit 6f955a9

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

controller/route.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,9 +194,6 @@ evaluate_lb_route_gates(struct hmap *gates,
194194
struct ovsdb_idl_index *service_monitor_by_selector,
195195
struct uuidset *relevant_service_monitors)
196196
{
197-
struct sbrec_service_monitor *filter =
198-
sbrec_service_monitor_index_init_row(service_monitor_by_selector);
199-
200197
struct lb_route_gate *g;
201198
HMAP_FOR_EACH (g, node, gates) {
202199
const char *checks = smap_get(&g->route->external_ids,
@@ -235,6 +232,9 @@ evaluate_lb_route_gates(struct hmap *gates,
235232
}
236233

237234
const char *tracked_lp = g->route->tracked_port->logical_port;
235+
struct sbrec_service_monitor *filter =
236+
sbrec_service_monitor_index_init_row(
237+
service_monitor_by_selector);
238238
sbrec_service_monitor_index_set_logical_port(filter, tracked_lp);
239239
sbrec_service_monitor_index_set_type(filter, "load-balancer");
240240
sbrec_service_monitor_index_set_protocol(filter, protocol);
@@ -256,14 +256,14 @@ evaluate_lb_route_gates(struct hmap *gates,
256256
!strcmp(monitor->status, "online");
257257
}
258258

259+
sbrec_service_monitor_index_destroy_row(filter);
260+
259261
if (g->any_online) {
260262
break;
261263
}
262264
}
263265
free(buf);
264266
}
265-
266-
sbrec_service_monitor_index_destroy_row(filter);
267267
}
268268

269269
/* Look up the gate decision for a specific route. Returns:

0 commit comments

Comments
 (0)