shill: vpn: Last systems bits for OpenVPN test
This performs the following tasks in completing the first pass
of OpenVPN support:
- Uses any interface for requesting a route to the VPN server.
- Only offers the VPN device to VPNProvider the first time
DeviceInfo sees a message for it.
- Use RTNLHandler::SetInterfaceFlags() to bring the interface
link state up on VPN::Start().
- Allow RTNLHandler::SetInterfaceFlags() to be called from unit
tests.
BUG=chromium-os:22063
TEST=Autotest for network_VPN/network_VPN.000VPNGenesis runs
successfully
Change-Id: I1dd79a43f9de276f337ed1ebcde5893da66f55a9
Reviewed-on: https://gerrit.chromium.org/gerrit/18500
Reviewed-by: mukesh agrawal <quiche@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
Commit-Ready: Paul Stewart <pstew@chromium.org>
diff --git a/device_info.cc b/device_info.cc
index 2534db3..ab93828 100644
--- a/device_info.cc
+++ b/device_info.cc
@@ -213,10 +213,12 @@
unsigned int flags = msg.link_status().flags;
unsigned int change = msg.link_status().change;
+ bool new_device = !ContainsKey(infos_, dev_index);
VLOG(2) << __func__ << "(index=" << dev_index
<< std::showbase << std::hex
<< ", flags=" << flags << ", change=" << change << ")"
- << std::dec << std::noshowbase;
+ << std::dec << std::noshowbase
+ << ", new_device=" << new_device;
infos_[dev_index].flags = flags;
DeviceRefPtr device = GetDevice(dev_index);
@@ -264,15 +266,18 @@
device->EnableIPv6Privacy();
break;
case Technology::kTunnel:
- // Tunnel devices are managed by the VPN code.
- VLOG(2) << "Tunnel link " << link_name << " at index " << dev_index
- << " -- notifying VPNProvider.";
- if (!manager_->vpn_provider()->OnDeviceInfoAvailable(link_name,
- dev_index)) {
- // If VPN does not know anything about this tunnel, it is probably
- // left over from a previous instance and should not exist.
- VLOG(2) << "Tunnel link is unused. Deleting.";
- DeleteInterface(dev_index);
+ // Tunnel devices are managed by the VPN code. Notify the VPN Provider
+ // only if this is the first time we have seen this device index.
+ if (new_device) {
+ VLOG(2) << "Tunnel link " << link_name << " at index " << dev_index
+ << " -- notifying VPNProvider.";
+ if (!manager_->vpn_provider()->OnDeviceInfoAvailable(link_name,
+ dev_index)) {
+ // If VPN does not know anything about this tunnel, it is probably
+ // left over from a previous instance and should not exist.
+ VLOG(2) << "Tunnel link is unused. Deleting.";
+ DeleteInterface(dev_index);
+ }
}
return;
default: