mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-06 15:51:41 +00:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7f3bd2ac8 | ||
|
|
22fe2fd038 | ||
|
|
7480aeffc8 | ||
|
|
bec366b404 | ||
|
|
e06e6e34bf | ||
|
|
832e47beab | ||
|
|
df3d54f776 |
No files matched your search
@@ -48,6 +48,14 @@ version 2.76
|
|||||||
(ie xx::0 to xx::ffff:ffff:ffff:ffff)
|
(ie xx::0 to xx::ffff:ffff:ffff:ffff)
|
||||||
Thanks to Laurent Bendel for spotting this problem.
|
Thanks to Laurent Bendel for spotting this problem.
|
||||||
|
|
||||||
|
Add support for a TTL parameter in --host-record and
|
||||||
|
--cname.
|
||||||
|
|
||||||
|
Add --dhcp-ttl option.
|
||||||
|
|
||||||
|
Add --tftp-mtu option. Thanks to Patrick McLean for the
|
||||||
|
initial patch.
|
||||||
|
|
||||||
|
|
||||||
version 2.75
|
version 2.75
|
||||||
Fix reversion on 2.74 which caused 100% CPU use when a
|
Fix reversion on 2.74 which caused 100% CPU use when a
|
||||||
|
|||||||
+18
-3
@@ -60,7 +60,7 @@ in the same way as for DHCP-derived names. Note that this does not
|
|||||||
apply to domain names in cnames, PTR records, TXT records etc.
|
apply to domain names in cnames, PTR records, TXT records etc.
|
||||||
.TP
|
.TP
|
||||||
.B \-T, --local-ttl=<time>
|
.B \-T, --local-ttl=<time>
|
||||||
When replying with information from /etc/hosts or the DHCP leases
|
When replying with information from /etc/hosts or configuration or the DHCP leases
|
||||||
file dnsmasq by default sets the time-to-live field to zero, meaning
|
file dnsmasq by default sets the time-to-live field to zero, meaning
|
||||||
that the requester should not itself cache the information. This is
|
that the requester should not itself cache the information. This is
|
||||||
the correct thing to do in almost all situations. This option allows a
|
the correct thing to do in almost all situations. This option allows a
|
||||||
@@ -68,6 +68,9 @@ time-to-live (in seconds) to be given for these replies. This will
|
|||||||
reduce the load on the server at the expense of clients using stale
|
reduce the load on the server at the expense of clients using stale
|
||||||
data under some circumstances.
|
data under some circumstances.
|
||||||
.TP
|
.TP
|
||||||
|
.B --dhcp-ttl=<time>
|
||||||
|
As for --local-ttl, but affects only replies with information from DHCP leases. If both are given, --dhcp-ttl applies for DHCP information, and --local-ttl for others. Setting this to zero eliminates the effect of --local-ttl for DHCP.
|
||||||
|
.TP
|
||||||
.B --neg-ttl=<time>
|
.B --neg-ttl=<time>
|
||||||
Negative replies from upstream servers normally contain time-to-live
|
Negative replies from upstream servers normally contain time-to-live
|
||||||
information in SOA records which dnsmasq uses for caching. If the
|
information in SOA records which dnsmasq uses for caching. If the
|
||||||
@@ -529,7 +532,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>][,<TTL>]
|
||||||
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
|
||||||
@@ -546,6 +549,10 @@ is in effect. Short and long names may appear in the same
|
|||||||
.B host-record,
|
.B host-record,
|
||||||
eg.
|
eg.
|
||||||
.B --host-record=laptop,laptop.thekelleys.org,192.168.0.1,1234::100
|
.B --host-record=laptop,laptop.thekelleys.org,192.168.0.1,1234::100
|
||||||
|
|
||||||
|
If the time-to-live is given, it overrides the default, which is zero
|
||||||
|
or the value of --local-ttl. The value is a positive integer and gives
|
||||||
|
the time-to-live in seconds.
|
||||||
.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,
|
||||||
@@ -559,7 +566,7 @@ Return a PTR DNS record.
|
|||||||
.B --naptr-record=<name>,<order>,<preference>,<flags>,<service>,<regexp>[,<replacement>]
|
.B --naptr-record=<name>,<order>,<preference>,<flags>,<service>,<regexp>[,<replacement>]
|
||||||
Return an NAPTR DNS record, as specified in RFC3403.
|
Return an NAPTR DNS record, as specified in RFC3403.
|
||||||
.TP
|
.TP
|
||||||
.B --cname=<cname>,<target>
|
.B --cname=<cname>,<target>[,<TTL>]
|
||||||
Return a CNAME record which indicates that <cname> is really
|
Return a CNAME record which indicates that <cname> is really
|
||||||
<target>. There are significant limitations on the target; it must be a
|
<target>. There are significant limitations on the target; it must be a
|
||||||
DNS name which is known to dnsmasq from /etc/hosts (or additional
|
DNS name which is known to dnsmasq from /etc/hosts (or additional
|
||||||
@@ -568,6 +575,10 @@ hosts files), from DHCP, from --interface-name or from another
|
|||||||
If the target does not satisfy this
|
If the target does not satisfy this
|
||||||
criteria, the whole cname is ignored. The cname must be unique, but it
|
criteria, the whole cname is ignored. The cname must be unique, but it
|
||||||
is permissable to have more than one cname pointing to the same target.
|
is permissable to have more than one cname pointing to the same target.
|
||||||
|
|
||||||
|
If the time-to-live is given, it overrides the default, which is zero
|
||||||
|
or the value of -local-ttl. The value is a positive integer and gives
|
||||||
|
the time-to-live in seconds.
|
||||||
.TP
|
.TP
|
||||||
.B --dns-rr=<name>,<RR-number>,[<hex data>]
|
.B --dns-rr=<name>,<RR-number>,[<hex data>]
|
||||||
Return an arbitrary DNS Resource Record. The number is the type of the
|
Return an arbitrary DNS Resource Record. The number is the type of the
|
||||||
@@ -1799,6 +1810,10 @@ require about (2*n) + 10 descriptors. If
|
|||||||
.B --tftp-port-range
|
.B --tftp-port-range
|
||||||
is given, that can affect the number of concurrent connections.
|
is given, that can affect the number of concurrent connections.
|
||||||
.TP
|
.TP
|
||||||
|
.B --tftp-mtu=<mtu size>
|
||||||
|
Use size as the ceiling of the MTU supported by the intervening network when
|
||||||
|
negotiating TFTP blocksize, overriding the MTU setting of the local interface if it is larger.
|
||||||
|
.TP
|
||||||
.B --tftp-no-blocksize
|
.B --tftp-no-blocksize
|
||||||
Stop the TFTP server from negotiating the "blocksize" option with a
|
Stop the TFTP server from negotiating the "blocksize" option with a
|
||||||
client. Some buggy clients request this option but then behave badly
|
client. Some buggy clients request this option but then behave badly
|
||||||
|
|||||||
+1
-1
@@ -824,7 +824,7 @@ size_t answer_auth(struct dns_header *header, char *limit, size_t qlen, time_t n
|
|||||||
|
|
||||||
/* Advertise our packet size limit in our reply */
|
/* Advertise our packet size limit in our reply */
|
||||||
if (have_pseudoheader)
|
if (have_pseudoheader)
|
||||||
return add_pseudoheader(header, ansp - (unsigned char *)header, (unsigned char *)limit, daemon->edns_pktsz, 0, NULL, 0, do_bit);
|
return add_pseudoheader(header, ansp - (unsigned char *)header, (unsigned char *)limit, daemon->edns_pktsz, 0, NULL, 0, do_bit, 0);
|
||||||
|
|
||||||
return ansp - (unsigned char *)header;
|
return ansp - (unsigned char *)header;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -778,6 +778,7 @@ static void add_hosts_cname(struct crec *target)
|
|||||||
(crec = whine_malloc(sizeof(struct crec))))
|
(crec = whine_malloc(sizeof(struct crec))))
|
||||||
{
|
{
|
||||||
crec->flags = F_FORWARD | F_IMMORTAL | F_NAMEP | F_CONFIG | F_CNAME;
|
crec->flags = F_FORWARD | F_IMMORTAL | F_NAMEP | F_CONFIG | F_CNAME;
|
||||||
|
crec->ttd = a->ttl;
|
||||||
crec->name.namep = a->alias;
|
crec->name.namep = a->alias;
|
||||||
crec->addr.cname.target.cache = target;
|
crec->addr.cname.target.cache = target;
|
||||||
crec->addr.cname.uid = target->uid;
|
crec->addr.cname.uid = target->uid;
|
||||||
@@ -981,6 +982,7 @@ int read_hostsfile(char *filename, unsigned int index, int cache_size, struct cr
|
|||||||
strcat(cache->name.sname, ".");
|
strcat(cache->name.sname, ".");
|
||||||
strcat(cache->name.sname, domain_suffix);
|
strcat(cache->name.sname, domain_suffix);
|
||||||
cache->flags = flags;
|
cache->flags = flags;
|
||||||
|
cache->ttd = daemon->local_ttl;
|
||||||
add_hosts_entry(cache, &addr, addrlen, index, rhash, hashsz);
|
add_hosts_entry(cache, &addr, addrlen, index, rhash, hashsz);
|
||||||
name_count++;
|
name_count++;
|
||||||
}
|
}
|
||||||
@@ -988,6 +990,7 @@ int read_hostsfile(char *filename, unsigned int index, int cache_size, struct cr
|
|||||||
{
|
{
|
||||||
strcpy(cache->name.sname, canon);
|
strcpy(cache->name.sname, canon);
|
||||||
cache->flags = flags;
|
cache->flags = flags;
|
||||||
|
cache->ttd = daemon->local_ttl;
|
||||||
add_hosts_entry(cache, &addr, addrlen, index, rhash, hashsz);
|
add_hosts_entry(cache, &addr, addrlen, index, rhash, hashsz);
|
||||||
name_count++;
|
name_count++;
|
||||||
}
|
}
|
||||||
@@ -1057,6 +1060,7 @@ void cache_reload(void)
|
|||||||
((cache = whine_malloc(sizeof(struct crec)))))
|
((cache = whine_malloc(sizeof(struct crec)))))
|
||||||
{
|
{
|
||||||
cache->flags = F_FORWARD | F_NAMEP | F_CNAME | F_IMMORTAL | F_CONFIG;
|
cache->flags = F_FORWARD | F_NAMEP | F_CNAME | F_IMMORTAL | F_CONFIG;
|
||||||
|
cache->ttd = a->ttl;
|
||||||
cache->name.namep = a->alias;
|
cache->name.namep = a->alias;
|
||||||
cache->addr.cname.target.int_name = intr;
|
cache->addr.cname.target.int_name = intr;
|
||||||
cache->addr.cname.uid = SRC_INTERFACE;
|
cache->addr.cname.uid = SRC_INTERFACE;
|
||||||
@@ -1071,6 +1075,7 @@ void cache_reload(void)
|
|||||||
(cache->addr.ds.keydata = blockdata_alloc(ds->digest, ds->digestlen)))
|
(cache->addr.ds.keydata = blockdata_alloc(ds->digest, ds->digestlen)))
|
||||||
{
|
{
|
||||||
cache->flags = F_FORWARD | F_IMMORTAL | F_DS | F_CONFIG | F_NAMEP;
|
cache->flags = F_FORWARD | F_IMMORTAL | F_DS | F_CONFIG | F_NAMEP;
|
||||||
|
cache->ttd = daemon->local_ttl;
|
||||||
cache->name.namep = ds->name;
|
cache->name.namep = ds->name;
|
||||||
cache->addr.ds.keylen = ds->digestlen;
|
cache->addr.ds.keylen = ds->digestlen;
|
||||||
cache->addr.ds.algo = ds->algo;
|
cache->addr.ds.algo = ds->algo;
|
||||||
@@ -1095,6 +1100,7 @@ void cache_reload(void)
|
|||||||
(cache = whine_malloc(sizeof(struct crec))))
|
(cache = whine_malloc(sizeof(struct crec))))
|
||||||
{
|
{
|
||||||
cache->name.namep = nl->name;
|
cache->name.namep = nl->name;
|
||||||
|
cache->ttd = hr->ttl;
|
||||||
cache->flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV4 | F_NAMEP | F_CONFIG;
|
cache->flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV4 | F_NAMEP | F_CONFIG;
|
||||||
add_hosts_entry(cache, (struct all_addr *)&hr->addr, INADDRSZ, SRC_CONFIG, (struct crec **)daemon->packet, revhashsz);
|
add_hosts_entry(cache, (struct all_addr *)&hr->addr, INADDRSZ, SRC_CONFIG, (struct crec **)daemon->packet, revhashsz);
|
||||||
}
|
}
|
||||||
@@ -1103,6 +1109,7 @@ void cache_reload(void)
|
|||||||
(cache = whine_malloc(sizeof(struct crec))))
|
(cache = whine_malloc(sizeof(struct crec))))
|
||||||
{
|
{
|
||||||
cache->name.namep = nl->name;
|
cache->name.namep = nl->name;
|
||||||
|
cache->ttd = hr->ttl;
|
||||||
cache->flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV6 | F_NAMEP | F_CONFIG;
|
cache->flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV6 | F_NAMEP | F_CONFIG;
|
||||||
add_hosts_entry(cache, (struct all_addr *)&hr->addr6, IN6ADDRSZ, SRC_CONFIG, (struct crec **)daemon->packet, revhashsz);
|
add_hosts_entry(cache, (struct all_addr *)&hr->addr6, IN6ADDRSZ, SRC_CONFIG, (struct crec **)daemon->packet, revhashsz);
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-3
@@ -308,6 +308,7 @@ struct ptr_record {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct cname {
|
struct cname {
|
||||||
|
int ttl;
|
||||||
char *alias, *target;
|
char *alias, *target;
|
||||||
struct cname *next;
|
struct cname *next;
|
||||||
};
|
};
|
||||||
@@ -344,6 +345,7 @@ struct auth_zone {
|
|||||||
|
|
||||||
|
|
||||||
struct host_record {
|
struct host_record {
|
||||||
|
int ttl;
|
||||||
struct name_list {
|
struct name_list {
|
||||||
char *name;
|
char *name;
|
||||||
struct name_list *next;
|
struct name_list *next;
|
||||||
@@ -953,7 +955,7 @@ extern struct daemon {
|
|||||||
int max_logs; /* queue limit */
|
int max_logs; /* queue limit */
|
||||||
int cachesize, ftabsize;
|
int cachesize, ftabsize;
|
||||||
int port, query_port, min_port, max_port;
|
int port, query_port, min_port, max_port;
|
||||||
unsigned long local_ttl, neg_ttl, max_ttl, min_cache_ttl, max_cache_ttl, auth_ttl;
|
unsigned long local_ttl, neg_ttl, max_ttl, min_cache_ttl, max_cache_ttl, auth_ttl, dhcp_ttl, use_dhcp_ttl;
|
||||||
char *dns_client_id;
|
char *dns_client_id;
|
||||||
struct hostsfile *addn_hosts;
|
struct hostsfile *addn_hosts;
|
||||||
struct dhcp_context *dhcp, *dhcp6;
|
struct dhcp_context *dhcp, *dhcp6;
|
||||||
@@ -973,7 +975,7 @@ extern struct daemon {
|
|||||||
struct dhcp_netid_list *dhcp_ignore, *dhcp_ignore_names, *dhcp_gen_names;
|
struct dhcp_netid_list *dhcp_ignore, *dhcp_ignore_names, *dhcp_gen_names;
|
||||||
struct dhcp_netid_list *force_broadcast, *bootp_dynamic;
|
struct dhcp_netid_list *force_broadcast, *bootp_dynamic;
|
||||||
struct hostsfile *dhcp_hosts_file, *dhcp_opts_file, *dynamic_dirs;
|
struct hostsfile *dhcp_hosts_file, *dhcp_opts_file, *dynamic_dirs;
|
||||||
int dhcp_max, tftp_max;
|
int dhcp_max, tftp_max, tftp_mtu;
|
||||||
int dhcp_server_port, dhcp_client_port;
|
int dhcp_server_port, dhcp_client_port;
|
||||||
int start_tftp_port, end_tftp_port;
|
int start_tftp_port, end_tftp_port;
|
||||||
unsigned int min_leasetime;
|
unsigned int min_leasetime;
|
||||||
@@ -1521,7 +1523,7 @@ int expand_workspace(unsigned char ***wkspc, int *szp, int new);
|
|||||||
unsigned char *find_pseudoheader(struct dns_header *header, size_t plen,
|
unsigned char *find_pseudoheader(struct dns_header *header, size_t plen,
|
||||||
size_t *len, unsigned char **p, int *is_sign, int *is_last);
|
size_t *len, unsigned char **p, int *is_sign, int *is_last);
|
||||||
size_t add_pseudoheader(struct dns_header *header, size_t plen, unsigned char *limit,
|
size_t add_pseudoheader(struct dns_header *header, size_t plen, unsigned char *limit,
|
||||||
unsigned short udp_sz, int optno, unsigned char *opt, size_t optlen, int set_do);
|
unsigned short udp_sz, int optno, unsigned char *opt, size_t optlen, int set_do, int replace);
|
||||||
size_t add_do_bit(struct dns_header *header, size_t plen, unsigned char *limit);
|
size_t add_do_bit(struct dns_header *header, size_t plen, unsigned char *limit);
|
||||||
size_t add_edns0_config(struct dns_header *header, size_t plen, unsigned char *limit,
|
size_t add_edns0_config(struct dns_header *header, size_t plen, unsigned char *limit,
|
||||||
union mysockaddr *source, time_t now, int *check_subnet);
|
union mysockaddr *source, time_t now, int *check_subnet);
|
||||||
|
|||||||
+47
-20
@@ -96,7 +96,7 @@ unsigned char *find_pseudoheader(struct dns_header *header, size_t plen, size_t
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t add_pseudoheader(struct dns_header *header, size_t plen, unsigned char *limit,
|
size_t add_pseudoheader(struct dns_header *header, size_t plen, unsigned char *limit,
|
||||||
unsigned short udp_sz, int optno, unsigned char *opt, size_t optlen, int set_do)
|
unsigned short udp_sz, int optno, unsigned char *opt, size_t optlen, int set_do, int replace)
|
||||||
{
|
{
|
||||||
unsigned char *lenp, *datap, *p, *udp_len, *buff = NULL;
|
unsigned char *lenp, *datap, *p, *udp_len, *buff = NULL;
|
||||||
int rdlen = 0, is_sign, is_last;
|
int rdlen = 0, is_sign, is_last;
|
||||||
@@ -120,7 +120,7 @@ size_t add_pseudoheader(struct dns_header *header, size_t plen, unsigned char *l
|
|||||||
|
|
||||||
if (set_do)
|
if (set_do)
|
||||||
{
|
{
|
||||||
p -=2;
|
p -= 2;
|
||||||
flags |= 0x8000;
|
flags |= 0x8000;
|
||||||
PUTSHORT(flags, p);
|
PUTSHORT(flags, p);
|
||||||
}
|
}
|
||||||
@@ -136,13 +136,36 @@ size_t add_pseudoheader(struct dns_header *header, size_t plen, unsigned char *l
|
|||||||
return plen;
|
return plen;
|
||||||
|
|
||||||
/* check if option already there */
|
/* check if option already there */
|
||||||
for (i = 0; i + 4 < rdlen; i += len + 4)
|
for (i = 0; i + 4 < rdlen;)
|
||||||
{
|
{
|
||||||
GETSHORT(code, p);
|
GETSHORT(code, p);
|
||||||
GETSHORT(len, p);
|
GETSHORT(len, p);
|
||||||
|
|
||||||
|
/* malformed option, delete the whole OPT RR and start again. */
|
||||||
|
if (i + len > rdlen)
|
||||||
|
{
|
||||||
|
rdlen = 0;
|
||||||
|
islast = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (code == optno)
|
if (code == optno)
|
||||||
return plen;
|
{
|
||||||
p += len;
|
if (!replace)
|
||||||
|
return plen;
|
||||||
|
|
||||||
|
/* delete option if we're to replace it. */
|
||||||
|
p -= 4;
|
||||||
|
rdlen -= len + 4;
|
||||||
|
memcpy(p, p+len+4, rdlen - i);
|
||||||
|
PUTSHORT(rdlen, lenp);
|
||||||
|
lenp -= 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p += len;
|
||||||
|
i += len + 4;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we're going to extend the RR, it has to be the last RR in the packet */
|
/* If we're going to extend the RR, it has to be the last RR in the packet */
|
||||||
@@ -203,7 +226,7 @@ size_t add_pseudoheader(struct dns_header *header, size_t plen, unsigned char *l
|
|||||||
|
|
||||||
size_t add_do_bit(struct dns_header *header, size_t plen, unsigned char *limit)
|
size_t add_do_bit(struct dns_header *header, size_t plen, unsigned char *limit)
|
||||||
{
|
{
|
||||||
return add_pseudoheader(header, plen, (unsigned char *)limit, PACKETSZ, 0, NULL, 0, 1);
|
return add_pseudoheader(header, plen, (unsigned char *)limit, PACKETSZ, 0, NULL, 0, 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned char char64(unsigned char c)
|
static unsigned char char64(unsigned char c)
|
||||||
@@ -235,7 +258,7 @@ static size_t add_dns_client(struct dns_header *header, size_t plen, unsigned ch
|
|||||||
encoder(mac+3, encode+4);
|
encoder(mac+3, encode+4);
|
||||||
encode[8] = 0;
|
encode[8] = 0;
|
||||||
}
|
}
|
||||||
plen = add_pseudoheader(header, plen, limit, PACKETSZ, EDNS0_OPTION_NOMDEVICEID, (unsigned char *)encode, strlen(encode), 0);
|
plen = add_pseudoheader(header, plen, limit, PACKETSZ, EDNS0_OPTION_NOMDEVICEID, (unsigned char *)encode, strlen(encode), 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return plen;
|
return plen;
|
||||||
@@ -248,7 +271,7 @@ static size_t add_mac(struct dns_header *header, size_t plen, unsigned char *lim
|
|||||||
unsigned char mac[DHCP_CHADDR_MAX];
|
unsigned char mac[DHCP_CHADDR_MAX];
|
||||||
|
|
||||||
if ((maclen = find_mac(l3, mac, 1, now)) != 0)
|
if ((maclen = find_mac(l3, mac, 1, now)) != 0)
|
||||||
plen = add_pseudoheader(header, plen, limit, PACKETSZ, EDNS0_OPTION_MAC, mac, maclen, 0);
|
plen = add_pseudoheader(header, plen, limit, PACKETSZ, EDNS0_OPTION_MAC, mac, maclen, 0, 0);
|
||||||
|
|
||||||
return plen;
|
return plen;
|
||||||
}
|
}
|
||||||
@@ -281,8 +304,11 @@ static size_t calc_subnet_opt(struct subnet_opt *opt, union mysockaddr *source)
|
|||||||
void *addrp;
|
void *addrp;
|
||||||
int sa_family = source->sa.sa_family;
|
int sa_family = source->sa.sa_family;
|
||||||
|
|
||||||
|
opt->source_netmask = 0;
|
||||||
|
opt->scope_netmask = 0;
|
||||||
|
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
if (source->sa.sa_family == AF_INET6)
|
if (source->sa.sa_family == AF_INET6 && daemon->add_subnet6)
|
||||||
{
|
{
|
||||||
opt->source_netmask = daemon->add_subnet6->mask;
|
opt->source_netmask = daemon->add_subnet6->mask;
|
||||||
if (daemon->add_subnet6->addr_used)
|
if (daemon->add_subnet6->addr_used)
|
||||||
@@ -293,8 +319,9 @@ static size_t calc_subnet_opt(struct subnet_opt *opt, union mysockaddr *source)
|
|||||||
else
|
else
|
||||||
addrp = &source->in6.sin6_addr;
|
addrp = &source->in6.sin6_addr;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (source->sa.sa_family == AF_INET && daemon->add_subnet4)
|
||||||
{
|
{
|
||||||
opt->source_netmask = daemon->add_subnet4->mask;
|
opt->source_netmask = daemon->add_subnet4->mask;
|
||||||
if (daemon->add_subnet4->addr_used)
|
if (daemon->add_subnet4->addr_used)
|
||||||
@@ -302,20 +329,20 @@ static size_t calc_subnet_opt(struct subnet_opt *opt, union mysockaddr *source)
|
|||||||
sa_family = daemon->add_subnet4->addr.sa.sa_family;
|
sa_family = daemon->add_subnet4->addr.sa.sa_family;
|
||||||
addrp = get_addrp(&daemon->add_subnet4->addr, sa_family);
|
addrp = get_addrp(&daemon->add_subnet4->addr, sa_family);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
addrp = &source->in.sin_addr;
|
addrp = &source->in.sin_addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
opt->scope_netmask = 0;
|
#ifdef HAVE_IPV6
|
||||||
|
opt->family = htons(sa_family == AF_INET6 ? 2 : 1);
|
||||||
|
#else
|
||||||
|
opt->family = htons(1);
|
||||||
|
#endif
|
||||||
|
|
||||||
len = 0;
|
len = 0;
|
||||||
|
|
||||||
if (opt->source_netmask != 0)
|
if (opt->source_netmask != 0)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_IPV6
|
|
||||||
opt->family = htons(sa_family == AF_INET6 ? 2 : 1);
|
|
||||||
#else
|
|
||||||
opt->family = htons(1);
|
|
||||||
#endif
|
|
||||||
len = ((opt->source_netmask - 1) >> 3) + 1;
|
len = ((opt->source_netmask - 1) >> 3) + 1;
|
||||||
memcpy(opt->addr, addrp, len);
|
memcpy(opt->addr, addrp, len);
|
||||||
if (opt->source_netmask & 7)
|
if (opt->source_netmask & 7)
|
||||||
@@ -333,7 +360,7 @@ static size_t add_source_addr(struct dns_header *header, size_t plen, unsigned c
|
|||||||
struct subnet_opt opt;
|
struct subnet_opt opt;
|
||||||
|
|
||||||
len = calc_subnet_opt(&opt, source);
|
len = calc_subnet_opt(&opt, source);
|
||||||
return add_pseudoheader(header, plen, (unsigned char *)limit, PACKETSZ, EDNS0_OPTION_CLIENT_SUBNET, (unsigned char *)&opt, len, 0);
|
return add_pseudoheader(header, plen, (unsigned char *)limit, PACKETSZ, EDNS0_OPTION_CLIENT_SUBNET, (unsigned char *)&opt, len, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int check_source(struct dns_header *header, size_t plen, unsigned char *pseudoheader, union mysockaddr *peer)
|
int check_source(struct dns_header *header, size_t plen, unsigned char *pseudoheader, union mysockaddr *peer)
|
||||||
@@ -387,7 +414,7 @@ size_t add_edns0_config(struct dns_header *header, size_t plen, unsigned char *l
|
|||||||
|
|
||||||
if (daemon->dns_client_id)
|
if (daemon->dns_client_id)
|
||||||
plen = add_pseudoheader(header, plen, limit, PACKETSZ, EDNS0_OPTION_NOMCPEID,
|
plen = add_pseudoheader(header, plen, limit, PACKETSZ, EDNS0_OPTION_NOMCPEID,
|
||||||
(unsigned char *)daemon->dns_client_id, strlen(daemon->dns_client_id), 0);
|
(unsigned char *)daemon->dns_client_id, strlen(daemon->dns_client_id), 0, 1);
|
||||||
|
|
||||||
if (option_bool(OPT_CLIENT_SUBNET))
|
if (option_bool(OPT_CLIENT_SUBNET))
|
||||||
{
|
{
|
||||||
|
|||||||
+63
-15
@@ -157,6 +157,8 @@ struct myoption {
|
|||||||
#define LOPT_MAXPORT 345
|
#define LOPT_MAXPORT 345
|
||||||
#define LOPT_CPE_ID 346
|
#define LOPT_CPE_ID 346
|
||||||
#define LOPT_SCRIPT_ARP 347
|
#define LOPT_SCRIPT_ARP 347
|
||||||
|
#define LOPT_DHCPTTL 348
|
||||||
|
#define LOPT_TFTP_MTU 349
|
||||||
|
|
||||||
#ifdef HAVE_GETOPT_LONG
|
#ifdef HAVE_GETOPT_LONG
|
||||||
static const struct option opts[] =
|
static const struct option opts[] =
|
||||||
@@ -243,6 +245,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-mtu", 1, 0, LOPT_TFTP_MTU },
|
||||||
{ "tftp-lowercase", 0, 0, LOPT_TFTP_LC },
|
{ "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 },
|
||||||
@@ -319,6 +322,7 @@ static const struct myoption opts[] =
|
|||||||
{ "quiet-ra", 0, 0, LOPT_QUIET_RA },
|
{ "quiet-ra", 0, 0, LOPT_QUIET_RA },
|
||||||
{ "dns-loop-detect", 0, 0, LOPT_LOOP_DETECT },
|
{ "dns-loop-detect", 0, 0, LOPT_LOOP_DETECT },
|
||||||
{ "script-arp", 0, 0, LOPT_SCRIPT_ARP },
|
{ "script-arp", 0, 0, LOPT_SCRIPT_ARP },
|
||||||
|
{ "dhcp-ttl", 1, 0 , LOPT_DHCPTTL },
|
||||||
{ NULL, 0, 0, 0 }
|
{ NULL, 0, 0, 0 }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -430,6 +434,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_NO_FAIL, OPT_TFTP_NO_FAIL, NULL, gettext_noop("Do not terminate the service if TFTP directories are inaccessible."), NULL },
|
{ LOPT_TFTP_NO_FAIL, OPT_TFTP_NO_FAIL, NULL, gettext_noop("Do not terminate the service if TFTP directories are inaccessible."), 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_TFTP_MTU, ARG_ONE, "<integer>", gettext_noop("Maximum MTU to use for TFTP transfers."), NULL },
|
||||||
{ 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_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 },
|
||||||
@@ -448,20 +453,20 @@ static struct {
|
|||||||
{ LOPT_GEN_NAMES, ARG_DUP, "[=tag:<tag>]", gettext_noop("Generate hostnames based on MAC address for nameless clients."), NULL},
|
{ LOPT_GEN_NAMES, ARG_DUP, "[=tag:<tag>]", gettext_noop("Generate hostnames based on MAC address for nameless clients."), NULL},
|
||||||
{ LOPT_PROXY, ARG_DUP, "[=<ipaddr>]...", gettext_noop("Use these DHCP relays as full proxies."), NULL },
|
{ LOPT_PROXY, ARG_DUP, "[=<ipaddr>]...", gettext_noop("Use these DHCP relays as full proxies."), NULL },
|
||||||
{ LOPT_RELAY, ARG_DUP, "<local-addr>,<server>[,<interface>]", gettext_noop("Relay DHCP requests to a remote server"), NULL},
|
{ LOPT_RELAY, ARG_DUP, "<local-addr>,<server>[,<interface>]", gettext_noop("Relay DHCP requests to a remote server"), NULL},
|
||||||
{ LOPT_CNAME, ARG_DUP, "<alias>,<target>", gettext_noop("Specify alias name for LOCAL DNS name."), NULL },
|
{ LOPT_CNAME, ARG_DUP, "<alias>,<target>[,<ttl>]", gettext_noop("Specify alias name for LOCAL DNS name."), NULL },
|
||||||
{ LOPT_PXE_PROMT, ARG_DUP, "<prompt>,[<timeout>]", gettext_noop("Prompt to send to PXE clients."), NULL },
|
{ LOPT_PXE_PROMT, ARG_DUP, "<prompt>,[<timeout>]", gettext_noop("Prompt to send to PXE clients."), NULL },
|
||||||
{ LOPT_PXE_SERV, ARG_DUP, "<service>", gettext_noop("Boot service for PXE menu."), NULL },
|
{ LOPT_PXE_SERV, ARG_DUP, "<service>", gettext_noop("Boot service for PXE menu."), NULL },
|
||||||
{ LOPT_TEST, 0, NULL, gettext_noop("Check configuration syntax."), NULL },
|
{ LOPT_TEST, 0, NULL, gettext_noop("Check configuration syntax."), NULL },
|
||||||
{ LOPT_ADD_MAC, ARG_DUP, "[=base64|text]", gettext_noop("Add requestor's MAC address to forwarded DNS queries."), NULL },
|
{ LOPT_ADD_MAC, ARG_DUP, "[=base64|text]", gettext_noop("Add requestor's MAC address to forwarded DNS queries."), NULL },
|
||||||
{ LOPT_ADD_SBNET, ARG_ONE, "<v4 pref>[,<v6 pref>]", gettext_noop("Add specified IP subnet to forwarded DNS queries."), NULL },
|
{ LOPT_ADD_SBNET, ARG_ONE, "<v4 pref>[,<v6 pref>]", gettext_noop("Add specified IP subnet to forwarded DNS queries."), NULL },
|
||||||
{ LOPT_CPE_ID, ARG_ONE, "<text>", gettext_noop("Add client identification to forwarded DNS queries."), NULL },
|
{ LOPT_CPE_ID, ARG_ONE, "<text>", gettext_noop("Add client identification to forwarded DNS queries."), NULL },
|
||||||
{ LOPT_DNSSEC, OPT_DNSSEC_PROXY, NULL, gettext_noop("Proxy DNSSEC validation results from upstream nameservers."), NULL },
|
{ LOPT_DNSSEC, OPT_DNSSEC_PROXY, NULL, gettext_noop("Proxy DNSSEC validation results from upstream nameservers."), NULL },
|
||||||
{ LOPT_INCR_ADDR, OPT_CONSEC_ADDR, NULL, gettext_noop("Attempt to allocate sequential IP addresses to DHCP clients."), NULL },
|
{ LOPT_INCR_ADDR, OPT_CONSEC_ADDR, NULL, gettext_noop("Attempt to allocate sequential IP addresses to DHCP clients."), NULL },
|
||||||
{ LOPT_CONNTRACK, OPT_CONNTRACK, NULL, gettext_noop("Copy connection-track mark from queries to upstream connections."), NULL },
|
{ LOPT_CONNTRACK, OPT_CONNTRACK, NULL, gettext_noop("Copy connection-track mark from queries to upstream connections."), NULL },
|
||||||
{ LOPT_FQDN, OPT_FQDN_UPDATE, NULL, gettext_noop("Allow DHCP clients to do their own DDNS updates."), NULL },
|
{ LOPT_FQDN, OPT_FQDN_UPDATE, NULL, gettext_noop("Allow DHCP clients to do their own DDNS updates."), NULL },
|
||||||
{ LOPT_RA, OPT_RA, NULL, gettext_noop("Send router-advertisements for interfaces doing DHCPv6"), NULL },
|
{ LOPT_RA, OPT_RA, NULL, gettext_noop("Send router-advertisements for interfaces doing DHCPv6"), NULL },
|
||||||
{ LOPT_DUID, ARG_ONE, "<enterprise>,<duid>", gettext_noop("Specify DUID_EN-type DHCPv6 server DUID"), NULL },
|
{ LOPT_DUID, ARG_ONE, "<enterprise>,<duid>", gettext_noop("Specify DUID_EN-type DHCPv6 server DUID"), NULL },
|
||||||
{ LOPT_HOST_REC, ARG_DUP, "<name>,<address>", gettext_noop("Specify host (A/AAAA and PTR) records"), NULL },
|
{ LOPT_HOST_REC, ARG_DUP, "<name>,<address>[,<ttl>]", gettext_noop("Specify host (A/AAAA and PTR) records"), NULL },
|
||||||
{ LOPT_RR, ARG_DUP, "<name>,<RR-number>,[<data>]", gettext_noop("Specify arbitrary DNS resource record"), NULL },
|
{ LOPT_RR, ARG_DUP, "<name>,<RR-number>,[<data>]", gettext_noop("Specify arbitrary DNS resource record"), NULL },
|
||||||
{ LOPT_CLVERBIND, OPT_CLEVERBIND, NULL, gettext_noop("Bind to interfaces in use - check for new interfaces"), NULL },
|
{ LOPT_CLVERBIND, OPT_CLEVERBIND, NULL, gettext_noop("Bind to interfaces in use - check for new interfaces"), NULL },
|
||||||
{ LOPT_AUTHSERV, ARG_ONE, "<NS>,<interface>", gettext_noop("Export local names to global DNS"), NULL },
|
{ LOPT_AUTHSERV, ARG_ONE, "<NS>,<interface>", gettext_noop("Export local names to global DNS"), NULL },
|
||||||
@@ -485,9 +490,10 @@ static struct {
|
|||||||
{ LOPT_QUIET_DHCP, OPT_QUIET_DHCP, NULL, gettext_noop("Do not log routine DHCP."), NULL },
|
{ LOPT_QUIET_DHCP, OPT_QUIET_DHCP, NULL, gettext_noop("Do not log routine DHCP."), NULL },
|
||||||
{ LOPT_QUIET_DHCP6, OPT_QUIET_DHCP6, NULL, gettext_noop("Do not log routine DHCPv6."), NULL },
|
{ LOPT_QUIET_DHCP6, OPT_QUIET_DHCP6, NULL, gettext_noop("Do not log routine DHCPv6."), NULL },
|
||||||
{ LOPT_QUIET_RA, OPT_QUIET_RA, NULL, gettext_noop("Do not log RA."), NULL },
|
{ LOPT_QUIET_RA, OPT_QUIET_RA, NULL, gettext_noop("Do not log RA."), NULL },
|
||||||
{ LOPT_LOCAL_SERVICE, OPT_LOCAL_SERVICE, NULL, gettext_noop("Accept queries only from directly-connected networks"), NULL },
|
{ LOPT_LOCAL_SERVICE, OPT_LOCAL_SERVICE, NULL, gettext_noop("Accept queries only from directly-connected networks."), NULL },
|
||||||
{ LOPT_LOOP_DETECT, OPT_LOOP_DETECT, NULL, gettext_noop("Detect and remove DNS forwarding loops"), NULL },
|
{ LOPT_LOOP_DETECT, OPT_LOOP_DETECT, NULL, gettext_noop("Detect and remove DNS forwarding loops."), NULL },
|
||||||
{ LOPT_IGNORE_ADDR, ARG_DUP, "<ipaddr>", gettext_noop("Ignore DNS responses containing ipaddr."), NULL },
|
{ LOPT_IGNORE_ADDR, ARG_DUP, "<ipaddr>", gettext_noop("Ignore DNS responses containing ipaddr."), NULL },
|
||||||
|
{ LOPT_DHCPTTL, ARG_ONE, "<ttl>", gettext_noop("Set TTL in DNS responses with DHCP-derived addresses."), NULL },
|
||||||
{ 0, 0, NULL, NULL, NULL }
|
{ 0, 0, NULL, NULL, NULL }
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1641,12 +1647,12 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
|
|
||||||
daemon->add_subnet4 = new;
|
daemon->add_subnet4 = new;
|
||||||
|
|
||||||
new = opt_malloc(sizeof(struct mysubnet));
|
|
||||||
if (comma)
|
if (comma)
|
||||||
{
|
{
|
||||||
if ((end = split_chr(comma, '/')))
|
new = opt_malloc(sizeof(struct mysubnet));
|
||||||
{
|
if ((end = split_chr(comma, '/')))
|
||||||
/* has subnet+len */
|
{
|
||||||
|
/* has subnet+len */
|
||||||
err = parse_mysockaddr(comma, &new->addr);
|
err = parse_mysockaddr(comma, &new->addr);
|
||||||
if (err)
|
if (err)
|
||||||
ret_err(err);
|
ret_err(err);
|
||||||
@@ -1659,8 +1665,9 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
if (!atoi_check(comma, &new->mask))
|
if (!atoi_check(comma, &new->mask))
|
||||||
ret_err(gen_err);
|
ret_err(gen_err);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
daemon->add_subnet6 = new;
|
daemon->add_subnet6 = new;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -2164,7 +2171,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
daemon->dns_client_id = opt_string_alloc(arg);
|
daemon->dns_client_id = opt_string_alloc(arg);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LOPT_ADD_MAC:
|
case LOPT_ADD_MAC: /* --add-mac */
|
||||||
if (!arg)
|
if (!arg)
|
||||||
set_option_bool(OPT_ADD_MAC);
|
set_option_bool(OPT_ADD_MAC);
|
||||||
else
|
else
|
||||||
@@ -2580,6 +2587,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
case LOPT_MINCTTL: /* --min-cache-ttl */
|
case LOPT_MINCTTL: /* --min-cache-ttl */
|
||||||
case LOPT_MAXCTTL: /* --max-cache-ttl */
|
case LOPT_MAXCTTL: /* --max-cache-ttl */
|
||||||
case LOPT_AUTHTTL: /* --auth-ttl */
|
case LOPT_AUTHTTL: /* --auth-ttl */
|
||||||
|
case LOPT_DHCPTTL: /* --dhcp-ttl */
|
||||||
{
|
{
|
||||||
int ttl;
|
int ttl;
|
||||||
if (!atoi_check(arg, &ttl))
|
if (!atoi_check(arg, &ttl))
|
||||||
@@ -2598,6 +2606,11 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
daemon->max_cache_ttl = (unsigned long)ttl;
|
daemon->max_cache_ttl = (unsigned long)ttl;
|
||||||
else if (option == LOPT_AUTHTTL)
|
else if (option == LOPT_AUTHTTL)
|
||||||
daemon->auth_ttl = (unsigned long)ttl;
|
daemon->auth_ttl = (unsigned long)ttl;
|
||||||
|
else if (option == LOPT_DHCPTTL)
|
||||||
|
{
|
||||||
|
daemon->dhcp_ttl = (unsigned long)ttl;
|
||||||
|
daemon->use_dhcp_ttl = 1;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
daemon->local_ttl = (unsigned long)ttl;
|
daemon->local_ttl = (unsigned long)ttl;
|
||||||
break;
|
break;
|
||||||
@@ -2616,6 +2629,11 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
ret_err(gen_err);
|
ret_err(gen_err);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case LOPT_TFTP_MTU: /* --tftp-mtu */
|
||||||
|
if (!atoi_check(arg, &daemon->tftp_mtu))
|
||||||
|
ret_err(gen_err);
|
||||||
|
break;
|
||||||
|
|
||||||
case LOPT_PREFIX: /* --tftp-prefix */
|
case LOPT_PREFIX: /* --tftp-prefix */
|
||||||
comma = split(arg);
|
comma = split(arg);
|
||||||
if (comma)
|
if (comma)
|
||||||
@@ -3692,12 +3710,15 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
case LOPT_CNAME: /* --cname */
|
case LOPT_CNAME: /* --cname */
|
||||||
{
|
{
|
||||||
struct cname *new;
|
struct cname *new;
|
||||||
char *alias;
|
char *alias, *target, *ttls;
|
||||||
char *target;
|
int ttl = -1;
|
||||||
|
|
||||||
if (!(comma = split(arg)))
|
if (!(comma = split(arg)))
|
||||||
ret_err(gen_err);
|
ret_err(gen_err);
|
||||||
|
|
||||||
|
if ((ttls = split(comma)) && !atoi_check(ttls, &ttl))
|
||||||
|
ret_err(_("bad TTL"));
|
||||||
|
|
||||||
alias = canonicalise_opt(arg);
|
alias = canonicalise_opt(arg);
|
||||||
target = canonicalise_opt(comma);
|
target = canonicalise_opt(comma);
|
||||||
|
|
||||||
@@ -3713,6 +3734,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
daemon->cnames = new;
|
daemon->cnames = new;
|
||||||
new->alias = alias;
|
new->alias = alias;
|
||||||
new->target = target;
|
new->target = target;
|
||||||
|
new->ttl = ttl;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
@@ -3913,6 +3935,7 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
{
|
{
|
||||||
struct host_record *new = opt_malloc(sizeof(struct host_record));
|
struct host_record *new = opt_malloc(sizeof(struct host_record));
|
||||||
memset(new, 0, sizeof(struct host_record));
|
memset(new, 0, sizeof(struct host_record));
|
||||||
|
new->ttl = -1;
|
||||||
|
|
||||||
if (!arg || !(comma = split(arg)))
|
if (!arg || !(comma = split(arg)))
|
||||||
ret_err(_("Bad host-record"));
|
ret_err(_("Bad host-record"));
|
||||||
@@ -3920,7 +3943,14 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
while (arg)
|
while (arg)
|
||||||
{
|
{
|
||||||
struct all_addr addr;
|
struct all_addr addr;
|
||||||
if (inet_pton(AF_INET, arg, &addr))
|
char *dig;
|
||||||
|
|
||||||
|
for (dig = arg; *dig != 0; dig++)
|
||||||
|
if (*dig < '0' || *dig > '9')
|
||||||
|
break;
|
||||||
|
if (*dig == 0)
|
||||||
|
new->ttl = atoi(arg);
|
||||||
|
else if (inet_pton(AF_INET, arg, &addr))
|
||||||
new->addr = addr.addr.addr4;
|
new->addr = addr.addr.addr4;
|
||||||
#ifdef HAVE_IPV6
|
#ifdef HAVE_IPV6
|
||||||
else if (inet_pton(AF_INET6, arg, &addr))
|
else if (inet_pton(AF_INET6, arg, &addr))
|
||||||
@@ -4602,6 +4632,24 @@ void read_opts(int argc, char **argv, char *compile_opts)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (daemon->host_records)
|
||||||
|
{
|
||||||
|
struct host_record *hr;
|
||||||
|
|
||||||
|
for (hr = daemon->host_records; hr; hr = hr->next)
|
||||||
|
if (hr->ttl == -1)
|
||||||
|
hr->ttl = daemon->local_ttl;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (daemon->cnames)
|
||||||
|
{
|
||||||
|
struct cname *cn;
|
||||||
|
|
||||||
|
for (cn = daemon->cnames; cn; cn = cn->next)
|
||||||
|
if (cn->ttl == -1)
|
||||||
|
cn->ttl = daemon->local_ttl;
|
||||||
|
}
|
||||||
|
|
||||||
if (daemon->if_addrs)
|
if (daemon->if_addrs)
|
||||||
{
|
{
|
||||||
struct iname *tmp;
|
struct iname *tmp;
|
||||||
|
|||||||
+16
-4
@@ -1167,10 +1167,22 @@ int add_resource_record(struct dns_header *header, char *limit, int *truncp, int
|
|||||||
static unsigned long crec_ttl(struct crec *crecp, time_t now)
|
static unsigned long crec_ttl(struct crec *crecp, time_t now)
|
||||||
{
|
{
|
||||||
/* Return 0 ttl for DHCP entries, which might change
|
/* Return 0 ttl for DHCP entries, which might change
|
||||||
before the lease expires. */
|
before the lease expires, unless configured otherwise. */
|
||||||
|
|
||||||
if (crecp->flags & (F_IMMORTAL | F_DHCP))
|
if (crecp->flags & F_DHCP)
|
||||||
return daemon->local_ttl;
|
{
|
||||||
|
int conf_ttl = daemon->use_dhcp_ttl ? daemon->dhcp_ttl : daemon->local_ttl;
|
||||||
|
|
||||||
|
/* Apply ceiling of actual lease length to configured TTL. */
|
||||||
|
if (!(crecp->flags & F_IMMORTAL) && (crecp->ttd - now) < conf_ttl)
|
||||||
|
return crecp->ttd - now;
|
||||||
|
|
||||||
|
return conf_ttl;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Immortal entries other than DHCP are local, and hold TTL in TTD field. */
|
||||||
|
if (crecp->flags & F_IMMORTAL)
|
||||||
|
return crecp->ttd;
|
||||||
|
|
||||||
/* Return the Max TTL value if it is lower then the actual TTL */
|
/* Return the Max TTL value if it is lower then the actual TTL */
|
||||||
if (daemon->max_ttl == 0 || ((unsigned)(crecp->ttd - now) < daemon->max_ttl))
|
if (daemon->max_ttl == 0 || ((unsigned)(crecp->ttd - now) < daemon->max_ttl))
|
||||||
@@ -1835,7 +1847,7 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen,
|
|||||||
|
|
||||||
/* Advertise our packet size limit in our reply */
|
/* Advertise our packet size limit in our reply */
|
||||||
if (have_pseudoheader)
|
if (have_pseudoheader)
|
||||||
len = add_pseudoheader(header, len, (unsigned char *)limit, daemon->edns_pktsz, 0, NULL, 0, do_bit);
|
len = add_pseudoheader(header, len, (unsigned char *)limit, daemon->edns_pktsz, 0, NULL, 0, do_bit, 0);
|
||||||
|
|
||||||
if (ad_reqd && sec_data)
|
if (ad_reqd && sec_data)
|
||||||
header->hb4 |= HB4_AD;
|
header->hb4 |= HB4_AD;
|
||||||
|
|||||||
+12
-2
@@ -103,8 +103,10 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
if (listen->iface)
|
if (listen->iface)
|
||||||
{
|
{
|
||||||
addr = listen->iface->addr;
|
addr = listen->iface->addr;
|
||||||
mtu = listen->iface->mtu;
|
|
||||||
name = listen->iface->name;
|
name = listen->iface->name;
|
||||||
|
mtu = listen->iface->mtu;
|
||||||
|
if (daemon->tftp_mtu != 0 && daemon->tftp_mtu < mtu)
|
||||||
|
mtu = daemon->tftp_mtu;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -234,9 +236,17 @@ void tftp_request(struct listener *listen, time_t now)
|
|||||||
|
|
||||||
strncpy(ifr.ifr_name, name, IF_NAMESIZE);
|
strncpy(ifr.ifr_name, name, IF_NAMESIZE);
|
||||||
if (ioctl(listen->tftpfd, SIOCGIFMTU, &ifr) != -1)
|
if (ioctl(listen->tftpfd, SIOCGIFMTU, &ifr) != -1)
|
||||||
mtu = ifr.ifr_mtu;
|
{
|
||||||
|
mtu = ifr.ifr_mtu;
|
||||||
|
if (daemon->tftp_mtu != 0 && daemon->tftp_mtu < mtu)
|
||||||
|
mtu = daemon->tftp_mtu;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Failed to get interface mtu - can use configured value. */
|
||||||
|
if (mtu == 0)
|
||||||
|
mtu = daemon->tftp_mtu;
|
||||||
|
|
||||||
if (name)
|
if (name)
|
||||||
{
|
{
|
||||||
/* check for per-interface prefix */
|
/* check for per-interface prefix */
|
||||||
|
|||||||
Reference in new issue
Block a user