/bin/wifi: restart dhclient on wpa_supplicant reconfigure.

Commit 1b1a151de35a9f06ecf0b7311499ec365da36cf2 introduced an
optimization to avoid restarting wpa_supplicant if it is already running
by sending it a "reconfigure" command. This caused it to bypass the
ifplugd action that starts dhclient. As a result, no new DHCP lease is
requested when switching APs (such as from a provisioning AP to a
restricted AP or to another provisioning AP).

Change-Id: Ic0fb633e7b275a6292c681126eee02b15de80849
diff --git a/wifi/quantenna.py b/wifi/quantenna.py
index f3f96ef..bb541f5 100755
--- a/wifi/quantenna.py
+++ b/wifi/quantenna.py
@@ -54,11 +54,11 @@
 
 
 def _set_link_state(hif, state):
-  subprocess.check_output(['if' + state, hif])
+  subprocess.check_call(['if' + state, hif])
 
 
 def _ifplugd_action(hif, state):
-  subprocess.check_output(['/etc/ifplugd/ifplugd.action', hif, state])
+  subprocess.check_call(['/etc/ifplugd/ifplugd.action', hif, state])
 
 
 def _parse_scan_result(line):
diff --git a/wifi/wifi.py b/wifi/wifi.py
index 34bb5e8..e0cb421 100755
--- a/wifi/wifi.py
+++ b/wifi/wifi.py
@@ -898,8 +898,12 @@
           "Couldn't stop hostapd to start wpa_supplicant.")
 
   if already_running:
+    subprocess.check_call(['ifdown', interface])
+    subprocess.check_call(['/etc/ifplugd/ifplugd.action', interface, 'down'])
     if not _reconfigure_wpa_supplicant(interface):
       raise utils.BinWifiException('Failed to reconfigure wpa_supplicant.')
+    subprocess.check_call(['ifup', interface])
+    subprocess.check_call(['/etc/ifplugd/ifplugd.action', interface, 'up'])
   elif not _start_wpa_supplicant(interface, tmp_config_filename):
     raise utils.BinWifiException(
         'wpa_supplicant failed to start.  Look at wpa_supplicant logs for '