|
@@ -79,7 +79,7 @@
|
|
|
#define CACHE_AUTO_ENABLE_SIZE (1024 * 1024 * 128)
|
|
|
#define EXPIRED_DOMAIN_PREFETCH_TIME (3600 * 8)
|
|
|
#define DNS_MAX_DOMAIN_REFETCH_NUM 64
|
|
|
-#define DNS_SERVER_NEIGHBOR_CACHE_MAX_NUM 8192
|
|
|
+#define DNS_SERVER_NEIGHBOR_CACHE_MAX_NUM (1024 * 8)
|
|
|
#define DNS_SERVER_NEIGHBOR_CACHE_TIMEOUT (3600 * 1)
|
|
|
#define DNS_SERVER_NEIGHBOR_CACHE_NOMAC_TIMEOUT 60
|
|
|
|
|
@@ -3619,13 +3619,36 @@ static struct dns_client_rules *_dns_server_get_client_rules_by_mac(uint8_t *net
|
|
|
args.netaddr = netaddr;
|
|
|
args.netaddr_len = netaddr_len;
|
|
|
|
|
|
- ret = netlink_get_neighbors(family, _dns_server_neighbors_callback, &args);
|
|
|
- if (ret < 0) {
|
|
|
- goto add_cache;
|
|
|
- }
|
|
|
+ for (int i = 0; i < 2; i++) {
|
|
|
+ ret = netlink_get_neighbors(family, _dns_server_neighbors_callback, &args);
|
|
|
+ if (ret < 0) {
|
|
|
+ goto add_cache;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (ret != 1) {
|
|
|
+ /* FIXME: ugly force refresh NDP table by sending ICMP message.*/
|
|
|
+ if (i == 0) {
|
|
|
+ char host[DNS_MAX_CNAME_LEN] = {0};
|
|
|
+ if (family == AF_INET) {
|
|
|
+ snprintf(host, sizeof(host), "%d.%d.%d.%d", netaddr[0], netaddr[1], netaddr[2], netaddr[3]);
|
|
|
+ } else if (family == AF_INET6) {
|
|
|
+ snprintf(host, sizeof(host),
|
|
|
+ "%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x", netaddr[0],
|
|
|
+ netaddr[1], netaddr[2], netaddr[3], netaddr[4], netaddr[5], netaddr[6], netaddr[7],
|
|
|
+ netaddr[8], netaddr[9], netaddr[10], netaddr[11], netaddr[12], netaddr[13], netaddr[14],
|
|
|
+ netaddr[15]);
|
|
|
+ }
|
|
|
+ struct ping_host_struct *ping_host = fast_ping_start(PING_TYPE_ICMP, host, 0, 10, 1000, NULL, NULL);
|
|
|
+ if (ping_host) {
|
|
|
+ /* wait for NDP*/
|
|
|
+ usleep(100);
|
|
|
+ fast_ping_stop(ping_host);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- if (ret != 1) {
|
|
|
- goto add_cache;
|
|
|
+ goto add_cache;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
if (args.group_mac == NULL) {
|
|
@@ -7384,7 +7407,6 @@ static int _dns_server_recv(struct dns_server_conn_head *conn, unsigned char *in
|
|
|
"%d, rcode = %d\n",
|
|
|
packet->head.qdcount, packet->head.ancount, packet->head.nscount, packet->head.nrcount, inpacket_len,
|
|
|
packet->head.id, packet->head.tc, packet->head.rd, packet->head.ra, packet->head.rcode);
|
|
|
-
|
|
|
client_rules = _dns_server_get_client_rules(from, from_len);
|
|
|
request = _dns_server_new_request();
|
|
|
if (request == NULL) {
|