dnsmasq: update to 63ba726 (2023-12-03) snapshot

arm-master
pedro 2 years ago
parent 8653f9c31b
commit cd8bb9eede

@ -1 +1 @@
(HEAD -> master, tag: v2.89-cd4db82, origin/master, origin/HEAD) (HEAD -> master, tag: v2.89-63ba726, origin/master, origin/HEAD)

@ -374,6 +374,13 @@ int main (int argc, char **argv)
if (!enumerate_interfaces(1) || !enumerate_interfaces(0)) if (!enumerate_interfaces(1) || !enumerate_interfaces(0))
die(_("failed to find list of interfaces: %s"), NULL, EC_MISC); die(_("failed to find list of interfaces: %s"), NULL, EC_MISC);
#ifdef HAVE_DHCP
/* Determine lease FQDNs after enumerate_interfaces() call, since it needs
to call get_domain and that's only valid for some domain configs once we
have interface addresses. */
lease_calc_fqdns();
#endif
if (option_bool(OPT_NOWILD) || option_bool(OPT_CLEVERBIND)) if (option_bool(OPT_NOWILD) || option_bool(OPT_CLEVERBIND))
{ {

@ -1605,6 +1605,7 @@ void lease_update_from_configs(void);
int do_script_run(time_t now); int do_script_run(time_t now);
void rerun_scripts(void); void rerun_scripts(void);
void lease_find_interfaces(time_t now); void lease_find_interfaces(time_t now);
void lease_calc_fqdns(void);
#ifdef HAVE_SCRIPT #ifdef HAVE_SCRIPT
void lease_add_extradata(struct dhcp_lease *lease, unsigned char *data, void lease_add_extradata(struct dhcp_lease *lease, unsigned char *data,
unsigned int len, int delim); unsigned int len, int delim);

@ -22,12 +22,13 @@ static int match_domain(struct in_addr addr, struct cond_domain *c);
static struct cond_domain *search_domain6(struct in6_addr *addr, struct cond_domain *c); static struct cond_domain *search_domain6(struct in6_addr *addr, struct cond_domain *c);
static int match_domain6(struct in6_addr *addr, struct cond_domain *c); static int match_domain6(struct in6_addr *addr, struct cond_domain *c);
int is_name_synthetic(int flags, char *name, union all_addr *addr) int is_name_synthetic(int flags, char *name, union all_addr *addrp)
{ {
char *p; char *p;
struct cond_domain *c = NULL; struct cond_domain *c = NULL;
int prot = (flags & F_IPV6) ? AF_INET6 : AF_INET; int prot = (flags & F_IPV6) ? AF_INET6 : AF_INET;
union all_addr addr;
for (c = daemon->synth_domains; c; c = c->next) for (c = daemon->synth_domains; c; c = c->next)
{ {
int found = 0; int found = 0;
@ -74,7 +75,7 @@ int is_name_synthetic(int flags, char *name, union all_addr *addr)
if (!c->is6 && if (!c->is6 &&
index <= ntohl(c->end.s_addr) - ntohl(c->start.s_addr)) index <= ntohl(c->end.s_addr) - ntohl(c->start.s_addr))
{ {
addr->addr4.s_addr = htonl(ntohl(c->start.s_addr) + index); addr.addr4.s_addr = htonl(ntohl(c->start.s_addr) + index);
found = 1; found = 1;
} }
} }
@ -86,8 +87,8 @@ int is_name_synthetic(int flags, char *name, union all_addr *addr)
index <= addr6part(&c->end6) - addr6part(&c->start6)) index <= addr6part(&c->end6) - addr6part(&c->start6))
{ {
u64 start = addr6part(&c->start6); u64 start = addr6part(&c->start6);
addr->addr6 = c->start6; addr.addr6 = c->start6;
setaddr6part(&addr->addr6, start + index); setaddr6part(&addr.addr6, start + index);
found = 1; found = 1;
} }
} }
@ -135,8 +136,8 @@ int is_name_synthetic(int flags, char *name, union all_addr *addr)
} }
} }
if (hostname_isequal(c->domain, p+1) && inet_pton(prot, tail, addr)) if (hostname_isequal(c->domain, p+1) && inet_pton(prot, tail, &addr))
found = (prot == AF_INET) ? match_domain(addr->addr4, c) : match_domain6(&addr->addr6, c); found = (prot == AF_INET) ? match_domain(addr.addr4, c) : match_domain6(&addr.addr6, c);
} }
/* restore name */ /* restore name */
@ -148,7 +149,12 @@ int is_name_synthetic(int flags, char *name, union all_addr *addr)
if (found) if (found)
return 1; {
if (addrp)
*addrp = addr;
return 1;
}
} }
return 0; return 0;

