lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | |
| 3 | path_sh=`nv get path_sh` |
| 4 | . $path_sh/global.sh |
| 5 | |
| 6 | #echo "Info: psext_updown_ipv6.sh $1 $2 start" >> $test_log |
| 7 | |
| 8 | c_id=$2 |
| 9 | |
| 10 | dhcp6s_conf=$path_conf/dhcp6s$c_id.conf |
| 11 | radvd_conf=$path_conf/radvd$c_id.conf |
| 12 | ndp_log=$path_conf/ndp$c_id.log |
| 13 | radvd_pidfile=$path_tmp/radvd$c_id.pid |
| 14 | |
| 15 | ps_if=`nv get pswan`$c_id |
| 16 | eth_if=`nv get "ps_ext"$c_id` |
| 17 | ps_ext_mode=`nv get need_jilian` |
| 18 | br_if="br"$c_id |
| 19 | dnsconfig=0 |
| 20 | prefix_len=64 |
| 21 | echo "Info: psext_updown_ipv6.sh $ps_ext_mode $ps_if $eth_if $br_if start" >> $test_log |
| 22 | |
| 23 | b_dhcpv6stateEnabled=`nv get dhcpv6stateEnabled` |
| 24 | b_dhcpv6statelessEnabled=`nv get dhcpv6statelessEnabled` |
| 25 | |
| 26 | #采用PDP激活方式,没有dhcp6c进程 |
| 27 | |
| 28 | #############linkup dhcpserver set############ |
| 29 | linkup_add_dns_to_dhcp6s_radvd_conf() |
| 30 | { |
| 31 | #直连模式没有手动DNS |
| 32 | ipv6_pridns_auto=`nv get $ps_if"_ipv6_pridns_auto"` |
| 33 | ipv6_secdns_auto=`nv get $ps_if"_ipv6_secdns_auto"` |
| 34 | |
| 35 | if [ -n "$ipv6_pridns_auto" ] && [ "-$ipv6_pridns_auto" != "-::" ] && [ "-$ipv6_pridns_auto" != "-::0" ];then |
| 36 | ipv6_prefer_dns=$ipv6_pridns_auto |
| 37 | fi |
| 38 | |
| 39 | if [ -n "$ipv6_secdns_auto" ] && [ "-$ipv6_secdns_auto" != "-::" ] && [ "-$ipv6_secdns_auto" != "-::0" ];then |
| 40 | ipv6_standby_dns=$ipv6_secdns_auto |
| 41 | fi |
| 42 | |
| 43 | if [ "-$ipv6_prefer_dns" == "-" -a "-$ipv6_standby_dns" == "-" ]; then |
| 44 | return |
| 45 | else |
| 46 | if [ -n "$1" ] && [ "-$1" == "-dhcp6s" ] ;then |
| 47 | echo -e "\toption dns_servers $ipv6_prefer_dns $ipv6_standby_dns;" >> $dhcp6s_conf |
| 48 | elif [ -n "$1" ] && [ "-$1" == "-radvd" ] ;then |
| 49 | # del last line |
| 50 | sed -i '$d' $radvd_conf |
| 51 | echo -e "\tRDNSS $ipv6_prefer_dns $ipv6_standby_dns\n\t{" >> $radvd_conf |
| 52 | echo -e "\t\tAdvRDNSSPreference 15;" >> $radvd_conf |
| 53 | echo -e "\t\tAdvRDNSSOpen on;" >> $radvd_conf |
| 54 | echo -e "\t};\n};" >> $radvd_conf |
| 55 | fi |
| 56 | |
| 57 | if [ "-$dnsconfig" == "-0" ]; then |
| 58 | echo "dnsconfig $1 $ipv6_prefer_dns, $ipv6_standby_dns" >> $test_log |
| 59 | if [ "-$ipv6_prefer_dns" != "-" ]; then |
| 60 | echo "nameserver $ipv6_prefer_dns" >> /etc/resolv.conf |
| 61 | fi |
| 62 | if [ "-$ipv6_standby_dns" != "-" ]; then |
| 63 | echo "nameserver $ipv6_standby_dns" >> /etc/resolv.conf |
| 64 | fi |
| 65 | dnsconfig=1 |
| 66 | fi |
| 67 | fi |
| 68 | } |
| 69 | |
| 70 | linkup_dhcpv6_set() |
| 71 | { |
| 72 | dhcpv6_start=$pdp_ip |
| 73 | dhcpv6_end=$pdp_ip |
| 74 | |
| 75 | #nv值非空则表示用户设置了静态ip、gw |
| 76 | gw=`nv get $ps_if"_ipv6_gw"` |
| 77 | |
| 78 | echo -e "interface $br_if {" > $dhcp6s_conf |
| 79 | if [ "-$b_dhcpv6stateEnabled" = "-1" ];then |
| 80 | echo -e "\tserver-preference 255;\n\trenew-time 6000;" >> $dhcp6s_conf |
| 81 | echo -e "\trebind-time 9000;\n\tprefer-life-time 1300;" >> $dhcp6s_conf |
| 82 | echo -e "\tvalid-life-time 2000;\n\tallow rapid-commit;" >> $dhcp6s_conf |
| 83 | echo -e "\tlink $br_if {\n\t\tallow unicast;\n\t\tsend unicast;" >> $dhcp6s_conf |
| 84 | echo -e "\t\tpool {\n\t\t\trange $dhcpv6_start to $dhcpv6_end/$prefix_len;" >> $dhcp6s_conf |
| 85 | echo -e "\t\t};\n\t};" >> $dhcp6s_conf |
| 86 | linkup_add_dns_to_dhcp6s_radvd_conf dhcp6s |
| 87 | echo -e "};" >> $dhcp6s_conf |
| 88 | dhcp6s -dDf -c $dhcp6s_conf $br_if & |
| 89 | else |
| 90 | #slaac with dhcp statelessset dns info |
| 91 | if [ "-$b_dhcpv6statelessEnabled" = "-1" ];then |
| 92 | echo -e "\tlink $br_if {\n\t};" >> $dhcp6s_conf |
| 93 | linkup_add_dns_to_dhcp6s_radvd_conf dhcp6s |
| 94 | echo -e "};" >> $dhcp6s_conf |
| 95 | dhcp6s -dDf -c $dhcp6s_conf $br_if & |
| 96 | if [ $? -ne 0 ];then |
| 97 | echo "Error: dhcp6s -dDf -c $dhcp6s_conf $br_if failed." >> $test_log |
| 98 | fi |
| 99 | fi |
| 100 | fi |
| 101 | } |
| 102 | |
| 103 | #获取ip并配置ps、eth |
| 104 | linkup_get_addr() |
| 105 | { |
| 106 | #disable the forwarding to send RS and not set the addr when receive ra packet |
| 107 | echo 0 > /proc/sys/net/ipv6/conf/all/forwarding |
| 108 | echo 0 > /proc/sys/net/ipv6/conf/$ps_if/accept_ra |
| 109 | echo 0 > /proc/sys/net/ipv6/conf/$eth_if/accept_ra |
| 110 | echo 0 > /proc/sys/net/ipv6/conf/$br_if/accept_ra |
| 111 | #call the slaac program to get the prefix addr |
| 112 | ifconfig $ps_if up 2>>$test_log |
| 113 | if [ $? -ne 0 ];then |
| 114 | echo "Error: ifconfig $ps_if up failed." >> $test_log |
| 115 | fi |
| 116 | prefix_info_temp=`nv get $ps_if"_ipv6_prefix_info"` |
| 117 | #如果当前没有前缀,则直接启动slaac,如果当前前缀已经设置,则说明已经获取到,直接配置IP地址即可 |
| 118 | if [ -n "$prefix_info_temp" -a "-$prefix_info_temp" != "-::" ]; then |
| 119 | ret_code=0 |
| 120 | else |
| 121 | sleep 1 |
| 122 | interface_id_temp1=`nv get $ps_if"_ipv6_interface_id"` |
| 123 | local_ipv6_addr="fe80::"$interface_id_temp1 |
| 124 | local_ipv6_addr_nv="$ps_if""_local_ipv6_addr" |
| 125 | nv set $local_ipv6_addr_nv=$local_ipv6_addr |
| 126 | ip -6 addr add $local_ipv6_addr/64 dev $ps_if 2>>$test_log |
| 127 | zte_ipv6_slaac -i "$ps_if" |
| 128 | ret_code=$? |
| 129 | fi |
| 130 | echo "Info: zte_ipv6_slaac return: $ret_code" >> $test_log |
| 131 | echo "the program zte_ipv6_slaac return = $ret_code" |
| 132 | if [ $ret_code -eq 0 ]; then |
| 133 | echo "the zte_ipv6_slaac success" |
| 134 | interface_id_temp=`nv get $ps_if"_ipv6_interface_id"` |
| 135 | prefix_info_temp=`nv get $ps_if"_ipv6_prefix_info"` |
| 136 | prefix_len=`nv get $ps_if"_ipv6_prefix_len"` |
| 137 | echo "##############1##########" |
| 138 | echo "$interface_id_temp" |
| 139 | echo "$prefix_info_temp $prefix_len" |
| 140 | echo "##############2##########" |
| 141 | |
| 142 | #pdp 激活的ipv6地址 |
| 143 | pdp_ip=$prefix_info_temp$interface_id_temp |
| 144 | #pdp激活地址,适配页面使用 |
xf.li | e08248a | 2025-05-05 22:34:52 -0700 | [diff] [blame] | 145 | nv set $ps_if"_ipv6_pdp"="$pdp_ip" |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 146 | |
| 147 | ipv6_addr_conver $pdp_ip "$ps_if" |
| 148 | |
| 149 | #给eth分配地址,使用ipv6_addr_conver在第15+1 |
| 150 | br_ip=`nv get ipv6_br0_addr` |
| 151 | brctl addbr $br_if |
| 152 | brctl setfd $br_if 0.1 |
| 153 | nv set $br_if"_ipv6_ip"=$br_ip |
xf.li | df7f8ba | 2024-09-12 23:53:34 -0700 | [diff] [blame] | 154 | if [ "$eth_if" != "zvnet"$c_id ]; then |
| 155 | ifconfig $br_if up 2>>$test_log |
| 156 | else |
| 157 | ifconfig $br_if -arp up 2>>$test_log |
| 158 | fi |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 159 | if [ $? -ne 0 ];then |
| 160 | echo "Error: ifconfig $br_if up failed." >> $test_log |
| 161 | fi |
| 162 | ip -6 addr add $br_ip/64 dev $br_if |
| 163 | #给外网口分配地址,使用ipv6_addr_conver在第15+2 |
| 164 | ps_ip=`nv get $ps_if"_dhcpv6_start"` |
| 165 | nv set $ps_if"_ipv6_ip"=$ps_ip |
| 166 | #ifconfig $ps_if $ps_ip up |
| 167 | #if [ $? -ne 0 ];then |
| 168 | # echo "Error: ifconfig $ps_ip up failed." >> $test_log |
| 169 | #fi |
| 170 | ip -6 addr add $ps_ip/126 dev $ps_if 2>>$test_log |
| 171 | if [ $? -ne 0 ];then |
| 172 | echo "Error: ip -6 addr add $ps_ip/126 dev $ps_if failed." >> $test_log |
| 173 | fi |
| 174 | nv set $ps_if"_ipv6_state"="working" |
| 175 | |
| 176 | echo "Info: zte_ipv6_slaac pdp_ip: $pdp_ip" >> $test_log |
| 177 | echo "Info: zte_ipv6_slaac ps_ip: $ps_ip" >> $test_log |
| 178 | echo "Info: zte_ipv6_slaac br_ip: $br_ip" >> $test_log |
| 179 | else |
| 180 | echo "the zte_ipv6_slaac fail" |
| 181 | nv set $ps_if"_ipv6_state"="dead" |
| 182 | exit 1 |
| 183 | fi |
| 184 | } |
| 185 | |
| 186 | #路由规则,ps与eth级联 |
| 187 | linkup_route_set() |
| 188 | { |
| 189 | echo 0 > /proc/sys/net/ipv6/conf/all/forwarding |
| 190 | |
| 191 | marknum=`expr $c_id + 60` |
| 192 | ip6tables -t mangle -A PREROUTING -i $ps_if -j MARK --set-mark $marknum |
| 193 | rt_num=`expr $c_id + 160` |
| 194 | ip -6 route add default dev $br_if table $rt_num |
| 195 | ip -6 rule add to $pdp_ip/64 fwmark $marknum table $rt_num |
| 196 | |
| 197 | marknum=`expr $c_id + 50` |
| 198 | ip6tables -t mangle -A PREROUTING -i $br_if -j MARK --set-mark $marknum |
| 199 | rt_num=`expr $c_id + 150` |
| 200 | ip -6 route add default dev $ps_if table $rt_num |
| 201 | ip -6 rule add from $pdp_ip/64 fwmark $marknum table $rt_num |
| 202 | |
| 203 | ip6tables -t filter -A FORWARD -p icmpv6 --icmpv6-type 135 -j DROP |
| 204 | |
| 205 | ip -6 route flush cache |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 206 | |
| 207 | route_info=`ip -6 route|grep default` |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 208 | |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 209 | if [ "$route_info" == "" ];then |
| 210 | #这句设完,里面可以ping通外网了 |
| 211 | echo "Info: route_set ps_ip=$ps_ip" >> $test_log |
| 212 | #ip -6 route add default via $ps_ip dev $ps_if |
| 213 | ip -6 route add default dev $ps_if 2>>$test_log |
| 214 | else |
| 215 | echo "Debug: default route6 already exist." >> $test_log |
| 216 | fi |
| 217 | |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 218 | if [ $? -ne 0 ];then |
| 219 | echo "Error: ip -6 route add default dev $ps_if failed." >> $test_log |
| 220 | fi |
| 221 | |
| 222 | #enable ipv6 packet forwarding |
| 223 | echo 1 > /proc/sys/net/ipv6/conf/all/forwarding |
| 224 | echo 1 > /proc/sys/net/ipv6/conf/$ps_if/accept_ra |
| 225 | echo 1 > /proc/sys/net/ipv6/conf/$eth_if/accept_ra |
| 226 | echo 1 > /proc/sys/net/ipv6/conf/$br_if/accept_ra |
| 227 | #enable ipv6 neigh discovery proxy |
| 228 | echo 1 > /proc/sys/net/ipv6/conf/all/proxy_ndp |
| 229 | |
| 230 | ndp_kill |
| 231 | zte_ndp -a -s $br_if -d $ps_if -l $ndp_log -p & |
| 232 | } |
| 233 | |
| 234 | #############linkup radvd set############ |
| 235 | linkup_radvd_set() |
| 236 | { |
| 237 | echo "enter linkup_radvd_set " |
| 238 | |
| 239 | rm -rf $radvd_conf |
| 240 | |
| 241 | if [ "-$b_dhcpv6stateEnabled" = "-1" ];then |
| 242 | echo -e "interface $br_if\n{\n\tAdvSendAdvert on;" > $radvd_conf |
| 243 | echo -e "\tAdvManagedFlag on;\n};" >> $radvd_conf |
| 244 | radvd_kill |
| 245 | rm -rf $radvd_pidfile |
| 246 | radvd -d 3 -C $radvd_conf -p $radvd_pidfile& |
| 247 | echo "leave linkup_radvd_set " |
| 248 | return |
| 249 | fi |
| 250 | |
| 251 | echo "Info: psext_updown_ipv6.sh br_if:$br_if, prefix_len:$prefix_len" >> $test_log |
| 252 | echo "ipv6_br0_addr_tmp:$ipv6_br0_addr_tmp" |
| 253 | echo "prefix_len:$prefix_len" |
| 254 | |
| 255 | cp $path_ro/radvd_template.conf $radvd_conf |
| 256 | |
| 257 | sed -i -e 's/#ipv6_wan_addr#\/64/#ipv6_wan_addr#\/#prefix_len#/g' $radvd_conf |
| 258 | sed -i -e s/br0/$br_if/g $radvd_conf |
| 259 | sed -i -e s/#ipv6_wan_addr#/$br_ip/g $radvd_conf |
| 260 | sed -i -e s/#prefix_len#/$prefix_len/g $radvd_conf |
| 261 | sed -i -e s/#adv_switch#/on/g $radvd_conf |
| 262 | |
| 263 | # TODO: replace br0's ipv6 address |
| 264 | #sed -i -e s/#ipv6_wan_addr#/$wan_addr/g $radvd_conf |
| 265 | #sed -i -e s/#adv_switch#/on/g $radvd_conf |
| 266 | |
| 267 | #slaac with dns info |
| 268 | if [ "-$b_dhcpv6statelessEnabled" = "-1" ];then |
| 269 | echo "use dhcpv6stateless for dns" |
| 270 | else |
| 271 | sed -i -e 's/AdvOtherConfigFlag on;/AdvOtherConfigFlag off;/g' $radvd_conf |
| 272 | linkup_add_dns_to_dhcp6s_radvd_conf radvd |
| 273 | fi |
| 274 | |
| 275 | radvd_kill |
| 276 | sleep 1 |
| 277 | rm -rf $radvd_pidfile |
| 278 | radvd -d 3 -C $radvd_conf -p $radvd_pidfile & |
| 279 | |
| 280 | echo "leave linkup_radvd_set " |
| 281 | } |
| 282 | |
| 283 | #构建网桥 |
| 284 | br_up() |
| 285 | { |
| 286 | br="br"$c_id |
| 287 | brctl addbr $br 2>>$test_log |
| 288 | if [ $? -ne 0 ];then |
| 289 | echo "Error: brctl addbr $br failed." >> $test_log |
| 290 | fi |
| 291 | brctl setfd $br 0.1 2>>$test_log |
| 292 | if [ $? -ne 0 ];then |
| 293 | echo "Error: brctl setfd $br 0.1 failed." >> $test_log |
| 294 | fi |
| 295 | ifconfig $br up 2>>$test_log |
| 296 | if [ $? -ne 0 ];then |
| 297 | echo "Error: ifconfig $br up failed." >> $test_log |
| 298 | fi |
| 299 | |
| 300 | ifconfig $ps_if up 2>>$test_log |
| 301 | if [ $? -ne 0 ];then |
| 302 | echo "Error: ifconfig $ps_if up failed." >> $test_log |
| 303 | fi |
| 304 | brctl addif $br $ps_if 2>>$test_log |
| 305 | if [ $? -ne 0 ];then |
| 306 | echo "Error: brctl addif $br $ps_if failed." >> $test_log |
| 307 | fi |
| 308 | |
| 309 | brctl addif $br $eth_if 2>>$test_log |
| 310 | if [ $? -ne 0 ];then |
| 311 | echo "Error: brctl addif $br $eth_if failed." >> $test_log |
| 312 | fi |
| 313 | ifconfig $eth_if up 2>>$test_log |
| 314 | if [ $? -ne 0 ];then |
| 315 | echo "Error: ifconfig $eth_if up failed." >> $test_log |
| 316 | fi |
| 317 | } |
| 318 | |
| 319 | #删除网桥 |
| 320 | br_down() |
| 321 | { |
| 322 | br="br"$c_id |
| 323 | brctl delif $br $eth_if 2>>$test_log |
| 324 | if [ $? -ne 0 ];then |
| 325 | echo "Error: brctl delif $br $eth_if failed." >> $test_log |
| 326 | fi |
| 327 | ifconfig $eth_if down 2>>$test_log |
| 328 | if [ $? -ne 0 ];then |
| 329 | echo "Error: ifconfig $eth_if down failed." >> $test_log |
| 330 | fi |
| 331 | brctl delif $br $ps_if 2>>$test_log |
| 332 | if [ $? -ne 0 ];then |
| 333 | echo "Error: brctl delif $br $ps_if failed." >> $test_log |
| 334 | fi |
| 335 | ifconfig $ps_if down 2>>$test_log |
| 336 | if [ $? -ne 0 ];then |
| 337 | echo "Error: ifconfig $ps_if down failed." >> $test_log |
| 338 | fi |
| 339 | ifconfig $br down 2>>$test_log |
| 340 | if [ $? -ne 0 ];then |
| 341 | echo "Error: ifconfig $br down failed." >> $test_log |
| 342 | fi |
| 343 | brctl delbr $br 2>>$test_log |
| 344 | if [ $? -ne 0 ];then |
| 345 | echo "Error: brctl delbr $br failed." >> $test_log |
| 346 | fi |
| 347 | } |
| 348 | |
| 349 | #清除相应的radvd进程 |
| 350 | linkdown_radvd_set() |
| 351 | { |
| 352 | #跟终端连接的网口直接会down,所以不用像ufi一样设置成1s有效期 |
| 353 | radvd_kill |
| 354 | } |
| 355 | |
| 356 | #清除相应的DHCPv6进程 |
| 357 | linkdown_dhcpv6_server_set() |
| 358 | { |
| 359 | dhcp6s_kill |
| 360 | } |
| 361 | |
| 362 | #删除相应的ipv6路由规则 |
| 363 | linkdown_route_set() |
| 364 | { |
| 365 | br_ip=`nv get $br_if"_ipv6_ip"` |
| 366 | ps_ip=`nv get $ps_if"_ipv6_ip"` |
xf.li | e08248a | 2025-05-05 22:34:52 -0700 | [diff] [blame] | 367 | pdp_ip=`nv get $ps_if"_ipv6_pdp"` |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 368 | |
| 369 | ip6tables -t filter -D FORWARD -p icmpv6 --icmpv6-type 135 -j DROP |
| 370 | |
| 371 | marknum=`expr $c_id + 50` |
| 372 | rt_num=`expr $c_id + 150` |
| 373 | ip -6 rule del from $pdp_ip/64 fwmark $marknum table $rt_num |
| 374 | ip6tables -t mangle -D PREROUTING -i $br_if -j MARK --set-mark $marknum |
| 375 | ip -6 route del default dev $ps_if table $rt_num |
| 376 | |
| 377 | marknum=`expr $c_id + 60` |
| 378 | rt_num=`expr $c_id + 160` |
| 379 | ip -6 rule del to $pdp_ip/64 fwmark $marknum table $rt_num |
| 380 | ip6tables -t mangle -D PREROUTING -i $ps_if -j MARK --set-mark $marknum |
| 381 | ip -6 route del default dev $br_if table $rt_num |
| 382 | |
| 383 | ip -6 addr del $br_ip/126 dev $br_if |
| 384 | #if [ $? -ne 0 ];then |
| 385 | # echo "Error: ip -6 addr del $eth_ip/126 dev $eth_if failed." >> $test_log |
| 386 | #fi |
| 387 | ip -6 addr del $ps_ip/126 dev $ps_if |
| 388 | #if [ $? -ne 0 ];then |
| 389 | # echo "Error: ip -6 addr del $ps_ip/126 dev $ps_if failed." >> $test_log |
| 390 | #fi |
xf.li | 9d1a0e1 | 2023-09-20 01:43:20 -0700 | [diff] [blame] | 391 | ip -6 route del default dev $ps_if |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 392 | #if [ $? -ne 0 ];then |
| 393 | # echo "Error: ip -6 route del default failed." >> $test_log |
| 394 | #fi |
| 395 | |
| 396 | ifconfig $br_if down 2>>$test_log |
| 397 | if [ $? -ne 0 ];then |
| 398 | echo "Error: ifconfig $br_if down failed." >> $test_log |
| 399 | fi |
| 400 | ifconfig $ps_if down 2>>$test_log |
| 401 | if [ $? -ne 0 ];then |
| 402 | echo "Error: ifconfig $ps_if down failed." >> $test_log |
| 403 | fi |
| 404 | |
| 405 | echo 0 > /proc/sys/net/ipv6/conf/$ps_if/accept_ra |
| 406 | |
| 407 | #reset nv |
| 408 | nv set $br_if"_ipv6_ip"="::" |
| 409 | nv set $ps_if"_ipv6_ip"="::" |
| 410 | nv set $ps_if"_ipv6_pridns_auto"="::" |
| 411 | nv set $ps_if"_ipv6_secdns_auto"="::" |
| 412 | nv set $ps_if"_ipv6_gw"="::" |
| 413 | nv set $ps_if"_ipv6_interface_id"="::" |
| 414 | nv set $ps_if"_ipv6_prefix_info"="::" |
| 415 | nv set $ps_if"_dhcpv6_start"="::" |
| 416 | nv set $ps_if"_dhcpv6_end"="::" |
| 417 | |
| 418 | #适配页面等其他地方使用老NV |
xf.li | e08248a | 2025-05-05 22:34:52 -0700 | [diff] [blame] | 419 | nv set $ps_if"_ipv6_pdp"="::" |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 420 | nv set $ps_if"_ipv6_state"="dead" |
| 421 | |
| 422 | local_ipv6_addr_nv="$ps_if""_local_ipv6_addr" |
| 423 | nv set $local_ipv6_addr_nv="::" |
| 424 | |
| 425 | ndp_kill |
| 426 | } |
| 427 | |
| 428 | if [ "$1" == "linkup" ]; then |
xf.li | 7ccf837 | 2024-03-07 00:08:02 -0800 | [diff] [blame] | 429 | ra_mtu_enable=`nv get ra_mtu_enable` |
| 430 | if [ "$ra_mtu_enable" != "1" ]; then |
| 431 | mtu=`nv get mtu` |
| 432 | ifconfig $ps_if mtu $mtu |
| 433 | fi |
lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 434 | if [ "-$ps_ext_mode" == "-1" ]; then |
| 435 | linkup_get_addr |
| 436 | linkup_route_set |
| 437 | linkup_dhcpv6_set |
| 438 | linkup_radvd_set |
| 439 | brctl addif $br_if $eth_if |
| 440 | ifconfig $eth_if up |
| 441 | tc_tbf.sh up $c_id |
| 442 | elif [ "-$ps_ext_mode" == "-0" ]; then |
| 443 | br_up |
| 444 | fi |
| 445 | elif [ "$1" == "linkdown" ]; then |
| 446 | if [ "-$ps_ext_mode" == "-1" ]; then |
| 447 | tc_tbf.sh down $c_id |
| 448 | linkdown_radvd_set |
| 449 | linkdown_dhcpv6_server_set |
| 450 | linkdown_route_set |
| 451 | slaac_kill |
| 452 | brctl delif $br_if $eth_if |
| 453 | ifconfig $eth_if down |
| 454 | echo "" > /etc/resolv.conf |
| 455 | elif [ "-$ps_ext_mode" == "-0" ]; then |
| 456 | br_down |
| 457 | fi |
| 458 | fi |
| 459 | |
| 460 | echo "Info: psext_updown_ipv6.sh leave" >> $test_log |