mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-06 15:51:41 +00:00
Compare commits
102
Commits
v2.69test10
...
v2.72
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25e27235dd | ||
|
|
bf2db4b084 | ||
|
|
5782649ad9 | ||
|
|
288df49c96 | ||
|
|
10cfc0ddb3 | ||
|
|
15b1b7e9c3 | ||
|
|
00c0f69aa5 | ||
|
|
51943369e3 | ||
|
|
2d75f2e4a5 | ||
|
|
976afc93e4 | ||
|
|
7f68f82146 | ||
|
|
85900a246c | ||
|
|
b4f971a081 | ||
|
|
3e1551a1de | ||
|
|
af292dae6d | ||
|
|
933878f2c8 | ||
|
|
d54409dcd3 | ||
|
|
5bf50af2d0 | ||
|
|
c43b8a6326 | ||
|
|
b06900d1a3 | ||
|
|
f2f02fc3fb | ||
|
|
aaeea9f6ed | ||
|
|
2bb6f7735f | ||
|
|
40766e55e8 | ||
|
|
b5ea1cc255 | ||
|
|
6d8e8ac0fa | ||
|
|
24b167ada8 | ||
|
|
993f8cbb1b | ||
|
|
47a9516980 | ||
|
|
dc8a1b1bcf | ||
|
|
cdb755c5f1 | ||
|
|
063efb330a | ||
|
|
70772c9091 | ||
|
|
10d8540f62 | ||
|
|
006c162382 | ||
|
|
6799a46605 | ||
|
|
c4638f9e66 | ||
|
|
4b34f5d22f | ||
|
|
a0358e5ddb | ||
|
|
a03f8d4c37 | ||
|
|
c4a0937683 | ||
|
|
2f4c4b6076 | ||
|
|
a008a843cf | ||
|
|
d92c53e700 | ||
|
|
a754e1d7b2 | ||
|
|
8e9ffba66e | ||
|
|
15a97ad6fb | ||
|
|
91f4a5e4b5 | ||
|
|
0fa7e62947 | ||
|
|
62f992f06c | ||
|
|
a23949d44d | ||
|
|
b692f23466 | ||
|
|
8aa999ef69 | ||
|
|
20b215f293 | ||
|
|
e6096e643a | ||
|
|
8938ae05ac | ||
|
|
9d1b22aac2 | ||
|
|
1fc02680af | ||
|
|
4872aa747b | ||
|
|
7ea3d3fdca | ||
|
|
50f86ce8e4 | ||
|
|
7e22cf28f8 | ||
|
|
3b1b3e9d50 | ||
|
|
ab72091de2 | ||
|
|
66f57867d8 | ||
|
|
6375838445 | ||
|
|
82a14af5e7 | ||
|
|
97dce08ed7 | ||
|
|
198d940af6 | ||
|
|
1d7e0a36e3 | ||
|
|
10068600f8 | ||
|
|
b7639d5815 | ||
|
|
49752b90d5 | ||
|
|
e98bd52e25 | ||
|
|
8a8bbad0cf | ||
|
|
fec216df32 | ||
|
|
4e1fe44428 | ||
|
|
51967f9807 | ||
|
|
b37f8b99ae | ||
|
|
fc2833f172 | ||
|
|
490f90758d | ||
|
|
56618c31f6 | ||
|
|
604f7598c2 | ||
|
|
2a7a2b84ec | ||
|
|
3e21a1a6fa | ||
|
|
2b29191e7c | ||
|
|
03431d6373 | ||
|
|
cc1a29e250 | ||
|
|
e62e9b6187 | ||
|
|
19c51cfa49 | ||
|
|
d5082158ee | ||
|
|
3f7483e816 | ||
|
|
0c8584eabc | ||
|
|
f00690f93e | ||
|
|
89b12ed35b | ||
|
|
1a9a3489ec | ||
|
|
c8a80487cd | ||
|
|
4ea8e80dd9 | ||
|
|
c07d30dcb1 | ||
|
|
d588ab54d4 | ||
|
|
f8b422a7b6 | ||
|
|
29fe922b14 |
No files matched your search
@@ -1,3 +1,74 @@
|
|||||||
|
version 2.72
|
||||||
|
Add ra-advrouter mode, for RFC-3775 mobile IPv6 support.
|
||||||
|
|
||||||
|
Add support for "ipsets" in *BSD, using pf. Thanks to
|
||||||
|
Sven Falempim for the patch.
|
||||||
|
|
||||||
|
Fix race condition which could lock up dnsmasq when an
|
||||||
|
interface goes down and up rapidly. Thanks to Conrad
|
||||||
|
Kostecki for helping to chase this down.
|
||||||
|
|
||||||
|
Add DBus methods SetFilterWin2KOption and SetBogusPrivOption
|
||||||
|
Thanks to the Smoothwall project for the patch.
|
||||||
|
|
||||||
|
Fix failure to build against Nettle-3.0. Thanks to Steven
|
||||||
|
Barth for spotting this and finding the fix.
|
||||||
|
|
||||||
|
When assigning existing DHCP leases to intefaces by comparing
|
||||||
|
networks, handle the case that two or more interfaces have the
|
||||||
|
same network part, but different prefix lengths (favour the
|
||||||
|
longer prefix length.) Thanks to Lung-Pin Chang for the
|
||||||
|
patch.
|
||||||
|
|
||||||
|
Add a mode which detects and removes DNS forwarding loops, ie
|
||||||
|
a query sent to an upstream server returns as a new query to
|
||||||
|
dnsmasq, and would therefore be forwarded again, resulting in
|
||||||
|
a query which loops many times before being dropped. Upstream
|
||||||
|
servers which loop back are disabled and this event is logged.
|
||||||
|
Thanks to Smoothwall for their sponsorship of this feature.
|
||||||
|
|
||||||
|
Extend --conf-dir to allow filtering of files. So
|
||||||
|
--conf-dir=/etc/dnsmasq.d,\*.conf
|
||||||
|
will load all the files in /etc/dnsmasq.d which end in .conf
|
||||||
|
|
||||||
|
Fix bug when resulted in NXDOMAIN answers instead of NODATA in
|
||||||
|
some circumstances.
|
||||||
|
|
||||||
|
Fix bug which caused dnsmasq to become unresponsive if it
|
||||||
|
failed to send packets due to a network interface disappearing.
|
||||||
|
Thanks to Niels Peen for spotting this.
|
||||||
|
|
||||||
|
Fix problem with --local-service option on big-endian platforms
|
||||||
|
Thanks to Richard Genoud for the patch.
|
||||||
|
|
||||||
|
|
||||||
|
version 2.71
|
||||||
|
Subtle change to error handling to help DNSSEC validation
|
||||||
|
when servers fail to provide NODATA answers for
|
||||||
|
non-existent DS records.
|
||||||
|
|
||||||
|
Tweak code which removes DNSSEC records from answers when
|
||||||
|
not required. Fixes broken answers when additional section
|
||||||
|
has real records in it. Thanks to Marco Davids for the bug
|
||||||
|
report.
|
||||||
|
|
||||||
|
Fix DNSSEC validation of ANY queries. Thanks to Marco Davids
|
||||||
|
for spotting that too.
|
||||||
|
|
||||||
|
Fix total DNS failure and 100% CPU use if cachesize set to zero,
|
||||||
|
regression introduced in 2.69. Thanks to James Hunt and
|
||||||
|
the Ubuntu crowd for assistance in fixing this.
|
||||||
|
|
||||||
|
|
||||||
|
version 2.70
|
||||||
|
Fix crash, introduced in 2.69, on TCP request when dnsmasq
|
||||||
|
compiled with DNSSEC support, but running without DNSSEC
|
||||||
|
enabled. Thanks to Manish Sing for spotting that one.
|
||||||
|
|
||||||
|
Fix regression which broke ipset functionality. Thanks to
|
||||||
|
Wang Jian for the bug report.
|
||||||
|
|
||||||
|
|
||||||
version 2.69
|
version 2.69
|
||||||
Implement dynamic interface discovery on *BSD. This allows
|
Implement dynamic interface discovery on *BSD. This allows
|
||||||
the contructor: syntax to be used in dhcp-range for DHCPv6
|
the contructor: syntax to be used in dhcp-range for DHCPv6
|
||||||
@@ -28,9 +99,9 @@ version 2.69
|
|||||||
|
|
||||||
make dnsmasq COPTS='-DHAVE_DNSSEC -DHAVE_DNSSEC_STATIC'
|
make dnsmasq COPTS='-DHAVE_DNSSEC -DHAVE_DNSSEC_STATIC'
|
||||||
|
|
||||||
which bloats the dnsmasq binary to over a megabyte, but
|
which bloats the dnsmasq binary, but saves the size of
|
||||||
saves the size of the shared libraries which are five
|
the shared libraries which are much bigger.
|
||||||
times that size.
|
|
||||||
To enable, DNSSEC, you will need a set of
|
To enable, DNSSEC, you will need a set of
|
||||||
trust-anchors. Now that the TLDs are signed, this can be
|
trust-anchors. Now that the TLDs are signed, this can be
|
||||||
the keys for the root zone, and for convenience they are
|
the keys for the root zone, and for convenience they are
|
||||||
@@ -56,6 +127,36 @@ version 2.69
|
|||||||
downstream validators. Setting --log-queries will show
|
downstream validators. Setting --log-queries will show
|
||||||
DNSSEC in action.
|
DNSSEC in action.
|
||||||
|
|
||||||
|
If a domain is returned from an upstream nameserver without
|
||||||
|
DNSSEC signature, dnsmasq by default trusts this. This
|
||||||
|
means that for unsigned zone (still the majority) there
|
||||||
|
is effectively no cost for having DNSSEC enabled. Of course
|
||||||
|
this allows an attacker to replace a signed record with a
|
||||||
|
false unsigned record. This is addressed by the
|
||||||
|
--dnssec-check-unsigned flag, which instructs dnsmasq
|
||||||
|
to prove that an unsigned record is legitimate, by finding
|
||||||
|
a secure proof that the zone containing the record is not
|
||||||
|
signed. Doing this has costs (typically one or two extra
|
||||||
|
upstream queries). It also has a nasty failure mode if
|
||||||
|
dnsmasq's upstream nameservers are not DNSSEC capable.
|
||||||
|
Without --dnssec-check-unsigned using such an upstream
|
||||||
|
server will simply result in not queries being validated;
|
||||||
|
with --dnssec-check-unsigned enabled and a
|
||||||
|
DNSSEC-ignorant upstream server, _all_ queries will fail.
|
||||||
|
|
||||||
|
Note that DNSSEC requires that the local time is valid and
|
||||||
|
accurate, if not then DNSSEC validation will fail. NTP
|
||||||
|
should be running. This presents a problem for routers
|
||||||
|
without a battery-backed clock. To set the time needs NTP
|
||||||
|
to do DNS lookups, but lookups will fail until NTP has run.
|
||||||
|
To address this, there's a flag, --dnssec-no-timecheck
|
||||||
|
which disables the time checks (only) in DNSSEC. When dnsmasq
|
||||||
|
is started and the clock is not synced, this flag should
|
||||||
|
be used. As soon as the clock is synced, SIGHUP dnsmasq.
|
||||||
|
The SIGHUP clears the cache of partially-validated data and
|
||||||
|
resets the no-timecheck flag, so that all DNSSEC checks
|
||||||
|
henceforward will be complete.
|
||||||
|
|
||||||
The development of DNSSEC in dnsmasq was started by
|
The development of DNSSEC in dnsmasq was started by
|
||||||
Giovanni Bajo, to whom huge thanks are owed. It has been
|
Giovanni Bajo, to whom huge thanks are owed. It has been
|
||||||
supported by Comcast, whose techfund grant has allowed for
|
supported by Comcast, whose techfund grant has allowed for
|
||||||
@@ -67,6 +168,26 @@ version 2.69
|
|||||||
Add --servers-file. Allows dynamic update of upstream servers
|
Add --servers-file. Allows dynamic update of upstream servers
|
||||||
full access to configuration.
|
full access to configuration.
|
||||||
|
|
||||||
|
Add --local-service. Accept DNS queries only from hosts
|
||||||
|
whose address is on a local subnet, ie a subnet for which
|
||||||
|
an interface exists on the server. This option
|
||||||
|
only has effect if there are no --interface --except-interface,
|
||||||
|
--listen-address or --auth-server options. It is intended
|
||||||
|
to be set as a default on installation, to allow
|
||||||
|
unconfigured installations to be useful but also safe from
|
||||||
|
being used for DNS amplification attacks.
|
||||||
|
|
||||||
|
Fix crashes in cache_get_cname_target() when dangling CNAMEs
|
||||||
|
encountered. Thanks to Andy and the rt-n56u project for
|
||||||
|
find this and helping to chase it down.
|
||||||
|
|
||||||
|
Fix wrong RCODE in authoritative DNS replies to PTR queries. The
|
||||||
|
correct answer was included, but the RCODE was set to NXDOMAIN.
|
||||||
|
Thanks to Craig McQueen for spotting this.
|
||||||
|
|
||||||
|
Make statistics available as DNS queries in the .bind TLD as
|
||||||
|
well as logging them.
|
||||||
|
|
||||||
|
|
||||||
version 2.68
|
version 2.68
|
||||||
Use random addresses for DHCPv6 temporary address
|
Use random addresses for DHCPv6 temporary address
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ lua_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_LUASCRIPT $(PKG_CON
|
|||||||
lua_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_LUASCRIPT $(PKG_CONFIG) --libs lua5.1`
|
lua_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_LUASCRIPT $(PKG_CONFIG) --libs lua5.1`
|
||||||
nettle_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC $(PKG_CONFIG) --cflags nettle hogweed`
|
nettle_cflags = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC $(PKG_CONFIG) --cflags nettle hogweed`
|
||||||
nettle_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC $(PKG_CONFIG) --libs nettle hogweed`
|
nettle_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC $(PKG_CONFIG) --libs nettle hogweed`
|
||||||
gmp_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC $(PKG_CONFIG) --copy -lgmp`
|
gmp_libs = `echo $(COPTS) | $(top)/bld/pkg-wrapper HAVE_DNSSEC NO_GMP --copy -lgmp`
|
||||||
sunos_libs = `if uname | grep SunOS >/dev/null 2>&1; then echo -lsocket -lnsl -lposix4; fi`
|
sunos_libs = `if uname | grep SunOS >/dev/null 2>&1; then echo -lsocket -lnsl -lposix4; fi`
|
||||||
version = -DVERSION='\"`$(top)/bld/get-version $(top)`\"'
|
version = -DVERSION='\"`$(top)/bld/get-version $(top)`\"'
|
||||||
|
|
||||||
@@ -69,7 +69,7 @@ objs = cache.o rfc1035.o util.o option.o forward.o network.o \
|
|||||||
dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o \
|
dnsmasq.o dhcp.o lease.o rfc2131.o netlink.o dbus.o bpf.o \
|
||||||
helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o \
|
helper.o tftp.o log.o conntrack.o dhcp6.o rfc3315.o \
|
||||||
dhcp-common.o outpacket.o radv.o slaac.o auth.o ipset.o \
|
dhcp-common.o outpacket.o radv.o slaac.o auth.o ipset.o \
|
||||||
domain.o dnssec.o blockdata.o
|
domain.o dnssec.o blockdata.o tables.o loop.o
|
||||||
|
|
||||||
hdrs = dnsmasq.h config.h dhcp-protocol.h dhcp6-protocol.h \
|
hdrs = dnsmasq.h config.h dhcp-protocol.h dhcp6-protocol.h \
|
||||||
dns-protocol.h radv-protocol.h ip6addr.h
|
dns-protocol.h radv-protocol.h ip6addr.h
|
||||||
|
|||||||
+2
-1
@@ -9,7 +9,8 @@ LOCAL_SRC_FILES := bpf.c cache.c dbus.c dhcp.c dnsmasq.c \
|
|||||||
rfc2131.c tftp.c util.c conntrack.c \
|
rfc2131.c tftp.c util.c conntrack.c \
|
||||||
dhcp6.c rfc3315.c dhcp-common.c outpacket.c \
|
dhcp6.c rfc3315.c dhcp-common.c outpacket.c \
|
||||||
radv.c slaac.c auth.c ipset.c domain.c \
|
radv.c slaac.c auth.c ipset.c domain.c \
|
||||||
dnssec.c dnssec-openssl.c blockdata.c
|
dnssec.c dnssec-openssl.c blockdata.c tables.c \
|
||||||
|
loop.c
|
||||||
|
|
||||||
LOCAL_MODULE := dnsmasq
|
LOCAL_MODULE := dnsmasq
|
||||||
|
|
||||||
|
|||||||
+10
-2
@@ -11,9 +11,17 @@ in=`cat`
|
|||||||
|
|
||||||
if grep "^\#[[:space:]]*define[[:space:]]*$search" config.h >/dev/null 2>&1 || \
|
if grep "^\#[[:space:]]*define[[:space:]]*$search" config.h >/dev/null 2>&1 || \
|
||||||
echo $in | grep $search >/dev/null 2>&1; then
|
echo $in | grep $search >/dev/null 2>&1; then
|
||||||
|
# Nasty, nasty, in --copy, arg 2 is another config to search for, use with NO_GMP
|
||||||
if [ $op = "--copy" ]; then
|
if [ $op = "--copy" ]; then
|
||||||
pkg="$*"
|
if grep "^\#[[:space:]]*define[[:space:]]*$pkg" config.h >/dev/null 2>&1 || \
|
||||||
|
echo $in | grep $pkg >/dev/null 2>&1; then
|
||||||
|
pkg=""
|
||||||
|
else
|
||||||
|
pkg="$*"
|
||||||
|
fi
|
||||||
|
elif grep "^\#[[:space:]]*define[[:space:]]*${search}_STATIC" config.h >/dev/null 2>&1 || \
|
||||||
|
echo $in | grep ${search}_STATIC >/dev/null 2>&1; then
|
||||||
|
pkg=`$pkg --static $op $*`
|
||||||
else
|
else
|
||||||
pkg=`$pkg $op $*`
|
pkg=`$pkg $op $*`
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=A lightweight DHCP and caching DNS server
|
Description=dnsmasq - A lightweight DHCP and caching DNS server
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=dbus
|
Type=dbus
|
||||||
|
|||||||
@@ -40,6 +40,14 @@ ClearCache
|
|||||||
Returns nothing. Clears the domain name cache and re-reads
|
Returns nothing. Clears the domain name cache and re-reads
|
||||||
/etc/hosts. The same as sending dnsmasq a HUP signal.
|
/etc/hosts. The same as sending dnsmasq a HUP signal.
|
||||||
|
|
||||||
|
SetFilterWin2KOption
|
||||||
|
--------------------
|
||||||
|
Takes boolean, sets or resets the --filterwin2k option.
|
||||||
|
|
||||||
|
SetBogusPrivOption
|
||||||
|
------------------
|
||||||
|
Takes boolean, sets or resets the --bogus-priv option.
|
||||||
|
|
||||||
SetServers
|
SetServers
|
||||||
----------
|
----------
|
||||||
Returns nothing. Takes a set of arguments representing the new
|
Returns nothing. Takes a set of arguments representing the new
|
||||||
@@ -152,6 +160,15 @@ for SetServersEx is represented as
|
|||||||
"/eng.mycorp.com/lab.mycorp.com/1003:1234:abcd::1%eth0"
|
"/eng.mycorp.com/lab.mycorp.com/1003:1234:abcd::1%eth0"
|
||||||
]
|
]
|
||||||
|
|
||||||
|
GetLoopServers
|
||||||
|
--------------
|
||||||
|
|
||||||
|
(Only available if dnsmasq compiled with HAVE_LOOP)
|
||||||
|
|
||||||
|
Return an array of strings, each string is the IP address of an upstream
|
||||||
|
server which has been found to loop queries back to this dnsmasq instance, and
|
||||||
|
it therefore not being used.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
2. SIGNALS
|
2. SIGNALS
|
||||||
|
|||||||
Vendored
+51
@@ -1,6 +1,57 @@
|
|||||||
|
dnsmasq (2.72-1) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream.
|
||||||
|
* If dns-root-data package is installed, use it to set the DNSSEC
|
||||||
|
trust anchor(s). Recommend dns-root-data. (closes: #760460)
|
||||||
|
* Handle AD bit correctly in replies from cache. (closes: #761654)
|
||||||
|
|
||||||
|
-- Simon Kelley <simon@thekelleys.org.uk> Tue, 20 May 2014 21:01:11 +0000
|
||||||
|
|
||||||
|
dnsmasq (2.71-1) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream.
|
||||||
|
* Fix 100% CPU-usage bug when dnsmasq started with cachesize
|
||||||
|
set to zero. (LP: #1314697)
|
||||||
|
|
||||||
|
-- Simon Kelley <simon@thekelleys.org.uk> Fri, 16 May 2014 20:17:10 +0000
|
||||||
|
|
||||||
|
dnsmasq (2.70-3) unstable; urgency=medium
|
||||||
|
|
||||||
|
* Write a pid-file, even when being started using systemd, since
|
||||||
|
other components may wish to signal dnsmasq.
|
||||||
|
* Enable dnsmasq systemd unit on install. Otherwise dnsmasq does not run on
|
||||||
|
fresh installations (without administrator handholding) and even worse it
|
||||||
|
is disabled on systems switching from sysv to systemd. Modify
|
||||||
|
postinst/postrm exactly as dh_systemd would, add dependency on
|
||||||
|
init-system-helpers. Closes: #724602
|
||||||
|
|
||||||
|
-- Simon Kelley <simon@thekelleys.org.uk> Sun, 11 May 2014 17:45:21 +0000
|
||||||
|
|
||||||
|
dnsmasq (2.70-2) unstable; urgency=low
|
||||||
|
|
||||||
|
* Ensure daemon not stared if dnsmasq package has been removed,
|
||||||
|
even if dnsmasq-base is still installed. (closes: #746941)
|
||||||
|
* Tidy cruft in initscript. (closes: #746940)
|
||||||
|
|
||||||
|
-- Simon Kelley <simon@thekelleys.org.uk> Sun, 04 May 2014 21:34:11 +0000
|
||||||
|
|
||||||
|
dnsmasq (2.70-1) unstable; urgency=low
|
||||||
|
|
||||||
|
* New upstream.
|
||||||
|
|
||||||
|
-- Simon Kelley <simon@thekelleys.org.uk> Wed, 23 Apr 2014 15:14:42 +0000
|
||||||
|
|
||||||
dnsmasq (2.69-1) unstable; urgency=low
|
dnsmasq (2.69-1) unstable; urgency=low
|
||||||
|
|
||||||
* New upstream.
|
* New upstream.
|
||||||
|
* Set --local-service. (closes: #732610)
|
||||||
|
This tells dnsmasq to ignore DNS requests that don't come
|
||||||
|
from a local network. It's automatically ignored if
|
||||||
|
--interface --except-interface, --listen-address or
|
||||||
|
--auth-server exist in the configuration, so for most
|
||||||
|
installations, it will have no effect, but for
|
||||||
|
otherwise-unconfigured installations, it stops dnsmasq
|
||||||
|
from being vulnerable to DNS-reflection attacks.
|
||||||
|
|
||||||
-- Simon Kelley <simon@thekelleys.org.uk> Tue, 4 Feb 2014 16:28:12 +0000
|
-- Simon Kelley <simon@thekelleys.org.uk> Tue, 4 Feb 2014 16:28:12 +0000
|
||||||
|
|
||||||
|
|||||||
Vendored
+6
-3
@@ -2,13 +2,15 @@ Source: dnsmasq
|
|||||||
Section: net
|
Section: net
|
||||||
Priority: optional
|
Priority: optional
|
||||||
Build-depends: gettext, libnetfilter-conntrack-dev [linux-any],
|
Build-depends: gettext, libnetfilter-conntrack-dev [linux-any],
|
||||||
libidn11-dev, libdbus-1-dev (>=0.61), libgmp-dev, nettle-dev (>=2.4-3)
|
libidn11-dev, libdbus-1-dev (>=0.61), libgmp-dev,
|
||||||
|
nettle-dev (>=2.4-3)
|
||||||
Maintainer: Simon Kelley <simon@thekelleys.org.uk>
|
Maintainer: Simon Kelley <simon@thekelleys.org.uk>
|
||||||
Standards-Version: 3.9.3
|
Standards-Version: 3.9.5
|
||||||
|
|
||||||
Package: dnsmasq
|
Package: dnsmasq
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Depends: netbase, dnsmasq-base(>= ${binary:Version})
|
Depends: netbase, dnsmasq-base(>= ${binary:Version}),
|
||||||
|
init-system-helpers (>= 1.18~)
|
||||||
Suggests: resolvconf
|
Suggests: resolvconf
|
||||||
Conflicts: resolvconf (<<1.15)
|
Conflicts: resolvconf (<<1.15)
|
||||||
Description: Small caching DNS proxy and DHCP/TFTP server
|
Description: Small caching DNS proxy and DHCP/TFTP server
|
||||||
@@ -26,6 +28,7 @@ Architecture: any
|
|||||||
Depends: adduser, ${shlibs:Depends}
|
Depends: adduser, ${shlibs:Depends}
|
||||||
Breaks: dnsmasq (<< 2.63-1~)
|
Breaks: dnsmasq (<< 2.63-1~)
|
||||||
Replaces: dnsmasq (<< 2.63-1~)
|
Replaces: dnsmasq (<< 2.63-1~)
|
||||||
|
Recommends: dns-root-data
|
||||||
Description: Small caching DNS proxy and DHCP/TFTP server
|
Description: Small caching DNS proxy and DHCP/TFTP server
|
||||||
This package contains the dnsmasq executable and documentation, but
|
This package contains the dnsmasq executable and documentation, but
|
||||||
not the infrastructure required to run it as a system daemon. For
|
not the infrastructure required to run it as a system daemon. For
|
||||||
|
|||||||
Vendored
+1
-1
@@ -27,7 +27,7 @@ CONFIG_DIR=/etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new
|
|||||||
# If the resolvconf package is installed, dnsmasq will use its output
|
# If the resolvconf package is installed, dnsmasq will use its output
|
||||||
# rather than the contents of /etc/resolv.conf to find upstream
|
# rather than the contents of /etc/resolv.conf to find upstream
|
||||||
# nameservers. Uncommenting this line inhibits this behaviour.
|
# nameservers. Uncommenting this line inhibits this behaviour.
|
||||||
# Not that including a "resolv-file=<filename>" line in
|
# Note that including a "resolv-file=<filename>" line in
|
||||||
# /etc/dnsmasq.conf is not enough to override resolvconf if it is
|
# /etc/dnsmasq.conf is not enough to override resolvconf if it is
|
||||||
# installed: the line below must be uncommented.
|
# installed: the line below must be uncommented.
|
||||||
#IGNORE_RESOLVCONF=yes
|
#IGNORE_RESOLVCONF=yes
|
||||||
Vendored
+32
-5
@@ -29,6 +29,12 @@ if [ -r /etc/default/locale ]; then
|
|||||||
export LANG
|
export LANG
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# /etc/dnsmasq.d/README is a non-conffile installed by the dnsmasq package.
|
||||||
|
# Should the dnsmasq package be removed, the following test ensures that
|
||||||
|
# the daemon is no longer started, even if the dnsmasq-base package is
|
||||||
|
# still in place.
|
||||||
|
test -e /etc/dnsmasq.d/README || exit 0
|
||||||
|
|
||||||
test -x $DAEMON || exit 0
|
test -x $DAEMON || exit 0
|
||||||
|
|
||||||
# Provide skeleton LSB log functions for backports which don't have LSB functions.
|
# Provide skeleton LSB log functions for backports which don't have LSB functions.
|
||||||
@@ -90,6 +96,24 @@ if [ ! "$DNSMASQ_USER" ]; then
|
|||||||
DNSMASQ_USER="dnsmasq"
|
DNSMASQ_USER="dnsmasq"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# This tells dnsmasq to ignore DNS requests that don't come from a local network.
|
||||||
|
# It's automatically ignored if --interface --except-interface, --listen-address
|
||||||
|
# or --auth-server exist in the configuration, so for most installations, it will
|
||||||
|
# have no effect, but for otherwise-unconfigured installations, it stops dnsmasq
|
||||||
|
# from being vulnerable to DNS-reflection attacks.
|
||||||
|
|
||||||
|
DNSMASQ_OPTS="$DNSMASQ_OPTS --local-service"
|
||||||
|
|
||||||
|
# If the dns-root-data package is installed, then the trust anchors will be
|
||||||
|
# available in $ROOT_DS, in BIND zone-file format. Reformat as dnsmasq
|
||||||
|
# --trust-anchor options.
|
||||||
|
|
||||||
|
ROOT_DS="/usr/share/dns/root.ds"
|
||||||
|
|
||||||
|
if [ -f $ROOT_DS ]; then
|
||||||
|
DNSMASQ_OPTS="$DNSMASQ_OPTS `sed -e s/". IN DS "/--trust-anchor=.,/ -e s/" "/,/g $ROOT_DS | tr '\n' ' '`"
|
||||||
|
fi
|
||||||
|
|
||||||
start()
|
start()
|
||||||
{
|
{
|
||||||
# Return
|
# Return
|
||||||
@@ -144,9 +168,6 @@ stop()
|
|||||||
# 2 if daemon could not be stopped
|
# 2 if daemon could not be stopped
|
||||||
# other if a failure occurred
|
# other if a failure occurred
|
||||||
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile /var/run/dnsmasq/$NAME.pid --name $NAME
|
start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile /var/run/dnsmasq/$NAME.pid --name $NAME
|
||||||
RETVAL="$?"
|
|
||||||
[ "$RETVAL" = 2 ] && return 2
|
|
||||||
return "$RETVAL"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_resolvconf()
|
stop_resolvconf()
|
||||||
@@ -266,9 +287,15 @@ case "$1" in
|
|||||||
stop_resolvconf
|
stop_resolvconf
|
||||||
;;
|
;;
|
||||||
systemd-exec)
|
systemd-exec)
|
||||||
# --pid-file without argument disables writing a PIDfile, we don't need one with sytemd.
|
# /var/run may be volatile, so we need to ensure that
|
||||||
|
# /var/run/dnsmasq exists here as well as in postinst
|
||||||
|
if [ ! -d /var/run/dnsmasq ]; then
|
||||||
|
mkdir /var/run/dnsmasq || return 2
|
||||||
|
chown dnsmasq:nogroup /var/run/dnsmasq || return 2
|
||||||
|
fi
|
||||||
# Enable DBus by default because we use DBus activation with systemd.
|
# Enable DBus by default because we use DBus activation with systemd.
|
||||||
exec $DAEMON --keep-in-foreground --pid-file --enable-dbus \
|
exec $DAEMON --keep-in-foreground --enable-dbus \
|
||||||
|
-x /var/run/dnsmasq/$NAME.pid \
|
||||||
${MAILHOSTNAME:+ -m $MAILHOSTNAME} \
|
${MAILHOSTNAME:+ -m $MAILHOSTNAME} \
|
||||||
${MAILTARGET:+ -t $MAILTARGET} \
|
${MAILTARGET:+ -t $MAILTARGET} \
|
||||||
${DNSMASQ_USER:+ -u $DNSMASQ_USER} \
|
${DNSMASQ_USER:+ -u $DNSMASQ_USER} \
|
||||||
|
|||||||
Vendored
+16
@@ -1,6 +1,22 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
# Code copied from dh_systemd_enable ----------------------
|
||||||
|
# This will only remove masks created by d-s-h on package removal.
|
||||||
|
deb-systemd-helper unmask dnsmasq.service >/dev/null || true
|
||||||
|
|
||||||
|
# was-enabled defaults to true, so new installations run enable.
|
||||||
|
if deb-systemd-helper --quiet was-enabled dnsmasq.service; then
|
||||||
|
# Enables the unit on first installation, creates new
|
||||||
|
# symlinks on upgrades if the unit file has changed.
|
||||||
|
deb-systemd-helper enable dnsmasq.service >/dev/null || true
|
||||||
|
else
|
||||||
|
# Update the statefile to add new symlinks (if any), which need to be
|
||||||
|
# cleaned up on purge. Also remove old symlinks.
|
||||||
|
deb-systemd-helper update-state dnsmasq.service >/dev/null || true
|
||||||
|
fi
|
||||||
|
# End code copied from dh_systemd_enable ------------------
|
||||||
|
|
||||||
if [ -x /etc/init.d/dnsmasq ]; then
|
if [ -x /etc/init.d/dnsmasq ]; then
|
||||||
update-rc.d dnsmasq defaults 15 85 >/dev/null
|
update-rc.d dnsmasq defaults 15 85 >/dev/null
|
||||||
|
|
||||||
|
|||||||
Vendored
+16
@@ -4,3 +4,19 @@ set -e
|
|||||||
if [ purge = "$1" ]; then
|
if [ purge = "$1" ]; then
|
||||||
update-rc.d dnsmasq remove >/dev/null
|
update-rc.d dnsmasq remove >/dev/null
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Code copied from dh_systemd_enable ----------------------
|
||||||
|
if [ "$1" = "remove" ]; then
|
||||||
|
if [ -x "/usr/bin/deb-systemd-helper" ]; then
|
||||||
|
deb-systemd-helper mask dnsmasq.service >/dev/null
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" = "purge" ]; then
|
||||||
|
if [ -x "/usr/bin/deb-systemd-helper" ]; then
|
||||||
|
deb-systemd-helper purge dnsmasq.service >/dev/null
|
||||||
|
deb-systemd-helper unmask dnsmasq.service >/dev/null
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
# End code copied from dh_systemd_enable ------------------
|
||||||
|
|
||||||
Vendored
+8
-8
@@ -11,18 +11,16 @@
|
|||||||
|
|
||||||
package=dnsmasq-base
|
package=dnsmasq-base
|
||||||
|
|
||||||
CFLAGS = $(shell export DEB_BUILD_OPTIONS=$(DEB_BUILD_OPTIONS); dpkg-buildflags --get CFLAGS)
|
dpkg_buildflags := DEB_BUILD_MAINT_OPTIONS="hardening=+all" dpkg-buildflags
|
||||||
CFLAGS += $(shell dpkg-buildflags --get CPPFLAGS)
|
|
||||||
|
CFLAGS = $(shell $(dpkg_buildflags) --get CFLAGS)
|
||||||
|
CFLAGS += $(shell $(dpkg_buildflags) --get CPPFLAGS)
|
||||||
CFLAGS += -Wall -W
|
CFLAGS += -Wall -W
|
||||||
|
|
||||||
LDFLAGS = $(shell dpkg-buildflags --get LDFLAGS)
|
LDFLAGS = $(shell $(dpkg_buildflags) --get LDFLAGS)
|
||||||
|
|
||||||
DEB_COPTS = $(COPTS)
|
DEB_COPTS = $(COPTS)
|
||||||
|
|
||||||
# The nettle library in Debian is too old to include
|
|
||||||
# ECC support.
|
|
||||||
DEB_COPTS += -DNO_NETTLE_ECC
|
|
||||||
|
|
||||||
TARGET = install-i18n
|
TARGET = install-i18n
|
||||||
|
|
||||||
DEB_BUILD_ARCH_OS := $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)
|
DEB_BUILD_ARCH_OS := $(shell dpkg-architecture -qDEB_BUILD_ARCH_OS)
|
||||||
@@ -134,7 +132,9 @@ binary-arch: checkroot
|
|||||||
-d debian/base/var/lib/misc
|
-d debian/base/var/lib/misc
|
||||||
make $(TARGET) PREFIX=/usr DESTDIR=`pwd`/debian/base CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(DEB_COPTS)" CC=gcc
|
make $(TARGET) PREFIX=/usr DESTDIR=`pwd`/debian/base CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" COPTS="$(DEB_COPTS)" CC=gcc
|
||||||
ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
|
ifeq (,$(findstring nodocs,$(DEB_BUILD_OPTIONS)))
|
||||||
install -m 644 doc.html debian/base/usr/share/doc/$(package)/.
|
# Need to remove paypal links in Debian Package for policy reasons.
|
||||||
|
sed -e /\<H2\>Donations/Q -e /icon.png/d doc.html -e /favicon.ico/d >debian/base/usr/share/doc/$(package)/doc.html
|
||||||
|
echo "</BODY>" >>debian/base/usr/share/doc/$(package)/doc.html
|
||||||
install -m 644 setup.html debian/base/usr/share/doc/$(package)/.
|
install -m 644 setup.html debian/base/usr/share/doc/$(package)/.
|
||||||
install -m 644 dnsmasq.conf.example debian/base/usr/share/doc/$(package)/examples/.
|
install -m 644 dnsmasq.conf.example debian/base/usr/share/doc/$(package)/examples/.
|
||||||
install -m 644 trust-anchors.conf debian/base/usr/share/$(package)/.
|
install -m 644 trust-anchors.conf debian/base/usr/share/$(package)/.
|
||||||
|
|||||||
Vendored
+3
-4
@@ -1,5 +1,5 @@
|
|||||||
[Unit]
|
[Unit]
|
||||||
Description=A lightweight DHCP and caching DNS server
|
Description=dnsmasq - A lightweight DHCP and caching DNS server
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=dbus
|
Type=dbus
|
||||||
@@ -13,9 +13,8 @@ ExecStartPre=/usr/sbin/dnsmasq --test
|
|||||||
# itself, when called with the "systemd-exec" function.
|
# itself, when called with the "systemd-exec" function.
|
||||||
#
|
#
|
||||||
# It also adds the command-line flags
|
# It also adds the command-line flags
|
||||||
# --keep-in-foreground --pid-file --enable-dbus
|
# --keep-in-foreground --enable-dbus
|
||||||
# to disable writing a pid-file (not needed with systemd) and
|
# to enable DBus by default because we use DBus activation.
|
||||||
# enable DBus by default because we use DBus activation.
|
|
||||||
#
|
#
|
||||||
ExecStart=/etc/init.d/dnsmasq systemd-exec
|
ExecStart=/etc/init.d/dnsmasq systemd-exec
|
||||||
|
|
||||||
|
|||||||
@@ -25,6 +25,14 @@
|
|||||||
#conf-file=%%PREFIX%%/share/dnsmasq/trust-anchors.conf
|
#conf-file=%%PREFIX%%/share/dnsmasq/trust-anchors.conf
|
||||||
#dnssec
|
#dnssec
|
||||||
|
|
||||||
|
# Replies which are not DNSSEC signed may be legitimate, because the domain
|
||||||
|
# is unsigned, or may be forgeries. Setting this option tells dnsmasq to
|
||||||
|
# check that an unsigned reply is OK, by finding a secure proof that a DS
|
||||||
|
# record somewhere between the root and the domain does not exist.
|
||||||
|
# The cost of setting this is that even queries in unsigned domains will need
|
||||||
|
# one or more extra DNS queries to verify.
|
||||||
|
#dnssec-check-unsigned
|
||||||
|
|
||||||
# Uncomment this to filter useless windows-originated DNS requests
|
# Uncomment this to filter useless windows-originated DNS requests
|
||||||
# which can trigger dial-on-demand links needlessly.
|
# which can trigger dial-on-demand links needlessly.
|
||||||
# Note that (amongst other things) this blocks all SRV requests,
|
# Note that (amongst other things) this blocks all SRV requests,
|
||||||
@@ -632,3 +640,9 @@
|
|||||||
# Include another lot of configuration options.
|
# Include another lot of configuration options.
|
||||||
#conf-file=/etc/dnsmasq.more.conf
|
#conf-file=/etc/dnsmasq.more.conf
|
||||||
#conf-dir=/etc/dnsmasq.d
|
#conf-dir=/etc/dnsmasq.d
|
||||||
|
|
||||||
|
# Include all the files in a directory except those ending in .bak
|
||||||
|
#conf-dir=/etc/dnsmasq.d,.bak
|
||||||
|
|
||||||
|
# Include all files in a directory which end in .conf
|
||||||
|
#conf-dir=/etc/dnsmasq.d/*.conf
|
||||||
@@ -1,8 +1,7 @@
|
|||||||
<HTML>
|
<HTML>
|
||||||
<HEAD>
|
<HEAD>
|
||||||
<TITLE> Dnsmasq - a DNS forwarder for NAT firewalls.</TITLE>
|
<TITLE> Dnsmasq - network services for small networks.</TITLE>
|
||||||
<link rel="icon"
|
<link rel="icon" href="http://www.thekelleys.org.uk/dnsmasq/images/favicon.ico">
|
||||||
href="http://www.thekelleys.org.uk/dnsmasq/images/favicon.ico">
|
|
||||||
</HEAD>
|
</HEAD>
|
||||||
<BODY BGCOLOR="WHITE">
|
<BODY BGCOLOR="WHITE">
|
||||||
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
<table width="100%" border="0" cellpadding="0" cellspacing="0">
|
||||||
@@ -11,82 +10,48 @@
|
|||||||
<td align="middle" valign="middle"><h1>Dnsmasq</h1></td>
|
<td align="middle" valign="middle"><h1>Dnsmasq</h1></td>
|
||||||
<td align="right" valign="middle"><img border="0" src="http://www.thekelleys.org.uk/dnsmasq/images/icon.png" /></td></tr>
|
<td align="right" valign="middle"><img border="0" src="http://www.thekelleys.org.uk/dnsmasq/images/icon.png" /></td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
Dnsmasq provides network infrastructure for small networks: DNS, DHCP, router advertisement and network boot. It is designed to be
|
||||||
|
lightweight and have a small footprint, suitable for resource constrained routers and firewalls. It has also been widely used
|
||||||
|
for tethering on smartphones and portable hotspots, and to support virtual networking in virtualisation frameworks.
|
||||||
|
Supported platforms include Linux (with glibc and uclibc), Android, *BSD, and Mac OS X. Dnsmasq is included in most
|
||||||
|
Linux distributions and the ports systems of FreeBSD, OpenBSD and NetBSD. Dnsmasq provides full IPv6 support.
|
||||||
|
|
||||||
Dnsmasq is a lightweight, easy to configure DNS forwarder and DHCP
|
|
||||||
server. It is designed to provide DNS and, optionally, DHCP, to a
|
|
||||||
small network. It can serve the names of local machines which are
|
|
||||||
not in the global DNS. The DHCP server integrates with the DNS
|
|
||||||
server and allows machines with DHCP-allocated addresses
|
|
||||||
to appear in the DNS with names configured either in each host or
|
|
||||||
in a central configuration file. Dnsmasq supports static and dynamic
|
|
||||||
DHCP leases and BOOTP/TFTP/PXE for network booting of diskless machines.
|
|
||||||
<P>
|
<P>
|
||||||
Dnsmasq is targeted at home networks using NAT and
|
The DNS subsystem provides a local DNS server for the network, with forwarding of all query types to upstream recursive DNS servers and
|
||||||
connected to the internet via a modem, cable-modem or ADSL
|
cacheing of common record types (A, AAAA, CNAME and PTR, also DNSKEY and DS when DNSSEC is enabled).
|
||||||
connection but would be a good choice for any smallish network (up to
|
|
||||||
1000 clients is known to work) where low
|
|
||||||
resource use and ease of configuration are important.
|
|
||||||
<P>
|
|
||||||
Supported platforms include Linux (with glibc and uclibc), Android, *BSD,
|
|
||||||
Solaris and Mac OS X.
|
|
||||||
Dnsmasq is included in at least the following Linux distributions:
|
|
||||||
Gentoo, Debian, Slackware, Suse, Fedora,
|
|
||||||
Smoothwall, IP-Cop, floppyfw, Firebox, LEAF, Freesco, fli4l,
|
|
||||||
CoyoteLinux, Endian Firewall and
|
|
||||||
Clarkconnect. It is also available as FreeBSD, OpenBSD and NetBSD ports and is used in
|
|
||||||
Linksys wireless routers (dd-wrt, openwrt and the stock firmware) and the m0n0wall project.
|
|
||||||
<P>
|
|
||||||
Dnsmasq provides the following features:
|
|
||||||
<DIR>
|
<DIR>
|
||||||
|
<LI>Local DNS names can be defined by reading /etc/hosts, by importing names from the DHCP subsystem, or by configuration of a wide range of useful record types.</LI>
|
||||||
<LI>
|
<LI>Upstream servers can be configured in a variety of convenient ways, including dynamic configuration as these change on moving upstream network.
|
||||||
The DNS configuration of machines behind the firewall is simple and
|
<LI>Authoritative DNS mode allows local DNS names may be exported to zone in the global DNS. Dnsmasq acts as authoritative server for this zone, and also provides
|
||||||
doesn't depend on the details of the ISP's dns servers
|
zone transfer to secondaries for the zone, if required.</LI>
|
||||||
<LI>
|
<LI>DNSSEC validation may be performed on DNS replies from upstream nameservers, providing security against spoofing and cache poisoning.</LI>
|
||||||
Clients which try to do DNS lookups while a modem link to the
|
<LI>Specified sub-domains can be directed to their own upstream DNS servers, making VPN configuration easy.</LI>
|
||||||
internet is down will time out immediately.
|
<LI>Internationalised domain names are supported.
|
||||||
</LI>
|
|
||||||
<LI>
|
|
||||||
Dnsmasq will serve names from the /etc/hosts file on the firewall
|
|
||||||
machine: If the names of local machines are there, then they can all
|
|
||||||
be addressed without having to maintain /etc/hosts on each machine.
|
|
||||||
</LI>
|
|
||||||
<LI>
|
|
||||||
The integrated DHCP server supports static and dynamic DHCP leases and
|
|
||||||
multiple networks and IP ranges. It works across BOOTP relays and
|
|
||||||
supports DHCP options including RFC3397 DNS search lists.
|
|
||||||
Machines which are configured by DHCP have their names automatically
|
|
||||||
included in the DNS and the names can specified by each machine or
|
|
||||||
centrally by associating a name with a MAC address in the dnsmasq
|
|
||||||
config file.
|
|
||||||
</LI>
|
|
||||||
<LI>
|
|
||||||
Dnsmasq caches internet addresses (A records and AAAA records) and address-to-name
|
|
||||||
mappings (PTR records), reducing the load on upstream servers and
|
|
||||||
improving performance (especially on modem connections).
|
|
||||||
</LI>
|
|
||||||
<LI>
|
|
||||||
Dnsmasq can be configured to automatically pick up the addresses of
|
|
||||||
its upstream nameservers from ppp or dhcp configuration. It will
|
|
||||||
automatically reload this information if it changes. This facility
|
|
||||||
will be of particular interest to maintainers of Linux firewall
|
|
||||||
distributions since it allows dns configuration to be made automatic.
|
|
||||||
</LI>
|
|
||||||
<LI>
|
|
||||||
On IPv6-enabled boxes, dnsmasq can both talk to upstream servers via IPv6
|
|
||||||
and offer DNS service via IPv6. On dual-stack (IPv4 and IPv6) boxes it talks
|
|
||||||
both protocols and can even act as IPv6-to-IPv4 or IPv4-to-IPv6 forwarder.
|
|
||||||
</LI>
|
|
||||||
<LI>
|
|
||||||
Dnsmasq can be configured to send queries for certain domains to
|
|
||||||
upstream servers handling only those domains. This makes integration
|
|
||||||
with private DNS systems easy.
|
|
||||||
</LI>
|
|
||||||
<LI>
|
|
||||||
Dnsmasq supports MX and SRV records and can be configured to return MX records
|
|
||||||
for any or all local machines.
|
|
||||||
</LI>
|
|
||||||
</DIR>
|
</DIR>
|
||||||
|
<P>
|
||||||
|
The DHCP subsystem supports DHCPv4, DHCPv6, BOOTP and PXE.
|
||||||
|
<DIR>
|
||||||
|
<LI> Both static and dynamic DHCP leases are supported, along with stateless mode in DHCPv6.</LI>
|
||||||
|
<LI> The PXE system is a full PXE server, supporting netboot menus and multiple architecture support. It
|
||||||
|
includes proxy-mode, where the PXE system co-operates with another DHCP server.</LI>
|
||||||
|
<LI> There is a built in read-only TFTP server to support netboot.</LI>
|
||||||
|
<LI> Machines which are configured by DHCP have their names automatically
|
||||||
|
included in the DNS and the names can specified by each machine or
|
||||||
|
centrally by associating a name with a MAC address or UID in the dnsmasq
|
||||||
|
configuration file.</LI>
|
||||||
|
</DIR>
|
||||||
|
<P>
|
||||||
|
The Router Advertisement subsystem provides basic autoconfiguration for IPv6 hosts. It can be used stand-alone or in conjunction with DHCPv6.
|
||||||
|
<DIR>
|
||||||
|
<LI> The M and O bits are configurable, to control hosts' use of DHCPv6.</LI>
|
||||||
|
<LI> Router advertisements can include the RDNSS option.</LI>
|
||||||
|
<LI> There is a mode which uses name information from DHCPv4 configuration to provide DNS entries
|
||||||
|
for autoconfigured IPv6 addresses which would otherwise be anonymous.</LI>
|
||||||
|
</DIR>
|
||||||
|
<P>
|
||||||
|
|
||||||
|
For extra compactness, unused features may be omitted at compile time.
|
||||||
|
|
||||||
|
|
||||||
<H2>Get code.</H2>
|
<H2>Get code.</H2>
|
||||||
|
|
||||||
@@ -102,7 +67,7 @@ the repo, or get a copy using git protocol with the command
|
|||||||
<PRE><TT>git clone git://thekelleys.org.uk/dnsmasq.git </TT></PRE>
|
<PRE><TT>git clone git://thekelleys.org.uk/dnsmasq.git </TT></PRE>
|
||||||
|
|
||||||
<H2>License.</H2>
|
<H2>License.</H2>
|
||||||
Dnsmasq is distributed under the GPL. See the file COPYING in the distribution
|
Dnsmasq is distributed under the GPL, version 2 or version 3 at your discretion. See the files COPYING and COPYING-v3 in the distribution
|
||||||
for details.
|
for details.
|
||||||
|
|
||||||
<H2>Contact.</H2>
|
<H2>Contact.</H2>
|
||||||
@@ -110,7 +75,21 @@ There is a dnsmasq mailing list at <A
|
|||||||
HREF="http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss">
|
HREF="http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss">
|
||||||
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss</A> which should be the
|
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss</A> which should be the
|
||||||
first location for queries, bugreports, suggestions etc.
|
first location for queries, bugreports, suggestions etc.
|
||||||
Dnsmasq was written by Simon Kelley. You can contact me at <A
|
You can contact me at <A
|
||||||
HREF="mailto:simon@thekelleys.org.uk">simon@thekelleys.org.uk</A>.
|
HREF="mailto:simon@thekelleys.org.uk">simon@thekelleys.org.uk</A>.
|
||||||
|
|
||||||
|
<H2>Donations.</H2>
|
||||||
|
Dnsmasq is mainly written and maintained by Simon Kelley. For most of its life, dnsmasq has been a spare-time project.
|
||||||
|
These days I'm working on it as my main activity.
|
||||||
|
I don't have an employer or anyone who pays me regularly to work on dnsmasq. If you'd like to make
|
||||||
|
a contribution towards my expenses, please use the donation button below.
|
||||||
|
<form action="https://www.paypal.com/cgi-bin/webscr" method="post" target="_top">
|
||||||
|
<input type="hidden" name="cmd" value="_s-xclick">
|
||||||
|
<input type="hidden" name="hosted_button_id" value="V3X9GVW5GX6DA">
|
||||||
|
<input type="image" src="https://www.paypalobjects.com/en_US/GB/i/btn/btn_donateCC_LG.gif" border="0" name="submit" alt="PayPal – The safer, easier way to pay online.">
|
||||||
|
<img alt="" border="0" src="https://www.paypalobjects.com/en_GB/i/scr/pixel.gif" width="1" height="1">
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
</BODY>
|
</BODY>
|
||||||
|
|
||||||
+69
-11
@@ -209,6 +209,14 @@ the address dnsmasq is listening on. When an interface is specified,
|
|||||||
it may be qualified with "/4" or "/6" to specify only the IPv4 or IPv6
|
it may be qualified with "/4" or "/6" to specify only the IPv4 or IPv6
|
||||||
addresses associated with the interface.
|
addresses associated with the interface.
|
||||||
.TP
|
.TP
|
||||||
|
.B --local-service
|
||||||
|
Accept DNS queries only from hosts whose address is on a local subnet,
|
||||||
|
ie a subnet for which an interface exists on the server. This option
|
||||||
|
only has effect is there are no --interface --except-interface,
|
||||||
|
--listen-address or --auth-server options. It is intended to be set as
|
||||||
|
a default on installation, to allow unconfigured installations to be
|
||||||
|
useful but also safe from being used for DNS amplification attacks.
|
||||||
|
.TP
|
||||||
.B \-2, --no-dhcp-interface=<interface name>
|
.B \-2, --no-dhcp-interface=<interface name>
|
||||||
Do not provide DHCP or TFTP on the specified interface, but do provide DNS service.
|
Do not provide DHCP or TFTP on the specified interface, but do provide DNS service.
|
||||||
.TP
|
.TP
|
||||||
@@ -326,6 +334,16 @@ it will send queries to just one server. Setting this flag forces
|
|||||||
dnsmasq to send all queries to all available servers. The reply from
|
dnsmasq to send all queries to all available servers. The reply from
|
||||||
the server which answers first will be returned to the original requester.
|
the server which answers first will be returned to the original requester.
|
||||||
.TP
|
.TP
|
||||||
|
.B --dns-loop-detect
|
||||||
|
Enable code to detect DNS forwarding loops; ie the situation where a query sent to one
|
||||||
|
of the upstream server eventually returns as a new query to the dnsmasq instance. The
|
||||||
|
process works by generating TXT queries of the form <hex>.test and sending them to
|
||||||
|
each upstream server. The hex is a UID which encodes the instance of dnsmasq sending the query
|
||||||
|
and the upstream server to which it was sent. If the query returns to the server which sent it, then
|
||||||
|
the upstream server through which it was sent is disabled and this event is logged. Each time the
|
||||||
|
set of upstream servers changes, the test is re-run on all of them, including ones which
|
||||||
|
were previously disabled.
|
||||||
|
.TP
|
||||||
.B --stop-dns-rebind
|
.B --stop-dns-rebind
|
||||||
Reject (and log) addresses from upstream nameservers which are in the
|
Reject (and log) addresses from upstream nameservers which are in the
|
||||||
private IP ranges. This blocks an attack where a browser behind a
|
private IP ranges. This blocks an attack where a browser behind a
|
||||||
@@ -599,7 +617,15 @@ clients unable to do validation, use of the AD bit set by dnsmasq is useful, pro
|
|||||||
the dnsmasq server and the client is trusted. Dnsmasq must be compiled with HAVE_DNSSEC enabled, and DNSSEC
|
the dnsmasq server and the client is trusted. Dnsmasq must be compiled with HAVE_DNSSEC enabled, and DNSSEC
|
||||||
trust anchors provided, see
|
trust anchors provided, see
|
||||||
.B --trust-anchor.
|
.B --trust-anchor.
|
||||||
Because the DNSSEC validation process uses the cache, it is not permitted to reduce the cache size below the default when DNSSEC is enabled.
|
Because the DNSSEC validation process uses the cache, it is not
|
||||||
|
permitted to reduce the cache size below the default when DNSSEC is
|
||||||
|
enabled. The nameservers upstream of dnsmasq must be DNSSEC-capable,
|
||||||
|
ie capable of returning DNSSEC records with data. If they are not,
|
||||||
|
then dnsmasq will not be able to determine the trusted status of
|
||||||
|
answers. In the default mode, this menas that all replies will be
|
||||||
|
marked as untrusted. If
|
||||||
|
.B --dnssec-check-unsigned
|
||||||
|
is set and the upstream servers don't support DNSSEC, then DNS service will be entirely broken.
|
||||||
.TP
|
.TP
|
||||||
.B --trust-anchor=[<class>],<domain>,<key-tag>,<algorithm>,<digest-type>,<digest>
|
.B --trust-anchor=[<class>],<domain>,<key-tag>,<algorithm>,<digest-type>,<digest>
|
||||||
Provide DS records to act a trust anchors for DNSSEC
|
Provide DS records to act a trust anchors for DNSSEC
|
||||||
@@ -615,7 +641,19 @@ legitimate: they are assumed to be valid and passed on (without the
|
|||||||
attacker forging unsigned replies for signed DNS zones, but it is
|
attacker forging unsigned replies for signed DNS zones, but it is
|
||||||
fast. If this flag is set, dnsmasq will check the zones of unsigned
|
fast. If this flag is set, dnsmasq will check the zones of unsigned
|
||||||
replies, to ensure that unsigned replies are allowed in those
|
replies, to ensure that unsigned replies are allowed in those
|
||||||
zones. The cost of this is more upstream queries and slower performance.
|
zones. The cost of this is more upstream queries and slower
|
||||||
|
performance. See also the warning about upstream servers in the
|
||||||
|
section on
|
||||||
|
.B --dnssec
|
||||||
|
.TP
|
||||||
|
.B --dnssec-no-timecheck
|
||||||
|
DNSSEC signatures are only valid for specified time windows, and should be rejected outside those windows. This generates an
|
||||||
|
interesting chicken-and-egg problem for machines which don't have a hardware real time clock. For these machines to determine the correct
|
||||||
|
time typically requires use of NTP and therefore DNS, but validating DNS requires that the correct time is already known. Setting this flag
|
||||||
|
removes the time-window checks (but not other DNSSEC validation.) only until the dnsmasq process receives SIGHUP. The intention is
|
||||||
|
that dnsmasq should be started with this flag when the platform determines that reliable time is not currently available. As soon as
|
||||||
|
reliable time is established, a SIGHUP should be sent to dnsmasq, which enables time checking, and purges the cache of DNS records
|
||||||
|
which have not been throughly checked.
|
||||||
.TP
|
.TP
|
||||||
.B --proxy-dnssec
|
.B --proxy-dnssec
|
||||||
Copy the DNSSEC Authenticated Data bit from upstream servers to downstream clients and cache it. This is an
|
Copy the DNSSEC Authenticated Data bit from upstream servers to downstream clients and cache it. This is an
|
||||||
@@ -647,7 +685,7 @@ Interface-name and address-literal subnet specifications may be used
|
|||||||
freely in the same --auth-zone declaration.
|
freely in the same --auth-zone declaration.
|
||||||
|
|
||||||
The subnet(s) are also used to define in-addr.arpa and
|
The subnet(s) are also used to define in-addr.arpa and
|
||||||
ipv6.arpa domains which are served for reverse-DNS queries. If not
|
ip6.arpa domains which are served for reverse-DNS queries. If not
|
||||||
specified, the prefix length defaults to 24 for IPv4 and 64 for IPv6.
|
specified, the prefix length defaults to 24 for IPv4 and 64 for IPv6.
|
||||||
For IPv4 subnets, the prefix length should be have the value 8, 16 or 24
|
For IPv4 subnets, the prefix length should be have the value 8, 16 or 24
|
||||||
unless you are familiar with RFC 2317 and have arranged the
|
unless you are familiar with RFC 2317 and have arranged the
|
||||||
@@ -754,7 +792,7 @@ or from /etc/ethers will be served. A static-only subnet with address
|
|||||||
all zeros may be used as a "catch-all" address to enable replies to all
|
all zeros may be used as a "catch-all" address to enable replies to all
|
||||||
Information-request packets on a subnet which is provided with
|
Information-request packets on a subnet which is provided with
|
||||||
stateless DHCPv6, ie
|
stateless DHCPv6, ie
|
||||||
.B --dhcp=range=::,static
|
.B --dhcp-range=::,static
|
||||||
|
|
||||||
For IPv4, the <mode> may be
|
For IPv4, the <mode> may be
|
||||||
.B proxy
|
.B proxy
|
||||||
@@ -766,7 +804,7 @@ and
|
|||||||
for details.)
|
for details.)
|
||||||
|
|
||||||
For IPv6, the mode may be some combination of
|
For IPv6, the mode may be some combination of
|
||||||
.B ra-only, slaac, ra-names, ra-stateless.
|
.B ra-only, slaac, ra-names, ra-stateless, ra-advrouter.
|
||||||
|
|
||||||
.B ra-only
|
.B ra-only
|
||||||
tells dnsmasq to offer Router Advertisement only on this subnet,
|
tells dnsmasq to offer Router Advertisement only on this subnet,
|
||||||
@@ -801,6 +839,11 @@ can be combined with
|
|||||||
and
|
and
|
||||||
.B slaac.
|
.B slaac.
|
||||||
|
|
||||||
|
.B ra-advrouter
|
||||||
|
enables a mode where router address(es) rather than prefix(es) are included in the advertisements.
|
||||||
|
This is described in RFC-3775 section 7.2 and is used in mobile IPv6. In this mode the interval option
|
||||||
|
is also included, as described in RFC-3775 section 7.3.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B \-G, --dhcp-host=[<hwaddr>][,id:<client_id>|*][,set:<tag>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]
|
.B \-G, --dhcp-host=[<hwaddr>][,id:<client_id>|*][,set:<tag>][,<ipaddr>][,<hostname>][,<lease_time>][,ignore]
|
||||||
Specify per host parameters for the DHCP server. This allows a machine
|
Specify per host parameters for the DHCP server. This allows a machine
|
||||||
@@ -1517,6 +1560,7 @@ Treat DHCP request packets arriving at any of the <alias> interfaces
|
|||||||
as if they had arrived at <interface>. This option is necessary when
|
as if they had arrived at <interface>. This option is necessary when
|
||||||
using "old style" bridging on BSD platforms, since
|
using "old style" bridging on BSD platforms, since
|
||||||
packets arrive at tap interfaces which don't have an IP address.
|
packets arrive at tap interfaces which don't have an IP address.
|
||||||
|
A trailing '*' wildcard can be used in each <alias>.
|
||||||
.TP
|
.TP
|
||||||
.B \-s, --domain=<domain>[,<address range>[,local]]
|
.B \-s, --domain=<domain>[,<address range>[,local]]
|
||||||
Specifies DNS domains for the DHCP server. Domains may be be given
|
Specifies DNS domains for the DHCP server. Domains may be be given
|
||||||
@@ -1681,12 +1725,16 @@ Specify a different configuration file. The conf-file option is also allowed in
|
|||||||
configuration files, to include multiple configuration files. A
|
configuration files, to include multiple configuration files. A
|
||||||
filename of "-" causes dnsmasq to read configuration from stdin.
|
filename of "-" causes dnsmasq to read configuration from stdin.
|
||||||
.TP
|
.TP
|
||||||
.B \-7, --conf-dir=<directory>[,<file-extension>......]
|
.B \-7, --conf-dir=<directory>[,<file-extension>......],
|
||||||
Read all the files in the given directory as configuration
|
Read all the files in the given directory as configuration
|
||||||
files. If extension(s) are given, any files which end in those
|
files. If extension(s) are given, any files which end in those
|
||||||
extensions are skipped. Any files whose names end in ~ or start with . or start and end
|
extensions are skipped. Any files whose names end in ~ or start with . or start and end
|
||||||
with # are always skipped. This flag may be given on the command
|
with # are always skipped. If the extension starts with * then only files
|
||||||
line or in a configuration file.
|
which have that extension are loaded. So
|
||||||
|
.B --conf-dir=/path/to/dir,*.conf
|
||||||
|
loads all files with the suffix .conf in /path/to/dir. This flag may be given on the command
|
||||||
|
line or in a configuration file. If giving it on the command line, be sure to
|
||||||
|
escape * characters.
|
||||||
.TP
|
.TP
|
||||||
.B --servers-file=<file>
|
.B --servers-file=<file>
|
||||||
A special case of
|
A special case of
|
||||||
@@ -1734,12 +1782,22 @@ When it receives a SIGUSR1,
|
|||||||
writes statistics to the system log. It writes the cache size,
|
writes statistics to the system log. It writes the cache size,
|
||||||
the number of names which have had to removed from the cache before
|
the number of names which have had to removed from the cache before
|
||||||
they expired in order to make room for new names and the total number
|
they expired in order to make room for new names and the total number
|
||||||
of names that have been inserted into the cache. For each upstream
|
of names that have been inserted into the cache. The number of cache hits and
|
||||||
|
misses and the number of authoritative queries answered are also given. For each upstream
|
||||||
server it gives the number of queries sent, and the number which
|
server it gives the number of queries sent, and the number which
|
||||||
resulted in an error. In
|
resulted in an error. In
|
||||||
.B --no-daemon
|
.B --no-daemon
|
||||||
mode or when full logging is enabled (-q), a complete dump of the
|
mode or when full logging is enabled (-q), a complete dump of the
|
||||||
contents of the cache is made.
|
contents of the cache is made.
|
||||||
|
|
||||||
|
The cache statistics are also available in the DNS as answers to
|
||||||
|
queries of class CHAOS and type TXT in domain bind. The domain names are cachesize.bind, insertions.bind, evictions.bind,
|
||||||
|
misses.bind, hits.bind, auth.bind and servers.bind. An example command to query this, using the
|
||||||
|
.B dig
|
||||||
|
utility would be
|
||||||
|
|
||||||
|
dig +short chaos txt cachesize.bind
|
||||||
|
|
||||||
.PP
|
.PP
|
||||||
When it receives SIGUSR2 and it is logging direct to a file (see
|
When it receives SIGUSR2 and it is logging direct to a file (see
|
||||||
.B --log-facility
|
.B --log-facility
|
||||||
@@ -1843,7 +1901,7 @@ which has tags will be used in preference to an untagged
|
|||||||
.B dhcp-option,
|
.B dhcp-option,
|
||||||
provided that _all_ the tags match somewhere in the
|
provided that _all_ the tags match somewhere in the
|
||||||
set collected as described above. The prefix '!' on a tag means 'not'
|
set collected as described above. The prefix '!' on a tag means 'not'
|
||||||
so --dhcp=option=tag:!purple,3,1.2.3.4 sends the option when the
|
so --dhcp-option=tag:!purple,3,1.2.3.4 sends the option when the
|
||||||
tag purple is not in the set of valid tags. (If using this in a
|
tag purple is not in the set of valid tags. (If using this in a
|
||||||
command line rather than a configuration file, be sure to escape !,
|
command line rather than a configuration file, be sure to escape !,
|
||||||
which is a shell metacharacter)
|
which is a shell metacharacter)
|
||||||
@@ -1995,7 +2053,7 @@ to particular hosts then
|
|||||||
will do so.
|
will do so.
|
||||||
|
|
||||||
Dnsmasq acts as an authoritative server for in-addr.arpa and
|
Dnsmasq acts as an authoritative server for in-addr.arpa and
|
||||||
ipv6.arpa domains associated with the subnets given in auth-zone
|
ip6.arpa domains associated with the subnets given in auth-zone
|
||||||
declarations, so reverse (address to name) lookups can be simply
|
declarations, so reverse (address to name) lookups can be simply
|
||||||
configured with a suitable NS record, for instance in this example,
|
configured with a suitable NS record, for instance in this example,
|
||||||
where we allow 1.2.3.0/24 addresses.
|
where we allow 1.2.3.0/24 addresses.
|
||||||
|
|||||||
+3
-3
@@ -706,7 +706,7 @@ l'un des sous-réseaux définis, ou dans un réseau correspondant à une plage D
|
|||||||
(ce comportement peut-être désactivé par
|
(ce comportement peut-être désactivé par
|
||||||
.B constructor-noauth:
|
.B constructor-noauth:
|
||||||
). Le ou les sous-réseaux sont également utilisé(s) pour définir les domaines
|
). Le ou les sous-réseaux sont également utilisé(s) pour définir les domaines
|
||||||
in-addr.arpa et ipv6.arpa servant à l'interrogation DNS inverse. Si la longueur
|
in-addr.arpa et ip6.arpa servant à l'interrogation DNS inverse. Si la longueur
|
||||||
de préfixe n'est pas spécifiée, elle sera par défaut de 24 pour IPv4 et 64 pour
|
de préfixe n'est pas spécifiée, elle sera par défaut de 24 pour IPv4 et 64 pour
|
||||||
IPv6. Dans le cas d'IPv4, la longueur du masque de réseau devrait-être de 8, 16
|
IPv6. Dans le cas d'IPv4, la longueur du masque de réseau devrait-être de 8, 16
|
||||||
ou 24, sauf si en cas de mise en place d'une délégation de la zone in-addr.arpa
|
ou 24, sauf si en cas de mise en place d'une délégation de la zone in-addr.arpa
|
||||||
@@ -1659,7 +1659,7 @@ Traiter les requêtes DHCP arrivant sur n'importe laquelle des interfaces <alias
|
|||||||
comme si elles arrivaient de l'interface <interface>. Cette option est
|
comme si elles arrivaient de l'interface <interface>. Cette option est
|
||||||
nécessaire lors de l'utilisation de pont ethernet "ancien mode" sur plate-forme
|
nécessaire lors de l'utilisation de pont ethernet "ancien mode" sur plate-forme
|
||||||
BSD, puisque dans ce cas les paquets arrivent sur des interfaces "tap" n'ont
|
BSD, puisque dans ce cas les paquets arrivent sur des interfaces "tap" n'ont
|
||||||
pas d'adresse IP.
|
pas d'adresse IP. Chaque <alias> peut finir avec un simple '*' joker.
|
||||||
.TP
|
.TP
|
||||||
.B \-s, --domain=<domaine>[,<gamme d'adresses>[,local]]
|
.B \-s, --domain=<domaine>[,<gamme d'adresses>[,local]]
|
||||||
Spécifie le domaine du serveur DHCP. Le domaine peut être donné de manière
|
Spécifie le domaine du serveur DHCP. Le domaine peut être donné de manière
|
||||||
@@ -2186,7 +2186,7 @@ spécifiques, vous pouvez le faire via :
|
|||||||
.fi
|
.fi
|
||||||
|
|
||||||
Dnsmasq joue le rôle de serveur faisant autorité pour les domaines in-addr.arpa
|
Dnsmasq joue le rôle de serveur faisant autorité pour les domaines in-addr.arpa
|
||||||
et ipv6.arpa associés aux sous-réseaux définis dans la déclaration de zone
|
et ip6.arpa associés aux sous-réseaux définis dans la déclaration de zone
|
||||||
auth-zone, ce qui fait que les requêtes DNS inversées (de l'adresse vers
|
auth-zone, ce qui fait que les requêtes DNS inversées (de l'adresse vers
|
||||||
le nom) peuvent-simplement être configurées avec un enregistrement NS
|
le nom) peuvent-simplement être configurées avec un enregistrement NS
|
||||||
adéquat. Par exemple, comme nous définissons plus haut les adresses
|
adéquat. Par exemple, comme nous définissons plus haut les adresses
|
||||||
|
|||||||
+603
-448
File diff suppressed because it is too large.
Load diff
+5
-3
@@ -31,7 +31,7 @@ static struct addrlist *find_subnet(struct auth_zone *zone, int flag, struct all
|
|||||||
if (!(flag & F_IPV4))
|
if (!(flag & F_IPV4))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
netmask.s_addr = htonl(~((1 << (32 - subnet->prefixlen)) - 1));
|
netmask.s_addr = htonl(~(in_addr_t)0 << (32 - subnet->prefixlen));
|
||||||
|
|
||||||
if (is_same_net(addr, subnet->addr.addr.addr4, netmask))
|
if (is_same_net(addr, subnet->addr.addr.addr4, netmask))
|
||||||
return subnet;
|
return subnet;
|
||||||
@@ -231,8 +231,10 @@ size_t answer_auth(struct dns_header *header, char *limit, size_t qlen, time_t n
|
|||||||
|
|
||||||
} while ((crecp = cache_find_by_addr(crecp, &addr, now, flag)));
|
} while ((crecp = cache_find_by_addr(crecp, &addr, now, flag)));
|
||||||
|
|
||||||
if (!found)
|
if (found)
|
||||||
log_query(flag | F_NEG | F_NXDOMAIN | F_REVERSE | F_AUTH, NULL, &addr, NULL);
|
nxdomain = 0;
|
||||||
|
else
|
||||||
|
log_query(flag | F_NEG | F_NXDOMAIN | F_REVERSE | (auth ? F_AUTH : 0), NULL, &addr, NULL);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
+9
-4
@@ -25,7 +25,7 @@ static void blockdata_expand(int n)
|
|||||||
{
|
{
|
||||||
struct blockdata *new = whine_malloc(n * sizeof(struct blockdata));
|
struct blockdata *new = whine_malloc(n * sizeof(struct blockdata));
|
||||||
|
|
||||||
if (new)
|
if (n > 0 && new)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
@@ -47,13 +47,18 @@ void blockdata_init(void)
|
|||||||
blockdata_count = 0;
|
blockdata_count = 0;
|
||||||
blockdata_hwm = 0;
|
blockdata_hwm = 0;
|
||||||
|
|
||||||
blockdata_expand((daemon->cachesize * 100) / sizeof(struct blockdata));
|
/* Note that daemon->cachesize is enforced to have non-zero size if OPT_DNSSEC_VALID is set */
|
||||||
|
if (option_bool(OPT_DNSSEC_VALID))
|
||||||
|
blockdata_expand((daemon->cachesize * 100) / sizeof(struct blockdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
void blockdata_report(void)
|
void blockdata_report(void)
|
||||||
{
|
{
|
||||||
my_syslog(LOG_INFO, _("DNSSEC memory in use %u, max %u, allocated %u"),
|
if (option_bool(OPT_DNSSEC_VALID))
|
||||||
blockdata_count * sizeof(struct blockdata), blockdata_hwm * sizeof(struct blockdata), blockdata_alloced * sizeof(struct blockdata));
|
my_syslog(LOG_INFO, _("DNSSEC memory in use %u, max %u, allocated %u"),
|
||||||
|
blockdata_count * sizeof(struct blockdata),
|
||||||
|
blockdata_hwm * sizeof(struct blockdata),
|
||||||
|
blockdata_alloced * sizeof(struct blockdata));
|
||||||
}
|
}
|
||||||
|
|
||||||
struct blockdata *blockdata_alloc(char *data, size_t len)
|
struct blockdata *blockdata_alloc(char *data, size_t len)
|
||||||
|
|||||||
@@ -376,7 +376,7 @@ void route_init(void)
|
|||||||
die(_("cannot create PF_ROUTE socket: %s"), NULL, EC_BADNET);
|
die(_("cannot create PF_ROUTE socket: %s"), NULL, EC_BADNET);
|
||||||
}
|
}
|
||||||
|
|
||||||
void route_sock(time_t now)
|
void route_sock(void)
|
||||||
{
|
{
|
||||||
struct if_msghdr *msg;
|
struct if_msghdr *msg;
|
||||||
int rc = recv(daemon->routefd, daemon->packet, daemon->packet_buff_sz, 0);
|
int rc = recv(daemon->routefd, daemon->packet, daemon->packet_buff_sz, 0);
|
||||||
@@ -401,7 +401,7 @@ void route_sock(time_t now)
|
|||||||
else if (msg->ifm_type == RTM_NEWADDR)
|
else if (msg->ifm_type == RTM_NEWADDR)
|
||||||
{
|
{
|
||||||
del_family = 0;
|
del_family = 0;
|
||||||
newaddress(now);
|
queue_event(EVENT_NEWADDR);
|
||||||
}
|
}
|
||||||
else if (msg->ifm_type == RTM_DELADDR)
|
else if (msg->ifm_type == RTM_DELADDR)
|
||||||
{
|
{
|
||||||
@@ -439,7 +439,7 @@ void route_sock(time_t now)
|
|||||||
of += sizeof(long) - (diff & (sizeof(long) - 1));
|
of += sizeof(long) - (diff & (sizeof(long) - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
newaddress(now);
|
queue_event(EVENT_NEWADDR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+135
-19
@@ -24,7 +24,6 @@ static struct crec *new_chain = NULL;
|
|||||||
static int cache_inserted = 0, cache_live_freed = 0, insert_error;
|
static int cache_inserted = 0, cache_live_freed = 0, insert_error;
|
||||||
static union bigname *big_free = NULL;
|
static union bigname *big_free = NULL;
|
||||||
static int bignames_left, hash_size;
|
static int bignames_left, hash_size;
|
||||||
static int uid = 1;
|
|
||||||
|
|
||||||
/* type->string mapping: this is also used by the name-hash function as a mixing table. */
|
/* type->string mapping: this is also used by the name-hash function as a mixing table. */
|
||||||
static const struct {
|
static const struct {
|
||||||
@@ -73,6 +72,19 @@ static void cache_link(struct crec *crecp);
|
|||||||
static void rehash(int size);
|
static void rehash(int size);
|
||||||
static void cache_hash(struct crec *crecp);
|
static void cache_hash(struct crec *crecp);
|
||||||
|
|
||||||
|
static unsigned int next_uid(void)
|
||||||
|
{
|
||||||
|
static unsigned int uid = 0;
|
||||||
|
|
||||||
|
uid++;
|
||||||
|
|
||||||
|
/* uid == 0 used to indicate CNAME to interface name. */
|
||||||
|
if (uid == SRC_INTERFACE)
|
||||||
|
uid++;
|
||||||
|
|
||||||
|
return uid;
|
||||||
|
}
|
||||||
|
|
||||||
void cache_init(void)
|
void cache_init(void)
|
||||||
{
|
{
|
||||||
struct crec *crecp;
|
struct crec *crecp;
|
||||||
@@ -88,7 +100,7 @@ void cache_init(void)
|
|||||||
{
|
{
|
||||||
cache_link(crecp);
|
cache_link(crecp);
|
||||||
crecp->flags = 0;
|
crecp->flags = 0;
|
||||||
crecp->uid = uid++;
|
crecp->uid = next_uid();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -192,10 +204,7 @@ static void cache_free(struct crec *crecp)
|
|||||||
{
|
{
|
||||||
crecp->flags &= ~F_FORWARD;
|
crecp->flags &= ~F_FORWARD;
|
||||||
crecp->flags &= ~F_REVERSE;
|
crecp->flags &= ~F_REVERSE;
|
||||||
crecp->uid = uid++; /* invalidate CNAMES pointing to this. */
|
crecp->uid = next_uid(); /* invalidate CNAMES pointing to this. */
|
||||||
|
|
||||||
if (uid == -1)
|
|
||||||
uid++;
|
|
||||||
|
|
||||||
if (cache_tail)
|
if (cache_tail)
|
||||||
cache_tail->next = crecp;
|
cache_tail->next = crecp;
|
||||||
@@ -256,7 +265,7 @@ char *cache_get_name(struct crec *crecp)
|
|||||||
|
|
||||||
char *cache_get_cname_target(struct crec *crecp)
|
char *cache_get_cname_target(struct crec *crecp)
|
||||||
{
|
{
|
||||||
if (crecp->addr.cname.uid != -1)
|
if (crecp->addr.cname.uid != SRC_INTERFACE)
|
||||||
return cache_get_name(crecp->addr.cname.target.cache);
|
return cache_get_name(crecp->addr.cname.target.cache);
|
||||||
|
|
||||||
return crecp->addr.cname.target.int_name->name;
|
return crecp->addr.cname.target.int_name->name;
|
||||||
@@ -289,7 +298,7 @@ struct crec *cache_enumerate(int init)
|
|||||||
|
|
||||||
static int is_outdated_cname_pointer(struct crec *crecp)
|
static int is_outdated_cname_pointer(struct crec *crecp)
|
||||||
{
|
{
|
||||||
if (!(crecp->flags & F_CNAME) || crecp->addr.cname.uid == -1)
|
if (!(crecp->flags & F_CNAME) || crecp->addr.cname.uid == SRC_INTERFACE)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* NB. record may be reused as DS or DNSKEY, where uid is
|
/* NB. record may be reused as DS or DNSKEY, where uid is
|
||||||
@@ -627,7 +636,7 @@ struct crec *cache_find_by_name(struct crec *crecp, char *name, time_t now, unsi
|
|||||||
{
|
{
|
||||||
if ((crecp->flags & F_FORWARD) &&
|
if ((crecp->flags & F_FORWARD) &&
|
||||||
#ifdef HAVE_DNSSEC
|
#ifdef HAVE_DNSSEC
|
||||||
((crecp->flags & (F_DNSKEY | F_DS)) == (prot & (F_DNSKEY | F_DS))) &&
|
(((crecp->flags & (F_DNSKEY | F_DS)) == (prot & (F_DNSKEY | F_DS))) || (prot & F_NSIGMATCH)) &&
|
||||||
#endif
|
#endif
|
||||||
(crecp->flags & prot) &&
|
(crecp->flags & prot) &&
|
||||||
hostname_isequal(cache_get_name(crecp), name))
|
hostname_isequal(cache_get_name(crecp), name))
|
||||||
@@ -687,7 +696,7 @@ struct crec *cache_find_by_name(struct crec *crecp, char *name, time_t now, unsi
|
|||||||
if (ans &&
|
if (ans &&
|
||||||
(ans->flags & F_FORWARD) &&
|
(ans->flags & F_FORWARD) &&
|
||||||
#ifdef HAVE_DNSSEC
|
#ifdef HAVE_DNSSEC
|
||||||
((ans->flags & (F_DNSKEY | F_DS)) == (prot & (F_DNSKEY | F_DS))) &&
|
(((ans->flags & (F_DNSKEY | F_DS)) == (prot & (F_DNSKEY | F_DS))) || (prot & F_NSIGMATCH)) &&
|
||||||
#endif
|
#endif
|
||||||
(ans->flags & prot) &&
|
(ans->flags & prot) &&
|
||||||
hostname_isequal(cache_get_name(ans), name))
|
hostname_isequal(cache_get_name(ans), name))
|
||||||
@@ -774,13 +783,14 @@ static void add_hosts_cname(struct crec *target)
|
|||||||
crec->name.namep = a->alias;
|
crec->name.namep = a->alias;
|
||||||
crec->addr.cname.target.cache = target;
|
crec->addr.cname.target.cache = target;
|
||||||
crec->addr.cname.uid = target->uid;
|
crec->addr.cname.uid = target->uid;
|
||||||
|
crec->uid = next_uid();
|
||||||
cache_hash(crec);
|
cache_hash(crec);
|
||||||
add_hosts_cname(crec); /* handle chains */
|
add_hosts_cname(crec); /* handle chains */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void add_hosts_entry(struct crec *cache, struct all_addr *addr, int addrlen,
|
static void add_hosts_entry(struct crec *cache, struct all_addr *addr, int addrlen,
|
||||||
int index, struct crec **rhash, int hashsz)
|
unsigned int index, struct crec **rhash, int hashsz)
|
||||||
{
|
{
|
||||||
struct crec *lookup = cache_find_by_name(NULL, cache_get_name(cache), 0, cache->flags & (F_IPV4 | F_IPV6));
|
struct crec *lookup = cache_find_by_name(NULL, cache_get_name(cache), 0, cache->flags & (F_IPV4 | F_IPV6));
|
||||||
int i, nameexists = 0;
|
int i, nameexists = 0;
|
||||||
@@ -884,7 +894,7 @@ static int gettok(FILE *f, char *token)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int read_hostsfile(char *filename, int index, int cache_size, struct crec **rhash, int hashsz)
|
static int read_hostsfile(char *filename, unsigned int index, int cache_size, struct crec **rhash, int hashsz)
|
||||||
{
|
{
|
||||||
FILE *f = fopen(filename, "r");
|
FILE *f = fopen(filename, "r");
|
||||||
char *token = daemon->namebuff, *domain_suffix = NULL;
|
char *token = daemon->namebuff, *domain_suffix = NULL;
|
||||||
@@ -1034,7 +1044,8 @@ void cache_reload(void)
|
|||||||
cache->flags = F_FORWARD | F_NAMEP | F_CNAME | F_IMMORTAL | F_CONFIG;
|
cache->flags = F_FORWARD | F_NAMEP | F_CNAME | F_IMMORTAL | F_CONFIG;
|
||||||
cache->name.namep = a->alias;
|
cache->name.namep = a->alias;
|
||||||
cache->addr.cname.target.int_name = intr;
|
cache->addr.cname.target.int_name = intr;
|
||||||
cache->addr.cname.uid = -1;
|
cache->addr.cname.uid = SRC_INTERFACE;
|
||||||
|
cache->uid = next_uid();
|
||||||
cache_hash(cache);
|
cache_hash(cache);
|
||||||
add_hosts_cname(cache); /* handle chains */
|
add_hosts_cname(cache); /* handle chains */
|
||||||
}
|
}
|
||||||
@@ -1070,7 +1081,7 @@ void cache_reload(void)
|
|||||||
{
|
{
|
||||||
cache->name.namep = nl->name;
|
cache->name.namep = nl->name;
|
||||||
cache->flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV4 | F_NAMEP | F_CONFIG;
|
cache->flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV4 | F_NAMEP | F_CONFIG;
|
||||||
add_hosts_entry(cache, (struct all_addr *)&hr->addr, INADDRSZ, 0, (struct crec **)daemon->packet, revhashsz);
|
add_hosts_entry(cache, (struct all_addr *)&hr->addr, INADDRSZ, SRC_CONFIG, (struct crec **)daemon->packet, revhashsz);
|
||||||
}
|
}
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
if (!IN6_IS_ADDR_UNSPECIFIED(&hr->addr6) &&
|
if (!IN6_IS_ADDR_UNSPECIFIED(&hr->addr6) &&
|
||||||
@@ -1078,7 +1089,7 @@ void cache_reload(void)
|
|||||||
{
|
{
|
||||||
cache->name.namep = nl->name;
|
cache->name.namep = nl->name;
|
||||||
cache->flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV6 | F_NAMEP | F_CONFIG;
|
cache->flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV6 | F_NAMEP | F_CONFIG;
|
||||||
add_hosts_entry(cache, (struct all_addr *)&hr->addr6, IN6ADDRSZ, 0, (struct crec **)daemon->packet, revhashsz);
|
add_hosts_entry(cache, (struct all_addr *)&hr->addr6, IN6ADDRSZ, SRC_CONFIG, (struct crec **)daemon->packet, revhashsz);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1091,7 +1102,7 @@ void cache_reload(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!option_bool(OPT_NO_HOSTS))
|
if (!option_bool(OPT_NO_HOSTS))
|
||||||
total_size = read_hostsfile(HOSTSFILE, 0, total_size, (struct crec **)daemon->packet, revhashsz);
|
total_size = read_hostsfile(HOSTSFILE, SRC_HOSTS, total_size, (struct crec **)daemon->packet, revhashsz);
|
||||||
|
|
||||||
daemon->addn_hosts = expand_filelist(daemon->addn_hosts);
|
daemon->addn_hosts = expand_filelist(daemon->addn_hosts);
|
||||||
for (ah = daemon->addn_hosts; ah; ah = ah->next)
|
for (ah = daemon->addn_hosts; ah; ah = ah->next)
|
||||||
@@ -1155,6 +1166,7 @@ static void add_dhcp_cname(struct crec *target, time_t ttd)
|
|||||||
aliasc->name.namep = a->alias;
|
aliasc->name.namep = a->alias;
|
||||||
aliasc->addr.cname.target.cache = target;
|
aliasc->addr.cname.target.cache = target;
|
||||||
aliasc->addr.cname.uid = target->uid;
|
aliasc->addr.cname.uid = target->uid;
|
||||||
|
aliasc->uid = next_uid();
|
||||||
cache_hash(aliasc);
|
cache_hash(aliasc);
|
||||||
add_dhcp_cname(aliasc, ttd);
|
add_dhcp_cname(aliasc, ttd);
|
||||||
}
|
}
|
||||||
@@ -1242,7 +1254,7 @@ void cache_add_dhcp_entry(char *host_name, int prot,
|
|||||||
crec->ttd = ttd;
|
crec->ttd = ttd;
|
||||||
crec->addr.addr = *host_address;
|
crec->addr.addr = *host_address;
|
||||||
crec->name.namep = host_name;
|
crec->name.namep = host_name;
|
||||||
crec->uid = uid++;
|
crec->uid = next_uid();
|
||||||
cache_hash(crec);
|
cache_hash(crec);
|
||||||
|
|
||||||
add_dhcp_cname(crec, ttd);
|
add_dhcp_cname(crec, ttd);
|
||||||
@@ -1250,6 +1262,101 @@ void cache_add_dhcp_entry(char *host_name, int prot,
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
int cache_make_stat(struct txt_record *t)
|
||||||
|
{
|
||||||
|
static char *buff = NULL;
|
||||||
|
static int bufflen = 60;
|
||||||
|
int len;
|
||||||
|
struct server *serv, *serv1;
|
||||||
|
char *p;
|
||||||
|
|
||||||
|
if (!buff && !(buff = whine_malloc(60)))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
p = buff;
|
||||||
|
|
||||||
|
switch (t->stat)
|
||||||
|
{
|
||||||
|
case TXT_STAT_CACHESIZE:
|
||||||
|
sprintf(buff+1, "%d", daemon->cachesize);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TXT_STAT_INSERTS:
|
||||||
|
sprintf(buff+1, "%d", cache_inserted);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TXT_STAT_EVICTIONS:
|
||||||
|
sprintf(buff+1, "%d", cache_live_freed);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TXT_STAT_MISSES:
|
||||||
|
sprintf(buff+1, "%u", daemon->queries_forwarded);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TXT_STAT_HITS:
|
||||||
|
sprintf(buff+1, "%u", daemon->local_answer);
|
||||||
|
break;
|
||||||
|
|
||||||
|
#ifdef HAVE_AUTH
|
||||||
|
case TXT_STAT_AUTH:
|
||||||
|
sprintf(buff+1, "%u", daemon->auth_answer);
|
||||||
|
break;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
case TXT_STAT_SERVERS:
|
||||||
|
/* sum counts from different records for same server */
|
||||||
|
for (serv = daemon->servers; serv; serv = serv->next)
|
||||||
|
serv->flags &= ~SERV_COUNTED;
|
||||||
|
|
||||||
|
for (serv = daemon->servers; serv; serv = serv->next)
|
||||||
|
if (!(serv->flags &
|
||||||
|
(SERV_NO_ADDR | SERV_LITERAL_ADDRESS | SERV_COUNTED | SERV_USE_RESOLV | SERV_NO_REBIND)))
|
||||||
|
{
|
||||||
|
char *new, *lenp;
|
||||||
|
int port, newlen, bytes_avail, bytes_needed;
|
||||||
|
unsigned int queries = 0, failed_queries = 0;
|
||||||
|
for (serv1 = serv; serv1; serv1 = serv1->next)
|
||||||
|
if (!(serv1->flags &
|
||||||
|
(SERV_NO_ADDR | SERV_LITERAL_ADDRESS | SERV_COUNTED | SERV_USE_RESOLV | SERV_NO_REBIND)) &&
|
||||||
|
sockaddr_isequal(&serv->addr, &serv1->addr))
|
||||||
|
{
|
||||||
|
serv1->flags |= SERV_COUNTED;
|
||||||
|
queries += serv1->queries;
|
||||||
|
failed_queries += serv1->failed_queries;
|
||||||
|
}
|
||||||
|
port = prettyprint_addr(&serv->addr, daemon->addrbuff);
|
||||||
|
lenp = p++; /* length */
|
||||||
|
bytes_avail = (p - buff) + bufflen;
|
||||||
|
bytes_needed = snprintf(p, bytes_avail, "%s#%d %u %u", daemon->addrbuff, port, queries, failed_queries);
|
||||||
|
if (bytes_needed >= bytes_avail)
|
||||||
|
{
|
||||||
|
/* expand buffer if necessary */
|
||||||
|
newlen = bytes_needed + 1 + bufflen - bytes_avail;
|
||||||
|
if (!(new = whine_malloc(newlen)))
|
||||||
|
return 0;
|
||||||
|
memcpy(new, buff, bufflen);
|
||||||
|
free(buff);
|
||||||
|
p = new + (p - buff);
|
||||||
|
lenp = p - 1;
|
||||||
|
buff = new;
|
||||||
|
bufflen = newlen;
|
||||||
|
bytes_avail = (p - buff) + bufflen;
|
||||||
|
bytes_needed = snprintf(p, bytes_avail, "%s#%d %u %u", daemon->addrbuff, port, queries, failed_queries);
|
||||||
|
}
|
||||||
|
*lenp = bytes_needed;
|
||||||
|
p += bytes_needed;
|
||||||
|
}
|
||||||
|
t->txt = (unsigned char *)buff;
|
||||||
|
t->len = p - buff;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
len = strlen(buff+1);
|
||||||
|
t->txt = (unsigned char *)buff;
|
||||||
|
t->len = len + 1;
|
||||||
|
*buff = len;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
void dump_cache(time_t now)
|
void dump_cache(time_t now)
|
||||||
{
|
{
|
||||||
@@ -1368,11 +1475,13 @@ void dump_cache(time_t now)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
char *record_source(int index)
|
char *record_source(unsigned int index)
|
||||||
{
|
{
|
||||||
struct hostsfile *ah;
|
struct hostsfile *ah;
|
||||||
|
|
||||||
if (index == 0)
|
if (index == SRC_CONFIG)
|
||||||
|
return "config";
|
||||||
|
else if (index == SRC_HOSTS)
|
||||||
return HOSTSFILE;
|
return HOSTSFILE;
|
||||||
|
|
||||||
for (ah = daemon->addn_hosts; ah; ah = ah->next)
|
for (ah = daemon->addn_hosts; ah; ah = ah->next)
|
||||||
@@ -1500,6 +1609,13 @@ void log_query(unsigned int flags, char *name, struct all_addr *addr, char *arg)
|
|||||||
source = arg;
|
source = arg;
|
||||||
verb = "to";
|
verb = "to";
|
||||||
}
|
}
|
||||||
|
else if (flags & F_IPSET)
|
||||||
|
{
|
||||||
|
source = "ipset add";
|
||||||
|
dest = name;
|
||||||
|
name = arg;
|
||||||
|
verb = daemon->addrbuff;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
source = "cached";
|
source = "cached";
|
||||||
|
|
||||||
|
|||||||
+26
-3
@@ -18,7 +18,7 @@
|
|||||||
#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 4096 /* default max EDNS.0 UDP packet from RFC5625 */
|
#define EDNS_PKTSZ 4096 /* default max EDNS.0 UDP packet from RFC5625 */
|
||||||
#define KEYBLOCK_LEN 35 /* choose to mininise fragmentation when storing DNSSEC keys */
|
#define KEYBLOCK_LEN 40 /* choose to mininise fragmentation when storing DNSSEC keys */
|
||||||
#define DNSSEC_WORK 50 /* Max number of queries to validate one question */
|
#define DNSSEC_WORK 50 /* Max number of queries to validate one question */
|
||||||
#define TIMEOUT 10 /* drop UDP queries after TIMEOUT seconds */
|
#define TIMEOUT 10 /* drop UDP queries after TIMEOUT seconds */
|
||||||
#define FORWARD_TEST 50 /* try all servers every 50 queries */
|
#define FORWARD_TEST 50 /* try all servers every 50 queries */
|
||||||
@@ -47,6 +47,8 @@
|
|||||||
#define SOA_REFRESH 1200 /* SOA refresh default */
|
#define SOA_REFRESH 1200 /* SOA refresh default */
|
||||||
#define SOA_RETRY 180 /* SOA retry default */
|
#define SOA_RETRY 180 /* SOA retry default */
|
||||||
#define SOA_EXPIRY 1209600 /* SOA expiry default */
|
#define SOA_EXPIRY 1209600 /* SOA expiry default */
|
||||||
|
#define LOOP_TEST_DOMAIN "test" /* domain for loop testing, "test" is reserved by RFC 2606 and won't therefore clash */
|
||||||
|
#define LOOP_TEST_TYPE T_TXT
|
||||||
|
|
||||||
/* compile-time options: uncomment below to enable or do eg.
|
/* compile-time options: uncomment below to enable or do eg.
|
||||||
make COPTS=-DHAVE_BROKEN_RTC
|
make COPTS=-DHAVE_BROKEN_RTC
|
||||||
@@ -105,6 +107,12 @@ HAVE_AUTH
|
|||||||
define this to include the facility to act as an authoritative DNS
|
define this to include the facility to act as an authoritative DNS
|
||||||
server for one or more zones.
|
server for one or more zones.
|
||||||
|
|
||||||
|
HAVE_DNSSEC
|
||||||
|
include DNSSEC validator.
|
||||||
|
|
||||||
|
HAVE_LOOP
|
||||||
|
include functionality to probe for and remove DNS forwarding loops.
|
||||||
|
|
||||||
|
|
||||||
NO_IPV6
|
NO_IPV6
|
||||||
NO_TFTP
|
NO_TFTP
|
||||||
@@ -118,6 +126,11 @@ NO_AUTH
|
|||||||
which are enabled by default in the distributed source tree. Building dnsmasq
|
which are enabled by default in the distributed source tree. Building dnsmasq
|
||||||
with something like "make COPTS=-DNO_SCRIPT" will do the trick.
|
with something like "make COPTS=-DNO_SCRIPT" will do the trick.
|
||||||
|
|
||||||
|
NO_NETTLE_ECC
|
||||||
|
Don't include the ECDSA cypher in DNSSEC validation. Needed for older Nettle versions.
|
||||||
|
NO_GMP
|
||||||
|
Don't use and link against libgmp, Useful if nettle is built with --enable-mini-gmp.
|
||||||
|
|
||||||
LEASEFILE
|
LEASEFILE
|
||||||
CONFFILE
|
CONFFILE
|
||||||
RESOLVFILE
|
RESOLVFILE
|
||||||
@@ -141,6 +154,7 @@ RESOLVFILE
|
|||||||
#define HAVE_SCRIPT
|
#define HAVE_SCRIPT
|
||||||
#define HAVE_AUTH
|
#define HAVE_AUTH
|
||||||
#define HAVE_IPSET
|
#define HAVE_IPSET
|
||||||
|
#define HAVE_LOOP
|
||||||
|
|
||||||
/* Build options which require external libraries.
|
/* Build options which require external libraries.
|
||||||
|
|
||||||
@@ -261,6 +275,7 @@ HAVE_SOCKADDR_SA_LEN
|
|||||||
/* Select the RFC_3542 version of the IPv6 socket API.
|
/* Select the RFC_3542 version of the IPv6 socket API.
|
||||||
Define before netinet6/in6.h is included. */
|
Define before netinet6/in6.h is included. */
|
||||||
#define __APPLE_USE_RFC_3542
|
#define __APPLE_USE_RFC_3542
|
||||||
|
#define NO_IPSET
|
||||||
|
|
||||||
#elif defined(__NetBSD__)
|
#elif defined(__NetBSD__)
|
||||||
#define HAVE_BSD_NETWORK
|
#define HAVE_BSD_NETWORK
|
||||||
@@ -330,10 +345,14 @@ HAVE_SOCKADDR_SA_LEN
|
|||||||
#undef HAVE_AUTH
|
#undef HAVE_AUTH
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(NO_IPSET) || !defined(HAVE_LINUX_NETWORK)
|
#if defined(NO_IPSET)
|
||||||
#undef HAVE_IPSET
|
#undef HAVE_IPSET
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef NO_LOOP
|
||||||
|
#undef HAVE_LOOP
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Define a string indicating which options are in use.
|
/* Define a string indicating which options are in use.
|
||||||
DNSMASQP_COMPILE_OPTS is only defined in dnsmasq.c */
|
DNSMASQP_COMPILE_OPTS is only defined in dnsmasq.c */
|
||||||
|
|
||||||
@@ -403,7 +422,11 @@ static char *compile_opts =
|
|||||||
#ifndef HAVE_DNSSEC
|
#ifndef HAVE_DNSSEC
|
||||||
"no-"
|
"no-"
|
||||||
#endif
|
#endif
|
||||||
"DNSSEC";
|
"DNSSEC "
|
||||||
|
#ifndef HAVE_LOOP
|
||||||
|
"no-"
|
||||||
|
#endif
|
||||||
|
"loop-detect";
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+78
-3
@@ -35,6 +35,11 @@ const char* introspection_xml_template =
|
|||||||
" <method name=\"GetVersion\">\n"
|
" <method name=\"GetVersion\">\n"
|
||||||
" <arg name=\"version\" direction=\"out\" type=\"s\"/>\n"
|
" <arg name=\"version\" direction=\"out\" type=\"s\"/>\n"
|
||||||
" </method>\n"
|
" </method>\n"
|
||||||
|
#ifdef HAVE_LOOP
|
||||||
|
" <method name=\"GetLoopServers\">\n"
|
||||||
|
" <arg name=\"server\" direction=\"out\" type=\"as\"/>\n"
|
||||||
|
" </method>\n"
|
||||||
|
#endif
|
||||||
" <method name=\"SetServers\">\n"
|
" <method name=\"SetServers\">\n"
|
||||||
" <arg name=\"servers\" direction=\"in\" type=\"av\"/>\n"
|
" <arg name=\"servers\" direction=\"in\" type=\"av\"/>\n"
|
||||||
" </method>\n"
|
" </method>\n"
|
||||||
@@ -44,6 +49,12 @@ const char* introspection_xml_template =
|
|||||||
" <method name=\"SetServersEx\">\n"
|
" <method name=\"SetServersEx\">\n"
|
||||||
" <arg name=\"servers\" direction=\"in\" type=\"aas\"/>\n"
|
" <arg name=\"servers\" direction=\"in\" type=\"aas\"/>\n"
|
||||||
" </method>\n"
|
" </method>\n"
|
||||||
|
" <method name=\"SetFilterWin2KOption\">\n"
|
||||||
|
" <arg name=\"filterwin2k\" direction=\"in\" type=\"b\"/>\n"
|
||||||
|
" </method>\n"
|
||||||
|
" <method name=\"SetBogusPrivOption\">\n"
|
||||||
|
" <arg name=\"boguspriv\" direction=\"in\" type=\"b\"/>\n"
|
||||||
|
" </method>\n"
|
||||||
" <signal name=\"DhcpLeaseAdded\">\n"
|
" <signal name=\"DhcpLeaseAdded\">\n"
|
||||||
" <arg name=\"ipaddr\" type=\"s\"/>\n"
|
" <arg name=\"ipaddr\" type=\"s\"/>\n"
|
||||||
" <arg name=\"hwaddr\" type=\"s\"/>\n"
|
" <arg name=\"hwaddr\" type=\"s\"/>\n"
|
||||||
@@ -150,13 +161,16 @@ static void dbus_read_servers(DBusMessage *message)
|
|||||||
dbus_message_iter_get_basic(&iter, &p[i]);
|
dbus_message_iter_get_basic(&iter, &p[i]);
|
||||||
dbus_message_iter_next (&iter);
|
dbus_message_iter_next (&iter);
|
||||||
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_BYTE)
|
if (dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_BYTE)
|
||||||
break;
|
{
|
||||||
|
i++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef HAVE_IPV6
|
#ifndef HAVE_IPV6
|
||||||
my_syslog(LOG_WARNING, _("attempt to set an IPv6 server address via DBus - no IPv6 support"));
|
my_syslog(LOG_WARNING, _("attempt to set an IPv6 server address via DBus - no IPv6 support"));
|
||||||
#else
|
#else
|
||||||
if (i == sizeof(struct in6_addr)-1)
|
if (i == sizeof(struct in6_addr))
|
||||||
{
|
{
|
||||||
memcpy(&addr.in6.sin6_addr, p, sizeof(struct in6_addr));
|
memcpy(&addr.in6.sin6_addr, p, sizeof(struct in6_addr));
|
||||||
#ifdef HAVE_SOCKADDR_SA_LEN
|
#ifdef HAVE_SOCKADDR_SA_LEN
|
||||||
@@ -196,6 +210,29 @@ static void dbus_read_servers(DBusMessage *message)
|
|||||||
cleanup_servers();
|
cleanup_servers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_LOOP
|
||||||
|
static DBusMessage *dbus_reply_server_loop(DBusMessage *message)
|
||||||
|
{
|
||||||
|
DBusMessageIter args, args_iter;
|
||||||
|
struct server *serv;
|
||||||
|
DBusMessage *reply = dbus_message_new_method_return(message);
|
||||||
|
|
||||||
|
dbus_message_iter_init_append (reply, &args);
|
||||||
|
dbus_message_iter_open_container (&args, DBUS_TYPE_ARRAY,DBUS_TYPE_STRING_AS_STRING, &args_iter);
|
||||||
|
|
||||||
|
for (serv = daemon->servers; serv; serv = serv->next)
|
||||||
|
if (serv->flags & SERV_LOOP)
|
||||||
|
{
|
||||||
|
prettyprint_addr(&serv->addr, daemon->addrbuff);
|
||||||
|
dbus_message_iter_append_basic (&args_iter, DBUS_TYPE_STRING, &daemon->addrbuff);
|
||||||
|
}
|
||||||
|
|
||||||
|
dbus_message_iter_close_container (&args, &args_iter);
|
||||||
|
|
||||||
|
return reply;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static DBusMessage* dbus_read_servers_ex(DBusMessage *message, int strings)
|
static DBusMessage* dbus_read_servers_ex(DBusMessage *message, int strings)
|
||||||
{
|
{
|
||||||
DBusMessageIter iter, array_iter, string_iter;
|
DBusMessageIter iter, array_iter, string_iter;
|
||||||
@@ -372,6 +409,30 @@ static DBusMessage* dbus_read_servers_ex(DBusMessage *message, int strings)
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DBusMessage *dbus_set_bool(DBusMessage *message, int flag, char *name)
|
||||||
|
{
|
||||||
|
DBusMessageIter iter;
|
||||||
|
dbus_bool_t enabled;
|
||||||
|
|
||||||
|
if (!dbus_message_iter_init(message, &iter) || dbus_message_iter_get_arg_type(&iter) != DBUS_TYPE_BOOLEAN)
|
||||||
|
return dbus_message_new_error(message, DBUS_ERROR_INVALID_ARGS, "Expected boolean argument");
|
||||||
|
|
||||||
|
dbus_message_iter_get_basic(&iter, &enabled);
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
my_syslog(LOG_INFO, "Enabling --%s option from D-Bus", name);
|
||||||
|
set_option_bool(flag);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
my_syslog(LOG_INFO, "Disabling --$s option from D-Bus", name);
|
||||||
|
reset_option_bool(flag);
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
DBusHandlerResult message_handler(DBusConnection *connection,
|
DBusHandlerResult message_handler(DBusConnection *connection,
|
||||||
DBusMessage *message,
|
DBusMessage *message,
|
||||||
void *user_data)
|
void *user_data)
|
||||||
@@ -400,6 +461,12 @@ DBusHandlerResult message_handler(DBusConnection *connection,
|
|||||||
|
|
||||||
dbus_message_append_args(reply, DBUS_TYPE_STRING, &v, DBUS_TYPE_INVALID);
|
dbus_message_append_args(reply, DBUS_TYPE_STRING, &v, DBUS_TYPE_INVALID);
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_LOOP
|
||||||
|
else if (strcmp(method, "GetLoopServers") == 0)
|
||||||
|
{
|
||||||
|
reply = dbus_reply_server_loop(message);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
else if (strcmp(method, "SetServers") == 0)
|
else if (strcmp(method, "SetServers") == 0)
|
||||||
{
|
{
|
||||||
dbus_read_servers(message);
|
dbus_read_servers(message);
|
||||||
@@ -415,6 +482,14 @@ DBusHandlerResult message_handler(DBusConnection *connection,
|
|||||||
reply = dbus_read_servers_ex(message, 1);
|
reply = dbus_read_servers_ex(message, 1);
|
||||||
new_servers = 1;
|
new_servers = 1;
|
||||||
}
|
}
|
||||||
|
else if (strcmp(method, "SetFilterWin2KOption") == 0)
|
||||||
|
{
|
||||||
|
reply = dbus_set_bool(message, OPT_FILTER, "filterwin2k");
|
||||||
|
}
|
||||||
|
else if (strcmp(method, "SetBogusPrivOption") == 0)
|
||||||
|
{
|
||||||
|
reply = dbus_set_bool(message, OPT_BOGUSPRIV, "bogus-priv");
|
||||||
|
}
|
||||||
else if (strcmp(method, "ClearCache") == 0)
|
else if (strcmp(method, "ClearCache") == 0)
|
||||||
clear_cache = 1;
|
clear_cache = 1;
|
||||||
else
|
else
|
||||||
@@ -558,7 +633,7 @@ void emit_dbus_signal(int action, struct dhcp_lease *lease, char *hostname)
|
|||||||
if (lease->flags & (LEASE_TA | LEASE_NA))
|
if (lease->flags & (LEASE_TA | LEASE_NA))
|
||||||
{
|
{
|
||||||
print_mac(mac, lease->clid, lease->clid_len);
|
print_mac(mac, lease->clid, lease->clid_len);
|
||||||
inet_ntop(AF_INET6, lease->hwaddr, daemon->addrbuff, ADDRSTRLEN);
|
inet_ntop(AF_INET6, &lease->addr6, daemon->addrbuff, ADDRSTRLEN);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
+3
-2
@@ -232,7 +232,7 @@ void dhcp_packet(time_t now, int pxe_fd)
|
|||||||
for (bridge = daemon->bridges; bridge; bridge = bridge->next)
|
for (bridge = daemon->bridges; bridge; bridge = bridge->next)
|
||||||
{
|
{
|
||||||
for (alias = bridge->alias; alias; alias = alias->next)
|
for (alias = bridge->alias; alias; alias = alias->next)
|
||||||
if (strncmp(ifr.ifr_name, alias->iface, IF_NAMESIZE) == 0)
|
if (wildcard_matchn(alias->iface, ifr.ifr_name, IF_NAMESIZE))
|
||||||
{
|
{
|
||||||
if (!(iface_index = if_nametoindex(bridge->iface)))
|
if (!(iface_index = if_nametoindex(bridge->iface)))
|
||||||
{
|
{
|
||||||
@@ -404,7 +404,8 @@ void dhcp_packet(time_t now, int pxe_fd)
|
|||||||
memcpy(arp_req.arp_ha.sa_data, mess->chaddr, mess->hlen);
|
memcpy(arp_req.arp_ha.sa_data, mess->chaddr, mess->hlen);
|
||||||
/* interface name already copied in */
|
/* interface name already copied in */
|
||||||
arp_req.arp_flags = ATF_COM;
|
arp_req.arp_flags = ATF_COM;
|
||||||
ioctl(daemon->dhcpfd, SIOCSARP, &arp_req);
|
if (ioctl(daemon->dhcpfd, SIOCSARP, &arp_req) == -1)
|
||||||
|
my_syslog(MS_DHCP | LOG_ERR, _("ARP-cache injection failed: %s"), strerror(errno));
|
||||||
}
|
}
|
||||||
#elif defined(HAVE_SOLARIS_NETWORK)
|
#elif defined(HAVE_SOLARIS_NETWORK)
|
||||||
else if ((ntohs(mess->flags) & 0x8000) || mess->hlen != ETHER_ADDR_LEN || mess->htype != ARPHRD_ETHER)
|
else if ((ntohs(mess->flags) & 0x8000) || mess->hlen != ETHER_ADDR_LEN || mess->htype != ARPHRD_ETHER)
|
||||||
|
|||||||
+1
-2
@@ -727,8 +727,7 @@ void dhcp_construct_contexts(time_t now)
|
|||||||
|
|
||||||
if (context->flags & CONTEXT_GC && !(context->flags & CONTEXT_OLD))
|
if (context->flags & CONTEXT_GC && !(context->flags & CONTEXT_OLD))
|
||||||
{
|
{
|
||||||
if ((context->flags & (CONTEXT_RA_ONLY | CONTEXT_RA_NAME | CONTEXT_RA_STATELESS)) ||
|
if ((context->flags & CONTEXT_RA) || option_bool(OPT_RA))
|
||||||
option_bool(OPT_RA))
|
|
||||||
{
|
{
|
||||||
/* previously constructed context has gone. advertise it's demise */
|
/* previously constructed context has gone. advertise it's demise */
|
||||||
context->flags |= CONTEXT_OLD;
|
context->flags |= CONTEXT_OLD;
|
||||||
|
|||||||
+44
-6
@@ -30,6 +30,7 @@ static void sig_handler(int sig);
|
|||||||
static void async_event(int pipe, time_t now);
|
static void async_event(int pipe, time_t now);
|
||||||
static void fatal_event(struct event_desc *ev, char *msg);
|
static void fatal_event(struct event_desc *ev, char *msg);
|
||||||
static int read_event(int fd, struct event_desc *evp, char **msg);
|
static int read_event(int fd, struct event_desc *evp, char **msg);
|
||||||
|
static void poll_resolv(int force, int do_reload, time_t now);
|
||||||
|
|
||||||
int main (int argc, char **argv)
|
int main (int argc, char **argv)
|
||||||
{
|
{
|
||||||
@@ -80,6 +81,8 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
umask(022); /* known umask, create leases and pid files as 0644 */
|
umask(022); /* known umask, create leases and pid files as 0644 */
|
||||||
|
|
||||||
|
rand_init(); /* Must precede read_opts() */
|
||||||
|
|
||||||
read_opts(argc, argv, compile_opts);
|
read_opts(argc, argv, compile_opts);
|
||||||
|
|
||||||
if (daemon->edns_pktsz < PACKETSZ)
|
if (daemon->edns_pktsz < PACKETSZ)
|
||||||
@@ -185,7 +188,10 @@ int main (int argc, char **argv)
|
|||||||
die(_("authoritative DNS not available: set HAVE_AUTH in src/config.h"), NULL, EC_BADCONF);
|
die(_("authoritative DNS not available: set HAVE_AUTH in src/config.h"), NULL, EC_BADCONF);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
rand_init();
|
#ifndef HAVE_LOOP
|
||||||
|
if (option_bool(OPT_LOOP_DETECT))
|
||||||
|
die(_("Loop detection not available: set HAVE_LOOP in src/config.h"), NULL, EC_BADCONF);
|
||||||
|
#endif
|
||||||
|
|
||||||
now = dnsmasq_time();
|
now = dnsmasq_time();
|
||||||
|
|
||||||
@@ -397,7 +403,7 @@ int main (int argc, char **argv)
|
|||||||
piperead = pipefd[0];
|
piperead = pipefd[0];
|
||||||
pipewrite = pipefd[1];
|
pipewrite = pipefd[1];
|
||||||
/* prime the pipe to load stuff first time. */
|
/* prime the pipe to load stuff first time. */
|
||||||
send_event(pipewrite, EVENT_RELOAD, 0, NULL);
|
send_event(pipewrite, EVENT_INIT, 0, NULL);
|
||||||
|
|
||||||
err_pipe[1] = -1;
|
err_pipe[1] = -1;
|
||||||
|
|
||||||
@@ -662,9 +668,16 @@ int main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (option_bool(OPT_LOCAL_SERVICE))
|
||||||
|
my_syslog(LOG_INFO, _("DNS service limited to local subnets"));
|
||||||
|
|
||||||
#ifdef HAVE_DNSSEC
|
#ifdef HAVE_DNSSEC
|
||||||
if (option_bool(OPT_DNSSEC_VALID))
|
if (option_bool(OPT_DNSSEC_VALID))
|
||||||
my_syslog(LOG_INFO, _("DNSSEC validation enabled"));
|
{
|
||||||
|
my_syslog(LOG_INFO, _("DNSSEC validation enabled"));
|
||||||
|
if (option_bool(OPT_DNSSEC_TIME))
|
||||||
|
my_syslog(LOG_INFO, _("DNSSEC signature timestamps not checked until first cache reload"));
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (log_err != 0)
|
if (log_err != 0)
|
||||||
@@ -910,10 +923,10 @@ int main (int argc, char **argv)
|
|||||||
|
|
||||||
#if defined(HAVE_LINUX_NETWORK)
|
#if defined(HAVE_LINUX_NETWORK)
|
||||||
if (FD_ISSET(daemon->netlinkfd, &rset))
|
if (FD_ISSET(daemon->netlinkfd, &rset))
|
||||||
netlink_multicast(now);
|
netlink_multicast();
|
||||||
#elif defined(HAVE_BSD_NETWORK)
|
#elif defined(HAVE_BSD_NETWORK)
|
||||||
if (FD_ISSET(daemon->routefd, &rset))
|
if (FD_ISSET(daemon->routefd, &rset))
|
||||||
route_sock(now);
|
route_sock();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Check for changes to resolv files once per second max. */
|
/* Check for changes to resolv files once per second max. */
|
||||||
@@ -1030,6 +1043,11 @@ void send_alarm(time_t event, time_t now)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void queue_event(int event)
|
||||||
|
{
|
||||||
|
send_event(pipewrite, event, 0, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
void send_event(int fd, int event, int data, char *msg)
|
void send_event(int fd, int event, int data, char *msg)
|
||||||
{
|
{
|
||||||
struct event_desc ev;
|
struct event_desc ev;
|
||||||
@@ -1127,6 +1145,16 @@ static void async_event(int pipe, time_t now)
|
|||||||
switch (ev.event)
|
switch (ev.event)
|
||||||
{
|
{
|
||||||
case EVENT_RELOAD:
|
case EVENT_RELOAD:
|
||||||
|
#ifdef HAVE_DNSSEC
|
||||||
|
if (option_bool(OPT_DNSSEC_VALID) && option_bool(OPT_DNSSEC_TIME))
|
||||||
|
{
|
||||||
|
my_syslog(LOG_INFO, _("now checking DNSSEC signature timestamps"));
|
||||||
|
reset_option_bool(OPT_DNSSEC_TIME);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
/* fall through */
|
||||||
|
|
||||||
|
case EVENT_INIT:
|
||||||
clear_cache_and_reload(now);
|
clear_cache_and_reload(now);
|
||||||
|
|
||||||
if (daemon->port != 0)
|
if (daemon->port != 0)
|
||||||
@@ -1214,6 +1242,16 @@ static void async_event(int pipe, time_t now)
|
|||||||
log_reopen(daemon->log_file);
|
log_reopen(daemon->log_file);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case EVENT_NEWADDR:
|
||||||
|
newaddress(now);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case EVENT_NEWROUTE:
|
||||||
|
resend_query();
|
||||||
|
/* Force re-reading resolv file right now, for luck. */
|
||||||
|
poll_resolv(0, 1, now);
|
||||||
|
break;
|
||||||
|
|
||||||
case EVENT_TERM:
|
case EVENT_TERM:
|
||||||
/* Knock all our children on the head. */
|
/* Knock all our children on the head. */
|
||||||
for (i = 0; i < MAX_PROCS; i++)
|
for (i = 0; i < MAX_PROCS; i++)
|
||||||
@@ -1246,7 +1284,7 @@ static void async_event(int pipe, time_t now)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void poll_resolv(int force, int do_reload, time_t now)
|
static void poll_resolv(int force, int do_reload, time_t now)
|
||||||
{
|
{
|
||||||
struct resolvc *res, *latest;
|
struct resolvc *res, *latest;
|
||||||
struct stat statbuf;
|
struct stat statbuf;
|
||||||
|
|||||||
+53
-11
@@ -164,6 +164,9 @@ struct event_desc {
|
|||||||
#define EVENT_FORK_ERR 18
|
#define EVENT_FORK_ERR 18
|
||||||
#define EVENT_LUA_ERR 19
|
#define EVENT_LUA_ERR 19
|
||||||
#define EVENT_TFTP_ERR 20
|
#define EVENT_TFTP_ERR 20
|
||||||
|
#define EVENT_INIT 21
|
||||||
|
#define EVENT_NEWADDR 22
|
||||||
|
#define EVENT_NEWROUTE 23
|
||||||
|
|
||||||
/* Exit codes. */
|
/* Exit codes. */
|
||||||
#define EC_GOOD 0
|
#define EC_GOOD 0
|
||||||
@@ -230,10 +233,12 @@ struct event_desc {
|
|||||||
#define OPT_QUIET_DHCP6 43
|
#define OPT_QUIET_DHCP6 43
|
||||||
#define OPT_QUIET_RA 44
|
#define OPT_QUIET_RA 44
|
||||||
#define OPT_DNSSEC_VALID 45
|
#define OPT_DNSSEC_VALID 45
|
||||||
#define OPT_DNSSEC_PERMISS 46
|
#define OPT_DNSSEC_TIME 46
|
||||||
#define OPT_DNSSEC_DEBUG 47
|
#define OPT_DNSSEC_DEBUG 47
|
||||||
#define OPT_DNSSEC_NO_SIGN 48
|
#define OPT_DNSSEC_NO_SIGN 48
|
||||||
#define OPT_LAST 49
|
#define OPT_LOCAL_SERVICE 49
|
||||||
|
#define OPT_LOOP_DETECT 50
|
||||||
|
#define OPT_LAST 51
|
||||||
|
|
||||||
/* extra flags for my_syslog, we use a couple of facilities since they are known
|
/* extra flags for my_syslog, we use a couple of facilities since they are known
|
||||||
not to occupy the same bits as priorities, no matter how syslog.h is set up. */
|
not to occupy the same bits as priorities, no matter how syslog.h is set up. */
|
||||||
@@ -279,10 +284,19 @@ struct naptr {
|
|||||||
struct naptr *next;
|
struct naptr *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define TXT_STAT_CACHESIZE 1
|
||||||
|
#define TXT_STAT_INSERTS 2
|
||||||
|
#define TXT_STAT_EVICTIONS 3
|
||||||
|
#define TXT_STAT_MISSES 4
|
||||||
|
#define TXT_STAT_HITS 5
|
||||||
|
#define TXT_STAT_AUTH 6
|
||||||
|
#define TXT_STAT_SERVERS 7
|
||||||
|
|
||||||
struct txt_record {
|
struct txt_record {
|
||||||
char *name;
|
char *name;
|
||||||
unsigned char *txt;
|
unsigned char *txt;
|
||||||
unsigned short class, len;
|
unsigned short class, len;
|
||||||
|
int stat;
|
||||||
struct txt_record *next;
|
struct txt_record *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -366,7 +380,7 @@ struct crec {
|
|||||||
struct crec *cache;
|
struct crec *cache;
|
||||||
struct interface_name *int_name;
|
struct interface_name *int_name;
|
||||||
} target;
|
} target;
|
||||||
int uid; /* -1 if union is interface-name */
|
unsigned int uid; /* 0 if union is interface-name */
|
||||||
} cname;
|
} cname;
|
||||||
struct {
|
struct {
|
||||||
struct blockdata *keydata;
|
struct blockdata *keydata;
|
||||||
@@ -387,7 +401,7 @@ struct crec {
|
|||||||
} addr;
|
} addr;
|
||||||
time_t ttd; /* time to die */
|
time_t ttd; /* time to die */
|
||||||
/* used as class if DNSKEY/DS/RRSIG, index to source for F_HOSTS */
|
/* used as class if DNSKEY/DS/RRSIG, index to source for F_HOSTS */
|
||||||
int uid;
|
unsigned int uid;
|
||||||
unsigned short flags;
|
unsigned short flags;
|
||||||
union {
|
union {
|
||||||
char sname[SMALLDNAME];
|
char sname[SMALLDNAME];
|
||||||
@@ -425,6 +439,14 @@ struct crec {
|
|||||||
#define F_KEYTAG (1u<<23)
|
#define F_KEYTAG (1u<<23)
|
||||||
#define F_SECSTAT (1u<<24)
|
#define F_SECSTAT (1u<<24)
|
||||||
#define F_NO_RR (1u<<25)
|
#define F_NO_RR (1u<<25)
|
||||||
|
#define F_IPSET (1u<<26)
|
||||||
|
#define F_NSIGMATCH (1u<<27)
|
||||||
|
|
||||||
|
/* Values of uid in crecs with F_CONFIG bit set. */
|
||||||
|
#define SRC_INTERFACE 0
|
||||||
|
#define SRC_CONFIG 1
|
||||||
|
#define SRC_HOSTS 2
|
||||||
|
#define SRC_AH 3
|
||||||
|
|
||||||
|
|
||||||
/* struct sockaddr is not large enough to hold any address,
|
/* struct sockaddr is not large enough to hold any address,
|
||||||
@@ -458,6 +480,7 @@ union mysockaddr {
|
|||||||
#define SERV_USE_RESOLV 1024 /* forward this domain in the normal way */
|
#define SERV_USE_RESOLV 1024 /* forward this domain in the normal way */
|
||||||
#define SERV_NO_REBIND 2048 /* inhibit dns-rebind protection */
|
#define SERV_NO_REBIND 2048 /* inhibit dns-rebind protection */
|
||||||
#define SERV_FROM_FILE 4096 /* read from --servers-file */
|
#define SERV_FROM_FILE 4096 /* read from --servers-file */
|
||||||
|
#define SERV_LOOP 8192 /* server causes forwarding loop */
|
||||||
|
|
||||||
struct serverfd {
|
struct serverfd {
|
||||||
int fd;
|
int fd;
|
||||||
@@ -478,6 +501,9 @@ struct server {
|
|||||||
char *domain; /* set if this server only handles a domain. */
|
char *domain; /* set if this server only handles a domain. */
|
||||||
int flags, tcpfd;
|
int flags, tcpfd;
|
||||||
unsigned int queries, failed_queries;
|
unsigned int queries, failed_queries;
|
||||||
|
#ifdef HAVE_LOOP
|
||||||
|
u32 uid;
|
||||||
|
#endif
|
||||||
struct server *next;
|
struct server *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -524,7 +550,7 @@ struct hostsfile {
|
|||||||
struct hostsfile *next;
|
struct hostsfile *next;
|
||||||
int flags;
|
int flags;
|
||||||
char *fname;
|
char *fname;
|
||||||
int index; /* matches to cache entries for logging */
|
unsigned int index; /* matches to cache entries for logging */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -621,6 +647,8 @@ struct dhcp_lease {
|
|||||||
unsigned char *extradata;
|
unsigned char *extradata;
|
||||||
unsigned int extradata_len, extradata_size;
|
unsigned int extradata_len, extradata_size;
|
||||||
int last_interface;
|
int last_interface;
|
||||||
|
int new_interface; /* save possible originated interface */
|
||||||
|
int new_prefixlen; /* and its prefix length */
|
||||||
#ifdef HAVE_DHCP6
|
#ifdef HAVE_DHCP6
|
||||||
struct in6_addr addr6;
|
struct in6_addr addr6;
|
||||||
int iaid;
|
int iaid;
|
||||||
@@ -805,7 +833,7 @@ struct dhcp_context {
|
|||||||
#define CONTEXT_NETMASK (1u<<1)
|
#define CONTEXT_NETMASK (1u<<1)
|
||||||
#define CONTEXT_BRDCAST (1u<<2)
|
#define CONTEXT_BRDCAST (1u<<2)
|
||||||
#define CONTEXT_PROXY (1u<<3)
|
#define CONTEXT_PROXY (1u<<3)
|
||||||
#define CONTEXT_RA_ONLY (1u<<4)
|
#define CONTEXT_RA_ROUTER (1u<<4)
|
||||||
#define CONTEXT_RA_DONE (1u<<5)
|
#define CONTEXT_RA_DONE (1u<<5)
|
||||||
#define CONTEXT_RA_NAME (1u<<6)
|
#define CONTEXT_RA_NAME (1u<<6)
|
||||||
#define CONTEXT_RA_STATELESS (1u<<7)
|
#define CONTEXT_RA_STATELESS (1u<<7)
|
||||||
@@ -820,7 +848,6 @@ struct dhcp_context {
|
|||||||
#define CONTEXT_OLD (1u<<16)
|
#define CONTEXT_OLD (1u<<16)
|
||||||
#define CONTEXT_V6 (1u<<17)
|
#define CONTEXT_V6 (1u<<17)
|
||||||
|
|
||||||
|
|
||||||
struct ping_result {
|
struct ping_result {
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
time_t time;
|
time_t time;
|
||||||
@@ -966,6 +993,7 @@ extern struct daemon {
|
|||||||
pid_t tcp_pids[MAX_PROCS];
|
pid_t tcp_pids[MAX_PROCS];
|
||||||
struct randfd randomsocks[RANDOM_SOCKS];
|
struct randfd randomsocks[RANDOM_SOCKS];
|
||||||
int v6pktinfo;
|
int v6pktinfo;
|
||||||
|
struct addrlist *interface_addrs; /* list of all addresses/prefix lengths associated with all local interfaces */
|
||||||
|
|
||||||
/* DHCP state */
|
/* DHCP state */
|
||||||
int dhcpfd, helperfd, pxefd;
|
int dhcpfd, helperfd, pxefd;
|
||||||
@@ -1003,7 +1031,7 @@ extern struct daemon {
|
|||||||
/* cache.c */
|
/* cache.c */
|
||||||
void cache_init(void);
|
void cache_init(void);
|
||||||
void log_query(unsigned int flags, char *name, struct all_addr *addr, char *arg);
|
void log_query(unsigned int flags, char *name, struct all_addr *addr, char *arg);
|
||||||
char *record_source(int index);
|
char *record_source(unsigned int index);
|
||||||
char *querystr(char *desc, unsigned short type);
|
char *querystr(char *desc, unsigned short type);
|
||||||
struct crec *cache_find_by_addr(struct crec *crecp,
|
struct crec *cache_find_by_addr(struct crec *crecp,
|
||||||
struct all_addr *addr, time_t now,
|
struct all_addr *addr, time_t now,
|
||||||
@@ -1019,6 +1047,7 @@ void cache_add_dhcp_entry(char *host_name, int prot, struct all_addr *host_addre
|
|||||||
struct in_addr a_record_from_hosts(char *name, time_t now);
|
struct in_addr a_record_from_hosts(char *name, time_t now);
|
||||||
void cache_unhash_dhcp(void);
|
void cache_unhash_dhcp(void);
|
||||||
void dump_cache(time_t now);
|
void dump_cache(time_t now);
|
||||||
|
int cache_make_stat(struct txt_record *t);
|
||||||
char *cache_get_name(struct crec *crecp);
|
char *cache_get_name(struct crec *crecp);
|
||||||
char *cache_get_cname_target(struct crec *crecp);
|
char *cache_get_cname_target(struct crec *crecp);
|
||||||
struct crec *cache_enumerate(int init);
|
struct crec *cache_enumerate(int init);
|
||||||
@@ -1100,6 +1129,7 @@ unsigned char* hash_questions(struct dns_header *header, size_t plen, char *name
|
|||||||
/* util.c */
|
/* util.c */
|
||||||
void rand_init(void);
|
void rand_init(void);
|
||||||
unsigned short rand16(void);
|
unsigned short rand16(void);
|
||||||
|
u32 rand32(void);
|
||||||
u64 rand64(void);
|
u64 rand64(void);
|
||||||
int legal_hostname(char *c);
|
int legal_hostname(char *c);
|
||||||
char *canonicalise(char *s, int *nomem);
|
char *canonicalise(char *s, int *nomem);
|
||||||
@@ -1111,6 +1141,7 @@ int sa_len(union mysockaddr *addr);
|
|||||||
int sockaddr_isequal(union mysockaddr *s1, union mysockaddr *s2);
|
int sockaddr_isequal(union mysockaddr *s1, union mysockaddr *s2);
|
||||||
int hostname_isequal(const char *a, const char *b);
|
int hostname_isequal(const char *a, const char *b);
|
||||||
time_t dnsmasq_time(void);
|
time_t dnsmasq_time(void);
|
||||||
|
int netmask_length(struct in_addr mask);
|
||||||
int is_same_net(struct in_addr a, struct in_addr b, struct in_addr mask);
|
int is_same_net(struct in_addr a, struct in_addr b, struct in_addr mask);
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
int is_same_net6(struct in6_addr *a, struct in6_addr *b, int prefixlen);
|
int is_same_net6(struct in6_addr *a, struct in6_addr *b, int prefixlen);
|
||||||
@@ -1130,6 +1161,7 @@ void bump_maxfd(int fd, int *max);
|
|||||||
int read_write(int fd, unsigned char *packet, int size, int rw);
|
int read_write(int fd, unsigned char *packet, int size, int rw);
|
||||||
|
|
||||||
int wildcard_match(const char* wildcard, const char* match);
|
int wildcard_match(const char* wildcard, const char* match);
|
||||||
|
int wildcard_matchn(const char* wildcard, const char* match, int num);
|
||||||
|
|
||||||
/* log.c */
|
/* log.c */
|
||||||
void die(char *message, char *arg1, int exit_code);
|
void die(char *message, char *arg1, int exit_code);
|
||||||
@@ -1162,6 +1194,9 @@ struct frec *get_new_frec(time_t now, int *wait, int force);
|
|||||||
int send_from(int fd, int nowild, char *packet, size_t len,
|
int send_from(int fd, int nowild, char *packet, size_t len,
|
||||||
union mysockaddr *to, struct all_addr *source,
|
union mysockaddr *to, struct all_addr *source,
|
||||||
unsigned int iface);
|
unsigned int iface);
|
||||||
|
void resend_query();
|
||||||
|
struct randfd *allocate_rfd(int family);
|
||||||
|
void free_rfd(struct randfd *rfd);
|
||||||
|
|
||||||
/* network.c */
|
/* network.c */
|
||||||
int indextoname(int fd, int index, char *name);
|
int indextoname(int fd, int index, char *name);
|
||||||
@@ -1269,15 +1304,15 @@ unsigned char *extended_hwaddr(int hwtype, int hwlen, unsigned char *hwaddr,
|
|||||||
int make_icmp_sock(void);
|
int make_icmp_sock(void);
|
||||||
int icmp_ping(struct in_addr addr);
|
int icmp_ping(struct in_addr addr);
|
||||||
#endif
|
#endif
|
||||||
|
void queue_event(int event);
|
||||||
void send_alarm(time_t event, time_t now);
|
void send_alarm(time_t event, time_t now);
|
||||||
void send_event(int fd, int event, int data, char *msg);
|
void send_event(int fd, int event, int data, char *msg);
|
||||||
void clear_cache_and_reload(time_t now);
|
void clear_cache_and_reload(time_t now);
|
||||||
void poll_resolv(int force, int do_reload, time_t now);
|
|
||||||
|
|
||||||
/* netlink.c */
|
/* netlink.c */
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_LINUX_NETWORK
|
||||||
void netlink_init(void);
|
void netlink_init(void);
|
||||||
void netlink_multicast(time_t now);
|
void netlink_multicast(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* bpf.c */
|
/* bpf.c */
|
||||||
@@ -1286,7 +1321,7 @@ void init_bpf(void);
|
|||||||
void send_via_bpf(struct dhcp_packet *mess, size_t len,
|
void send_via_bpf(struct dhcp_packet *mess, size_t len,
|
||||||
struct in_addr iface_addr, struct ifreq *ifr);
|
struct in_addr iface_addr, struct ifreq *ifr);
|
||||||
void route_init(void);
|
void route_init(void);
|
||||||
void route_sock(time_t now);
|
void route_sock(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* bpf.c or netlink.c */
|
/* bpf.c or netlink.c */
|
||||||
@@ -1427,3 +1462,10 @@ void slaac_add_addrs(struct dhcp_lease *lease, time_t now, int force);
|
|||||||
time_t periodic_slaac(time_t now, struct dhcp_lease *leases);
|
time_t periodic_slaac(time_t now, struct dhcp_lease *leases);
|
||||||
void slaac_ping_reply(struct in6_addr *sender, unsigned char *packet, char *interface, struct dhcp_lease *leases);
|
void slaac_ping_reply(struct in6_addr *sender, unsigned char *packet, char *interface, struct dhcp_lease *leases);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* loop.c */
|
||||||
|
#ifdef HAVE_LOOP
|
||||||
|
void loop_send_probes();
|
||||||
|
int detect_loop(char *query, int type);
|
||||||
|
#endif
|
||||||
|
|
||||||
+37
-16
@@ -26,7 +26,14 @@
|
|||||||
# include <nettle/ecc-curve.h>
|
# include <nettle/ecc-curve.h>
|
||||||
#endif
|
#endif
|
||||||
#include <nettle/nettle-meta.h>
|
#include <nettle/nettle-meta.h>
|
||||||
#include <gmp.h>
|
#include <nettle/bignum.h>
|
||||||
|
|
||||||
|
/* Nettle-3.0 moved to a new API for DSA. We use a name that's defined in the new API
|
||||||
|
to detect Nettle-3, and invoke the backwards compatibility mode. */
|
||||||
|
#ifdef dsa_params_init
|
||||||
|
#include <nettle/dsa-compat.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define SERIAL_UNDEF -100
|
#define SERIAL_UNDEF -100
|
||||||
#define SERIAL_EQ 0
|
#define SERIAL_EQ 0
|
||||||
@@ -120,8 +127,8 @@ static int hash_init(const struct nettle_hash *hash, void **ctxp, unsigned char
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rsa_verify(struct blockdata *key_data, unsigned int key_len, unsigned char *sig, size_t sig_len,
|
static int dnsmasq_rsa_verify(struct blockdata *key_data, unsigned int key_len, unsigned char *sig, size_t sig_len,
|
||||||
unsigned char *digest, int algo)
|
unsigned char *digest, int algo)
|
||||||
{
|
{
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
size_t exp_len;
|
size_t exp_len;
|
||||||
@@ -172,8 +179,8 @@ static int rsa_verify(struct blockdata *key_data, unsigned int key_len, unsigned
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int dsa_verify(struct blockdata *key_data, unsigned int key_len, unsigned char *sig, size_t sig_len,
|
static int dnsmasq_dsa_verify(struct blockdata *key_data, unsigned int key_len, unsigned char *sig, size_t sig_len,
|
||||||
unsigned char *digest, int algo)
|
unsigned char *digest, int algo)
|
||||||
{
|
{
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
unsigned int t;
|
unsigned int t;
|
||||||
@@ -292,10 +299,10 @@ static int verify(struct blockdata *key_data, unsigned int key_len, unsigned cha
|
|||||||
switch (algo)
|
switch (algo)
|
||||||
{
|
{
|
||||||
case 1: case 5: case 7: case 8: case 10:
|
case 1: case 5: case 7: case 8: case 10:
|
||||||
return rsa_verify(key_data, key_len, sig, sig_len, digest, algo);
|
return dnsmasq_rsa_verify(key_data, key_len, sig, sig_len, digest, algo);
|
||||||
|
|
||||||
case 3: case 6:
|
case 3: case 6:
|
||||||
return dsa_verify(key_data, key_len, sig, sig_len, digest, algo);
|
return dnsmasq_dsa_verify(key_data, key_len, sig, sig_len, digest, algo);
|
||||||
|
|
||||||
#ifndef NO_NETTLE_ECC
|
#ifndef NO_NETTLE_ECC
|
||||||
case 13: case 14:
|
case 13: case 14:
|
||||||
@@ -390,7 +397,13 @@ static int serial_compare_32(unsigned long s1, unsigned long s2)
|
|||||||
/* Check whether today/now is between date_start and date_end */
|
/* Check whether today/now is between date_start and date_end */
|
||||||
static int check_date_range(unsigned long date_start, unsigned long date_end)
|
static int check_date_range(unsigned long date_start, unsigned long date_end)
|
||||||
{
|
{
|
||||||
unsigned long curtime = time(0);
|
unsigned long curtime;
|
||||||
|
|
||||||
|
/* Checking timestamps may be temporarily disabled */
|
||||||
|
if (option_bool(OPT_DNSSEC_TIME))
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
curtime = time(0);
|
||||||
|
|
||||||
/* We must explicitly check against wanted values, because of SERIAL_UNDEF */
|
/* We must explicitly check against wanted values, because of SERIAL_UNDEF */
|
||||||
return serial_compare_32(curtime, date_start) == SERIAL_GT
|
return serial_compare_32(curtime, date_start) == SERIAL_GT
|
||||||
@@ -827,7 +840,7 @@ static int validate_rrset(time_t now, struct dns_header *header, size_t plen, in
|
|||||||
for (; crecp; crecp = cache_find_by_name(crecp, keyname, now, F_DNSKEY))
|
for (; crecp; crecp = cache_find_by_name(crecp, keyname, now, F_DNSKEY))
|
||||||
if (crecp->addr.key.algo == algo &&
|
if (crecp->addr.key.algo == algo &&
|
||||||
crecp->addr.key.keytag == key_tag &&
|
crecp->addr.key.keytag == key_tag &&
|
||||||
crecp->uid == class &&
|
crecp->uid == (unsigned int)class &&
|
||||||
verify(crecp->addr.key.keydata, crecp->addr.key.keylen, sig, sig_len, digest, hash->digest_size, algo))
|
verify(crecp->addr.key.keydata, crecp->addr.key.keylen, sig, sig_len, digest, hash->digest_size, algo))
|
||||||
return (labels < name_labels) ? STAT_SECURE_WILDCARD : STAT_SECURE;
|
return (labels < name_labels) ? STAT_SECURE_WILDCARD : STAT_SECURE;
|
||||||
}
|
}
|
||||||
@@ -932,7 +945,7 @@ int dnssec_validate_by_ds(time_t now, struct dns_header *header, size_t plen, ch
|
|||||||
|
|
||||||
if (recp1->addr.ds.algo == algo &&
|
if (recp1->addr.ds.algo == algo &&
|
||||||
recp1->addr.ds.keytag == keytag &&
|
recp1->addr.ds.keytag == keytag &&
|
||||||
recp1->uid == class &&
|
recp1->uid == (unsigned int)class &&
|
||||||
(hash = hash_find(ds_digest_name(recp1->addr.ds.digest))) &&
|
(hash = hash_find(ds_digest_name(recp1->addr.ds.digest))) &&
|
||||||
hash_init(hash, &ctx, &digest))
|
hash_init(hash, &ctx, &digest))
|
||||||
|
|
||||||
@@ -1677,6 +1690,9 @@ int dnssec_validate_reply(time_t now, struct dns_header *header, size_t plen, ch
|
|||||||
GETSHORT(qclass, p1);
|
GETSHORT(qclass, p1);
|
||||||
ans_start = p1;
|
ans_start = p1;
|
||||||
|
|
||||||
|
if (qtype == T_ANY)
|
||||||
|
have_answer = 1;
|
||||||
|
|
||||||
/* Can't validate an RRISG query */
|
/* Can't validate an RRISG query */
|
||||||
if (qtype == T_RRSIG)
|
if (qtype == T_RRSIG)
|
||||||
return STAT_INSECURE;
|
return STAT_INSECURE;
|
||||||
@@ -1918,14 +1934,14 @@ int dnssec_validate_reply(time_t now, struct dns_header *header, size_t plen, ch
|
|||||||
int dnssec_chase_cname(time_t now, struct dns_header *header, size_t plen, char *name, char *keyname)
|
int dnssec_chase_cname(time_t now, struct dns_header *header, size_t plen, char *name, char *keyname)
|
||||||
{
|
{
|
||||||
unsigned char *p = (unsigned char *)(header+1);
|
unsigned char *p = (unsigned char *)(header+1);
|
||||||
int type, class, qtype, qclass, rdlen, j, rc;
|
int type, class, qclass, rdlen, j, rc;
|
||||||
int cname_count = CNAME_CHAIN;
|
int cname_count = CNAME_CHAIN;
|
||||||
|
|
||||||
/* Get question */
|
/* Get question */
|
||||||
if (!extract_name(header, plen, &p, name, 1, 4))
|
if (!extract_name(header, plen, &p, name, 1, 4))
|
||||||
return STAT_BOGUS;
|
return STAT_BOGUS;
|
||||||
|
|
||||||
GETSHORT(qtype, p);
|
p +=2; /* type */
|
||||||
GETSHORT(qclass, p);
|
GETSHORT(qclass, p);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
@@ -2126,7 +2142,7 @@ static int check_rrs(unsigned char *p, struct dns_header *header, size_t plen, i
|
|||||||
int i, type, class, rdlen;
|
int i, type, class, rdlen;
|
||||||
unsigned char *pp;
|
unsigned char *pp;
|
||||||
|
|
||||||
for (i = 0; i < ntohs(header->ancount) + ntohs(header->nscount); i++)
|
for (i = 0; i < ntohs(header->ancount) + ntohs(header->nscount) + ntohs(header->arcount); i++)
|
||||||
{
|
{
|
||||||
pp = p;
|
pp = p;
|
||||||
|
|
||||||
@@ -2172,7 +2188,7 @@ size_t filter_rrsigs(struct dns_header *header, size_t plen)
|
|||||||
static int rr_sz = 0;
|
static int rr_sz = 0;
|
||||||
|
|
||||||
unsigned char *p = (unsigned char *)(header+1);
|
unsigned char *p = (unsigned char *)(header+1);
|
||||||
int i, rdlen, qtype, qclass, rr_found, chop_an, chop_ns;
|
int i, rdlen, qtype, qclass, rr_found, chop_an, chop_ns, chop_ar;
|
||||||
|
|
||||||
if (ntohs(header->qdcount) != 1 ||
|
if (ntohs(header->qdcount) != 1 ||
|
||||||
!(p = skip_name(p, header, plen, 4)))
|
!(p = skip_name(p, header, plen, 4)))
|
||||||
@@ -2183,7 +2199,9 @@ size_t filter_rrsigs(struct dns_header *header, size_t plen)
|
|||||||
|
|
||||||
/* First pass, find pointers to start and end of all the records we wish to elide:
|
/* First pass, find pointers to start and end of all the records we wish to elide:
|
||||||
records added for DNSSEC, unless explicity queried for */
|
records added for DNSSEC, unless explicity queried for */
|
||||||
for (rr_found = 0, chop_ns = 0, chop_an = 0, i = 0; i < ntohs(header->ancount) + ntohs(header->nscount); i++)
|
for (rr_found = 0, chop_ns = 0, chop_an = 0, chop_ar = 0, i = 0;
|
||||||
|
i < ntohs(header->ancount) + ntohs(header->nscount) + ntohs(header->arcount);
|
||||||
|
i++)
|
||||||
{
|
{
|
||||||
unsigned char *pstart = p;
|
unsigned char *pstart = p;
|
||||||
int type, class;
|
int type, class;
|
||||||
@@ -2211,8 +2229,10 @@ size_t filter_rrsigs(struct dns_header *header, size_t plen)
|
|||||||
|
|
||||||
if (i < ntohs(header->ancount))
|
if (i < ntohs(header->ancount))
|
||||||
chop_an++;
|
chop_an++;
|
||||||
else
|
else if (i < (ntohs(header->nscount) + ntohs(header->ancount)))
|
||||||
chop_ns++;
|
chop_ns++;
|
||||||
|
else
|
||||||
|
chop_ar++;
|
||||||
}
|
}
|
||||||
else if (!ADD_RDLEN(header, p, plen, rdlen))
|
else if (!ADD_RDLEN(header, p, plen, rdlen))
|
||||||
return plen;
|
return plen;
|
||||||
@@ -2249,6 +2269,7 @@ size_t filter_rrsigs(struct dns_header *header, size_t plen)
|
|||||||
plen = p - (unsigned char *)header;
|
plen = p - (unsigned char *)header;
|
||||||
header->ancount = htons(ntohs(header->ancount) - chop_an);
|
header->ancount = htons(ntohs(header->ancount) - chop_an);
|
||||||
header->nscount = htons(ntohs(header->nscount) - chop_ns);
|
header->nscount = htons(ntohs(header->nscount) - chop_ns);
|
||||||
|
header->arcount = htons(ntohs(header->arcount) - chop_ar);
|
||||||
|
|
||||||
/* Fourth pass, fix up pointers in the remaining records */
|
/* Fourth pass, fix up pointers in the remaining records */
|
||||||
p = (unsigned char *)(header+1);
|
p = (unsigned char *)(header+1);
|
||||||
|
|||||||
+220
-73
@@ -22,7 +22,6 @@ static struct frec *lookup_frec_by_sender(unsigned short id,
|
|||||||
void *hash);
|
void *hash);
|
||||||
static unsigned short get_id(void);
|
static unsigned short get_id(void);
|
||||||
static void free_frec(struct frec *f);
|
static void free_frec(struct frec *f);
|
||||||
static struct randfd *allocate_rfd(int family);
|
|
||||||
|
|
||||||
#ifdef HAVE_DNSSEC
|
#ifdef HAVE_DNSSEC
|
||||||
static int tcp_key_recurse(time_t now, int status, struct dns_header *header, size_t n,
|
static int tcp_key_recurse(time_t now, int status, struct dns_header *header, size_t n,
|
||||||
@@ -278,7 +277,7 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
|
|||||||
blockdata_retrieve(forward->stash, forward->stash_len, (void *)header);
|
blockdata_retrieve(forward->stash, forward->stash_len, (void *)header);
|
||||||
plen = forward->stash_len;
|
plen = forward->stash_len;
|
||||||
|
|
||||||
if (forward->sentto->addr.sa.sa_family)
|
if (forward->sentto->addr.sa.sa_family == AF_INET)
|
||||||
log_query(F_DNSSEC | F_IPV4, "retry", (struct all_addr *)&forward->sentto->addr.in.sin_addr, "dnssec");
|
log_query(F_DNSSEC | F_IPV4, "retry", (struct all_addr *)&forward->sentto->addr.in.sin_addr, "dnssec");
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
else
|
else
|
||||||
@@ -299,7 +298,7 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
|
|||||||
|
|
||||||
while (sendto(fd, (char *)header, plen, 0,
|
while (sendto(fd, (char *)header, plen, 0,
|
||||||
&forward->sentto->addr.sa,
|
&forward->sentto->addr.sa,
|
||||||
sa_len(&forward->sentto->addr)) == -1 && retry_send());
|
sa_len(&forward->sentto->addr)) == -1 && retry_send());
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -427,7 +426,7 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
|
|||||||
|
|
||||||
if (type == (start->flags & SERV_TYPE) &&
|
if (type == (start->flags & SERV_TYPE) &&
|
||||||
(type != SERV_HAS_DOMAIN || hostname_isequal(domain, start->domain)) &&
|
(type != SERV_HAS_DOMAIN || hostname_isequal(domain, start->domain)) &&
|
||||||
!(start->flags & SERV_LITERAL_ADDRESS))
|
!(start->flags & (SERV_LITERAL_ADDRESS | SERV_LOOP)))
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
@@ -535,20 +534,23 @@ static size_t process_reply(struct dns_header *header, time_t now, struct server
|
|||||||
(void) do_bit;
|
(void) do_bit;
|
||||||
|
|
||||||
#ifdef HAVE_IPSET
|
#ifdef HAVE_IPSET
|
||||||
/* Similar algorithm to search_servers. */
|
if (daemon->ipsets && extract_request(header, n, daemon->namebuff, NULL))
|
||||||
struct ipsets *ipset_pos;
|
|
||||||
unsigned int namelen = strlen(daemon->namebuff);
|
|
||||||
unsigned int matchlen = 0;
|
|
||||||
for (ipset_pos = daemon->ipsets; ipset_pos; ipset_pos = ipset_pos->next)
|
|
||||||
{
|
{
|
||||||
unsigned int domainlen = strlen(ipset_pos->domain);
|
/* Similar algorithm to search_servers. */
|
||||||
char *matchstart = daemon->namebuff + namelen - domainlen;
|
struct ipsets *ipset_pos;
|
||||||
if (namelen >= domainlen && hostname_isequal(matchstart, ipset_pos->domain) &&
|
unsigned int namelen = strlen(daemon->namebuff);
|
||||||
(domainlen == 0 || namelen == domainlen || *(matchstart - 1) == '.' ) &&
|
unsigned int matchlen = 0;
|
||||||
domainlen >= matchlen)
|
for (ipset_pos = daemon->ipsets; ipset_pos; ipset_pos = ipset_pos->next)
|
||||||
{
|
{
|
||||||
matchlen = domainlen;
|
unsigned int domainlen = strlen(ipset_pos->domain);
|
||||||
sets = ipset_pos->sets;
|
char *matchstart = daemon->namebuff + namelen - domainlen;
|
||||||
|
if (namelen >= domainlen && hostname_isequal(matchstart, ipset_pos->domain) &&
|
||||||
|
(domainlen == 0 || namelen == domainlen || *(matchstart - 1) == '.' ) &&
|
||||||
|
domainlen >= matchlen)
|
||||||
|
{
|
||||||
|
matchlen = domainlen;
|
||||||
|
sets = ipset_pos->sets;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@@ -585,7 +587,7 @@ static size_t process_reply(struct dns_header *header, time_t now, struct server
|
|||||||
header->hb4 &= ~HB4_AD;
|
header->hb4 &= ~HB4_AD;
|
||||||
|
|
||||||
if (OPCODE(header) != QUERY || (RCODE(header) != NOERROR && RCODE(header) != NXDOMAIN))
|
if (OPCODE(header) != QUERY || (RCODE(header) != NOERROR && RCODE(header) != NXDOMAIN))
|
||||||
return n;
|
return resize_packet(header, n, pheader, plen);
|
||||||
|
|
||||||
/* Complain loudly if the upstream server is non-recursive. */
|
/* Complain loudly if the upstream server is non-recursive. */
|
||||||
if (!(header->hb4 & HB4_RA) && RCODE(header) == NOERROR && ntohs(header->ancount) == 0 &&
|
if (!(header->hb4 & HB4_RA) && RCODE(header) == NOERROR && ntohs(header->ancount) == 0 &&
|
||||||
@@ -698,13 +700,19 @@ void reply_query(int fd, int family, time_t now)
|
|||||||
serveraddr.in6.sin6_flowinfo = 0;
|
serveraddr.in6.sin6_flowinfo = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
header = (struct dns_header *)daemon->packet;
|
||||||
|
|
||||||
|
if (n < (int)sizeof(struct dns_header) || !(header->hb3 & HB3_QR))
|
||||||
|
return;
|
||||||
|
|
||||||
/* spoof check: answer must come from known server, */
|
/* spoof check: answer must come from known server, */
|
||||||
for (server = daemon->servers; server; server = server->next)
|
for (server = daemon->servers; server; server = server->next)
|
||||||
if (!(server->flags & (SERV_LITERAL_ADDRESS | SERV_NO_ADDR)) &&
|
if (!(server->flags & (SERV_LITERAL_ADDRESS | SERV_NO_ADDR)) &&
|
||||||
sockaddr_isequal(&server->addr, &serveraddr))
|
sockaddr_isequal(&server->addr, &serveraddr))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
header = (struct dns_header *)daemon->packet;
|
if (!server)
|
||||||
|
return;
|
||||||
|
|
||||||
#ifdef HAVE_DNSSEC
|
#ifdef HAVE_DNSSEC
|
||||||
hash = hash_questions(header, n, daemon->namebuff);
|
hash = hash_questions(header, n, daemon->namebuff);
|
||||||
@@ -713,9 +721,7 @@ void reply_query(int fd, int family, time_t now)
|
|||||||
crc = questions_crc(header, n, daemon->namebuff);
|
crc = questions_crc(header, n, daemon->namebuff);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!server ||
|
if (!(forward = lookup_frec(ntohs(header->id), hash)))
|
||||||
n < (int)sizeof(struct dns_header) || !(header->hb3 & HB3_QR) ||
|
|
||||||
!(forward = lookup_frec(ntohs(header->id), hash)))
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if ((RCODE(header) == SERVFAIL || RCODE(header) == REFUSED) &&
|
if ((RCODE(header) == SERVFAIL || RCODE(header) == REFUSED) &&
|
||||||
@@ -747,7 +753,7 @@ void reply_query(int fd, int family, time_t now)
|
|||||||
|
|
||||||
if ((forward->sentto->flags & SERV_TYPE) == 0)
|
if ((forward->sentto->flags & SERV_TYPE) == 0)
|
||||||
{
|
{
|
||||||
if (RCODE(header) == SERVFAIL || RCODE(header) == REFUSED)
|
if (RCODE(header) == REFUSED)
|
||||||
server = NULL;
|
server = NULL;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -770,8 +776,7 @@ void reply_query(int fd, int family, time_t now)
|
|||||||
we get a good reply from another server. Kill it when we've
|
we get a good reply from another server. Kill it when we've
|
||||||
had replies from all to avoid filling the forwarding table when
|
had replies from all to avoid filling the forwarding table when
|
||||||
everything is broken */
|
everything is broken */
|
||||||
if (forward->forwardall == 0 || --forward->forwardall == 1 ||
|
if (forward->forwardall == 0 || --forward->forwardall == 1 || RCODE(header) != SERVFAIL)
|
||||||
(RCODE(header) != REFUSED && RCODE(header) != SERVFAIL))
|
|
||||||
{
|
{
|
||||||
int check_rebind = 0, no_cache_dnssec = 0, cache_secure = 0;
|
int check_rebind = 0, no_cache_dnssec = 0, cache_secure = 0;
|
||||||
|
|
||||||
@@ -784,7 +789,7 @@ void reply_query(int fd, int family, time_t now)
|
|||||||
no_cache_dnssec = 1;
|
no_cache_dnssec = 1;
|
||||||
|
|
||||||
#ifdef HAVE_DNSSEC
|
#ifdef HAVE_DNSSEC
|
||||||
if (option_bool(OPT_DNSSEC_VALID) && !(forward->flags & FREC_CHECKING_DISABLED))
|
if (server && option_bool(OPT_DNSSEC_VALID) && !(forward->flags & FREC_CHECKING_DISABLED))
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
@@ -850,6 +855,7 @@ void reply_query(int fd, int family, time_t now)
|
|||||||
*new = *forward; /* copy everything, then overwrite */
|
*new = *forward; /* copy everything, then overwrite */
|
||||||
new->next = next;
|
new->next = next;
|
||||||
new->blocking_query = NULL;
|
new->blocking_query = NULL;
|
||||||
|
new->sentto = server;
|
||||||
new->rfd4 = NULL;
|
new->rfd4 = NULL;
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
new->rfd6 = NULL;
|
new->rfd6 = NULL;
|
||||||
@@ -1076,11 +1082,60 @@ void receive_query(struct listener *listen, time_t now)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
source_addr.sa.sa_family = listen->family;
|
source_addr.sa.sa_family = listen->family;
|
||||||
|
|
||||||
|
if (listen->family == AF_INET)
|
||||||
|
{
|
||||||
|
/* Source-port == 0 is an error, we can't send back to that.
|
||||||
|
http://www.ietf.org/mail-archive/web/dnsop/current/msg11441.html */
|
||||||
|
if (source_addr.in.sin_port == 0)
|
||||||
|
return;
|
||||||
|
}
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
if (listen->family == AF_INET6)
|
else
|
||||||
source_addr.in6.sin6_flowinfo = 0;
|
{
|
||||||
|
/* Source-port == 0 is an error, we can't send back to that. */
|
||||||
|
if (source_addr.in6.sin6_port == 0)
|
||||||
|
return;
|
||||||
|
source_addr.in6.sin6_flowinfo = 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* We can be configured to only accept queries from at-most-one-hop-away addresses. */
|
||||||
|
if (option_bool(OPT_LOCAL_SERVICE))
|
||||||
|
{
|
||||||
|
struct addrlist *addr;
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
if (listen->family == AF_INET6)
|
||||||
|
{
|
||||||
|
for (addr = daemon->interface_addrs; addr; addr = addr->next)
|
||||||
|
if ((addr->flags & ADDRLIST_IPV6) &&
|
||||||
|
is_same_net6(&addr->addr.addr.addr6, &source_addr.in6.sin6_addr, addr->prefixlen))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
struct in_addr netmask;
|
||||||
|
for (addr = daemon->interface_addrs; addr; addr = addr->next)
|
||||||
|
{
|
||||||
|
netmask.s_addr = htonl(~(in_addr_t)0 << (32 - addr->prefixlen));
|
||||||
|
if (!(addr->flags & ADDRLIST_IPV6) &&
|
||||||
|
is_same_net(addr->addr.addr.addr4, source_addr.in.sin_addr, netmask))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!addr)
|
||||||
|
{
|
||||||
|
static int warned = 0;
|
||||||
|
if (!warned)
|
||||||
|
{
|
||||||
|
my_syslog(LOG_WARNING, _("Ignoring query from non-local network"));
|
||||||
|
warned = 1;
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (check_dst)
|
if (check_dst)
|
||||||
{
|
{
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
@@ -1215,6 +1270,12 @@ void receive_query(struct listener *listen, time_t now)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LOOP
|
||||||
|
/* Check for forwarding loop */
|
||||||
|
if (detect_loop(daemon->namebuff, type))
|
||||||
|
return;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_AUTH
|
#ifdef HAVE_AUTH
|
||||||
@@ -1276,6 +1337,10 @@ static int send_check_sign(time_t now, struct dns_header *header, size_t plen, c
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Reached the root */
|
||||||
|
if (!name_start)
|
||||||
|
return STAT_BOGUS;
|
||||||
|
|
||||||
strcpy(keyname, name_start);
|
strcpy(keyname, name_start);
|
||||||
return STAT_NEED_DS_NEG;
|
return STAT_NEED_DS_NEG;
|
||||||
}
|
}
|
||||||
@@ -1287,13 +1352,20 @@ static int do_check_sign(time_t now, struct dns_header *header, size_t plen, cha
|
|||||||
{
|
{
|
||||||
char *name_start;
|
char *name_start;
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
int status = dnssec_validate_ds(now, header, plen, name, keyname, class);
|
int status;
|
||||||
|
|
||||||
if (status != STAT_INSECURE)
|
/* In this case only, a SERVFAIL reply allows us to continue up the tree, looking for a
|
||||||
|
suitable NSEC reply to DS queries. */
|
||||||
|
if (RCODE(header) != SERVFAIL)
|
||||||
{
|
{
|
||||||
if (status == STAT_NO_DS)
|
status = dnssec_validate_ds(now, header, plen, name, keyname, class);
|
||||||
status = STAT_INSECURE;
|
|
||||||
return status;
|
if (status != STAT_INSECURE)
|
||||||
|
{
|
||||||
|
if (status == STAT_NO_DS)
|
||||||
|
status = STAT_INSECURE;
|
||||||
|
return status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
p = (unsigned char *)(header+1);
|
p = (unsigned char *)(header+1);
|
||||||
@@ -1341,7 +1413,10 @@ static int tcp_check_for_unsigned_zone(time_t now, struct dns_header *header, s
|
|||||||
struct crec *crecp = cache_find_by_name(NULL, name_start, now, F_DS);
|
struct crec *crecp = cache_find_by_name(NULL, name_start, now, F_DS);
|
||||||
|
|
||||||
if (--(*keycount) == 0)
|
if (--(*keycount) == 0)
|
||||||
return STAT_BOGUS;
|
{
|
||||||
|
free(packet);
|
||||||
|
return STAT_BOGUS;
|
||||||
|
}
|
||||||
|
|
||||||
if (crecp && (crecp->flags & F_DNSSECOK))
|
if (crecp && (crecp->flags & F_DNSSECOK))
|
||||||
{
|
{
|
||||||
@@ -1357,46 +1432,60 @@ static int tcp_check_for_unsigned_zone(time_t now, struct dns_header *header, s
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* reached the root */
|
||||||
|
if (!name_start)
|
||||||
|
{
|
||||||
|
free(packet);
|
||||||
|
return STAT_BOGUS;
|
||||||
|
}
|
||||||
|
|
||||||
m = dnssec_generate_query(header, ((char *) header) + 65536, name_start, class, T_DS, &server->addr);
|
m = dnssec_generate_query(header, ((char *) header) + 65536, name_start, class, T_DS, &server->addr);
|
||||||
|
|
||||||
/* We rely on the question section coming back unchanged, ensure it is with the hash. */
|
/* We rely on the question section coming back unchanged, ensure it is with the hash. */
|
||||||
if ((newhash = hash_questions(header, (unsigned int)m, name)))
|
if ((newhash = hash_questions(header, (unsigned int)m, name)))
|
||||||
memcpy(hash, newhash, HASH_SIZE);
|
|
||||||
|
|
||||||
*length = htons(m);
|
|
||||||
|
|
||||||
if (read_write(server->tcpfd, packet, m + sizeof(u16), 0) &&
|
|
||||||
read_write(server->tcpfd, &c1, 1, 1) &&
|
|
||||||
read_write(server->tcpfd, &c2, 1, 1) &&
|
|
||||||
read_write(server->tcpfd, payload, (c1 << 8) | c2, 1))
|
|
||||||
{
|
{
|
||||||
m = (c1 << 8) | c2;
|
memcpy(hash, newhash, HASH_SIZE);
|
||||||
|
|
||||||
newhash = hash_questions(header, (unsigned int)m, name);
|
*length = htons(m);
|
||||||
if (newhash && memcmp(hash, newhash, HASH_SIZE) == 0)
|
|
||||||
|
if (read_write(server->tcpfd, packet, m + sizeof(u16), 0) &&
|
||||||
|
read_write(server->tcpfd, &c1, 1, 1) &&
|
||||||
|
read_write(server->tcpfd, &c2, 1, 1) &&
|
||||||
|
read_write(server->tcpfd, payload, (c1 << 8) | c2, 1))
|
||||||
{
|
{
|
||||||
/* Note this trashes all three name workspaces */
|
m = (c1 << 8) | c2;
|
||||||
status = tcp_key_recurse(now, STAT_NEED_DS_NEG, header, m, class, name, keyname, server, keycount);
|
|
||||||
|
|
||||||
/* We've found a DS which proves the bit of the DNS where the
|
newhash = hash_questions(header, (unsigned int)m, name);
|
||||||
original query is, is unsigned, so the answer is OK,
|
if (newhash && memcmp(hash, newhash, HASH_SIZE) == 0)
|
||||||
if unvalidated. */
|
|
||||||
if (status == STAT_NO_DS)
|
|
||||||
{
|
{
|
||||||
free(packet);
|
/* In this case only, a SERVFAIL reply allows us to continue up the tree, looking for a
|
||||||
return STAT_INSECURE;
|
suitable NSEC reply to DS queries. */
|
||||||
}
|
if (RCODE(header) == SERVFAIL)
|
||||||
|
status = STAT_INSECURE;
|
||||||
|
else
|
||||||
|
/* Note this trashes all three name workspaces */
|
||||||
|
status = tcp_key_recurse(now, STAT_NEED_DS_NEG, header, m, class, name, keyname, server, keycount);
|
||||||
|
|
||||||
/* No DS, not got to DNSSEC-land yet, go up. */
|
/* We've found a DS which proves the bit of the DNS where the
|
||||||
if (status == STAT_INSECURE)
|
original query is, is unsigned, so the answer is OK,
|
||||||
{
|
if unvalidated. */
|
||||||
p = (unsigned char *)(header+1);
|
if (status == STAT_NO_DS)
|
||||||
|
|
||||||
if (extract_name(header, plen, &p, name, 1, 4) &&
|
|
||||||
(name_start = strchr(name, '.')))
|
|
||||||
{
|
{
|
||||||
name_start++; /* chop a label off and try again */
|
free(packet);
|
||||||
continue;
|
return STAT_INSECURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No DS, not got to DNSSEC-land yet, go up. */
|
||||||
|
if (status == STAT_INSECURE)
|
||||||
|
{
|
||||||
|
p = (unsigned char *)(header+1);
|
||||||
|
|
||||||
|
if (extract_name(header, plen, &p, name, 1, 4) &&
|
||||||
|
(name_start = strchr(name, '.')))
|
||||||
|
{
|
||||||
|
name_start++; /* chop a label off and try again */
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1545,6 +1634,37 @@ unsigned char *tcp_request(int confd, time_t now,
|
|||||||
if (getpeername(confd, (struct sockaddr *)&peer_addr, &peer_len) == -1)
|
if (getpeername(confd, (struct sockaddr *)&peer_addr, &peer_len) == -1)
|
||||||
return packet;
|
return packet;
|
||||||
|
|
||||||
|
/* We can be configured to only accept queries from at-most-one-hop-away addresses. */
|
||||||
|
if (option_bool(OPT_LOCAL_SERVICE))
|
||||||
|
{
|
||||||
|
struct addrlist *addr;
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
if (peer_addr.sa.sa_family == AF_INET6)
|
||||||
|
{
|
||||||
|
for (addr = daemon->interface_addrs; addr; addr = addr->next)
|
||||||
|
if ((addr->flags & ADDRLIST_IPV6) &&
|
||||||
|
is_same_net6(&addr->addr.addr.addr6, &peer_addr.in6.sin6_addr, addr->prefixlen))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
struct in_addr netmask;
|
||||||
|
for (addr = daemon->interface_addrs; addr; addr = addr->next)
|
||||||
|
{
|
||||||
|
netmask.s_addr = htonl(~(in_addr_t)0 << (32 - addr->prefixlen));
|
||||||
|
if (!(addr->flags & ADDRLIST_IPV6) &&
|
||||||
|
is_same_net(addr->addr.addr.addr4, peer_addr.in.sin_addr, netmask))
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!addr)
|
||||||
|
{
|
||||||
|
my_syslog(LOG_WARNING, _("Ignoring query from non-local network"));
|
||||||
|
return packet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
if (!packet ||
|
if (!packet ||
|
||||||
@@ -1642,8 +1762,10 @@ unsigned char *tcp_request(int confd, time_t now,
|
|||||||
struct server *firstsendto = NULL;
|
struct server *firstsendto = NULL;
|
||||||
#ifdef HAVE_DNSSEC
|
#ifdef HAVE_DNSSEC
|
||||||
unsigned char *newhash, hash[HASH_SIZE];
|
unsigned char *newhash, hash[HASH_SIZE];
|
||||||
if ((newhash = hash_questions(header, (unsigned int)size, daemon->keyname)))
|
if ((newhash = hash_questions(header, (unsigned int)size, daemon->namebuff)))
|
||||||
memcpy(hash, newhash, HASH_SIZE);
|
memcpy(hash, newhash, HASH_SIZE);
|
||||||
|
else
|
||||||
|
memset(hash, 0, HASH_SIZE);
|
||||||
#else
|
#else
|
||||||
unsigned int crc = questions_crc(header, (unsigned int)size, daemon->namebuff);
|
unsigned int crc = questions_crc(header, (unsigned int)size, daemon->namebuff);
|
||||||
#endif
|
#endif
|
||||||
@@ -1665,7 +1787,8 @@ unsigned char *tcp_request(int confd, time_t now,
|
|||||||
|
|
||||||
/* server for wrong domain */
|
/* server for wrong domain */
|
||||||
if (type != (last_server->flags & SERV_TYPE) ||
|
if (type != (last_server->flags & SERV_TYPE) ||
|
||||||
(type == SERV_HAS_DOMAIN && !hostname_isequal(domain, last_server->domain)))
|
(type == SERV_HAS_DOMAIN && !hostname_isequal(domain, last_server->domain)) ||
|
||||||
|
(last_server->flags & (SERV_LITERAL_ADDRESS | SERV_LOOP)))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (last_server->tcpfd == -1)
|
if (last_server->tcpfd == -1)
|
||||||
@@ -1719,6 +1842,10 @@ unsigned char *tcp_request(int confd, time_t now,
|
|||||||
|
|
||||||
*length = htons(size);
|
*length = htons(size);
|
||||||
|
|
||||||
|
/* get query name again for logging - may have been overwritten */
|
||||||
|
if (!(gotname = extract_request(header, (unsigned int)size, daemon->namebuff, &qtype)))
|
||||||
|
strcpy(daemon->namebuff, "query");
|
||||||
|
|
||||||
if (!read_write(last_server->tcpfd, packet, size + sizeof(u16), 0) ||
|
if (!read_write(last_server->tcpfd, packet, size + sizeof(u16), 0) ||
|
||||||
!read_write(last_server->tcpfd, &c1, 1, 1) ||
|
!read_write(last_server->tcpfd, &c1, 1, 1) ||
|
||||||
!read_write(last_server->tcpfd, &c2, 1, 1) ||
|
!read_write(last_server->tcpfd, &c2, 1, 1) ||
|
||||||
@@ -1731,8 +1858,6 @@ unsigned char *tcp_request(int confd, time_t now,
|
|||||||
|
|
||||||
m = (c1 << 8) | c2;
|
m = (c1 << 8) | c2;
|
||||||
|
|
||||||
if (!gotname)
|
|
||||||
strcpy(daemon->namebuff, "query");
|
|
||||||
if (last_server->addr.sa.sa_family == AF_INET)
|
if (last_server->addr.sa.sa_family == AF_INET)
|
||||||
log_query(F_SERVER | F_IPV4 | F_FORWARD, daemon->namebuff,
|
log_query(F_SERVER | F_IPV4 | F_FORWARD, daemon->namebuff,
|
||||||
(struct all_addr *)&last_server->addr.in.sin_addr, NULL);
|
(struct all_addr *)&last_server->addr.in.sin_addr, NULL);
|
||||||
@@ -1839,7 +1964,7 @@ static struct frec *allocate_frec(time_t now)
|
|||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct randfd *allocate_rfd(int family)
|
struct randfd *allocate_rfd(int family)
|
||||||
{
|
{
|
||||||
static int finger = 0;
|
static int finger = 0;
|
||||||
int i;
|
int i;
|
||||||
@@ -1874,19 +1999,22 @@ static struct randfd *allocate_rfd(int family)
|
|||||||
|
|
||||||
return NULL; /* doom */
|
return NULL; /* doom */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void free_rfd(struct randfd *rfd)
|
||||||
|
{
|
||||||
|
if (rfd && --(rfd->refcount) == 0)
|
||||||
|
close(rfd->fd);
|
||||||
|
}
|
||||||
|
|
||||||
static void free_frec(struct frec *f)
|
static void free_frec(struct frec *f)
|
||||||
{
|
{
|
||||||
if (f->rfd4 && --(f->rfd4->refcount) == 0)
|
free_rfd(f->rfd4);
|
||||||
close(f->rfd4->fd);
|
|
||||||
|
|
||||||
f->rfd4 = NULL;
|
f->rfd4 = NULL;
|
||||||
f->sentto = NULL;
|
f->sentto = NULL;
|
||||||
f->flags = 0;
|
f->flags = 0;
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
if (f->rfd6 && --(f->rfd6->refcount) == 0)
|
free_rfd(f->rfd6);
|
||||||
close(f->rfd6->fd);
|
|
||||||
|
|
||||||
f->rfd6 = NULL;
|
f->rfd6 = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -2012,6 +2140,25 @@ static struct frec *lookup_frec_by_sender(unsigned short id,
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Send query packet again, if we can. */
|
||||||
|
void resend_query()
|
||||||
|
{
|
||||||
|
if (daemon->srv_save)
|
||||||
|
{
|
||||||
|
int fd;
|
||||||
|
|
||||||
|
if (daemon->srv_save->sfd)
|
||||||
|
fd = daemon->srv_save->sfd->fd;
|
||||||
|
else if (daemon->rfd_save && daemon->rfd_save->refcount != 0)
|
||||||
|
fd = daemon->rfd_save->fd;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
|
||||||
|
while(sendto(fd, daemon->packet, daemon->packet_len, 0,
|
||||||
|
&daemon->srv_save->addr.sa, sa_len(&daemon->srv_save->addr)) == -1 && retry_send());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/* A server record is going away, remove references to it */
|
/* A server record is going away, remove references to it */
|
||||||
void server_gone(struct server *server)
|
void server_gone(struct server *server)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
#include "dnsmasq.h"
|
#include "dnsmasq.h"
|
||||||
|
|
||||||
#ifdef HAVE_IPSET
|
#if defined(HAVE_IPSET) && defined(HAVE_LINUX_NETWORK)
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|||||||
+25
-5
@@ -352,15 +352,20 @@ static int find_interface_v4(struct in_addr local, int if_index, char *label,
|
|||||||
struct in_addr netmask, struct in_addr broadcast, void *vparam)
|
struct in_addr netmask, struct in_addr broadcast, void *vparam)
|
||||||
{
|
{
|
||||||
struct dhcp_lease *lease;
|
struct dhcp_lease *lease;
|
||||||
|
int prefix = netmask_length(netmask);
|
||||||
|
|
||||||
(void) label;
|
(void) label;
|
||||||
(void) broadcast;
|
(void) broadcast;
|
||||||
(void) vparam;
|
(void) vparam;
|
||||||
|
|
||||||
for (lease = leases; lease; lease = lease->next)
|
for (lease = leases; lease; lease = lease->next)
|
||||||
if (!(lease->flags & (LEASE_TA | LEASE_NA)))
|
if (!(lease->flags & (LEASE_TA | LEASE_NA)) &&
|
||||||
if (is_same_net(local, lease->addr, netmask))
|
is_same_net(local, lease->addr, netmask) &&
|
||||||
lease_set_interface(lease, if_index, *((time_t *)vparam));
|
prefix > lease->new_prefixlen)
|
||||||
|
{
|
||||||
|
lease->new_interface = if_index;
|
||||||
|
lease->new_prefixlen = prefix;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -376,11 +381,17 @@ static int find_interface_v6(struct in6_addr *local, int prefix,
|
|||||||
(void)flags;
|
(void)flags;
|
||||||
(void)preferred;
|
(void)preferred;
|
||||||
(void)valid;
|
(void)valid;
|
||||||
|
(void)vparam;
|
||||||
|
|
||||||
for (lease = leases; lease; lease = lease->next)
|
for (lease = leases; lease; lease = lease->next)
|
||||||
if ((lease->flags & (LEASE_TA | LEASE_NA)))
|
if ((lease->flags & (LEASE_TA | LEASE_NA)))
|
||||||
if (is_same_net6(local, &lease->addr6, prefix))
|
if (is_same_net6(local, &lease->addr6, prefix) && prefix > lease->new_prefixlen) {
|
||||||
lease_set_interface(lease, if_index, *((time_t *)vparam));
|
/* save prefix length for comparison, as we might get shorter matching
|
||||||
|
* prefix in upcoming netlink GETADDR responses
|
||||||
|
* */
|
||||||
|
lease->new_interface = if_index;
|
||||||
|
lease->new_prefixlen = prefix;
|
||||||
|
}
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -414,10 +425,19 @@ void lease_update_slaac(time_t now)
|
|||||||
start-time. */
|
start-time. */
|
||||||
void lease_find_interfaces(time_t now)
|
void lease_find_interfaces(time_t now)
|
||||||
{
|
{
|
||||||
|
struct dhcp_lease *lease;
|
||||||
|
|
||||||
|
for (lease = leases; lease; lease = lease->next)
|
||||||
|
lease->new_prefixlen = lease->new_interface = 0;
|
||||||
|
|
||||||
iface_enumerate(AF_INET, &now, find_interface_v4);
|
iface_enumerate(AF_INET, &now, find_interface_v4);
|
||||||
#ifdef HAVE_DHCP6
|
#ifdef HAVE_DHCP6
|
||||||
iface_enumerate(AF_INET6, &now, find_interface_v6);
|
iface_enumerate(AF_INET6, &now, find_interface_v6);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
for (lease = leases; lease; lease = lease->next)
|
||||||
|
if (lease->new_interface != 0)
|
||||||
|
lease_set_interface(lease, lease->new_interface, now);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_DHCP6
|
#ifdef HAVE_DHCP6
|
||||||
|
|||||||
+116
@@ -0,0 +1,116 @@
|
|||||||
|
/* dnsmasq is Copyright (c) 2000-2014 Simon Kelley
|
||||||
|
|
||||||
|
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
|
||||||
|
the Free Software Foundation; version 2 dated June, 1991, or
|
||||||
|
(at your option) version 3 dated 29 June, 2007.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "dnsmasq.h"
|
||||||
|
|
||||||
|
#ifdef HAVE_LOOP
|
||||||
|
static ssize_t loop_make_probe(u32 uid);
|
||||||
|
|
||||||
|
void loop_send_probes()
|
||||||
|
{
|
||||||
|
struct server *serv;
|
||||||
|
|
||||||
|
if (!option_bool(OPT_LOOP_DETECT))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/* Loop through all upstream servers not for particular domains, and send a query to that server which is
|
||||||
|
identifiable, via the uid. If we see that query back again, then the server is looping, and we should not use it. */
|
||||||
|
for (serv = daemon->servers; serv; serv = serv->next)
|
||||||
|
if (!(serv->flags &
|
||||||
|
(SERV_LITERAL_ADDRESS | SERV_NO_ADDR | SERV_USE_RESOLV | SERV_NO_REBIND | SERV_HAS_DOMAIN | SERV_FOR_NODOTS | SERV_LOOP)))
|
||||||
|
{
|
||||||
|
ssize_t len = loop_make_probe(serv->uid);
|
||||||
|
int fd;
|
||||||
|
struct randfd *rfd = NULL;
|
||||||
|
|
||||||
|
if (serv->sfd)
|
||||||
|
fd = serv->sfd->fd;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!(rfd = allocate_rfd(serv->addr.sa.sa_family)))
|
||||||
|
continue;
|
||||||
|
fd = rfd->fd;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (sendto(fd, daemon->packet, len, 0, &serv->addr.sa, sa_len(&serv->addr)) == -1 && retry_send());
|
||||||
|
|
||||||
|
free_rfd(rfd);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static ssize_t loop_make_probe(u32 uid)
|
||||||
|
{
|
||||||
|
struct dns_header *header = (struct dns_header *)daemon->packet;
|
||||||
|
unsigned char *p = (unsigned char *)(header+1);
|
||||||
|
|
||||||
|
/* packet buffer overwritten */
|
||||||
|
daemon->srv_save = NULL;
|
||||||
|
|
||||||
|
header->id = rand16();
|
||||||
|
header->ancount = header->nscount = header->arcount = htons(0);
|
||||||
|
header->qdcount = htons(1);
|
||||||
|
header->hb3 = HB3_RD;
|
||||||
|
header->hb4 = 0;
|
||||||
|
SET_OPCODE(header, QUERY);
|
||||||
|
|
||||||
|
*p++ = 8;
|
||||||
|
sprintf((char *)p, "%.8x", uid);
|
||||||
|
p += 8;
|
||||||
|
*p++ = strlen(LOOP_TEST_DOMAIN);
|
||||||
|
strcpy((char *)p, LOOP_TEST_DOMAIN); /* Add terminating zero */
|
||||||
|
p += strlen(LOOP_TEST_DOMAIN) + 1;
|
||||||
|
|
||||||
|
PUTSHORT(LOOP_TEST_TYPE, p);
|
||||||
|
PUTSHORT(C_IN, p);
|
||||||
|
|
||||||
|
return p - (unsigned char *)header;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int detect_loop(char *query, int type)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
u32 uid;
|
||||||
|
struct server *serv;
|
||||||
|
|
||||||
|
if (!option_bool(OPT_LOOP_DETECT))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
if (type != LOOP_TEST_TYPE ||
|
||||||
|
strlen(LOOP_TEST_DOMAIN) + 9 != strlen(query) ||
|
||||||
|
strstr(query, LOOP_TEST_DOMAIN) != query + 9)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
for (i = 0; i < 8; i++)
|
||||||
|
if (!isxdigit(query[i]))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
uid = strtol(query, NULL, 16);
|
||||||
|
|
||||||
|
for (serv = daemon->servers; serv; serv = serv->next)
|
||||||
|
if (!(serv->flags &
|
||||||
|
(SERV_LITERAL_ADDRESS | SERV_NO_ADDR | SERV_USE_RESOLV | SERV_NO_REBIND | SERV_HAS_DOMAIN | SERV_FOR_NODOTS | SERV_LOOP)) &&
|
||||||
|
uid == serv->uid)
|
||||||
|
{
|
||||||
|
serv->flags |= SERV_LOOP;
|
||||||
|
check_servers(); /* log new state */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
+12
-48
@@ -38,7 +38,7 @@
|
|||||||
static struct iovec iov;
|
static struct iovec iov;
|
||||||
static u32 netlink_pid;
|
static u32 netlink_pid;
|
||||||
|
|
||||||
static int nl_async(struct nlmsghdr *h);
|
static void nl_async(struct nlmsghdr *h);
|
||||||
|
|
||||||
void netlink_init(void)
|
void netlink_init(void)
|
||||||
{
|
{
|
||||||
@@ -142,7 +142,7 @@ int iface_enumerate(int family, void *parm, int (*callback)())
|
|||||||
struct nlmsghdr *h;
|
struct nlmsghdr *h;
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
static unsigned int seq = 0;
|
static unsigned int seq = 0;
|
||||||
int callback_ok = 1, newaddr = 0;
|
int callback_ok = 1;
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
struct nlmsghdr nlh;
|
struct nlmsghdr nlh;
|
||||||
@@ -191,21 +191,10 @@ int iface_enumerate(int family, void *parm, int (*callback)())
|
|||||||
if (h->nlmsg_seq != seq || h->nlmsg_pid != netlink_pid || h->nlmsg_type == NLMSG_ERROR)
|
if (h->nlmsg_seq != seq || h->nlmsg_pid != netlink_pid || h->nlmsg_type == NLMSG_ERROR)
|
||||||
{
|
{
|
||||||
/* May be multicast arriving async */
|
/* May be multicast arriving async */
|
||||||
if (nl_async(h))
|
nl_async(h);
|
||||||
{
|
|
||||||
newaddr = 1;
|
|
||||||
enumerate_interfaces(1); /* reset */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if (h->nlmsg_type == NLMSG_DONE)
|
else if (h->nlmsg_type == NLMSG_DONE)
|
||||||
{
|
return callback_ok;
|
||||||
/* handle async new interface address arrivals, these have to be done
|
|
||||||
after we complete as we're not re-entrant */
|
|
||||||
if (newaddr)
|
|
||||||
newaddress(dnsmasq_time());
|
|
||||||
|
|
||||||
return callback_ok;
|
|
||||||
}
|
|
||||||
else if (h->nlmsg_type == RTM_NEWADDR && family != AF_UNSPEC && family != AF_LOCAL)
|
else if (h->nlmsg_type == RTM_NEWADDR && family != AF_UNSPEC && family != AF_LOCAL)
|
||||||
{
|
{
|
||||||
struct ifaddrmsg *ifa = NLMSG_DATA(h);
|
struct ifaddrmsg *ifa = NLMSG_DATA(h);
|
||||||
@@ -219,7 +208,8 @@ int iface_enumerate(int family, void *parm, int (*callback)())
|
|||||||
struct in_addr netmask, addr, broadcast;
|
struct in_addr netmask, addr, broadcast;
|
||||||
char *label = NULL;
|
char *label = NULL;
|
||||||
|
|
||||||
netmask.s_addr = htonl(0xffffffff << (32 - ifa->ifa_prefixlen));
|
netmask.s_addr = htonl(~(in_addr_t)0 << (32 - ifa->ifa_prefixlen));
|
||||||
|
|
||||||
addr.s_addr = 0;
|
addr.s_addr = 0;
|
||||||
broadcast.s_addr = 0;
|
broadcast.s_addr = 0;
|
||||||
|
|
||||||
@@ -330,11 +320,11 @@ int iface_enumerate(int family, void *parm, int (*callback)())
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void netlink_multicast(time_t now)
|
void netlink_multicast(void)
|
||||||
{
|
{
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
struct nlmsghdr *h;
|
struct nlmsghdr *h;
|
||||||
int flags, newaddr = 0;
|
int flags;
|
||||||
|
|
||||||
/* don't risk blocking reading netlink messages here. */
|
/* don't risk blocking reading netlink messages here. */
|
||||||
if ((flags = fcntl(daemon->netlinkfd, F_GETFL)) == -1 ||
|
if ((flags = fcntl(daemon->netlinkfd, F_GETFL)) == -1 ||
|
||||||
@@ -343,24 +333,19 @@ void netlink_multicast(time_t now)
|
|||||||
|
|
||||||
if ((len = netlink_recv()) != -1)
|
if ((len = netlink_recv()) != -1)
|
||||||
for (h = (struct nlmsghdr *)iov.iov_base; NLMSG_OK(h, (size_t)len); h = NLMSG_NEXT(h, len))
|
for (h = (struct nlmsghdr *)iov.iov_base; NLMSG_OK(h, (size_t)len); h = NLMSG_NEXT(h, len))
|
||||||
if (nl_async(h))
|
nl_async(h);
|
||||||
newaddr = 1;
|
|
||||||
|
|
||||||
/* restore non-blocking status */
|
/* restore non-blocking status */
|
||||||
fcntl(daemon->netlinkfd, F_SETFL, flags);
|
fcntl(daemon->netlinkfd, F_SETFL, flags);
|
||||||
|
|
||||||
if (newaddr)
|
|
||||||
newaddress(now);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nl_async(struct nlmsghdr *h)
|
static void nl_async(struct nlmsghdr *h)
|
||||||
{
|
{
|
||||||
if (h->nlmsg_type == NLMSG_ERROR)
|
if (h->nlmsg_type == NLMSG_ERROR)
|
||||||
{
|
{
|
||||||
struct nlmsgerr *err = NLMSG_DATA(h);
|
struct nlmsgerr *err = NLMSG_DATA(h);
|
||||||
if (err->error != 0)
|
if (err->error != 0)
|
||||||
my_syslog(LOG_ERR, _("netlink returns error: %s"), strerror(-(err->error)));
|
my_syslog(LOG_ERR, _("netlink returns error: %s"), strerror(-(err->error)));
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
else if (h->nlmsg_pid == 0 && h->nlmsg_type == RTM_NEWROUTE)
|
else if (h->nlmsg_pid == 0 && h->nlmsg_type == RTM_NEWROUTE)
|
||||||
{
|
{
|
||||||
@@ -372,31 +357,10 @@ static int nl_async(struct nlmsghdr *h)
|
|||||||
struct rtmsg *rtm = NLMSG_DATA(h);
|
struct rtmsg *rtm = NLMSG_DATA(h);
|
||||||
|
|
||||||
if (rtm->rtm_type == RTN_UNICAST && rtm->rtm_scope == RT_SCOPE_LINK)
|
if (rtm->rtm_type == RTN_UNICAST && rtm->rtm_scope == RT_SCOPE_LINK)
|
||||||
{
|
queue_event(EVENT_NEWROUTE);
|
||||||
/* Force re-reading resolv file right now, for luck. */
|
|
||||||
daemon->last_resolv = 0;
|
|
||||||
|
|
||||||
if (daemon->srv_save)
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
|
|
||||||
if (daemon->srv_save->sfd)
|
|
||||||
fd = daemon->srv_save->sfd->fd;
|
|
||||||
else if (daemon->rfd_save && daemon->rfd_save->refcount != 0)
|
|
||||||
fd = daemon->rfd_save->fd;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
while(sendto(fd, daemon->packet, daemon->packet_len, 0,
|
|
||||||
&daemon->srv_save->addr.sa, sa_len(&daemon->srv_save->addr)) == -1 && retry_send());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
else if (h->nlmsg_type == RTM_NEWADDR || h->nlmsg_type == RTM_DELADDR)
|
else if (h->nlmsg_type == RTM_NEWADDR || h->nlmsg_type == RTM_DELADDR)
|
||||||
return 1; /* clever bind mode - rescan */
|
queue_event(EVENT_NEWADDR);
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
+66
-12
@@ -269,6 +269,39 @@ static int iface_allowed(struct iface_param *param, int if_index, char *label,
|
|||||||
if (!label)
|
if (!label)
|
||||||
label = ifr.ifr_name;
|
label = ifr.ifr_name;
|
||||||
|
|
||||||
|
/* maintain a list of all addresses on all interfaces for --local-service option */
|
||||||
|
if (option_bool(OPT_LOCAL_SERVICE))
|
||||||
|
{
|
||||||
|
struct addrlist *al;
|
||||||
|
|
||||||
|
if (param->spare)
|
||||||
|
{
|
||||||
|
al = param->spare;
|
||||||
|
param->spare = al->next;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
al = whine_malloc(sizeof(struct addrlist));
|
||||||
|
|
||||||
|
if (al)
|
||||||
|
{
|
||||||
|
al->next = daemon->interface_addrs;
|
||||||
|
daemon->interface_addrs = al;
|
||||||
|
al->prefixlen = prefixlen;
|
||||||
|
|
||||||
|
if (addr->sa.sa_family == AF_INET)
|
||||||
|
{
|
||||||
|
al->addr.addr.addr4 = addr->in.sin_addr;
|
||||||
|
al->flags = 0;
|
||||||
|
}
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
else
|
||||||
|
{
|
||||||
|
al->addr.addr.addr6 = addr->in6.sin6_addr;
|
||||||
|
al->flags = ADDRLIST_IPV6;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
if (addr->sa.sa_family != AF_INET6 || !IN6_IS_ADDR_LINKLOCAL(&addr->in6.sin6_addr))
|
if (addr->sa.sa_family != AF_INET6 || !IN6_IS_ADDR_LINKLOCAL(&addr->in6.sin6_addr))
|
||||||
@@ -518,7 +551,7 @@ static int iface_allowed_v4(struct in_addr local, int if_index, char *label,
|
|||||||
int enumerate_interfaces(int reset)
|
int enumerate_interfaces(int reset)
|
||||||
{
|
{
|
||||||
static struct addrlist *spare = NULL;
|
static struct addrlist *spare = NULL;
|
||||||
static int done = 0, active = 0;
|
static int done = 0;
|
||||||
struct iface_param param;
|
struct iface_param param;
|
||||||
int errsave, ret = 1;
|
int errsave, ret = 1;
|
||||||
struct addrlist *addr, *tmp;
|
struct addrlist *addr, *tmp;
|
||||||
@@ -537,14 +570,11 @@ int enumerate_interfaces(int reset)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (done || active)
|
if (done)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
done = 1;
|
done = 1;
|
||||||
|
|
||||||
/* protect against recusive calls from iface_enumerate(); */
|
|
||||||
active = 1;
|
|
||||||
|
|
||||||
if ((param.fd = socket(PF_INET, SOCK_DGRAM, 0)) == -1)
|
if ((param.fd = socket(PF_INET, SOCK_DGRAM, 0)) == -1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -565,6 +595,15 @@ int enumerate_interfaces(int reset)
|
|||||||
intname->addr = NULL;
|
intname->addr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Remove list of addresses of local interfaces */
|
||||||
|
for (addr = daemon->interface_addrs; addr; addr = tmp)
|
||||||
|
{
|
||||||
|
tmp = addr->next;
|
||||||
|
addr->next = spare;
|
||||||
|
spare = addr;
|
||||||
|
}
|
||||||
|
daemon->interface_addrs = NULL;
|
||||||
|
|
||||||
#ifdef HAVE_AUTH
|
#ifdef HAVE_AUTH
|
||||||
/* remove addresses stored against auth_zone subnets, but not
|
/* remove addresses stored against auth_zone subnets, but not
|
||||||
ones configured as address literals */
|
ones configured as address literals */
|
||||||
@@ -635,9 +674,7 @@ int enumerate_interfaces(int reset)
|
|||||||
}
|
}
|
||||||
|
|
||||||
errno = errsave;
|
errno = errsave;
|
||||||
|
|
||||||
spare = param.spare;
|
spare = param.spare;
|
||||||
active = 0;
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@@ -1260,8 +1297,14 @@ void mark_servers(int flag)
|
|||||||
|
|
||||||
/* mark everything with argument flag */
|
/* mark everything with argument flag */
|
||||||
for (serv = daemon->servers; serv; serv = serv->next)
|
for (serv = daemon->servers; serv; serv = serv->next)
|
||||||
if (serv->flags & flag)
|
{
|
||||||
serv->flags |= SERV_MARK;
|
if (serv->flags & flag)
|
||||||
|
serv->flags |= SERV_MARK;
|
||||||
|
#ifdef HAVE_LOOP
|
||||||
|
/* Give looped servers another chance */
|
||||||
|
serv->flags &= ~SERV_LOOP;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void cleanup_servers(void)
|
void cleanup_servers(void)
|
||||||
@@ -1283,6 +1326,11 @@ void cleanup_servers(void)
|
|||||||
else
|
else
|
||||||
up = &serv->next;
|
up = &serv->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_LOOP
|
||||||
|
/* Now we have a new set of servers, test for loops. */
|
||||||
|
loop_send_probes();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void add_update_server(int flags,
|
void add_update_server(int flags,
|
||||||
@@ -1348,6 +1396,9 @@ void add_update_server(int flags,
|
|||||||
serv->domain = domain_str;
|
serv->domain = domain_str;
|
||||||
serv->next = next;
|
serv->next = next;
|
||||||
serv->queries = serv->failed_queries = 0;
|
serv->queries = serv->failed_queries = 0;
|
||||||
|
#ifdef HAVE_LOOP
|
||||||
|
serv->uid = rand32();
|
||||||
|
#endif
|
||||||
|
|
||||||
if (domain)
|
if (domain)
|
||||||
serv->flags |= SERV_HAS_DOMAIN;
|
serv->flags |= SERV_HAS_DOMAIN;
|
||||||
@@ -1427,6 +1478,10 @@ void check_servers(void)
|
|||||||
else if (!(serv->flags & SERV_LITERAL_ADDRESS))
|
else if (!(serv->flags & SERV_LITERAL_ADDRESS))
|
||||||
my_syslog(LOG_INFO, _("using nameserver %s#%d for %s %s"), daemon->namebuff, port, s1, s2);
|
my_syslog(LOG_INFO, _("using nameserver %s#%d for %s %s"), daemon->namebuff, port, s1, s2);
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_LOOP
|
||||||
|
else if (serv->flags & SERV_LOOP)
|
||||||
|
my_syslog(LOG_INFO, _("NOT using nameserver %s#%d - query loop detected"), daemon->namebuff, port);
|
||||||
|
#endif
|
||||||
else if (serv->interface[0] != 0)
|
else if (serv->interface[0] != 0)
|
||||||
my_syslog(LOG_INFO, _("using nameserver %s#%d(via %s)"), daemon->namebuff, port, serv->interface);
|
my_syslog(LOG_INFO, _("using nameserver %s#%d(via %s)"), daemon->namebuff, port, serv->interface);
|
||||||
else
|
else
|
||||||
@@ -1522,13 +1577,13 @@ int reload_servers(char *fname)
|
|||||||
return gotone;
|
return gotone;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_LINUX_NETWORK) || defined(HAVE_BSD_NETWORK)
|
|
||||||
/* Called when addresses are added or deleted from an interface */
|
/* Called when addresses are added or deleted from an interface */
|
||||||
void newaddress(time_t now)
|
void newaddress(time_t now)
|
||||||
{
|
{
|
||||||
(void)now;
|
(void)now;
|
||||||
|
|
||||||
if (option_bool(OPT_CLEVERBIND) || daemon->doing_dhcp6 || daemon->relay6 || daemon->doing_ra)
|
if (option_bool(OPT_CLEVERBIND) || option_bool(OPT_LOCAL_SERVICE) ||
|
||||||
|
daemon->doing_dhcp6 || daemon->relay6 || daemon->doing_ra)
|
||||||
enumerate_interfaces(0);
|
enumerate_interfaces(0);
|
||||||
|
|
||||||
if (option_bool(OPT_CLEVERBIND))
|
if (option_bool(OPT_CLEVERBIND))
|
||||||
@@ -1546,7 +1601,6 @@ void newaddress(time_t now)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+157
-97
@@ -64,86 +64,89 @@ struct myoption {
|
|||||||
#define OPTSTRING "951yZDNLERKzowefnbvhdkqr:m:p:c:l:s:i:t:u:g:a:x:S:C:A:T:H:Q:I:B:F:G:O:M:X:V:U:j:P:J:W:Y:2:4:6:7:8:0:3:"
|
#define OPTSTRING "951yZDNLERKzowefnbvhdkqr:m:p:c:l:s:i:t:u:g:a:x:S:C:A:T:H:Q:I:B:F:G:O:M:X:V:U:j:P:J:W:Y:2:4:6:7:8:0:3:"
|
||||||
|
|
||||||
/* options which don't have a one-char version */
|
/* options which don't have a one-char version */
|
||||||
#define LOPT_RELOAD 256
|
#define LOPT_RELOAD 256
|
||||||
#define LOPT_NO_NAMES 257
|
#define LOPT_NO_NAMES 257
|
||||||
#define LOPT_TFTP 258
|
#define LOPT_TFTP 258
|
||||||
#define LOPT_SECURE 259
|
#define LOPT_SECURE 259
|
||||||
#define LOPT_PREFIX 260
|
#define LOPT_PREFIX 260
|
||||||
#define LOPT_PTR 261
|
#define LOPT_PTR 261
|
||||||
#define LOPT_BRIDGE 262
|
#define LOPT_BRIDGE 262
|
||||||
#define LOPT_TFTP_MAX 263
|
#define LOPT_TFTP_MAX 263
|
||||||
#define LOPT_FORCE 264
|
#define LOPT_FORCE 264
|
||||||
#define LOPT_NOBLOCK 265
|
#define LOPT_NOBLOCK 265
|
||||||
#define LOPT_LOG_OPTS 266
|
#define LOPT_LOG_OPTS 266
|
||||||
#define LOPT_MAX_LOGS 267
|
#define LOPT_MAX_LOGS 267
|
||||||
#define LOPT_CIRCUIT 268
|
#define LOPT_CIRCUIT 268
|
||||||
#define LOPT_REMOTE 269
|
#define LOPT_REMOTE 269
|
||||||
#define LOPT_SUBSCR 270
|
#define LOPT_SUBSCR 270
|
||||||
#define LOPT_INTNAME 271
|
#define LOPT_INTNAME 271
|
||||||
#define LOPT_BANK 272
|
#define LOPT_BANK 272
|
||||||
#define LOPT_DHCP_HOST 273
|
#define LOPT_DHCP_HOST 273
|
||||||
#define LOPT_APREF 274
|
#define LOPT_APREF 274
|
||||||
#define LOPT_OVERRIDE 275
|
#define LOPT_OVERRIDE 275
|
||||||
#define LOPT_TFTPPORTS 276
|
#define LOPT_TFTPPORTS 276
|
||||||
#define LOPT_REBIND 277
|
#define LOPT_REBIND 277
|
||||||
#define LOPT_NOLAST 278
|
#define LOPT_NOLAST 278
|
||||||
#define LOPT_OPTS 279
|
#define LOPT_OPTS 279
|
||||||
#define LOPT_DHCP_OPTS 280
|
#define LOPT_DHCP_OPTS 280
|
||||||
#define LOPT_MATCH 281
|
#define LOPT_MATCH 281
|
||||||
#define LOPT_BROADCAST 282
|
#define LOPT_BROADCAST 282
|
||||||
#define LOPT_NEGTTL 283
|
#define LOPT_NEGTTL 283
|
||||||
#define LOPT_ALTPORT 284
|
#define LOPT_ALTPORT 284
|
||||||
#define LOPT_SCRIPTUSR 285
|
#define LOPT_SCRIPTUSR 285
|
||||||
#define LOPT_LOCAL 286
|
#define LOPT_LOCAL 286
|
||||||
#define LOPT_NAPTR 287
|
#define LOPT_NAPTR 287
|
||||||
#define LOPT_MINPORT 288
|
#define LOPT_MINPORT 288
|
||||||
#define LOPT_DHCP_FQDN 289
|
#define LOPT_DHCP_FQDN 289
|
||||||
#define LOPT_CNAME 290
|
#define LOPT_CNAME 290
|
||||||
#define LOPT_PXE_PROMT 291
|
#define LOPT_PXE_PROMT 291
|
||||||
#define LOPT_PXE_SERV 292
|
#define LOPT_PXE_SERV 292
|
||||||
#define LOPT_TEST 293
|
#define LOPT_TEST 293
|
||||||
#define LOPT_TAG_IF 294
|
#define LOPT_TAG_IF 294
|
||||||
#define LOPT_PROXY 295
|
#define LOPT_PROXY 295
|
||||||
#define LOPT_GEN_NAMES 296
|
#define LOPT_GEN_NAMES 296
|
||||||
#define LOPT_MAXTTL 297
|
#define LOPT_MAXTTL 297
|
||||||
#define LOPT_NO_REBIND 298
|
#define LOPT_NO_REBIND 298
|
||||||
#define LOPT_LOC_REBND 299
|
#define LOPT_LOC_REBND 299
|
||||||
#define LOPT_ADD_MAC 300
|
#define LOPT_ADD_MAC 300
|
||||||
#define LOPT_DNSSEC 301
|
#define LOPT_DNSSEC 301
|
||||||
#define LOPT_INCR_ADDR 302
|
#define LOPT_INCR_ADDR 302
|
||||||
#define LOPT_CONNTRACK 303
|
#define LOPT_CONNTRACK 303
|
||||||
#define LOPT_FQDN 304
|
#define LOPT_FQDN 304
|
||||||
#define LOPT_LUASCRIPT 305
|
#define LOPT_LUASCRIPT 305
|
||||||
#define LOPT_RA 306
|
#define LOPT_RA 306
|
||||||
#define LOPT_DUID 307
|
#define LOPT_DUID 307
|
||||||
#define LOPT_HOST_REC 308
|
#define LOPT_HOST_REC 308
|
||||||
#define LOPT_TFTP_LC 309
|
#define LOPT_TFTP_LC 309
|
||||||
#define LOPT_RR 310
|
#define LOPT_RR 310
|
||||||
#define LOPT_CLVERBIND 311
|
#define LOPT_CLVERBIND 311
|
||||||
#define LOPT_MAXCTTL 312
|
#define LOPT_MAXCTTL 312
|
||||||
#define LOPT_AUTHZONE 313
|
#define LOPT_AUTHZONE 313
|
||||||
#define LOPT_AUTHSERV 314
|
#define LOPT_AUTHSERV 314
|
||||||
#define LOPT_AUTHTTL 315
|
#define LOPT_AUTHTTL 315
|
||||||
#define LOPT_AUTHSOA 316
|
#define LOPT_AUTHSOA 316
|
||||||
#define LOPT_AUTHSFS 317
|
#define LOPT_AUTHSFS 317
|
||||||
#define LOPT_AUTHPEER 318
|
#define LOPT_AUTHPEER 318
|
||||||
#define LOPT_IPSET 319
|
#define LOPT_IPSET 319
|
||||||
#define LOPT_SYNTH 320
|
#define LOPT_SYNTH 320
|
||||||
#ifdef OPTION6_PREFIX_CLASS
|
#ifdef OPTION6_PREFIX_CLASS
|
||||||
#define LOPT_PREF_CLSS 321
|
#define LOPT_PREF_CLSS 321
|
||||||
#endif
|
#endif
|
||||||
#define LOPT_RELAY 323
|
#define LOPT_RELAY 323
|
||||||
#define LOPT_RA_PARAM 324
|
#define LOPT_RA_PARAM 324
|
||||||
#define LOPT_ADD_SBNET 325
|
#define LOPT_ADD_SBNET 325
|
||||||
#define LOPT_QUIET_DHCP 326
|
#define LOPT_QUIET_DHCP 326
|
||||||
#define LOPT_QUIET_DHCP6 327
|
#define LOPT_QUIET_DHCP6 327
|
||||||
#define LOPT_QUIET_RA 328
|
#define LOPT_QUIET_RA 328
|
||||||
#define LOPT_SEC_VALID 329
|
#define LOPT_SEC_VALID 329
|
||||||
#define LOPT_TRUST_ANCHOR 330
|
#define LOPT_TRUST_ANCHOR 330
|
||||||
#define LOPT_DNSSEC_DEBUG 331
|
#define LOPT_DNSSEC_DEBUG 331
|
||||||
#define LOPT_REV_SERV 332
|
#define LOPT_REV_SERV 332
|
||||||
#define LOPT_SERVERS_FILE 333
|
#define LOPT_SERVERS_FILE 333
|
||||||
#define LOPT_DNSSEC_CHECK 334
|
#define LOPT_DNSSEC_CHECK 334
|
||||||
|
#define LOPT_LOCAL_SERVICE 335
|
||||||
|
#define LOPT_DNSSEC_TIME 336
|
||||||
|
#define LOPT_LOOP_DETECT 337
|
||||||
|
|
||||||
#ifdef HAVE_GETOPT_LONG
|
#ifdef HAVE_GETOPT_LONG
|
||||||
static const struct option opts[] =
|
static const struct option opts[] =
|
||||||
@@ -175,6 +178,7 @@ static const struct myoption opts[] =
|
|||||||
{ "domain-suffix", 1, 0, 's' },
|
{ "domain-suffix", 1, 0, 's' },
|
||||||
{ "interface", 1, 0, 'i' },
|
{ "interface", 1, 0, 'i' },
|
||||||
{ "listen-address", 1, 0, 'a' },
|
{ "listen-address", 1, 0, 'a' },
|
||||||
|
{ "local-service", 0, 0, LOPT_LOCAL_SERVICE },
|
||||||
{ "bogus-priv", 0, 0, 'b' },
|
{ "bogus-priv", 0, 0, 'b' },
|
||||||
{ "bogus-nxdomain", 1, 0, 'B' },
|
{ "bogus-nxdomain", 1, 0, 'B' },
|
||||||
{ "selfmx", 0, 0, 'e' },
|
{ "selfmx", 0, 0, 'e' },
|
||||||
@@ -285,6 +289,7 @@ static const struct myoption opts[] =
|
|||||||
{ "trust-anchor", 1, 0, LOPT_TRUST_ANCHOR },
|
{ "trust-anchor", 1, 0, LOPT_TRUST_ANCHOR },
|
||||||
{ "dnssec-debug", 0, 0, LOPT_DNSSEC_DEBUG },
|
{ "dnssec-debug", 0, 0, LOPT_DNSSEC_DEBUG },
|
||||||
{ "dnssec-check-unsigned", 0, 0, LOPT_DNSSEC_CHECK },
|
{ "dnssec-check-unsigned", 0, 0, LOPT_DNSSEC_CHECK },
|
||||||
|
{ "dnssec-no-timecheck", 0, 0, LOPT_DNSSEC_TIME },
|
||||||
#ifdef OPTION6_PREFIX_CLASS
|
#ifdef OPTION6_PREFIX_CLASS
|
||||||
{ "dhcp-prefix-class", 1, 0, LOPT_PREF_CLSS },
|
{ "dhcp-prefix-class", 1, 0, LOPT_PREF_CLSS },
|
||||||
#endif
|
#endif
|
||||||
@@ -293,6 +298,7 @@ static const struct myoption opts[] =
|
|||||||
{ "quiet-dhcp", 0, 0, LOPT_QUIET_DHCP },
|
{ "quiet-dhcp", 0, 0, LOPT_QUIET_DHCP },
|
||||||
{ "quiet-dhcp6", 0, 0, LOPT_QUIET_DHCP6 },
|
{ "quiet-dhcp6", 0, 0, LOPT_QUIET_DHCP6 },
|
||||||
{ "quiet-ra", 0, 0, LOPT_QUIET_RA },
|
{ "quiet-ra", 0, 0, LOPT_QUIET_RA },
|
||||||
|
{ "dns-loop-detect", 0, 0, LOPT_LOOP_DETECT },
|
||||||
{ NULL, 0, 0, 0 }
|
{ NULL, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -441,6 +447,7 @@ static struct {
|
|||||||
{ LOPT_TRUST_ANCHOR, ARG_DUP, "<domain>,[<class>],...", gettext_noop("Specify trust anchor key digest."), NULL },
|
{ LOPT_TRUST_ANCHOR, ARG_DUP, "<domain>,[<class>],...", gettext_noop("Specify trust anchor key digest."), NULL },
|
||||||
{ LOPT_DNSSEC_DEBUG, OPT_DNSSEC_DEBUG, NULL, gettext_noop("Disable upstream checking for DNSSEC debugging."), NULL },
|
{ LOPT_DNSSEC_DEBUG, OPT_DNSSEC_DEBUG, NULL, gettext_noop("Disable upstream checking for DNSSEC debugging."), NULL },
|
||||||
{ LOPT_DNSSEC_CHECK, OPT_DNSSEC_NO_SIGN, NULL, gettext_noop("Ensure answers without DNSSEC are in unsigned zones."), NULL },
|
{ LOPT_DNSSEC_CHECK, OPT_DNSSEC_NO_SIGN, NULL, gettext_noop("Ensure answers without DNSSEC are in unsigned zones."), NULL },
|
||||||
|
{ LOPT_DNSSEC_TIME, OPT_DNSSEC_TIME, NULL, gettext_noop("Don't check DNSSEC signature timestamps until first cache-reload"), NULL },
|
||||||
#ifdef OPTION6_PREFIX_CLASS
|
#ifdef OPTION6_PREFIX_CLASS
|
||||||
{ LOPT_PREF_CLSS, ARG_DUP, "set:tag,<class>", gettext_noop("Specify DHCPv6 prefix class"), NULL },
|
{ LOPT_PREF_CLSS, ARG_DUP, "set:tag,<class>", gettext_noop("Specify DHCPv6 prefix class"), NULL },
|
||||||
#endif
|
#endif
|
||||||
@@ -448,6 +455,8 @@ static struct {
|
|||||||
{ LOPT_QUIET_DHCP, OPT_QUIET_DHCP, NULL, gettext_noop("Do not log routine DHCP."), NULL },
|
{ LOPT_QUIET_DHCP, OPT_QUIET_DHCP, NULL, gettext_noop("Do not log routine DHCP."), NULL },
|
||||||
{ LOPT_QUIET_DHCP6, OPT_QUIET_DHCP6, NULL, gettext_noop("Do not log routine DHCPv6."), NULL },
|
{ LOPT_QUIET_DHCP6, OPT_QUIET_DHCP6, NULL, gettext_noop("Do not log routine DHCPv6."), NULL },
|
||||||
{ LOPT_QUIET_RA, OPT_QUIET_RA, NULL, gettext_noop("Do not log RA."), NULL },
|
{ LOPT_QUIET_RA, OPT_QUIET_RA, NULL, gettext_noop("Do not log RA."), NULL },
|
||||||
|
{ LOPT_LOCAL_SERVICE, OPT_LOCAL_SERVICE, NULL, gettext_noop("Accept queries only from directly-connected networks"), NULL },
|
||||||
|
{ LOPT_LOOP_DETECT, OPT_LOOP_DETECT, NULL, gettext_noop("Detect and remove DNS forwarding loops"), NULL },
|
||||||
{ 0, 0, NULL, NULL, NULL }
|
{ 0, 0, NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -612,19 +621,24 @@ static int atoi_check8(char *a, int *res)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void add_txt(char *name, char *txt)
|
static void add_txt(char *name, char *txt, int stat)
|
||||||
{
|
{
|
||||||
size_t len = strlen(txt);
|
|
||||||
struct txt_record *r = opt_malloc(sizeof(struct txt_record));
|
struct txt_record *r = opt_malloc(sizeof(struct txt_record));
|
||||||
|
|
||||||
|
if (txt)
|
||||||
|
{
|
||||||
|
size_t len = strlen(txt);
|
||||||
|
r->txt = opt_malloc(len+1);
|
||||||
|
r->len = len+1;
|
||||||
|
*(r->txt) = len;
|
||||||
|
memcpy((r->txt)+1, txt, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
r->stat = stat;
|
||||||
r->name = opt_string_alloc(name);
|
r->name = opt_string_alloc(name);
|
||||||
r->next = daemon->txt;
|
r->next = daemon->txt;
|
||||||
daemon->txt = r;
|
daemon->txt = r;
|
||||||
r->class = C_CHAOS;
|
r->class = C_CHAOS;
|
||||||
r->txt = opt_malloc(len+1);
|
|
||||||
r->len = len+1;
|
|
||||||
*(r->txt) = len;
|
|
||||||
memcpy((r->txt)+1, txt, len);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void do_usage(void)
|
static void do_usage(void)
|
||||||
@@ -1451,7 +1465,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
struct list {
|
struct list {
|
||||||
char *suffix;
|
char *suffix;
|
||||||
struct list *next;
|
struct list *next;
|
||||||
} *ignore_suffix = NULL, *li;
|
} *ignore_suffix = NULL, *match_suffix = NULL, *li;
|
||||||
|
|
||||||
comma = split(arg);
|
comma = split(arg);
|
||||||
if (!(directory = opt_string_alloc(arg)))
|
if (!(directory = opt_string_alloc(arg)))
|
||||||
@@ -1461,10 +1475,20 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
{
|
{
|
||||||
comma = split(arg);
|
comma = split(arg);
|
||||||
li = opt_malloc(sizeof(struct list));
|
li = opt_malloc(sizeof(struct list));
|
||||||
li->next = ignore_suffix;
|
if (*arg == '*')
|
||||||
ignore_suffix = li;
|
{
|
||||||
/* Have to copy: buffer is overwritten */
|
li->next = match_suffix;
|
||||||
li->suffix = opt_string_alloc(arg);
|
match_suffix = li;
|
||||||
|
/* Have to copy: buffer is overwritten */
|
||||||
|
li->suffix = opt_string_alloc(arg+1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
li->next = ignore_suffix;
|
||||||
|
ignore_suffix = li;
|
||||||
|
/* Have to copy: buffer is overwritten */
|
||||||
|
li->suffix = opt_string_alloc(arg);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (!(dir_stream = opendir(directory)))
|
if (!(dir_stream = opendir(directory)))
|
||||||
@@ -1482,6 +1506,20 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
ent->d_name[0] == '.')
|
ent->d_name[0] == '.')
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
if (match_suffix)
|
||||||
|
{
|
||||||
|
for (li = match_suffix; li; li = li->next)
|
||||||
|
{
|
||||||
|
/* check for required suffices */
|
||||||
|
size_t ls = strlen(li->suffix);
|
||||||
|
if (len > ls &&
|
||||||
|
strcmp(li->suffix, &ent->d_name[len - ls]) == 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!li)
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
for (li = ignore_suffix; li; li = li->next)
|
for (li = ignore_suffix; li; li = li->next)
|
||||||
{
|
{
|
||||||
/* check for proscribed suffices */
|
/* check for proscribed suffices */
|
||||||
@@ -1661,7 +1699,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
case 'H': /* --addn-hosts */
|
case 'H': /* --addn-hosts */
|
||||||
{
|
{
|
||||||
struct hostsfile *new = opt_malloc(sizeof(struct hostsfile));
|
struct hostsfile *new = opt_malloc(sizeof(struct hostsfile));
|
||||||
static int hosts_index = 1;
|
static unsigned int hosts_index = SRC_AH;
|
||||||
new->fname = opt_string_alloc(arg);
|
new->fname = opt_string_alloc(arg);
|
||||||
new->index = hosts_index++;
|
new->index = hosts_index++;
|
||||||
new->flags = 0;
|
new->flags = 0;
|
||||||
@@ -2160,6 +2198,9 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
{
|
{
|
||||||
newlist = opt_malloc(sizeof(struct server));
|
newlist = opt_malloc(sizeof(struct server));
|
||||||
memset(newlist, 0, sizeof(struct server));
|
memset(newlist, 0, sizeof(struct server));
|
||||||
|
#ifdef HAVE_LOOP
|
||||||
|
newlist->uid = rand32();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (servers_only && option == 'S')
|
if (servers_only && option == 'S')
|
||||||
@@ -2572,9 +2613,11 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
if (strcmp(a[leasepos], "static") == 0)
|
if (strcmp(a[leasepos], "static") == 0)
|
||||||
new->flags |= CONTEXT_STATIC | CONTEXT_DHCP;
|
new->flags |= CONTEXT_STATIC | CONTEXT_DHCP;
|
||||||
else if (strcmp(a[leasepos], "ra-only") == 0 || strcmp(a[leasepos], "slaac") == 0 )
|
else if (strcmp(a[leasepos], "ra-only") == 0 || strcmp(a[leasepos], "slaac") == 0 )
|
||||||
new->flags |= CONTEXT_RA_ONLY | CONTEXT_RA;
|
new->flags |= CONTEXT_RA;
|
||||||
else if (strcmp(a[leasepos], "ra-names") == 0)
|
else if (strcmp(a[leasepos], "ra-names") == 0)
|
||||||
new->flags |= CONTEXT_RA_NAME | CONTEXT_RA;
|
new->flags |= CONTEXT_RA_NAME | CONTEXT_RA;
|
||||||
|
else if (strcmp(a[leasepos], "ra-advrouter") == 0)
|
||||||
|
new->flags |= CONTEXT_RA_ROUTER | CONTEXT_RA;
|
||||||
else if (strcmp(a[leasepos], "ra-stateless") == 0)
|
else if (strcmp(a[leasepos], "ra-stateless") == 0)
|
||||||
new->flags |= CONTEXT_RA_STATELESS | CONTEXT_DHCP | CONTEXT_RA;
|
new->flags |= CONTEXT_RA_STATELESS | CONTEXT_DHCP | CONTEXT_RA;
|
||||||
else if (leasepos == 1 && inet_pton(AF_INET6, a[leasepos], &new->end6))
|
else if (leasepos == 1 && inet_pton(AF_INET6, a[leasepos], &new->end6))
|
||||||
@@ -2604,7 +2647,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
|
|
||||||
if (new->prefix != 64)
|
if (new->prefix != 64)
|
||||||
{
|
{
|
||||||
if ((new->flags & (CONTEXT_RA_ONLY | CONTEXT_RA_NAME | CONTEXT_RA_STATELESS)))
|
if (new->flags & CONTEXT_RA)
|
||||||
ret_err(_("prefix length must be exactly 64 for RA subnets"));
|
ret_err(_("prefix length must be exactly 64 for RA subnets"));
|
||||||
else if (new->flags & CONTEXT_TEMPLATE)
|
else if (new->flags & CONTEXT_TEMPLATE)
|
||||||
ret_err(_("prefix length must be exactly 64 for subnet constructors"));
|
ret_err(_("prefix length must be exactly 64 for subnet constructors"));
|
||||||
@@ -3606,6 +3649,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
new->next = daemon->txt;
|
new->next = daemon->txt;
|
||||||
daemon->txt = new;
|
daemon->txt = new;
|
||||||
new->class = C_IN;
|
new->class = C_IN;
|
||||||
|
new->stat = 0;
|
||||||
|
|
||||||
if (!(new->name = canonicalise_opt(arg)))
|
if (!(new->name = canonicalise_opt(arg)))
|
||||||
ret_err(_("bad TXT record"));
|
ret_err(_("bad TXT record"));
|
||||||
@@ -4017,10 +4061,11 @@ static int one_file(char *file, int hard_opt)
|
|||||||
/* expand any name which is a directory */
|
/* expand any name which is a directory */
|
||||||
struct hostsfile *expand_filelist(struct hostsfile *list)
|
struct hostsfile *expand_filelist(struct hostsfile *list)
|
||||||
{
|
{
|
||||||
int i;
|
unsigned int i;
|
||||||
struct hostsfile *ah;
|
struct hostsfile *ah;
|
||||||
|
|
||||||
for (i = 0, ah = list; ah; ah = ah->next)
|
/* find largest used index */
|
||||||
|
for (i = SRC_AH, ah = list; ah; ah = ah->next)
|
||||||
{
|
{
|
||||||
if (i <= ah->index)
|
if (i <= ah->index)
|
||||||
i = ah->index + 1;
|
i = ah->index + 1;
|
||||||
@@ -4254,9 +4299,19 @@ void read_opts(int argc, char **argv, char *compile_opts)
|
|||||||
daemon->soa_refresh = SOA_REFRESH;
|
daemon->soa_refresh = SOA_REFRESH;
|
||||||
daemon->soa_retry = SOA_RETRY;
|
daemon->soa_retry = SOA_RETRY;
|
||||||
daemon->soa_expiry = SOA_EXPIRY;
|
daemon->soa_expiry = SOA_EXPIRY;
|
||||||
add_txt("version.bind", "dnsmasq-" VERSION );
|
|
||||||
add_txt("authors.bind", "Simon Kelley");
|
add_txt("version.bind", "dnsmasq-" VERSION, 0 );
|
||||||
add_txt("copyright.bind", COPYRIGHT);
|
add_txt("authors.bind", "Simon Kelley", 0);
|
||||||
|
add_txt("copyright.bind", COPYRIGHT, 0);
|
||||||
|
add_txt("cachesize.bind", NULL, TXT_STAT_CACHESIZE);
|
||||||
|
add_txt("insertions.bind", NULL, TXT_STAT_INSERTS);
|
||||||
|
add_txt("evictions.bind", NULL, TXT_STAT_EVICTIONS);
|
||||||
|
add_txt("misses.bind", NULL, TXT_STAT_MISSES);
|
||||||
|
add_txt("hits.bind", NULL, TXT_STAT_HITS);
|
||||||
|
#ifdef HAVE_AUTH
|
||||||
|
add_txt("auth.bind", NULL, TXT_STAT_AUTH);
|
||||||
|
#endif
|
||||||
|
add_txt("servers.bind", NULL, TXT_STAT_SERVERS);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
@@ -4457,6 +4512,11 @@ void read_opts(int argc, char **argv, char *compile_opts)
|
|||||||
else if (option_bool(OPT_DHCP_FQDN))
|
else if (option_bool(OPT_DHCP_FQDN))
|
||||||
die(_("there must be a default domain when --dhcp-fqdn is set"), NULL, EC_BADCONF);
|
die(_("there must be a default domain when --dhcp-fqdn is set"), NULL, EC_BADCONF);
|
||||||
|
|
||||||
|
/* If there's access-control config, then ignore --local-service, it's intended
|
||||||
|
as a system default to keep otherwise unconfigured installations safe. */
|
||||||
|
if (daemon->if_names || daemon->if_except || daemon->if_addrs || daemon->authserver)
|
||||||
|
reset_option_bool(OPT_LOCAL_SERVICE);
|
||||||
|
|
||||||
if (testmode)
|
if (testmode)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "dnsmasq: %s.\n", _("syntax check OK"));
|
fprintf(stderr, "dnsmasq: %s.\n", _("syntax check OK"));
|
||||||
|
|||||||
@@ -49,6 +49,8 @@ struct prefix_opt {
|
|||||||
#define ICMP6_OPT_SOURCE_MAC 1
|
#define ICMP6_OPT_SOURCE_MAC 1
|
||||||
#define ICMP6_OPT_PREFIX 3
|
#define ICMP6_OPT_PREFIX 3
|
||||||
#define ICMP6_OPT_MTU 5
|
#define ICMP6_OPT_MTU 5
|
||||||
|
#define ICMP6_OPT_ADV_INTERVAL 7
|
||||||
|
#define ICMP6_OPT_RT_INFO 24
|
||||||
#define ICMP6_OPT_RDNSS 25
|
#define ICMP6_OPT_RDNSS 25
|
||||||
#define ICMP6_OPT_DNSSL 31
|
#define ICMP6_OPT_DNSSL 31
|
||||||
|
|
||||||
|
|||||||
+47
-20
@@ -28,11 +28,11 @@
|
|||||||
|
|
||||||
struct ra_param {
|
struct ra_param {
|
||||||
time_t now;
|
time_t now;
|
||||||
int ind, managed, other, found_context, first;
|
int ind, managed, other, found_context, first, adv_router;
|
||||||
char *if_name;
|
char *if_name;
|
||||||
struct dhcp_netid *tags;
|
struct dhcp_netid *tags;
|
||||||
struct in6_addr link_local, link_global, ula;
|
struct in6_addr link_local, link_global, ula;
|
||||||
unsigned int glob_pref_time, link_pref_time, ula_pref_time, adv_interval;
|
unsigned int glob_pref_time, link_pref_time, ula_pref_time, adv_interval, prio;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct search_param {
|
struct search_param {
|
||||||
@@ -211,27 +211,29 @@ static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *de
|
|||||||
FILE *f;
|
FILE *f;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
parm.ind = iface;
|
||||||
|
parm.managed = 0;
|
||||||
|
parm.other = 0;
|
||||||
|
parm.found_context = 0;
|
||||||
|
parm.adv_router = 0;
|
||||||
|
parm.if_name = iface_name;
|
||||||
|
parm.first = 1;
|
||||||
|
parm.now = now;
|
||||||
|
parm.glob_pref_time = parm.link_pref_time = parm.ula_pref_time = 0;
|
||||||
|
parm.adv_interval = calc_interval(ra_param);
|
||||||
|
parm.prio = calc_prio(ra_param);
|
||||||
|
|
||||||
save_counter(0);
|
save_counter(0);
|
||||||
ra = expand(sizeof(struct ra_packet));
|
ra = expand(sizeof(struct ra_packet));
|
||||||
|
|
||||||
ra->type = ND_ROUTER_ADVERT;
|
ra->type = ND_ROUTER_ADVERT;
|
||||||
ra->code = 0;
|
ra->code = 0;
|
||||||
ra->hop_limit = hop_limit;
|
ra->hop_limit = hop_limit;
|
||||||
ra->flags = calc_prio(ra_param);
|
ra->flags = parm.prio;
|
||||||
ra->lifetime = htons(calc_lifetime(ra_param));
|
ra->lifetime = htons(calc_lifetime(ra_param));
|
||||||
ra->reachable_time = 0;
|
ra->reachable_time = 0;
|
||||||
ra->retrans_time = 0;
|
ra->retrans_time = 0;
|
||||||
|
|
||||||
parm.ind = iface;
|
|
||||||
parm.managed = 0;
|
|
||||||
parm.other = 0;
|
|
||||||
parm.found_context = 0;
|
|
||||||
parm.if_name = iface_name;
|
|
||||||
parm.first = 1;
|
|
||||||
parm.now = now;
|
|
||||||
parm.glob_pref_time = parm.link_pref_time = parm.ula_pref_time = 0;
|
|
||||||
parm.adv_interval = calc_interval(ra_param);
|
|
||||||
|
|
||||||
/* set tag with name == interface */
|
/* set tag with name == interface */
|
||||||
iface_id.net = iface_name;
|
iface_id.net = iface_name;
|
||||||
iface_id.next = NULL;
|
iface_id.next = NULL;
|
||||||
@@ -286,8 +288,7 @@ static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *de
|
|||||||
setaddr6part(&local, addr6part(&local) & ~((context->prefix == 64) ? (u64)-1LL : (1LLU << (128 - context->prefix)) - 1LLU));
|
setaddr6part(&local, addr6part(&local) & ~((context->prefix == 64) ? (u64)-1LL : (1LLU << (128 - context->prefix)) - 1LLU));
|
||||||
|
|
||||||
|
|
||||||
if ((context->flags &
|
if (context->flags & CONTEXT_RA)
|
||||||
(CONTEXT_RA_ONLY | CONTEXT_RA_NAME | CONTEXT_RA_STATELESS)))
|
|
||||||
{
|
{
|
||||||
do_slaac = 1;
|
do_slaac = 1;
|
||||||
if (context->flags & CONTEXT_DHCP)
|
if (context->flags & CONTEXT_DHCP)
|
||||||
@@ -339,6 +340,17 @@ static void send_ra(time_t now, int iface, char *iface_name, struct in6_addr *de
|
|||||||
if (!old_prefix && !parm.found_context)
|
if (!old_prefix && !parm.found_context)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
/* If we're sending router address instead of prefix in at least on prefix,
|
||||||
|
include the advertisement interval option. */
|
||||||
|
if (parm.adv_router)
|
||||||
|
{
|
||||||
|
put_opt6_char(ICMP6_OPT_ADV_INTERVAL);
|
||||||
|
put_opt6_char(1);
|
||||||
|
put_opt6_short(0);
|
||||||
|
/* interval value is in milliseconds */
|
||||||
|
put_opt6_long(1000 * calc_interval(find_iface_param(iface_name)));
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_LINUX_NETWORK
|
||||||
/* Note that IPv6 MTU is not necessarilly the same as the IPv4 MTU
|
/* Note that IPv6 MTU is not necessarilly the same as the IPv4 MTU
|
||||||
available from SIOCGIFMTU */
|
available from SIOCGIFMTU */
|
||||||
@@ -500,6 +512,7 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
int do_slaac = 0;
|
int do_slaac = 0;
|
||||||
int deprecate = 0;
|
int deprecate = 0;
|
||||||
int constructed = 0;
|
int constructed = 0;
|
||||||
|
int adv_router = 0;
|
||||||
unsigned int time = 0xffffffff;
|
unsigned int time = 0xffffffff;
|
||||||
struct dhcp_context *context;
|
struct dhcp_context *context;
|
||||||
|
|
||||||
@@ -511,8 +524,7 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
{
|
{
|
||||||
context->saved_valid = valid;
|
context->saved_valid = valid;
|
||||||
|
|
||||||
if ((context->flags &
|
if (context->flags & CONTEXT_RA)
|
||||||
(CONTEXT_RA_ONLY | CONTEXT_RA_NAME | CONTEXT_RA_STATELESS)))
|
|
||||||
{
|
{
|
||||||
do_slaac = 1;
|
do_slaac = 1;
|
||||||
if (context->flags & CONTEXT_DHCP)
|
if (context->flags & CONTEXT_DHCP)
|
||||||
@@ -531,6 +543,16 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
param->other = 1;
|
param->other = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Configured to advertise router address, not prefix. See RFC 3775 7.2
|
||||||
|
In this case we do all addresses associated with a context,
|
||||||
|
hence the real_prefix setting here. */
|
||||||
|
if (context->flags & CONTEXT_RA_ROUTER)
|
||||||
|
{
|
||||||
|
adv_router = 1;
|
||||||
|
param->adv_router = 1;
|
||||||
|
real_prefix = context->prefix;
|
||||||
|
}
|
||||||
|
|
||||||
/* find floor time, don't reduce below 3 * RA interval. */
|
/* find floor time, don't reduce below 3 * RA interval. */
|
||||||
if (time > context->lease_time)
|
if (time > context->lease_time)
|
||||||
{
|
{
|
||||||
@@ -556,7 +578,7 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
/* subsequent prefixes on the same interface
|
/* subsequent prefixes on the same interface
|
||||||
and subsequent instances of this prefix don't need timers.
|
and subsequent instances of this prefix don't need timers.
|
||||||
Be careful not to find the same prefix twice with different
|
Be careful not to find the same prefix twice with different
|
||||||
addresses. */
|
addresses unless we're advertising the actual addresses. */
|
||||||
if (!(context->flags & CONTEXT_RA_DONE))
|
if (!(context->flags & CONTEXT_RA_DONE))
|
||||||
{
|
{
|
||||||
if (!param->first)
|
if (!param->first)
|
||||||
@@ -607,13 +629,18 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
if ((opt = expand(sizeof(struct prefix_opt))))
|
if ((opt = expand(sizeof(struct prefix_opt))))
|
||||||
{
|
{
|
||||||
/* zero net part of address */
|
/* zero net part of address */
|
||||||
setaddr6part(local, addr6part(local) & ~((real_prefix == 64) ? (u64)-1LL : (1LLU << (128 - real_prefix)) - 1LLU));
|
if (!adv_router)
|
||||||
|
setaddr6part(local, addr6part(local) & ~((real_prefix == 64) ? (u64)-1LL : (1LLU << (128 - real_prefix)) - 1LLU));
|
||||||
|
|
||||||
opt->type = ICMP6_OPT_PREFIX;
|
opt->type = ICMP6_OPT_PREFIX;
|
||||||
opt->len = 4;
|
opt->len = 4;
|
||||||
opt->prefix_len = real_prefix;
|
opt->prefix_len = real_prefix;
|
||||||
/* autonomous only if we're not doing dhcp, always set "on-link" */
|
/* autonomous only if we're not doing dhcp, always set "on-link" */
|
||||||
opt->flags = do_slaac ? 0xC0 : 0x80;
|
opt->flags = 0x80;
|
||||||
|
if (do_slaac)
|
||||||
|
opt->flags |= 0x40;
|
||||||
|
if (adv_router)
|
||||||
|
opt->flags |= 0x20;
|
||||||
opt->valid_lifetime = htonl(valid);
|
opt->valid_lifetime = htonl(valid);
|
||||||
opt->preferred_lifetime = htonl(preferred);
|
opt->preferred_lifetime = htonl(preferred);
|
||||||
opt->reserved = 0;
|
opt->reserved = 0;
|
||||||
|
|||||||
+27
-7
@@ -1065,6 +1065,8 @@ int extract_addresses(struct dns_header *header, size_t qlen, char *name, time_t
|
|||||||
if (newc)
|
if (newc)
|
||||||
{
|
{
|
||||||
newc->addr.cname.target.cache = NULL;
|
newc->addr.cname.target.cache = NULL;
|
||||||
|
/* anything other than zero, to avoid being mistaken for CNAME to interface-name */
|
||||||
|
newc->addr.cname.uid = 1;
|
||||||
if (cpp)
|
if (cpp)
|
||||||
{
|
{
|
||||||
cpp->addr.cname.target.cache = newc;
|
cpp->addr.cname.target.cache = newc;
|
||||||
@@ -1100,7 +1102,10 @@ int extract_addresses(struct dns_header *header, size_t qlen, char *name, time_t
|
|||||||
{
|
{
|
||||||
ipsets_cur = ipsets;
|
ipsets_cur = ipsets;
|
||||||
while (*ipsets_cur)
|
while (*ipsets_cur)
|
||||||
add_to_ipset(*ipsets_cur++, &addr, flags, 0);
|
{
|
||||||
|
log_query((flags & (F_IPV4 | F_IPV6)) | F_IPSET, name, &addr, *ipsets_cur);
|
||||||
|
add_to_ipset(*ipsets_cur++, &addr, flags, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -1241,7 +1246,12 @@ int check_for_local_domain(char *name, time_t now)
|
|||||||
struct ptr_record *ptr;
|
struct ptr_record *ptr;
|
||||||
struct naptr *naptr;
|
struct naptr *naptr;
|
||||||
|
|
||||||
if ((crecp = cache_find_by_name(NULL, name, now, F_IPV4 | F_IPV6 | F_CNAME | F_NO_RR)) &&
|
/* Note: the call to cache_find_by_name is intended to find any record which matches
|
||||||
|
ie A, AAAA, CNAME, DS. Because RRSIG records are marked by setting both F_DS and F_DNSKEY,
|
||||||
|
cache_find_by name ordinarily only returns records with an exact match on those bits (ie
|
||||||
|
for the call below, only DS records). The F_NSIGMATCH bit changes this behaviour */
|
||||||
|
|
||||||
|
if ((crecp = cache_find_by_name(NULL, name, now, F_IPV4 | F_IPV6 | F_CNAME | F_DS | F_NO_RR | F_NSIGMATCH)) &&
|
||||||
(crecp->flags & (F_HOSTS | F_DHCP | F_CONFIG)))
|
(crecp->flags & (F_HOSTS | F_DHCP | F_CONFIG)))
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@@ -1456,7 +1466,7 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen,
|
|||||||
{
|
{
|
||||||
char *name = daemon->namebuff;
|
char *name = daemon->namebuff;
|
||||||
unsigned char *p, *ansp, *pheader;
|
unsigned char *p, *ansp, *pheader;
|
||||||
int qtype, qclass;
|
unsigned int qtype, qclass;
|
||||||
struct all_addr addr;
|
struct all_addr addr;
|
||||||
int nameoffset;
|
int nameoffset;
|
||||||
unsigned short flag;
|
unsigned short flag;
|
||||||
@@ -1545,10 +1555,20 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen,
|
|||||||
ans = 1;
|
ans = 1;
|
||||||
if (!dryrun)
|
if (!dryrun)
|
||||||
{
|
{
|
||||||
|
unsigned long ttl = daemon->local_ttl;
|
||||||
|
int ok = 1;
|
||||||
log_query(F_CONFIG | F_RRNAME, name, NULL, "<TXT>");
|
log_query(F_CONFIG | F_RRNAME, name, NULL, "<TXT>");
|
||||||
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
/* Dynamically generate stat record */
|
||||||
daemon->local_ttl, NULL,
|
if (t->stat != 0)
|
||||||
T_TXT, t->class, "t", t->len, t->txt))
|
{
|
||||||
|
ttl = 0;
|
||||||
|
if (!cache_make_stat(t))
|
||||||
|
ok = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ok && add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
||||||
|
ttl, NULL,
|
||||||
|
T_TXT, t->class, "t", t->len, t->txt))
|
||||||
anscount++;
|
anscount++;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -2016,7 +2036,7 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen,
|
|||||||
|
|
||||||
strcpy(name, cname_target);
|
strcpy(name, cname_target);
|
||||||
/* check if target interface_name */
|
/* check if target interface_name */
|
||||||
if (crecp->addr.cname.uid == -1)
|
if (crecp->addr.cname.uid == SRC_INTERFACE)
|
||||||
goto intname_restart;
|
goto intname_restart;
|
||||||
else
|
else
|
||||||
goto cname_restart;
|
goto cname_restart;
|
||||||
|
|||||||
@@ -962,6 +962,8 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
case DHCPDISCOVER:
|
case DHCPDISCOVER:
|
||||||
if (ignore || have_config(config, CONFIG_DISABLE))
|
if (ignore || have_config(config, CONFIG_DISABLE))
|
||||||
{
|
{
|
||||||
|
if (option_bool(OPT_QUIET_DHCP))
|
||||||
|
return 0;
|
||||||
message = _("ignored");
|
message = _("ignored");
|
||||||
opt = NULL;
|
opt = NULL;
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-2
@@ -313,8 +313,8 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
|||||||
else if (msg_type != DHCP6IREQ)
|
else if (msg_type != DHCP6IREQ)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
/* server-id must match except for SOLICIT and CONFIRM messages */
|
/* server-id must match except for SOLICIT, CONFIRM and REBIND messages */
|
||||||
if (msg_type != DHCP6SOLICIT && msg_type != DHCP6CONFIRM && msg_type != DHCP6IREQ &&
|
if (msg_type != DHCP6SOLICIT && msg_type != DHCP6CONFIRM && msg_type != DHCP6IREQ && msg_type != DHCP6REBIND &&
|
||||||
(!(opt = opt6_find(state->packet_options, state->end, OPTION6_SERVER_ID, 1)) ||
|
(!(opt = opt6_find(state->packet_options, state->end, OPTION6_SERVER_ID, 1)) ||
|
||||||
opt6_len(opt) != daemon->duid_len ||
|
opt6_len(opt) != daemon->duid_len ||
|
||||||
memcmp(opt6_ptr(opt, 0), daemon->duid, daemon->duid_len) != 0))
|
memcmp(opt6_ptr(opt, 0), daemon->duid, daemon->duid_len) != 0))
|
||||||
@@ -328,6 +328,7 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
|||||||
(msg_type == DHCP6REQUEST || msg_type == DHCP6RENEW || msg_type == DHCP6RELEASE || msg_type == DHCP6DECLINE))
|
(msg_type == DHCP6REQUEST || msg_type == DHCP6RENEW || msg_type == DHCP6RELEASE || msg_type == DHCP6DECLINE))
|
||||||
|
|
||||||
{
|
{
|
||||||
|
*outmsgtypep = DHCP6REPLY;
|
||||||
o1 = new_opt6(OPTION6_STATUS_CODE);
|
o1 = new_opt6(OPTION6_STATUS_CODE);
|
||||||
put_opt6_short(DHCP6USEMULTI);
|
put_opt6_short(DHCP6USEMULTI);
|
||||||
put_opt6_string("Use multicast");
|
put_opt6_string("Use multicast");
|
||||||
@@ -1039,6 +1040,8 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
|||||||
|
|
||||||
case DHCP6CONFIRM:
|
case DHCP6CONFIRM:
|
||||||
{
|
{
|
||||||
|
int good_addr = 0;
|
||||||
|
|
||||||
/* set reply message type */
|
/* set reply message type */
|
||||||
*outmsgtypep = DHCP6REPLY;
|
*outmsgtypep = DHCP6REPLY;
|
||||||
|
|
||||||
@@ -1063,10 +1066,15 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
good_addr = 1;
|
||||||
log6_quiet(state, "DHCPREPLY", req_addr, state->hostname);
|
log6_quiet(state, "DHCPREPLY", req_addr, state->hostname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* No addresses, no reply: RFC 3315 18.2.2 */
|
||||||
|
if (!good_addr)
|
||||||
|
return 0;
|
||||||
|
|
||||||
o1 = new_opt6(OPTION6_STATUS_CODE);
|
o1 = new_opt6(OPTION6_STATUS_CODE);
|
||||||
put_opt6_short(DHCP6SUCCESS );
|
put_opt6_short(DHCP6SUCCESS );
|
||||||
put_opt6_string(_("all addresses still on link"));
|
put_opt6_string(_("all addresses still on link"));
|
||||||
@@ -1232,6 +1240,12 @@ static int dhcp6_no_relay(struct state *state, int msg_type, void *inbuff, size_
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* We must anwser with 'success' in global section anyway */
|
||||||
|
o1 = new_opt6(OPTION6_STATUS_CODE);
|
||||||
|
put_opt6_short(DHCP6SUCCESS);
|
||||||
|
put_opt6_string(_("success"));
|
||||||
|
end_opt6(o1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+169
@@ -0,0 +1,169 @@
|
|||||||
|
/* tables.c is Copyright (c) 2014 Sven Falempin All Rights Reserved.
|
||||||
|
|
||||||
|
Author's email: sfalempin@citypassenger.com
|
||||||
|
|
||||||
|
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
|
||||||
|
the Free Software Foundation; version 2 dated June, 1991, or
|
||||||
|
(at your option) version 3 dated 29 June, 2007.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "dnsmasq.h"
|
||||||
|
|
||||||
|
#if defined(HAVE_IPSET) && defined(HAVE_BSD_NETWORK)
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
|
#include <sys/ioctl.h>
|
||||||
|
|
||||||
|
#include <net/if.h>
|
||||||
|
#include <netinet/in.h>
|
||||||
|
#include <net/pfvar.h>
|
||||||
|
|
||||||
|
#include <err.h>
|
||||||
|
#include <errno.h>
|
||||||
|
#include <fcntl.h>
|
||||||
|
|
||||||
|
#define UNUSED(x) (void)(x)
|
||||||
|
|
||||||
|
static char *pf_device = "/dev/pf";
|
||||||
|
static int dev = -1;
|
||||||
|
|
||||||
|
static char *pfr_strerror(int errnum)
|
||||||
|
{
|
||||||
|
switch (errnum)
|
||||||
|
{
|
||||||
|
case ESRCH:
|
||||||
|
return "Table does not exist";
|
||||||
|
case ENOENT:
|
||||||
|
return "Anchor or Ruleset does not exist";
|
||||||
|
default:
|
||||||
|
return strerror(errnum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int pfr_add_tables(struct pfr_table *tbl, int size, int *nadd, int flags)
|
||||||
|
{
|
||||||
|
struct pfioc_table io;
|
||||||
|
|
||||||
|
if (size < 0 || (size && tbl == NULL))
|
||||||
|
{
|
||||||
|
errno = EINVAL;
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
bzero(&io, sizeof io);
|
||||||
|
io.pfrio_flags = flags;
|
||||||
|
io.pfrio_buffer = tbl;
|
||||||
|
io.pfrio_esize = sizeof(*tbl);
|
||||||
|
io.pfrio_size = size;
|
||||||
|
if (ioctl(dev, DIOCRADDTABLES, &io))
|
||||||
|
return (-1);
|
||||||
|
if (nadd != NULL)
|
||||||
|
*nadd = io.pfrio_nadd;
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int fill_addr(const struct all_addr *ipaddr, int flags, struct pfr_addr* addr) {
|
||||||
|
if ( !addr || !ipaddr)
|
||||||
|
{
|
||||||
|
my_syslog(LOG_ERR, _("error: fill_addr missused"));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
bzero(addr, sizeof(*addr));
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
|
if (flags & F_IPV6)
|
||||||
|
{
|
||||||
|
addr->pfra_af = AF_INET6;
|
||||||
|
addr->pfra_net = 0x80;
|
||||||
|
memcpy(&(addr->pfra_ip6addr), &(ipaddr->addr), sizeof(struct in6_addr));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
addr->pfra_af = AF_INET;
|
||||||
|
addr->pfra_net = 0x20;
|
||||||
|
addr->pfra_ip4addr.s_addr = ipaddr->addr.addr4.s_addr;
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
void ipset_init(void)
|
||||||
|
{
|
||||||
|
dev = open( pf_device, O_RDWR);
|
||||||
|
if (dev == -1)
|
||||||
|
{
|
||||||
|
err(1, "%s", pf_device);
|
||||||
|
die (_("failed to access pf devices: %s"), NULL, EC_MISC);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int add_to_ipset(const char *setname, const struct all_addr *ipaddr,
|
||||||
|
int flags, int remove)
|
||||||
|
{
|
||||||
|
struct pfr_addr addr;
|
||||||
|
struct pfioc_table io;
|
||||||
|
struct pfr_table table;
|
||||||
|
int n = 0, rc = 0;
|
||||||
|
|
||||||
|
if ( dev == -1 )
|
||||||
|
{
|
||||||
|
my_syslog(LOG_ERR, _("warning: no opened pf devices %s"), pf_device);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
bzero(&table, sizeof(struct pfr_table));
|
||||||
|
table.pfrt_flags |= PFR_TFLAG_PERSIST;
|
||||||
|
if ( strlen(setname) >= PF_TABLE_NAME_SIZE )
|
||||||
|
{
|
||||||
|
my_syslog(LOG_ERR, _("error: cannot use table name %s"), setname);
|
||||||
|
errno = ENAMETOOLONG;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( strlcpy(table.pfrt_name, setname,
|
||||||
|
sizeof(table.pfrt_name)) >= sizeof(table.pfrt_name))
|
||||||
|
{
|
||||||
|
my_syslog(LOG_ERR, _("error: cannot strlcpy table name %s"), setname);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rc = pfr_add_tables(&table, 1, &n, 0))
|
||||||
|
{
|
||||||
|
my_syslog(LOG_WARNING, _("warning: pfr_add_tables: %s(%d)"),
|
||||||
|
pfr_strerror(errno),rc);
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
table.pfrt_flags &= ~PFR_TFLAG_PERSIST;
|
||||||
|
if (n)
|
||||||
|
my_syslog(LOG_INFO, _("info: table created"));
|
||||||
|
|
||||||
|
fill_addr(ipaddr,flags,&addr);
|
||||||
|
bzero(&io, sizeof(io));
|
||||||
|
io.pfrio_flags = 0;
|
||||||
|
io.pfrio_table = table;
|
||||||
|
io.pfrio_buffer = &addr;
|
||||||
|
io.pfrio_esize = sizeof(addr);
|
||||||
|
io.pfrio_size = 1;
|
||||||
|
if (ioctl(dev, ( remove ? DIOCRDELADDRS : DIOCRADDADDRS ), &io))
|
||||||
|
{
|
||||||
|
my_syslog(LOG_WARNING, _("warning: DIOCR%sADDRS: %s"), ( remove ? "DEL" : "ADD" ), pfr_strerror(errno));
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
my_syslog(LOG_INFO, _("%d addresses %s"),
|
||||||
|
io.pfrio_nadd, ( remove ? "removed" : "added" ));
|
||||||
|
|
||||||
|
return io.pfrio_nadd;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif
|
||||||
+56
-2
@@ -81,6 +81,18 @@ unsigned short rand16(void)
|
|||||||
return (unsigned short) out[--outleft];
|
return (unsigned short) out[--outleft];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 rand32(void)
|
||||||
|
{
|
||||||
|
if (!outleft)
|
||||||
|
{
|
||||||
|
if (!++in[0]) if (!++in[1]) if (!++in[2]) ++in[3];
|
||||||
|
surf();
|
||||||
|
outleft = 8;
|
||||||
|
}
|
||||||
|
|
||||||
|
return out[--outleft];
|
||||||
|
}
|
||||||
|
|
||||||
u64 rand64(void)
|
u64 rand64(void)
|
||||||
{
|
{
|
||||||
static int outleft = 0;
|
static int outleft = 0;
|
||||||
@@ -319,6 +331,19 @@ time_t dnsmasq_time(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int netmask_length(struct in_addr mask)
|
||||||
|
{
|
||||||
|
int zero_count = 0;
|
||||||
|
|
||||||
|
while (0x0 == (mask.s_addr & 0x1) && zero_count < 32)
|
||||||
|
{
|
||||||
|
mask.s_addr >>= 1;
|
||||||
|
zero_count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 32 - zero_count;
|
||||||
|
}
|
||||||
|
|
||||||
int is_same_net(struct in_addr a, struct in_addr b, struct in_addr mask)
|
int is_same_net(struct in_addr a, struct in_addr b, struct in_addr mask)
|
||||||
{
|
{
|
||||||
return (a.s_addr & mask.s_addr) == (b.s_addr & mask.s_addr);
|
return (a.s_addr & mask.s_addr) == (b.s_addr & mask.s_addr);
|
||||||
@@ -545,15 +570,25 @@ void bump_maxfd(int fd, int *max)
|
|||||||
|
|
||||||
int retry_send(void)
|
int retry_send(void)
|
||||||
{
|
{
|
||||||
struct timespec waiter;
|
/* Linux kernels can return EAGAIN in perpetuity when calling
|
||||||
|
sendmsg() and the relevant interface has gone. Here we loop
|
||||||
|
retrying in EAGAIN for 1 second max, to avoid this hanging
|
||||||
|
dnsmasq. */
|
||||||
|
|
||||||
|
static int retries = 0;
|
||||||
|
struct timespec waiter;
|
||||||
|
|
||||||
if (errno == EAGAIN || errno == EWOULDBLOCK)
|
if (errno == EAGAIN || errno == EWOULDBLOCK)
|
||||||
{
|
{
|
||||||
waiter.tv_sec = 0;
|
waiter.tv_sec = 0;
|
||||||
waiter.tv_nsec = 10000;
|
waiter.tv_nsec = 10000;
|
||||||
nanosleep(&waiter, NULL);
|
nanosleep(&waiter, NULL);
|
||||||
return 1;
|
if (retries++ < 1000)
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
retries = 0;
|
||||||
|
|
||||||
if (errno == EINTR)
|
if (errno == EINTR)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
@@ -602,3 +637,22 @@ int wildcard_match(const char* wildcard, const char* match)
|
|||||||
|
|
||||||
return *wildcard == *match;
|
return *wildcard == *match;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* The same but comparing a maximum of NUM characters, like strncmp. */
|
||||||
|
int wildcard_matchn(const char* wildcard, const char* match, int num)
|
||||||
|
{
|
||||||
|
while (*wildcard && *match && num)
|
||||||
|
{
|
||||||
|
if (*wildcard == '*')
|
||||||
|
return 1;
|
||||||
|
|
||||||
|
if (*wildcard != *match)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
++wildcard;
|
||||||
|
++match;
|
||||||
|
--num;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (!num) || (*wildcard == *match);
|
||||||
|
}
|
||||||
Reference in new issue
Block a user