mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-19 19:51:01 +00:00
Compare commits
13
Commits
v2.61test7
...
v2.61test9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c8257540bc | ||
|
|
2240704863 | ||
|
|
e8ca69ea16 | ||
|
|
da632e7cc1 | ||
|
|
30cd96663f | ||
|
|
7dbe98147d | ||
|
|
5d71d83420 | ||
|
|
38a59a9ff7 | ||
|
|
4b028ad612 | ||
|
|
442560beb4 | ||
|
|
7d2b5c9583 | ||
|
|
29689cfa5a | ||
|
|
52d4abf2f9 |
No files matched your search
@@ -40,7 +40,32 @@ version 2.61
|
|||||||
|
|
||||||
Set the environment variable DNSMASQ_LOG_DHCP when running
|
Set the environment variable DNSMASQ_LOG_DHCP when running
|
||||||
the script id --log-dhcp is in effect, so that script can
|
the script id --log-dhcp is in effect, so that script can
|
||||||
taylor their logging verbosity. Suggestion from Malte Forkel.
|
taylor their logging verbosity. Suggestion from Malte
|
||||||
|
Forkel.
|
||||||
|
|
||||||
|
Arrange that addresses specified with --listen-address
|
||||||
|
work even if there is no interface carrying the
|
||||||
|
address. This is chiefly useful for IPv4 loopback
|
||||||
|
addresses, where any address in 127.0.0.0/8 is a valid
|
||||||
|
loopback address, but normally only 127.0.0.1 appears on
|
||||||
|
the lo interface. Thanks to Mathieu Trudel-Lapierre for
|
||||||
|
the idea and initial patch.
|
||||||
|
|
||||||
|
Fix crash, introduced in 2.60, when a DHCPINFORM is
|
||||||
|
received from a network which has no valid dhcp-range.
|
||||||
|
Thanks to Stephane Glondu for the bug report.
|
||||||
|
|
||||||
|
Add a new DHCP lease time keyword, "deprecated" for
|
||||||
|
--dhcp-range. This is only valid for IPv6, and sets the
|
||||||
|
preffered lease time for both DHCP and RA to zero. The
|
||||||
|
effect is that clients can continue to use the address
|
||||||
|
for existing connections, but new connections will use
|
||||||
|
other addresses, if they exist. This makes hitless
|
||||||
|
renumbering at least possible.
|
||||||
|
|
||||||
|
Fix bug in address6_available() which caused DHCPv6 lease
|
||||||
|
aquistion to fail of more than one dhcp-range in use.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
version 2.60
|
version 2.60
|
||||||
|
|||||||
Vendored
+6
@@ -7,6 +7,12 @@ dnsmasq (2.61-1) unstable; urgency=low
|
|||||||
|
|
||||||
-- 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
|
||||||
|
|
||||||
|
* Fix DHCPv4 segfault. (closes: #665008)
|
||||||
|
|
||||||
|
-- Simon Kelley <simon@thekelleys.org.uk> Fri, 23 Mar 2012 09:37:23 +0000
|
||||||
|
|
||||||
dnsmasq (2.60-1) unstable; urgency=low
|
dnsmasq (2.60-1) unstable; urgency=low
|
||||||
|
|
||||||
* New upstream.
|
* New upstream.
|
||||||
|
|||||||
+20
-2
@@ -169,14 +169,32 @@
|
|||||||
# hosts. Use the DHCPv4 lease to derive the name, network segment and
|
# hosts. Use the DHCPv4 lease to derive the name, network segment and
|
||||||
# MAC address and assume that the host will also have an
|
# MAC address and assume that the host will also have an
|
||||||
# IPv6 address calculated using the SLAAC alogrithm.
|
# IPv6 address calculated using the SLAAC alogrithm.
|
||||||
# This will generate an erroneous AAAA record if a host is using privacy
|
|
||||||
# extensions or does not support IPv6. Use with care.
|
|
||||||
#dhcp-range=1234::, ra-names
|
#dhcp-range=1234::, ra-names
|
||||||
|
|
||||||
# Do Router Advertisements, BUT NOT DHCP for this subnet.
|
# Do Router Advertisements, BUT NOT DHCP for this subnet.
|
||||||
# Set the lifetime to 46 hours. (Note: minimum lifetime is 2 hours.)
|
# Set the lifetime to 46 hours. (Note: minimum lifetime is 2 hours.)
|
||||||
#dhcp-range=1234::, ra-only, 48h
|
#dhcp-range=1234::, ra-only, 48h
|
||||||
|
|
||||||
|
# Do DHCP and Router Advertisements for this subnet. Set the A bit in the RA
|
||||||
|
# so that clients can use SLAAC addresses as well as DHCP ones.
|
||||||
|
#dhcp-range=1234::2, 1234::500, slaac
|
||||||
|
|
||||||
|
# Do Router Advertisements and stateless DHCP for this subnet. Clients will
|
||||||
|
# not get addresses from DHCP, but they will get other configuration information.
|
||||||
|
# They will use SLAAC for addresses.
|
||||||
|
#dhcp-range=1234::, ra-stateless
|
||||||
|
|
||||||
|
# Do stateless DHCP, SLAAC, and generate DNS names for SLAAC addresses
|
||||||
|
# from DHCPv4 leases.
|
||||||
|
#dhcp-range=1234::, ra-stateless, ra-names
|
||||||
|
|
||||||
|
# Do router advertisements for all subnets where we're doing DHCPv6
|
||||||
|
# Unless overriden by ra-stateless, ra-names, et al, the router
|
||||||
|
# advertisements will have the M and O bits set, so that the clients
|
||||||
|
# get addresses and configuration from DHCPv6, and the A bit reset, so the
|
||||||
|
# clients don't use SLAAC addresses.
|
||||||
|
#enable-ra
|
||||||
|
|
||||||
# Supply parameters for specified hosts using DHCP. There are lots
|
# Supply parameters for specified hosts using DHCP. There are lots
|
||||||
# of valid alternatives, so we will give examples of each. Note that
|
# of valid alternatives, so we will give examples of each. Note that
|
||||||
# IP addresses DO NOT have to be in the range given above, they just
|
# IP addresses DO NOT have to be in the range given above, they just
|
||||||
|
|||||||
+39
-29
@@ -510,9 +510,9 @@ compiled in and the kernel must have conntrack support
|
|||||||
included and configured. This option cannot be combined with
|
included and configured. This option cannot be combined with
|
||||||
--query-port.
|
--query-port.
|
||||||
.TP
|
.TP
|
||||||
.B \-F, --dhcp-range=[interface:<interface>,][tag:<tag>[,tag:<tag>],][set:<tag],]<start-addr>,<end-addr>[,<netmask>[,<broadcast>]][,<lease time>]
|
.B \-F, --dhcp-range=[interface:<interface>,][tag:<tag>[,tag:<tag>],][set:<tag],]<start-addr>[,<end-addr>][,<mode>][,<netmask>[,<broadcast>]][,<lease time>]
|
||||||
.TP
|
.TP
|
||||||
.B \-F, --dhcp-range=[interface:<interface>,][tag:<tag>[,tag:<tag>],][set:<tag],]<start-IPv6addr>,<end-IPv6addr>[,<prefix-len>][,<lease time>]
|
.B \-F, --dhcp-range=[interface:<interface>,][tag:<tag>[,tag:<tag>],][set:<tag],]<start-IPv6addr>[,<end-IPv6addr>][,<mode>][,<prefix-len>][,<lease time>]
|
||||||
|
|
||||||
Enable the DHCP server. Addresses will be given out from the range
|
Enable the DHCP server. Addresses will be given out from the range
|
||||||
<start-addr> to <end-addr> and from statically defined addresses given
|
<start-addr> to <end-addr> and from statically defined addresses given
|
||||||
@@ -522,8 +522,12 @@ options. If the lease time is given, then leases
|
|||||||
will be given for that length of time. The lease time is in seconds,
|
will be given for that length of time. The lease time is in seconds,
|
||||||
or minutes (eg 45m) or hours (eg 1h) or "infinite". If not given,
|
or minutes (eg 45m) or hours (eg 1h) or "infinite". If not given,
|
||||||
the default lease time is one hour. The
|
the default lease time is one hour. The
|
||||||
minimum lease time is two minutes. This
|
minimum lease time is two minutes. For IPv6 ranges, the lease time
|
||||||
option may be repeated, with different addresses, to enable DHCP
|
maybe "deprecated"; this sets the preferred lifetime sent in a DHCP
|
||||||
|
lease or router advertisement to zero, which causes clients to use
|
||||||
|
other addresses, if available, for new connections as a prelude to renumbering.
|
||||||
|
|
||||||
|
This option may be repeated, with different addresses, to enable DHCP
|
||||||
service to more than one network. For directly connected networks (ie,
|
service to more than one network. For directly connected networks (ie,
|
||||||
networks on which the machine running dnsmasq has an interface) the
|
networks on which the machine running dnsmasq has an interface) the
|
||||||
netmask is optional: dnsmasq will determine it from the interface
|
netmask is optional: dnsmasq will determine it from the interface
|
||||||
@@ -548,7 +552,7 @@ When it is prefixed with 'tag:' instead, then its meaning changes from setting
|
|||||||
a tag to matching it. Only one tag may be set, but more than one tag
|
a tag to matching it. Only one tag may be set, but more than one tag
|
||||||
may be matched.
|
may be matched.
|
||||||
|
|
||||||
The end address may be replaced by the keyword
|
The optional <mode> keyword may be
|
||||||
.B static
|
.B static
|
||||||
which tells dnsmasq to enable DHCP for the network specified, but not
|
which tells dnsmasq to enable DHCP for the network specified, but not
|
||||||
to dynamically allocate IP addresses: only hosts which have static
|
to dynamically allocate IP addresses: only hosts which have static
|
||||||
@@ -556,25 +560,36 @@ addresses given via
|
|||||||
.B dhcp-host
|
.B dhcp-host
|
||||||
or from /etc/ethers will be served.
|
or from /etc/ethers will be served.
|
||||||
|
|
||||||
The end address may be replaced by
|
Fot IPv4, the <mode> may be
|
||||||
the keyword
|
|
||||||
.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
|
||||||
.B pxe-prompt
|
.B pxe-prompt
|
||||||
and
|
and
|
||||||
.B pxe-service
|
.B pxe-service
|
||||||
for details, applies to IPv4 only.)
|
for details.)
|
||||||
|
|
||||||
|
For IPv6, the mode may be some combination of
|
||||||
|
.B ra-only, slaac, ra-names, ra-stateless.
|
||||||
|
|
||||||
The end address may be replaced by
|
|
||||||
the keyword
|
|
||||||
.B ra-only
|
.B ra-only
|
||||||
which tells dnsmasq to offer Router Advertisement only on this subnet,
|
tells dnsmasq to offer Router Advertisement only on this subnet,
|
||||||
and not DHCP. This applies to IPv6 only, see
|
and not DHCP.
|
||||||
.B enable-ra
|
|
||||||
for details. Instead, the keyword
|
.B slaac
|
||||||
|
tells dnsmasq to offer Router Advertisement on this subnet and to set
|
||||||
|
the A bit in the router advertisement, so that the client will use
|
||||||
|
SLAAC addresses. When used with a DHCP range or static DHCP address
|
||||||
|
this results in the client having both a DHCP-assigned and a SLAAC
|
||||||
|
address.
|
||||||
|
|
||||||
|
.B ra-stateless
|
||||||
|
sends router advertisements with the O and A bits set, and provides a
|
||||||
|
stateless DHCP service. The client will use a SLAAC address, and use
|
||||||
|
DHCP for other configuration information.
|
||||||
|
|
||||||
.B ra-names
|
.B ra-names
|
||||||
may be used. This does the same at ra-only, but also enables a mode
|
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
|
||||||
@@ -584,6 +599,11 @@ 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
|
||||||
networks, (not one doing DHCP via a relay) and it will not work
|
networks, (not one doing DHCP via a relay) and it will not work
|
||||||
if a host is using privacy extensions.
|
if a host is using privacy extensions.
|
||||||
|
.B ra-names
|
||||||
|
can be combined with
|
||||||
|
.B ra-stateless
|
||||||
|
and
|
||||||
|
.B slaac.
|
||||||
|
|
||||||
The interface:<interface name> section is not normally used. See the
|
The interface:<interface name> section is not normally used. See the
|
||||||
NOTES section for details of this.
|
NOTES section for details of this.
|
||||||
@@ -1319,20 +1339,10 @@ only a subset of this is needed, and dnsmasq can handle it, using
|
|||||||
existing DHCP configuration to provide most data. When RA is enabled,
|
existing DHCP configuration to provide most data. When RA is enabled,
|
||||||
dnsmasq will advertise a prefix for each dhcp-range, with default
|
dnsmasq will advertise a prefix for each dhcp-range, with default
|
||||||
router and recursive DNS server as the relevant link-local address on
|
router and recursive DNS server as the relevant link-local address on
|
||||||
the machine running dnsmasq. The "managed address" bits are set, and
|
the machine running dnsmasq. By default, he "managed address" bits are set, and
|
||||||
the "use SLAAC" bit is reset, except for a dhcp-range which is
|
the "use SLAAC" bit is reset. This can be changed for individual
|
||||||
marked as "ra-only" or "ra-names", in which case RA is provided but no
|
subnets with the mode keywords described in
|
||||||
DHCPv6 service and the managed address bits are
|
.B --dhcp-range.
|
||||||
cleared and the "use SLAAC" bit set. If the same subnet appears in a
|
|
||||||
normal dhcp-range and an "ra-only" dhcp-range, then the "managed
|
|
||||||
address" bits and the "use SLAAC" bits are all set, allowing SLAAC and
|
|
||||||
DHCP address to co-exist on the same subnet.
|
|
||||||
.B enable-ra
|
|
||||||
enables router advertisement for prefixes where dnsmasq is doing
|
|
||||||
DHCPv6. It is not needed for "ra-only" prefixes. Creating an "ra-only"
|
|
||||||
prefix and not setting
|
|
||||||
.B enable-ra
|
|
||||||
sends advertisements only to "ra-only" prefixes.
|
|
||||||
.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
|
||||||
|
|||||||
+1
-1
@@ -167,7 +167,7 @@ HAVE_SOLARIS_NETWORK
|
|||||||
define exactly one of these to alter interaction with kernel networking.
|
define exactly one of these to alter interaction with kernel networking.
|
||||||
|
|
||||||
HAVE_GETOPT_LONG
|
HAVE_GETOPT_LONG
|
||||||
defined when GNU-sty;e getopt_long available.
|
defined when GNU-style getopt_long available.
|
||||||
|
|
||||||
HAVE_ARC4RANDOM
|
HAVE_ARC4RANDOM
|
||||||
defined if arc4random() available to get better security from DNS spoofs
|
defined if arc4random() available to get better security from DNS spoofs
|
||||||
|
|||||||
+4
-4
@@ -229,7 +229,7 @@ int address6_allocate(struct dhcp_context *context, unsigned char *clid, int cl
|
|||||||
|
|
||||||
for (pass = 0; pass <= 1; pass++)
|
for (pass = 0; pass <= 1; pass++)
|
||||||
for (c = context; c; c = c->current)
|
for (c = context; c; c = c->current)
|
||||||
if (c->flags & (CONTEXT_STATIC | CONTEXT_PROXY))
|
if (c->flags & (CONTEXT_DEPRECATE | CONTEXT_STATIC | CONTEXT_RA_STATELESS))
|
||||||
continue;
|
continue;
|
||||||
else if (!match_netid(c->filter, netids, pass))
|
else if (!match_netid(c->filter, netids, pass))
|
||||||
continue;
|
continue;
|
||||||
@@ -282,9 +282,9 @@ struct dhcp_context *address6_available(struct dhcp_context *context,
|
|||||||
start = addr6part(&tmp->start6);
|
start = addr6part(&tmp->start6);
|
||||||
end = addr6part(&tmp->end6);
|
end = addr6part(&tmp->end6);
|
||||||
|
|
||||||
if (!(tmp->flags & (CONTEXT_STATIC | CONTEXT_PROXY)) &&
|
if (!(tmp->flags & (CONTEXT_STATIC | CONTEXT_RA_STATELESS)) &&
|
||||||
is_same_net6(&context->start6, taddr, context->prefix) &&
|
is_same_net6(&tmp->start6, taddr, tmp->prefix) &&
|
||||||
is_same_net6(&context->end6, taddr, context->prefix) &&
|
is_same_net6(&tmp->end6, taddr, tmp->prefix) &&
|
||||||
addr >= start &&
|
addr >= start &&
|
||||||
addr <= end &&
|
addr <= end &&
|
||||||
match_netid(tmp->filter, netids, 1))
|
match_netid(tmp->filter, netids, 1))
|
||||||
|
|||||||
+51
-25
@@ -209,13 +209,6 @@ 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);
|
||||||
|
|
||||||
for (if_tmp = daemon->if_addrs; if_tmp; if_tmp = if_tmp->next)
|
|
||||||
if (!if_tmp->used)
|
|
||||||
{
|
|
||||||
prettyprint_addr(&if_tmp->addr, daemon->namebuff);
|
|
||||||
die(_("no interface with address %s"), daemon->namebuff, EC_BADNET);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
create_wildcard_listeners();
|
create_wildcard_listeners();
|
||||||
@@ -537,7 +530,7 @@ int main (int argc, char **argv)
|
|||||||
my_syslog(MS_DHCP | LOG_INFO, _("IPv6 router advertisement enabled"));
|
my_syslog(MS_DHCP | LOG_INFO, _("IPv6 router advertisement enabled"));
|
||||||
|
|
||||||
#ifdef HAVE_DHCP
|
#ifdef HAVE_DHCP
|
||||||
if (daemon->dhcp || daemon->dhcp6)
|
if (daemon->dhcp || daemon->dhcp6 || daemon->ra_contexts)
|
||||||
{
|
{
|
||||||
struct dhcp_context *dhcp_tmp;
|
struct dhcp_context *dhcp_tmp;
|
||||||
int family = AF_INET;
|
int family = AF_INET;
|
||||||
@@ -556,23 +549,50 @@ int main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
start = &dhcp_tmp->start6;
|
start = &dhcp_tmp->start6;
|
||||||
end = &dhcp_tmp->end6;
|
end = &dhcp_tmp->end6;
|
||||||
|
struct in6_addr subnet = dhcp_tmp->start6;
|
||||||
|
setaddr6part(&subnet, 0);
|
||||||
|
inet_ntop(AF_INET6, &subnet, daemon->addrbuff, 256);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
prettyprint_time(daemon->dhcp_buff2, dhcp_tmp->lease_time);
|
if (family != AF_INET && (dhcp_tmp->flags & CONTEXT_DEPRECATE))
|
||||||
|
strcpy(daemon->namebuff, _("prefix deprecated"));
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char *p = daemon->namebuff;
|
||||||
|
p += sprintf(p, _("lease time "));
|
||||||
|
prettyprint_time(p, dhcp_tmp->lease_time);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (daemon->dhcp_buff)
|
||||||
inet_ntop(family, start, daemon->dhcp_buff, 256);
|
inet_ntop(family, start, daemon->dhcp_buff, 256);
|
||||||
|
if (daemon->dhcp_buff3)
|
||||||
inet_ntop(family, end, daemon->dhcp_buff3, 256);
|
inet_ntop(family, end, daemon->dhcp_buff3, 256);
|
||||||
|
if ((dhcp_tmp->flags & CONTEXT_DHCP) || family == AF_INET)
|
||||||
my_syslog(MS_DHCP | LOG_INFO,
|
my_syslog(MS_DHCP | LOG_INFO,
|
||||||
|
(dhcp_tmp->flags & CONTEXT_RA_STATELESS) ?
|
||||||
|
_("stateless DHCPv6 on %s%.0s%.0s") :
|
||||||
(dhcp_tmp->flags & CONTEXT_STATIC) ?
|
(dhcp_tmp->flags & CONTEXT_STATIC) ?
|
||||||
_("DHCP, static leases only on %.0s%s, lease time %s") :
|
_("DHCP, static leases only on %.0s%s, %s") :
|
||||||
(dhcp_tmp->flags & CONTEXT_RA_NAME) ?
|
|
||||||
_("router advertisement with DHCPv4-derived names on %.0s%s, lifetime %s") :
|
|
||||||
(dhcp_tmp->flags & CONTEXT_RA_ONLY) ?
|
|
||||||
_("router advertisement only on %.0s%s, lifetime %s") :
|
|
||||||
(dhcp_tmp->flags & CONTEXT_PROXY) ?
|
(dhcp_tmp->flags & CONTEXT_PROXY) ?
|
||||||
_("DHCP, proxy on subnet %.0s%s%.0s") :
|
_("DHCP, proxy on subnet %.0s%s%.0s") :
|
||||||
_("DHCP, IP range %s -- %s, lease time %s"),
|
_("DHCP, IP range %s -- %s, %s"),
|
||||||
daemon->dhcp_buff, daemon->dhcp_buff3, daemon->dhcp_buff2);
|
daemon->dhcp_buff, daemon->dhcp_buff3, daemon->namebuff);
|
||||||
|
|
||||||
|
if (dhcp_tmp->flags & CONTEXT_RA_NAME)
|
||||||
|
my_syslog(MS_DHCP | LOG_INFO, _("DHCPv4-derived IPv6 names on %s"),
|
||||||
|
daemon->addrbuff);
|
||||||
|
if (dhcp_tmp->flags & (CONTEXT_RA_ONLY | CONTEXT_RA_NAME | CONTEXT_RA_STATELESS))
|
||||||
|
{
|
||||||
|
if (!(dhcp_tmp->flags & CONTEXT_DEPRECATE))
|
||||||
|
{
|
||||||
|
char *p = daemon->namebuff;
|
||||||
|
p += sprintf(p, _("prefix valid "));
|
||||||
|
prettyprint_time(p, dhcp_tmp->lease_time > 7200 ? dhcp_tmp->lease_time : 7200);
|
||||||
|
}
|
||||||
|
my_syslog(MS_DHCP | LOG_INFO, _("SLAAC on %s %s"),
|
||||||
|
daemon->addrbuff, daemon->namebuff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_DHCP6
|
#ifdef HAVE_DHCP6
|
||||||
@@ -700,13 +720,13 @@ int main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
FD_SET(daemon->dhcp6fd, &rset);
|
FD_SET(daemon->dhcp6fd, &rset);
|
||||||
bump_maxfd(daemon->dhcp6fd, &maxfd);
|
bump_maxfd(daemon->dhcp6fd, &maxfd);
|
||||||
|
}
|
||||||
|
|
||||||
if (daemon->ra_contexts)
|
if (daemon->ra_contexts)
|
||||||
{
|
{
|
||||||
FD_SET(daemon->icmp6fd, &rset);
|
FD_SET(daemon->icmp6fd, &rset);
|
||||||
bump_maxfd(daemon->icmp6fd, &maxfd);
|
bump_maxfd(daemon->icmp6fd, &maxfd);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_LINUX_NETWORK
|
#ifdef HAVE_LINUX_NETWORK
|
||||||
@@ -1284,18 +1304,19 @@ static void check_dns_listeners(fd_set *set, time_t now)
|
|||||||
int confd;
|
int confd;
|
||||||
struct irec *iface = NULL;
|
struct irec *iface = NULL;
|
||||||
pid_t p;
|
pid_t p;
|
||||||
|
union mysockaddr tcp_addr;
|
||||||
|
socklen_t tcp_len = sizeof(union mysockaddr);
|
||||||
|
|
||||||
while ((confd = accept(listener->tcpfd, NULL, NULL)) == -1 && errno == EINTR);
|
while ((confd = accept(listener->tcpfd, NULL, NULL)) == -1 && errno == EINTR);
|
||||||
|
|
||||||
if (confd == -1)
|
if (confd == -1 ||
|
||||||
|
getsockname(confd, (struct sockaddr *)&tcp_addr, &tcp_len) == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (option_bool(OPT_NOWILD))
|
if (option_bool(OPT_NOWILD))
|
||||||
iface = listener->iface;
|
iface = listener->iface; /* May be NULL */
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
union mysockaddr tcp_addr;
|
|
||||||
socklen_t tcp_len = sizeof(union mysockaddr);
|
|
||||||
/* Check for allowed interfaces when binding the wildcard address:
|
/* Check for allowed interfaces when binding the wildcard address:
|
||||||
we do this by looking for an interface with the same address as
|
we do this by looking for an interface with the same address as
|
||||||
the local address of the TCP connection, then looking to see if that's
|
the local address of the TCP connection, then looking to see if that's
|
||||||
@@ -1303,14 +1324,13 @@ static void check_dns_listeners(fd_set *set, time_t now)
|
|||||||
interface too, for localisation. */
|
interface too, for localisation. */
|
||||||
|
|
||||||
/* interface may be new since startup */
|
/* interface may be new since startup */
|
||||||
if (enumerate_interfaces() &&
|
if (enumerate_interfaces())
|
||||||
getsockname(confd, (struct sockaddr *)&tcp_addr, &tcp_len) != -1)
|
|
||||||
for (iface = daemon->interfaces; iface; iface = iface->next)
|
for (iface = daemon->interfaces; iface; iface = iface->next)
|
||||||
if (sockaddr_isequal(&iface->addr, &tcp_addr))
|
if (sockaddr_isequal(&iface->addr, &tcp_addr))
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!iface)
|
if (!iface && !option_bool(OPT_NOWILD))
|
||||||
{
|
{
|
||||||
shutdown(confd, SHUT_RDWR);
|
shutdown(confd, SHUT_RDWR);
|
||||||
close(confd);
|
close(confd);
|
||||||
@@ -1336,6 +1356,12 @@ static void check_dns_listeners(fd_set *set, time_t now)
|
|||||||
unsigned char *buff;
|
unsigned char *buff;
|
||||||
struct server *s;
|
struct server *s;
|
||||||
int flags;
|
int flags;
|
||||||
|
struct in_addr netmask;
|
||||||
|
|
||||||
|
if (iface)
|
||||||
|
netmask = iface->netmask;
|
||||||
|
else
|
||||||
|
netmask.s_addr = 0;
|
||||||
|
|
||||||
#ifndef NO_FORK
|
#ifndef NO_FORK
|
||||||
/* Arrange for SIGALARM after CHILD_LIFETIME seconds to
|
/* Arrange for SIGALARM after CHILD_LIFETIME seconds to
|
||||||
@@ -1354,7 +1380,7 @@ static void check_dns_listeners(fd_set *set, time_t now)
|
|||||||
if ((flags = fcntl(confd, F_GETFL, 0)) != -1)
|
if ((flags = fcntl(confd, F_GETFL, 0)) != -1)
|
||||||
fcntl(confd, F_SETFL, flags & ~O_NONBLOCK);
|
fcntl(confd, F_SETFL, flags & ~O_NONBLOCK);
|
||||||
|
|
||||||
buff = tcp_request(confd, now, &iface->addr, iface->netmask);
|
buff = tcp_request(confd, now, &tcp_addr, netmask);
|
||||||
|
|
||||||
shutdown(confd, SHUT_RDWR);
|
shutdown(confd, SHUT_RDWR);
|
||||||
close(confd);
|
close(confd);
|
||||||
|
|||||||
+6
-3
@@ -395,7 +395,7 @@ struct irec {
|
|||||||
|
|
||||||
struct listener {
|
struct listener {
|
||||||
int fd, tcpfd, tftpfd, family;
|
int fd, tcpfd, tftpfd, family;
|
||||||
struct irec *iface; /* only valid for non-wildcard */
|
struct irec *iface; /* only sometimes valid for non-wildcard */
|
||||||
struct listener *next;
|
struct listener *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -653,6 +653,9 @@ struct dhcp_context {
|
|||||||
#define CONTEXT_RA_ONLY 16
|
#define CONTEXT_RA_ONLY 16
|
||||||
#define CONTEXT_RA_DONE 32
|
#define CONTEXT_RA_DONE 32
|
||||||
#define CONTEXT_RA_NAME 64
|
#define CONTEXT_RA_NAME 64
|
||||||
|
#define CONTEXT_RA_STATELESS 128
|
||||||
|
#define CONTEXT_DHCP 256
|
||||||
|
#define CONTEXT_DEPRECATE 512
|
||||||
|
|
||||||
struct ping_result {
|
struct ping_result {
|
||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
@@ -911,9 +914,9 @@ unsigned char *tcp_request(int confd, time_t now,
|
|||||||
union mysockaddr *local_addr, struct in_addr netmask);
|
union mysockaddr *local_addr, struct in_addr netmask);
|
||||||
void server_gone(struct server *server);
|
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);
|
||||||
void send_from(int fd, int nowild, char *packet, size_t len,
|
int send_from(int fd, int nowild, char *packet, size_t len,
|
||||||
union mysockaddr *to, struct all_addr *source,
|
union mysockaddr *to, struct all_addr *source,
|
||||||
unsigned int iface);
|
unsigned int iface, int *errp);
|
||||||
|
|
||||||
/* network.c */
|
/* network.c */
|
||||||
int indextoname(int fd, int index, char *name);
|
int indextoname(int fd, int index, char *name);
|
||||||
|
|||||||
+13
-6
@@ -26,9 +26,9 @@ static struct randfd *allocate_rfd(int family);
|
|||||||
|
|
||||||
/* Send a UDP packet with its source address set as "source"
|
/* Send a UDP packet with its source address set as "source"
|
||||||
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 */
|
||||||
void send_from(int fd, int nowild, char *packet, size_t len,
|
int send_from(int fd, int nowild, char *packet, size_t len,
|
||||||
union mysockaddr *to, struct all_addr *source,
|
union mysockaddr *to, struct all_addr *source,
|
||||||
unsigned int iface)
|
unsigned int iface, int *errp)
|
||||||
{
|
{
|
||||||
struct msghdr msg;
|
struct msghdr msg;
|
||||||
struct iovec iov[1];
|
struct iovec iov[1];
|
||||||
@@ -110,8 +110,15 @@ void send_from(int fd, int nowild, char *packet, size_t len,
|
|||||||
if (retry_send())
|
if (retry_send())
|
||||||
goto retry;
|
goto retry;
|
||||||
|
|
||||||
|
if (errp)
|
||||||
|
*errp = errno;
|
||||||
|
else
|
||||||
my_syslog(LOG_ERR, _("failed to send packet: %s"), strerror(errno));
|
my_syslog(LOG_ERR, _("failed to send packet: %s"), strerror(errno));
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int search_servers(time_t now, struct all_addr **addrpp,
|
static unsigned int search_servers(time_t now, struct all_addr **addrpp,
|
||||||
@@ -432,7 +439,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);
|
send_from(udpfd, option_bool(OPT_NOWILD), (char *)header, plen, udpaddr, dst_addr, dst_iface, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -621,7 +628,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);
|
&forward->source, &forward->dest, forward->iface, NULL);
|
||||||
}
|
}
|
||||||
free_frec(forward); /* cancel */
|
free_frec(forward); /* cancel */
|
||||||
}
|
}
|
||||||
@@ -660,7 +667,7 @@ void receive_query(struct listener *listen, time_t now)
|
|||||||
/* packet buffer overwritten */
|
/* packet buffer overwritten */
|
||||||
daemon->srv_save = NULL;
|
daemon->srv_save = NULL;
|
||||||
|
|
||||||
if (listen->family == AF_INET && option_bool(OPT_NOWILD))
|
if (listen->iface && listen->family == AF_INET && option_bool(OPT_NOWILD))
|
||||||
{
|
{
|
||||||
dst_addr_4 = listen->iface->addr.in.sin_addr;
|
dst_addr_4 = listen->iface->addr.in.sin_addr;
|
||||||
netmask = listen->iface->netmask;
|
netmask = listen->iface->netmask;
|
||||||
@@ -816,7 +823,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);
|
m, &source_addr, &dst_addr, if_index, NULL);
|
||||||
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,
|
||||||
|
|||||||
@@ -511,6 +511,7 @@ void create_bound_listeners(int dienow)
|
|||||||
{
|
{
|
||||||
struct listener *new;
|
struct listener *new;
|
||||||
struct irec *iface;
|
struct irec *iface;
|
||||||
|
struct iname *if_tmp;
|
||||||
|
|
||||||
for (iface = daemon->interfaces; iface; iface = iface->next)
|
for (iface = daemon->interfaces; iface; iface = iface->next)
|
||||||
if (!iface->done && !iface->dad &&
|
if (!iface->done && !iface->dad &&
|
||||||
@@ -521,6 +522,25 @@ void create_bound_listeners(int dienow)
|
|||||||
daemon->listeners = new;
|
daemon->listeners = new;
|
||||||
iface->done = 1;
|
iface->done = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Check for --listen-address options that haven't been used because there's
|
||||||
|
no interface with a matching address. These may be valid: eg it's possible
|
||||||
|
to listen on 127.0.1.1 even if the loopback interface is 127.0.0.1
|
||||||
|
|
||||||
|
If the address isn't valid the bind() will fail and we'll die().
|
||||||
|
|
||||||
|
The resulting listeners have the ->iface field NULL, and this has to be
|
||||||
|
handled by the DNS and TFTP code. It disables --localise-queries processing
|
||||||
|
(no netmask) and some MTU login the tftp code. */
|
||||||
|
|
||||||
|
for (if_tmp = daemon->if_addrs; if_tmp; if_tmp = if_tmp->next)
|
||||||
|
if (!if_tmp->used &&
|
||||||
|
(new = create_listeners(&if_tmp->addr, 1, dienow)))
|
||||||
|
{
|
||||||
|
new->iface = NULL;
|
||||||
|
new->next = daemon->listeners;
|
||||||
|
daemon->listeners = new;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int is_dad_listeners(void)
|
int is_dad_listeners(void)
|
||||||
|
|||||||
+34
-46
@@ -1959,7 +1959,7 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
|
|||||||
case 'F': /* --dhcp-range */
|
case 'F': /* --dhcp-range */
|
||||||
{
|
{
|
||||||
int k, leasepos = 2;
|
int k, leasepos = 2;
|
||||||
char *cp, *a[5] = { NULL, NULL, NULL, NULL, NULL };
|
char *cp, *a[7] = { NULL, NULL, NULL, NULL, NULL, NULL, NULL };
|
||||||
struct dhcp_context *new = opt_malloc(sizeof(struct dhcp_context));
|
struct dhcp_context *new = opt_malloc(sizeof(struct dhcp_context));
|
||||||
|
|
||||||
memset (new, 0, sizeof(*new));
|
memset (new, 0, sizeof(*new));
|
||||||
@@ -2010,7 +2010,7 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (k = 1; k < 5; k++)
|
for (k = 1; k < 7; k++)
|
||||||
if (!(a[k] = split(a[k-1])))
|
if (!(a[k] = split(a[k-1])))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -2020,17 +2020,12 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
|
|||||||
{
|
{
|
||||||
new->next = daemon->dhcp;
|
new->next = daemon->dhcp;
|
||||||
daemon->dhcp = new;
|
daemon->dhcp = new;
|
||||||
|
new->end = new->start;
|
||||||
if (strcmp(a[1], "static") == 0)
|
if (strcmp(a[1], "static") == 0)
|
||||||
{
|
|
||||||
new->end = new->start;
|
|
||||||
new->flags |= CONTEXT_STATIC;
|
new->flags |= CONTEXT_STATIC;
|
||||||
}
|
|
||||||
else if (strcmp(a[1], "proxy") == 0)
|
else if (strcmp(a[1], "proxy") == 0)
|
||||||
{
|
|
||||||
new->end = new->start;
|
|
||||||
new->flags |= CONTEXT_PROXY;
|
new->flags |= CONTEXT_PROXY;
|
||||||
}
|
else if (!inet_pton(AF_INET, a[1], &new->end))
|
||||||
else if ((new->end.s_addr = inet_addr(a[1])) == (in_addr_t)-1)
|
|
||||||
option = '?';
|
option = '?';
|
||||||
|
|
||||||
if (ntohl(new->start.s_addr) > ntohl(new->end.s_addr))
|
if (ntohl(new->start.s_addr) > ntohl(new->end.s_addr))
|
||||||
@@ -2060,53 +2055,54 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
|
|||||||
else if (inet_pton(AF_INET6, a[0], &new->start6))
|
else if (inet_pton(AF_INET6, a[0], &new->start6))
|
||||||
{
|
{
|
||||||
new->prefix = 64; /* default */
|
new->prefix = 64; /* default */
|
||||||
|
new->end6 = new->start6;
|
||||||
|
|
||||||
if (strcmp(a[1], "static") == 0)
|
for (leasepos = 1; leasepos < k; leasepos++)
|
||||||
{
|
{
|
||||||
memcpy(&new->end6, &new->start6, IN6ADDRSZ);
|
if (strcmp(a[leasepos], "static") == 0)
|
||||||
new->flags |= CONTEXT_STATIC;
|
new->flags |= CONTEXT_STATIC | CONTEXT_DHCP;
|
||||||
}
|
else if (strcmp(a[leasepos], "ra-only") == 0 || strcmp(a[leasepos], "slaac") == 0 )
|
||||||
else if (strcmp(a[1], "ra-only") == 0)
|
|
||||||
{
|
|
||||||
memcpy(&new->end6, &new->start6, IN6ADDRSZ);
|
|
||||||
new->flags |= CONTEXT_RA_ONLY;
|
new->flags |= CONTEXT_RA_ONLY;
|
||||||
}
|
else if (strcmp(a[leasepos], "ra-names") == 0)
|
||||||
else if (strcmp(a[1], "ra-names") == 0)
|
new->flags |= CONTEXT_RA_NAME;
|
||||||
{
|
else if (strcmp(a[leasepos], "ra-stateless") == 0)
|
||||||
memcpy(&new->end6, &new->start6, IN6ADDRSZ);
|
new->flags |= CONTEXT_RA_STATELESS | CONTEXT_DHCP;
|
||||||
new->flags |= CONTEXT_RA_NAME | CONTEXT_RA_ONLY;
|
else if (leasepos == 1 && inet_pton(AF_INET6, a[leasepos], &new->end6))
|
||||||
}
|
new->flags |= CONTEXT_DHCP;
|
||||||
else if (!inet_pton(AF_INET6, a[1], &new->end6))
|
|
||||||
option = '?';
|
|
||||||
|
|
||||||
if (new->flags & CONTEXT_RA_ONLY)
|
|
||||||
{
|
|
||||||
new->next = daemon->ra_contexts;
|
|
||||||
daemon->ra_contexts = new;
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (new->flags & CONTEXT_DHCP)
|
||||||
{
|
{
|
||||||
new->next = daemon->dhcp6;
|
new->next = daemon->dhcp6;
|
||||||
daemon->dhcp6 = new;
|
daemon->dhcp6 = new;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
new->next = daemon->ra_contexts;
|
||||||
|
daemon->ra_contexts = new;
|
||||||
|
}
|
||||||
|
|
||||||
/* bare integer < 128 is prefix value */
|
/* bare integer < 128 is prefix value */
|
||||||
if (option != '?' && k >= 3)
|
if (option != '?' && leasepos < k)
|
||||||
{
|
{
|
||||||
int pref;
|
int pref;
|
||||||
for (cp = a[2]; *cp; cp++)
|
for (cp = a[leasepos]; *cp; cp++)
|
||||||
if (!(*cp >= '0' && *cp <= '9'))
|
if (!(*cp >= '0' && *cp <= '9'))
|
||||||
break;
|
break;
|
||||||
if (!*cp && (pref = atoi(a[2])) <= 128)
|
if (!*cp && (pref = atoi(a[leasepos])) <= 128)
|
||||||
{
|
{
|
||||||
new->prefix = pref;
|
new->prefix = pref;
|
||||||
leasepos = 3;
|
leasepos++;
|
||||||
if ((new->flags & CONTEXT_RA_ONLY) && new->prefix != 64)
|
if ((new->flags & (CONTEXT_RA_ONLY | CONTEXT_RA_NAME | CONTEXT_RA_STATELESS)) &&
|
||||||
|
new->prefix != 64)
|
||||||
problem = _("prefix must be exactly 64 for RA subnets");
|
problem = _("prefix must be exactly 64 for RA subnets");
|
||||||
else if (new->prefix < 64)
|
else if (new->prefix < 64)
|
||||||
problem = _("prefix must be at least 64");
|
problem = _("prefix must be at least 64");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!problem && !is_same_net6(&new->start6, &new->end6, new->prefix))
|
if (!problem && !is_same_net6(&new->start6, &new->end6, new->prefix))
|
||||||
problem = _("inconsistent DHCPv6 range");
|
problem = _("inconsistent DHCPv6 range");
|
||||||
else if (addr6part(&new->start6) > addr6part(&new->end6))
|
else if (addr6part(&new->start6) > addr6part(&new->end6))
|
||||||
@@ -2118,10 +2114,12 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (k >= leasepos+1)
|
if (leasepos < k)
|
||||||
{
|
{
|
||||||
if (strcmp(a[leasepos], "infinite") == 0)
|
if (strcmp(a[leasepos], "infinite") == 0)
|
||||||
new->lease_time = 0xffffffff;
|
new->lease_time = 0xffffffff;
|
||||||
|
else if (strcmp(a[leasepos], "deprecated") == 0)
|
||||||
|
new->flags |= CONTEXT_DEPRECATE;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int fac = 1;
|
int fac = 1;
|
||||||
@@ -2154,16 +2152,6 @@ static char *one_opt(int option, char *arg, char *gen_prob, int command_line)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_DHCP6
|
|
||||||
/* lifetimes must be min 2 hrs, by RFC 2462.
|
|
||||||
This gets enforced in radv.c for DHCP ranges
|
|
||||||
which are legitimately less. */
|
|
||||||
if ((new->flags & CONTEXT_RA_ONLY) &&
|
|
||||||
new->lease_time < 7200)
|
|
||||||
new->lease_time = 7200;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+41
-33
@@ -27,7 +27,7 @@
|
|||||||
#include <netinet/icmp6.h>
|
#include <netinet/icmp6.h>
|
||||||
|
|
||||||
struct ra_param {
|
struct ra_param {
|
||||||
int ind, managed, found_context, first;
|
int ind, managed, other, found_context, first;
|
||||||
char *if_name;
|
char *if_name;
|
||||||
struct in6_addr link_local;
|
struct in6_addr link_local;
|
||||||
};
|
};
|
||||||
@@ -213,6 +213,7 @@ static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
|
|||||||
|
|
||||||
parm.ind = iface;
|
parm.ind = iface;
|
||||||
parm.managed = 0;
|
parm.managed = 0;
|
||||||
|
parm.other = 0;
|
||||||
parm.found_context = 0;
|
parm.found_context = 0;
|
||||||
parm.if_name = iface_name;
|
parm.if_name = iface_name;
|
||||||
parm.first = 1;
|
parm.first = 1;
|
||||||
@@ -246,7 +247,9 @@ static void send_ra(int iface, char *iface_name, struct in6_addr *dest)
|
|||||||
|
|
||||||
/* 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)
|
||||||
ra->flags = 0xc0; /* M flag, managed, O flag, other */
|
ra->flags |= 0x80; /* M flag, managed, */
|
||||||
|
if (parm.other)
|
||||||
|
ra->flags |= 0x40; /* O flag, other */
|
||||||
|
|
||||||
/* decide where we're sending */
|
/* decide where we're sending */
|
||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
@@ -266,16 +269,15 @@ 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);
|
(union mysockaddr *)&addr, (struct all_addr *)&parm.link_local, iface, NULL);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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, *tmp;
|
struct dhcp_context *context;
|
||||||
struct ra_param *param = vparam;
|
struct ra_param *param = vparam;
|
||||||
struct prefix_opt *opt;
|
|
||||||
|
|
||||||
(void)scope; /* warning */
|
(void)scope; /* warning */
|
||||||
(void)dad;
|
(void)dad;
|
||||||
@@ -288,52 +290,58 @@ 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_slaac = 0;
|
||||||
|
int deprecate = 0;
|
||||||
|
unsigned int time = 0xffffffff;
|
||||||
|
struct in6_addr *addr = NULL;
|
||||||
|
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) &&
|
||||||
is_same_net6(local, &context->end6, prefix))
|
is_same_net6(local, &context->end6, prefix))
|
||||||
{
|
{
|
||||||
int do_slaac = 0;
|
if ((context->flags &
|
||||||
|
(CONTEXT_RA_ONLY | CONTEXT_RA_NAME | CONTEXT_RA_STATELESS)))
|
||||||
if (context->flags & CONTEXT_RA_ONLY)
|
{
|
||||||
do_slaac = 1;
|
do_slaac = 1;
|
||||||
|
if (context->flags & CONTEXT_RA_STATELESS)
|
||||||
|
param->other = 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* don't do RA for non-ra-only unless --enable-ra is set */
|
/* don't do RA for non-ra-only unless --enable-ra is set */
|
||||||
if (!option_bool(OPT_RA))
|
if (!option_bool(OPT_RA))
|
||||||
continue;
|
continue;
|
||||||
param->managed = 1;
|
param->managed = 1;
|
||||||
|
param->other = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (context->flags & CONTEXT_RA_DONE)
|
/* find floor time */
|
||||||
continue;
|
if (time > context->lease_time)
|
||||||
|
time = context->lease_time;
|
||||||
|
|
||||||
/* subsequent prefixes on the same interface don't need timers */
|
if (context->flags & CONTEXT_DEPRECATE)
|
||||||
|
deprecate = 1;
|
||||||
|
|
||||||
|
/* subsequent prefixes on the same interface
|
||||||
|
and subsequent instances of this prefix don't need timers */
|
||||||
if (!param->first)
|
if (!param->first)
|
||||||
context->ra_time = 0;
|
context->ra_time = 0;
|
||||||
param->first = 0;
|
param->first = 0;
|
||||||
param->found_context = 1;
|
param->found_context = 1;
|
||||||
context->flags |= CONTEXT_RA_DONE;
|
|
||||||
|
|
||||||
/* mark this subnet and duplicates: as done. */
|
if (context->flags & CONTEXT_RA_DONE)
|
||||||
for (tmp = context->next; tmp; tmp = tmp->next)
|
continue;
|
||||||
if (tmp->prefix == prefix &&
|
|
||||||
is_same_net6(local, &tmp->start6, prefix) &&
|
context->flags |= CONTEXT_RA_DONE;
|
||||||
is_same_net6(local, &tmp->end6, prefix))
|
addr = &context->start6;
|
||||||
{
|
|
||||||
/* if any dhcp-range with ra-only on this subnet
|
|
||||||
set the "do_slaac" bit */
|
|
||||||
if (tmp->flags & CONTEXT_RA_ONLY)
|
|
||||||
do_slaac = 1;
|
|
||||||
tmp->flags |= CONTEXT_RA_DONE;
|
|
||||||
context->ra_time = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((opt = expand(sizeof(struct prefix_opt))))
|
if (addr && (opt = expand(sizeof(struct prefix_opt))))
|
||||||
{
|
{
|
||||||
u64 addrpart = addr6part(&context->start6);
|
u64 addrpart = addr6part(addr);
|
||||||
u64 mask = (prefix == 64) ? (u64)-1LL : (1LLU << (128 - prefix)) - 1LLU;
|
u64 mask = (prefix == 64) ? (u64)-1LL : (1LLU << (128 - prefix)) - 1LLU;
|
||||||
unsigned int time = context->lease_time;
|
|
||||||
|
|
||||||
/* lifetimes must be min 2 hrs, by RFC 2462 */
|
/* lifetimes must be min 2 hrs, by RFC 2462 */
|
||||||
if (time < 7200)
|
if (time < 7200)
|
||||||
@@ -344,10 +352,11 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
opt->prefix_len = prefix;
|
opt->prefix_len = prefix;
|
||||||
/* autonomous only is we're not doing dhcp */
|
/* autonomous only is we're not doing dhcp */
|
||||||
opt->flags = do_slaac ? 0x40 : 0x00;
|
opt->flags = do_slaac ? 0x40 : 0x00;
|
||||||
opt->valid_lifetime = opt->preferred_lifetime = htonl(time);
|
opt->valid_lifetime = htonl(time);
|
||||||
|
opt->preferred_lifetime = htonl(deprecate ? 0 : time);
|
||||||
opt->reserved = 0;
|
opt->reserved = 0;
|
||||||
|
|
||||||
opt->prefix = context->start6;
|
opt->prefix = *addr;
|
||||||
setaddr6part(&opt->prefix, addrpart & ~mask);
|
setaddr6part(&opt->prefix, addrpart & ~mask);
|
||||||
|
|
||||||
inet_ntop(AF_INET6, &opt->prefix, daemon->addrbuff, ADDRSTRLEN);
|
inet_ntop(AF_INET6, &opt->prefix, daemon->addrbuff, ADDRSTRLEN);
|
||||||
@@ -355,7 +364,6 @@ static int add_prefixes(struct in6_addr *local, int prefix,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -395,11 +403,11 @@ time_t periodic_ra(time_t now)
|
|||||||
for (next_event = 0, context = daemon->ra_contexts; context; context = context->next)
|
for (next_event = 0, context = daemon->ra_contexts; context; context = context->next)
|
||||||
if (context->ra_time != 0)
|
if (context->ra_time != 0)
|
||||||
{
|
{
|
||||||
if (difftime(context->ra_time, now) < 0.0)
|
if (difftime(context->ra_time, now) <= 0.0)
|
||||||
break; /* overdue */
|
break; /* overdue */
|
||||||
|
|
||||||
if (next_event == 0 || difftime(next_event, context->ra_time + 2) > 0.0)
|
if (next_event == 0 || difftime(next_event, context->ra_time) > 0.0)
|
||||||
next_event = context->ra_time + 2;
|
next_event = context->ra_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* none overdue */
|
/* none overdue */
|
||||||
|
|||||||
@@ -2095,6 +2095,7 @@ static void do_options(struct dhcp_context *context,
|
|||||||
struct dhcp_netid_list *id_list;
|
struct dhcp_netid_list *id_list;
|
||||||
|
|
||||||
/* filter options based on tags, those we want get DHOPT_TAGOK bit set */
|
/* filter options based on tags, those we want get DHOPT_TAGOK bit set */
|
||||||
|
if (context)
|
||||||
context->netid.next = NULL;
|
context->netid.next = NULL;
|
||||||
tagif = option_filter(netid, context && context->netid.net ? &context->netid : NULL, config_opts);
|
tagif = option_filter(netid, context && context->netid.net ? &context->netid : NULL, config_opts);
|
||||||
|
|
||||||
|
|||||||
+20
-15
@@ -513,13 +513,13 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
|||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
struct in6_addr alloced_addr, *addrp = NULL;
|
struct in6_addr alloced_addr, *addrp = NULL;
|
||||||
u32 preferred_time = 0;
|
u32 requested_time = 0;
|
||||||
struct dhcp_lease *lease = NULL;
|
struct dhcp_lease *lease = NULL;
|
||||||
|
|
||||||
if (ia_option)
|
if (ia_option)
|
||||||
{
|
{
|
||||||
struct in6_addr *req_addr = opt6_ptr(ia_option, 0);
|
struct in6_addr *req_addr = opt6_ptr(ia_option, 0);
|
||||||
preferred_time = opt6_uint(ia_option, 16, 4);
|
requested_time = opt6_uint(ia_option, 16, 4);
|
||||||
|
|
||||||
if (!address6_available(context, req_addr, tags) &&
|
if (!address6_available(context, req_addr, tags) &&
|
||||||
(!have_config(config, CONFIG_ADDR6) || memcmp(&config->addr6, req_addr, IN6ADDRSZ) != 0))
|
(!have_config(config, CONFIG_ADDR6) || memcmp(&config->addr6, req_addr, IN6ADDRSZ) != 0))
|
||||||
@@ -621,10 +621,10 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
|||||||
|
|
||||||
if (ia_option)
|
if (ia_option)
|
||||||
{
|
{
|
||||||
if (preferred_time < 120u )
|
if (requested_time < 120u )
|
||||||
preferred_time = 120u; /* sanity */
|
requested_time = 120u; /* sanity */
|
||||||
if (lease_time == 0xffffffff || (preferred_time != 0xffffffff && preferred_time < lease_time))
|
if (lease_time == 0xffffffff || (requested_time != 0xffffffff && requested_time < lease_time))
|
||||||
lease_time = preferred_time;
|
lease_time = requested_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lease_time < min_time)
|
if (lease_time < min_time)
|
||||||
@@ -730,8 +730,9 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
|||||||
{
|
{
|
||||||
o1 = new_opt6(OPTION6_IAADDR);
|
o1 = new_opt6(OPTION6_IAADDR);
|
||||||
put_opt6(addrp, sizeof(*addrp));
|
put_opt6(addrp, sizeof(*addrp));
|
||||||
put_opt6_long(lease_time);
|
/* preferred lifetime */
|
||||||
put_opt6_long(lease_time);
|
put_opt6_long(this_context && (this_context->flags & CONTEXT_DEPRECATE) ? 0 : lease_time);
|
||||||
|
put_opt6_long(lease_time); /* valid lifetime */
|
||||||
end_opt6(o1);
|
end_opt6(o1);
|
||||||
|
|
||||||
log6_packet( make_lease ? "DHCPREPLY" : "DHCPADVERTISE",
|
log6_packet( make_lease ? "DHCPREPLY" : "DHCPADVERTISE",
|
||||||
@@ -842,7 +843,7 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
|||||||
{
|
{
|
||||||
struct dhcp_lease *lease = NULL;
|
struct dhcp_lease *lease = NULL;
|
||||||
struct in6_addr *req_addr = opt6_ptr(ia_option, 0);
|
struct in6_addr *req_addr = opt6_ptr(ia_option, 0);
|
||||||
u32 preferred_time = opt6_uint(ia_option, 16, 4);
|
u32 requested_time = opt6_uint(ia_option, 16, 4);
|
||||||
unsigned int lease_time;
|
unsigned int lease_time;
|
||||||
struct dhcp_context *this_context;
|
struct dhcp_context *this_context;
|
||||||
struct dhcp_config *valid_config = config;
|
struct dhcp_config *valid_config = config;
|
||||||
@@ -873,7 +874,10 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
|||||||
|
|
||||||
if (!address6_available(context, req_addr, tagif) ||
|
if (!address6_available(context, req_addr, tagif) ||
|
||||||
!(this_context = narrow_context6(context, req_addr, tagif)))
|
!(this_context = narrow_context6(context, req_addr, tagif)))
|
||||||
|
{
|
||||||
lease_time = 0;
|
lease_time = 0;
|
||||||
|
this_context = NULL;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* get tags from context if we've not used it before */
|
/* get tags from context if we've not used it before */
|
||||||
@@ -895,10 +899,10 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
|||||||
|
|
||||||
lease_time = have_config(valid_config, CONFIG_TIME) ? valid_config->lease_time : this_context->lease_time;
|
lease_time = have_config(valid_config, CONFIG_TIME) ? valid_config->lease_time : this_context->lease_time;
|
||||||
|
|
||||||
if (preferred_time < 120u )
|
if (requested_time < 120u )
|
||||||
preferred_time = 120u; /* sanity */
|
requested_time = 120u; /* sanity */
|
||||||
if (lease_time == 0xffffffff || (preferred_time != 0xffffffff && preferred_time < lease_time))
|
if (lease_time == 0xffffffff || (requested_time != 0xffffffff && requested_time < lease_time))
|
||||||
lease_time = preferred_time;
|
lease_time = requested_time;
|
||||||
|
|
||||||
lease_set_expires(lease, lease_time, now);
|
lease_set_expires(lease, lease_time, now);
|
||||||
if (ia_type == OPTION6_IA_NA && hostname)
|
if (ia_type == OPTION6_IA_NA && hostname)
|
||||||
@@ -917,8 +921,9 @@ static int dhcp6_no_relay(int msg_type, struct in6_addr *link_address, struct dh
|
|||||||
|
|
||||||
o1 = new_opt6(OPTION6_IAADDR);
|
o1 = new_opt6(OPTION6_IAADDR);
|
||||||
put_opt6(req_addr, sizeof(*req_addr));
|
put_opt6(req_addr, sizeof(*req_addr));
|
||||||
put_opt6_long(lease_time);
|
/* preferred lifetime */
|
||||||
put_opt6_long(lease_time);
|
put_opt6_long(this_context && (this_context->flags & CONTEXT_DEPRECATE) ? 0 : lease_time);
|
||||||
|
put_opt6_long(lease_time); /* valid lifetime */
|
||||||
end_opt6(o1);
|
end_opt6(o1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+13
-6
@@ -131,14 +131,15 @@ time_t periodic_slaac(time_t now, struct dhcp_lease *leases)
|
|||||||
for (lease = leases; lease; lease = lease->next)
|
for (lease = leases; lease; lease = lease->next)
|
||||||
for (slaac = lease->slaac_address; slaac; slaac = slaac->next)
|
for (slaac = lease->slaac_address; slaac; slaac = slaac->next)
|
||||||
{
|
{
|
||||||
/* confirmed? */
|
/* confirmed or given up? */
|
||||||
if (slaac->backoff == 0)
|
if (slaac->backoff == 0 || slaac->ping_time == 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (difftime(slaac->ping_time, now) <= 0.0)
|
if (difftime(slaac->ping_time, now) <= 0.0)
|
||||||
{
|
{
|
||||||
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));
|
||||||
@@ -155,16 +156,22 @@ 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;
|
||||||
|
|
||||||
send_from(daemon->icmp6fd, 0, daemon->outpacket.iov_base, save_counter(0),
|
if (send_from(daemon->icmp6fd, 0, daemon->outpacket.iov_base, save_counter(0),
|
||||||
(union mysockaddr *)&addr, (struct all_addr *)&slaac->local, lease->last_interface);
|
(union mysockaddr *)&addr, (struct all_addr *)&slaac->local,
|
||||||
|
lease->last_interface, &err))
|
||||||
|
{
|
||||||
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)
|
||||||
slaac->ping_time += rand16()/4000; /* 0 - 15 */
|
slaac->ping_time += rand16()/4000; /* 0 - 15 */
|
||||||
|
if (slaac->backoff < 12)
|
||||||
slaac->backoff++;
|
slaac->backoff++;
|
||||||
}
|
}
|
||||||
|
else if (err == EHOSTUNREACH)
|
||||||
|
slaac->ping_time = 0; /* Give up */
|
||||||
|
}
|
||||||
|
|
||||||
if (next_event == 0 || difftime(next_event, slaac->ping_time) >= 0.0)
|
if (slaac->ping_time != 0 &&
|
||||||
|
(next_event == 0 || difftime(next_event, slaac->ping_time) >= 0.0))
|
||||||
next_event = slaac->ping_time;
|
next_event = slaac->ping_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+15
-1
@@ -57,7 +57,7 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
int mtuflag = IP_PMTUDISC_DONT;
|
int mtuflag = IP_PMTUDISC_DONT;
|
||||||
#endif
|
#endif
|
||||||
char namebuff[IF_NAMESIZE];
|
char namebuff[IF_NAMESIZE];
|
||||||
char *name;
|
char *name = NULL;
|
||||||
char *prefix = daemon->tftp_prefix;
|
char *prefix = daemon->tftp_prefix;
|
||||||
struct tftp_prefix *pref;
|
struct tftp_prefix *pref;
|
||||||
struct interface_list *ir;
|
struct interface_list *ir;
|
||||||
@@ -94,11 +94,22 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if (option_bool(OPT_NOWILD))
|
if (option_bool(OPT_NOWILD))
|
||||||
|
{
|
||||||
|
if (listen->iface)
|
||||||
{
|
{
|
||||||
addr = listen->iface->addr;
|
addr = listen->iface->addr;
|
||||||
mtu = listen->iface->mtu;
|
mtu = listen->iface->mtu;
|
||||||
name = listen->iface->name;
|
name = listen->iface->name;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* we're listening on an address that doesn't appear on an interface,
|
||||||
|
ask the kernel what the socket is bound to */
|
||||||
|
socklen_t tcp_len = sizeof(union mysockaddr);
|
||||||
|
if (getsockname(listen->tftpfd, (struct sockaddr *)&addr, &tcp_len) == -1)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct cmsghdr *cmptr;
|
struct cmsghdr *cmptr;
|
||||||
@@ -211,6 +222,8 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
mtu = ifr.ifr_mtu;
|
mtu = ifr.ifr_mtu;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (name)
|
||||||
|
{
|
||||||
/* check for per-interface prefix */
|
/* check for per-interface prefix */
|
||||||
for (pref = daemon->if_prefix; pref; pref = pref->next)
|
for (pref = daemon->if_prefix; pref; pref = pref->next)
|
||||||
if (strcmp(pref->interface, name) == 0)
|
if (strcmp(pref->interface, name) == 0)
|
||||||
@@ -220,6 +233,7 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
for (ir = daemon->tftp_interfaces; ir; ir = ir->next)
|
for (ir = daemon->tftp_interfaces; ir; ir = ir->next)
|
||||||
if (strcmp(ir->interface, name) == 0)
|
if (strcmp(ir->interface, name) == 0)
|
||||||
special = 1;
|
special = 1;
|
||||||
|
}
|
||||||
|
|
||||||
if (listen->family == AF_INET)
|
if (listen->family == AF_INET)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user