Skip to content

Commit c546627

Browse files
chandler0149igsilya
authored andcommitted
rconn: Fix fd leak when close monitor.
Prior to the patch, the last monitor vconn copied to the deleted one, causing the monitor fd to be leaked, the patch fixes it. Also update tests to cover this issue. Signed-off-by: Chandler Wu <chandler0149@gmail.com> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
1 parent a04b2a4 commit c546627

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

lib/rconn.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1285,6 +1285,7 @@ close_monitor(struct rconn *rc, size_t idx, int retval)
12851285
VLOG_DBG("%s: closing monitor connection to %s: %s",
12861286
rconn_get_name(rc), vconn_get_name(rc->monitors[idx]),
12871287
ovs_retval_to_string(retval));
1288+
vconn_close(rc->monitors[idx]);
12881289
rc->monitors[idx] = rc->monitors[--rc->n_monitors];
12891290
}
12901291

tests/ovs-ofctl.at

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3293,8 +3293,10 @@ dnl setup controller for br0 before starting the controller
32933293
AT_CHECK([ovs-vsctl -vsyslog:off set-controller br0 unix:testcontroller])
32943294

32953295
dnl then start listening on the '.snoop' connection
3296-
on_exit 'kill `cat ovs-ofctl-snoop.pid`'
3297-
AT_CHECK([ovs-ofctl -vsyslog:off --detach --no-chdir --pidfile=ovs-ofctl-snoop.pid snoop br0 > snoopbr0.txt 2>&1])
3296+
on_exit 'test -e ovs-ofctl-snoop.pid && kill `cat ovs-ofctl-snoop.pid`'
3297+
AT_CHECK([ovs-ofctl -vsyslog:off --detach --no-chdir \
3298+
--unixctl=snoop.ctl --pidfile=ovs-ofctl-snoop.pid \
3299+
snoop br0 > snoopbr0.txt 2>&1])
32983300

32993301
dnl finally start the controller
33003302
on_exit 'kill `cat ovs-testcontroller.pid`'
@@ -3306,6 +3308,9 @@ OVS_WAIT_UNTIL([grep -E "OFPT_FEATURES_REQUEST" snoopbr0.txt >/dev/null 2>&1])
33063308
OVS_WAIT_UNTIL([grep -E "OFPT_FEATURES_REPLY" snoopbr0.txt >/dev/null 2>&1])
33073309
OVS_WAIT_UNTIL([grep -E "OFPT_SET_CONFIG" snoopbr0.txt >/dev/null 2>&1])
33083310

3311+
AT_CHECK([ovs-appctl -t $(pwd)/snoop.ctl exit])
3312+
OVS_WAIT_WHILE([test -e ovs-ofctl-snoop.pid])
3313+
33093314
dnl need to suppress the 'connection failed' WARN message in ovs-vswitchd
33103315
dnl because we need ovs-vswitchd to have the controller config before starting
33113316
dnl the controller to 'snoop' the OpenFlow messages from beginning

0 commit comments

Comments
 (0)