Skip to content

会在A 记录返回后马上 force IPv4 preferred,导致dualstack-ip-selection-threshold 设置无效 #2419

Description

@wy315700

问题现象
典型过程:

上游正常返回 IPv4和IPv6地址,然后向两个地址发起了Ping。
IPv4 ICMP 以 131.5 ms 先返回。
此时 IPv6 回调尚未处理,显示 time1: -1,SmartDNS 立即执行 force IPv4 preferred。
仅晚 0.9 ms,ICMPv6 以 132.4 ms 成功返回,但 SOA 已经发给客户端,无法补发 AAAA。
这种情况下,dualstack-ip-selection-threshold设置是无效的。因为IPV6的time是-1

if (dualstack_dns_cache && (dualstack_dns_cache->info.speed > 0)) {
			if ((dualstack_dns_cache->info.speed + (request->conf->dns_dualstack_ip_selection_threshold * 10)) <
					dns_cache->info.speed ||
				dns_cache->info.speed < 0) {
				tlog(TLOG_DEBUG, "cache result: %s, qtype: %d, force %s preferred, id: %d, time1: %d, time2: %d",
					 request->domain, request->qtype, request->qtype == DNS_T_AAAA ? "IPv4" : "IPv6", request->id,
					 dns_cache->info.speed, dualstack_dns_cache->info.speed);
				request->ip_ttl = _dns_server_get_expired_ttl_reply(request, dualstack_dns_cache);
				ret = _dns_server_reply_SOA(DNS_RC_NOERROR, request);
				goto out_update_cache;
			}
		}

这个地方判断的时候info.speed是-1

运行环境

  1. 固件型号
    1.2026.v48.1.0
  2. 运营商
    上海移动
  3. smartdns来源以及版本
    pikuzheng/smartdns:1.2026.v48.1.0
  4. 涉及的配置(注意去除个人相关信息)
bind [::]:53

cache-size 0

# enable persist cache when restart
cache-persist yes

# cache persist file
cache-file /etc/smartdns/smartdns.cache


serve-expired yes

serve-expired-ttl 259200

serve-expired-reply-ttl 3

prefetch-domain yes
serve-expired-prefetch-time 21600

cache-checkpoint-time 3600

#speed-check-mode none

force-qtype-SOA 65

dualstack-ip-selection yes
dualstack-ip-selection-threshold 15

rr-ttl-min 300
rr-ttl-max 86400
#rr-ttl-reply-max 120
local-ttl 60
#max-reply-ip-num 2

log-level debug
log-file /etc/smartdns/smartdns.log
log-size 128k
log-num 2

#response-mode fastest-response

ip-set -name china_ip -file /etc/smartdns/china_ip_list.txt
ip-rules ip-set:china_ip -whitelist-ip

whitelist-ip 127.0.0.0/8
whitelist-ip 10.0.0.0/8
whitelist-ip 172.16.0.0/12
whitelist-ip 192.168.0.0/16
whitelist-ip 198.18.0.0/15
whitelist-ip 100.64.0.0/10
whitelist-ip 224.0.0.0/4
whitelist-ip ::1/128
whitelist-ip fc00::/7
whitelist-ip fe80::/10
whitelist-ip ff00::/8
whitelist-ip 2e00:1234:5678:1::/64

whitelist-ip 17.0.0.0/8

server-quic 223.6.6.6 -whitelist-ip
server-quic 2400:3200::1 -whitelist-ip

server 192.168.9.200:5553 -fallback

plugin /usr/lib/libsmartdns_ui.so
smartdns-ui.www-root /wwwroot
smartdns-ui.ip http://0.0.0.0:6080
data-dir /etc/smartdns
smartdns-ui.max-query-log-age 86400

重现步骤

  1. 上游DNS配置。

  2. 访问的域名。
    含个人信息,隐藏了

信息收集

  1. 将/var/log/smrtdns.log日志作为附件上传(注意去除个人相关信息)。
  2. 如进程异常,请将coredump功能开启,上传coredump信息文件,同时上传配套的smartdns进程文件。
    在自定义界面,开启设置->自定义设置->生成coredump配置,重现问题后提交coredump文件
    coredump文件在/tmp目录下

smartdns.log

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions