44
55h_ENABLED=$( uci get fleth.global.enabled 2> /dev/null)
66h_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
1618fi
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
7072fi
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
0 commit comments