Hi Hurd,

This series of patches implements a port of dhcpcd to the Hurd. It works but has
some limitations that could be fixed in the future. This is the current state of
the port:

- Support only for IPv4. IPv6 not supported yet.
- It works only over lwip. First, because dhcpcd requires some definitions from
  headers and pfinet doesn't provide them AFAIK, but lwip provide the headers
  through the liblwip-dev package.
  Second, because both pfinet and lwip need changes in the translator in order
  to be fully compatible with dhcpcd, and I made the changes in lwip since I
  know it better.
- Only Ethernet is supported. This is because the Hurd doesn't define AF_LINK
  so dhcpcd can't get any data from the interface other thant what is returned
  by `getifaddrs()`.
  I'm manually providing the MAC address and hardcoding the interface type to
  Ethernet in the `if_init` function. I assume this is correct because the Hurd
  only supports ethernet interfaces AFAIK.
- dhcpcd monitors the interfaces and gets notified when there are changes in
  routes or network configurations. This is not working yet for the Hurd.
- dhcpcd implements some privilege separation by which the process spawns new
  processes that run as a non-privileged user. Or that's what I understood.
  It's not implemented for the Hurd because I've deferred this for now.
- Access to BPF is provided by libpcap.
- libpcap and liblwip-dev are dependencies for the Hurd.
- This has been tested only in a 32-bit Hurd.

1. New libpcap BPF backend
  - Dhcpcd uses a BPF filter to push DHCP packets to the wire. This is done
    differently in different platforms:
    - In Linux, a `PF_PACKET` socket is opened and data is sent to it.
    - In BSD, dhcpcd gets a file descriptor from `/dev/bpf` and sends data to
      it.
    
    For the Hurd, I found the BPF implementation was not clear and apparently
    there are three methods:
    - GNU Mach implementation at `/device/bpf.h`.
    - Hurd implementation through libbpf: Only used from eth-multiplexer AFAIK.
    - libpcap: Tries to use the GNU Mach implementation, if it can't, it reads
      all packets and filters it itself.
    
    Based on the discussion at [1], we can see there was an attempt to create
    a BPF translator to be installed in /dev/bpf, emulating the BSD interface,
    but at the end it was assumed that every client wanting to install a BPF
    filter would just use libpcap. For that reason, I chose that approach and
    added this libpcap module for dhcpcd.

2. Add support for the Hurd in ./configure
  - This makes some changes in the configure file to add better support for the
    Hurd. In particular, it checks for libpcap and liblwip-dev and add some
    headers and macro definitions to config.h, a file by which general system
    config is provided to compiler.
    
3. Filename escaping
  - dhcpcd creates some directory entries which names are or include interface
    names. In the Hurd, interface names can include invalid characters like `/`,
    so those must be escaped.

4. Adapt codebase to the new Hurd backend.
  - Added `__GNU__` macro checks throughout the codebase to handle Hurd-specific
    behavior.
  - Defined `RTM_NEWADDR` and `RTM_DELADDR` for internal use (only used
    internally by dhcpcd).
  - Added `getprogname()` declaration for Hurd.

5. New GNU/Hurd backend
  - This module adds support for the Hurd in dhcpcd. It declares/overwrites some
    functions so dhcpcd can get basic info about interfaces and routes in the
    Hurd.

    So far the support is very basic and still has many TODOs. I'll keep working
    on completing this module so we can have a fully featured dhcpcd port.

6. Add some build instructions for the Hurd
  - This just adds some comments in the docs to indicate how to build dhcpcd on
    the Hurd and inform about current limitations.
    
Thanks.

---
[1] https://darnassus.sceen.net/~hurd-web/open_issues/bpf/

Reply via email to