RFC-3442 classless routes and DHCPD
Philip Prindeville
philipp_subx at redfish-solutions.com
Mon Aug 17 16:58:31 UTC 2020
Still working on the OpenWRT integration of ISC-DHCP(D) and was hoping for some guidance.
I was looking at:
https://kb.isc.org/docs/isc-dhcp-44-manual-pages-dhcp-options#DEFINING%20NEW%20OPTIONS
As well as RFC 3442, in particular:
Classless Route Option Format
The code for this option is 121, and its minimum length is 5 bytes.
This option can contain one or more static routes, each of which
consists of a destination descriptor and the IP address of the router
that should be used to reach that destination.
Code Len Destination 1 Router 1
+-----+---+----+-----+----+----+----+----+----+
| 121 | n | d1 | ... | dN | r1 | r2 | r3 | r4 |
+-----+---+----+-----+----+----+----+----+----+
Destination 2 Router 2
+----+-----+----+----+----+----+----+
| d1 | ... | dN | r1 | r2 | r3 | r4 |
+----+-----+----+----+----+----+----+
In the above example, two static routes are specified.
Destination descriptors describe the IP subnet number and subnet mask
of a particular destination using a compact encoding. This encoding
consists of one octet describing the width of the subnet mask,
followed by all the significant octets of the subnet number.
The width of the subnet mask describes the number of one bits in the
mask, so for example a subnet with a subnet number of 10.0.127.0 and
a netmask of 255.255.255.0 would have a subnet mask width of 24.
The significant portion of the subnet number is simply all of the
octets of the subnet number where the corresponding octet in the
subnet mask is non-zero. The number of significant octets is the
width of the subnet mask divided by eight, rounding up, as shown in
the following table:
Width of subnet mask Number of significant octets
0 0
1- 8 1
9-16 2
17-24 3
25-32 4
The following table contains some examples of how various subnet
number/mask combinations can be encoded:
Subnet number Subnet mask Destination descriptor
0 0 0
10.0.0.0 255.0.0.0 8.10
10.0.0.0 255.255.255.0 24.10.0.0
10.17.0.0 255.255.0.0 16.10.17
10.27.129.0 255.255.255.0 24.10.27.129
10.229.0.128 255.255.255.128 25.10.229.0.128
10.198.122.47 255.255.255.255 32.10.198.122.47
And how to reconcile these two. Don’t know why the option needed to “compact” the dotted quad… It just seems to create more work for no apparent gain (other than a pittance of octets saved).
Does anyone have a simple/clever way to define a new option for RFC-3442?
Without the compaction, this would be trivial as:
option classless-ipv4-route code 121 = { unsigned integer 8, ip-address, ip-address };
But that’s not the case.
I could do:
option classless-ipv4-route code 121 = { unsigned integer 8, array of { unsigned integer 8 }, ip-address };
But then I lose the notational convenience of ip-address.
Anyone?
Thanks,
-Philip
More information about the dhcp-workers
mailing list