Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "shill/dhcp_config.h" |
| 6 | |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 7 | #include <arpa/inet.h> |
| 8 | |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 9 | #include <base/file_util.h> |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 10 | #include <base/logging.h> |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 11 | #include <base/stringprintf.h> |
Chris Masone | 43b48a1 | 2011-07-01 13:37:07 -0700 | [diff] [blame] | 12 | #include <chromeos/dbus/service_constants.h> |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 13 | |
| 14 | #include "shill/dhcpcd_proxy.h" |
| 15 | #include "shill/dhcp_provider.h" |
Paul Stewart | 26b327e | 2011-10-19 11:38:09 -0700 | [diff] [blame] | 16 | #include "shill/event_dispatcher.h" |
Darin Petkov | 3258a81 | 2011-06-23 11:28:45 -0700 | [diff] [blame] | 17 | #include "shill/glib.h" |
Paul Stewart | 1d18e8c | 2011-07-15 11:00:31 -0700 | [diff] [blame] | 18 | #include "shill/ip_address.h" |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 19 | #include "shill/proxy_factory.h" |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 20 | |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 21 | using std::string; |
| 22 | using std::vector; |
| 23 | |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 24 | namespace shill { |
| 25 | |
Chris Masone | 0756f23 | 2011-07-21 17:24:00 -0700 | [diff] [blame] | 26 | // static |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 27 | const char DHCPConfig::kConfigurationKeyBroadcastAddress[] = "BroadcastAddress"; |
| 28 | const char DHCPConfig::kConfigurationKeyDNS[] = "DomainNameServers"; |
| 29 | const char DHCPConfig::kConfigurationKeyDomainName[] = "DomainName"; |
| 30 | const char DHCPConfig::kConfigurationKeyDomainSearch[] = "DomainSearch"; |
| 31 | const char DHCPConfig::kConfigurationKeyIPAddress[] = "IPAddress"; |
| 32 | const char DHCPConfig::kConfigurationKeyMTU[] = "InterfaceMTU"; |
| 33 | const char DHCPConfig::kConfigurationKeyRouters[] = "Routers"; |
| 34 | const char DHCPConfig::kConfigurationKeySubnetCIDR[] = "SubnetCIDR"; |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 35 | const char DHCPConfig::kDHCPCDPath[] = "/sbin/dhcpcd"; |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 36 | const char DHCPConfig::kDHCPCDPathFormatLease[] = "var/run/dhcpcd-%s.lease"; |
| 37 | const char DHCPConfig::kDHCPCDPathFormatPID[] = "var/run/dhcpcd-%s.pid"; |
Darin Petkov | f9b0ca8 | 2011-06-20 12:10:23 -0700 | [diff] [blame] | 38 | const char DHCPConfig::kReasonBound[] = "BOUND"; |
| 39 | const char DHCPConfig::kReasonFail[] = "FAIL"; |
| 40 | const char DHCPConfig::kReasonRebind[] = "REBIND"; |
| 41 | const char DHCPConfig::kReasonReboot[] = "REBOOT"; |
| 42 | const char DHCPConfig::kReasonRenew[] = "RENEW"; |
Chris Masone | 0756f23 | 2011-07-21 17:24:00 -0700 | [diff] [blame] | 43 | // static |
| 44 | const char DHCPConfig::kType[] = "dhcp"; |
Darin Petkov | f9b0ca8 | 2011-06-20 12:10:23 -0700 | [diff] [blame] | 45 | |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 46 | |
Chris Masone | 19e3040 | 2011-07-19 15:48:47 -0700 | [diff] [blame] | 47 | DHCPConfig::DHCPConfig(ControlInterface *control_interface, |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 48 | EventDispatcher *dispatcher, |
Chris Masone | 19e3040 | 2011-07-19 15:48:47 -0700 | [diff] [blame] | 49 | DHCPProvider *provider, |
Darin Petkov | f65e928 | 2011-06-21 14:29:56 -0700 | [diff] [blame] | 50 | const string &device_name, |
Paul Stewart | d32f484 | 2012-01-11 16:08:13 -0800 | [diff] [blame^] | 51 | const string &request_hostname, |
Darin Petkov | 3258a81 | 2011-06-23 11:28:45 -0700 | [diff] [blame] | 52 | GLib *glib) |
Chris Masone | 0756f23 | 2011-07-21 17:24:00 -0700 | [diff] [blame] | 53 | : IPConfig(control_interface, device_name, kType), |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 54 | proxy_factory_(ProxyFactory::GetInstance()), |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 55 | provider_(provider), |
Paul Stewart | d32f484 | 2012-01-11 16:08:13 -0800 | [diff] [blame^] | 56 | request_hostname_(request_hostname), |
Darin Petkov | f7897bc | 2011-06-08 17:13:36 -0700 | [diff] [blame] | 57 | pid_(0), |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 58 | child_watch_tag_(0), |
| 59 | root_("/"), |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 60 | task_factory_(this), |
| 61 | dispatcher_(dispatcher), |
Darin Petkov | f7897bc | 2011-06-08 17:13:36 -0700 | [diff] [blame] | 62 | glib_(glib) { |
mukesh agrawal | de29fa8 | 2011-09-16 16:16:36 -0700 | [diff] [blame] | 63 | mutable_store()->RegisterConstString(flimflam::kAddressProperty, |
| 64 | &(properties().address)); |
Darin Petkov | f65e928 | 2011-06-21 14:29:56 -0700 | [diff] [blame] | 65 | VLOG(2) << __func__ << ": " << device_name; |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 66 | } |
| 67 | |
| 68 | DHCPConfig::~DHCPConfig() { |
Darin Petkov | f65e928 | 2011-06-21 14:29:56 -0700 | [diff] [blame] | 69 | VLOG(2) << __func__ << ": " << device_name(); |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 70 | |
| 71 | // Don't leave behind dhcpcd running. |
| 72 | Stop(); |
| 73 | |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 74 | // Make sure we don't get any callbacks to the destroyed instance. |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 75 | CleanupClientState(); |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 76 | } |
| 77 | |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 78 | bool DHCPConfig::RequestIP() { |
Darin Petkov | f65e928 | 2011-06-21 14:29:56 -0700 | [diff] [blame] | 79 | VLOG(2) << __func__ << ": " << device_name(); |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 80 | if (!pid_) { |
| 81 | return Start(); |
| 82 | } |
| 83 | if (!proxy_.get()) { |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 84 | LOG(ERROR) << "Unable to request IP before acquiring destination."; |
| 85 | return Restart(); |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 86 | } |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 87 | return RenewIP(); |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 88 | } |
| 89 | |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 90 | bool DHCPConfig::RenewIP() { |
Darin Petkov | f65e928 | 2011-06-21 14:29:56 -0700 | [diff] [blame] | 91 | VLOG(2) << __func__ << ": " << device_name(); |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 92 | if (!pid_) { |
| 93 | return false; |
| 94 | } |
Darin Petkov | aceede3 | 2011-07-18 15:32:38 -0700 | [diff] [blame] | 95 | proxy_->Rebind(device_name()); |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 96 | return true; |
| 97 | } |
| 98 | |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 99 | bool DHCPConfig::ReleaseIP() { |
Darin Petkov | f65e928 | 2011-06-21 14:29:56 -0700 | [diff] [blame] | 100 | VLOG(2) << __func__ << ": " << device_name(); |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 101 | if (!pid_) { |
| 102 | return true; |
| 103 | } |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 104 | if (proxy_.get()) { |
| 105 | proxy_->Release(device_name()); |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 106 | } |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 107 | Stop(); |
| 108 | return true; |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 109 | } |
| 110 | |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 111 | void DHCPConfig::InitProxy(const string &service) { |
| 112 | // Defer proxy creation because dbus-c++ doesn't allow registration of new |
| 113 | // D-Bus objects in the context of a D-Bus signal handler. |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 114 | if (!proxy_.get()) { |
Darin Petkov | a7b8949 | 2011-07-27 12:48:17 -0700 | [diff] [blame] | 115 | dispatcher_->PostTask( |
| 116 | task_factory_.NewRunnableMethod(&DHCPConfig::InitProxyTask, service)); |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | void DHCPConfig::InitProxyTask(const string &service) { |
| 121 | if (!proxy_.get()) { |
| 122 | VLOG(2) << "Init DHCP Proxy: " << device_name() << " at " << service; |
Darin Petkov | ab565bb | 2011-10-06 02:55:51 -0700 | [diff] [blame] | 123 | proxy_.reset(proxy_factory_->CreateDHCPProxy(service)); |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 124 | } |
| 125 | } |
| 126 | |
Darin Petkov | f9b0ca8 | 2011-06-20 12:10:23 -0700 | [diff] [blame] | 127 | void DHCPConfig::ProcessEventSignal(const string &reason, |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 128 | const Configuration &configuration) { |
| 129 | LOG(INFO) << "Event reason: " << reason; |
Darin Petkov | f9b0ca8 | 2011-06-20 12:10:23 -0700 | [diff] [blame] | 130 | if (reason == kReasonFail) { |
| 131 | LOG(ERROR) << "Received failure event from DHCP client."; |
| 132 | UpdateProperties(IPConfig::Properties(), false); |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 133 | return; |
| 134 | } |
Darin Petkov | f9b0ca8 | 2011-06-20 12:10:23 -0700 | [diff] [blame] | 135 | if (reason != kReasonBound && |
| 136 | reason != kReasonRebind && |
| 137 | reason != kReasonReboot && |
| 138 | reason != kReasonRenew) { |
| 139 | LOG(WARNING) << "Event ignored."; |
| 140 | return; |
| 141 | } |
| 142 | IPConfig::Properties properties; |
| 143 | CHECK(ParseConfiguration(configuration, &properties)); |
| 144 | UpdateProperties(properties, true); |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 145 | } |
| 146 | |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 147 | bool DHCPConfig::Start() { |
Darin Petkov | f65e928 | 2011-06-21 14:29:56 -0700 | [diff] [blame] | 148 | VLOG(2) << __func__ << ": " << device_name(); |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 149 | |
Paul Stewart | d32f484 | 2012-01-11 16:08:13 -0800 | [diff] [blame^] | 150 | vector<char *> args; |
| 151 | args.push_back(const_cast<char *>(kDHCPCDPath)); |
| 152 | args.push_back(const_cast<char *>("-B")); // foreground |
| 153 | args.push_back(const_cast<char *>(device_name().c_str())); |
| 154 | if (!request_hostname_.empty()) { |
| 155 | args.push_back(const_cast<char *>("-h")); // request hostname |
| 156 | args.push_back(const_cast<char *>(request_hostname_.c_str())); |
| 157 | } |
| 158 | args.push_back(NULL); |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 159 | char *envp[1] = { NULL }; |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 160 | |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 161 | CHECK(!pid_); |
Darin Petkov | f7897bc | 2011-06-08 17:13:36 -0700 | [diff] [blame] | 162 | if (!glib_->SpawnAsync(NULL, |
Paul Stewart | d32f484 | 2012-01-11 16:08:13 -0800 | [diff] [blame^] | 163 | args.data(), |
Darin Petkov | f7897bc | 2011-06-08 17:13:36 -0700 | [diff] [blame] | 164 | envp, |
| 165 | G_SPAWN_DO_NOT_REAP_CHILD, |
| 166 | NULL, |
| 167 | NULL, |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 168 | &pid_, |
Darin Petkov | f7897bc | 2011-06-08 17:13:36 -0700 | [diff] [blame] | 169 | NULL)) { |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 170 | LOG(ERROR) << "Unable to spawn " << kDHCPCDPath; |
| 171 | return false; |
| 172 | } |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 173 | LOG(INFO) << "Spawned " << kDHCPCDPath << " with pid: " << pid_; |
Darin Petkov | f7897bc | 2011-06-08 17:13:36 -0700 | [diff] [blame] | 174 | provider_->BindPID(pid_, this); |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 175 | CHECK(!child_watch_tag_); |
| 176 | child_watch_tag_ = glib_->ChildWatchAdd(pid_, ChildWatchCallback, this); |
Darin Petkov | d1b715b | 2011-06-02 21:21:22 -0700 | [diff] [blame] | 177 | return true; |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 178 | } |
| 179 | |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 180 | void DHCPConfig::Stop() { |
| 181 | if (pid_) { |
| 182 | VLOG(2) << "Terminating " << pid_; |
| 183 | PLOG_IF(ERROR, kill(pid_, SIGTERM) < 0); |
| 184 | } |
| 185 | } |
| 186 | |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 187 | bool DHCPConfig::Restart() { |
| 188 | // Check to ensure that this instance doesn't get destroyed in the middle of |
| 189 | // this call. If stopping a running client while there's only one reference to |
| 190 | // this instance, we will end up destroying it when the PID is unbound from |
| 191 | // the Provider. Since the Provider doesn't invoke Restart, this would mean |
| 192 | // that Restart was erroneously executed through a bare reference. |
| 193 | CHECK(!pid_ || !HasOneRef()); |
| 194 | Stop(); |
| 195 | if (pid_) { |
| 196 | provider_->UnbindPID(pid_); |
| 197 | } |
| 198 | CleanupClientState(); |
| 199 | return Start(); |
| 200 | } |
| 201 | |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 202 | string DHCPConfig::GetIPv4AddressString(unsigned int address) { |
| 203 | char str[INET_ADDRSTRLEN]; |
| 204 | if (inet_ntop(AF_INET, &address, str, arraysize(str))) { |
| 205 | return str; |
| 206 | } |
| 207 | LOG(ERROR) << "Unable to convert IPv4 address to string: " << address; |
| 208 | return ""; |
| 209 | } |
| 210 | |
| 211 | bool DHCPConfig::ParseConfiguration(const Configuration& configuration, |
| 212 | IPConfig::Properties *properties) { |
| 213 | VLOG(2) << __func__; |
Chris Masone | 43b48a1 | 2011-07-01 13:37:07 -0700 | [diff] [blame] | 214 | properties->method = flimflam::kTypeDHCP; |
Paul Stewart | 7355ce1 | 2011-09-02 10:47:01 -0700 | [diff] [blame] | 215 | properties->address_family = IPAddress::kFamilyIPv4; |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 216 | for (Configuration::const_iterator it = configuration.begin(); |
| 217 | it != configuration.end(); ++it) { |
| 218 | const string &key = it->first; |
| 219 | const DBus::Variant &value = it->second; |
| 220 | VLOG(2) << "Processing key: " << key; |
| 221 | if (key == kConfigurationKeyIPAddress) { |
| 222 | properties->address = GetIPv4AddressString(value.reader().get_uint32()); |
| 223 | if (properties->address.empty()) { |
| 224 | return false; |
| 225 | } |
| 226 | } else if (key == kConfigurationKeySubnetCIDR) { |
| 227 | properties->subnet_cidr = value.reader().get_byte(); |
| 228 | } else if (key == kConfigurationKeyBroadcastAddress) { |
| 229 | properties->broadcast_address = |
| 230 | GetIPv4AddressString(value.reader().get_uint32()); |
| 231 | if (properties->broadcast_address.empty()) { |
| 232 | return false; |
| 233 | } |
| 234 | } else if (key == kConfigurationKeyRouters) { |
Darin Petkov | f7897bc | 2011-06-08 17:13:36 -0700 | [diff] [blame] | 235 | vector<unsigned int> routers = value.operator vector<unsigned int>(); |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 236 | if (routers.empty()) { |
| 237 | LOG(ERROR) << "No routers provided."; |
| 238 | return false; |
| 239 | } |
| 240 | properties->gateway = GetIPv4AddressString(routers[0]); |
| 241 | if (properties->gateway.empty()) { |
| 242 | return false; |
| 243 | } |
| 244 | } else if (key == kConfigurationKeyDNS) { |
Darin Petkov | f7897bc | 2011-06-08 17:13:36 -0700 | [diff] [blame] | 245 | vector<unsigned int> servers = value.operator vector<unsigned int>(); |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 246 | for (vector<unsigned int>::const_iterator it = servers.begin(); |
| 247 | it != servers.end(); ++it) { |
| 248 | string server = GetIPv4AddressString(*it); |
| 249 | if (server.empty()) { |
| 250 | return false; |
| 251 | } |
| 252 | properties->dns_servers.push_back(server); |
| 253 | } |
| 254 | } else if (key == kConfigurationKeyDomainName) { |
| 255 | properties->domain_name = value.reader().get_string(); |
| 256 | } else if (key == kConfigurationKeyDomainSearch) { |
Darin Petkov | f7897bc | 2011-06-08 17:13:36 -0700 | [diff] [blame] | 257 | properties->domain_search = value.operator vector<string>(); |
Darin Petkov | e7cb7f8 | 2011-06-03 13:21:51 -0700 | [diff] [blame] | 258 | } else if (key == kConfigurationKeyMTU) { |
| 259 | int mtu = value.reader().get_uint16(); |
| 260 | if (mtu >= 576) { |
| 261 | properties->mtu = mtu; |
| 262 | } |
| 263 | } else { |
| 264 | VLOG(2) << "Key ignored."; |
| 265 | } |
| 266 | } |
| 267 | return true; |
| 268 | } |
| 269 | |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 270 | void DHCPConfig::ChildWatchCallback(GPid pid, gint status, gpointer data) { |
| 271 | VLOG(2) << "pid " << pid << " exit status " << status; |
| 272 | DHCPConfig *config = reinterpret_cast<DHCPConfig *>(data); |
| 273 | config->child_watch_tag_ = 0; |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 274 | CHECK_EQ(pid, config->pid_); |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 275 | config->CleanupClientState(); |
| 276 | |
| 277 | // |config| instance may be destroyed after this call. |
| 278 | config->provider_->UnbindPID(pid); |
| 279 | } |
| 280 | |
| 281 | void DHCPConfig::CleanupClientState() { |
Darin Petkov | 98dd6a0 | 2011-06-10 15:12:57 -0700 | [diff] [blame] | 282 | if (child_watch_tag_) { |
| 283 | glib_->SourceRemove(child_watch_tag_); |
| 284 | child_watch_tag_ = 0; |
| 285 | } |
| 286 | if (pid_) { |
| 287 | glib_->SpawnClosePID(pid_); |
| 288 | pid_ = 0; |
| 289 | } |
Darin Petkov | f9b0ca8 | 2011-06-20 12:10:23 -0700 | [diff] [blame] | 290 | proxy_.reset(); |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 291 | file_util::Delete(root_.Append(base::StringPrintf(kDHCPCDPathFormatLease, |
Darin Petkov | f65e928 | 2011-06-21 14:29:56 -0700 | [diff] [blame] | 292 | device_name().c_str())), |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 293 | false); |
| 294 | file_util::Delete(root_.Append(base::StringPrintf(kDHCPCDPathFormatPID, |
Darin Petkov | f65e928 | 2011-06-21 14:29:56 -0700 | [diff] [blame] | 295 | device_name().c_str())), |
Darin Petkov | 92c4390 | 2011-06-09 20:46:06 -0700 | [diff] [blame] | 296 | false); |
| 297 | } |
| 298 | |
Darin Petkov | 50308cd | 2011-06-01 18:25:07 -0700 | [diff] [blame] | 299 | } // namespace shill |