mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2025-02-21 19:02:30 +00:00
net_util: Consolidate vnet_hdr_len() functions
As a result of refactoring this function was duplicated so consolidate into the top level. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
48faf3abac
commit
7f3e40e0cf
@ -70,6 +70,11 @@ fn create_socket() -> Result<net::UdpSocket> {
|
||||
Ok(unsafe { net::UdpSocket::from_raw_fd(sock) })
|
||||
}
|
||||
|
||||
fn vnet_hdr_len() -> usize {
|
||||
use virtio_bindings::bindings::virtio_net::virtio_net_hdr_v1;
|
||||
std::mem::size_of::<virtio_net_hdr_v1>()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
@ -2,12 +2,10 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
||||
|
||||
use super::TapError;
|
||||
use super::{MacAddr, Tap};
|
||||
use super::{vnet_hdr_len, MacAddr, Tap, TapError};
|
||||
use std::net::Ipv4Addr;
|
||||
use std::path::Path;
|
||||
use std::{fs, io};
|
||||
use virtio_bindings::bindings::virtio_net::virtio_net_hdr_v1;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
@ -39,10 +37,6 @@ pub enum Error {
|
||||
|
||||
type Result<T> = std::result::Result<T, Error>;
|
||||
|
||||
fn vnet_hdr_len() -> usize {
|
||||
std::mem::size_of::<virtio_net_hdr_v1>()
|
||||
}
|
||||
|
||||
fn check_mq_support(if_name: &Option<&str>, queue_pairs: usize) -> Result<()> {
|
||||
if let Some(tap_name) = if_name {
|
||||
let mq = queue_pairs > 1;
|
||||
|
@ -2,13 +2,12 @@
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0 AND BSD-3-Clause
|
||||
|
||||
use super::Tap;
|
||||
use super::{vnet_hdr_len, Tap};
|
||||
use std::cmp;
|
||||
use std::io::Write;
|
||||
use std::num::Wrapping;
|
||||
use vm_memory::{Bytes, GuestAddress, GuestMemoryMmap};
|
||||
use vm_virtio::{DescriptorChain, Queue};
|
||||
use virtio_bindings::bindings::virtio_net::virtio_net_hdr_v1
|
||||
|
||||
/// The maximum buffer size when segmentation offload is enabled. This
|
||||
/// includes the 12-byte virtio net header.
|
||||
@ -183,7 +182,3 @@ impl RxVirtio {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn vnet_hdr_len() -> usize {
|
||||
std::mem::size_of::<virtio_net_hdr_v1>()
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user