@ -15,7 +15,6 @@
*/ */
#include "dnsmasq.h" #include "dnsmasq.h"
#ifdef HAVE_DHCP #ifdef HAVE_DHCP
static struct dhcp_lease *leases = NULL, *old_leases = NULL; static struct dhcp_lease *leases = NULL, *old_leases = NULL;
@ -28,8 +27,7 @@ static int read_leases(time_t now, FILE *leasestream)
struct dhcp_lease *lease; struct dhcp_lease *lease;
int clid_len, hw_len, hw_type; int clid_len, hw_len, hw_type;
int items; int items;
char *domain = NULL;
*daemon->dhcp_buff3 = *daemon->dhcp_buff2 = '\0'; *daemon->dhcp_buff3 = *daemon->dhcp_buff2 = '\0';
/* client-id max length is 255 which is 255*2 digits + 254 colons /* client-id max length is 255 which is 255*2 digits + 254 colons
@ -69,8 +67,8 @@ static int read_leases(time_t now, FILE *leasestream)
if (inet_pton(AF_INET, daemon->namebuff, &addr.addr4)) if (inet_pton(AF_INET, daemon->namebuff, &addr.addr4))
{ {
if ((lease = lease4_allocate(addr.addr4))) lease = lease4_allocate(addr.addr4);
domain = get_domain(lease->addr);
hw_len = parse_hex(daemon->dhcp_buff2, (unsigned char *)daemon->dhcp_buff2, DHCP_CHADDR_MAX, NULL, &hw_type); hw_len = parse_hex(daemon->dhcp_buff2, (unsigned char *)daemon->dhcp_buff2, DHCP_CHADDR_MAX, NULL, &hw_type);
/* For backwards compatibility, no explicit MAC address type means ether. */ /* For backwards compatibility, no explicit MAC address type means ether. */
@ -90,10 +88,7 @@ static int read_leases(time_t now, FILE *leasestream)
} }
if ((lease = lease6_allocate(&addr.addr6, lease_type))) if ((lease = lease6_allocate(&addr.addr6, lease_type)))
{ lease_set_iaid(lease, strtoul(s, NULL, 10));
lease_set_iaid(lease, strtoul(s, NULL, 10));
domain = get_domain6(&lease->addr6);
}
} }
#endif #endif
else else
@ -114,7 +109,7 @@ static int read_leases(time_t now, FILE *leasestream)
hw_len, hw_type, clid_len, now, 0); hw_len, hw_type, clid_len, now, 0);
if (strcmp(daemon->dhcp_buff, "*") != 0) if (strcmp(daemon->dhcp_buff, "*") != 0)
lease_set_hostname(lease, daemon->dhcp_buff, 0, domain, NULL); lease_set_hostname(lease, daemon->dhcp_buff, 0, NULL, NULL);
ei = atol(daemon->dhcp_buff3); ei = atol(daemon->dhcp_buff3);
@ -946,6 +941,36 @@ static void kill_name(struct dhcp_lease *lease)
lease->hostname = lease->fqdn = NULL; lease->hostname = lease->fqdn = NULL;
} }
void lease_calc_fqdns(void)
{
struct dhcp_lease *lease;
for (lease = leases; lease; lease = lease->next)
{
char *domain;
if (lease->hostname)
{
#ifdef HAVE_DHCP6
if (lease->flags & (LEASE_TA | LEASE_NA))
domain = get_domain6(&lease->addr6);
else
#endif
domain = get_domain(lease->addr);
if (domain)
{
/* This is called only during startup, before forking, hence safe_malloc() */
lease->fqdn = safe_malloc(strlen(lease->hostname) + strlen(domain) + 2);
strcpy(lease->fqdn, lease->hostname);
strcat(lease->fqdn, ".");
strcat(lease->fqdn, domain);
}
}
}
}
void lease_set_hostname(struct dhcp_lease *lease, const char *name, int auth, char *domain, char *config_domain) void lease_set_hostname(struct dhcp_lease *lease, const char *name, int auth, char *domain, char *config_domain)
{ {
struct dhcp_lease *lease_tmp; struct dhcp_lease *lease_tmp;

@ -1213,6 +1213,10 @@ int check_for_local_domain(char *name, time_t now)
if (cache_find_non_terminal(name, now)) if (cache_find_non_terminal(name, now))
return 1; return 1;
if (is_name_synthetic(F_IPV4, name, NULL) ||
is_name_synthetic(F_IPV6, name, NULL))
return 1;
return 0; return 0;
} }

