|
|
@ -372,8 +372,7 @@ class InterfaceUpdateHandler(UpdateStackHandler[IpAddressUpdate]):
|
|
|
|
self.nft_handler = nft_handler
|
|
|
|
self.nft_handler = nft_handler
|
|
|
|
self.lock = RLock()
|
|
|
|
self.lock = RLock()
|
|
|
|
self.config = config
|
|
|
|
self.config = config
|
|
|
|
self.ipv4Addrs = list[IPv4Interface]()
|
|
|
|
self.addrs = dict[IPInterface, IpAddressUpdate]()
|
|
|
|
self.ipv6Addrs = list[IPv6Interface]()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _update_stack(self, data: Sequence[IpAddressUpdate]) -> None:
|
|
|
|
def _update_stack(self, data: Sequence[IpAddressUpdate]) -> None:
|
|
|
|
nft_updates = tuple(
|
|
|
|
nft_updates = tuple(
|
|
|
@ -403,18 +402,20 @@ class InterfaceUpdateHandler(UpdateStackHandler[IpAddressUpdate]):
|
|
|
|
return # ignore (yet) tentiative addresses
|
|
|
|
return # ignore (yet) tentiative addresses
|
|
|
|
logger.debug(f"{self.config.ifname}: process change of IP {data.ip}")
|
|
|
|
logger.debug(f"{self.config.ifname}: process change of IP {data.ip}")
|
|
|
|
with self.lock:
|
|
|
|
with self.lock:
|
|
|
|
ip_list: list[IPv4Interface] | list[IPv6Interface] = (
|
|
|
|
stored = data.ip in self.addrs
|
|
|
|
self.ipv6Addrs if isinstance(data.ip, IPv6Interface) else self.ipv4Addrs
|
|
|
|
changed = stored != (not data.deleted)
|
|
|
|
)
|
|
|
|
|
|
|
|
if data.deleted != (data.ip in ip_list):
|
|
|
|
|
|
|
|
return # no change required
|
|
|
|
|
|
|
|
if data.deleted:
|
|
|
|
if data.deleted:
|
|
|
|
|
|
|
|
if not changed:
|
|
|
|
|
|
|
|
return # no updates required
|
|
|
|
logger.info(f"{self.config.ifname}: deleted IP {data.ip}")
|
|
|
|
logger.info(f"{self.config.ifname}: deleted IP {data.ip}")
|
|
|
|
ip_list.remove(data.ip) # type: ignore[arg-type]
|
|
|
|
del self.addrs[data.ip]
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
|
|
|
|
if not stored:
|
|
|
|
logger.info(f"{self.config.ifname}: discovered IP {data.ip}")
|
|
|
|
logger.info(f"{self.config.ifname}: discovered IP {data.ip}")
|
|
|
|
ip_list.append(data.ip) # type: ignore[arg-type]
|
|
|
|
self.addrs[data.ip] = data # keep entry up to date
|
|
|
|
|
|
|
|
if changed:
|
|
|
|
yield from self.__update_network_sets(data.ip, data.deleted)
|
|
|
|
yield from self.__update_network_sets(data.ip, data.deleted)
|
|
|
|
|
|
|
|
# even if "not changed", still check SLAAC rules because of lifetimes
|
|
|
|
# ignore unique link locals for SLAAC sets
|
|
|
|
# ignore unique link locals for SLAAC sets
|
|
|
|
if data.ip.version != 6 or data.ip in IPv6_ULA_NET:
|
|
|
|
if data.ip.version != 6 or data.ip in IPv6_ULA_NET:
|
|
|
|
return
|
|
|
|
return
|
|
|
|