Bug 459276

Summary: NetworkManager doesn't honor the NTP servers provided by the DHCP server
Product: [Fedora] Fedora Reporter: Anders Blomdell <anders.blomdell>
Component: dhcpAssignee: Jiri Popelka <jpopelka>
Status: CLOSED CURRENTRELEASE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: medium Docs Contact:
Priority: medium    
Version: 13CC: cra, dcbw, jns, liblit, mlichvar, pertusus, somlo, wtogami
Target Milestone: ---Keywords: Reopened
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2010-05-22 06:33:09 EDT Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---
Attachments:
Description Flags
Temporary workaround (python dbus listener)
none
Changes to .spec file needed for clean install on FC9
none
Patch to make it compile on FC9
none
suggested dispatcher script for dhclient
none
improve dhclient dispatcher script none

Description Anders Blomdell 2008-08-15 12:20:24 EDT
Created attachment 314394 [details]
Temporary workaround (python dbus listener)

Description of problem:

NetworkManager doesn't honor the NTP servers provided by the DHCP server.

Version-Release number of selected component (if applicable):

NetworkManager-0.7.0-0.9.4.svn3675.fc9.i386



How reproducible:

Always

Steps to Reproduce:
1. Start network on a network where DHCP provides NTP servers
2. 
3.
  
Actual results:

/etc/ntp.conf is unchanged, i.e. servers are:

server 0.fedora.pool.ntp.org dynamic
server 1.fedora.pool.ntp.org dynamic
server 2.fedora.pool.ntp.org dynamic

Expected results:

The servers from the DHCP servers should be used

Additional info:
Comment 1 Anders Blomdell 2008-08-15 12:35:35 EDT
Comment on attachment 314394 [details]
Temporary workaround (python dbus listener)

OOPS, typo:

if new_servers == old_servers:

should be:

if new_servers != old_servers:
Comment 2 Dan Williams 2008-08-15 13:22:52 EDT
I don't think the normal network scripts handle this either?  What usually updates the settings when NM isn't in use?

You can also just write a script that you place in /etc/NetworkManager/dispatcher.d that takes two arguments (a) interface name, and (b) "up" or "down", and then grab NTP servers out of the IP4_NTP_SERVERS environment variable.
Comment 3 Dan Williams 2008-08-15 13:25:09 EDT
ah right, dhclient hooks.  Yeah, we should have dispatcher scripts to hook up ntp/nis/etc.
Comment 4 Anders Blomdell 2008-08-15 13:46:53 EDT
(In reply to comment #2)
> I don't think the normal network scripts handle this either?  What usually
> updates the settings when NM isn't in use?
> 
> You can also just write a script that you place in
> /etc/NetworkManager/dispatcher.d that takes two arguments (a) interface name,
> and (b) "up" or "down", and then grab NTP servers out of the IP4_NTP_SERVERS
> environment variable.

That would be nice, but it seems to me like the the logic to pass environment variables to the /etc/NetworkManager/dispatcher.d/ scripts is lacking, with this script:

#!/bin/sh

date >> /tmp/ntp.log
echo $@ >> /tmp/ntp.log
printenv >> /tmp/ntp.log

I get:

Fri Aug 15 19:43:56 CEST 2008
eth1 down
PWD=/
SHLVL=1
_=/usr/bin/printenv
Fri Aug 15 19:44:00 CEST 2008
eth1 up
PWD=/
SHLVL=1
_=/usr/bin/printenv
Comment 5 Dan Williams 2008-08-15 14:47:31 EDT
3675, yes.  Whats in F9 updates-testing (3930) exports the DHCP configuration to the scripts' environment.
Comment 7 Anders Blomdell 2008-08-15 15:38:44 EDT
With 3930 from svn://svn.gnome.org/svn/NetworkManager/trunk

> grep IP4 callouts/nm-dispatcher-action.c
construct_envp (NMIP4Config *ip4_config, NMDHCP4Config *dhcp4_config)
        /* IP4 config stuff */
             NMSettingIP4Address *addr = (NMSettingIP4Address *) iter->data;
             g_string_append_printf (tmp, "IP4_ADDRESS_%d=%s/%d %s", num++, str_addr, addr->prefix, str_gw);
             envp[envp_idx++] = g_strdup_printf ("IP4_NUM_ADDRESSES=%d", num);
             tmp = g_string_new ("IP4_NAMESERVERS=");
             tmp = g_string_new ("IP4_DOMAINS=");
             NMSettingIP4Route *route = (NMSettingIP4Route *) iter->data;
             g_string_append_printf (tmp, "IP4_ROUTE_%d=%s/%d %s %d", num++, str_addr, route->prefix, str_nh, route->metric);
        envp[envp_idx++] = g_strdup_printf ("IP4_NUM_ROUTES=%d", num);
                  NMIP4Config *ip4_config,
        NMIP4Config *ip4_config = NULL;

No IP4_NTP_SERVER to be seen...
Comment 8 Dan Williams 2008-08-15 15:52:40 EDT
Sorry, I lied there :)