@ -79,7 +79,7 @@
/* Declare static char *compiler_opts in config.h */ /* Declare static char *compiler_opts in config.h */
#define DNSMASQ_COMPILE_OPTS #define DNSMASQ_COMPILE_OPTS
@@ -1574,8 +1612,22 @@ @@ -1581,8 +1619,22 @@
/* Note: this may leave TCP-handling processes with the old file still open. /* Note: this may leave TCP-handling processes with the old file still open.
Since any such process will die in CHILD_LIFETIME or probably much sooner, Since any such process will die in CHILD_LIFETIME or probably much sooner,
we leave them logging to the old file. */ we leave them logging to the old file. */
@ -102,7 +102,7 @@
break; break;
case EVENT_NEWADDR: case EVENT_NEWADDR:
@@ -1619,6 +1671,12 @@ @@ -1626,6 +1678,12 @@
close(daemon->helperfd); close(daemon->helperfd);
} }
#endif #endif
@ -117,7 +117,7 @@
fclose(daemon->lease_stream); fclose(daemon->lease_stream);
--- dnsmasq/src/dnsmasq.h --- dnsmasq/src/dnsmasq.h
+++ dnsmasq/src/dnsmasq.h +++ dnsmasq/src/dnsmasq.h
@@ -1626,6 +1626,12 @@ @@ -1627,6 +1627,12 @@
int icmp_ping(struct in_addr addr); int icmp_ping(struct in_addr addr);
int delay_dhcp(time_t start, int sec, int fd, uint32_t addr, unsigned short id); int delay_dhcp(time_t start, int sec, int fd, uint32_t addr, unsigned short id);
#endif #endif
@ -132,7 +132,7 @@
void send_event(int fd, int event, int data, char *msg); void send_event(int fd, int event, int data, char *msg);
--- dnsmasq/src/lease.c --- dnsmasq/src/lease.c
+++ dnsmasq/src/lease.c +++ dnsmasq/src/lease.c
@@ -118,12 +118,15 @@ @@ -113,12 +113,15 @@
ei = atol(daemon->dhcp_buff3); ei = atol(daemon->dhcp_buff3);
@ -149,7 +149,7 @@
#else #else
/* strictly time_t is opaque, but this hack should work on all sane systems, /* strictly time_t is opaque, but this hack should work on all sane systems,
even when sizeof(time_t) == 8 */ even when sizeof(time_t) == 8 */
@@ -269,10 +272,19 @@ @@ -264,10 +267,19 @@
continue; continue;
#endif #endif
@ -171,7 +171,7 @@
#endif #endif
if (lease->hwaddr_type != ARPHRD_ETHER || lease->hwaddr_len == 0) if (lease->hwaddr_type != ARPHRD_ETHER || lease->hwaddr_len == 0)
@@ -313,12 +325,21 @@ @@ -308,12 +320,21 @@
if (!(lease->flags & (LEASE_TA | LEASE_NA))) if (!(lease->flags & (LEASE_TA | LEASE_NA)))
continue; continue;
@ -196,7 +196,7 @@
inet_ntop(AF_INET6, &lease->addr6, daemon->addrbuff, ADDRSTRLEN); inet_ntop(AF_INET6, &lease->addr6, daemon->addrbuff, ADDRSTRLEN);
ourprintf(&err, "%s%u %s ", (lease->flags & LEASE_TA) ? "T" : "", ourprintf(&err, "%s%u %s ", (lease->flags & LEASE_TA) ? "T" : "",
@@ -1196,4 +1217,66 @@ @@ -1221,4 +1242,66 @@
} }
#endif #endif

Loading…
Cancel
Save