shill: vpn: Add support for creating a tunnel interface
Use the ioctl inteface for creating a TUN device (no RTNL interface
for this appears available). Also create a means for removing
interfaces, using the RTNL interface.
BUG=chromium-os:26841
TEST=New unit test for RTNL interface, manual testing for ioctl
interface and for TUN interface detection and handling.
Change-Id: If70eeeecd5d2a2e3c348b56c297c0f3dd4226b8f
Reviewed-on: https://gerrit.chromium.org/gerrit/17127
Commit-Ready: Paul Stewart <pstew@chromium.org>
Reviewed-by: Paul Stewart <pstew@chromium.org>
Tested-by: Paul Stewart <pstew@chromium.org>
diff --git a/rtnl_handler.cc b/rtnl_handler.cc
index fde52d0..66639f5 100644
--- a/rtnl_handler.cc
+++ b/rtnl_handler.cc
@@ -310,6 +310,18 @@
IPAddress(local.family()));
}
+bool RTNLHandler::RemoveInterface(int interface_index) {
+ RTNLMessage msg(
+ RTNLMessage::kTypeLink,
+ RTNLMessage::kModeDelete,
+ NLM_F_REQUEST,
+ 0,
+ 0,
+ interface_index,
+ IPAddress::kFamilyUnknown);
+ return SendMessage(&msg);
+}
+
int RTNLHandler::GetInterfaceIndex(const string &interface_name) {
if (interface_name.empty()) {
LOG(ERROR) << "Empty interface name -- unable to obtain index.";