DHCP4_NTP_SERVERS

is what you'll want.  The DHCP options get dumped into the script environment too, prefixed with DHCP4_ and all upper-case, without the "new_" prefix.  This functionality for DHCP options should also be present in the svn38xx that's in updates-testing as well as 3930.
Comment 9 Anders Blomdell 2008-08-18 07:19:53 EDT
Created attachment 314469 [details]
Changes to .spec file needed for clean install on FC9
Comment 10 Anders Blomdell 2008-08-18 07:20:40 EDT
Created attachment 314470 [details]
Patch to make it compile on FC9
Comment 11 Anders Blomdell 2008-08-18 07:34:24 EDT
OK, found svn3930 in development (not updates-testing). Have attached what is needed to make it compile and install on FC9.

Now I get the DHCP environment variables when interface goes up, but if some info changes at renewal, that is not propagated. I.E. with NetworkManager there is no to emulate this behaviour from /sbin/dhclient-script:


    elif [ -n "$new_ntp_servers" ] && [ -e /etc/ntp.conf ]; then
        save_previous /etc/ntp.conf
        /bin/egrep -v '^server .*  # added by /sbin/dhclient-script$'< /etc/ntp.conf.predhclient.$interface > /etc/ntp.conf

        for s in $new_ntp_servers; do
            echo "server $s  # added by /sbin/dhclient-script" >> /etc/ntp.conf
        done

        if [ -x /usr/bin/diff ] && /usr/bin/diff -q /etc/ntp.conf /etc/ntp.conf.predhclient.$interface >/dev/null 2>&1; then
            :
        else
            /sbin/service ntpd condrestart >/dev/null 2>&1
        fi
    fi

since /etc/NeworkManager/dispatcher.d/* doesn't get called on DHCP lease updates, is this something that will be fixed (e.g. by adding a 'renew' massage besides the 'up' and 'down' messages)?
Comment 12 Dan Williams 2008-08-18 09:41:14 EDT
Good point; I'll add that functionality.  It'll be named something like "ip4-change" instead of "up" or "down".
Comment 13 Jessica Sterling 2009-03-08 16:38:31 EDT
This bug has been triaged.

-- 
Fedora Bugzappers volunteer triage team
https://fedoraproject.org/wiki/BugZappers
Comment 14 Miroslav Lichvar 2009-04-20 09:06:57 EDT
dhclient now has the functionality moved to /etc/dhcp/dhclient.d/*.sh, could NetworkManager call these scripts?
Comment 15 Dan Williams 2009-05-09 22:58:28 EDT
(In reply to comment #14)
> dhclient now has the functionality moved to /etc/dhcp/dhclient.d/*.sh, could
> NetworkManager call these scripts?  

no, but a dispatcher script dropped in /etc/NetworkManager/dispatcher.d certainly could if dhcp wanted to drop one there
Comment 16 Bug Zapper 2009-06-09 22:28:37 EDT
This message is a reminder that Fedora 9 is nearing its end of life.
Approximately 30 (thirty) days from now Fedora will stop maintaining
and issuing updates for Fedora 9.  It is Fedora's policy to close all
bug reports from releases that are no longer maintained.  At that time
this bug will be closed as WONTFIX if it remains open with a Fedora 
'version' of '9'.

Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version' 
to a later Fedora version prior to Fedora 9's end of life.

Bug Reporter: Thank you for reporting this issue and we are sorry that 
we may not be able to fix it before Fedora 9 is end of life.  If you 
would still like to see this bug fixed and are able to reproduce it 
against a later version of Fedora please change the 'version' of this 
bug to the applicable version.  If you are unable to change the version, 
please add a comment here and someone will do it for you.

Although we aim to fix as many bugs as possible during every release's 
lifetime, sometimes those efforts are overtaken by events.  Often a 
more recent Fedora release includes newer upstream software that fixes 
bugs or makes them obsolete.

The process we are following is described here: 
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 17 Bug Zapper 2009-07-14 12:55:16 EDT
Fedora 9 changed to end-of-life (EOL) status on 2009-07-10. Fedora 9 is 
no longer maintained, which means that it will not receive any further 
security or bug fix updates. As a result we are closing this bug.

If you can reproduce this bug against a currently maintained version of 
Fedora please feel free to reopen this bug against that version.

Thank you for reporting this bug and we are sorry it could not be fixed.
Comment 18 David Cantrell 2009-07-16 15:38:24 EDT
Per comment #15, reassigning to ntp.  The ntp package should also be providing an /etc/NetworkManager/dispatcher.d script to handle the NTP options from the server.
Comment 19 Miroslav Lichvar 2009-07-17 06:00:23 EDT
Wouldn't it be better to reuse the scripts in /etc/dhcp/dhclient.d/ and have just one dhclient script in /etc/NetworkManager/dispatcher.d/ that would call them?
Comment 20 David Cantrell 2009-07-20 16:00:50 EDT
(In reply to comment #19)
> Wouldn't it be better to reuse the scripts in /etc/dhcp/dhclient.d/ and have
> just one dhclient script in /etc/NetworkManager/dispatcher.d/ that would call
> them?  

I have no problem with that.  Whatever you want to do in the ntp package to provide the helper scripts to dhclient-script and NetworkManager is fine with me.
Comment 21 Miroslav Lichvar 2009-07-23 11:43:58 EDT
Created attachment 354878 [details]
suggested dispatcher script for dhclient
Comment 22 Miroslav Lichvar 2009-07-23 11:48:44 EDT
Ok, attached is a dhclient dispatcher script that calls the dhclient.d scripts on "up" and "down".

If NetworkManager implements also a "renew" event, it might be useful to export also the old_* variables provided by dhclient.
Comment 23 David Cantrell 2009-07-23 23:08:27 EDT
Script is included in dhcp-4.1.0-25.fc12.  Thanks.
Comment 24 Miroslav Lichvar 2009-08-12 11:00:11 EDT
Created attachment 357182 [details]
improve dhclient dispatcher script

David, can you please apply this patch for the dispatcher script in the next release? It replaces the expensive conversion to lowercase and adds /etc/sysconfig/network sourcing.
Comment 25 David Cantrell 2009-08-12 17:12:32 EDT
(In reply to comment #24)
> Created an attachment (id=357182) [details]
> improve dhclient dispatcher script
> 
> David, can you please apply this patch for the dispatcher script in the next
> release? It replaces the expensive conversion to lowercase and adds
> /etc/sysconfig/network sourcing.  

Done, built as dhcp-4.1.0p1-3.fc12 in rawhide.
Comment 26 Gabriel Somlo 2009-11-23 14:06:46 EST
I'm (now) on F-12, running dhclient-4.1.0p1-13.fc12, but can't find the
dhclient dispatcher script at the location suggested by previous comments:

'/etc/NetworkManager/dispatcher.d/10-dhclient'

NetworkManager + dhclient still do not install ntp servers received via dhcp.
Comment 27 Bug Zapper 2010-03-15 08:03:18 EDT
This bug appears to have been reported against 'rawhide' during the Fedora 13 development cycle.
Changing version to '13'.

More information and reason for this action is here:
http://fedoraproject.org/wiki/BugZappers/HouseKeeping
Comment 28 Jiri Popelka 2010-05-22 06:33:09 EDT
(In reply to comment #26)
> I'm (now) on F-12, running dhclient-4.1.0p1-13.fc12, but can't find the
> dhclient dispatcher script at the location suggested by previous comments:
> 
> '/etc/NetworkManager/dispatcher.d/10-dhclient'

Fixed in dhcp-4.1.1-16.fc12 and dhcp-4.1.1-21.fc13.