Joan Lledó, le mar. 14 oct. 2025 22:07:34 +0200, a ecrit:
> On 10/13/25 23:53, Samuel Thibault wrote:
> > > > In this patch, my approach is to make the data pass through a pipe,
> > > > which read end is going to be the selectable_fd for dhcpcd. When capture
> > > > starts, a new thread reads packets from gnumach bpf and pushes them to
> > > > the pipe. When the pipe has data, dhcpcd is signaled and it will call
> > > > the read function, which I modified to read from the pipe and return 
> > > > data
> > > > to dhcpcd. This is working fine in my local tests, but I'd appreciate a
> > > > review.
> > 
> > That doesn't look like an efficient way :)
> > 
> > But for gnumach devices, we don't really have another way to get it
> > through poll(), so it's actually the most efficient way (more than using
> > some separate translator on /dev/eth0).
> 
> How difficult would be implementing such a thing? a selectable fd that would
> be signaled by gnumach when there is data in the bpf filter?

Basically, you need something that answers both io_read and io_select
requests, so some translator. Better just reuse what is already
implemented, by using a pipe.

> I decided to leave them like "just in case" but theoretically EBADF should
> never happen with the final implementation when the thread is cancelled by
> pthread_cancel() before closing the pipe.

Yes, so better let the code warn if that's not the case.

Samuel

Reply via email to