Skip to content

Commit a56bfa1

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 b672ea1 commit a56bfa1

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
@@ -3561,8 +3561,10 @@ dnl setup controller for br0 before starting the controller
35613561
AT_CHECK([ovs-vsctl -vsyslog:off set-controller br0 unix:testcontroller])
35623562

35633563
dnl then start listening on the '.snoop' connection
3564-
on_exit 'kill `cat ovs-ofctl-snoop.pid`'
3565-
AT_CHECK([ovs-ofctl -vsyslog:off --detach --no-chdir --pidfile=ovs-ofctl-snoop.pid snoop br0 > snoopbr0.txt 2>&1])
3564+
on_exit 'test -e ovs-ofctl-snoop.pid && kill `cat ovs-ofctl-snoop.pid`'
3565+
AT_CHECK([ovs-ofctl -vsyslog:off --detach --no-chdir \
3566+
--unixctl=snoop.ctl --pidfile=ovs-ofctl-snoop.pid \
3567+
snoop br0 > snoopbr0.txt 2>&1])
35663568

35673569
dnl finally start the controller
35683570
on_exit 'kill `cat ovs-testcontroller.pid`'
@@ -3574,6 +3576,9 @@ OVS_WAIT_UNTIL([grep -E "OFPT_FEATURES_REQUEST" snoopbr0.txt >/dev/null 2>&1])
35743576
OVS_WAIT_UNTIL([grep -E "OFPT_FEATURES_REPLY" snoopbr0.txt >/dev/null 2>&1])
35753577
OVS_WAIT_UNTIL([grep -E "OFPT_SET_CONFIG" snoopbr0.txt >/dev/null 2>&1])
35763578

3579+
AT_CHECK([ovs-appctl -t $(pwd)/snoop.ctl exit])
3580+
OVS_WAIT_WHILE([test -e ovs-ofctl-snoop.pid])
3581+
35773582
dnl need to suppress the 'connection failed' WARN message in ovs-vswitchd
35783583
dnl because we need ovs-vswitchd to have the controller config before starting
35793584
dnl the controller to 'snoop' the OpenFlow messages from beginning

0 commit comments

Comments
 (0)