dhcp: request classless-static-route option first according to RFC 3442

In ip4_start(), we iterate over @dhcp4_requests array and add the
options that are to be included. We do so, by calling
sd_dhcp_client_set_request_option().

Note that sd_dhcp_client_set_request_option() only appends the options
to a list, not taking special care about the order in which options are
added.

RFC 3442 (The Classless Static Route Option for Dynamic Host Configuration
Protocol (DHCP) version 4) says:

   DHCP clients that support this option and send a parameter request
   list MAY also request the Static Routes option, for compatibility
   with older servers that don't support Classless Static Routes.  The
   Classless Static Routes option code MUST appear in the parameter
   request list prior to both the Router option code and the Static
   Routes option code, if present.

Compare to RFC 2132 (DHCP Options and BOOTP Vendor Extensions) which says
about the parameter request list:

   The client MAY list the options in order of preference.

Note, with RFC 7844 (Anonymity Profiles for DHCP Clients), the order
should be randomized. But since we don't follow RFC 7844 (yet), let's follow
at least RFC 3442.
This commit is contained in:
Thomas Haller 2018-12-03 16:08:34 +01:00
parent 795facc2ba
commit 2f2b489d38

View file

@ -115,19 +115,24 @@ typedef struct {
static const ReqOption dhcp4_requests[] = {
REQ (SD_DHCP_OPTION_SUBNET_MASK, "subnet_mask", TRUE ),
REQ (SD_DHCP_OPTION_TIME_OFFSET, "time_offset", TRUE ),
REQ (SD_DHCP_OPTION_ROUTER, "routers", TRUE ),
REQ (SD_DHCP_OPTION_DOMAIN_NAME_SERVER, "domain_name_servers", TRUE ),
REQ (SD_DHCP_OPTION_HOST_NAME, "host_name", TRUE ),
REQ (SD_DHCP_OPTION_DOMAIN_NAME, "domain_name", TRUE ),
REQ (SD_DHCP_OPTION_INTERFACE_MTU, "interface_mtu", TRUE ),
REQ (SD_DHCP_OPTION_BROADCAST, "broadcast_address", TRUE ),
/* RFC 3442: The Classless Static Routes option code MUST appear in the parameter
* request list prior to both the Router option code and the Static
* Routes option code, if present. */
REQ (SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE, "rfc3442_classless_static_routes", TRUE ),
REQ (SD_DHCP_OPTION_ROUTER, "routers", TRUE ),
REQ (SD_DHCP_OPTION_STATIC_ROUTE, "static_routes", TRUE ),
REQ (DHCP_OPTION_NIS_DOMAIN, "nis_domain", TRUE ),
REQ (DHCP_OPTION_NIS_SERVERS, "nis_servers", TRUE ),
REQ (SD_DHCP_OPTION_NTP_SERVER, "ntp_servers", TRUE ),
REQ (SD_DHCP_OPTION_SERVER_IDENTIFIER, "dhcp_server_identifier", TRUE ),
REQ (SD_DHCP_OPTION_DOMAIN_SEARCH_LIST, "domain_search", TRUE ),
REQ (SD_DHCP_OPTION_CLASSLESS_STATIC_ROUTE, "rfc3442_classless_static_routes", TRUE ),
REQ (SD_DHCP_OPTION_PRIVATE_CLASSLESS_STATIC_ROUTE, "ms_classless_static_routes", TRUE ),
REQ (SD_DHCP_OPTION_PRIVATE_PROXY_AUTODISCOVERY, "wpad", TRUE ),
REQ (SD_DHCP_OPTION_ROOT_PATH, "root_path", TRUE ),