shill: OpenVPNDriver: Fix deletion of tunnel interfaces during cleanup
shill used to have a ProcessKiller class, which was used to invoke a
callback when the external openvpn process was killed. This callback
cleanly removed the tunnel interface. But later ProcessKiller was removed
in favor of ProcessManager. Commit 609e2f164a71c1 ("shill: OpenVPNDriver:
remove use of ProcessKiller") converted OpenVPNDriver
to use the new ProcessManager interface, but unlike ProcessKiller,
ProcessManager will not invoke callbacks for a watched process after
OpenVPNDriver has requested termination. So, per the documentation in
process_manager.h for StopProcess(), this will schedule a callback that
never gets run:
process_manager_->UpdateExitCallback(pid_, callback);
process_manager_->StopProcess(pid_);
Consequently, users report that the tunX interfaces are never deleted,
and a bunch of old unused tunX interfaces "pile up" over time as the
user connects and disconnects from the VPN.
To work around this, terminate the openvpn daemon synchronously, then
delete the tunX interface without a callback. (In my testing openvpn
seems to exit immediately upon receiving SIGTERM, so it generally should
not block shill.)
BUG=chromium:707518
TEST=manually connect/disconnect from an openvpn server,
then run `ifconfig` to verify that the tunX interface is gone
TEST=manually connect to an openvpn server, then `killall -SEGV openvpn`
and verify that the tunX interface is gone
TEST=unit tests
Change-Id: I428ad68e2bcfa9f6260ca954a836b05bb64aa51c
Reviewed-on: https://chromium-review.googlesource.com/490524
Commit-Ready: Kevin Cernekee <cernekee@chromium.org>
Tested-by: Kevin Cernekee <cernekee@chromium.org>
Reviewed-by: Ben Chan <benchan@chromium.org>
3 files changed