mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-06 15:51:41 +00:00
Compare commits
35
Commits
v2.61test9
...
v2.61
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f61b3ad59 | ||
|
|
a9ab732e35 | ||
|
|
11263a462c | ||
|
|
231d061b45 | ||
|
|
cdbee9a40b | ||
|
|
7b4ad2eb34 | ||
|
|
19d69be220 | ||
|
|
04363607aa | ||
|
|
dcffad2a86 | ||
|
|
6a69ab5ebd | ||
|
|
fc92ead0dd | ||
|
|
61ce600b20 | ||
|
|
7a14dfebbb | ||
|
|
42fb8153ba | ||
|
|
6f13e53886 | ||
|
|
d1c759c5c1 | ||
|
|
e46164e0bd | ||
|
|
7389ce7ff5 | ||
|
|
2f77797b17 | ||
|
|
9380ba70d6 | ||
|
|
1023dcbc9e | ||
|
|
83e854e359 | ||
|
|
50303b19d8 | ||
|
|
89382bacaa | ||
|
|
6c559c34df | ||
|
|
adaa6888dd | ||
|
|
a813111379 | ||
|
|
18f0fb050b | ||
|
|
05e92e5afe | ||
|
|
4723d49dad | ||
|
|
fbbc14541a | ||
|
|
5ef33279f2 | ||
|
|
1e02a85970 | ||
|
|
0e88d53faa | ||
|
|
01d1b8ddf2 |
No files matched your search
@@ -4,8 +4,12 @@ version 2.61
|
|||||||
and allows us to find the prefix length for IPv6
|
and allows us to find the prefix length for IPv6
|
||||||
addresses.
|
addresses.
|
||||||
|
|
||||||
Add ra-names DHCPv6 keyword which adds AAAA records
|
Add ra-names, ra-stateless and slaac keywords for DHCPv6.
|
||||||
for dual-stack hosts which get IPv6 addresses via SLAAC.
|
Dnsmasq can now synthesise AAAA records for dual-stack
|
||||||
|
hosts which get IPv6 addresses via SLAAC. It is also now
|
||||||
|
possible to use SLAAC and stateless DHCPv6, and to
|
||||||
|
tell clients to use SLAAC addresses as well as DHCP ones.
|
||||||
|
Thanks to Dave Taht for help with this.
|
||||||
|
|
||||||
Add --dhcp-duid to allow DUID-EN uids to be used.
|
Add --dhcp-duid to allow DUID-EN uids to be used.
|
||||||
|
|
||||||
@@ -64,10 +68,43 @@ version 2.61
|
|||||||
renumbering at least possible.
|
renumbering at least possible.
|
||||||
|
|
||||||
Fix bug in address6_available() which caused DHCPv6 lease
|
Fix bug in address6_available() which caused DHCPv6 lease
|
||||||
aquistion to fail of more than one dhcp-range in use.
|
aquistion to fail if more than one dhcp-range in use.
|
||||||
|
|
||||||
|
Provide RDNSS and DNSSL data in router advertisements,
|
||||||
|
using the settings provided for DHCP options
|
||||||
|
option6:domain-search and option6:dns-server.
|
||||||
|
|
||||||
|
Tweak logo/favicon.ico to add some transparency. Thanks to
|
||||||
|
SamLT for work on this.
|
||||||
|
|
||||||
|
Don't cache data from non-recursive nameservers, since it
|
||||||
|
may erroneously look like a valid CNAME to a non-exitant
|
||||||
|
name. Thanks to Ben Winslow for finding this.
|
||||||
|
|
||||||
|
Call SO_BINDTODEVICE on the DHCP socket(s) when doing DHCP
|
||||||
|
on exacly one interface and --bind-interfaces is set. This
|
||||||
|
makes the OpenStack use-case of one dnsmasq per virtual
|
||||||
|
interface work. This is only available on Linux; it's not
|
||||||
|
supported on other platforms. Thanks to Vishvananda Ishaya
|
||||||
|
and the OpenStack team for the suggestion.
|
||||||
|
|
||||||
|
Updated French translation. Thanks to Gildas Le Nadan.
|
||||||
|
|
||||||
|
Give correct from-cache answers to explict CNAME queries.
|
||||||
|
Thanks to Rob Zwissler for spotting this.
|
||||||
|
|
||||||
|
Add --tftp-lowercase option. Thanks to Oliver Rath for the
|
||||||
|
patch.
|
||||||
|
|
||||||
|
Ensure that the DBus DhcpLeaseUpdated events are generated
|
||||||
|
when a lease goes through INIT_REBOOT state, even if the
|
||||||
|
dhcp-script is not in use. thanks to Antoaneta-Ecaterina
|
||||||
|
Ene for the patch.
|
||||||
|
|
||||||
|
Fix failure of TFTP over IPv4 on OpenBSD platform. Thanks
|
||||||
|
to Brad Smith for spotting this.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
version 2.60
|
version 2.60
|
||||||
Fix compilation problem in Mac OS X Lion. Thanks to Olaf
|
Fix compilation problem in Mac OS X Lion. Thanks to Olaf
|
||||||
Flebbe for the patch.
|
Flebbe for the patch.
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ else
|
|||||||
vers=`cat $1/VERSION | sed 's/[(), ]/,/ g' | tr ',' '\n' | grep $v[0-9]`
|
vers=`cat $1/VERSION | sed 's/[(), ]/,/ g' | tr ',' '\n' | grep $v[0-9]`
|
||||||
|
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo "${vers}" | head -n 1 | tail -c +2
|
echo "${vers}" | head -n 1 | sed 's/^v//'
|
||||||
else
|
else
|
||||||
cat $1/VERSION
|
cat $1/VERSION
|
||||||
fi
|
fi
|
||||||
|
|||||||
Vendored
+2
-1
@@ -4,7 +4,8 @@ dnsmasq (2.61-1) unstable; urgency=low
|
|||||||
* Provide "dump-stats" initscript method. (closes: #654656)
|
* Provide "dump-stats" initscript method. (closes: #654656)
|
||||||
* Add (empty) build-indep and build-arch rules targets.
|
* Add (empty) build-indep and build-arch rules targets.
|
||||||
* Bump standards-version to 3.9.3
|
* Bump standards-version to 3.9.3
|
||||||
|
* Add port option to example dnsmasq.conf (closes: #668386)
|
||||||
|
|
||||||
-- Simon Kelley <simon@thekelleys.org.uk> Tue, 6 Mar 2012 19:45:43 +0000
|
-- Simon Kelley <simon@thekelleys.org.uk> Tue, 6 Mar 2012 19:45:43 +0000
|
||||||
|
|
||||||
dnsmasq (2.60-2) unstable; urgency=high
|
dnsmasq (2.60-2) unstable; urgency=high
|
||||||
|
|||||||
@@ -4,6 +4,11 @@
|
|||||||
# as the long options legal on the command line. See
|
# as the long options legal on the command line. See
|
||||||
# "/usr/sbin/dnsmasq --help" or "man 8 dnsmasq" for details.
|
# "/usr/sbin/dnsmasq --help" or "man 8 dnsmasq" for details.
|
||||||
|
|
||||||
|
# Listen on this specific port instead of the standard DNS port
|
||||||
|
# (53). Setting this to zero completely disables DNS function,
|
||||||
|
# leaving only DHCP and/or TFTP.
|
||||||
|
#port=5353
|
||||||
|
|
||||||
# The following two options make you a better netizen, since they
|
# The following two options make you a better netizen, since they
|
||||||
# tell dnsmasq to filter out queries which the public DNS cannot
|
# tell dnsmasq to filter out queries which the public DNS cannot
|
||||||
# answer, and which load the servers (especially the root servers)
|
# answer, and which load the servers (especially the root servers)
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
+22
-8
@@ -23,7 +23,7 @@ options. It includes a secure, read-only,
|
|||||||
TFTP server to allow net/PXE boot of DHCP hosts and also supports BOOTP.
|
TFTP server to allow net/PXE boot of DHCP hosts and also supports BOOTP.
|
||||||
.PP
|
.PP
|
||||||
Dnsmasq
|
Dnsmasq
|
||||||
supports IPv6 for all functions and a minimal router-advertisemnet daemon.
|
supports IPv6 for all functions and a minimal router-advertisement daemon.
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
Note that in general missing parameters are allowed and switch off
|
Note that in general missing parameters are allowed and switch off
|
||||||
functions, for instance "--pid-file" disables writing a PID file. On
|
functions, for instance "--pid-file" disables writing a PID file. On
|
||||||
@@ -416,7 +416,7 @@ zone files: the port, weight and priority numbers are in a different
|
|||||||
order. More than one SRV record for a given service/domain is allowed,
|
order. More than one SRV record for a given service/domain is allowed,
|
||||||
all that match are returned.
|
all that match are returned.
|
||||||
.TP
|
.TP
|
||||||
.B --host-record=<name>[,<name>....][<IPv4-address>],[IPv6-address]
|
.B --host-record=<name>[,<name>....][<IPv4-address>],[<IPv6-address>]
|
||||||
Add A, AAAA and PTR records to the DNS. This adds one or more names to
|
Add A, AAAA and PTR records to the DNS. This adds one or more names to
|
||||||
the DNS with associated IPv4 (A) and IPv6 (AAAA) records. A name may
|
the DNS with associated IPv4 (A) and IPv6 (AAAA) records. A name may
|
||||||
appear in more than one
|
appear in more than one
|
||||||
@@ -427,10 +427,12 @@ the same rule as is used reading hosts-files.
|
|||||||
.B host-record
|
.B host-record
|
||||||
options are considered to be read before host-files, so a name
|
options are considered to be read before host-files, so a name
|
||||||
appearing there inhibits PTR-record creation if it appears in
|
appearing there inhibits PTR-record creation if it appears in
|
||||||
hosts-file also. Unlike host-files, names are not expanded, even when
|
hosts-file also. Unlike hosts-files, names are not expanded, even when
|
||||||
.B expand-hosts
|
.B expand-hosts
|
||||||
is in effect. Short and long names may appear in the same
|
is in effect. Short and long names may appear in the same
|
||||||
.B host-record, eg. --host-record=laptop,laptop.thekelleys.org,192.168.0.1,1234::100
|
.B host-record,
|
||||||
|
eg.
|
||||||
|
.B --host-record=laptop,laptop.thekelleys.org,192.168.0.1,1234::100
|
||||||
.TP
|
.TP
|
||||||
.B \-Y, --txt-record=<name>[[,<text>],<text>]
|
.B \-Y, --txt-record=<name>[[,<text>],<text>]
|
||||||
Return a TXT DNS record. The value of TXT record is a set of strings,
|
Return a TXT DNS record. The value of TXT record is a set of strings,
|
||||||
@@ -560,7 +562,7 @@ addresses given via
|
|||||||
.B dhcp-host
|
.B dhcp-host
|
||||||
or from /etc/ethers will be served.
|
or from /etc/ethers will be served.
|
||||||
|
|
||||||
Fot IPv4, the <mode> may be
|
For IPv4, the <mode> may be
|
||||||
.B proxy
|
.B proxy
|
||||||
in which case dnsmasq will provide proxy-DHCP on the specified
|
in which case dnsmasq will provide proxy-DHCP on the specified
|
||||||
subnet. (See
|
subnet. (See
|
||||||
@@ -593,7 +595,7 @@ enables a mode
|
|||||||
which gives DNS names to dual-stack hosts which do SLAAC for
|
which gives DNS names to dual-stack hosts which do SLAAC for
|
||||||
IPv6. Dnsmasq uses the host's IPv4 lease to derive the name, network
|
IPv6. Dnsmasq uses the host's IPv4 lease to derive the name, network
|
||||||
segment and MAC address and assumes that the host will also have an
|
segment and MAC address and assumes that the host will also have an
|
||||||
IPv6 address calculated using the SLAAC alogrithm, on the same network
|
IPv6 address calculated using the SLAAC algorithm, on the same network
|
||||||
segment. The address is pinged, and if a reply is received, an AAAA
|
segment. The address is pinged, and if a reply is received, an AAAA
|
||||||
record is added to the DNS for this IPv6
|
record is added to the DNS for this IPv6
|
||||||
address. Note that this is only happens for directly-connected
|
address. Note that this is only happens for directly-connected
|
||||||
@@ -1140,7 +1142,9 @@ is known.
|
|||||||
DNSMASQ_TAGS contains all the tags set during the
|
DNSMASQ_TAGS contains all the tags set during the
|
||||||
DHCP transaction, separated by spaces.
|
DHCP transaction, separated by spaces.
|
||||||
|
|
||||||
DNSMASQ_LOG_DHCP is set if --log-dhcp is in effect.
|
DNSMASQ_LOG_DHCP is set if
|
||||||
|
.B --log-dhcp
|
||||||
|
is in effect.
|
||||||
|
|
||||||
For IPv4 only:
|
For IPv4 only:
|
||||||
|
|
||||||
@@ -1193,7 +1197,7 @@ with an "old " event.
|
|||||||
There are two further actions which may appear as the first argument
|
There are two further actions which may appear as the first argument
|
||||||
to the script, "init" and "tftp". More may be added in the future, so
|
to the script, "init" and "tftp". More may be added in the future, so
|
||||||
scripts should be written to ignore unknown actions. "init" is
|
scripts should be written to ignore unknown actions. "init" is
|
||||||
decsribed below in
|
described below in
|
||||||
.B --leasefile-ro
|
.B --leasefile-ro
|
||||||
The "tftp" action is invoked when a TFTP file transfer completes: the
|
The "tftp" action is invoked when a TFTP file transfer completes: the
|
||||||
arguments are the file size in bytes, the address to which the file
|
arguments are the file size in bytes, the address to which the file
|
||||||
@@ -1343,6 +1347,10 @@ the machine running dnsmasq. By default, he "managed address" bits are set, and
|
|||||||
the "use SLAAC" bit is reset. This can be changed for individual
|
the "use SLAAC" bit is reset. This can be changed for individual
|
||||||
subnets with the mode keywords described in
|
subnets with the mode keywords described in
|
||||||
.B --dhcp-range.
|
.B --dhcp-range.
|
||||||
|
RFC6106 DNS parameters are included in the advertisements. By default,
|
||||||
|
the relevant link-local address of the machine running dnsmasq is sent
|
||||||
|
as recursive DNS server. If provided, the DHCPv6 options dns-server and
|
||||||
|
domain-search are used for RDNSS and DNSSL.
|
||||||
.TP
|
.TP
|
||||||
.B --enable-tftp[=<interface>]
|
.B --enable-tftp[=<interface>]
|
||||||
Enable the TFTP server function. This is deliberately limited to that
|
Enable the TFTP server function. This is deliberately limited to that
|
||||||
@@ -1377,6 +1385,12 @@ are accessible. It is not recommended to run dnsmasq as root with TFTP
|
|||||||
enabled, and certainly not without specifying --tftp-root. Doing so
|
enabled, and certainly not without specifying --tftp-root. Doing so
|
||||||
can expose any world-readable file on the server to any host on the net.
|
can expose any world-readable file on the server to any host on the net.
|
||||||
.TP
|
.TP
|
||||||
|
.B --tftp-lowercase
|
||||||
|
Convert filenames in TFTP requests to all lowercase. This is useful
|
||||||
|
for requests from Windows machines, which have case-insensitive
|
||||||
|
filesystems and tend to play fast-and-loose with case in filenames.
|
||||||
|
Note that dnsmasq's tftp server always converts "\\" to "/" in filenames.
|
||||||
|
.TP
|
||||||
.B --tftp-max=<connections>
|
.B --tftp-max=<connections>
|
||||||
Set the maximum number of concurrent TFTP connections allowed. This
|
Set the maximum number of concurrent TFTP connections allowed. This
|
||||||
defaults to 50. When serving a large number of TFTP connections,
|
defaults to 50. When serving a large number of TFTP connections,
|
||||||
|
|||||||
+123
-22
@@ -22,7 +22,8 @@ peut être configuré pour envoyer n'importe quel option DHCP.
|
|||||||
Il inclut un serveur TFTP sécurisé en lecture seule permettant le démarrage via
|
Il inclut un serveur TFTP sécurisé en lecture seule permettant le démarrage via
|
||||||
le réseau/PXE de clients DHCP et supporte également le protocole BOOTP.
|
le réseau/PXE de clients DHCP et supporte également le protocole BOOTP.
|
||||||
.PP
|
.PP
|
||||||
Dnsmasq supporte IPv6 pour le DNS et TFTP mais pas pour le DHCP.
|
Dnsmasq supporte IPv6 et contient un démon minimaliste capable de faire des
|
||||||
|
annonces routeurs ("router-advertisements").
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
Notes : Il est possible d'utiliser des options sans leur donner de paramètre.
|
Notes : Il est possible d'utiliser des options sans leur donner de paramètre.
|
||||||
Dans ce cas, la fonction correspondante sera désactivée. Par exemple
|
Dans ce cas, la fonction correspondante sera désactivée. Par exemple
|
||||||
@@ -492,6 +493,27 @@ dans un ordre différents. Pour un service/domaine donné, plus d'un
|
|||||||
enregistrement SRV est autorisé et tous les enregistrements qui coïncident sont
|
enregistrement SRV est autorisé et tous les enregistrements qui coïncident sont
|
||||||
retournés dans la réponse.
|
retournés dans la réponse.
|
||||||
.TP
|
.TP
|
||||||
|
.B --host-record=<nom>[,<nom>....][<adresse IPv4>],[<adresse IPv6>]
|
||||||
|
Ajoute des enregistrements A, AAAA et PTR dans le DNS. Ceci permet d'ajouter
|
||||||
|
un ou plusieurs noms dans le DNS et de les associer à des enregistrements IPv4
|
||||||
|
(A) ou IPv6 (AAAA). Un nom peut apparaître dans plus d'une entrée
|
||||||
|
.B host-record
|
||||||
|
et de fait être associé à plus d'une adresse. Seule la première entrée créée
|
||||||
|
l'enregistrement PTR associée au nom. Ceci correspond à la même règle que celle
|
||||||
|
utilisée lors de la lecture du fichier hosts.
|
||||||
|
Les options
|
||||||
|
.B host-record
|
||||||
|
sont considérées lues avant le fichier hosts, ainsi un nom apparaissant dans
|
||||||
|
une option host-record et dans le fichier hosts n'aura pas d'enregistrement
|
||||||
|
PTR associé à l'entrée dans le fichier hosts. A l'inverse du fichier hosts, les
|
||||||
|
noms ne sont pas étendus, même lorsque l'option
|
||||||
|
.B expand-hosts
|
||||||
|
est activée. Les noms longs et les noms courts peuvent apparaitre dans la même
|
||||||
|
entrée
|
||||||
|
.B host-record,
|
||||||
|
c-à-d
|
||||||
|
.B --host-record=laptop,laptop.thekelleys.org,192.168.0.1,1234::100
|
||||||
|
.TP
|
||||||
.B \-Y, --txt-record=<nom>[[,<texte>],<texte>]
|
.B \-Y, --txt-record=<nom>[[,<texte>],<texte>]
|
||||||
Définit un enregistrement DNS de type TXT. La valeur de l'enregistrement TXT est
|
Définit un enregistrement DNS de type TXT. La valeur de l'enregistrement TXT est
|
||||||
un ensemble de chaînes de caractères, donc un nombre variable de chaînes de
|
un ensemble de chaînes de caractères, donc un nombre variable de chaînes de
|
||||||
@@ -577,11 +599,11 @@ l'ayant déclenché, ce qui est pratique pour la gestion de la bande passante
|
|||||||
(accounting) et le filtrage (firewall). Dnsmasq doit pour cela être compilé
|
(accounting) et le filtrage (firewall). Dnsmasq doit pour cela être compilé
|
||||||
avec le support conntrack, le noyau doit également inclure conntrack et être
|
avec le support conntrack, le noyau doit également inclure conntrack et être
|
||||||
configuré pour cela. Cette option ne peut pas être combinée avec
|
configuré pour cela. Cette option ne peut pas être combinée avec
|
||||||
--query-port.
|
--query-port.
|
||||||
.TP
|
.TP
|
||||||
.B \-F, --dhcp-range=[interface:<interface>,][tag:<label>[,tag:<label>],][set:<label>],]<adresse de début>,<adresse de fin>[,<masque de réseau>[,<broadcast>]][,<durée de bail>]
|
.B \-F, --dhcp-range=[interface:<interface>,][tag:<label>[,tag:<label>],][set:<label>],]<adresse de début>[,<adresse de fin>][,<mode>][,<masque de réseau>[,<broadcast>]][,<durée de bail>]
|
||||||
.TP
|
.TP
|
||||||
.B \-F, --dhcp-range=[interface:<interface>,][tag:<label>[,tag:<label>],][set:<label>],]<addresse IPv6 de début>,<adresse IPv6 de fin>[,<longueur de préfixe>][,<durée de bail>]
|
.B \-F, --dhcp-range=[interface:<interface>,][tag:<label>[,tag:<label>],][set:<label>],]<addresse IPv6 de début>[,<adresse IPv6 de fin>][,<mode>][,<longueur de préfixe>][,<durée de bail>]
|
||||||
Active le serveur DHCP. Les adresses seront données dans la plage comprise entre
|
Active le serveur DHCP. Les adresses seront données dans la plage comprise entre
|
||||||
<adresse de début> et <adresse de fin> et à partir des adresses définies
|
<adresse de début> et <adresse de fin> et à partir des adresses définies
|
||||||
statiquement dans l'option
|
statiquement dans l'option
|
||||||
@@ -592,6 +614,13 @@ en heures (exemple : 1h) ou être la chaine de caractère "infinite" pour une
|
|||||||
durée indéterminée. Si aucune valeur n'est donnée, une durée de bail par défaut
|
durée indéterminée. Si aucune valeur n'est donnée, une durée de bail par défaut
|
||||||
de une heure est appliquée. La valeur minimum pour un bail DHCP est de 2
|
de une heure est appliquée. La valeur minimum pour un bail DHCP est de 2
|
||||||
minutes.
|
minutes.
|
||||||
|
|
||||||
|
Pour les plages IPv6, la durée de bail peut-être égale au mot-clef "deprecated"
|
||||||
|
(obsolète); Cela positionne la durée de vie préférée envoyée dans les baux DHCP
|
||||||
|
ou les annonces routeurs à zéro, ce qui incite les clients à utiliser d'autres
|
||||||
|
adresses autant que possible, pour toute nouvelle connexion, en préalable à
|
||||||
|
la renumérotation.
|
||||||
|
|
||||||
Cette option peut être répétée, avec différentes adresses,
|
Cette option peut être répétée, avec différentes adresses,
|
||||||
pour activer le service DHCP sur plus d'un réseau. Pour des réseaux directement
|
pour activer le service DHCP sur plus d'un réseau. Pour des réseaux directement
|
||||||
connectés (c'est-à-dire des réseaux dans lesquels la machine sur laquelle tourne
|
connectés (c'est-à-dire des réseaux dans lesquels la machine sur laquelle tourne
|
||||||
@@ -622,30 +651,59 @@ Lorsque préfixé par 'tag:', la signification change, et au lieu de définir un
|
|||||||
label, il définit le label pour laquelle la règle s'applique. Un seul label peut-
|
label, il définit le label pour laquelle la règle s'applique. Un seul label peut-
|
||||||
être défini mais plusieurs labels peuvent coïncider.
|
être défini mais plusieurs labels peuvent coïncider.
|
||||||
|
|
||||||
L'adresse de fin peut être remplacée par le mot-clef
|
Le mot clef optionnel <mode> peut être égal à
|
||||||
.B static
|
.B static
|
||||||
("statique") qui indique à Dnsmasq d'activer le service DHCP pour le réseau
|
("statique") ce qui indique à Dnsmasq d'activer le service DHCP pour le réseau
|
||||||
spécifié, mais de ne pas activer l'allocation dynamique d'adresses IP : Seuls
|
spécifié, mais de ne pas activer l'allocation dynamique d'adresses IP : Seuls
|
||||||
les hôtes possédant des adresses IP statiques fournies via
|
les hôtes possédant des adresses IP statiques fournies via
|
||||||
.B dhcp-host
|
.B dhcp-host
|
||||||
ou présentes dans le fichier /etc/ethers seront alors servis par le DHCP.
|
ou présentes dans le fichier /etc/ethers seront alors servis par le DHCP.
|
||||||
|
|
||||||
L'adresse de fin peut-être remplacée par le mot-clef
|
Pour IPv4, le <mode> peut est égal à
|
||||||
.B proxy
|
.B proxy
|
||||||
, auquel cas Dnsmasq fournira un service de DHCP proxy pour le sous-réseau
|
, auquel cas Dnsmasq fournira un service de DHCP proxy pour le sous-réseau
|
||||||
spécifié. (voir
|
spécifié. (voir
|
||||||
.B pxe-prompt
|
.B pxe-prompt
|
||||||
et
|
et
|
||||||
.B pxe-service
|
.B pxe-service
|
||||||
pour plus de détails, s'applique à IPv4 seulement).
|
pour plus de détails).
|
||||||
|
|
||||||
|
Pour IPv6, le mode peut-être une combinaison des valeurs
|
||||||
|
.B ra-only, slaac, ra-names, ra-stateless.
|
||||||
|
|
||||||
L'adresse de fin peut être remplacée par le mot-clef
|
|
||||||
.B ra-only
|
.B ra-only
|
||||||
qui indique à dnsmasq de n'effectuer que des annonces de routeur (Router
|
indique à dnsmasq de n'effectuer que des annonces de routeur (Router
|
||||||
Advertisement, RA) sur ce sous-réseau, et de ne pas faire de DHCP. Ceci
|
Advertisement, RA) sur ce sous-réseau, et de ne pas faire de DHCP.
|
||||||
s'applique uniquement à IPv6, voir
|
|
||||||
.B enable-ra
|
.B slaac
|
||||||
pour plus de détails.
|
indique à dnsmasq d'effectuer des annonces de routeur sur ce sous-réseau
|
||||||
|
et de positionner dans celles-ci le bit A, afin que les clients utilisent
|
||||||
|
des adresses SLAAC. Lorsqu'utilisé conjointement avec une plage DHCP ou des
|
||||||
|
affectations statiques d'adresses DHCP, les clients disposeront à la fois
|
||||||
|
d'adresses DHCP assignées et d'adresses SLAAC.
|
||||||
|
|
||||||
|
.B ra-stateless
|
||||||
|
indique à dnsmasq d'effectuer des annonces de routeur avec les bits 0 et A
|
||||||
|
positionnés, et de fournir un service DHCP sans état ("stateless"). Les clients
|
||||||
|
utiliseront des adresses SLAAC, et utiliseront DHCP pour toutes les autres
|
||||||
|
informations de configuration.
|
||||||
|
|
||||||
|
.B ra-names
|
||||||
|
active un mode qui fourni des noms DNS aux hôtes fonctionnant en double pile
|
||||||
|
("dual stack") et configurés pour faire du SLAAC en IPv6. Dnsmasq utilise le
|
||||||
|
bail IPv4 de l'hôte afin de dériver le nom, le segment de réseau et l'adresse
|
||||||
|
MAC et assume que l'hôte disposera d'une adresse IPv6 calculée via l'algorithme
|
||||||
|
SLAAC, sur le même segment de réseau. Un ping est envoyé à l'adresse, et si une
|
||||||
|
réponse est obtenue, un enregistrement AAAA est rajouté dans le DNS pour cette
|
||||||
|
adresse IPv6. Veuillez-noter que cela n'arrive que pour les réseaux directement
|
||||||
|
connectés (et non ceux pour lesquels DHCP se fait via relai), et ne
|
||||||
|
fonctionnera pas si un hôte utilise les "extensions de vie privée"
|
||||||
|
("privacy extensions").
|
||||||
|
.B ra-names
|
||||||
|
peut-être combiné avec
|
||||||
|
.B ra-stateless
|
||||||
|
et
|
||||||
|
.B slaac.
|
||||||
|
|
||||||
La section interface:<nom d'interface> n'est normalement pas utilisée. Se
|
La section interface:<nom d'interface> n'est normalement pas utilisée. Se
|
||||||
référer aux indications de la section NOTES pour plus de détail à ce sujet.
|
référer aux indications de la section NOTES pour plus de détail à ce sujet.
|
||||||
@@ -1170,9 +1228,21 @@ détermination de celles-ci.
|
|||||||
.B \-l, --dhcp-leasefile=<chemin de fichier>
|
.B \-l, --dhcp-leasefile=<chemin de fichier>
|
||||||
Utilise le fichier dont le chemin est fourni pour stocker les informations de
|
Utilise le fichier dont le chemin est fourni pour stocker les informations de
|
||||||
baux DHCP.
|
baux DHCP.
|
||||||
.TP
|
.TP
|
||||||
|
.B --dhcp-duid=<ID d'entreprise>,<uid>
|
||||||
|
(IPv6 seulement) Spécifie le numéro d'UID de serveur persistant que le serveur
|
||||||
|
DHCPv6 doit utiliser. Cette option n'est normalement pas requise, Dnsmasq
|
||||||
|
créant un DUID automatiquement lorsque cela est nécessaire. Lorsque cette
|
||||||
|
option est positionnée, elle fournit à Dnsmasq les données nécessaires à la
|
||||||
|
création d'un DUID de type DUID-EN. Veuillez noter qu'une fois créé, le DUID
|
||||||
|
est stocké dans la base des baux, aussi changer entre un DUID créé
|
||||||
|
automatiquement et un DUID-EN et vice-versa impose de réinitialiser la base de
|
||||||
|
baux. Le numéro d'ID d'entreprise est assigné par l'IANA, et l'uid est une
|
||||||
|
chaine hexadécimale unique à chaque serveur.
|
||||||
|
.TP
|
||||||
.B \-6 --dhcp-script=<chemin de fichier>
|
.B \-6 --dhcp-script=<chemin de fichier>
|
||||||
Lorsqu'un bail DHCP est créé, ou qu'un ancien est supprimé, le fichier dont le
|
Lorsqu'un bail DHCP est créé, qu'un ancien est supprimé, ou qu'un transfert
|
||||||
|
TFTP est terminé, le fichier dont le
|
||||||
chemin est spécifié est exécuté. Le <chemin de fichier> doit être un chemin
|
chemin est spécifié est exécuté. Le <chemin de fichier> doit être un chemin
|
||||||
absolu, aucune recherche n'est effectuée via la variable d'environnement PATH.
|
absolu, aucune recherche n'est effectuée via la variable d'environnement PATH.
|
||||||
Les arguments fournis à celui-ci sont soit
|
Les arguments fournis à celui-ci sont soit
|
||||||
@@ -1223,6 +1293,10 @@ relai DHCP pour contacter Dnsmasq, si l'adresse IP du relai est connue.
|
|||||||
DNSMASQ_TAGS contient tous les labels fournis pendant la transaction DHCP,
|
DNSMASQ_TAGS contient tous les labels fournis pendant la transaction DHCP,
|
||||||
séparés par des espaces.
|
séparés par des espaces.
|
||||||
|
|
||||||
|
DNSMASQ_LOG_DHCP est positionné si
|
||||||
|
.B --log-dhcp
|
||||||
|
est activé.
|
||||||
|
|
||||||
Pour IPv4 seulement :
|
Pour IPv4 seulement :
|
||||||
|
|
||||||
DNSMASQ_CLIENT_ID, si l'hôte a fourni un identifiant de client.
|
DNSMASQ_CLIENT_ID, si l'hôte a fourni un identifiant de client.
|
||||||
@@ -1262,6 +1336,16 @@ Au démarrage de Dnsmasq, le script sera invoqué pour chacun des baux existants
|
|||||||
dans le fichier des baux. Le script sera lancé avec l'action "del" pour les
|
dans le fichier des baux. Le script sera lancé avec l'action "del" pour les
|
||||||
baux expirés, et "old" pour les autres. Lorsque Dnsmasq reçoit un signal HUP,
|
baux expirés, et "old" pour les autres. Lorsque Dnsmasq reçoit un signal HUP,
|
||||||
le script sera invoqué avec une action "old" pour tous les baux existants.
|
le script sera invoqué avec une action "old" pour tous les baux existants.
|
||||||
|
|
||||||
|
Il existe deux autres actions pouvant apparaître comme argument au script :
|
||||||
|
"init" et "tftp". D'autres sont susceptibles d'être rajoutées dans le futur,
|
||||||
|
aussi les scripts devraient-être écrits de sorte à ignorer les actions
|
||||||
|
inconnues. "init" est décrite ci-dessous dans
|
||||||
|
.B --leasefile-ro.
|
||||||
|
L'action "tftp" est invoquée lorsqu'un transfert de fichier TFTP s'est
|
||||||
|
terminé. Ses arguments sont la taille du fichier en octets, l'adresse à
|
||||||
|
laquelle le fichier a été envoyé, ainsi que le chemin complet du fichier.
|
||||||
|
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-luascript=<chemin>
|
.B --dhcp-luascript=<chemin>
|
||||||
Spécifie un script écrit en Lua, devant être exécuté lorsque des baux sont
|
Spécifie un script écrit en Lua, devant être exécuté lorsque des baux sont
|
||||||
@@ -1276,8 +1360,10 @@ et peut fournir des fonctions
|
|||||||
et
|
et
|
||||||
.B shutdown
|
.B shutdown
|
||||||
qui sont appellées, sans arguments, lorsque dnsmasq démarre ou s'arrête.
|
qui sont appellées, sans arguments, lorsque dnsmasq démarre ou s'arrête.
|
||||||
|
Il peut également fournir une fonction
|
||||||
|
.B tftp.
|
||||||
|
|
||||||
La méthode
|
La fonction
|
||||||
.B lease
|
.B lease
|
||||||
reçoit les informations détaillées dans
|
reçoit les informations détaillées dans
|
||||||
.B --dhcp-script.
|
.B --dhcp-script.
|
||||||
@@ -1301,6 +1387,16 @@ et
|
|||||||
ainsi que
|
ainsi que
|
||||||
.B hostname
|
.B hostname
|
||||||
(le nom d'hôte) dans le cas d'IPv6.
|
(le nom d'hôte) dans le cas d'IPv6.
|
||||||
|
|
||||||
|
La fonction
|
||||||
|
.B tftp
|
||||||
|
est appelée de la même façon que la fonction "lease", et la table contient les
|
||||||
|
labels
|
||||||
|
.B destination_address,
|
||||||
|
.B file_name
|
||||||
|
et
|
||||||
|
.B file_size
|
||||||
|
(respectivement "adresse de destination", "nom de fichier" et "taille de fichier").
|
||||||
.TP
|
.TP
|
||||||
.B --dhcp-scriptuser
|
.B --dhcp-scriptuser
|
||||||
Spécifie l'utilisateur sous lequel le script shell lease-change ou le script
|
Spécifie l'utilisateur sous lequel le script shell lease-change ou le script
|
||||||
@@ -1367,7 +1463,7 @@ Si la gamme d'adresse est fournie sous la forme
|
|||||||
qui a pour effect d'ajouter --local-declarations aux requêtes DNS directes et
|
qui a pour effect d'ajouter --local-declarations aux requêtes DNS directes et
|
||||||
inverses. C-à-d
|
inverses. C-à-d
|
||||||
.B --domain=thekelleys.org.uk,192.168.0.0/24,local
|
.B --domain=thekelleys.org.uk,192.168.0.0/24,local
|
||||||
est indentique à
|
est identique à
|
||||||
.B --domain=thekelleys.org.uk,192.168.0.0/24
|
.B --domain=thekelleys.org.uk,192.168.0.0/24
|
||||||
--local=/thekelleys.org.uk/ --local=/0.168.192.in-addr.arpa/
|
--local=/thekelleys.org.uk/ --local=/0.168.192.in-addr.arpa/
|
||||||
La taille de réseau doit-être de 8, 16 ou 24 pour être valide.
|
La taille de réseau doit-être de 8, 16 ou 24 pour être valide.
|
||||||
@@ -1411,10 +1507,15 @@ Advertisement") sont activées, dnsmasq va annoncer un préfixe pour chaque
|
|||||||
dhcp-range et, par défaut, fournir comme valeur de routeur et de DNS récursif
|
dhcp-range et, par défaut, fournir comme valeur de routeur et de DNS récursif
|
||||||
la valeur d'adresse link-local appropriée parmi celles de la machine sur
|
la valeur d'adresse link-local appropriée parmi celles de la machine sur
|
||||||
laquelle tourne dnsmasq.
|
laquelle tourne dnsmasq.
|
||||||
Les bits "managed address" sont positionnés, sauf pour un dhcp-range marqué
|
Par défaut, les bits "managed address" sont positionnés, et le bit "use SLAAC"
|
||||||
comme "ra-only" (annonce routeur uniquement). Dans ce cas le service d'annonce
|
("utiliser SLAAC") est réinitialisé. Cela peut-être changé pour des
|
||||||
routeur est rendu mais aucun service DHCPv6 n'est assuré, et les bits "managed
|
sous-réseaux donnés par le biais du mot clef de mode décris dans
|
||||||
address" ne sont pas positionnés.
|
.B --dhcp-range.
|
||||||
|
Les paramètres DNS du RFC6106 sont inclus dans les annonces. Par défaut,
|
||||||
|
l'adresse link-local appropriée parmi celles de la machine sur laquelle tourne
|
||||||
|
dnsmasq est spécifiée comme DNS récursif. Si elles sont fournies, les
|
||||||
|
options dns-server et domain-search sont utilisées respectivement pour RDNSS et
|
||||||
|
DNSSL.
|
||||||
.TP
|
.TP
|
||||||
.B --enable-tftp[=<interface>]
|
.B --enable-tftp[=<interface>]
|
||||||
Active la fonction serveur TFTP. Celui-ci est de manière délibérée limité aux
|
Active la fonction serveur TFTP. Celui-ci est de manière délibérée limité aux
|
||||||
|
|||||||
@@ -1128,9 +1128,10 @@ msgstr "DHCP, Proxy im Subnetz %.0s%s%.0s"
|
|||||||
msgid "DHCP, IP range %s -- %s, lease time %s"
|
msgid "DHCP, IP range %s -- %s, lease time %s"
|
||||||
msgstr "DHCP, IP-Bereich %s - %s, Lease-Zeit %s "
|
msgstr "DHCP, IP-Bereich %s - %s, Lease-Zeit %s "
|
||||||
|
|
||||||
|
# FIXME: this and the next few must be full strings to be translatable - do not assemble in code"
|
||||||
#: dnsmasq.c:588
|
#: dnsmasq.c:588
|
||||||
msgid "root is "
|
msgid "root is "
|
||||||
msgstr "FIXME: this and the next few must be full strings to be translatable - do not assemble in code"
|
msgstr ""
|
||||||
|
|
||||||
#: dnsmasq.c:588
|
#: dnsmasq.c:588
|
||||||
msgid "enabled"
|
msgid "enabled"
|
||||||
|
|||||||
+85
-13
@@ -25,6 +25,9 @@ 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 = 0;
|
static int uid = 0;
|
||||||
|
#ifdef HAVE_DNSSEC
|
||||||
|
static struct keydata *keyblock_free = NULL;
|
||||||
|
#endif
|
||||||
|
|
||||||
/* 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 {
|
||||||
@@ -190,6 +193,10 @@ static void cache_free(struct crec *crecp)
|
|||||||
big_free = crecp->name.bname;
|
big_free = crecp->name.bname;
|
||||||
crecp->flags &= ~F_BIGNAME;
|
crecp->flags &= ~F_BIGNAME;
|
||||||
}
|
}
|
||||||
|
#ifdef HAVE_DNSSEC
|
||||||
|
else if (crecp->flags & (F_DNSKEY | F_DS))
|
||||||
|
keydata_free(crecp->addr.key.keydata);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/* insert a new cache entry at the head of the list (youngest entry) */
|
/* insert a new cache entry at the head of the list (youngest entry) */
|
||||||
@@ -233,7 +240,11 @@ static int is_outdated_cname_pointer(struct crec *crecp)
|
|||||||
if (!(crecp->flags & F_CNAME))
|
if (!(crecp->flags & F_CNAME))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (crecp->addr.cname.cache && crecp->addr.cname.uid == crecp->addr.cname.cache->uid)
|
/* NB. record may be reused as DS or DNSKEY, where uid is
|
||||||
|
overloaded for something completely different */
|
||||||
|
if (crecp->addr.cname.cache &&
|
||||||
|
(crecp->addr.cname.cache->flags & (F_IPV4 | F_IPV6)) &&
|
||||||
|
crecp->addr.cname.uid == crecp->addr.cname.cache->uid)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
@@ -280,7 +291,7 @@ static int cache_scan_free(char *name, struct all_addr *addr, time_t now, unsign
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((crecp->flags & F_FORWARD) &&
|
else if ((crecp->flags & F_FORWARD) &&
|
||||||
((flags & crecp->flags & (F_IPV4 | F_IPV6)) || ((crecp->flags | flags) & F_CNAME)) &&
|
((flags & crecp->flags & F_TYPE) || ((crecp->flags | flags) & F_CNAME)) &&
|
||||||
hostname_isequal(cache_get_name(crecp), name))
|
hostname_isequal(cache_get_name(crecp), name))
|
||||||
{
|
{
|
||||||
if (crecp->flags & (F_HOSTS | F_DHCP))
|
if (crecp->flags & (F_HOSTS | F_DHCP))
|
||||||
@@ -360,7 +371,9 @@ struct crec *cache_insert(char *name, struct all_addr *addr,
|
|||||||
int freed_all = flags & F_REVERSE;
|
int freed_all = flags & F_REVERSE;
|
||||||
int free_avail = 0;
|
int free_avail = 0;
|
||||||
|
|
||||||
log_query(flags | F_UPSTREAM, name, addr, NULL);
|
/* Don't log keys */
|
||||||
|
if (flags & (F_IPV4 | F_IPV6))
|
||||||
|
log_query(flags | F_UPSTREAM, name, addr, NULL);
|
||||||
|
|
||||||
/* if previous insertion failed give up now. */
|
/* if previous insertion failed give up now. */
|
||||||
if (insert_error)
|
if (insert_error)
|
||||||
@@ -452,9 +465,7 @@ struct crec *cache_insert(char *name, struct all_addr *addr,
|
|||||||
|
|
||||||
if (addr)
|
if (addr)
|
||||||
new->addr.addr = *addr;
|
new->addr.addr = *addr;
|
||||||
else
|
|
||||||
new->addr.cname.cache = NULL;
|
|
||||||
|
|
||||||
new->ttd = now + (time_t)ttl;
|
new->ttd = now + (time_t)ttl;
|
||||||
new->next = new_chain;
|
new->next = new_chain;
|
||||||
new_chain = new;
|
new_chain = new;
|
||||||
@@ -1150,22 +1161,35 @@ void dump_cache(time_t now)
|
|||||||
if (!is_outdated_cname_pointer(cache))
|
if (!is_outdated_cname_pointer(cache))
|
||||||
a = cache_get_name(cache->addr.cname.cache);
|
a = cache_get_name(cache->addr.cname.cache);
|
||||||
}
|
}
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_DNSSEC
|
||||||
|
else if (cache->flags & F_DNSKEY)
|
||||||
|
{
|
||||||
|
a = daemon->addrbuff;
|
||||||
|
sprintf(a, "%3u %u", cache->addr.key.algo, cache->uid);
|
||||||
|
}
|
||||||
|
else if (cache->flags & F_DS)
|
||||||
|
{
|
||||||
|
a = daemon->addrbuff;
|
||||||
|
sprintf(a, "%5u %3u %3u %u", cache->addr.key.flags_or_keyid,
|
||||||
|
cache->addr.key.algo, cache->addr.key.digest, cache->uid);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
a = daemon->addrbuff;
|
a = daemon->addrbuff;
|
||||||
if (cache->flags & F_IPV4)
|
if (cache->flags & F_IPV4)
|
||||||
inet_ntop(AF_INET, &cache->addr.addr, a, ADDRSTRLEN);
|
inet_ntop(AF_INET, &cache->addr.addr, a, ADDRSTRLEN);
|
||||||
|
#ifdef HAVE_IPV6
|
||||||
else if (cache->flags & F_IPV6)
|
else if (cache->flags & F_IPV6)
|
||||||
inet_ntop(AF_INET6, &cache->addr.addr, a, ADDRSTRLEN);
|
inet_ntop(AF_INET6, &cache->addr.addr, a, ADDRSTRLEN);
|
||||||
}
|
|
||||||
#else
|
|
||||||
else
|
|
||||||
a = inet_ntoa(cache->addr.addr.addr.addr4);
|
|
||||||
#endif
|
#endif
|
||||||
p += sprintf(p, "%-30.30s %s%s%s%s%s%s%s%s%s%s ", a,
|
}
|
||||||
|
|
||||||
|
p += sprintf(p, "%-30.30s %s%s%s%s%s%s%s%s%s%s%s%s%s ", a,
|
||||||
cache->flags & F_IPV4 ? "4" : "",
|
cache->flags & F_IPV4 ? "4" : "",
|
||||||
cache->flags & F_IPV6 ? "6" : "",
|
cache->flags & F_IPV6 ? "6" : "",
|
||||||
|
cache->flags & F_DNSKEY ? "K" : "",
|
||||||
|
cache->flags & F_DS ? "S" : "",
|
||||||
cache->flags & F_CNAME ? "C" : "",
|
cache->flags & F_CNAME ? "C" : "",
|
||||||
cache->flags & F_FORWARD ? "F" : " ",
|
cache->flags & F_FORWARD ? "F" : " ",
|
||||||
cache->flags & F_REVERSE ? "R" : " ",
|
cache->flags & F_REVERSE ? "R" : " ",
|
||||||
@@ -1173,7 +1197,8 @@ void dump_cache(time_t now)
|
|||||||
cache->flags & F_DHCP ? "D" : " ",
|
cache->flags & F_DHCP ? "D" : " ",
|
||||||
cache->flags & F_NEG ? "N" : " ",
|
cache->flags & F_NEG ? "N" : " ",
|
||||||
cache->flags & F_NXDOMAIN ? "X" : " ",
|
cache->flags & F_NXDOMAIN ? "X" : " ",
|
||||||
cache->flags & F_HOSTS ? "H" : " ");
|
cache->flags & F_HOSTS ? "H" : " ",
|
||||||
|
cache->flags & F_DNSSECOK ? "V" : " ");
|
||||||
#ifdef HAVE_BROKEN_RTC
|
#ifdef HAVE_BROKEN_RTC
|
||||||
p += sprintf(p, "%lu", cache->flags & F_IMMORTAL ? 0: (unsigned long)(cache->ttd - now));
|
p += sprintf(p, "%lu", cache->flags & F_IMMORTAL ? 0: (unsigned long)(cache->ttd - now));
|
||||||
#else
|
#else
|
||||||
@@ -1287,3 +1312,50 @@ void log_query(unsigned int flags, char *name, struct all_addr *addr, char *arg)
|
|||||||
my_syslog(LOG_INFO, "%s %s %s %s", source, name, verb, dest);
|
my_syslog(LOG_INFO, "%s %s %s %s", source, name, verb, dest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef HAVE_DNSSEC
|
||||||
|
struct keydata *keydata_alloc(char *data, size_t len)
|
||||||
|
{
|
||||||
|
struct keydata *block, *ret = NULL;
|
||||||
|
struct keydata **prev = &ret;
|
||||||
|
while (len > 0)
|
||||||
|
{
|
||||||
|
if (keyblock_free)
|
||||||
|
{
|
||||||
|
block = keyblock_free;
|
||||||
|
keyblock_free = block->next;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
block = whine_malloc(sizeof(struct keydata));
|
||||||
|
|
||||||
|
if (!block)
|
||||||
|
{
|
||||||
|
/* failed to alloc, free partial chain */
|
||||||
|
keydata_free(ret);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(block->key, data, len > KEYBLOCK_LEN ? KEYBLOCK_LEN : len);
|
||||||
|
data += KEYBLOCK_LEN;
|
||||||
|
len -= KEYBLOCK_LEN;
|
||||||
|
*prev = block;
|
||||||
|
prev = &block->next;
|
||||||
|
block->next = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
void keydata_free(struct keydata *blocks)
|
||||||
|
{
|
||||||
|
struct keydata *tmp;
|
||||||
|
|
||||||
|
if (blocks)
|
||||||
|
{
|
||||||
|
for (tmp = blocks; tmp->next; tmp = tmp->next);
|
||||||
|
tmp->next = keyblock_free;
|
||||||
|
keyblock_free = blocks;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
@@ -18,6 +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 140 /* choose to mininise fragmentation when storing DNSSEC keys */
|
||||||
#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 */
|
||||||
#define FORWARD_TIME 20 /* or 20 seconds */
|
#define FORWARD_TIME 20 /* or 20 seconds */
|
||||||
|
|||||||
@@ -111,6 +111,13 @@ struct dhcp_netid *option_filter(struct dhcp_netid *tags, struct dhcp_netid *con
|
|||||||
last_tag->next = tags;
|
last_tag->next = tags;
|
||||||
tagif = run_tag_if(context_tags);
|
tagif = run_tag_if(context_tags);
|
||||||
|
|
||||||
|
/* reset stuff with tag:!<tag> which now matches. */
|
||||||
|
for (opt = opts; opt; opt = opt->next)
|
||||||
|
if (!(opt->flags & (DHOPT_ENCAPSULATE | DHOPT_VENDOR | DHOPT_RFC3925)) &&
|
||||||
|
(opt->flags & DHOPT_TAGOK) &&
|
||||||
|
!match_netid(opt->netid, tagif, 0))
|
||||||
|
opt->flags &= ~DHOPT_TAGOK;
|
||||||
|
|
||||||
for (opt = opts; opt; opt = opt->next)
|
for (opt = opts; opt; opt = opt->next)
|
||||||
if (!(opt->flags & (DHOPT_ENCAPSULATE | DHOPT_VENDOR | DHOPT_RFC3925 | DHOPT_TAGOK)) &&
|
if (!(opt->flags & (DHOPT_ENCAPSULATE | DHOPT_VENDOR | DHOPT_RFC3925 | DHOPT_TAGOK)) &&
|
||||||
match_netid(opt->netid, tagif, 0))
|
match_netid(opt->netid, tagif, 0))
|
||||||
@@ -444,6 +451,41 @@ void join_multicast(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_LINUX_NETWORK
|
||||||
|
void bindtodevice(int fd)
|
||||||
|
{
|
||||||
|
/* If we are doing DHCP on exactly one interface, and running linux, do SO_BINDTODEVICE
|
||||||
|
to that device. This is for the use case of (eg) OpenStack, which runs a new
|
||||||
|
dnsmasq instance for each VLAN interface it creates. Without the BINDTODEVICE,
|
||||||
|
individual processes don't always see the packets they should.
|
||||||
|
SO_BINDTODEVICE is only available Linux. */
|
||||||
|
|
||||||
|
struct irec *iface, *found;
|
||||||
|
|
||||||
|
for (found = NULL, iface = daemon->interfaces; iface; iface = iface->next)
|
||||||
|
if (iface->dhcp_ok)
|
||||||
|
{
|
||||||
|
if (!found)
|
||||||
|
found = iface;
|
||||||
|
else if (strcmp(found->name, iface->name) != 0)
|
||||||
|
{
|
||||||
|
/* more than one. */
|
||||||
|
found = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found)
|
||||||
|
{
|
||||||
|
struct ifreq ifr;
|
||||||
|
strcpy(ifr.ifr_name, found->name);
|
||||||
|
/* only allowed by root. */
|
||||||
|
if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, (void *)&ifr, sizeof(ifr)) == -1 &&
|
||||||
|
errno != EPERM)
|
||||||
|
die(_("failed to set SO_BINDTODEVICE on DHCP socket: %s"), NULL, EC_BADNET);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
static const struct opttab_t {
|
static const struct opttab_t {
|
||||||
char *name;
|
char *name;
|
||||||
|
|||||||
@@ -54,6 +54,7 @@
|
|||||||
#define OPTION6_RECONFIGURE_MSG 19
|
#define OPTION6_RECONFIGURE_MSG 19
|
||||||
#define OPTION6_RECONF_ACCEPT 20
|
#define OPTION6_RECONF_ACCEPT 20
|
||||||
#define OPTION6_DNS_SERVER 23
|
#define OPTION6_DNS_SERVER 23
|
||||||
|
#define OPTION6_DOMAIN_SEARCH 24
|
||||||
#define OPTION6_REMOTE_ID 37
|
#define OPTION6_REMOTE_ID 37
|
||||||
#define OPTION6_SUBSCRIBER_ID 38
|
#define OPTION6_SUBSCRIBER_ID 38
|
||||||
#define OPTION6_FQDN 39
|
#define OPTION6_FQDN 39
|
||||||
|
|||||||
+2
-2
@@ -33,12 +33,12 @@ void dhcp6_init(void)
|
|||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
struct sockaddr_in6 saddr;
|
struct sockaddr_in6 saddr;
|
||||||
#if defined(IP_TOS) && defined(IPTOS_CLASS_CS6)
|
#if defined(IPV6_TCLASS) && defined(IPTOS_CLASS_CS6)
|
||||||
int class = IPTOS_CLASS_CS6;
|
int class = IPTOS_CLASS_CS6;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if ((fd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP)) == -1 ||
|
if ((fd = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP)) == -1 ||
|
||||||
#if defined(IP_TOS) && defined(IPTOS_CLASS_CS6)
|
#if defined(IPV6_TCLASS) && defined(IPTOS_CLASS_CS6)
|
||||||
setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, &class, sizeof(class)) == -1 ||
|
setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, &class, sizeof(class)) == -1 ||
|
||||||
#endif
|
#endif
|
||||||
!fix_fd(fd) ||
|
!fix_fd(fd) ||
|
||||||
|
|||||||
@@ -209,6 +209,21 @@ int main (int argc, char **argv)
|
|||||||
for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next)
|
for (if_tmp = daemon->if_names; if_tmp; if_tmp = if_tmp->next)
|
||||||
if (if_tmp->name && !if_tmp->used)
|
if (if_tmp->name && !if_tmp->used)
|
||||||
die(_("unknown interface %s"), if_tmp->name, EC_BADNET);
|
die(_("unknown interface %s"), if_tmp->name, EC_BADNET);
|
||||||
|
|
||||||
|
#if defined(HAVE_LINUX_NETWORK) && defined(HAVE_DHCP)
|
||||||
|
/* after enumerate_interfaces() */
|
||||||
|
if (daemon->dhcp)
|
||||||
|
{
|
||||||
|
bindtodevice(daemon->dhcpfd);
|
||||||
|
if (daemon->enable_pxe)
|
||||||
|
bindtodevice(daemon->pxefd);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_LINUX_NETWORK) && defined(HAVE_DHCP6)
|
||||||
|
if (daemon->dhcp6)
|
||||||
|
bindtodevice(daemon->dhcp6fd);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
create_wildcard_listeners();
|
create_wildcard_listeners();
|
||||||
|
|||||||
+36
-8
@@ -217,7 +217,8 @@ struct event_desc {
|
|||||||
#define OPT_CONNTRACK 35
|
#define OPT_CONNTRACK 35
|
||||||
#define OPT_FQDN_UPDATE 36
|
#define OPT_FQDN_UPDATE 36
|
||||||
#define OPT_RA 37
|
#define OPT_RA 37
|
||||||
#define OPT_LAST 38
|
#define OPT_TFTP_LC 38
|
||||||
|
#define OPT_LAST 39
|
||||||
|
|
||||||
/* 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. */
|
||||||
@@ -297,17 +298,30 @@ union bigname {
|
|||||||
union bigname *next; /* freelist */
|
union bigname *next; /* freelist */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct keydata {
|
||||||
|
struct keydata *next;
|
||||||
|
unsigned char key[KEYBLOCK_LEN];
|
||||||
|
};
|
||||||
|
|
||||||
struct crec {
|
struct crec {
|
||||||
struct crec *next, *prev, *hash_next;
|
struct crec *next, *prev, *hash_next;
|
||||||
time_t ttd; /* time to die */
|
/* union is 16 bytes when doing IPv6, 8 bytes on 32 bit machines without IPv6 */
|
||||||
int uid;
|
|
||||||
union {
|
union {
|
||||||
struct all_addr addr;
|
struct all_addr addr;
|
||||||
struct {
|
struct {
|
||||||
struct crec *cache;
|
struct crec *cache;
|
||||||
int uid;
|
int uid;
|
||||||
} cname;
|
} cname;
|
||||||
|
struct {
|
||||||
|
struct keydata *keydata;
|
||||||
|
unsigned char algo;
|
||||||
|
unsigned char digest; /* DS only */
|
||||||
|
unsigned short flags_or_keyid; /* flags for DNSKEY, keyid for DS */
|
||||||
|
} key;
|
||||||
} addr;
|
} addr;
|
||||||
|
time_t ttd; /* time to die */
|
||||||
|
/* used as keylen if F_DS or F_DNSKEY, index to source for F_HOSTS */
|
||||||
|
int uid;
|
||||||
unsigned short flags;
|
unsigned short flags;
|
||||||
union {
|
union {
|
||||||
char sname[SMALLDNAME];
|
char sname[SMALLDNAME];
|
||||||
@@ -328,14 +342,21 @@ struct crec {
|
|||||||
#define F_BIGNAME (1u<<9)
|
#define F_BIGNAME (1u<<9)
|
||||||
#define F_NXDOMAIN (1u<<10)
|
#define F_NXDOMAIN (1u<<10)
|
||||||
#define F_CNAME (1u<<11)
|
#define F_CNAME (1u<<11)
|
||||||
#define F_NOERR (1u<<12)
|
#define F_DNSKEY (1u<<12)
|
||||||
#define F_CONFIG (1u<<13)
|
#define F_CONFIG (1u<<13)
|
||||||
|
#define F_DS (1u<<14)
|
||||||
|
#define F_DNSSECOK (1u<<15)
|
||||||
|
|
||||||
/* below here are only valid as args to log_query: cache
|
/* below here are only valid as args to log_query: cache
|
||||||
entries are limited to 16 bits */
|
entries are limited to 16 bits */
|
||||||
#define F_UPSTREAM (1u<<16)
|
#define F_UPSTREAM (1u<<16)
|
||||||
#define F_RRNAME (1u<<17)
|
#define F_RRNAME (1u<<17)
|
||||||
#define F_SERVER (1u<<18)
|
#define F_SERVER (1u<<18)
|
||||||
#define F_QUERY (1u<<19)
|
#define F_QUERY (1u<<19)
|
||||||
|
#define F_NOERR (1u<<20)
|
||||||
|
/* composites */
|
||||||
|
#define F_TYPE (F_IPV4 | F_IPV6 | F_DNSKEY | F_DS) /* Only one may be set */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* struct sockaddr is not large enough to hold any address,
|
/* struct sockaddr is not large enough to hold any address,
|
||||||
@@ -388,7 +409,7 @@ struct server {
|
|||||||
struct irec {
|
struct irec {
|
||||||
union mysockaddr addr;
|
union mysockaddr addr;
|
||||||
struct in_addr netmask; /* only valid for IPv4 */
|
struct in_addr netmask; /* only valid for IPv4 */
|
||||||
int tftp_ok, mtu, done, dad;
|
int tftp_ok, dhcp_ok, mtu, done, dad;
|
||||||
char *name;
|
char *name;
|
||||||
struct irec *next;
|
struct irec *next;
|
||||||
};
|
};
|
||||||
@@ -838,6 +859,10 @@ char *get_domain(struct in_addr addr);
|
|||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
char *get_domain6(struct in6_addr *addr);
|
char *get_domain6(struct in6_addr *addr);
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_DNSSEC
|
||||||
|
struct keydata *keydata_alloc(char *data, size_t len);
|
||||||
|
void keydata_free(struct keydata *blocks);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* rfc1035.c */
|
/* rfc1035.c */
|
||||||
unsigned int extract_request(struct dns_header *header, size_t qlen,
|
unsigned int extract_request(struct dns_header *header, size_t qlen,
|
||||||
@@ -916,7 +941,7 @@ void server_gone(struct server *server);
|
|||||||
struct frec *get_new_frec(time_t now, int *wait);
|
struct frec *get_new_frec(time_t now, int *wait);
|
||||||
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, int *errp);
|
unsigned int iface);
|
||||||
|
|
||||||
/* network.c */
|
/* network.c */
|
||||||
int indextoname(int fd, int index, char *name);
|
int indextoname(int fd, int index, char *name);
|
||||||
@@ -975,7 +1000,7 @@ u64 lease_find_max_addr6(struct dhcp_context *context);
|
|||||||
void lease_ping_reply(struct in6_addr *sender, unsigned char *packet, char *interface);
|
void lease_ping_reply(struct in6_addr *sender, unsigned char *packet, char *interface);
|
||||||
#endif
|
#endif
|
||||||
void lease_set_hwaddr(struct dhcp_lease *lease, unsigned char *hwaddr,
|
void lease_set_hwaddr(struct dhcp_lease *lease, unsigned char *hwaddr,
|
||||||
unsigned char *clid, int hw_len, int hw_type, int clid_len, time_t now);
|
unsigned char *clid, int hw_len, int hw_type, int clid_len, time_t now, int force);
|
||||||
void lease_set_hostname(struct dhcp_lease *lease, char *name, int auth, char *domain, char *config_domain);
|
void lease_set_hostname(struct dhcp_lease *lease, char *name, int auth, char *domain, char *config_domain);
|
||||||
void lease_set_expires(struct dhcp_lease *lease, unsigned int len, time_t now);
|
void lease_set_expires(struct dhcp_lease *lease, unsigned int len, time_t now);
|
||||||
void lease_set_interface(struct dhcp_lease *lease, int interface, time_t now);
|
void lease_set_interface(struct dhcp_lease *lease, int interface, time_t now);
|
||||||
@@ -1108,6 +1133,9 @@ u16 lookup_dhcp_opt(int prot, char *name);
|
|||||||
u16 lookup_dhcp_len(int prot, u16 val);
|
u16 lookup_dhcp_len(int prot, u16 val);
|
||||||
char *option_string(int prot, unsigned int opt, unsigned char *val,
|
char *option_string(int prot, unsigned int opt, unsigned char *val,
|
||||||
int opt_len, char *buf, int buf_len);
|
int opt_len, char *buf, int buf_len);
|
||||||
|
#ifdef HAVE_LINUX_NETWORK
|
||||||
|
void bindtodevice(int fd);
|
||||||
|
#endif
|
||||||
# ifdef HAVE_DHCP6
|
# ifdef HAVE_DHCP6
|
||||||
void display_opts6(void);
|
void display_opts6(void);
|
||||||
void join_multicast(void);
|
void join_multicast(void);
|
||||||
@@ -1138,7 +1166,7 @@ void ra_start_unsolicted(time_t now, struct dhcp_context *context);
|
|||||||
/* slaac.c */
|
/* slaac.c */
|
||||||
#ifdef HAVE_DHCP6
|
#ifdef HAVE_DHCP6
|
||||||
void build_subnet_map(void);
|
void build_subnet_map(void);
|
||||||
void slaac_add_addrs(struct dhcp_lease *lease, time_t now);
|
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);
|
||||||
void schedule_subnet_map(void);
|
void schedule_subnet_map(void);
|
||||||
|
|||||||
+5
-8
@@ -28,7 +28,7 @@ static struct randfd *allocate_rfd(int family);
|
|||||||
unless nowild is true, when we just send it with the kernel default */
|
unless nowild is true, when we just send it with the kernel default */
|
||||||
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, int *errp)
|
unsigned int iface)
|
||||||
{
|
{
|
||||||
struct msghdr msg;
|
struct msghdr msg;
|
||||||
struct iovec iov[1];
|
struct iovec iov[1];
|
||||||
@@ -110,10 +110,7 @@ int send_from(int fd, int nowild, char *packet, size_t len,
|
|||||||
if (retry_send())
|
if (retry_send())
|
||||||
goto retry;
|
goto retry;
|
||||||
|
|
||||||
if (errp)
|
my_syslog(LOG_ERR, _("failed to send packet: %s"), strerror(errno));
|
||||||
*errp = errno;
|
|
||||||
else
|
|
||||||
my_syslog(LOG_ERR, _("failed to send packet: %s"), strerror(errno));
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -439,7 +436,7 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
|
|||||||
if (udpfd != -1)
|
if (udpfd != -1)
|
||||||
{
|
{
|
||||||
plen = setup_reply(header, plen, addrp, flags, daemon->local_ttl);
|
plen = setup_reply(header, plen, addrp, flags, daemon->local_ttl);
|
||||||
send_from(udpfd, option_bool(OPT_NOWILD), (char *)header, plen, udpaddr, dst_addr, dst_iface, NULL);
|
send_from(udpfd, option_bool(OPT_NOWILD), (char *)header, plen, udpaddr, dst_addr, dst_iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -628,7 +625,7 @@ void reply_query(int fd, int family, time_t now)
|
|||||||
header->id = htons(forward->orig_id);
|
header->id = htons(forward->orig_id);
|
||||||
header->hb4 |= HB4_RA; /* recursion if available */
|
header->hb4 |= HB4_RA; /* recursion if available */
|
||||||
send_from(forward->fd, option_bool(OPT_NOWILD), daemon->packet, nn,
|
send_from(forward->fd, option_bool(OPT_NOWILD), daemon->packet, nn,
|
||||||
&forward->source, &forward->dest, forward->iface, NULL);
|
&forward->source, &forward->dest, forward->iface);
|
||||||
}
|
}
|
||||||
free_frec(forward); /* cancel */
|
free_frec(forward); /* cancel */
|
||||||
}
|
}
|
||||||
@@ -823,7 +820,7 @@ void receive_query(struct listener *listen, time_t now)
|
|||||||
if (m >= 1)
|
if (m >= 1)
|
||||||
{
|
{
|
||||||
send_from(listen->fd, option_bool(OPT_NOWILD), (char *)header,
|
send_from(listen->fd, option_bool(OPT_NOWILD), (char *)header,
|
||||||
m, &source_addr, &dst_addr, if_index, NULL);
|
m, &source_addr, &dst_addr, if_index);
|
||||||
daemon->local_answer++;
|
daemon->local_answer++;
|
||||||
}
|
}
|
||||||
else if (forward_query(listen->fd, &source_addr, &dst_addr, if_index,
|
else if (forward_query(listen->fd, &source_addr, &dst_addr, if_index,
|
||||||
|
|||||||
+13
-7
@@ -98,7 +98,7 @@ void lease_init(time_t now)
|
|||||||
hw_type = ARPHRD_ETHER;
|
hw_type = ARPHRD_ETHER;
|
||||||
|
|
||||||
lease_set_hwaddr(lease, (unsigned char *)daemon->dhcp_buff2, (unsigned char *)daemon->packet,
|
lease_set_hwaddr(lease, (unsigned char *)daemon->dhcp_buff2, (unsigned char *)daemon->packet,
|
||||||
hw_len, hw_type, clid_len, now);
|
hw_len, hw_type, clid_len, now, 0);
|
||||||
|
|
||||||
if (strcmp(daemon->dhcp_buff, "*") != 0)
|
if (strcmp(daemon->dhcp_buff, "*") != 0)
|
||||||
lease_set_hostname(lease, daemon->dhcp_buff, 0, get_domain(lease->addr), NULL);
|
lease_set_hostname(lease, daemon->dhcp_buff, 0, get_domain(lease->addr), NULL);
|
||||||
@@ -119,7 +119,7 @@ void lease_init(time_t now)
|
|||||||
|
|
||||||
if ((lease = lease6_allocate(&addr.addr.addr6, lease_type)))
|
if ((lease = lease6_allocate(&addr.addr.addr6, lease_type)))
|
||||||
{
|
{
|
||||||
lease_set_hwaddr(lease, NULL, (unsigned char *)daemon->packet, 0, hw_type, clid_len, now);
|
lease_set_hwaddr(lease, NULL, (unsigned char *)daemon->packet, 0, hw_type, clid_len, now, 0);
|
||||||
|
|
||||||
if (strcmp(daemon->dhcp_buff, "*") != 0)
|
if (strcmp(daemon->dhcp_buff, "*") != 0)
|
||||||
lease_set_hostname(lease, daemon->dhcp_buff, 0, get_domain6((struct in6_addr *)lease->hwaddr), NULL);
|
lease_set_hostname(lease, daemon->dhcp_buff, 0, get_domain6((struct in6_addr *)lease->hwaddr), NULL);
|
||||||
@@ -373,7 +373,10 @@ static int find_interface_v6(struct in6_addr *local, int prefix,
|
|||||||
|
|
||||||
void lease_ping_reply(struct in6_addr *sender, unsigned char *packet, char *interface)
|
void lease_ping_reply(struct in6_addr *sender, unsigned char *packet, char *interface)
|
||||||
{
|
{
|
||||||
slaac_ping_reply(sender, packet, interface, leases);
|
/* We may be doing RA but not DHCPv4, in which case the lease
|
||||||
|
database may not exist and we have nothing to do anyway */
|
||||||
|
if (daemon->dhcp)
|
||||||
|
slaac_ping_reply(sender, packet, interface, leases);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
@@ -699,13 +702,16 @@ void lease_set_expires(struct dhcp_lease *lease, unsigned int len, time_t now)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void lease_set_hwaddr(struct dhcp_lease *lease, unsigned char *hwaddr,
|
void lease_set_hwaddr(struct dhcp_lease *lease, unsigned char *hwaddr,
|
||||||
unsigned char *clid, int hw_len, int hw_type, int clid_len, time_t now)
|
unsigned char *clid, int hw_len, int hw_type, int clid_len,
|
||||||
|
time_t now, int force)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_DHCP6
|
#ifdef HAVE_DHCP6
|
||||||
int change = 0;
|
int change = force;
|
||||||
lease->flags |= LEASE_HAVE_HWADDR;
|
lease->flags |= LEASE_HAVE_HWADDR;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
(void)force;
|
||||||
|
|
||||||
if (hw_len != lease->hwaddr_len ||
|
if (hw_len != lease->hwaddr_len ||
|
||||||
hw_type != lease->hwaddr_type ||
|
hw_type != lease->hwaddr_type ||
|
||||||
(hw_len != 0 && memcmp(lease->hwaddr, hwaddr, hw_len) != 0))
|
(hw_len != 0 && memcmp(lease->hwaddr, hwaddr, hw_len) != 0))
|
||||||
@@ -755,7 +761,7 @@ void lease_set_hwaddr(struct dhcp_lease *lease, unsigned char *hwaddr,
|
|||||||
|
|
||||||
#ifdef HAVE_DHCP6
|
#ifdef HAVE_DHCP6
|
||||||
if (change)
|
if (change)
|
||||||
slaac_add_addrs(lease, now);
|
slaac_add_addrs(lease, now, force);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -883,7 +889,7 @@ void lease_set_interface(struct dhcp_lease *lease, int interface, time_t now)
|
|||||||
lease->flags |= LEASE_CHANGED;
|
lease->flags |= LEASE_CHANGED;
|
||||||
|
|
||||||
#ifdef HAVE_DHCP6
|
#ifdef HAVE_DHCP6
|
||||||
slaac_add_addrs(lease, now);
|
slaac_add_addrs(lease, now, 0);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+16
-5
@@ -162,6 +162,7 @@ static int iface_allowed(struct irec **irecp, int if_index,
|
|||||||
int fd, mtu = 0, loopback;
|
int fd, mtu = 0, loopback;
|
||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
int tftp_ok = daemon->tftp_unlimited;
|
int tftp_ok = daemon->tftp_unlimited;
|
||||||
|
int dhcp_ok = 1;
|
||||||
#ifdef HAVE_DHCP
|
#ifdef HAVE_DHCP
|
||||||
struct iname *tmp;
|
struct iname *tmp;
|
||||||
#endif
|
#endif
|
||||||
@@ -190,6 +191,9 @@ static int iface_allowed(struct irec **irecp, int if_index,
|
|||||||
}
|
}
|
||||||
|
|
||||||
loopback = ifr.ifr_flags & IFF_LOOPBACK;
|
loopback = ifr.ifr_flags & IFF_LOOPBACK;
|
||||||
|
|
||||||
|
if (loopback)
|
||||||
|
dhcp_ok = 0;
|
||||||
|
|
||||||
if (ioctl(fd, SIOCGIFMTU, &ifr) != -1)
|
if (ioctl(fd, SIOCGIFMTU, &ifr) != -1)
|
||||||
mtu = ifr.ifr_mtu;
|
mtu = ifr.ifr_mtu;
|
||||||
@@ -238,7 +242,10 @@ static int iface_allowed(struct irec **irecp, int if_index,
|
|||||||
#ifdef HAVE_DHCP
|
#ifdef HAVE_DHCP
|
||||||
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
for (tmp = daemon->dhcp_except; tmp; tmp = tmp->next)
|
||||||
if (tmp->name && (strcmp(tmp->name, ifr.ifr_name) == 0))
|
if (tmp->name && (strcmp(tmp->name, ifr.ifr_name) == 0))
|
||||||
tftp_ok = 0;
|
{
|
||||||
|
tftp_ok = 0;
|
||||||
|
dhcp_ok = 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
@@ -254,14 +261,18 @@ static int iface_allowed(struct irec **irecp, int if_index,
|
|||||||
iface->addr = *addr;
|
iface->addr = *addr;
|
||||||
iface->netmask = netmask;
|
iface->netmask = netmask;
|
||||||
iface->tftp_ok = tftp_ok;
|
iface->tftp_ok = tftp_ok;
|
||||||
|
iface->dhcp_ok = dhcp_ok;
|
||||||
iface->mtu = mtu;
|
iface->mtu = mtu;
|
||||||
iface->dad = dad;
|
iface->dad = dad;
|
||||||
iface->done = 0;
|
iface->done = 0;
|
||||||
if ((iface->name = whine_malloc(strlen(ifr.ifr_name)+1)))
|
if ((iface->name = whine_malloc(strlen(ifr.ifr_name)+1)))
|
||||||
strcpy(iface->name, ifr.ifr_name);
|
{
|
||||||
iface->next = *irecp;
|
strcpy(iface->name, ifr.ifr_name);
|
||||||
*irecp = iface;
|
iface->next = *irecp;
|
||||||
return 1;
|
*irecp = iface;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
free(iface);
|
||||||
}
|
}
|
||||||
|
|
||||||
errno = ENOMEM;
|
errno = ENOMEM;
|
||||||
|
|||||||
+28
-13
@@ -117,6 +117,7 @@ struct myoption {
|
|||||||
#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
|
||||||
|
|
||||||
#ifdef HAVE_GETOPT_LONG
|
#ifdef HAVE_GETOPT_LONG
|
||||||
static const struct option opts[] =
|
static const struct option opts[] =
|
||||||
@@ -196,6 +197,7 @@ static const struct myoption opts[] =
|
|||||||
{ "tftp-unique-root", 0, 0, LOPT_APREF },
|
{ "tftp-unique-root", 0, 0, LOPT_APREF },
|
||||||
{ "tftp-root", 1, 0, LOPT_PREFIX },
|
{ "tftp-root", 1, 0, LOPT_PREFIX },
|
||||||
{ "tftp-max", 1, 0, LOPT_TFTP_MAX },
|
{ "tftp-max", 1, 0, LOPT_TFTP_MAX },
|
||||||
|
{ "tftp-lowercase", 0, 0, LOPT_TFTP_LC },
|
||||||
{ "ptr-record", 1, 0, LOPT_PTR },
|
{ "ptr-record", 1, 0, LOPT_PTR },
|
||||||
{ "naptr-record", 1, 0, LOPT_NAPTR },
|
{ "naptr-record", 1, 0, LOPT_NAPTR },
|
||||||
{ "bridge-interface", 1, 0 , LOPT_BRIDGE },
|
{ "bridge-interface", 1, 0 , LOPT_BRIDGE },
|
||||||
@@ -342,6 +344,7 @@ static struct {
|
|||||||
{ LOPT_SECURE, OPT_TFTP_SECURE, NULL, gettext_noop("Allow access only to files owned by the user running dnsmasq."), NULL },
|
{ LOPT_SECURE, OPT_TFTP_SECURE, NULL, gettext_noop("Allow access only to files owned by the user running dnsmasq."), NULL },
|
||||||
{ LOPT_TFTP_MAX, ARG_ONE, "<integer>", gettext_noop("Maximum number of conncurrent TFTP transfers (defaults to %s)."), "#" },
|
{ LOPT_TFTP_MAX, ARG_ONE, "<integer>", gettext_noop("Maximum number of conncurrent TFTP transfers (defaults to %s)."), "#" },
|
||||||
{ LOPT_NOBLOCK, OPT_TFTP_NOBLOCK, NULL, gettext_noop("Disable the TFTP blocksize extension."), NULL },
|
{ LOPT_NOBLOCK, OPT_TFTP_NOBLOCK, NULL, gettext_noop("Disable the TFTP blocksize extension."), NULL },
|
||||||
|
{ LOPT_TFTP_LC, OPT_TFTP_LC, NULL, gettext_noop("Convert TFTP filenames to lowercase"), NULL },
|
||||||
{ LOPT_TFTPPORTS, ARG_ONE, "<start>,<end>", gettext_noop("Ephemeral port range for use by TFTP transfers."), NULL },
|
{ LOPT_TFTPPORTS, ARG_ONE, "<start>,<end>", gettext_noop("Ephemeral port range for use by TFTP transfers."), NULL },
|
||||||
{ LOPT_LOG_OPTS, OPT_LOG_OPTS, NULL, gettext_noop("Extra logging for DHCP."), NULL },
|
{ LOPT_LOG_OPTS, OPT_LOG_OPTS, NULL, gettext_noop("Extra logging for DHCP."), NULL },
|
||||||
{ LOPT_MAX_LOGS, ARG_ONE, "[=<integer>]", gettext_noop("Enable async. logging; optionally set queue length."), NULL },
|
{ LOPT_MAX_LOGS, ARG_ONE, "[=<integer>]", gettext_noop("Enable async. logging; optionally set queue length."), NULL },
|
||||||
@@ -1000,6 +1003,7 @@ static char *parse_dhcp_opt(char *arg, int flags)
|
|||||||
while (arg && *arg)
|
while (arg && *arg)
|
||||||
{
|
{
|
||||||
u16 len = strlen(arg);
|
u16 len = strlen(arg);
|
||||||
|
unhide_metas(arg);
|
||||||
PUTSHORT(len, p);
|
PUTSHORT(len, p);
|
||||||
memcpy(p, arg, len);
|
memcpy(p, arg, len);
|
||||||
p += len;
|
p += len;
|
||||||
@@ -1013,29 +1017,40 @@ static char *parse_dhcp_opt(char *arg, int flags)
|
|||||||
}
|
}
|
||||||
else if (comma && (opt_len & OT_RFC1035_NAME))
|
else if (comma && (opt_len & OT_RFC1035_NAME))
|
||||||
{
|
{
|
||||||
int i, commas = 1;
|
unsigned char *p = NULL, *newp, *end;
|
||||||
unsigned char *p, *newp;
|
int len = 0;
|
||||||
|
|
||||||
for (i = 0; comma[i]; i++)
|
|
||||||
if (comma[i] == ',')
|
|
||||||
commas++;
|
|
||||||
|
|
||||||
newp = opt_malloc(strlen(comma)+(2*commas));
|
|
||||||
p = newp;
|
|
||||||
arg = comma;
|
arg = comma;
|
||||||
comma = split(arg);
|
comma = split(arg);
|
||||||
|
|
||||||
while (arg && *arg)
|
while (arg && *arg)
|
||||||
{
|
{
|
||||||
p = do_rfc1035_name(p, arg);
|
char *dom = canonicalise_opt(arg);
|
||||||
*p++ = 0;
|
if (!dom)
|
||||||
|
{
|
||||||
|
problem = _("bad domain in dhcp-option");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
newp = opt_malloc(len + strlen(dom) + 2);
|
||||||
|
|
||||||
|
if (p)
|
||||||
|
{
|
||||||
|
memcpy(newp, p, len);
|
||||||
|
free(p);
|
||||||
|
}
|
||||||
|
|
||||||
|
p = newp;
|
||||||
|
end = do_rfc1035_name(p + len, dom);
|
||||||
|
*end++ = 0;
|
||||||
|
len = end - p;
|
||||||
|
free(dom);
|
||||||
|
|
||||||
arg = comma;
|
arg = comma;
|
||||||
comma = split(arg);
|
comma = split(arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
new->val = newp;
|
new->val = p;
|
||||||
new->len = p - newp;
|
new->len = len;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ struct prefix_opt {
|
|||||||
#define ICMP6_OPT_PREFIX 3
|
#define ICMP6_OPT_PREFIX 3
|
||||||
#define ICMP6_OPT_MTU 5
|
#define ICMP6_OPT_MTU 5
|
||||||
#define ICMP6_OPT_RDNSS 25
|
#define ICMP6_OPT_RDNSS 25
|
||||||
|
#define ICMP6_OPT_DNSSL 31
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
+139
-75
@@ -29,6 +29,7 @@
|
|||||||
struct ra_param {
|
struct ra_param {
|
||||||
int ind, managed, other, found_context, first;
|
int ind, managed, other, found_context, first;
|
||||||
char *if_name;
|
char *if_name;
|
||||||
|
struct dhcp_netid *tags;
|
||||||
struct in6_addr link_local;
|
struct in6_addr link_local;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -50,7 +51,7 @@ void ra_init(time_t now)
|
|||||||
{
|
{
|
||||||
struct icmp6_filter filter;
|
struct icmp6_filter filter;
|
||||||
int fd;
|
int fd;
|
||||||
#if defined(IP_TOS) && defined(IPTOS_CLASS_CS6)
|
#if defined(IPV6_TCLASS) && defined(IPTOS_CLASS_CS6)
|
||||||
int class = IPTOS_CLASS_CS6;
|
int class = IPTOS_CLASS_CS6;
|
||||||
#endif
|
#endif
|
||||||
int val = 255; /* radvd uses this value */
|
int val = 255; /* radvd uses this value */
|
||||||
@@ -72,7 +73,7 @@ void ra_init(time_t now)
|
|||||||
|
|
||||||
if ((fd = socket(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) == -1 ||
|
if ((fd = socket(PF_INET6, SOCK_RAW, IPPROTO_ICMPV6)) == -1 ||
|
||||||
getsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &hop_limit, &len) ||
|
getsockopt(fd, IPPROTO_IPV6, IPV6_UNICAST_HOPS, &hop_limit, &len) ||
|
||||||
#if defined(IP_TOS) && defined(IPTOS_CLASS_CS6)
|
#if defined(IPV6_TCLASS) && defined(IPTOS_CLASS_CS6)
|
||||||
setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, &class, sizeof(class)) == -1 ||
|
setsockopt(fd, IPPROTO_IPV6, IPV6_TCLASS, &class, sizeof(class)) == -1 ||
|
||||||
#endif
|
#endif
|
||||||
!fix_fd(fd) ||
|
!fix_fd(fd) ||
|
||||||
@@ -116,8 +117,7 @@ void icmp6_packet(void)
|
|||||||
char control6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
|
char control6[CMSG_SPACE(sizeof(struct in6_pktinfo))];
|
||||||
} control_u;
|
} control_u;
|
||||||
struct sockaddr_in6 from;
|
struct sockaddr_in6 from;
|
||||||
unsigned char *p;
|
unsigned char *packet;
|
||||||
char *mac = "";
|
|
||||||
struct iname *tmp;
|
struct iname *tmp;
|
||||||
struct dhcp_context *context;
|
struct dhcp_context *context;
|
||||||
|
|
||||||
@@ -132,6 +132,8 @@ void icmp6_packet(void)
|
|||||||
|
|
||||||
if ((sz = recv_dhcp_packet(daemon->icmp6fd, &msg)) == -1 || sz < 8)
|
if ((sz = recv_dhcp_packet(daemon->icmp6fd, &msg)) == -1 || sz < 8)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
packet = (unsigned char *)daemon->outpacket.iov_base;
|
||||||
|
|
||||||
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
for (cmptr = CMSG_FIRSTHDR(&msg); cmptr; cmptr = CMSG_NXTHDR(&msg, cmptr))
|
||||||
if (cmptr->cmsg_level == IPPROTO_IPV6 && cmptr->cmsg_type == daemon->v6pktinfo)
|
if (cmptr->cmsg_level == IPPROTO_IPV6 && cmptr->cmsg_type == daemon->v6pktinfo)
|
||||||
@@ -160,36 +162,25 @@ void icmp6_packet(void)
|
|||||||
if (!context->interface || strcmp(context->interface, interface) == 0)
|
if (!context->interface || strcmp(context->interface, interface) == 0)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (!context)
|
if (!context || packet[1] != 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
p = (unsigned char *)daemon->outpacket.iov_base;
|
if (packet[0] == ICMP6_ECHO_REPLY)
|
||||||
|
lease_ping_reply(&from.sin6_addr, packet, interface);
|
||||||
if (p[1] != 0)
|
else if (packet[0] == ND_ROUTER_SOLICIT)
|
||||||
return;
|
|
||||||
|
|
||||||
if (p[0] == ICMP6_ECHO_REPLY)
|
|
||||||
{
|
{
|
||||||
/* We may be doing RA but not DHCPv4, in which case the lease
|
char *mac = "";
|
||||||
database may not exist and we have nothing to do anyway */
|
|
||||||
if (daemon->dhcp)
|
/* look for link-layer address option for logging */
|
||||||
lease_ping_reply(&from.sin6_addr, p, interface);
|
if (sz >= 16 && packet[8] == ICMP6_OPT_SOURCE_MAC && (packet[9] * 8) + 8 <= sz)
|
||||||
return;
|
{
|
||||||
|
print_mac(daemon->namebuff, &packet[10], (packet[9] * 8) - 2);
|
||||||
|
mac = daemon->namebuff;
|
||||||
|
}
|
||||||
|
|
||||||
|
my_syslog(MS_DHCP | LOG_INFO, "RTR-SOLICIT(%s) %s", interface, mac);
|
||||||
|
send_ra(if_index, interface, &from.sin6_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p[0] != ND_ROUTER_SOLICIT)
|
|
||||||
return;
|
|
||||||
|
|
||||||
/* look for link-layer address option for logging */
|
|
||||||
if (sz >= 16 && p[8] == ICMP6_OPT_SOURCE_MAC && (p[9] * 8) + 8 <= sz)
|
|
||||||
{
|
|
||||||
print_mac(daemon->namebuff, &p[10], (p[9] * 8) - 2);
|
|
||||||
mac = daemon->namebuff;
|
|
||||||
}
|
|
||||||
|
|
||||||
my_syslog(MS_DHCP | LOG_INFO, "RTR-SOLICIT(%s) %s", interface, mac);
|
|
||||||
|
|
||||||
send_ra(if_index, interface, &from.sin6_addr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
|
static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
|
||||||
@@ -199,7 +190,10 @@ static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
|
|||||||
struct ifreq ifr;
|
struct ifreq ifr;
|
||||||
struct sockaddr_in6 addr;
|
struct sockaddr_in6 addr;
|
||||||
struct dhcp_context *context;
|
struct dhcp_context *context;
|
||||||
|
struct dhcp_netid iface_id;
|
||||||
|
struct dhcp_opt *opt_cfg;
|
||||||
|
int done_dns = 0;
|
||||||
|
|
||||||
save_counter(0);
|
save_counter(0);
|
||||||
ra = expand(sizeof(struct ra_packet));
|
ra = expand(sizeof(struct ra_packet));
|
||||||
|
|
||||||
@@ -218,9 +212,17 @@ static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
|
|||||||
parm.if_name = iface_name;
|
parm.if_name = iface_name;
|
||||||
parm.first = 1;
|
parm.first = 1;
|
||||||
|
|
||||||
for (context = daemon->ra_contexts; context; context = context->next)
|
/* set tag with name == interface */
|
||||||
context->flags &= ~CONTEXT_RA_DONE;
|
iface_id.net = iface_name;
|
||||||
|
iface_id.next = NULL;
|
||||||
|
parm.tags = &iface_id;
|
||||||
|
|
||||||
|
for (context = daemon->ra_contexts; context; context = context->next)
|
||||||
|
{
|
||||||
|
context->flags &= ~CONTEXT_RA_DONE;
|
||||||
|
context->netid.next = &context->netid;
|
||||||
|
}
|
||||||
|
|
||||||
if (!iface_enumerate(AF_INET6, &parm, add_prefixes) ||
|
if (!iface_enumerate(AF_INET6, &parm, add_prefixes) ||
|
||||||
!parm.found_context)
|
!parm.found_context)
|
||||||
return;
|
return;
|
||||||
@@ -236,14 +238,63 @@ static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
iface_enumerate(AF_LOCAL, &iface, add_lla);
|
iface_enumerate(AF_LOCAL, &iface, add_lla);
|
||||||
|
|
||||||
|
/* RDNSS, RFC 6106, use relevant DHCP6 options */
|
||||||
|
(void)option_filter(parm.tags, NULL, daemon->dhcp_opts6);
|
||||||
|
|
||||||
/* RDNSS, RFC 6106 */
|
for (opt_cfg = daemon->dhcp_opts6; opt_cfg; opt_cfg = opt_cfg->next)
|
||||||
put_opt6_char(ICMP6_OPT_RDNSS);
|
{
|
||||||
put_opt6_char(3);
|
int i;
|
||||||
put_opt6_short(0);
|
|
||||||
put_opt6_long(1800); /* lifetime - twice RA retransmit */
|
/* netids match and not encapsulated? */
|
||||||
put_opt6(&parm.link_local, IN6ADDRSZ);
|
if (!(opt_cfg->flags & DHOPT_TAGOK))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (opt_cfg->opt == OPTION6_DNS_SERVER)
|
||||||
|
{
|
||||||
|
struct in6_addr *a = (struct in6_addr *)opt_cfg->val;
|
||||||
|
|
||||||
|
done_dns = 1;
|
||||||
|
if (opt_cfg->len == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
put_opt6_char(ICMP6_OPT_RDNSS);
|
||||||
|
put_opt6_char((opt_cfg->len/8) + 1);
|
||||||
|
put_opt6_short(0);
|
||||||
|
put_opt6_long(1800); /* lifetime - twice RA retransmit */
|
||||||
|
/* zero means "self" */
|
||||||
|
for (i = 0; i < opt_cfg->len; i += IN6ADDRSZ, a++)
|
||||||
|
if (IN6_IS_ADDR_UNSPECIFIED(a))
|
||||||
|
put_opt6(&parm.link_local, IN6ADDRSZ);
|
||||||
|
else
|
||||||
|
put_opt6(a, IN6ADDRSZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (opt_cfg->opt == OPTION6_DOMAIN_SEARCH && opt_cfg->len != 0)
|
||||||
|
{
|
||||||
|
int len = ((opt_cfg->len+7)/8);
|
||||||
|
|
||||||
|
put_opt6_char(ICMP6_OPT_DNSSL);
|
||||||
|
put_opt6_char(len + 1);
|
||||||
|
put_opt6_short(0);
|
||||||
|
put_opt6_long(1800); /* lifetime - twice RA retransmit */
|
||||||
|
put_opt6(opt_cfg->val, opt_cfg->len);
|
||||||
|
|
||||||
|
/* pad */
|
||||||
|
for (i = opt_cfg->len; i < len * 8; i++)
|
||||||
|
put_opt6_char(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!done_dns)
|
||||||
|
{
|
||||||
|
/* default == us. */
|
||||||
|
put_opt6_char(ICMP6_OPT_RDNSS);
|
||||||
|
put_opt6_char(3);
|
||||||
|
put_opt6_short(0);
|
||||||
|
put_opt6_long(1800); /* lifetime - twice RA retransmit */
|
||||||
|
put_opt6(&parm.link_local, IN6ADDRSZ);
|
||||||
|
}
|
||||||
|
|
||||||
/* set managed bits unless we're providing only RA on this link */
|
/* set managed bits unless we're providing only RA on this link */
|
||||||
if (parm.managed)
|
if (parm.managed)
|
||||||
@@ -269,14 +320,13 @@ static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
|
|||||||
inet_pton(AF_INET6, ALL_HOSTS, &addr.sin6_addr);
|
inet_pton(AF_INET6, ALL_HOSTS, &addr.sin6_addr);
|
||||||
|
|
||||||
send_from(daemon->icmp6fd, 0, daemon->outpacket.iov_base, save_counter(0),
|
send_from(daemon->icmp6fd, 0, daemon->outpacket.iov_base, save_counter(0),
|
||||||
(union mysockaddr *)&addr, (struct all_addr *)&parm.link_local, iface, NULL);
|
(union mysockaddr *)&addr, (struct all_addr *)&parm.link_local, iface);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int add_prefixes(struct in6_addr *local, int prefix,
|
static int add_prefixes(struct in6_addr *local, int prefix,
|
||||||
int scope, int if_index, int dad, void *vparam)
|
int scope, int if_index, int dad, void *vparam)
|
||||||
{
|
{
|
||||||
struct dhcp_context *context;
|
|
||||||
struct ra_param *param = vparam;
|
struct ra_param *param = vparam;
|
||||||
|
|
||||||
(void)scope; /* warning */
|
(void)scope; /* warning */
|
||||||
@@ -290,12 +340,12 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
!IN6_IS_ADDR_LINKLOCAL(local) &&
|
!IN6_IS_ADDR_LINKLOCAL(local) &&
|
||||||
!IN6_IS_ADDR_MULTICAST(local))
|
!IN6_IS_ADDR_MULTICAST(local))
|
||||||
{
|
{
|
||||||
|
int do_prefix = 0;
|
||||||
int do_slaac = 0;
|
int do_slaac = 0;
|
||||||
int deprecate = 0;
|
int deprecate = 0;
|
||||||
unsigned int time = 0xffffffff;
|
unsigned int time = 0xffffffff;
|
||||||
struct in6_addr *addr = NULL;
|
struct dhcp_context *context;
|
||||||
struct prefix_opt *opt;
|
|
||||||
|
|
||||||
for (context = daemon->ra_contexts; context; context = context->next)
|
for (context = daemon->ra_contexts; context; context = context->next)
|
||||||
if (prefix == context->prefix &&
|
if (prefix == context->prefix &&
|
||||||
is_same_net6(local, &context->start6, prefix) &&
|
is_same_net6(local, &context->start6, prefix) &&
|
||||||
@@ -305,8 +355,12 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
(CONTEXT_RA_ONLY | CONTEXT_RA_NAME | CONTEXT_RA_STATELESS)))
|
(CONTEXT_RA_ONLY | CONTEXT_RA_NAME | CONTEXT_RA_STATELESS)))
|
||||||
{
|
{
|
||||||
do_slaac = 1;
|
do_slaac = 1;
|
||||||
if (context->flags & CONTEXT_RA_STATELESS)
|
if (context->flags & CONTEXT_DHCP)
|
||||||
param->other = 1;
|
{
|
||||||
|
param->other = 1;
|
||||||
|
if (!(context->flags & CONTEXT_RA_STATELESS))
|
||||||
|
param->managed = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -330,37 +384,47 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
context->ra_time = 0;
|
context->ra_time = 0;
|
||||||
param->first = 0;
|
param->first = 0;
|
||||||
param->found_context = 1;
|
param->found_context = 1;
|
||||||
|
|
||||||
if (context->flags & CONTEXT_RA_DONE)
|
/* collect dhcp-range tags */
|
||||||
continue;
|
if (context->netid.next == &context->netid && context->netid.net)
|
||||||
|
{
|
||||||
context->flags |= CONTEXT_RA_DONE;
|
context->netid.next = param->tags;
|
||||||
addr = &context->start6;
|
param->tags = &context->netid;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(context->flags & CONTEXT_RA_DONE))
|
||||||
|
{
|
||||||
|
context->flags |= CONTEXT_RA_DONE;
|
||||||
|
do_prefix = 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (addr && (opt = expand(sizeof(struct prefix_opt))))
|
if (do_prefix)
|
||||||
{
|
{
|
||||||
u64 addrpart = addr6part(addr);
|
struct prefix_opt *opt;
|
||||||
u64 mask = (prefix == 64) ? (u64)-1LL : (1LLU << (128 - prefix)) - 1LLU;
|
|
||||||
|
if ((opt = expand(sizeof(struct prefix_opt))))
|
||||||
/* lifetimes must be min 2 hrs, by RFC 2462 */
|
{
|
||||||
if (time < 7200)
|
/* zero net part of address */
|
||||||
time = 7200;
|
setaddr6part(local, addr6part(local) & ~((prefix == 64) ? (u64)-1LL : (1LLU << (128 - prefix)) - 1LLU));
|
||||||
|
|
||||||
opt->type = ICMP6_OPT_PREFIX;
|
/* lifetimes must be min 2 hrs, by RFC 2462 */
|
||||||
opt->len = 4;
|
if (time < 7200)
|
||||||
opt->prefix_len = prefix;
|
time = 7200;
|
||||||
/* autonomous only is we're not doing dhcp */
|
|
||||||
opt->flags = do_slaac ? 0x40 : 0x00;
|
opt->type = ICMP6_OPT_PREFIX;
|
||||||
opt->valid_lifetime = htonl(time);
|
opt->len = 4;
|
||||||
opt->preferred_lifetime = htonl(deprecate ? 0 : time);
|
opt->prefix_len = prefix;
|
||||||
opt->reserved = 0;
|
/* autonomous only if we're not doing dhcp */
|
||||||
|
opt->flags = do_slaac ? 0x40 : 0x00;
|
||||||
opt->prefix = *addr;
|
opt->valid_lifetime = htonl(time);
|
||||||
setaddr6part(&opt->prefix, addrpart & ~mask);
|
opt->preferred_lifetime = htonl(deprecate ? 0 : time);
|
||||||
|
opt->reserved = 0;
|
||||||
inet_ntop(AF_INET6, &opt->prefix, daemon->addrbuff, ADDRSTRLEN);
|
opt->prefix = *local;
|
||||||
my_syslog(MS_DHCP | LOG_INFO, "RTR-ADVERT(%s) %s", param->if_name, daemon->addrbuff);
|
|
||||||
|
inet_ntop(AF_INET6, local, daemon->addrbuff, ADDRSTRLEN);
|
||||||
|
my_syslog(MS_DHCP | LOG_INFO, "RTR-ADVERT(%s) %s", param->if_name, daemon->addrbuff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+42
-13
@@ -699,15 +699,17 @@ static unsigned char *do_doctor(unsigned char *p, int count, struct dns_header *
|
|||||||
unsigned char *p2 = p1;
|
unsigned char *p2 = p1;
|
||||||
/* make counted string zero-term and sanitise */
|
/* make counted string zero-term and sanitise */
|
||||||
for (i = 0; i < len; i++)
|
for (i = 0; i < len; i++)
|
||||||
if (isprint(*(p2+1)))
|
{
|
||||||
{
|
if (!isprint((int)*(p2+1)))
|
||||||
*p2 = *(p2+1);
|
break;
|
||||||
p2++;
|
|
||||||
}
|
*p2 = *(p2+1);
|
||||||
|
p2++;
|
||||||
|
}
|
||||||
*p2 = 0;
|
*p2 = 0;
|
||||||
my_syslog(LOG_INFO, "reply %s is %s", name, p1);
|
my_syslog(LOG_INFO, "reply %s is %s", name, p1);
|
||||||
/* restore */
|
/* restore */
|
||||||
memmove(p1 + 1, p1, len);
|
memmove(p1 + 1, p1, i);
|
||||||
*p1 = len;
|
*p1 = len;
|
||||||
p1 += len+1;
|
p1 += len+1;
|
||||||
}
|
}
|
||||||
@@ -936,10 +938,14 @@ int extract_addresses(struct dns_header *header, size_t qlen, char *name, time_t
|
|||||||
if (!cname_count--)
|
if (!cname_count--)
|
||||||
return 0; /* looped CNAMES */
|
return 0; /* looped CNAMES */
|
||||||
newc = cache_insert(name, NULL, now, attl, F_CNAME | F_FORWARD);
|
newc = cache_insert(name, NULL, now, attl, F_CNAME | F_FORWARD);
|
||||||
if (newc && cpp)
|
if (newc)
|
||||||
{
|
{
|
||||||
cpp->addr.cname.cache = newc;
|
newc->addr.cname.cache = NULL;
|
||||||
cpp->addr.cname.uid = newc->uid;
|
if (cpp)
|
||||||
|
{
|
||||||
|
cpp->addr.cname.cache = newc;
|
||||||
|
cpp->addr.cname.uid = newc->uid;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cpp = newc;
|
cpp = newc;
|
||||||
@@ -1003,10 +1009,16 @@ int extract_addresses(struct dns_header *header, size_t qlen, char *name, time_t
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't put stuff from a truncated packet into the cache,
|
/* Don't put stuff from a truncated packet into the cache.
|
||||||
also don't cache replies where DNSSEC validation was turned off, either
|
Don't cache replies where DNSSEC validation was turned off, either
|
||||||
the upstream server told us so, or the original query specified it. */
|
the upstream server told us so, or the original query specified it.
|
||||||
if (!(header->hb3 & HB3_TC) && !(header->hb4 & HB4_CD) && !checking_disabled)
|
Don't cache replies from non-recursive nameservers, since we may get a
|
||||||
|
reply containing a CNAME but not its target, even though the target
|
||||||
|
does exist. */
|
||||||
|
if (!(header->hb3 & HB3_TC) &&
|
||||||
|
!(header->hb4 & HB4_CD) &&
|
||||||
|
(header->hb4 & HB4_RA) &&
|
||||||
|
!checking_disabled)
|
||||||
cache_end_insert();
|
cache_end_insert();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1633,6 +1645,23 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen,
|
|||||||
} while ((crecp = cache_find_by_name(crecp, name, now, flag | F_CNAME)));
|
} while ((crecp = cache_find_by_name(crecp, name, now, flag | F_CNAME)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (qtype == T_CNAME || qtype == T_ANY)
|
||||||
|
{
|
||||||
|
if ((crecp = cache_find_by_name(NULL, name, now, F_CNAME)) &&
|
||||||
|
(qtype == T_CNAME || (crecp->flags & (F_HOSTS | F_DHCP))))
|
||||||
|
{
|
||||||
|
ans = 1;
|
||||||
|
if (!dryrun)
|
||||||
|
{
|
||||||
|
log_query(crecp->flags, name, NULL, record_source(crecp->uid));
|
||||||
|
if (add_resource_record(header, limit, &trunc, nameoffset, &ansp,
|
||||||
|
crec_ttl(crecp, now), &nameoffset,
|
||||||
|
T_CNAME, C_IN, "d", cache_get_name(crecp->addr.cname.cache)))
|
||||||
|
anscount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (qtype == T_MX || qtype == T_ANY)
|
if (qtype == T_MX || qtype == T_ANY)
|
||||||
{
|
{
|
||||||
|
|||||||
+46
-41
@@ -483,7 +483,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
{
|
{
|
||||||
logaddr = &mess->yiaddr;
|
logaddr = &mess->yiaddr;
|
||||||
|
|
||||||
lease_set_hwaddr(lease, mess->chaddr, NULL, mess->hlen, mess->htype, 0, now);
|
lease_set_hwaddr(lease, mess->chaddr, NULL, mess->hlen, mess->htype, 0, now, 1);
|
||||||
if (hostname)
|
if (hostname)
|
||||||
lease_set_hostname(lease, hostname, 1, get_domain(lease->addr), domain);
|
lease_set_hostname(lease, hostname, 1, get_domain(lease->addr), domain);
|
||||||
/* infinite lease unless nailed in dhcp-host line. */
|
/* infinite lease unless nailed in dhcp-host line. */
|
||||||
@@ -1222,51 +1222,56 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
|
|
||||||
log_tags(tagif_netid, ntohl(mess->xid));
|
log_tags(tagif_netid, ntohl(mess->xid));
|
||||||
|
|
||||||
#ifdef HAVE_SCRIPT
|
if (do_classes)
|
||||||
if (do_classes && daemon->lease_change_command)
|
|
||||||
{
|
{
|
||||||
struct dhcp_netid *n;
|
/* pick up INIT-REBOOT events. */
|
||||||
|
|
||||||
if (mess->giaddr.s_addr)
|
|
||||||
lease->giaddr = mess->giaddr;
|
|
||||||
|
|
||||||
lease->flags |= LEASE_CHANGED;
|
lease->flags |= LEASE_CHANGED;
|
||||||
free(lease->extradata);
|
|
||||||
lease->extradata = NULL;
|
|
||||||
lease->extradata_size = lease->extradata_len = 0;
|
|
||||||
|
|
||||||
add_extradata_opt(lease, option_find(mess, sz, OPTION_VENDOR_ID, 1));
|
|
||||||
add_extradata_opt(lease, option_find(mess, sz, OPTION_HOSTNAME, 1));
|
|
||||||
add_extradata_opt(lease, oui);
|
|
||||||
add_extradata_opt(lease, serial);
|
|
||||||
add_extradata_opt(lease, class);
|
|
||||||
|
|
||||||
/* space-concat tag set */
|
|
||||||
if (!tagif_netid)
|
|
||||||
add_extradata_opt(lease, NULL);
|
|
||||||
else
|
|
||||||
for (n = tagif_netid; n; n = n->next)
|
|
||||||
{
|
|
||||||
struct dhcp_netid *n1;
|
|
||||||
/* kill dupes */
|
|
||||||
for (n1 = n->next; n1; n1 = n1->next)
|
|
||||||
if (strcmp(n->net, n1->net) == 0)
|
|
||||||
break;
|
|
||||||
if (!n1)
|
|
||||||
lease_add_extradata(lease, (unsigned char *)n->net, strlen(n->net), n->next ? ' ' : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((opt = option_find(mess, sz, OPTION_USER_CLASS, 1)))
|
#ifdef HAVE_SCRIPT
|
||||||
|
if (daemon->lease_change_command)
|
||||||
{
|
{
|
||||||
int len = option_len(opt);
|
struct dhcp_netid *n;
|
||||||
unsigned char *ucp = option_ptr(opt, 0);
|
|
||||||
/* If the user-class option started as counted strings, the first byte will be zero. */
|
if (mess->giaddr.s_addr)
|
||||||
if (len != 0 && ucp[0] == 0)
|
lease->giaddr = mess->giaddr;
|
||||||
ucp++, len--;
|
|
||||||
lease_add_extradata(lease, ucp, len, 0);
|
free(lease->extradata);
|
||||||
|
lease->extradata = NULL;
|
||||||
|
lease->extradata_size = lease->extradata_len = 0;
|
||||||
|
|
||||||
|
add_extradata_opt(lease, option_find(mess, sz, OPTION_VENDOR_ID, 1));
|
||||||
|
add_extradata_opt(lease, option_find(mess, sz, OPTION_HOSTNAME, 1));
|
||||||
|
add_extradata_opt(lease, oui);
|
||||||
|
add_extradata_opt(lease, serial);
|
||||||
|
add_extradata_opt(lease, class);
|
||||||
|
|
||||||
|
/* space-concat tag set */
|
||||||
|
if (!tagif_netid)
|
||||||
|
add_extradata_opt(lease, NULL);
|
||||||
|
else
|
||||||
|
for (n = tagif_netid; n; n = n->next)
|
||||||
|
{
|
||||||
|
struct dhcp_netid *n1;
|
||||||
|
/* kill dupes */
|
||||||
|
for (n1 = n->next; n1; n1 = n1->next)
|
||||||
|
if (strcmp(n->net, n1->net) == 0)
|
||||||
|
break;
|
||||||
|
if (!n1)
|
||||||
|
lease_add_extradata(lease, (unsigned char *)n->net, strlen(n->net), n->next ? ' ' : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((opt = option_find(mess, sz, OPTION_USER_CLASS, 1)))
|
||||||
|
{
|
||||||
|
int len = option_len(opt);
|
||||||
|
unsigned char *ucp = option_ptr(opt, 0);
|
||||||
|
/* If the user-class option started as counted strings, the first byte will be zero. */
|
||||||
|
if (len != 0 && ucp[0] == 0)
|
||||||
|
ucp++, len--;
|
||||||
|
lease_add_extradata(lease, ucp, len, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (!hostname_auth && (client_hostname = host_from_dns(mess->yiaddr)))
|
if (!hostname_auth && (client_hostname = host_from_dns(mess->yiaddr)))
|
||||||
{
|
{
|
||||||
@@ -1276,7 +1281,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
}
|
}
|
||||||
|
|
||||||
time = calc_time(context, config, option_find(mess, sz, OPTION_LEASE_TIME, 4));
|
time = calc_time(context, config, option_find(mess, sz, OPTION_LEASE_TIME, 4));
|
||||||
lease_set_hwaddr(lease, mess->chaddr, clid, mess->hlen, mess->htype, clid_len, now);
|
lease_set_hwaddr(lease, mess->chaddr, clid, mess->hlen, mess->htype, clid_len, now, do_classes);
|
||||||
|
|
||||||
/* if all the netids in the ignore_name list are present, ignore client-supplied name */
|
/* if all the netids in the ignore_name list are present, ignore client-supplied name */
|
||||||
if (!hostname_auth)
|
if (!hostname_auth)
|
||||||
|
|||||||
+23
-23
@@ -349,28 +349,28 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
|||||||
|
|
||||||
if (len != 0 && len < 255)
|
if (len != 0 && len < 255)
|
||||||
{
|
{
|
||||||
unsigned char *pp, *op = opt6_ptr(opt, 1);
|
unsigned char *pp, *op = opt6_ptr(opt, 1);
|
||||||
char *pq = daemon->dhcp_buff;
|
char *pq = daemon->dhcp_buff;
|
||||||
|
|
||||||
pp = op;
|
pp = op;
|
||||||
while (*op != 0 && ((op + (*op) + 1) - pp) < len)
|
while (*op != 0 && ((op + (*op)) - pp) < len)
|
||||||
{
|
{
|
||||||
memcpy(pq, op+1, *op);
|
memcpy(pq, op+1, *op);
|
||||||
pq += *op;
|
pq += *op;
|
||||||
op += (*op)+1;
|
op += (*op)+1;
|
||||||
*(pq++) = '.';
|
*(pq++) = '.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pq != daemon->dhcp_buff)
|
if (pq != daemon->dhcp_buff)
|
||||||
pq--;
|
pq--;
|
||||||
*pq = 0;
|
*pq = 0;
|
||||||
|
|
||||||
if (legal_hostname(daemon->dhcp_buff))
|
if (legal_hostname(daemon->dhcp_buff))
|
||||||
{
|
{
|
||||||
client_hostname = daemon->dhcp_buff;
|
client_hostname = daemon->dhcp_buff;
|
||||||
if (option_bool(OPT_LOG_OPTS))
|
if (option_bool(OPT_LOG_OPTS))
|
||||||
my_syslog(MS_DHCP | LOG_INFO, _("%u client provides name: %s"), xid, client_hostname);
|
my_syslog(MS_DHCP | LOG_INFO, _("%u client provides name: %s"), xid, client_hostname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -637,7 +637,7 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
|||||||
if (lease)
|
if (lease)
|
||||||
{
|
{
|
||||||
lease_set_expires(lease, lease_time, now);
|
lease_set_expires(lease, lease_time, now);
|
||||||
lease_set_hwaddr(lease, NULL, clid, 0, iaid, clid_len, now);
|
lease_set_hwaddr(lease, NULL, clid, 0, iaid, clid_len, now, 0);
|
||||||
lease_set_interface(lease, interface, now);
|
lease_set_interface(lease, interface, now);
|
||||||
if (hostname && ia_type == OPTION6_IA_NA)
|
if (hostname && ia_type == OPTION6_IA_NA)
|
||||||
{
|
{
|
||||||
|
|||||||
+21
-10
@@ -23,12 +23,14 @@
|
|||||||
static int map_rebuild = 0;
|
static int map_rebuild = 0;
|
||||||
static int ping_id = 0;
|
static int ping_id = 0;
|
||||||
|
|
||||||
void slaac_add_addrs(struct dhcp_lease *lease, time_t now)
|
void slaac_add_addrs(struct dhcp_lease *lease, time_t now, int force)
|
||||||
{
|
{
|
||||||
struct slaac_address *slaac, *old, **up;
|
struct slaac_address *slaac, *old, **up;
|
||||||
struct dhcp_context *context;
|
struct dhcp_context *context;
|
||||||
|
int dns_dirty = 0;
|
||||||
|
|
||||||
if (!(lease->flags & LEASE_HAVE_HWADDR) ||
|
if (!(lease->flags & LEASE_HAVE_HWADDR) ||
|
||||||
|
(lease->flags & (LEASE_TA | LEASE_NA)) ||
|
||||||
lease->last_interface == 0 ||
|
lease->last_interface == 0 ||
|
||||||
!lease->hostname)
|
!lease->hostname)
|
||||||
return ;
|
return ;
|
||||||
@@ -72,6 +74,13 @@ void slaac_add_addrs(struct dhcp_lease *lease, time_t now)
|
|||||||
if (IN6_ARE_ADDR_EQUAL(&addr, &slaac->addr))
|
if (IN6_ARE_ADDR_EQUAL(&addr, &slaac->addr))
|
||||||
{
|
{
|
||||||
*up = slaac->next;
|
*up = slaac->next;
|
||||||
|
/* recheck when DHCPv4 goes through init-reboot */
|
||||||
|
if (force)
|
||||||
|
{
|
||||||
|
slaac->ping_time = now;
|
||||||
|
slaac->backoff = 1;
|
||||||
|
dns_dirty = 1;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
up = &slaac->next;
|
up = &slaac->next;
|
||||||
@@ -95,6 +104,9 @@ void slaac_add_addrs(struct dhcp_lease *lease, time_t now)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (old || dns_dirty)
|
||||||
|
lease_update_dns(1);
|
||||||
|
|
||||||
/* Free any no reused */
|
/* Free any no reused */
|
||||||
for (; old; old = slaac)
|
for (; old; old = slaac)
|
||||||
{
|
{
|
||||||
@@ -108,8 +120,8 @@ time_t periodic_slaac(time_t now, struct dhcp_lease *leases)
|
|||||||
{
|
{
|
||||||
struct dhcp_context *context;
|
struct dhcp_context *context;
|
||||||
struct dhcp_lease *lease;
|
struct dhcp_lease *lease;
|
||||||
struct slaac_address *slaac;
|
struct slaac_address *slaac;
|
||||||
time_t next_event = 0;
|
time_t next_event = 0;
|
||||||
|
|
||||||
for (context = daemon->ra_contexts; context; context = context->next)
|
for (context = daemon->ra_contexts; context; context = context->next)
|
||||||
if ((context->flags & CONTEXT_RA_NAME))
|
if ((context->flags & CONTEXT_RA_NAME))
|
||||||
@@ -139,8 +151,7 @@ time_t periodic_slaac(time_t now, struct dhcp_lease *leases)
|
|||||||
{
|
{
|
||||||
struct ping_packet *ping;
|
struct ping_packet *ping;
|
||||||
struct sockaddr_in6 addr;
|
struct sockaddr_in6 addr;
|
||||||
int err;
|
|
||||||
|
|
||||||
save_counter(0);
|
save_counter(0);
|
||||||
ping = expand(sizeof(struct ping_packet));
|
ping = expand(sizeof(struct ping_packet));
|
||||||
ping->type = ICMP6_ECHO_REQUEST;
|
ping->type = ICMP6_ECHO_REQUEST;
|
||||||
@@ -156,9 +167,11 @@ time_t periodic_slaac(time_t now, struct dhcp_lease *leases)
|
|||||||
addr.sin6_port = htons(IPPROTO_ICMPV6);
|
addr.sin6_port = htons(IPPROTO_ICMPV6);
|
||||||
addr.sin6_addr = slaac->addr;
|
addr.sin6_addr = slaac->addr;
|
||||||
|
|
||||||
if (send_from(daemon->icmp6fd, 0, daemon->outpacket.iov_base, save_counter(0),
|
if (sendto(daemon->icmp6fd, daemon->outpacket.iov_base, save_counter(0), 0,
|
||||||
(union mysockaddr *)&addr, (struct all_addr *)&slaac->local,
|
(struct sockaddr *)&addr, sizeof(addr)) == -1 &&
|
||||||
lease->last_interface, &err))
|
errno == EHOSTUNREACH)
|
||||||
|
slaac->ping_time = 0; /* Give up */
|
||||||
|
else
|
||||||
{
|
{
|
||||||
slaac->ping_time += (1 << (slaac->backoff - 1)) + (rand16()/21785); /* 0 - 3 */
|
slaac->ping_time += (1 << (slaac->backoff - 1)) + (rand16()/21785); /* 0 - 3 */
|
||||||
if (slaac->backoff > 4)
|
if (slaac->backoff > 4)
|
||||||
@@ -166,8 +179,6 @@ time_t periodic_slaac(time_t now, struct dhcp_lease *leases)
|
|||||||
if (slaac->backoff < 12)
|
if (slaac->backoff < 12)
|
||||||
slaac->backoff++;
|
slaac->backoff++;
|
||||||
}
|
}
|
||||||
else if (err == EHOSTUNREACH)
|
|
||||||
slaac->ping_time = 0; /* Give up */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (slaac->ping_time != 0 &&
|
if (slaac->ping_time != 0 &&
|
||||||
|
|||||||
+50
-34
@@ -24,6 +24,7 @@ static ssize_t tftp_err(int err, char *packet, char *mess, char *file);
|
|||||||
static ssize_t tftp_err_oops(char *packet, char *file);
|
static ssize_t tftp_err_oops(char *packet, char *file);
|
||||||
static ssize_t get_block(char *packet, struct tftp_transfer *transfer);
|
static ssize_t get_block(char *packet, struct tftp_transfer *transfer);
|
||||||
static char *next(char **p, char *end);
|
static char *next(char **p, char *end);
|
||||||
|
static void sanitise(char *buf);
|
||||||
|
|
||||||
#define OP_RRQ 1
|
#define OP_RRQ 1
|
||||||
#define OP_WRQ 2
|
#define OP_WRQ 2
|
||||||
@@ -311,7 +312,10 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
!(filename = next(&p, end)) ||
|
!(filename = next(&p, end)) ||
|
||||||
!(mode = next(&p, end)) ||
|
!(mode = next(&p, end)) ||
|
||||||
(strcasecmp(mode, "octet") != 0 && strcasecmp(mode, "netascii") != 0))
|
(strcasecmp(mode, "octet") != 0 && strcasecmp(mode, "netascii") != 0))
|
||||||
len = tftp_err(ERR_ILL, packet, _("unsupported request from %s"), daemon->addrbuff);
|
{
|
||||||
|
len = tftp_err(ERR_ILL, packet, _("unsupported request from %s"), daemon->addrbuff);
|
||||||
|
is_err = 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (strcasecmp(mode, "netascii") == 0)
|
if (strcasecmp(mode, "netascii") == 0)
|
||||||
@@ -344,9 +348,12 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* cope with backslashes from windows boxen. */
|
/* cope with backslashes from windows boxen. */
|
||||||
while ((p = strchr(filename, '\\')))
|
for (p = filename; *p; p++)
|
||||||
*p = '/';
|
if (*p == '\\')
|
||||||
|
*p = '/';
|
||||||
|
else if (option_bool(OPT_TFTP_LC))
|
||||||
|
*p = tolower(*p);
|
||||||
|
|
||||||
strcpy(daemon->namebuff, "/");
|
strcpy(daemon->namebuff, "/");
|
||||||
if (prefix)
|
if (prefix)
|
||||||
{
|
{
|
||||||
@@ -393,7 +400,7 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
}
|
}
|
||||||
|
|
||||||
while (sendto(transfer->sockfd, packet, len, 0,
|
while (sendto(transfer->sockfd, packet, len, 0,
|
||||||
(struct sockaddr *)&peer, sizeof(peer)) == -1 && errno == EINTR);
|
(struct sockaddr *)&peer, sa_len(&peer)) == -1 && errno == EINTR);
|
||||||
|
|
||||||
if (is_err)
|
if (is_err)
|
||||||
free_transfer(transfer);
|
free_transfer(transfer);
|
||||||
@@ -501,12 +508,12 @@ void check_tftp_listeners(fd_set *rset, time_t now)
|
|||||||
{
|
{
|
||||||
tmp = transfer->next;
|
tmp = transfer->next;
|
||||||
|
|
||||||
|
prettyprint_addr(&transfer->peer, daemon->addrbuff);
|
||||||
|
|
||||||
if (FD_ISSET(transfer->sockfd, rset))
|
if (FD_ISSET(transfer->sockfd, rset))
|
||||||
{
|
{
|
||||||
/* we overwrote the buffer... */
|
/* we overwrote the buffer... */
|
||||||
daemon->srv_save = NULL;
|
daemon->srv_save = NULL;
|
||||||
|
|
||||||
prettyprint_addr(&transfer->peer, daemon->addrbuff);
|
|
||||||
|
|
||||||
if ((len = recv(transfer->sockfd, daemon->packet, daemon->packet_buff_sz, 0)) >= (ssize_t)sizeof(struct ack))
|
if ((len = recv(transfer->sockfd, daemon->packet, daemon->packet_buff_sz, 0)) >= (ssize_t)sizeof(struct ack))
|
||||||
{
|
{
|
||||||
@@ -528,14 +535,8 @@ void check_tftp_listeners(fd_set *rset, time_t now)
|
|||||||
if (!err)
|
if (!err)
|
||||||
err = "";
|
err = "";
|
||||||
else
|
else
|
||||||
{
|
sanitise(err);
|
||||||
unsigned char *q, *r;
|
|
||||||
for (q = r = (unsigned char *)err; *r; r++)
|
|
||||||
if (isprint(*r))
|
|
||||||
*(q++) = *r;
|
|
||||||
*q = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
my_syslog(MS_TFTP | LOG_ERR, _("error %d %s received from %s"),
|
my_syslog(MS_TFTP | LOG_ERR, _("error %d %s received from %s"),
|
||||||
(int)ntohs(mess->block), err,
|
(int)ntohs(mess->block), err,
|
||||||
daemon->addrbuff);
|
daemon->addrbuff);
|
||||||
@@ -562,32 +563,33 @@ void check_tftp_listeners(fd_set *rset, time_t now)
|
|||||||
len = tftp_err_oops(daemon->packet, transfer->file->filename);
|
len = tftp_err_oops(daemon->packet, transfer->file->filename);
|
||||||
endcon = 1;
|
endcon = 1;
|
||||||
}
|
}
|
||||||
else if (++transfer->backoff > 5)
|
/* don't complain about timeout when we're awaiting the last
|
||||||
|
ACK, some clients never send it */
|
||||||
|
else if (++transfer->backoff > 5 && len != 0)
|
||||||
{
|
{
|
||||||
/* don't complain about timeout when we're awaiting the last
|
endcon = 1;
|
||||||
ACK, some clients never send it */
|
len = 0;
|
||||||
if (len != 0)
|
|
||||||
{
|
|
||||||
my_syslog(MS_TFTP | LOG_ERR, _("failed sending %s to %s"),
|
|
||||||
transfer->file->filename, daemon->addrbuff);
|
|
||||||
len = 0;
|
|
||||||
endcon = 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (len != 0)
|
if (len != 0)
|
||||||
while(sendto(transfer->sockfd, daemon->packet, len, 0,
|
while(sendto(transfer->sockfd, daemon->packet, len, 0,
|
||||||
(struct sockaddr *)&transfer->peer, sizeof(transfer->peer)) == -1 && errno == EINTR);
|
(struct sockaddr *)&transfer->peer, sa_len(&transfer->peer)) == -1 && errno == EINTR);
|
||||||
|
|
||||||
if (endcon || len == 0)
|
if (endcon || len == 0)
|
||||||
{
|
{
|
||||||
if (!endcon)
|
strcpy(daemon->namebuff, transfer->file->filename);
|
||||||
my_syslog(MS_TFTP | LOG_INFO, _("sent %s to %s"), transfer->file->filename, daemon->addrbuff);
|
sanitise(daemon->namebuff);
|
||||||
|
my_syslog(MS_TFTP | LOG_INFO, endcon ? _("failed sending %s to %s") : _("sent %s to %s"), daemon->namebuff, daemon->addrbuff);
|
||||||
/* unlink */
|
/* unlink */
|
||||||
*up = tmp;
|
*up = tmp;
|
||||||
/* put on queue to be sent to script and deleted */
|
if (endcon)
|
||||||
transfer->next = daemon->tftp_done_trans;
|
free_transfer(transfer);
|
||||||
daemon->tftp_done_trans = transfer;
|
else
|
||||||
|
{
|
||||||
|
/* put on queue to be sent to script and deleted */
|
||||||
|
transfer->next = daemon->tftp_done_trans;
|
||||||
|
daemon->tftp_done_trans = transfer;
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -621,6 +623,16 @@ static char *next(char **p, char *end)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void sanitise(char *buf)
|
||||||
|
{
|
||||||
|
unsigned char *q, *r;
|
||||||
|
for (q = r = (unsigned char *)buf; *r; r++)
|
||||||
|
if (isprint((int)*r))
|
||||||
|
*(q++) = *r;
|
||||||
|
*q = 0;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static ssize_t tftp_err(int err, char *packet, char *message, char *file)
|
static ssize_t tftp_err(int err, char *packet, char *message, char *file)
|
||||||
{
|
{
|
||||||
struct errmess {
|
struct errmess {
|
||||||
@@ -629,7 +641,9 @@ static ssize_t tftp_err(int err, char *packet, char *message, char *file)
|
|||||||
} *mess = (struct errmess *)packet;
|
} *mess = (struct errmess *)packet;
|
||||||
ssize_t ret = 4;
|
ssize_t ret = 4;
|
||||||
char *errstr = strerror(errno);
|
char *errstr = strerror(errno);
|
||||||
|
|
||||||
|
sanitise(file);
|
||||||
|
|
||||||
mess->op = htons(OP_ERR);
|
mess->op = htons(OP_ERR);
|
||||||
mess->err = htons(err);
|
mess->err = htons(err);
|
||||||
ret += (snprintf(mess->message, 500, message, file, errstr) + 1);
|
ret += (snprintf(mess->message, 500, message, file, errstr) + 1);
|
||||||
@@ -640,7 +654,9 @@ static ssize_t tftp_err(int err, char *packet, char *message, char *file)
|
|||||||
|
|
||||||
static ssize_t tftp_err_oops(char *packet, char *file)
|
static ssize_t tftp_err_oops(char *packet, char *file)
|
||||||
{
|
{
|
||||||
return tftp_err(ERR_NOTDEF, packet, _("cannot read %s: %s"), file);
|
/* May have >1 refs to file, so potentially mangle a copy of the name */
|
||||||
|
strcpy(daemon->namebuff, file);
|
||||||
|
return tftp_err(ERR_NOTDEF, packet, _("cannot read %s: %s"), daemon->namebuff);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* return -1 for error, zero for done. */
|
/* return -1 for error, zero for done. */
|
||||||
|
|||||||
Reference in new issue
Block a user