From 51dadf421e280c946bb7a7d9f66d92e4fc691e38 Mon Sep 17 00:00:00 2001 From: brent s Date: Fri, 15 May 2020 03:20:04 -0400 Subject: [PATCH] ditto --- utils/he_ipv6/tunnelbroker.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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: