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 10:33:09 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
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 16:20:24 UTC
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 16:35:35 UTC
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 17:22:52 UTC
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 17:25:09 UTC
ah right, dhclient hooks.  Yeah, we should have dispatcher scripts to hook up ntp/nis/etc.

Comment 4 Anders Blomdell 2008-08-15 17:46:53 UTC
(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 18:47:31 UTC
3675, yes.  Whats in F9 updates-testing (3930) exports the DHCP configuration to the scripts' environment.

Comment 7 Anders Blomdell 2008-08-15 19:38:44 UTC
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 19:52:40 UTC
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 11:19:53 UTC
Created attachment 314469 [details]
Changes to .spec file needed for clean install on FC9

Comment 10 Anders Blomdell 2008-08-18 11:20:40 UTC
Created attachment 314470 [details]
Patch to make it compile on FC9

Comment 11 Anders Blomdell 2008-08-18 11:34:24 UTC
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 13:41:14 UTC
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 20:38:31 UTC
This bug has been triaged.

-- 
Fedora Bugzappers volunteer triage team
https://fedoraproject.org/wiki/BugZappers

Comment 14 Miroslav Lichvar 2009-04-20 13:06:57 UTC
dhclient now has the functionality moved to /etc/dhcp/dhclient.d/*.sh, could NetworkManager call these scripts?

Comment 15 Dan Williams 2009-05-10 02:58:28 UTC
(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-10 02:28:37 UTC
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 16:55:16 UTC
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 19:38:24 UTC
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 10:00:23 UTC
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 20:00:50 UTC
(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 15:43:58 UTC
Created attachment 354878 [details]
suggested dispatcher script for dhclient

Comment 22 Miroslav Lichvar 2009-07-23 15:48:44 UTC
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-24 03:08:27 UTC
Script is included in dhcp-4.1.0-25.fc12.  Thanks.

Comment 24 Miroslav Lichvar 2009-08-12 15:00:11 UTC
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 21:12:32 UTC
(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 19:06:46 UTC
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 12:03:18 UTC
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 10:33:09 UTC
(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.