On 17 July 2021 13:16:59 CEST, Bjorn Ketelaars <b...@openbsd.org> wrote:
>An inconsistency exists between dhclient(8) and dhcpleased(8) when
>receiving the Classless Static Routes option: dhcpleased creates a
>default route, while dhclient does not.
>
>If I'm not mistaken, the behaviour of dhclient is correct. From
>rfc3442:
>"If the DHCP server returns both a Classless Static Routes option and a
>Router option, the DHCP client MUST ignore the Router option."
>

Correct. But you are fixing it in the wrong place. It doesn't say to ignore a 
default route, which can be transmitted via classless static routes option 
(it's 0/0).

You need to fix this in parse_dhcp in engine.c

>Comments?
>
>
>diff --git sbin/dhcpleased/dhcpleased.c sbin/dhcpleased/dhcpleased.c
>index 2157406e71a..93df9f55e7f 100644
>--- sbin/dhcpleased/dhcpleased.c
>+++ sbin/dhcpleased/dhcpleased.c
>@@ -819,7 +819,7 @@ configure_routes(uint8_t rtm_type, struct
>imsg_configure_interface *imsg)
> {
>       struct sockaddr_in       dst, mask, gw, ifa;
>       in_addr_t                addrnet, gwnet;
>-      int                      i;
>+      int                      csr = 0, i;
> 
>       memset(&ifa, 0, sizeof(ifa));
>       ifa.sin_family = AF_INET;
>@@ -840,6 +840,13 @@ configure_routes(uint8_t rtm_type, struct
>imsg_configure_interface *imsg)
> 
>       addrnet = imsg->addr.s_addr & imsg->mask.s_addr;
> 
>+      for (i = 0; i < imsg->routes_len; i++) {
>+              if (imsg->routes[i].dst.s_addr != INADDR_ANY) {
>+                      csr = 1;
>+                      break;
>+              }
>+      }
>+
>       for (i = 0; i < imsg->routes_len; i++) {
>               dst.sin_addr.s_addr = imsg->routes[i].dst.s_addr;
>               mask.sin_addr.s_addr = imsg->routes[i].mask.s_addr;
>@@ -872,6 +879,15 @@ configure_routes(uint8_t rtm_type, struct
>imsg_configure_interface *imsg)
>                               /* directly connected default */
>                               configure_route(rtm_type, imsg->if_index,
>                                   imsg->rdomain, &dst, &mask, &gw, NULL, 0);
>+                      } else if (csr) {
>+                              /*
>+                              * RFC3442 states that if the DHCP server returns
>+                              * both a Classless Static Routes option and a
>+                              * Router option, the DHCP client MUST ignore the
>+                              * Router option.
>+                              */
>+                              log_warnx("%s: ignoring router option",
>+                                  __func__);
>                       } else {
>                               /* default route via gateway */
>                               configure_route(rtm_type, imsg->if_index,

-- 
Sent from a mobile device. Please excuse poor formatting.

Reply via email to