diff --git a/utils/he_ipv6/tunnelbroker.py b/utils/he_ipv6/tunnelbroker.py index 7d0c771..716f6b2 100644 --- a/utils/he_ipv6/tunnelbroker.py +++ b/utils/he_ipv6/tunnelbroker.py @@ -145,6 +145,16 @@ class TunnelBroker(object): for assignment in self.tun.assignments: for a in assignment.iface_addrs: # The interface-specific ":1" addrs. + # Try to remove first in case it's already assigned. + try: + ipr.addr('del', + index = assignment.iface_idx, + address = a.str, + mask = a.prefix, + family = socket.AF_INET6) + logger.debug('Removed {0} with prefix {1} from {2}.'.format(a.str, a.prefixlen, assignment.iface)) + except Exception as e: + pass try: ipr.addr('add', index = assignment.iface_idx, @@ -159,13 +169,14 @@ class TunnelBroker(object): raise e # The SLAAC prefixes. for b in assignment.iface_blocks: + # Try to remove first in case it's already assigned. try: ipr.addr('del', index = assignment.iface_idx, - address = b.str, + address = str(b), mask = b.prefixlen, family = socket.AF_INET6) - logger.debug('Removed {0} with prefix {1} from {2}.'.format(b.str, b.prefixlen, assignment.iface)) + logger.debug('Removed {0} with prefix {1} from {2}.'.format(str(b), b.prefixlen, assignment.iface)) except Exception as e: pass try: