Hi Samuel,

-------- Original Message --------
On 20/7/25 7:43 pm, Samuel Thibault <samuel.thiba...@gnu.org> wrote:

>  Damien Zammit, le dim. 20 juil. 2025 02:49:16 +0000, a ecrit:
>  > +  flag = 0;
>  > +  err = rump_sys_ioctl (nd->bpf_fd, BIOCIMMEDIATE, &flag);
>  > +  if (err < 0)
>  > +    {
>  > +      mach_print("ERROR: biocimmediate failed\n");
>  > +      errno = rump_errno2host(err);
>  > +      return errno;
>  > +    }
>  > +
>  > +  /* We need this timeout for blocking requests to flush even if not full 
> */
>  > +  err = rump_sys_ioctl (nd->bpf_fd, BIOCSRTIMEOUT, &timeout);
>  
>  ? Is that not BIOCIMMEDIATE that achieves this? You are talking about
>  incomming packets, right? rarpd for instance only uses BIOCIMMEDIATE,
>  not BIOCSRTIMEOUT?

Set Receive Timeout is required.

The immediate flag makes it begin filling the bpf buffer without any delay.  
But without the timeout set, a pending blocking read will never return until 
the whole buffer is filled because the default timeout is indefinitely long.  
Therefore, both are required for blocking mode.
Alternatively, we could use non-blocking mode and implement our own delay with 
a select and/or poll.  I think the way I implemented it is easier.

>  > +static io_return_t
>  > +send_packet (struct net_data *nd, io_buf_ptr_t buf, unsigned int bytes)
>  > +{
>  > +  io_return_t err;
>  > +  struct ethhdr *hdr = (struct ethhdr *)buf;
>  
>  I don't think you need the cast?

OK I can remove it.

Thanks,
Damien

Reply via email to