pub struct Net {
pub tap: Tap,
pub mmds_ns: Option<MmdsNetworkStack>,
/* private fields */
}Expand description
VirtIO network device.
It emulates a network device able to exchange L2 frames between the guest and a host-side tap device.
Fields§
§tap: TapThe backend for this device: a tap.
mmds_ns: Option<MmdsNetworkStack>The MMDS stack corresponding to this interface. Only if MMDS transport has been associated with it.
Implementations§
Source§impl Net
impl Net
Sourcepub fn new_with_tap(
id: String,
tap: Tap,
guest_mac: Option<MacAddr>,
rx_rate_limiter: RateLimiter,
tx_rate_limiter: RateLimiter,
) -> Result<Self, NetError>
pub fn new_with_tap( id: String, tap: Tap, guest_mac: Option<MacAddr>, rx_rate_limiter: RateLimiter, tx_rate_limiter: RateLimiter, ) -> Result<Self, NetError>
Create a new virtio network device with the given TAP interface.
Sourcepub fn new(
id: String,
tap_if_name: &str,
guest_mac: Option<MacAddr>,
rx_rate_limiter: RateLimiter,
tx_rate_limiter: RateLimiter,
) -> Result<Self, NetError>
pub fn new( id: String, tap_if_name: &str, guest_mac: Option<MacAddr>, rx_rate_limiter: RateLimiter, tx_rate_limiter: RateLimiter, ) -> Result<Self, NetError>
Create a new virtio network device given the interface name.
Sourcepub fn iface_name(&self) -> String
pub fn iface_name(&self) -> String
Provides the host IFACE name of this net device.
Sourcepub fn mmds_ns(&self) -> Option<&MmdsNetworkStack>
pub fn mmds_ns(&self) -> Option<&MmdsNetworkStack>
Provides the MmdsNetworkStack of this net device.
Sourcepub fn configure_mmds_network_stack(
&mut self,
ipv4_addr: Ipv4Addr,
mmds: Arc<Mutex<Mmds>>,
)
pub fn configure_mmds_network_stack( &mut self, ipv4_addr: Ipv4Addr, mmds: Arc<Mutex<Mmds>>, )
Configures the MmdsNetworkStack to allow device to forward MMDS requests.
If the device already supports MMDS, updates the IPv4 address.
Sourcepub fn disable_mmds_network_stack(&mut self)
pub fn disable_mmds_network_stack(&mut self)
Disables the MmdsNetworkStack to prevent device to forward MMDS requests.
Sourcepub fn rx_rate_limiter(&self) -> &RateLimiter
pub fn rx_rate_limiter(&self) -> &RateLimiter
Provides a reference to the configured RX rate limiter.
Sourcepub fn tx_rate_limiter(&self) -> &RateLimiter
pub fn tx_rate_limiter(&self) -> &RateLimiter
Provides a reference to the configured TX rate limiter.
pub fn rate_limited_rx_single_frame(&mut self, frame_size: u32) -> bool
Sourcepub fn parse_rx_descriptors(&mut self) -> Result<(), InvalidAvailIdx>
pub fn parse_rx_descriptors(&mut self) -> Result<(), InvalidAvailIdx>
Parse available RX DescriptorChains from the queue
Sourcepub fn build_tap_offload_features(guest_supported_features: u64) -> u32
pub fn build_tap_offload_features(guest_supported_features: u64) -> u32
Builds the offload features we will setup on the TAP device based on the features that the guest supports.
Sourcepub fn patch_rate_limiters(
&mut self,
rx_bytes: BucketUpdate,
rx_ops: BucketUpdate,
tx_bytes: BucketUpdate,
tx_ops: BucketUpdate,
)
pub fn patch_rate_limiters( &mut self, rx_bytes: BucketUpdate, rx_ops: BucketUpdate, tx_bytes: BucketUpdate, tx_ops: BucketUpdate, )
Updates the parameters for the rate limiters
Sourcepub unsafe fn read_tap(&mut self) -> Result<usize>
pub unsafe fn read_tap(&mut self) -> Result<usize>
Reads a frame from the TAP device inside the first descriptor held by self.rx_buffer.
§Safety
self.rx_buffer needs to have at least one descriptor chain parsed
Sourcepub fn process_rx_queue_event(&mut self)
pub fn process_rx_queue_event(&mut self)
Process a single RX queue event.
This is called by the event manager responding to the guest adding a new buffer in the RX queue.
pub fn process_tap_rx_event(&mut self)
Sourcepub fn process_tx_queue_event(&mut self)
pub fn process_tx_queue_event(&mut self)
Process a single TX queue event.
This is called by the event manager responding to the guest adding a new buffer in the TX queue.
pub fn process_rx_rate_limiter_event(&mut self)
pub fn process_tx_rate_limiter_event(&mut self)
Sourcepub fn process_virtio_queues(&mut self) -> Result<(), InvalidAvailIdx>
pub fn process_virtio_queues(&mut self) -> Result<(), InvalidAvailIdx>
Process device virtio queue(s).
Sourcepub fn prepare_save(&mut self)
pub fn prepare_save(&mut self)
Prepare saving state
Trait Implementations§
Source§impl From<&Net> for NetworkInterfaceConfig
impl From<&Net> for NetworkInterfaceConfig
Source§impl Persist<'_> for Net
impl Persist<'_> for Net
Source§type ConstructorArgs = NetConstructorArgs
type ConstructorArgs = NetConstructorArgs
Source§type Error = NetPersistError
type Error = NetPersistError
Source§impl VirtioDevice for Net
impl VirtioDevice for Net
Source§fn const_device_type() -> u32
fn const_device_type() -> u32
Source§fn device_type(&self) -> u32
fn device_type(&self) -> u32
Source§fn avail_features(&self) -> u64
fn avail_features(&self) -> u64
Source§fn acked_features(&self) -> u64
fn acked_features(&self) -> u64
Source§fn set_acked_features(&mut self, acked_features: u64)
fn set_acked_features(&mut self, acked_features: u64)
Source§fn queues_mut(&mut self) -> &mut [Queue]
fn queues_mut(&mut self) -> &mut [Queue]
Source§fn queue_events(&self) -> &[EventFd]
fn queue_events(&self) -> &[EventFd]
fn interrupt_trigger(&self) -> &dyn VirtioInterrupt
Source§fn read_config(&self, offset: u64, data: &mut [u8])
fn read_config(&self, offset: u64, data: &mut [u8])
offset.Source§fn write_config(&mut self, offset: u64, data: &[u8])
fn write_config(&mut self, offset: u64, data: &[u8])
offset.Source§fn activate(
&mut self,
mem: GuestMemoryMmap,
interrupt: Arc<dyn VirtioInterrupt>,
) -> Result<(), ActivateError>
fn activate( &mut self, mem: GuestMemoryMmap, interrupt: Arc<dyn VirtioInterrupt>, ) -> Result<(), ActivateError>
is_activated.Source§fn is_activated(&self) -> bool
fn is_activated(&self) -> bool
Source§fn has_feature(&self, feature: u64) -> bool
fn has_feature(&self, feature: u64) -> bool
Source§fn interrupt_status(&self) -> Arc<AtomicU32>
fn interrupt_status(&self) -> Arc<AtomicU32>
Source§fn avail_features_by_page(&self, page: u32) -> u32
fn avail_features_by_page(&self, page: u32) -> u32
page * 32.Source§fn ack_features_by_page(&mut self, page: u32, value: u32)
fn ack_features_by_page(&mut self, page: u32, value: u32)
Source§fn reset(&mut self) -> Option<(Arc<dyn VirtioInterrupt>, Vec<EventFd>)>
fn reset(&mut self) -> Option<(Arc<dyn VirtioInterrupt>, Vec<EventFd>)>
Source§fn mark_queue_memory_dirty(
&mut self,
mem: &GuestMemoryMmap,
) -> Result<(), QueueError>
fn mark_queue_memory_dirty( &mut self, mem: &GuestMemoryMmap, ) -> Result<(), QueueError>
Source§fn as_cow_file_engine(&self) -> Option<&CowFileEngine>
fn as_cow_file_engine(&self) -> Option<&CowFileEngine>
Source§fn nyx_handle_queue_event(&mut self, _queue_index: u16)
fn nyx_handle_queue_event(&mut self, _queue_index: u16)
Auto Trait Implementations§
impl Freeze for Net
impl !RefUnwindSafe for Net
impl Send for Net
impl !Sync for Net
impl Unpin for Net
impl UnsafeUnpin for Net
impl !UnwindSafe for Net
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.