mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-08-21 15:31:15 +00:00
net_util: Don't always set the tap offload
Setting the tap offload should only be done based on the features that are acked by the guest. Therefore it is incorrect to set these upon opening the tap. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
70e926372a
commit
b945a341b3
@ -70,7 +70,6 @@ pub fn open_tap(
|
|||||||
let mut taps: Vec<Tap> = Vec::new();
|
let mut taps: Vec<Tap> = Vec::new();
|
||||||
let mut ifname: String = String::new();
|
let mut ifname: String = String::new();
|
||||||
let vnet_hdr_size = vnet_hdr_len() as i32;
|
let vnet_hdr_size = vnet_hdr_len() as i32;
|
||||||
let flag = net_gen::TUN_F_CSUM | net_gen::TUN_F_UFO | net_gen::TUN_F_TSO4 | net_gen::TUN_F_TSO6;
|
|
||||||
|
|
||||||
// In case the tap interface already exists, check if the number of
|
// In case the tap interface already exists, check if the number of
|
||||||
// queues is appropriate. The tap might not support multiqueue while
|
// queues is appropriate. The tap might not support multiqueue while
|
||||||
@ -98,7 +97,6 @@ pub fn open_tap(
|
|||||||
*host_mac = Some(tap.get_mac_addr().map_err(Error::TapGetMac)?)
|
*host_mac = Some(tap.get_mac_addr().map_err(Error::TapGetMac)?)
|
||||||
}
|
}
|
||||||
tap.enable().map_err(Error::TapEnable)?;
|
tap.enable().map_err(Error::TapEnable)?;
|
||||||
tap.set_offload(flag).map_err(Error::TapSetOffload)?;
|
|
||||||
|
|
||||||
tap.set_vnet_hdr_size(vnet_hdr_size)
|
tap.set_vnet_hdr_size(vnet_hdr_size)
|
||||||
.map_err(Error::TapSetVnetHdrSize)?;
|
.map_err(Error::TapSetVnetHdrSize)?;
|
||||||
@ -106,7 +104,6 @@ pub fn open_tap(
|
|||||||
ifname = String::from_utf8(tap.get_if_name()).unwrap();
|
ifname = String::from_utf8(tap.get_if_name()).unwrap();
|
||||||
} else {
|
} else {
|
||||||
tap = Tap::open_named(ifname.as_str(), num_rx_q, flags).map_err(Error::TapOpen)?;
|
tap = Tap::open_named(ifname.as_str(), num_rx_q, flags).map_err(Error::TapOpen)?;
|
||||||
tap.set_offload(flag).map_err(Error::TapSetOffload)?;
|
|
||||||
|
|
||||||
tap.set_vnet_hdr_size(vnet_hdr_size)
|
tap.set_vnet_hdr_size(vnet_hdr_size)
|
||||||
.map_err(Error::TapSetVnetHdrSize)?;
|
.map_err(Error::TapSetVnetHdrSize)?;
|
||||||
|
@ -191,10 +191,7 @@ impl Tap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let tap = Tap { tap_file, if_name };
|
let tap = Tap { tap_file, if_name };
|
||||||
let offload_flags =
|
|
||||||
net_gen::TUN_F_CSUM | net_gen::TUN_F_UFO | net_gen::TUN_F_TSO4 | net_gen::TUN_F_TSO6;
|
|
||||||
let vnet_hdr_size = vnet_hdr_len() as i32;
|
let vnet_hdr_size = vnet_hdr_len() as i32;
|
||||||
tap.set_offload(offload_flags)?;
|
|
||||||
tap.set_vnet_hdr_size(vnet_hdr_size)?;
|
tap.set_vnet_hdr_size(vnet_hdr_size)?;
|
||||||
|
|
||||||
Ok(tap)
|
Ok(tap)
|
||||||
|
Loading…
Reference in New Issue
Block a user