[PATCH]: compute_nameservers - NM mishandles multiple DHCP name servers



When a DCHP server provides multiple domain-name-servers, NM currently
repeats the first one serveral times in /etc/resolv.conf.

For example, if the DHCP lease is:
lease {
  interface "eth0";
  fixed-address 10.10.4.5;
  option subnet-mask 255.255.0.0;
  option dhcp-lease-time 604800;
  option routers 10.10.2.2;
  option dhcp-message-type 5;
  option dhcp-server-identifier 10.10.2.11;
  option domain-name-servers 10.10.2.102,10.10.2.11,10.10.2.118;
  option dhcp-renewal-time 302400;
  option dhcp-rebinding-time 529200;
  option domain-name "foobar.com";
  renew 0 2006/1/22 19:38:42;
  rebind 3 2006/1/25 20:29:27;
  expire 4 2006/1/26 17:29:27;
}

NM produces the following /etc/resolv.conf:
# generated by NetworkManager, do not edit!

search foobar.com


nameserver 10.10.2.102
nameserver 10.10.2.102
nameserver 10.10.2.102

The problem appears to be in the file nm-named-manager.c, in the
function compute_nameservers().

It looks like the loop is not 'using' the loop index:

Should
                addr.s_addr = nm_ip4_config_get_nameserver (config, 0);
be
                addr.s_addr = nm_ip4_config_get_nameserver (config, i);

A suggested patch:

--- nm-named-manager.c  2005-09-28 07:42:57.000000000 -0700
+++ new.c       2006-01-19 10:45:29.000000000 -0800
@@ -301,7 +301,7 @@
                if (!str)
                        str = g_string_new ("");

-               addr.s_addr = nm_ip4_config_get_nameserver (config, 0);
+               addr.s_addr = nm_ip4_config_get_nameserver (config, i);
                buf = g_malloc0 (ADDR_BUF_LEN);
                inet_ntop (AF_INET, &addr, buf, ADDR_BUF_LEN);

tom
--
Tom London



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]