core: 判断 IPv6 动静态时,先考虑实际测试结果,再考虑 RA,从而处理 RA 乱配的情况

fixes #231
This commit is contained in:
bin456789 2025-02-15 00:02:08 +08:00
parent 275e1812dd
commit f84f40f869
No known key found for this signature in database
GPG Key ID: EE301B386DE6C11B
2 changed files with 11 additions and 2 deletions

View File

@ -442,6 +442,7 @@ fi
netconf="/dev/netconf/$ethx"
mkdir -p "$netconf"
$dhcpv4 && echo 1 >"$netconf/dhcpv4" || echo 0 >"$netconf/dhcpv4"
$dhcpv6_or_slaac && echo 1 >"$netconf/dhcpv6_or_slaac" || echo 0 >"$netconf/dhcpv6_or_slaac"
$should_disable_ra_slaac && echo 1 >"$netconf/should_disable_ra_slaac" || echo 0 >"$netconf/should_disable_ra_slaac"
$is_in_china && echo 1 >"$netconf/is_in_china" || echo 0 >"$netconf/is_in_china"
echo "$ethx" >"$netconf/ethx"

View File

@ -612,6 +612,12 @@ is_staticv6() {
return 1
}
is_dhcpv6_or_slaac() {
get_netconf_to dhcpv6_or_slaac
# shellcheck disable=SC2154
[ "$dhcpv6_or_slaac" = 1 ]
}
should_disable_ra_slaac() {
get_netconf_to should_disable_ra_slaac
# shellcheck disable=SC2154
@ -619,8 +625,9 @@ should_disable_ra_slaac() {
}
is_slaac() {
# 如果是静态(包括自动获取到 IP 但无法联网而切换成静态)直接返回 1不考虑 ra
# 防止部分机器slaac/dhcpv6获取的ip/网关无法上网
if should_disable_ra_slaac; then
if ! is_dhcpv6_or_slaac; then
return 1
fi
get_netconf_to slaac
@ -629,8 +636,9 @@ is_slaac() {
}
is_dhcpv6() {
# 如果是静态(包括自动获取到 IP 但无法联网而切换成静态)直接返回 1不考虑 ra
# 防止部分机器slaac/dhcpv6获取的ip/网关无法上网
if should_disable_ra_slaac; then
if ! is_dhcpv6_or_slaac; then
return 1
fi
get_netconf_to dhcpv6