Skip to content

Commit

Permalink
Virtio: Fix reception of packet by skipping the NetHdr
Browse files Browse the repository at this point in the history
  • Loading branch information
roblabla committed Jun 28, 2019
1 parent 566137f commit f49d40a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions virtio/src/net.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use smoltcp::time::Instant;
use core::fmt;
use sunrise_libuser::error::Error;
use bit_field::BitField;
use log::info;
use log::*;

bitflags! {
/// Features supported by the Virtio-Net driver.
Expand Down Expand Up @@ -280,6 +280,7 @@ impl<'a> Device<'a> for VirtioNet {

fn receive(&'a mut self) -> Option<(Self::RxToken, Self::TxToken)> {
let buf = self.receive_queues().nth(0).unwrap().pop_buffer_w()?;
debug!("{:#?}", buf);
let rx = VirtioNetRxToken(buf);
let tx = VirtioNetTxToken(self);
Some((rx, tx))
Expand Down Expand Up @@ -311,7 +312,8 @@ impl RxToken for VirtioNetRxToken {
where
F: FnOnce(&[u8]) -> smoltcp::Result<R>
{
f(&self.0[..])
debug!("Consuming the buffer");
f(&self.0[core::mem::size_of::<NetHdr>()..])
}
}

Expand Down

0 comments on commit f49d40a

Please sign in to comment.