Hi,

this series of patches implement some required changes to make dhcpcd work on 
the Hurd.

1. Make server ops return `kern_return_t`
  - This one is just to fix some warnings
  
2. Implement `pfinet_getroutes`
  - At some point dhcpcd requests a list of routes in the system. I'm calling 
the
    `pfinet_getroutes` op to get them. In LwIP this was not implemented so this
    patch implements it based on what the pfinet translator does.
    
    I have a question here: pfinet sets the `dealloc_data` output parameter to 
true,
    so I did the same. But does that mean the caller, in this case dhcpcd, is
    responsible for deallocatinng the pointer? I assumed yes and do it on the 
dhcpcd
    patch

3. Better null termination protection
  - Just a nitpick

4. Consider gateway in ip inquire and configure
  - This just adds a new macro `GWADDR` to identify addresses received by
    `inquire_device` and `configure_device`. This is convenient because it's 
used
    from new ioctls I added.

5. Additional protection in `siocsifXaddr`
  - Another minor fix I found: `siocsifXaddr` should check the given address 
family

6. Implement routing ioctls
  - This one is important and I'd appreciate some review on this. Dhcpcd needs 
a way
    to create and delete routes on the system. I had to find out a way and my 
approach
    was to add them through ioctls, in particular `SIOCADDRT` and `SIOCDELRT`. 
This
    patch implements those.
    
    The tricky part is LwIP doesn't really support routing, the only notion of 
routing
    LwIP has is setting a gateway for each interface. So the way to add routes 
to LwIP
    is configuring IP, netmask and gateway in a way packets will be routed as 
expected.
    
    This ioctls try to translate what the user tries to do into what LwIP can 
do. And
    some scenarios in regular Unix routing are not implemented. In fact, this 
patch
    only implements two scenarios:
    
    - When adding a new route
      - Client sends an interface plus a netmask but gateway=any
        Intends to add a subnet route.
        e.g. `192.168.1.0/24 dev eth0`
      
        In this scenario, the function checks the given mask and destination are
        compatible with current IP and sets the new mask to the given interface.
      
      - Client sends an interface plus a gateway but netmask=any
        Intends to set a default gateway.
        e.g. `0.0.0.0/0 via 192.168.1.1`
      
        In this scenario, the function checks the given gateway will be 
reachable
        from the given interface and sets the gateway. It also makes the 
interface
        default.
    
    - When removing a route, the same two scenarios are supported. The function 
checks
      the given route matches the current config and then it removes the 
configuration.
      
    This is the minimal routing required by dhcpcd. It performs the next 
sequence:
    
      1. Add the leased IP to an interface through `SIOCSIFADDR`
      2. Add a subnet route
      3. For one interface, add a default gateway
      
 7. Implement `SIOCDIFADDR`
    - During the shutdown sequence, dhcpcd removes all routes and IPs. The LwIP
      translator didn't have the `SIOCDIFADDR` implemented so I had to add it.
      The patch just sets IP to INADDR_NONE.
      
Thanks

Reply via email to