Commit cdeda28f authored by Simon Kelley's avatar Simon Kelley

import of dnsmasq-2.27.tar.gz

parent aedef830
...@@ -1639,3 +1639,58 @@ version 2.26 ...@@ -1639,3 +1639,58 @@ version 2.26
network. Thanks to Lutz Pressler for the bug report and network. Thanks to Lutz Pressler for the bug report and
patch. patch.
version 2.27
Tweaked DHCP behaviour when a client attempts to renew a lease
which dnsmasq doesn't know about. Previously that would always
result in a DHCPNAK. Now, in dhcp-authoritative mode, the
lease will be created, if it's legal. This makes dnsmasq work
better if the lease database is lost, for example on an OpenWRT
system which reboots. Thanks to Stephen Rose for work on
this.
Added the ability to support RFC-3442 style destination
descriptors in dhcp-options. This makes classless static
routes easy to do, eg dhcp-option=121,192.168.1.0/24,1.2.3.4
Added error-checking to the code which writes the lease
file. If this fails for any reason, an error is logged,
and a retry occurs after one minute. This should improve
things eg when a filesystem is full. Thanks to Jens Holze
for the bug report.
Fixed breakage of the "/#/ matches any domain" facility
which happened in 2.24. Thanks to Peter Surda for the bug
report.
Use "size_t" and "ssize_t" types where appropriate in the
code.
Fix buggy CNAME handling in mixed IPv4 and IPv6
queries. Thanks to Andreas Pelme for help finding that.
Added some code to attempt to re-transmit DNS queries when
a network interface comes up. This helps on DoD links,
where frequently the packet which triggers dialling is
a DNS query, which then gets lost. By re-sending, we can
avoid the lookup failing. This function is only active
when netlink support is compiled in, and therefore only
under Linux. Thanks to Jean Wolter for help with this.
Tweaked the DHCP tag-matching code to work correctly with
NOT-tag conditions. Thanks to Lutz Pressler for finding
the bug.
Generalised netid-tag matching in dhcp-range statements to
allow more than one tag.
Added --dhcp-mac to do MAC address matching in the same
way as vendorclass and userclass matching. A good
suggestion from Lutz Pressler.
Add workaround for buggy early Microsoft DHCP clients
which need zero-termination in string options.
Thanks to Fabiano Pires for help with this.
Generalised the DHCP code to cope with any hardware
address type, at least on Linux. *BSD is still limited to
ethernet only.
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
############################################################################### ###############################################################################
Name: dnsmasq Name: dnsmasq
Version: 2.26 Version: 2.27
Release: 1 Release: 1
License: GPL License: GPL
Group: System Environment/Daemons Group: System Environment/Daemons
...@@ -127,7 +127,7 @@ fi ...@@ -127,7 +127,7 @@ fi
%attr(0755,root,root) /etc/rc.d/init.d/dnsmasq %attr(0755,root,root) /etc/rc.d/init.d/dnsmasq
%attr(0664,root,root) /etc/dnsmasq.conf %attr(0664,root,root) /etc/dnsmasq.conf
%attr(0755,root,root) /usr/sbin/dnsmasq %attr(0755,root,root) /usr/sbin/dnsmasq
%attr(0644,root,root) /usr/share/man/*/man8/dnsmasq* #%attr(0644,root,root) /usr/share/man/*/man8/dnsmasq*
%attr(0644,root,root) /usr/share/man/man8/dnsmasq* %attr(0644,root,root) /usr/share/man/man8/dnsmasq*
%attr(0644,root,root) /usr/share/locale/*/LC_MESSAGES/* %attr(0644,root,root) /usr/share/locale/*/LC_MESSAGES/*
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
############################################################################### ###############################################################################
Name: dnsmasq Name: dnsmasq
Version: 2.26 Version: 2.27
Release: 1 Release: 1
Copyright: GPL Copyright: GPL
Group: Productivity/Networking/DNS/Servers Group: Productivity/Networking/DNS/Servers
......
...@@ -184,6 +184,10 @@ bogus-priv ...@@ -184,6 +184,10 @@ bogus-priv
# of whose DHCP userclass strings includes the substring "accounts" # of whose DHCP userclass strings includes the substring "accounts"
#dhcp-userclass=red,accounts #dhcp-userclass=red,accounts
# Send extra options which are tagged as "red" to any machine whose
# MAC address matches the pattern.
#dhcp-mac=red,00:60:8C:*:*:*
# If this line is uncommented, dnsmasq will read /etc/ethers and act # If this line is uncommented, dnsmasq will read /etc/ethers and act
# on the ethernet-address/IP pairs found there just as if they had # on the ethernet-address/IP pairs found there just as if they had
# been given as --dhcp-host options. Useful if you keep # been given as --dhcp-host options. Useful if you keep
...@@ -204,6 +208,10 @@ bogus-priv ...@@ -204,6 +208,10 @@ bogus-priv
# DNS server - 6 # DNS server - 6
# broadcast address - 28 # broadcast address - 28
# Override the default route supplied by dnsmasq, which assumes the
# router is the same machine as the one running dnsmasq.
#dhcp-option=3,1.2.3.4
# Set the NTP time server addresses to 192.168.0.4 and 10.10.0.5 # Set the NTP time server addresses to 192.168.0.4 and 10.10.0.5
#dhcp-option=42,192.168.0.4,10.10.0.5 #dhcp-option=42,192.168.0.4,10.10.0.5
...@@ -244,6 +252,9 @@ bogus-priv ...@@ -244,6 +252,9 @@ bogus-priv
# probably doesn't support this...... # probably doesn't support this......
#dhcp-option=119,eng.apple.com,marketing.apple.com #dhcp-option=119,eng.apple.com,marketing.apple.com
# Send RFC-3442 classless static routes (note the netmask encoding)
#dhcp-option=121,192.168.1.0/24,1.2.3.4,10.0.0.0/8,5.6.7.8
# Send encapsulated vendor-class specific options. The vendor-class # Send encapsulated vendor-class specific options. The vendor-class
# is sent as DHCP option 60, and all the options marked with the # is sent as DHCP option 60, and all the options marked with the
# vendor class are send encapsulated in DHCP option 43. The meaning of # vendor class are send encapsulated in DHCP option 43. The meaning of
......
...@@ -349,7 +349,7 @@ allowed to have more than one dhcp-range in a single subnet. The optional ...@@ -349,7 +349,7 @@ allowed to have more than one dhcp-range in a single subnet. The optional
network-id is a alphanumeric label which marks this network so that network-id is a alphanumeric label which marks this network so that
dhcp options may be specified on a per-network basis. dhcp options may be specified on a per-network basis.
When it is prefixed with 'net:' then its meaning changes from setting When it is prefixed with 'net:' then its meaning changes from setting
a tag to matching it. a tag to matching it. Only one tag may be set, but more than one tag may be matched.
The end address may be replaced by the keyword The end address may be replaced by the keyword
.B static .B static
which tells dnsmasq to enable DHCP for the network specified, but not which tells dnsmasq to enable DHCP for the network specified, but not
...@@ -368,7 +368,7 @@ which case the IP address and lease times will apply to any machine ...@@ -368,7 +368,7 @@ which case the IP address and lease times will apply to any machine
claiming that name. For example claiming that name. For example
.B --dhcp-host=00:20:e0:3b:13:af,wap,infinite .B --dhcp-host=00:20:e0:3b:13:af,wap,infinite
tells dnsmasq to give tells dnsmasq to give
the machine with ethernet address 00:20:e0:3b:13:af the name wap, and the machine with hardware address 00:20:e0:3b:13:af the name wap, and
an infinite DHCP lease. an infinite DHCP lease.
.B --dhcp-host=lap,192.168.0.199 .B --dhcp-host=lap,192.168.0.199
tells tells
...@@ -401,9 +401,15 @@ for this host. ...@@ -401,9 +401,15 @@ for this host.
Ethernet addresses (but not client-ids) may have Ethernet addresses (but not client-ids) may have
wildcard bytes, so for example wildcard bytes, so for example
.B --dhcp-host=00:20:e0:3b:13:*,ignore .B --dhcp-host=00:20:e0:3b:13:*,ignore
will cause dnsmasq to ignore a range of ethernet addresses. Note that will cause dnsmasq to ignore a range of hardware addresses. Note that
the "*" will need to be escaped or quoted on a command line, but not the "*" will need to be escaped or quoted on a command line, but not
in the configuration file. in the configuration file. Hardware addresses normally match any
network (ARP) type, but it is possible to restrict them to a single
ARP type by preceding them with the ARP-type (in HEX) and "-". so
.B --dhcp-host=06-00:20:e0:3b:13:af,1.2.3.4
will only match a
Token-Ring hardware address, since the ARP-address type for token ring
is 6.
.TP .TP
.B \-Z, --read-ethers .B \-Z, --read-ethers
Read /etc/ethers for information about hosts for the DHCP server. The Read /etc/ethers for information about hosts for the DHCP server. The
...@@ -432,6 +438,11 @@ dotted-quad IP addresses, a decimal number, colon-separated hex digits ...@@ -432,6 +438,11 @@ dotted-quad IP addresses, a decimal number, colon-separated hex digits
and a text string. If the optional network-ids are given then and a text string. If the optional network-ids are given then
this option is only sent when all the network-ids are matched. this option is only sent when all the network-ids are matched.
Special processing is done on a text argument for option 119, to
conform with RFC 3397, and dotted-quad IP addresses which are followed
by a slash and then a netmask size are encoded as described in RFC
3442.
Be careful: no checking is done that the correct type of data for the Be careful: no checking is done that the correct type of data for the
option number is sent, it is quite possible to option number is sent, it is quite possible to
persuade dnsmasq to generate illegal DHCP packets with injudicious use persuade dnsmasq to generate illegal DHCP packets with injudicious use
...@@ -476,7 +487,13 @@ to different classes of hosts. It is possible, for instance to use ...@@ -476,7 +487,13 @@ to different classes of hosts. It is possible, for instance to use
this to set a different printer server for hosts in the class this to set a different printer server for hosts in the class
"accounts" than for hosts in the class "engineering". "accounts" than for hosts in the class "engineering".
.TP .TP
.B \ -J, --dhcp-ignore=<network-id>[,<network-id>] .B \-4, --dhcp-mac=<network-id>,<MAC address>
Map from a MAC address to a network-id. The MAC address may include
wildcards. For example
.B --dhcp-mac=3com,01:34:23:*:*:*
will set the tag "3com" for any host whose MAC address matches the pattern.
.TP
.B \-J, --dhcp-ignore=<network-id>[,<network-id>]
When all the given network-ids match the set of network-ids derived When all the given network-ids match the set of network-ids derived
from the net, host, vendor and user classes, ignore the host and do from the net, host, vendor and user classes, ignore the host and do
not allocate it a DHCP lease. not allocate it a DHCP lease.
...@@ -498,7 +515,9 @@ process. ...@@ -498,7 +515,9 @@ process.
Should be set when dnsmasq is definately the only DHCP server on a network. Should be set when dnsmasq is definately the only DHCP server on a network.
It changes the behaviour from strict RFC compliance so that DHCP requests on It changes the behaviour from strict RFC compliance so that DHCP requests on
unknown leases from unknown hosts are not ignored. This allows new hosts unknown leases from unknown hosts are not ignored. This allows new hosts
to get a lease without a tedious timeout under all circumstances. to get a lease without a tedious timeout under all circumstances. It also
allows dnsmasq to rebuild its lease database without each client needing to
reaquire a lease, if the database is lost.
.TP .TP
.B \-3, --bootp-dynamic .B \-3, --bootp-dynamic
Enable dynamic allocation of IP addresses to BOOTP clients. Use this Enable dynamic allocation of IP addresses to BOOTP clients. Use this
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -194,7 +194,7 @@ static int cache_scan_free(char *name, struct all_addr *addr, time_t now, unsign ...@@ -194,7 +194,7 @@ static int cache_scan_free(char *name, struct all_addr *addr, time_t now, unsign
} }
} }
else if ((crecp->flags & F_FORWARD) && else if ((crecp->flags & F_FORWARD) &&
((flags & crecp->flags & (F_IPV4 | F_IPV6)) || (crecp->flags & F_CNAME)) && ((flags & crecp->flags & (F_IPV4 | F_IPV6)) || ((crecp->flags | flags) & F_CNAME)) &&
hostname_isequal(cache_get_name(crecp), name)) hostname_isequal(cache_get_name(crecp), name))
{ {
if (crecp->flags & (F_HOSTS | F_DHCP)) if (crecp->flags & (F_HOSTS | F_DHCP))
......
...@@ -12,13 +12,14 @@ ...@@ -12,13 +12,14 @@
/* Author's email: simon@thekelleys.org.uk */ /* Author's email: simon@thekelleys.org.uk */
#define VERSION "2.26" #define VERSION "2.27"
#define FTABSIZ 150 /* max number of outstanding requests */ #define FTABSIZ 150 /* max number of outstanding requests */
#define MAX_PROCS 20 /* max no children for TCP requests */ #define MAX_PROCS 20 /* max no children for TCP requests */
#define CHILD_LIFETIME 150 /* secs 'till terminated (RFC1035 suggests > 120s) */ #define CHILD_LIFETIME 150 /* secs 'till terminated (RFC1035 suggests > 120s) */
#define EDNS_PKTSZ 1280 /* default max EDNS.0 UDP packet from RFC2671 */ #define EDNS_PKTSZ 1280 /* default max EDNS.0 UDP packet from RFC2671 */
#define TIMEOUT 20 /* drop UDP queries after TIMEOUT seconds */ #define TIMEOUT 20 /* drop UDP queries after TIMEOUT seconds */
#define LEASE_RETRY 60 /* on error, retry writing leasefile after LEASE_RETRY seconds */
#define LOGRATE 120 /* log table overflows every LOGRATE seconds */ #define LOGRATE 120 /* log table overflows every LOGRATE seconds */
#define CACHESIZ 150 /* default cache size */ #define CACHESIZ 150 /* default cache size */
#define MAXTOK 50 /* token in DHCP leases */ #define MAXTOK 50 /* token in DHCP leases */
......
This diff is collapsed.
/* dnsmasq is Copyright (c) 2000-2005 Simon Kelley /* dnsmasq is Copyright (c) 2000-2006 Simon Kelley
This program is free software; you can redistribute it and/or modify This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
...@@ -176,8 +176,7 @@ int main (int argc, char **argv) ...@@ -176,8 +176,7 @@ int main (int argc, char **argv)
die(_("DBus error: %s"), err); die(_("DBus error: %s"), err);
} }
#else #else
if (daemon->options & OPT_DBUS) die(_("DBus not available: set HAVE_DBUS in src/config.h"), NULL);
die(_("DBus not available: set HAVE_DBUS in src/config.h"), NULL);
#endif #endif
/* If query_port is set then create a socket now, before dumping root /* If query_port is set then create a socket now, before dumping root
...@@ -256,7 +255,7 @@ int main (int argc, char **argv) ...@@ -256,7 +255,7 @@ int main (int argc, char **argv)
#endif #endif
if (daemon->dhcp && if (daemon->dhcp &&
(i == daemon->lease_fd || (i == fileno(daemon->lease_stream) ||
i == daemon->dhcpfd || i == daemon->dhcpfd ||
i == daemon->dhcp_raw_fd || i == daemon->dhcp_raw_fd ||
i == daemon->dhcp_icmp_fd)) i == daemon->dhcp_icmp_fd))
...@@ -314,14 +313,14 @@ int main (int argc, char **argv) ...@@ -314,14 +313,14 @@ int main (int argc, char **argv)
if (if_tmp->name && !if_tmp->used) if (if_tmp->name && !if_tmp->used)
syslog(LOG_WARNING, _("warning: interface %s does not currently exist"), if_tmp->name); syslog(LOG_WARNING, _("warning: interface %s does not currently exist"), if_tmp->name);
#ifdef HAVE_RTNETLINK
/* Must do this after daemonizing so that the pid is right */
netlink_init(daemon);
#endif
if (daemon->dhcp) if (daemon->dhcp)
{ {
struct dhcp_context *dhcp_tmp; struct dhcp_context *dhcp_tmp;
#ifdef HAVE_RTNETLINK
/* Must do this after daemonizing so that the pid is right */
daemon->netlinkfd = netlink_init();
#endif
for (dhcp_tmp = daemon->dhcp; dhcp_tmp; dhcp_tmp = dhcp_tmp->next) for (dhcp_tmp = daemon->dhcp; dhcp_tmp; dhcp_tmp = dhcp_tmp->next)
{ {
...@@ -375,7 +374,7 @@ int main (int argc, char **argv) ...@@ -375,7 +374,7 @@ int main (int argc, char **argv)
{ {
if (daemon->dhcp) if (daemon->dhcp)
{ {
lease_update_file(1, now); lease_update_file(daemon, 1, now);
#ifdef HAVE_BROKEN_RTC #ifdef HAVE_BROKEN_RTC
alarm(daemon->min_leasetime); alarm(daemon->min_leasetime);
#endif #endif
...@@ -400,6 +399,15 @@ int main (int argc, char **argv) ...@@ -400,6 +399,15 @@ int main (int argc, char **argv)
maxfd = daemon->dhcpfd; maxfd = daemon->dhcpfd;
} }
#ifdef HAVE_RTNETLINK
if (daemon->netlinkfd != -1)
{
FD_SET(daemon->netlinkfd, &rset);
if (daemon->netlinkfd > maxfd)
maxfd = daemon->netlinkfd;
}
#endif
/* Whilst polling for the dbus, wake every quarter second */ /* Whilst polling for the dbus, wake every quarter second */
#ifdef HAVE_PSELECT #ifdef HAVE_PSELECT
{ {
...@@ -497,6 +505,11 @@ int main (int argc, char **argv) ...@@ -497,6 +505,11 @@ int main (int argc, char **argv)
} }
} }
} }
#ifdef HAVE_RTNETLINK
if (daemon->netlinkfd != -1 && FD_ISSET(daemon->netlinkfd, &rset))
netlink_multicast(daemon);
#endif
#ifdef HAVE_DBUS #ifdef HAVE_DBUS
/* if we didn't create a DBus connection, retry now. */ /* if we didn't create a DBus connection, retry now. */
...@@ -522,9 +535,9 @@ int main (int argc, char **argv) ...@@ -522,9 +535,9 @@ int main (int argc, char **argv)
if (daemon->dhcp) if (daemon->dhcp)
{ {
#ifdef HAVE_BROKEN_RTC #ifdef HAVE_BROKEN_RTC
lease_update_file(1, now); lease_update_file(daemon, 1, now);
#endif #endif
close(daemon->lease_fd); fclose(daemon->lease_stream);
} }
return 0; return 0;
...@@ -565,7 +578,7 @@ void clear_cache_and_reload(struct daemon *daemon, time_t now) ...@@ -565,7 +578,7 @@ void clear_cache_and_reload(struct daemon *daemon, time_t now)
dhcp_read_ethers(daemon); dhcp_read_ethers(daemon);
dhcp_update_configs(daemon->dhcp_conf); dhcp_update_configs(daemon->dhcp_conf);
lease_update_from_configs(daemon); lease_update_from_configs(daemon);
lease_update_file(0, now); lease_update_file(daemon, 0, now);
lease_update_dns(daemon); lease_update_dns(daemon);
} }
} }
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -503,7 +503,7 @@ void check_servers(struct daemon *daemon) ...@@ -503,7 +503,7 @@ void check_servers(struct daemon *daemon)
/* forward table rules reference servers, so have to blow them away */ /* forward table rules reference servers, so have to blow them away */
forward_init(0); forward_init(0);
daemon->last_server = NULL; daemon->last_server = daemon->srv_save = NULL;
for (new = daemon->servers; new; new = tmp) for (new = daemon->servers; new; new = tmp)
{ {
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment