mirror of
http://thekelleys.org.uk/git/dnsmasq.git
synced 2026-11-12 16:50:54 +00:00
Compare commits
10
Commits
v2.86test6
...
v2.86test7
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a1729deed3 | ||
|
|
fc64b97cd5 | ||
|
|
daddc8cb80 | ||
|
|
527c3c7d0d | ||
|
|
fcb4dcaf7c | ||
|
|
3ca4995d34 | ||
|
|
d387f8f06c | ||
|
|
ea43234c86 | ||
|
|
867e56a45e | ||
|
|
a163c63787 |
No files matched your search
@@ -1,6 +1,6 @@
|
|||||||
version 2.86
|
version 2.86
|
||||||
Handle DHCPREBIND requests in the DHCPv6 server code.
|
Handle DHCPREBIND requests in the DHCPv6 server code.
|
||||||
Thanks to Aichun Li for spotting this ommision, and the initial
|
Thanks to Aichun Li for spotting this omission, and the initial
|
||||||
patch.
|
patch.
|
||||||
|
|
||||||
Fix bug which caused dnsmasq to lose track of processes forked
|
Fix bug which caused dnsmasq to lose track of processes forked
|
||||||
@@ -33,7 +33,7 @@ version 2.86
|
|||||||
address=/example.com/1.2.3.4
|
address=/example.com/1.2.3.4
|
||||||
address=/example.com/5.6.7.8
|
address=/example.com/5.6.7.8
|
||||||
It also handles multiple upstream servers for a domain better; using
|
It also handles multiple upstream servers for a domain better; using
|
||||||
the same try/retry alogrithms as non domain-specific servers. This
|
the same try/retry algorithms as non domain-specific servers. This
|
||||||
also applies to DNSSEC-generated queries.
|
also applies to DNSSEC-generated queries.
|
||||||
Finally, some of the oldest and gnarliest code in dnsmasq has had
|
Finally, some of the oldest and gnarliest code in dnsmasq has had
|
||||||
a significant clean-up. It's far from perfect, but it _is_ better.
|
a significant clean-up. It's far from perfect, but it _is_ better.
|
||||||
@@ -76,12 +76,16 @@ version 2.86
|
|||||||
Disallowed queries are not forwarded; they are rejected
|
Disallowed queries are not forwarded; they are rejected
|
||||||
with a REFUSED error code.
|
with a REFUSED error code.
|
||||||
|
|
||||||
Allow smaller then 64 prefix lengths in synth-domain, with caveats.
|
Allow smaller than 64 prefix lengths in synth-domain, with caveats.
|
||||||
--synth-domain=1234:4567::/56,example.com is now valid.
|
--synth-domain=1234:4567::/56,example.com is now valid.
|
||||||
|
|
||||||
Make domains generated by --synth-domain appear in replies
|
Make domains generated by --synth-domain appear in replies
|
||||||
when in authoritative mode.
|
when in authoritative mode.
|
||||||
|
|
||||||
|
Ensure CAP_NET_ADMIN capability is available when
|
||||||
|
conntrack is configured. Thanks to Yick Xie for spotting
|
||||||
|
the lack of this.
|
||||||
|
|
||||||
|
|
||||||
version 2.85
|
version 2.85
|
||||||
Fix problem with DNS retries in 2.83/2.84.
|
Fix problem with DNS retries in 2.83/2.84.
|
||||||
|
|||||||
@@ -153,7 +153,11 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
lease.s_addr = inet_addr(argv[1]);
|
if (inet_pton(AF_INET, argv[1], &lease) < 1)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "invalid address: %s\n", argv[1]);
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
memset(&packet, 0, sizeof(packet));
|
memset(&packet, 0, sizeof(packet));
|
||||||
|
|
||||||
@@ -177,7 +181,7 @@ int main(int argc, char **argv)
|
|||||||
*(p++) = OPTION_END;
|
*(p++) = OPTION_END;
|
||||||
|
|
||||||
dest.sin_family = AF_INET;
|
dest.sin_family = AF_INET;
|
||||||
dest.sin_addr.s_addr = inet_addr("127.0.0.1");
|
(void)inet_pton(AF_INET, "127.0.0.1", &dest.sin_addr);
|
||||||
dest.sin_port = ntohs(DHCP_SERVER_PORT);
|
dest.sin_port = ntohs(DHCP_SERVER_PORT);
|
||||||
|
|
||||||
if (sendto(fd, &packet, sizeof(packet), 0,
|
if (sendto(fd, &packet, sizeof(packet), 0,
|
||||||
|
|||||||
@@ -288,13 +288,12 @@ int main(int argc, char **argv)
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (inet_addr(argv[2]) == INADDR_NONE)
|
if (inet_pton(AF_INET, argv[2], &lease.s_addr) < 1)
|
||||||
{
|
{
|
||||||
perror("invalid ip address");
|
perror("invalid ip address");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
lease.s_addr = inet_addr(argv[2]);
|
|
||||||
server = find_interface(lease, nl, if_nametoindex(argv[1]), fd, &ifr);
|
server = find_interface(lease, nl, if_nametoindex(argv[1]), fd, &ifr);
|
||||||
|
|
||||||
memset(&packet, 0, sizeof(packet));
|
memset(&packet, 0, sizeof(packet));
|
||||||
|
|||||||
+11
-6
@@ -468,8 +468,11 @@ void dhcp_packet(time_t now, int pxe_fd)
|
|||||||
|
|
||||||
/* This can fail when, eg, iptables DROPS destination 255.255.255.255 */
|
/* This can fail when, eg, iptables DROPS destination 255.255.255.255 */
|
||||||
if (errno != 0)
|
if (errno != 0)
|
||||||
|
{
|
||||||
|
inet_ntop(AF_INET, &dest.sin_addr, daemon->addrbuff, ADDRSTRLEN);
|
||||||
my_syslog(MS_DHCP | LOG_WARNING, _("Error sending DHCP packet to %s: %s"),
|
my_syslog(MS_DHCP | LOG_WARNING, _("Error sending DHCP packet to %s: %s"),
|
||||||
inet_ntoa(dest.sin_addr), strerror(errno));
|
daemon->addrbuff, strerror(errno));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check against secondary interface addresses */
|
/* check against secondary interface addresses */
|
||||||
@@ -521,10 +524,11 @@ static void guess_range_netmask(struct in_addr addr, struct in_addr netmask)
|
|||||||
!(is_same_net(addr, context->start, netmask) &&
|
!(is_same_net(addr, context->start, netmask) &&
|
||||||
is_same_net(addr, context->end, netmask)))
|
is_same_net(addr, context->end, netmask)))
|
||||||
{
|
{
|
||||||
strcpy(daemon->dhcp_buff, inet_ntoa(context->start));
|
inet_ntop(AF_INET, &context->start, daemon->dhcp_buff, DHCP_BUFF_SZ);
|
||||||
strcpy(daemon->dhcp_buff2, inet_ntoa(context->end));
|
inet_ntop(AF_INET, &context->end, daemon->dhcp_buff2, DHCP_BUFF_SZ);
|
||||||
|
inet_ntop(AF_INET, &netmask, daemon->addrbuff, ADDRSTRLEN);
|
||||||
my_syslog(MS_DHCP | LOG_WARNING, _("DHCP range %s -- %s is not consistent with netmask %s"),
|
my_syslog(MS_DHCP | LOG_WARNING, _("DHCP range %s -- %s is not consistent with netmask %s"),
|
||||||
daemon->dhcp_buff, daemon->dhcp_buff2, inet_ntoa(netmask));
|
daemon->dhcp_buff, daemon->dhcp_buff2, daemon->addrbuff);
|
||||||
}
|
}
|
||||||
context->netmask = netmask;
|
context->netmask = netmask;
|
||||||
}
|
}
|
||||||
@@ -922,7 +926,7 @@ void dhcp_read_ethers(void)
|
|||||||
|
|
||||||
if (!*cp)
|
if (!*cp)
|
||||||
{
|
{
|
||||||
if ((addr.s_addr = inet_addr(ip)) == (in_addr_t)-1)
|
if (inet_pton(AF_INET, ip, &addr.s_addr) < 1)
|
||||||
{
|
{
|
||||||
my_syslog(MS_DHCP | LOG_ERR, _("bad address at %s line %d"), ETHERSFILE, lineno);
|
my_syslog(MS_DHCP | LOG_ERR, _("bad address at %s line %d"), ETHERSFILE, lineno);
|
||||||
continue;
|
continue;
|
||||||
@@ -1097,7 +1101,8 @@ static int relay_upstream4(struct dhcp_relay *relay, struct dhcp_packet *mess,
|
|||||||
if (option_bool(OPT_LOG_OPTS))
|
if (option_bool(OPT_LOG_OPTS))
|
||||||
{
|
{
|
||||||
inet_ntop(AF_INET, &relay->local, daemon->addrbuff, ADDRSTRLEN);
|
inet_ntop(AF_INET, &relay->local, daemon->addrbuff, ADDRSTRLEN);
|
||||||
my_syslog(MS_DHCP | LOG_INFO, _("DHCP relay %s -> %s"), daemon->addrbuff, inet_ntoa(relay->server.addr4));
|
inet_ntop(AF_INET, &relay->server.addr4, daemon->dhcp_buff2, DHCP_BUFF_SZ);
|
||||||
|
my_syslog(MS_DHCP | LOG_INFO, _("DHCP relay %s -> %s"), daemon->addrbuff, daemon->dhcp_buff2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Save this for replies */
|
/* Save this for replies */
|
||||||
|
|||||||
+6
-2
@@ -109,7 +109,6 @@ int main (int argc, char **argv)
|
|||||||
daemon->packet_buff_sz = daemon->edns_pktsz + MAXDNAME + RRFIXEDSZ;
|
daemon->packet_buff_sz = daemon->edns_pktsz + MAXDNAME + RRFIXEDSZ;
|
||||||
daemon->packet = safe_malloc(daemon->packet_buff_sz);
|
daemon->packet = safe_malloc(daemon->packet_buff_sz);
|
||||||
|
|
||||||
daemon->addrbuff = safe_malloc(ADDRSTRLEN);
|
|
||||||
if (option_bool(OPT_EXTRALOG))
|
if (option_bool(OPT_EXTRALOG))
|
||||||
daemon->addrbuff2 = safe_malloc(ADDRSTRLEN);
|
daemon->addrbuff2 = safe_malloc(ADDRSTRLEN);
|
||||||
|
|
||||||
@@ -212,8 +211,13 @@ int main (int argc, char **argv)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_CONNTRACK
|
#ifdef HAVE_CONNTRACK
|
||||||
if (option_bool(OPT_CONNTRACK) && (daemon->query_port != 0 || daemon->osport))
|
if (option_bool(OPT_CONNTRACK))
|
||||||
|
{
|
||||||
|
if (daemon->query_port != 0 || daemon->osport)
|
||||||
die (_("cannot use --conntrack AND --query-port"), NULL, EC_BADCONF);
|
die (_("cannot use --conntrack AND --query-port"), NULL, EC_BADCONF);
|
||||||
|
|
||||||
|
need_cap_net_admin = 1;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
if (option_bool(OPT_CONNTRACK))
|
if (option_bool(OPT_CONNTRACK))
|
||||||
die(_("conntrack support not available: set HAVE_CONNTRACK in src/config.h"), NULL, EC_BADCONF);
|
die(_("conntrack support not available: set HAVE_CONNTRACK in src/config.h"), NULL, EC_BADCONF);
|
||||||
|
|||||||
+26
-21
@@ -255,29 +255,25 @@ static int forward_query(int udpfd, union mysockaddr *udpaddr,
|
|||||||
/* new query */
|
/* new query */
|
||||||
if (!forward)
|
if (!forward)
|
||||||
{
|
{
|
||||||
/* new query */
|
if (lookup_domain(daemon->namebuff, gotname, &first, &last))
|
||||||
|
flags = is_local_answer(now, first, daemon->namebuff);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* no available server. */
|
||||||
|
ede = EDE_NOT_READY;
|
||||||
|
flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* don't forward A or AAAA queries for simple names, except the empty name */
|
/* don't forward A or AAAA queries for simple names, except the empty name */
|
||||||
if (option_bool(OPT_NODOTS_LOCAL) &&
|
if (!flags &&
|
||||||
|
option_bool(OPT_NODOTS_LOCAL) &&
|
||||||
(gotname & (F_IPV4 | F_IPV6)) &&
|
(gotname & (F_IPV4 | F_IPV6)) &&
|
||||||
!strchr(daemon->namebuff, '.') &&
|
!strchr(daemon->namebuff, '.') &&
|
||||||
strlen(daemon->namebuff) != 0)
|
strlen(daemon->namebuff) != 0)
|
||||||
{
|
flags = check_for_local_domain(daemon->namebuff, now) ? F_NOERR : F_NXDOMAIN;
|
||||||
flags = F_NOERR;
|
|
||||||
goto reply;
|
|
||||||
}
|
|
||||||
|
|
||||||
flags = 0;
|
|
||||||
|
|
||||||
/* no available server. */
|
|
||||||
if (!lookup_domain(daemon->namebuff, gotname, &first, &last))
|
|
||||||
{
|
|
||||||
ede = EDE_NOT_READY;
|
|
||||||
goto reply;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Configured answer. */
|
/* Configured answer. */
|
||||||
if ((flags = is_local_answer(now, first, daemon->namebuff)))
|
if (flags || ede == EDE_NOT_READY)
|
||||||
goto reply;
|
goto reply;
|
||||||
|
|
||||||
master = daemon->serverarray[first];
|
master = daemon->serverarray[first];
|
||||||
@@ -2038,15 +2034,24 @@ unsigned char *tcp_request(int confd, time_t now,
|
|||||||
struct server *master;
|
struct server *master;
|
||||||
int start;
|
int start;
|
||||||
|
|
||||||
|
if (lookup_domain(daemon->namebuff, gotname, &first, &last))
|
||||||
|
flags = is_local_answer(now, first, daemon->namebuff);
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* No configured servers */
|
||||||
|
ede = EDE_NOT_READY;
|
||||||
|
flags = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* don't forward A or AAAA queries for simple names, except the empty name */
|
/* don't forward A or AAAA queries for simple names, except the empty name */
|
||||||
if (option_bool(OPT_NODOTS_LOCAL) &&
|
if (!flags &&
|
||||||
|
option_bool(OPT_NODOTS_LOCAL) &&
|
||||||
(gotname & (F_IPV4 | F_IPV6)) &&
|
(gotname & (F_IPV4 | F_IPV6)) &&
|
||||||
!strchr(daemon->namebuff, '.') &&
|
!strchr(daemon->namebuff, '.') &&
|
||||||
strlen(daemon->namebuff) != 0)
|
strlen(daemon->namebuff) != 0)
|
||||||
flags = F_NOERR;
|
flags = check_for_local_domain(daemon->namebuff, now) ? F_NOERR : F_NXDOMAIN;
|
||||||
else if (!lookup_domain(daemon->namebuff, gotname, &first, &last))
|
|
||||||
ede = EDE_NOT_READY; /* No configured servers */
|
if (!flags && ede != EDE_NOT_READY)
|
||||||
else if (!(flags = is_local_answer(now, first, daemon->namebuff)))
|
|
||||||
{
|
{
|
||||||
master = daemon->serverarray[first];
|
master = daemon->serverarray[first];
|
||||||
|
|
||||||
|
|||||||
+8
-2
@@ -432,7 +432,8 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
|
|||||||
buf = grab_extradata_lua(buf, end, "relay_address");
|
buf = grab_extradata_lua(buf, end, "relay_address");
|
||||||
else if (data.giaddr.s_addr != 0)
|
else if (data.giaddr.s_addr != 0)
|
||||||
{
|
{
|
||||||
lua_pushstring(lua, inet_ntoa(data.giaddr));
|
inet_ntop(AF_INET, &data.giaddr, daemon->addrbuff, ADDRSTRLEN);
|
||||||
|
lua_pushstring(lua, daemon->addrbuff);
|
||||||
lua_setfield(lua, -2, "relay_address");
|
lua_setfield(lua, -2, "relay_address");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -611,7 +612,12 @@ int create_helper(int event_fd, int err_fd, uid_t uid, gid_t gid, long max_fd)
|
|||||||
if (is6)
|
if (is6)
|
||||||
buf = grab_extradata(buf, end, "DNSMASQ_RELAY_ADDRESS", &err);
|
buf = grab_extradata(buf, end, "DNSMASQ_RELAY_ADDRESS", &err);
|
||||||
else
|
else
|
||||||
my_setenv("DNSMASQ_RELAY_ADDRESS", data.giaddr.s_addr != 0 ? inet_ntoa(data.giaddr) : NULL, &err);
|
{
|
||||||
|
const char *giaddr = NULL;
|
||||||
|
if (data.giaddr.s_addr != 0)
|
||||||
|
giaddr = inet_ntop(AF_INET, &data.giaddr, daemon->addrbuff, ADDRSTRLEN);
|
||||||
|
my_setenv("DNSMASQ_RELAY_ADDRESS", giaddr, &err);
|
||||||
|
}
|
||||||
|
|
||||||
for (i = 0; buf; i++)
|
for (i = 0; buf; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -1688,7 +1688,7 @@ int reload_servers(char *fname)
|
|||||||
memset(&addr, 0, sizeof(addr));
|
memset(&addr, 0, sizeof(addr));
|
||||||
memset(&source_addr, 0, sizeof(source_addr));
|
memset(&source_addr, 0, sizeof(source_addr));
|
||||||
|
|
||||||
if ((addr.in.sin_addr.s_addr = inet_addr(token)) != (in_addr_t) -1)
|
if (inet_pton(AF_INET, token, &addr.in.sin_addr) > 0)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_SOCKADDR_SA_LEN
|
#ifdef HAVE_SOCKADDR_SA_LEN
|
||||||
source_addr.in.sin_len = addr.in.sin_len = sizeof(source_addr.in);
|
source_addr.in.sin_len = addr.in.sin_len = sizeof(source_addr.in);
|
||||||
|
|||||||
+4
-1
@@ -3612,7 +3612,9 @@ static int one_opt(int option, char *arg, char *errstr, char *gen_err, int comma
|
|||||||
for (configs = daemon->dhcp_conf; configs; configs = configs->next)
|
for (configs = daemon->dhcp_conf; configs; configs = configs->next)
|
||||||
if ((configs->flags & CONFIG_ADDR) && configs->addr.s_addr == in.s_addr)
|
if ((configs->flags & CONFIG_ADDR) && configs->addr.s_addr == in.s_addr)
|
||||||
{
|
{
|
||||||
sprintf(errstr, _("duplicate dhcp-host IP address %s"), inet_ntoa(in));
|
inet_ntop(AF_INET, &in, daemon->addrbuff, ADDRSTRLEN);
|
||||||
|
sprintf(errstr, _("duplicate dhcp-host IP address %s"),
|
||||||
|
daemon->addrbuff);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5234,6 +5236,7 @@ void read_opts(int argc, char **argv, char *compile_opts)
|
|||||||
daemon = opt_malloc(sizeof(struct daemon));
|
daemon = opt_malloc(sizeof(struct daemon));
|
||||||
memset(daemon, 0, sizeof(struct daemon));
|
memset(daemon, 0, sizeof(struct daemon));
|
||||||
daemon->namebuff = buff;
|
daemon->namebuff = buff;
|
||||||
|
daemon->addrbuff = safe_malloc(ADDRSTRLEN);
|
||||||
|
|
||||||
/* Set defaults - everything else is zero or NULL */
|
/* Set defaults - everything else is zero or NULL */
|
||||||
daemon->cachesize = CACHESIZ;
|
daemon->cachesize = CACHESIZ;
|
||||||
|
|||||||
+43
-21
@@ -372,9 +372,22 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
|
|
||||||
if (!context)
|
if (!context)
|
||||||
{
|
{
|
||||||
|
const char *via;
|
||||||
|
if (subnet_addr.s_addr)
|
||||||
|
{
|
||||||
|
via = _("with subnet selector");
|
||||||
|
inet_ntop(AF_INET, &subnet_addr, daemon->addrbuff, ADDRSTRLEN);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
via = _("via");
|
||||||
|
if (mess->giaddr.s_addr)
|
||||||
|
inet_ntop(AF_INET, &mess->giaddr, daemon->addrbuff, ADDRSTRLEN);
|
||||||
|
else
|
||||||
|
safe_strncpy(daemon->addrbuff, iface_name, ADDRSTRLEN);
|
||||||
|
}
|
||||||
my_syslog(MS_DHCP | LOG_WARNING, _("no address range available for DHCP request %s %s"),
|
my_syslog(MS_DHCP | LOG_WARNING, _("no address range available for DHCP request %s %s"),
|
||||||
subnet_addr.s_addr ? _("with subnet selector") : _("via"),
|
via, daemon->addrbuff);
|
||||||
subnet_addr.s_addr ? inet_ntoa(subnet_addr) : (mess->giaddr.s_addr ? inet_ntoa(mess->giaddr) : iface_name));
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -383,13 +396,19 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
struct dhcp_context *context_tmp;
|
struct dhcp_context *context_tmp;
|
||||||
for (context_tmp = context; context_tmp; context_tmp = context_tmp->current)
|
for (context_tmp = context; context_tmp; context_tmp = context_tmp->current)
|
||||||
{
|
{
|
||||||
strcpy(daemon->namebuff, inet_ntoa(context_tmp->start));
|
inet_ntop(AF_INET, &context_tmp->start, daemon->namebuff, MAXDNAME);
|
||||||
if (context_tmp->flags & (CONTEXT_STATIC | CONTEXT_PROXY))
|
if (context_tmp->flags & (CONTEXT_STATIC | CONTEXT_PROXY))
|
||||||
|
{
|
||||||
|
inet_ntop(AF_INET, &context_tmp->netmask, daemon->addrbuff, ADDRSTRLEN);
|
||||||
my_syslog(MS_DHCP | LOG_INFO, _("%u available DHCP subnet: %s/%s"),
|
my_syslog(MS_DHCP | LOG_INFO, _("%u available DHCP subnet: %s/%s"),
|
||||||
ntohl(mess->xid), daemon->namebuff, inet_ntoa(context_tmp->netmask));
|
ntohl(mess->xid), daemon->namebuff, daemon->addrbuff);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
inet_ntop(AF_INET, &context_tmp->end, daemon->addrbuff, ADDRSTRLEN);
|
||||||
my_syslog(MS_DHCP | LOG_INFO, _("%u available DHCP range: %s -- %s"),
|
my_syslog(MS_DHCP | LOG_INFO, _("%u available DHCP range: %s -- %s"),
|
||||||
ntohl(mess->xid), daemon->namebuff, inet_ntoa(context_tmp->end));
|
ntohl(mess->xid), daemon->namebuff, daemon->addrbuff);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1031,8 +1050,9 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
config->addr.s_addr == option_addr(opt).s_addr)
|
config->addr.s_addr == option_addr(opt).s_addr)
|
||||||
{
|
{
|
||||||
prettyprint_time(daemon->dhcp_buff, DECLINE_BACKOFF);
|
prettyprint_time(daemon->dhcp_buff, DECLINE_BACKOFF);
|
||||||
|
inet_ntop(AF_INET, &config->addr, daemon->addrbuff, ADDRSTRLEN);
|
||||||
my_syslog(MS_DHCP | LOG_WARNING, _("disabling DHCP static address %s for %s"),
|
my_syslog(MS_DHCP | LOG_WARNING, _("disabling DHCP static address %s for %s"),
|
||||||
inet_ntoa(config->addr), daemon->dhcp_buff);
|
daemon->addrbuff, daemon->dhcp_buff);
|
||||||
config->flags |= CONFIG_DECLINED;
|
config->flags |= CONFIG_DECLINED;
|
||||||
config->decline_time = now;
|
config->decline_time = now;
|
||||||
}
|
}
|
||||||
@@ -1078,7 +1098,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
|
|
||||||
if (have_config(config, CONFIG_ADDR))
|
if (have_config(config, CONFIG_ADDR))
|
||||||
{
|
{
|
||||||
char *addrs = inet_ntoa(config->addr);
|
inet_ntop(AF_INET, &config->addr, daemon->addrbuff, ADDRSTRLEN);
|
||||||
|
|
||||||
if ((ltmp = lease_find_by_addr(config->addr)) &&
|
if ((ltmp = lease_find_by_addr(config->addr)) &&
|
||||||
ltmp != lease &&
|
ltmp != lease &&
|
||||||
@@ -1088,7 +1108,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
unsigned char *mac = extended_hwaddr(ltmp->hwaddr_type, ltmp->hwaddr_len,
|
unsigned char *mac = extended_hwaddr(ltmp->hwaddr_type, ltmp->hwaddr_len,
|
||||||
ltmp->hwaddr, ltmp->clid_len, ltmp->clid, &len);
|
ltmp->hwaddr, ltmp->clid_len, ltmp->clid, &len);
|
||||||
my_syslog(MS_DHCP | LOG_WARNING, _("not using configured address %s because it is leased to %s"),
|
my_syslog(MS_DHCP | LOG_WARNING, _("not using configured address %s because it is leased to %s"),
|
||||||
addrs, print_mac(daemon->namebuff, mac, len));
|
daemon->addrbuff, print_mac(daemon->namebuff, mac, len));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1097,10 +1117,10 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
if (context->router.s_addr == config->addr.s_addr)
|
if (context->router.s_addr == config->addr.s_addr)
|
||||||
break;
|
break;
|
||||||
if (tmp)
|
if (tmp)
|
||||||
my_syslog(MS_DHCP | LOG_WARNING, _("not using configured address %s because it is in use by the server or relay"), addrs);
|
my_syslog(MS_DHCP | LOG_WARNING, _("not using configured address %s because it is in use by the server or relay"), daemon->addrbuff);
|
||||||
else if (have_config(config, CONFIG_DECLINED) &&
|
else if (have_config(config, CONFIG_DECLINED) &&
|
||||||
difftime(now, config->decline_time) < (float)DECLINE_BACKOFF)
|
difftime(now, config->decline_time) < (float)DECLINE_BACKOFF)
|
||||||
my_syslog(MS_DHCP | LOG_WARNING, _("not using configured address %s because it was previously declined"), addrs);
|
my_syslog(MS_DHCP | LOG_WARNING, _("not using configured address %s because it was previously declined"), daemon->addrbuff);
|
||||||
else
|
else
|
||||||
conf = config->addr;
|
conf = config->addr;
|
||||||
}
|
}
|
||||||
@@ -1303,9 +1323,10 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|||||||
a lease from one of it's MACs to give the address to another. */
|
a lease from one of it's MACs to give the address to another. */
|
||||||
if (config && config_has_mac(config, ltmp->hwaddr, ltmp->hwaddr_len, ltmp->hwaddr_type))
|
if (config && config_has_mac(config, ltmp->hwaddr, ltmp->hwaddr_len, ltmp->hwaddr_type))
|
||||||
{
|
{
|
||||||
|
inet_ntop(AF_INET, <mp->addr, daemon->addrbuff, ADDRSTRLEN);
|
||||||
my_syslog(MS_DHCP | LOG_INFO, _("abandoning lease to %s of %s"),
|
my_syslog(MS_DHCP | LOG_INFO, _("abandoning lease to %s of %s"),
|
||||||
print_mac(daemon->namebuff, ltmp->hwaddr, ltmp->hwaddr_len),
|
print_mac(daemon->namebuff, ltmp->hwaddr, ltmp->hwaddr_len),
|
||||||
inet_ntoa(ltmp->addr));
|
daemon->addrbuff);
|
||||||
lease = ltmp;
|
lease = ltmp;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -1674,23 +1695,21 @@ static void add_extradata_opt(struct dhcp_lease *lease, unsigned char *opt)
|
|||||||
static void log_packet(char *type, void *addr, unsigned char *ext_mac,
|
static void log_packet(char *type, void *addr, unsigned char *ext_mac,
|
||||||
int mac_len, char *interface, char *string, char *err, u32 xid)
|
int mac_len, char *interface, char *string, char *err, u32 xid)
|
||||||
{
|
{
|
||||||
struct in_addr a;
|
|
||||||
|
|
||||||
if (!err && !option_bool(OPT_LOG_OPTS) && option_bool(OPT_QUIET_DHCP))
|
if (!err && !option_bool(OPT_LOG_OPTS) && option_bool(OPT_QUIET_DHCP))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* addr may be misaligned */
|
daemon->addrbuff[0] = 0;
|
||||||
if (addr)
|
if (addr)
|
||||||
memcpy(&a, addr, sizeof(a));
|
inet_ntop(AF_INET, addr, daemon->addrbuff, ADDRSTRLEN);
|
||||||
|
|
||||||
print_mac(daemon->namebuff, ext_mac, mac_len);
|
print_mac(daemon->namebuff, ext_mac, mac_len);
|
||||||
|
|
||||||
if(option_bool(OPT_LOG_OPTS))
|
if (option_bool(OPT_LOG_OPTS))
|
||||||
my_syslog(MS_DHCP | LOG_INFO, "%u %s(%s) %s%s%s %s%s",
|
my_syslog(MS_DHCP | LOG_INFO, "%u %s(%s) %s%s%s %s%s",
|
||||||
ntohl(xid),
|
ntohl(xid),
|
||||||
type,
|
type,
|
||||||
interface,
|
interface,
|
||||||
addr ? inet_ntoa(a) : "",
|
daemon->addrbuff,
|
||||||
addr ? " " : "",
|
addr ? " " : "",
|
||||||
daemon->namebuff,
|
daemon->namebuff,
|
||||||
string ? string : "",
|
string ? string : "",
|
||||||
@@ -1699,7 +1718,7 @@ static void log_packet(char *type, void *addr, unsigned char *ext_mac,
|
|||||||
my_syslog(MS_DHCP | LOG_INFO, "%s(%s) %s%s%s %s%s",
|
my_syslog(MS_DHCP | LOG_INFO, "%s(%s) %s%s%s %s%s",
|
||||||
type,
|
type,
|
||||||
interface,
|
interface,
|
||||||
addr ? inet_ntoa(a) : "",
|
daemon->addrbuff,
|
||||||
addr ? " " : "",
|
addr ? " " : "",
|
||||||
daemon->namebuff,
|
daemon->namebuff,
|
||||||
string ? string : "",
|
string ? string : "",
|
||||||
@@ -1707,9 +1726,9 @@ static void log_packet(char *type, void *addr, unsigned char *ext_mac,
|
|||||||
|
|
||||||
#ifdef HAVE_UBUS
|
#ifdef HAVE_UBUS
|
||||||
if (!strcmp(type, "DHCPACK"))
|
if (!strcmp(type, "DHCPACK"))
|
||||||
ubus_event_bcast("dhcp.ack", daemon->namebuff, addr ? inet_ntoa(a) : NULL, string ? string : NULL, interface);
|
ubus_event_bcast("dhcp.ack", daemon->namebuff, addr ? daemon->addrbuff : NULL, string, interface);
|
||||||
else if (!strcmp(type, "DHCPRELEASE"))
|
else if (!strcmp(type, "DHCPRELEASE"))
|
||||||
ubus_event_bcast("dhcp.release", daemon->namebuff, addr ? inet_ntoa(a) : NULL, string ? string : NULL, interface);
|
ubus_event_bcast("dhcp.release", daemon->namebuff, addr ? daemon->addrbuff : NULL, string, interface);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1861,7 +1880,10 @@ static size_t dhcp_packet_size(struct dhcp_packet *mess, unsigned char *agent_id
|
|||||||
if (option_bool(OPT_LOG_OPTS))
|
if (option_bool(OPT_LOG_OPTS))
|
||||||
{
|
{
|
||||||
if (mess->siaddr.s_addr != 0)
|
if (mess->siaddr.s_addr != 0)
|
||||||
my_syslog(MS_DHCP | LOG_INFO, _("%u next server: %s"), ntohl(mess->xid), inet_ntoa(mess->siaddr));
|
{
|
||||||
|
inet_ntop(AF_INET, &mess->siaddr, daemon->addrbuff, ADDRSTRLEN);
|
||||||
|
my_syslog(MS_DHCP | LOG_INFO, _("%u next server: %s"), ntohl(mess->xid), daemon->addrbuff);
|
||||||
|
}
|
||||||
|
|
||||||
if ((mess->flags & htons(0x8000)) && mess->ciaddr.s_addr == 0)
|
if ((mess->flags & htons(0x8000)) && mess->ciaddr.s_addr == 0)
|
||||||
my_syslog(MS_DHCP | LOG_INFO, _("%u broadcast response"), ntohl(mess->xid));
|
my_syslog(MS_DHCP | LOG_INFO, _("%u broadcast response"), ntohl(mess->xid));
|
||||||
|
|||||||
+6
-8
@@ -21,7 +21,6 @@
|
|||||||
#include <libubus.h>
|
#include <libubus.h>
|
||||||
|
|
||||||
static struct blob_buf b;
|
static struct blob_buf b;
|
||||||
static int notify;
|
|
||||||
static int error_logged = 0;
|
static int error_logged = 0;
|
||||||
|
|
||||||
static int ubus_handle_metrics(struct ubus_context *ctx, struct ubus_object *obj,
|
static int ubus_handle_metrics(struct ubus_context *ctx, struct ubus_object *obj,
|
||||||
@@ -78,17 +77,16 @@ static void ubus_subscribe_cb(struct ubus_context *ctx, struct ubus_object *obj)
|
|||||||
(void)ctx;
|
(void)ctx;
|
||||||
|
|
||||||
my_syslog(LOG_DEBUG, _("UBus subscription callback: %s subscriber(s)"), obj->has_subscribers ? "1" : "0");
|
my_syslog(LOG_DEBUG, _("UBus subscription callback: %s subscriber(s)"), obj->has_subscribers ? "1" : "0");
|
||||||
notify = obj->has_subscribers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ubus_destroy(struct ubus_context *ubus)
|
static void ubus_destroy(struct ubus_context *ubus)
|
||||||
{
|
{
|
||||||
|
ubus_free(ubus);
|
||||||
|
daemon->ubus = NULL;
|
||||||
|
|
||||||
// Forces re-initialization when we're reusing the same definitions later on.
|
// Forces re-initialization when we're reusing the same definitions later on.
|
||||||
ubus_object.id = 0;
|
ubus_object.id = 0;
|
||||||
ubus_object_type.id = 0;
|
ubus_object_type.id = 0;
|
||||||
|
|
||||||
ubus_free(ubus);
|
|
||||||
daemon->ubus = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ubus_disconnect_cb(struct ubus_context *ubus)
|
static void ubus_disconnect_cb(struct ubus_context *ubus)
|
||||||
@@ -312,7 +310,7 @@ void ubus_event_bcast(const char *type, const char *mac, const char *ip, const c
|
|||||||
struct ubus_context *ubus = (struct ubus_context *)daemon->ubus;
|
struct ubus_context *ubus = (struct ubus_context *)daemon->ubus;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!ubus || !notify)
|
if (!ubus || !ubus_object.has_subscribers)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
blob_buf_init(&b, BLOBMSG_TYPE_TABLE);
|
blob_buf_init(&b, BLOBMSG_TYPE_TABLE);
|
||||||
@@ -336,7 +334,7 @@ void ubus_event_bcast_connmark_allowlist_refused(u32 mark, const char *name)
|
|||||||
struct ubus_context *ubus = (struct ubus_context *)daemon->ubus;
|
struct ubus_context *ubus = (struct ubus_context *)daemon->ubus;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!ubus || !notify)
|
if (!ubus || !ubus_object.has_subscribers)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
@@ -353,7 +351,7 @@ void ubus_event_bcast_connmark_allowlist_resolved(u32 mark, const char *name, co
|
|||||||
struct ubus_context *ubus = (struct ubus_context *)daemon->ubus;
|
struct ubus_context *ubus = (struct ubus_context *)daemon->ubus;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!ubus || !notify)
|
if (!ubus || !ubus_object.has_subscribers)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
blob_buf_init(&b, 0);
|
blob_buf_init(&b, 0);
|
||||||
|
|||||||
Reference in new issue
Block a user