ok just ran that command in that piece of code by hand
ifconfig gif0 inet6gif0: flags=8051<UP,POINTOPOINT,RUNNING,MULTICAST> metric 0 mtu 1480
tunnel inet 24.13.xxx.xxx --> 209.51.181.2
inet6 2001:470:xxxx:b85::2
--> 2001:470:xxxx:b85::1 prefixlen 128
inet6 fe80::209:5bff:fee2:ccdb%gif0 prefixlen 64 scopeid 0x8
And I see the
--> so from the way I read the code it sets it to 126, even though you can see the prefixlen is clearly 128

Im fairly sure could just remove this line
$parts[5] = "126";
And it would show the correct mask, wouldn't it??