mirror of
https://chromium.googlesource.com/crosvm/crosvm
synced 2024-11-25 13:23:08 +00:00
b0406736ed
The validate_and_configure_tap() and virtio_features_to_tap_offload() functions already effectively did nothing on Windows, since the implementations of these for Slirp were not provided. These functions are moved to sys so the Linux-specific TAP interfaces are no longer needed in TapTCommon. The get_ifreq() function is only called internally inside the implementation of the Linux Tap struct; it does not need to be part of the TapT trait at all. The MacAddress <-> sockaddr interop is only needed on Linux, and the conversion can be moved into the get_mac_address and set_mac_address implementations for Linux. With these changes, net_sys is used only on Linux, so it can be conditionally compiled and not included in non-Linux builds at all. BUG=None TEST=tools/dev_container tools/presubmit Change-Id: I3419a3bdb1470c4d72588fe19e43fabcdfe4e451 Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5046598 Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Reviewed-by: Noah Gold <nkgold@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
57 lines
1.4 KiB
Rust
57 lines
1.4 KiB
Rust
// Copyright 2022 The ChromiumOS Authors
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#![cfg(any(target_os = "android", target_os = "linux"))]
|
|
|
|
use std::net;
|
|
|
|
use base::test_utils::call_test_with_sudo;
|
|
use net_util::sys::linux::Tap;
|
|
use net_util::sys::linux::TapTLinux;
|
|
use net_util::MacAddress;
|
|
use net_util::TapTCommon;
|
|
|
|
#[test]
|
|
fn tap_create() {
|
|
call_test_with_sudo("tap_create_impl")
|
|
}
|
|
|
|
#[test]
|
|
#[ignore = "Only to be called by tap_create"]
|
|
fn tap_create_impl() {
|
|
Tap::new(true, false).unwrap();
|
|
}
|
|
|
|
#[test]
|
|
fn tap_configure() {
|
|
call_test_with_sudo("tap_configure_impl")
|
|
}
|
|
|
|
#[test]
|
|
#[ignore = "Only to be called by tap_configure"]
|
|
fn tap_configure_impl() {
|
|
let tap = Tap::new(true, false).unwrap();
|
|
let ip_addr: net::Ipv4Addr = "100.115.92.5".parse().unwrap();
|
|
let netmask: net::Ipv4Addr = "255.255.255.252".parse().unwrap();
|
|
let mac_addr: MacAddress = "a2:06:b9:3d:68:4d".parse().unwrap();
|
|
|
|
tap.set_ip_addr(ip_addr).unwrap();
|
|
tap.set_netmask(netmask).unwrap();
|
|
tap.set_mac_address(mac_addr).unwrap();
|
|
tap.set_vnet_hdr_size(16).unwrap();
|
|
tap.set_offload(0).unwrap();
|
|
}
|
|
|
|
#[test]
|
|
fn tap_enable() {
|
|
call_test_with_sudo("tap_enable_impl")
|
|
}
|
|
|
|
#[test]
|
|
#[ignore = "Only to be called by tap_enable"]
|
|
fn tap_enable_impl() {
|
|
let tap = Tap::new(true, false).unwrap();
|
|
|
|
tap.enable().unwrap();
|
|
}
|