From f84f40f8698e2e6dfc1ba9713f1a91d39bf3df44 Mon Sep 17 00:00:00 2001 From: bin456789 Date: Sat, 15 Feb 2025 00:02:08 +0800 Subject: [PATCH] =?UTF-8?q?core:=20=E5=88=A4=E6=96=AD=20IPv6=20=E5=8A=A8?= =?UTF-8?q?=E9=9D=99=E6=80=81=E6=97=B6=EF=BC=8C=E5=85=88=E8=80=83=E8=99=91?= =?UTF-8?q?=E5=AE=9E=E9=99=85=E6=B5=8B=E8=AF=95=E7=BB=93=E6=9E=9C=EF=BC=8C?= =?UTF-8?q?=E5=86=8D=E8=80=83=E8=99=91=20RA=EF=BC=8C=E4=BB=8E=E8=80=8C?= =?UTF-8?q?=E5=A4=84=E7=90=86=20RA=20=E4=B9=B1=E9=85=8D=E7=9A=84=E6=83=85?= =?UTF-8?q?=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fixes #231 --- initrd-network.sh | 1 + trans.sh | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/initrd-network.sh b/initrd-network.sh index 6836278..a73fc24 100644 --- a/initrd-network.sh +++ b/initrd-network.sh @@ -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" diff --git a/trans.sh b/trans.sh index a3c823c..611e67b 100644 --- a/trans.sh +++ b/trans.sh @@ -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