After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 761268 - default route not added from dhcp option 121 (classless-static-routes)
default route not added from dhcp option 121 (classless-static-routes)
Status: RESOLVED FIXED
Product: NetworkManager
Classification: Platform
Component: IP and DNS config
1.0.x
Other Linux
: Normal normal
: ---
Assigned To: NetworkManager maintainer(s)
NetworkManager maintainer(s)
Depends on:
Blocks: nm-1-2
 
 
Reported: 2016-01-28 22:38 UTC by Uwe Helm
Modified: 2016-02-15 23:16 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
dhcp/systemd: accept default gateway in classless static routes option (5.34 KB, patch)
2016-02-15 10:50 UTC, Beniamino Galvani
none Details | Review

Description Uwe Helm 2016-01-28 22:38:57 UTC
I run an OpenBSD 5.8 DHCP server that hands out 3 routes via dhcp option 121 (classless-static-routes). The default gateway is one of these routes and is handed out as 0.0.0.0/0. It works fine on CentOS 6 and 7 with NetworkManager 1.0.6.

NM 1.0.10 (Arch) configures everything correctly except for the default gateway.

The log message is the following:


nm_ip4_config_add_route: assertion 'new->plen > 0' failed


The DHCP offer looks fine in a packet tracer. I wasn't able to reproduce the issue with 2 VMs and the same software versions.


The dhcpd.conf line looks like this (obfuscated the public IPs):
option classless-static-routes 172.16.0.0/16 x.x.x.253, 10.0.0.0/8 x.x.x.253, 0.0.0.0/0 x.x.x.254;
Comment 1 Thomas Haller 2016-01-29 17:10:20 UTC
(In reply to Uwe Helm from comment #0)
> I run an OpenBSD 5.8 DHCP server that hands out 3 routes via dhcp option 121
> (classless-static-routes). The default gateway is one of these routes and is
> handed out as 0.0.0.0/0. It works fine on CentOS 6 and 7 with NetworkManager
> 1.0.6.
> 
> NM 1.0.10 (Arch) configures everything correctly except for the default
> gateway.
> 
> The log message is the following:
> 
> 
> nm_ip4_config_add_route: assertion 'new->plen > 0' failed

that the assertion is hit is a bug.

Nonetheless, NM doesn't accept a default route (i.e. one with prefix length zero) via a option 33 nor 121.

Instead it only allows specifying it as router (dhcp option 3).


Strange if it worked in 1.0.6. Your DHCP server configuration didn't change?


> The DHCP offer looks fine in a packet tracer. I wasn't able to reproduce the
> issue with 2 VMs and the same software versions.
> 
> 
> The dhcpd.conf line looks like this (obfuscated the public IPs):
> option classless-static-routes 172.16.0.0/16 x.x.x.253, 10.0.0.0/8
> x.x.x.253, 0.0.0.0/0 x.x.x.254;

You did configure "ipv4.never-default" as "no", right? Check with `nmcli connection show $ID`.

What DHCP plugin are you using? (configured in /etc/NetworkManager/NetworkManager.conf or conf.d).
Comment 2 Uwe Helm 2016-02-04 18:32:38 UTC
(In reply to Thomas Haller from comment #1)
> (In reply to Uwe Helm from comment #0)
> > I run an OpenBSD 5.8 DHCP server that hands out 3 routes via dhcp option 121
> > (classless-static-routes). The default gateway is one of these routes and is
> > handed out as 0.0.0.0/0. It works fine on CentOS 6 and 7 with NetworkManager
> > 1.0.6.
> > 
> > NM 1.0.10 (Arch) configures everything correctly except for the default
> > gateway.
> > 
> > The log message is the following:
> > 
> > 
> > nm_ip4_config_add_route: assertion 'new->plen > 0' failed
> 
> that the assertion is hit is a bug.
> 
> Nonetheless, NM doesn't accept a default route (i.e. one with prefix length
> zero) via a option 33 nor 121.
> 
> Instead it only allows specifying it as router (dhcp option 3).
> 
> 
> Strange if it worked in 1.0.6. Your DHCP server configuration didn't change?

I have 25 CentOS 7 (NM 1.0.6) clients connected and the default route works fine for them. Only my NM 1.0.10 has this issue.

> 
> 
> > The DHCP offer looks fine in a packet tracer. I wasn't able to reproduce the
> > issue with 2 VMs and the same software versions.
> > 
> > 
> > The dhcpd.conf line looks like this (obfuscated the public IPs):
> > option classless-static-routes 172.16.0.0/16 x.x.x.253, 10.0.0.0/8
> > x.x.x.253, 0.0.0.0/0 x.x.x.254;
> 
> You did configure "ipv4.never-default" as "no", right? Check with `nmcli
> connection show $ID`.

I didn't configure it but it shows as "no".
> 
> What DHCP plugin are you using? (configured in
> /etc/NetworkManager/NetworkManager.conf or conf.d).

It's "dhcp=internal" on my machine. For the CentOS 7 machines there is no "dhcp=" option, but "plugins=ifcfg-rh" and it uses dhclient. That probably explains why it's working on those machines.
Comment 3 Uwe Helm 2016-02-04 21:29:04 UTC
Was able to test it today and "dhcp=dhclient" works for the default route.

NetworkManager[15479]: <info>    gateway x.x.x.254
NetworkManager[15479]: <info>    classless static route 10.0.0.0/8 gw x.x.x.253
NetworkManager[15479]: <info>    classless static route 172.16.0.0/16 gw x.x.x.253
Comment 4 Beniamino Galvani 2016-02-15 09:18:36 UTC
I think this is a bug in the internal DHCP client implementation, which should handle a default (0/0) route in the "classless static routes" option as a gateway. In fact, this is the only way possible to provide a default gateway when option 121 is used, since RFC 3442 states:

  If the DHCP server returns both a Classless Static Routes option and
  a Router option, the DHCP client MUST ignore the Router option.

We should fix this.
Comment 5 Beniamino Galvani 2016-02-15 10:50:03 UTC
Created attachment 321235 [details] [review]
dhcp/systemd: accept default gateway in classless static routes option
Comment 6 Thomas Haller 2016-02-15 19:19:39 UTC

nm_log_info (LOGD_DHCP4, "ignoring duplicate default classless static route");

I'm not sure we should log something like that because it can be triggered externally and flood the log. I would just silently ignore it.




  static_default_gateway = TRUE;
  nm_ip4_config_set_gateway (ip4_config, route.gateway);

if route.gateway is 0.0.0.0, we add an on-link route. Is that a valid setting? Maybe zero default-gateways should be rejected?


Otherwise lgtm
Comment 7 Beniamino Galvani 2016-02-15 23:16:51 UTC
(In reply to Thomas Haller from comment #6)
> I'm not sure we should log something like that because it can be triggered
> externally and flood the log. I would just silently ignore it.

Ok, dropped the message.

> if route.gateway is 0.0.0.0, we add an on-link route. Is that a valid
> setting? Maybe zero default-gateways should be rejected?

This is explicitly allowed by RFC 3442, to provide a way for the server to deliver link routes when the client belongs to multiple subnets.

Merged to master:

https://cgit.freedesktop.org/NetworkManager/NetworkManager/commit/?id=0f5c5ad44692d029eec60cdc7d8783b51ede59bb