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
tree: 7e78d6019fa97c5ede5e2f95058c8dd12fb03186
  1. bin/
  2. binder/
  3. cellular/
  4. dbus/
  5. dbus_bindings/
  6. dhcp/
  7. doc/
  8. ethernet/
  9. init/
  10. mobile_operator_db/
  11. net/
  12. pppoe/
  13. setup_wifi/
  14. shims/
  15. supplicant/
  16. test-rpc-proxy/
  17. test-scripts/
  18. udev/
  19. upstart/
  20. vpn/
  21. wifi/
  22. wimax/
  23. .gitignore
  24. accessor_interface.h
  25. active_link_monitor.cc
  26. active_link_monitor.h
  27. active_link_monitor_unittest.cc
  28. adaptor_interfaces.h
  29. adaptor_stub.cc
  30. adaptor_stub.h
  31. Android.mk
  32. async_connection.cc
  33. async_connection.h
  34. async_connection_unittest.cc
  35. callbacks.h
  36. certificate_file.cc
  37. certificate_file.h
  38. certificate_file_unittest.cc
  39. connection.cc
  40. connection.h
  41. connection_diagnostics.cc
  42. connection_diagnostics.h
  43. connection_diagnostics_unittest.cc
  44. connection_health_checker.cc
  45. connection_health_checker.h
  46. connection_health_checker_unittest.cc
  47. connection_info.cc
  48. connection_info.h
  49. connection_info_reader.cc
  50. connection_info_reader.h
  51. connection_info_reader_unittest.cc
  52. connection_info_unittest.cc
  53. connection_tester.cc
  54. connection_tester.h
  55. connection_tester_unittest.cc
  56. connection_unittest.cc
  57. connectivity_trial.cc
  58. connectivity_trial.h
  59. connectivity_trial_unittest.cc
  60. control_interface.h
  61. crypto_des_cbc.cc
  62. crypto_des_cbc.h
  63. crypto_des_cbc_unittest.cc
  64. crypto_interface.h
  65. crypto_provider.cc
  66. crypto_provider.h
  67. crypto_provider_unittest.cc
  68. crypto_rot47.cc
  69. crypto_rot47.h
  70. crypto_rot47_unittest.cc
  71. crypto_util_proxy.cc
  72. crypto_util_proxy.h
  73. crypto_util_proxy_unittest.cc
  74. daemon_task.cc
  75. daemon_task.h
  76. daemon_task_unittest.cc
  77. dbus_properties_proxy_interface.h
  78. default_profile.cc
  79. default_profile.h
  80. default_profile_unittest.cc
  81. device.cc
  82. device.h
  83. device_claimer.cc
  84. device_claimer.h
  85. device_claimer_unittest.cc
  86. device_info.cc
  87. device_info.h
  88. device_info_unittest.cc
  89. device_stub.h
  90. device_unittest.cc
  91. dns_client.cc
  92. dns_client.h
  93. dns_client_factory.cc
  94. dns_client_factory.h
  95. dns_client_unittest.cc
  96. dns_server_proxy.cc
  97. dns_server_proxy.h
  98. dns_server_proxy_factory.cc
  99. dns_server_proxy_factory.h
  100. dns_server_tester.cc
  101. dns_server_tester.h
  102. dns_server_tester_unittest.cc
  103. eap_credentials.cc
  104. eap_credentials.h
  105. eap_credentials_unittest.cc
  106. eap_listener.cc
  107. eap_listener.h
  108. eap_listener_unittest.cc
  109. eap_protocol.h
  110. ephemeral_profile.cc
  111. ephemeral_profile.h
  112. error.cc
  113. error.h
  114. error_unittest.cc
  115. event_dispatcher.cc
  116. event_dispatcher.h
  117. external_task.cc
  118. external_task.h
  119. external_task_unittest.cc
  120. fake_store.cc
  121. fake_store.h
  122. file_io.cc
  123. file_io.h
  124. file_reader.cc
  125. file_reader.h
  126. file_reader_unittest.cc
  127. firewall_proxy_interface.h
  128. geolocation_info.cc
  129. geolocation_info.h
  130. HACKING
  131. hook_table.cc
  132. hook_table.h
  133. hook_table_unittest.cc
  134. http_request.cc
  135. http_request.h
  136. http_request_unittest.cc
  137. http_url.cc
  138. http_url.h
  139. http_url_unittest.cc
  140. icmp.cc
  141. icmp.h
  142. icmp_session.cc
  143. icmp_session.h
  144. icmp_session_factory.cc
  145. icmp_session_factory.h
  146. icmp_session_unittest.cc
  147. icmp_unittest.cc
  148. ip_address_store.cc
  149. ip_address_store.h
  150. ip_address_store_unittest.cc
  151. ipconfig.cc
  152. ipconfig.h
  153. ipconfig_adaptor_stub.cc
  154. ipconfig_adaptor_stub.h
  155. ipconfig_unittest.cc
  156. json_store.cc
  157. json_store.h
  158. json_store_unittest.cc
  159. key_file_store.cc
  160. key_file_store.h
  161. key_file_store_unittest.cc
  162. key_value_store.cc
  163. key_value_store.h
  164. key_value_store_unittest.cc
  165. libshill-client-test.pc.in
  166. libshill-client.pc.in
  167. link_monitor.cc
  168. link_monitor.h
  169. link_monitor_unittest.cc
  170. logging.cc
  171. logging.h
  172. manager.cc
  173. manager.h
  174. manager_unittest.cc
  175. metrics.cc
  176. metrics.h
  177. metrics_unittest.cc
  178. mock_active_link_monitor.cc
  179. mock_active_link_monitor.h
  180. mock_adaptors.cc
  181. mock_adaptors.h
  182. mock_ares.cc
  183. mock_ares.h
  184. mock_async_connection.cc
  185. mock_async_connection.h
  186. mock_certificate_file.cc
  187. mock_certificate_file.h
  188. mock_connection.cc
  189. mock_connection.h
  190. mock_connection_health_checker.cc
  191. mock_connection_health_checker.h
  192. mock_connection_info_reader.cc
  193. mock_connection_info_reader.h
  194. mock_connectivity_trial.cc
  195. mock_connectivity_trial.h
  196. mock_control.cc
  197. mock_control.h
  198. mock_crypto_util_proxy.cc
  199. mock_crypto_util_proxy.h
  200. mock_dbus_manager.cc
  201. mock_dbus_manager.h
  202. mock_dbus_properties_proxy.cc
  203. mock_dbus_properties_proxy.h
  204. mock_device.cc
  205. mock_device.h
  206. mock_device_claimer.cc
  207. mock_device_claimer.h
  208. mock_device_info.cc
  209. mock_device_info.h
  210. mock_dns_client.cc
  211. mock_dns_client.h
  212. mock_dns_client_factory.cc
  213. mock_dns_client_factory.h
  214. mock_dns_server_proxy.cc
  215. mock_dns_server_proxy.h
  216. mock_dns_server_proxy_factory.cc
  217. mock_dns_server_proxy_factory.h
  218. mock_dns_server_tester.cc
  219. mock_dns_server_tester.h
  220. mock_eap_credentials.cc
  221. mock_eap_credentials.h
  222. mock_eap_listener.cc
  223. mock_eap_listener.h
  224. mock_event_dispatcher.cc
  225. mock_event_dispatcher.h
  226. mock_external_task.cc
  227. mock_external_task.h
  228. mock_file_io.h
  229. mock_firewall_proxy.h
  230. mock_http_request.cc
  231. mock_http_request.h
  232. mock_icmp.cc
  233. mock_icmp.h
  234. mock_icmp_session.cc
  235. mock_icmp_session.h
  236. mock_icmp_session_factory.cc
  237. mock_icmp_session_factory.h
  238. mock_ip_address_store.cc
  239. mock_ip_address_store.h
  240. mock_ipconfig.cc
  241. mock_ipconfig.h
  242. mock_link_monitor.cc
  243. mock_link_monitor.h
  244. mock_log.cc
  245. mock_log.h
  246. mock_log_unittest.cc
  247. mock_manager.cc
  248. mock_manager.h
  249. mock_metrics.cc
  250. mock_metrics.h
  251. mock_passive_link_monitor.cc
  252. mock_passive_link_monitor.h
  253. mock_pending_activation_store.cc
  254. mock_pending_activation_store.h
  255. mock_portal_detector.cc
  256. mock_portal_detector.h
  257. mock_power_manager.cc
  258. mock_power_manager.h
  259. mock_power_manager_proxy.cc
  260. mock_power_manager_proxy.h
  261. mock_ppp_device.cc
  262. mock_ppp_device.h
  263. mock_ppp_device_factory.cc
  264. mock_ppp_device_factory.h
  265. mock_process_manager.cc
  266. mock_process_manager.h
  267. mock_profile.cc
  268. mock_profile.h
  269. mock_property_store.cc
  270. mock_property_store.h
  271. mock_resolver.cc
  272. mock_resolver.h
  273. mock_routing_table.cc
  274. mock_routing_table.h
  275. mock_service.cc
  276. mock_service.h
  277. mock_socket_info_reader.cc
  278. mock_socket_info_reader.h
  279. mock_store.cc
  280. mock_store.h
  281. mock_throttler.cc
  282. mock_throttler.h
  283. mock_traffic_monitor.cc
  284. mock_traffic_monitor.h
  285. mock_virtual_device.cc
  286. mock_virtual_device.h
  287. MODULE_LICENSE_APACHE2
  288. NETLINK_MESSAGES.txt
  289. nice_mock_control.cc
  290. nice_mock_control.h
  291. NOTICE
  292. OWNERS
  293. passive_link_monitor.cc
  294. passive_link_monitor.h
  295. passive_link_monitor_unittest.cc
  296. pending_activation_store.cc
  297. pending_activation_store.h
  298. pending_activation_store_unittest.cc
  299. portal_detector.cc
  300. portal_detector.h
  301. portal_detector_unittest.cc
  302. power_manager.cc
  303. power_manager.h
  304. power_manager_proxy_interface.h
  305. power_manager_proxy_stub.cc
  306. power_manager_proxy_stub.h
  307. power_manager_unittest.cc
  308. ppp_daemon.cc
  309. ppp_daemon.h
  310. ppp_daemon_unittest.cc
  311. ppp_device.cc
  312. ppp_device.h
  313. ppp_device_factory.cc
  314. ppp_device_factory.h
  315. ppp_device_unittest.cc
  316. PRESUBMIT.cfg
  317. process_manager.cc
  318. process_manager.h
  319. process_manager_unittest.cc
  320. profile.cc
  321. profile.h
  322. profile_adaptor_stub.cc
  323. profile_adaptor_stub.h
  324. profile_unittest.cc
  325. property_accessor.h
  326. property_accessor_unittest.cc
  327. property_iterator.h
  328. property_observer.h
  329. property_observer_interface.h
  330. property_observer_unittest.cc
  331. property_store.cc
  332. property_store.h
  333. property_store_unittest.cc
  334. property_store_unittest.h
  335. protobuf_lite_streams.cc
  336. protobuf_lite_streams.h
  337. provider_db_unittest.bfd
  338. provider_interface.h
  339. refptr_types.h
  340. resolver.cc
  341. resolver.h
  342. resolver_unittest.cc
  343. result_aggregator.cc
  344. result_aggregator.h
  345. result_aggregator_unittest.cc
  346. routing_table.cc
  347. routing_table.h
  348. routing_table_entry.h
  349. routing_table_unittest.cc
  350. rpc_service_watcher_interface.h
  351. rpc_task.cc
  352. rpc_task.h
  353. rpc_task_adaptor_stub.cc
  354. rpc_task_adaptor_stub.h
  355. rpc_task_unittest.cc
  356. scope_logger.cc
  357. scope_logger.h
  358. scope_logger_unittest.cc
  359. scoped_umask.cc
  360. scoped_umask.h
  361. service.cc
  362. service.h
  363. service_property_change_notifier.cc
  364. service_property_change_notifier.h
  365. service_property_change_test.cc
  366. service_property_change_test.h
  367. service_sorter.h
  368. service_under_test.cc
  369. service_under_test.h
  370. service_unittest.cc
  371. shill-client.gyp
  372. shill.gyp
  373. shill.gypi
  374. shill.rc
  375. shill_ares.cc
  376. shill_ares.h
  377. shill_config.cc
  378. shill_config.h
  379. shill_daemon.cc
  380. shill_daemon.h
  381. shill_main.cc
  382. shill_test_config.cc
  383. shill_test_config.h
  384. socket_info.cc
  385. socket_info.h
  386. socket_info_reader.cc
  387. socket_info_reader.h
  388. socket_info_reader_unittest.cc
  389. socket_info_unittest.cc
  390. static_ip_parameters.cc
  391. static_ip_parameters.h
  392. static_ip_parameters_unittest.cc
  393. store_interface.h
  394. stub_storage.h
  395. technology.cc
  396. technology.h
  397. technology_unittest.cc
  398. test_event_dispatcher.h
  399. TESTING
  400. testing.h
  401. testrunner.cc
  402. tethering.cc
  403. tethering.h
  404. third_party_vpn_adaptor_stub.cc
  405. third_party_vpn_adaptor_stub.h
  406. throttler.cc
  407. throttler.h
  408. throttler_unittest.cc
  409. traffic_monitor.cc
  410. traffic_monitor.h
  411. traffic_monitor_unittest.cc
  412. virtual_device.cc
  413. virtual_device.h
  414. virtual_device_unittest.cc