|
79 | 79 | #define CACHE_AUTO_ENABLE_SIZE (1024 * 1024 * 128)
|
80 | 80 | #define EXPIRED_DOMAIN_PREFETCH_TIME (3600 * 8)
|
81 | 81 | #define DNS_MAX_DOMAIN_REFETCH_NUM 64
|
82 |
| -#define DNS_SERVER_NEIGHBOR_CACHE_MAX_NUM 8192 |
| 82 | +#define DNS_SERVER_NEIGHBOR_CACHE_MAX_NUM (1024 * 8) |
83 | 83 | #define DNS_SERVER_NEIGHBOR_CACHE_TIMEOUT (3600 * 1)
|
84 | 84 | #define DNS_SERVER_NEIGHBOR_CACHE_NOMAC_TIMEOUT 60
|
85 | 85 |
|
@@ -3619,13 +3619,36 @@ static struct dns_client_rules *_dns_server_get_client_rules_by_mac(uint8_t *net
|
3619 | 3619 | args.netaddr = netaddr;
|
3620 | 3620 | args.netaddr_len = netaddr_len;
|
3621 | 3621 |
|
3622 |
| - ret = netlink_get_neighbors(family, _dns_server_neighbors_callback, &args); |
3623 |
| - if (ret < 0) { |
3624 |
| - goto add_cache; |
3625 |
| - } |
| 3622 | + for (int i = 0; i < 2; i++) { |
| 3623 | + ret = netlink_get_neighbors(family, _dns_server_neighbors_callback, &args); |
| 3624 | + if (ret < 0) { |
| 3625 | + goto add_cache; |
| 3626 | + } |
| 3627 | + |
| 3628 | + if (ret != 1) { |
| 3629 | + /* FIXME: ugly force refresh NDP table by sending ICMP message.*/ |
| 3630 | + if (i == 0) { |
| 3631 | + char host[DNS_MAX_CNAME_LEN] = {0}; |
| 3632 | + if (family == AF_INET) { |
| 3633 | + snprintf(host, sizeof(host), "%d.%d.%d.%d", netaddr[0], netaddr[1], netaddr[2], netaddr[3]); |
| 3634 | + } else if (family == AF_INET6) { |
| 3635 | + snprintf(host, sizeof(host), |
| 3636 | + "%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x:%.2x%.2x", netaddr[0], |
| 3637 | + netaddr[1], netaddr[2], netaddr[3], netaddr[4], netaddr[5], netaddr[6], netaddr[7], |
| 3638 | + netaddr[8], netaddr[9], netaddr[10], netaddr[11], netaddr[12], netaddr[13], netaddr[14], |
| 3639 | + netaddr[15]); |
| 3640 | + } |
| 3641 | + struct ping_host_struct *ping_host = fast_ping_start(PING_TYPE_ICMP, host, 0, 10, 1000, NULL, NULL); |
| 3642 | + if (ping_host) { |
| 3643 | + /* wait for NDP*/ |
| 3644 | + usleep(100); |
| 3645 | + fast_ping_stop(ping_host); |
| 3646 | + continue; |
| 3647 | + } |
| 3648 | + } |
3626 | 3649 |
|
3627 |
| - if (ret != 1) { |
3628 |
| - goto add_cache; |
| 3650 | + goto add_cache; |
| 3651 | + } |
3629 | 3652 | }
|
3630 | 3653 |
|
3631 | 3654 | if (args.group_mac == NULL) {
|
@@ -7384,7 +7407,6 @@ static int _dns_server_recv(struct dns_server_conn_head *conn, unsigned char *in
|
7384 | 7407 | "%d, rcode = %d\n",
|
7385 | 7408 | packet->head.qdcount, packet->head.ancount, packet->head.nscount, packet->head.nrcount, inpacket_len,
|
7386 | 7409 | packet->head.id, packet->head.tc, packet->head.rd, packet->head.ra, packet->head.rcode);
|
7387 |
| - |
7388 | 7410 | client_rules = _dns_server_get_client_rules(from, from_len);
|
7389 | 7411 | request = _dns_server_new_request();
|
7390 | 7412 | if (request == NULL) {
|
|
0 commit comments