Bug 80054 - dns/dnsmasq: dns-servers are started too late if not named
Summary: dns/dnsmasq: dns-servers are started too late if not named
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-04-18 09:30 UTC by Thomas Schweikle
Modified: 2005-07-16 02:23 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Schweikle 2005-04-18 09:30:28 UTC
      if an other dns server than named is used, like dnsmasq, this server is started after other daemons requiring dns services, like ntpdate and ntpd.

Fix: 

Any dns server selected has to start before and daemon using dns services. This makes daemon starting global. It can't matter a daemon being "Local" or "System". It maters what it provides.

The error is within the start procedure first starting all "System" daemons, then local ones. We can't do it this way. We have to intermix both, then find what has to be started first, regardless of "Local" or "System".
How-To-Repeat:       In /etc/rc.conf set:
| dnsmasq_enable="YES"
| named_enable="NO"

Configure dnsmasq in /usr/local/etc/dnsmasq.conf:
| domain-needed
| bogus-priv
| filterwin2k
| resolv-file=/etc/resolv.dnsmasq
| local=/invalid/
| expand-hosts
| domain=invalid
| dhcp-range=192.168.1.100,192.168.1.199,255.255.255.0,192.168.1.255,48h
| dhcp-option=3,192.168.1.1
| dhcp-authoritative
| cache-size=150
| no-negcache

Configure /etc/resolv.dnsmasq:
| search invalid
| nameserver 217.237.150.141
| nameserver 217.237.150.97

Configure /etc/resolv.conf:
| search invalid
| nameserver 127.0.0.1
| nameserver 192.168.1.11

Restart.
ntpdate will now be started before dnsmasq is running. Thus ntpdate will never find configured servers. This makes the system start extremly slow, since it waits for ntpdates dns query to time out. Second: time is never set by ntpdate, in tune ntpd does not sync if the local clocks displacement is to large.
Comment 1 Gleb Smirnoff freebsd_committer freebsd_triage 2005-04-18 13:03:36 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-port-bugs

This is issue with dnsmasq port, not with base system.
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2005-04-25 23:04:18 UTC
Responsible Changed
From-To: freebsd-port-bugs->freebsd-ports-bugs

Fix assignment.
Comment 3 Yen-Ming Lee freebsd_committer freebsd_triage 2005-05-11 05:46:26 UTC
State Changed
From-To: open->feedback

The maintainer is noticed.
Comment 4 Yen-Ming Lee freebsd_committer freebsd_triage 2005-05-11 05:46:30 UTC
Responsible Changed
From-To: freebsd-ports-bugs->leeym

I will take care of this PR.
Comment 5 Thomas Schweikle 2005-05-11 12:04:32 UTC
OK. I've tested. No change.

This was something I tried first.

The start script does:
- read all headers from files in "/etc/rc.d",
- calculate dependencies,
- start everything in dependency order,
- read all headers from files in "/usr/local/etc/rc.d",
- calculate dependencies,
- start everything in dependency order

The start script does no:
- read all headers from files in "/etc/rc.d", "/usr/local/etc/rc.d",
- calculate dependencies,
- start everything in dependency order

Given the above: dnsmasq will *always* start *after* ntpdate, since
starting ntpdate is done with "/etc/rc.d/ntpdate". This is worked on and
run *before* any file in "/usr/local/etc/rc.d" is touched.

With the second approach this would be done --- but this is not what
"/etc/rc" tells rcorder to do:
files=`rcorder ${skip} /etc/rc.d/* 2>/dev/null`

for _rc_elem in ${files}; do
        run_rc_script ${_rc_elem} ${_boot}
done

Only "/etc/rc.d" is looked at. rcorder should instead have had looked at
both: "/etc/rc.d" *and* "/usr/local/etc/rc.d". Handling over the full
list of daemons to start in "${files}".

Given instead in "/etc/rc":
files=`rcorder ${skip} /etc/rc.d/* /usr/local/etc/rc.d/*\.sh \
  2>/dev/null`

would solve the problem.


BTW: Your patch makes "rcorder /etc/rc.d/* /usr/local/etc/rc.d/*\.sh"
exaust:
/etc/rc.d/NETWORKING
/etc/rc.d/devd
/etc/rc.d/mountcritremote
/etc/rc.d/accounting
/etc/rc.d/cleanvar
/etc/rc.d/ipmon
/etc/rc.d/syslogd
/etc/rc.d/savecore
/etc/rc.d/SERVERS
/etc/rc.d/named                <---
/etc/rc.d/ntpdate              <---
/etc/rc.d/rpcbind
/etc/rc.d/nfsclient
/etc/rc.d/nisdomain
/etc/rc.d/ypserv
/etc/rc.d/ypbind
/etc/rc.d/amd
/etc/rc.d/atm3
/etc/rc.d/tmp
/etc/rc.d/cleartmp
/etc/rc.d/dmesg
/etc/rc.d/ike
/etc/rc.d/ipsec
/etc/rc.d/ipxrouted
/etc/rc.d/kerberos
/etc/rc.d/kadmind
/etc/rc.d/keyserv
/etc/rc.d/kpasswdd
/etc/rc.d/ldconfig
/etc/rc.d/quota
/etc/rc.d/nfsserver
/etc/rc.d/mountd
/etc/rc.d/nfsd
/etc/rc.d/nfslocking
/etc/rc.d/pflog
/etc/rc.d/pf
/etc/rc.d/pppoed
/etc/rc.d/pwcheck
/etc/rc.d/virecover
/usr/local/etc/rc.d/apache2.sh
rcorder: Circular dependency on provision `DAEMON' in file
`/usr/local/etc/rc.d/dnsmasq.sh'.
/usr/local/etc/rc.d/dnsmasq.sh <---

While "/etc/rc.d/named" is started *before* "/etc/rc.d/ntpdate",
"/usr/local/etc/rc.d/dnsmasq.sh" ist called after. But it would be
necessary to call "/usr/local/etc/rc.d/dnsmasq.sh" right after
"/etc/rc.d/named".

There is a atage missing in between "NETWORK" and "SERVER" we could put
services in required by other services, or alternatively: a keyword
ordering "named" or "dnsmasq" right after all "NETWORK" started.

Changing the header of "/usr/local/etc/rc.d/dnsmasq.sh" to:
#! /bin/sh
#
#
# PROVIDE: dnsmasq
# REQUIRE: NETWORKING syslogd cleanvar
# BEFORE:  SERVERS
# KEYWORD: FreeBSD
#
# Add the following line to /etc/rc.conf to enable dnsmasq:

BTW: The same should be done for "/etc/rc.d/named" --- just to make
shure it is there before any other maybe requiring dns services are started.

Additionaly it would be of high use, if "named" and "dnsmasq" could
provide "dns" ("dnsmasq" additionaly "dhcp"). Other services depending
on these could just ask for "dns" (or "dhcp") to have it started before
this particular service. For "ntpdate":

# PROVIDE: ntpdate
# REQUIRE: NETWORKING syslogd
# KEYWORD: nojail

could be changed to

# PROVIDE: ntpdate
# REQUIRE: NETWORKING syslogd dns
# KEYWORD: nojail

-- 
Thomas
Comment 6 Yen-Ming Lee freebsd_committer freebsd_triage 2005-06-06 17:38:54 UTC
Responsible Changed
From-To: leeym->freebsd-ports-bugs

Need to patch /etc/rc which is not in ports. Release to the pool.
Comment 7 Yen-Ming Lee freebsd_committer freebsd_triage 2005-07-16 02:23:12 UTC
State Changed
From-To: feedback->closed

Fixed, thanks.