Skip to content

Commit d48f697

Browse files
committed
Add 'prefer_slaac' and 'tunnel_activation'
1 parent 9f14f79 commit d48f697

File tree

7 files changed

+101
-3
lines changed

7 files changed

+101
-3
lines changed

htdocs/luci-static/resources/view/fleth.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,26 @@ return view.extend({
280280
o.nocreate = true;
281281
o.default = "wan";
282282

283+
o = s.taboption(
284+
"general",
285+
form.Flag,
286+
"prefer_slaac",
287+
_("Prefer SLAAC Address"),
288+
_("Router outbound connections will prefer SLAAC addresses over MAP-E/ipip6h static addresses")
289+
);
290+
o.rmempty = false;
291+
o.default = "1";
292+
293+
o = s.taboption(
294+
"general",
295+
form.Flag,
296+
"tunnel_activation",
297+
_("Auto Activate Tunnel"),
298+
_("Automatically send ping to activate tunnel. Without traffic, some tunnels may fail to establish connection properly.")
299+
);
300+
o.rmempty = false;
301+
o.default = "1";
302+
283303
// LAN IPv6 Configuration section in Tools tab
284304
o = s.taboption("tools", form.DummyValue, "_lan_ipv6_recommendation");
285305
o.title = _("LAN IPv6 Configuration");

po/ja/fleth.po

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,15 @@ msgstr "ですが、MAP-E/IPIP6 を正常に動作させるには \"00\" で終
212212

213213
msgid "Please check your upstream router's prefix delegation settings."
214214
msgstr "上位ルーターのプレフィックス委譲設定を確認してください。"
215+
216+
msgid "Prefer SLAAC Address"
217+
msgstr "SLAAC アドレス優先"
218+
219+
msgid "Router outbound connections will prefer SLAAC addresses over MAP-E/ipip6h static addresses"
220+
msgstr "ルーターの送信接続は MAP-E/ipip6h 静的アドレスより SLAAC アドレスを優先します"
221+
222+
msgid "Auto Activate Tunnel"
223+
msgstr "トンネル自動有効化"
224+
225+
msgid "Automatically send ping to activate tunnel. Without traffic, some tunnels may fail to establish connection properly."
226+
msgstr "トンネルを有効化するために自動的に Ping を送信します。トラフィックがない場合、一部のトンネルは正常に接続を確立できない場合があります。"

po/zh_Hans/fleth.po

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,15 @@ msgstr ",但必须以 \"00\" 结尾才能使 MAP-E/IPIP6 正常工作。"
212212

213213
msgid "Please check your upstream router's prefix delegation settings."
214214
msgstr "请检查上游路由器的前缀委派设置。"
215+
216+
msgid "Prefer SLAAC Address"
217+
msgstr "优先 SLAAC 地址"
218+
219+
msgid "Router outbound connections will prefer SLAAC addresses over MAP-E/ipip6h static addresses"
220+
msgstr "路由器出站连接将优先使用 SLAAC 地址而非 MAP-E/ipip6h 静态地址"
221+
222+
msgid "Auto Activate Tunnel"
223+
msgstr "自动激活隧道"
224+
225+
msgid "Automatically send ping to activate tunnel. Without traffic, some tunnels may fail to establish connection properly."
226+
msgstr "自动发送 ping 以激活隧道。如果没有流量,某些隧道可能无法正常建立连接。"

po/zh_Hant/fleth.po

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,15 @@ msgstr ",但必須以 \"00\" 結尾才能使 MAP-E/IPIP6 正常運作。"
212212

213213
msgid "Please check your upstream router's prefix delegation settings."
214214
msgstr "請檢查上游路由器的前綴委派設定。"
215+
216+
msgid "Prefer SLAAC Address"
217+
msgstr "優先 SLAAC 地址"
218+
219+
msgid "Router outbound connections will prefer SLAAC addresses over MAP-E/ipip6h static addresses"
220+
msgstr "路由器出站連線將優先使用 SLAAC 地址而非 MAP-E/ipip6h 靜態地址"
221+
222+
msgid "Auto Activate Tunnel"
223+
msgstr "自動啟動隧道"
224+
225+
msgid "Automatically send ping to activate tunnel. Without traffic, some tunnels may fail to establish connection properly."
226+
msgstr "自動傳送 ping 以啟動隧道。如果沒有流量,某些隧道可能無法正常建立連線。"

root/etc/hotplug.d/iface/70-fleth

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
h_ENABLED=$(uci get fleth.global.enabled 2>/dev/null)
66
h_UPLINK_INTERFACE=$(uci get fleth.global.interface6 2>/dev/null)
7+
h_PREFER_SLAAC=$(uci get fleth.global.prefer_slaac 2>/dev/null)
8+
h_TUNNEL_ACTIVATION=$(uci get fleth.global.tunnel_activation 2>/dev/null)
79

810
# Exit if fleth is not enabled or interface is not configured
911
[ "$h_ENABLED" != "1" ] && exit 0
@@ -16,7 +18,7 @@ if [ "$INTERFACE" = "$h_UPLINK_INTERFACE" ] && [ "$ACTION" = "ifup" ]; then
1618
fi
1719

1820
# Connectivity test for tunnel interfaces
19-
if [ "$ACTION" = "ifup" ]; then
21+
if [ "$h_TUNNEL_ACTIVATION" = "1" ] && [ "$ACTION" = "ifup" ]; then
2022
# Get interface protocol type
2123
proto=$(uci get network.${INTERFACE}.proto 2>/dev/null)
2224

@@ -68,3 +70,22 @@ if [ "$ACTION" = "ifup" ]; then
6870
;;
6971
esac
7072
fi
73+
74+
# Deprecate static /128 addresses to prioritize SLAAC
75+
# This ensures SLAAC addresses are preferred over manually configured addresses
76+
if [ "$h_PREFER_SLAAC" = "1" ] && { [ "$ACTION" = "ifup" ] || [ "$ACTION" = "ifupdate" ]; }; then
77+
device=$(ifstatus ${INTERFACE} 2>/dev/null | jsonfilter -e '@.device' 2>/dev/null)
78+
[ -z "$device" ] && device=$(ifstatus ${INTERFACE} 2>/dev/null | jsonfilter -e '@.l3_device' 2>/dev/null)
79+
if [ -n "$device" ]; then
80+
ip -6 addr show dev "$device" scope global 2>/dev/null | grep "inet6" | while read -r line; do
81+
addr=$(echo "$line" | awk '{print $2}')
82+
if echo "$addr" | grep -q "/128$"; then
83+
if ! echo "$line" | grep -q "dynamic"; then
84+
clean_addr=$(echo "$addr" | cut -d'/' -f1)
85+
ip -6 addr change "$clean_addr"/128 dev "$device" preferred_lft 0
86+
logger -t fleth-hotplug "Deprecated static /128 address $clean_addr on $device (interface: $INTERFACE)"
87+
fi
88+
fi
89+
done
90+
fi
91+
fi

root/etc/uci-defaults/luci-app-fleth

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,23 @@ config fleth 'global'
1010
option interface_zone 'wan'
1111
option interface6 'wan6'
1212
option mtu '1460'
13+
option prefer_slaac '1'
14+
option tunnel_activation '1'
1315
EOF
14-
fi
15-
if [ -f /etc/config/fleth ]; then
16+
else
1617
sed -i '/option ip6prefix_enabled/d' /etc/config/fleth
1718
sed -i '/option cron_dhcpv6_renew_enabled/d' /etc/config/fleth
1819
sed -i '/option type/d' /etc/config/fleth
20+
# Add prefer_slaac option if not exists
21+
if ! grep -q "option prefer_slaac" /etc/config/fleth; then
22+
uci set fleth.global.prefer_slaac='1'
23+
uci commit fleth
24+
fi
25+
# Add tunnel_activation option if not exists
26+
if ! grep -q "option tunnel_activation" /etc/config/fleth; then
27+
uci set fleth.global.tunnel_activation='1'
28+
uci commit fleth
29+
fi
1930
fi
2031
fleth hook_none.js
2132
exit 0

root/lib/netifd/proto/ipip6h.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,16 @@ proto_ipip6h_setup() {
179179
json_close_array
180180
json_close_object
181181
ubus call network add_dynamic "$(json_dump)"
182+
183+
# Deprecate static address if prefer_slaac is enabled
184+
local prefer_slaac=$(uci get fleth.global.prefer_slaac 2>/dev/null)
185+
if [ "$prefer_slaac" = "1" ]; then
186+
local parent_device=$(ifstatus ${parent_iface} 2>/dev/null | jsonfilter -e '@.device' 2>/dev/null)
187+
if [ -n "$parent_device" ]; then
188+
ip -6 addr change "${ip6addr}"/128 dev "$parent_device" preferred_lft 0 2>/dev/null
189+
logger -t ipip6h "[${cfg}] Deprecated static address ${ip6addr} to prefer SLAAC"
190+
fi
191+
fi
182192
fi
183193

184194
logger -t ipip6h "[${cfg}] Setup completed"

0 commit comments

Comments
 (0)