When IPv6 address is added to an interface there are actually two RTM_NEWADDR netlink messages sent. The second message is sent when DAD is complete and tentative flag is removed.
For the second message associated with the same address we have to check if the flags have changed and update them in the Device instance to be in sync.
Signed-off-by: Jan Tluka jtluka@redhat.com --- lnst/Devices/Device.py | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/lnst/Devices/Device.py b/lnst/Devices/Device.py index e69a297f..112a9276 100644 --- a/lnst/Devices/Device.py +++ b/lnst/Devices/Device.py @@ -210,6 +210,13 @@ class Device(object, metaclass=DeviceMeta):
if addr not in self._ip_addrs: self._ip_addrs.append(addr) + else: + old_idx = self._ip_addrs.index(addr) + addr_old = self._ip_addrs[old_idx] + if addr.flags != addr_old.flags: + self._ip_addrs.pop(old_idx) + self._ip_addrs.append(addr) + elif nl_msg['header']['type'] == RTM_DELADDR: addr = ipaddress(nl_msg.get_attr('IFA_ADDRESS')) addr.prefixlen = nl_msg["prefixlen"]
On Fri, Feb 28, 2020 at 08:47:26PM +0100, Jan Tluka wrote:
When IPv6 address is added to an interface there are actually two RTM_NEWADDR netlink messages sent. The second message is sent when DAD is complete and tentative flag is removed.
For the second message associated with the same address we have to check if the flags have changed and update them in the Device instance to be in sync.
Signed-off-by: Jan Tluka jtluka@redhat.com
lnst/Devices/Device.py | 7 +++++++ 1 file changed, 7 insertions(+)
diff --git a/lnst/Devices/Device.py b/lnst/Devices/Device.py index e69a297f..112a9276 100644 --- a/lnst/Devices/Device.py +++ b/lnst/Devices/Device.py @@ -210,6 +210,13 @@ class Device(object, metaclass=DeviceMeta):
if addr not in self._ip_addrs: self._ip_addrs.append(addr)
else:
old_idx = self._ip_addrs.index(addr)
addr_old = self._ip_addrs[old_idx]
if addr.flags != addr_old.flags:
self._ip_addrs.pop(old_idx)
self._ip_addrs.append(addr)
elif nl_msg['header']['type'] == RTM_DELADDR: addr = ipaddress(nl_msg.get_attr('IFA_ADDRESS')) addr.prefixlen = nl_msg["prefixlen"]
-- 2.21.1 _______________________________________________ LNST-developers mailing list -- lnst-developers@lists.fedorahosted.org To unsubscribe send an email to lnst-developers-leave@lists.fedorahosted.org Fedora Code of Conduct: https://docs.fedoraproject.org/en-US/project/code-of-conduct/ List Guidelines: https://fedoraproject.org/wiki/Mailing_list_guidelines List Archives: https://lists.fedorahosted.org/archives/list/lnst-developers@lists.fedorahos...
ack, applying and pushing.
Thanks, -Ondrej
lnst-developers@lists.fedorahosted.org