openwrt / odhcpd

This repository is a mirror of https://git.openwrt.org/?p=project/odhcpd.git. Pull requests will be accepted which will be merged in odhcpd.git
GNU General Public License v2.0
162 stars 98 forks source link

FEATURE REQUEST: setting to choose whether to do IA_NA, IA_PD or both or none. #111

Closed mikaabra closed 5 years ago

mikaabra commented 6 years ago

I would like to support IA_PD behind the router, but not IA_NA (and also not IA_TA either). Currently IA_NA and IA_PD seems to be conflated, but this could be fixed with a new configuration option (text below as example):

dhcpv6_stateful_type    integer     0       No IA_* types available
                    1       IA_NA only available
                    2       IA_PD only available
                    3       IA_PD and IA_NA available

If I set RA_management to 0, if the client still asks for DHCPv6 IA_NA or PD, it's handed out. This option would also enable possibility of actually turning selected functionality off completely.

mikaabra commented 6 years ago

I wrote some implementation guidance, if that might help. My intention is for me (or someone else) to submit a pull request for this (start working on that in the next few weeks), and this was my text to the person who would create the patch. It gives some background and implementation guidance. Any feedback on this appreciated.

The feature request consists of three parts, described here (in addition to what's already in the above request):

Background:

In DHCPv6 "stateful addressing" there are two main types of addresses that can be requested. They are:

IA_NA (Internet Address - Network Address). This is a single address, very similar to what is done in DHCPv4 IA_PD (Internet Address - Prefix Delegation). This is a block of addresses, a prefix. This means a block of addresses will be routed to the client.

By default in odhcpd in OpenWrt 15 and (LEDE) 17, both of these are supported, at the same time. If the client asks for both, it will get one of each. This is not configurable and it's always on when odhcpd is running on an interface.

Now, we want to support using only IA_PD and not support IA_NA, so we need to make resource type handout configurable. This means the feature request consists of multiple things:

  1. Implement configuration option and update documentation
  2. Read configuration option in odhcpd and put into variable
  3. Check this variable at point of handout of resources
  4. Possibly web UI changes to make this configurable (out of scope for this feature request)
  5. The feature request to odhcpd in above suggests values and name of configuration, basically a bit field to turn IA_NA and IA_PD support on/off. It's ok if these are instead two booleans to turn IA_NA and IA_PD support on/off respectively. It should be possible to do this on a per-interface basis.

The changes needed are to implement the new configuration option(s) in [[https://github.com/openwrt/odhcpd/blob/master/src/config.c]] Then the variable chosen needs to be checked in [[https://github.com/openwrt/odhcpd/blob/master/src/dhcpv6-ia.c]] at some place, either whilst parsing the options or when considering to hand out the options. The options in question are The proper response to a IA_NA question with you're configured to not hand out IA_NA is to omit the option in the response, same with IA_PD. Possible implementation method could be to just ignore the NA/PD options during parsing if configured to not support them.

mikaabra commented 6 years ago

After interacting with some DHCPv6 experts they pointed to RFC3633 which has the following text:

If the delegating router will not assign any prefixes to any IA_PDs in a subsequent Request from the requesting router, the delegating router MUST send an Advertise message to the requesting router that includes the IA_PD with no prefixes in the IA_PD and a Status Code option in the IA_PD containing status code NoPrefixAvail and a status message for the user, a Server Identifier option with the delegating router's DUID and a Client Identifier option with the requesting router's DUID.

So it would be a perfectly valid approach to implement this in the "find free prefix/address" code part and just return the same way you could if there are no free prefix/addresses to be had (NoAddrsAvail and NoPrefixAvail) respectively, when the odhcpd is configured to not provide NA/PD respectively.

dedeckeh commented 5 years ago

Implemented in https://github.com/openwrt/odhcpd/commit/7abbed4fba6c9b75ec5331291eb7dc787f99a977