From b795280ddcd9d290d89ff0e284bc12ae91640baf Mon Sep 17 00:00:00 2001 From: "Jorge E. Moreira" Date: Tue, 12 Feb 2019 16:43:05 -0800 Subject: Add support for multiple network interfaces Allow --tap-fd to be given mutliple times, a different virtual network card will be added each time the flag is given. Additionally, --tap-fd is no longer mutually exclusive with --host-ip, etc. Bug=chromium:931470 Test=booted cuttlefish device with multiple network cards Change-Id: I4108f97c7f4b19db12fcb3c533088a04a58e56db Reviewed-on: https://chromium-review.googlesource.com/1469222 Commit-Ready: Jorge Moreira Broche Tested-by: kokoro Tested-by: Jorge Moreira Broche Reviewed-by: Dylan Reid --- src/linux.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/linux.rs') diff --git a/src/linux.rs b/src/linux.rs index b81bc71..1dbd8fd 100644 --- a/src/linux.rs +++ b/src/linux.rs @@ -432,7 +432,7 @@ fn create_virtio_devs( }); // We checked above that if the IP is defined, then the netmask is, too. - if let Some(tap_fd) = cfg.tap_fd { + for tap_fd in cfg.tap_fd { // Safe because we ensure that we get a unique handle to the fd. let tap = unsafe { Tap::from_raw_fd(validate_raw_fd(tap_fd).map_err(Error::ValidateRawFd)?) @@ -449,7 +449,9 @@ fn create_virtio_devs( }; devs.push(VirtioDeviceStub { dev: net_box, jail }); - } else if let Some(host_ip) = cfg.host_ip { + } + + if let Some(host_ip) = cfg.host_ip { if let Some(netmask) = cfg.netmask { if let Some(mac_address) = cfg.mac_address { let net_box: Box = if cfg.vhost_net { -- cgit 1.4.1