nft-update-addresses: InterfaceUpdateHandler: separate handling of SLAAC prefix updates & deletions

main
Felix Stupp 1 month ago
parent b04a322635
commit 84fe940a26
Signed by: zocker
GPG Key ID: 93E1BD26F6B02FB7

@ -420,7 +420,11 @@ class InterfaceUpdateHandler(UpdateStackHandler[IpAddressUpdate]):
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
# TODO track on IPv6 which are valid & so auto select for which prefix to apply rules for # TODO track on IPv6 which are valid & so auto select for which prefix to apply rules for
yield from self.__update_slaac_sets(data.ip, data.deleted) yield from (
self.__empty_slaac_sets()
if not data.deleted
else self.__update_slaac_sets(data.ip)
)
def __update_network_sets( def __update_network_sets(
self, self,
@ -454,13 +458,9 @@ class InterfaceUpdateHandler(UpdateStackHandler[IpAddressUpdate]):
values=(ip.ip.compressed,), values=(ip.ip.compressed,),
) )
def __update_slaac_sets( def __update_slaac_sets(self, ip: IPv6Interface) -> Iterable[NftUpdate]:
self, set_prefix = f"{self.config.ifname}v6"
ip: IPv6Interface, op = NftValueOperation.REPLACE
deleted: bool = False,
) -> Iterable[NftUpdate]:
set_prefix = f"{self.config.ifname}v{ip.version}"
op = NftValueOperation.if_emptied(deleted)
slaacs = {mac: slaac_eui48(ip.network, mac) for mac in self.config.macs} slaacs = {mac: slaac_eui48(ip.network, mac) for mac in self.config.macs}
for mac in self.config.macs: for mac in self.config.macs:
yield NftUpdate( yield NftUpdate(
@ -481,6 +481,24 @@ class InterfaceUpdateHandler(UpdateStackHandler[IpAddressUpdate]):
values=tuple(one_set.sub_elements(slaacs_sub)), values=tuple(one_set.sub_elements(slaacs_sub)),
) )
def __empty_slaac_sets(self) -> Iterable[NftUpdate]:
set_prefix = f"{self.config.ifname}v6"
op = NftValueOperation.EMPTY
for mac in self.config.macs:
yield NftUpdate(
obj_type="set",
obj_name=f"{set_prefix}_{mac}",
operation=op,
values=tuple(),
)
for one_set in self.config.sets:
yield NftUpdate(
obj_type=one_set.set_type,
obj_name=one_set.name,
operation=op,
values=tuple(),
)
def gen_set_definitions(self) -> str: def gen_set_definitions(self) -> str:
output = [] output = []
for ip_v in [4, 6]: for ip_v in [4, 6]:

Loading…
Cancel
Save