Skip to content

Conversation

@jlledom
Copy link

@jlledom jlledom commented Oct 16, 2025

This PR implements the selectable_fd feature for the Hurd. This is needed
by some clients like dhcpcd.

In this patch, the approach is to make the data pass through a pipe,
which read end is going to be the selectable_fd. When capture starts, a
new thread gets packets from gnumach BPF and pushes them to the pipe.

@guyharris
Copy link
Member

This adds an extra move of the packet data through a pipe, which seems... suboptimal.

Is there a way in Hurd to do a select(), or equivalent, that can wait on file descriptors and Mach ports? (macOS's kqueue implementation supports Mach ports as an item that generates kevents.)

Is there a way to have an "event" descriptor that can be selected on and that can be poked to trigger a select wakeup? (Linux and Windows have that, and they're used in libpcap.)

@jlledom
Copy link
Author

jlledom commented Oct 19, 2025

This adds an extra move of the packet data through a pipe, which seems... suboptimal.

Yes, I know, we already discused this in the hurd list: https://www.mail-archive.com/[email protected]/msg37636.html

Is there a way in Hurd to do a select(), or equivalent, that can wait on file descriptors and Mach ports? (macOS's kqueue implementation supports Mach ports as an item that generates kevents.)

Is there a way to have an "event" descriptor that can be selected on and that can be poked to trigger a select wakeup? (Linux and Windows have that, and they're used in libpcap.)

None of those two, as far as I know. From my current knowledge, I can only think on two solutions:

  1. Actually write the /dev/bpf translator. That would take a lot of time probably. And, in that case, the Hurd module wouldn't be needed at all.
  2. In the hurd module, use the pipe only when a selectable_fd is requested. In that case, pcap_get_selectable_fd function should be modified to something like this:
int
pcap_get_selectable_fd(pcap_t *p)
{
  if (!p->selectable_fd) {
    pcap_init_selectable_fd();
  }
  return (p->selectable_fd);
}

and that pcap_init_selectable_fd would be implemented only on the hurd module and empty in all other platforms. The function would initialize the thread and the pipe. The read method for the hurd would read from the pipe only if the pipe is initialized, otherwise it would read from gnumach directly, as before.

Would you accept something like this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants