Hi,
this patch is a followup to my most recent bug report on the users list:

When the kernel reports the deletion of an interface (RTM_DELLINK),
the cached interface attributes, including ifindex, become invalid
and must be forgotten.

Interface link state changes ("up" and "down") show up as RTM_NEWLINK,
so they will not cause a cached entry to be removed or
prevent listening to address change notifications.

Once an interface has been deleted, the kernel ought to stop sending
notifications for it. If the interface gets recreated with the same
name later, the kernel again reports RTM_NEWLINK, which causes a new
cache entry to be created.

There should be no reason to keep a stale cache entry around, as was
claimed in the comment.

Regards,
Mirko
diff --git a/src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c b/src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c
index 2196575..198b409 100644
--- a/src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c
+++ b/src/libhydra/plugins/kernel_netlink/kernel_netlink_net.c
@@ -375,13 +375,21 @@ static void process_link(private_kernel_netlink_net_t *this,
 			{
 				if (current->ifindex == msg->ifi_index)
 				{
-					/* we do not remove it, as an address may be added to a
-					 * "down" interface and we wan't to know that. */
-					current->flags = msg->ifi_flags;
+					entry = current;
 					break;
 				}
 			}
 			enumerator->destroy(enumerator);
+			if (entry)
+			{
+				if (event)
+				{
+					update = TRUE;
+					DBG1(DBG_KNL, "interface %s deleted", entry->ifname);
+				}
+				this->ifaces->remove(this->ifaces, entry, NULL);
+				iface_entry_destroy(entry);
+			}
 			break;
 		}
 	}
_______________________________________________
Dev mailing list
[email protected]
https://lists.strongswan.org/mailman/listinfo/dev

Reply via email to