]> git.proxmox.com Git - mirror_iproute2.git/blobdiff - lib/ll_map.c
ll_map: Add function to remove link cache entry by index
[mirror_iproute2.git] / lib / ll_map.c
index 32c8e4429fca19105061b1f7d954723f0679aa77..8e8a0b1e9c9d9880bcbecccffd225fe4ebe9a1c6 100644 (file)
@@ -77,8 +77,7 @@ static struct ll_cache *ll_get_by_name(const char *name)
        return NULL;
 }
 
-int ll_remember_index(const struct sockaddr_nl *who,
-                     struct nlmsghdr *n, void *arg)
+int ll_remember_index(struct nlmsghdr *n, void *arg)
 {
        unsigned int h;
        const char *ifname;
@@ -144,7 +143,7 @@ const char *ll_idx_n2a(unsigned int idx)
        return buf;
 }
 
-unsigned int ll_idx_a2n(const char *name)
+static unsigned int ll_idx_a2n(const char *name)
 {
        unsigned int idx;
 
@@ -211,6 +210,20 @@ unsigned ll_name_to_index(const char *name)
        return idx;
 }
 
+void ll_drop_by_index(unsigned index)
+{
+       struct ll_cache *im;
+
+       im = ll_get_by_index(index);
+       if (!im)
+               return;
+
+       hlist_del(&im->idx_hash);
+       hlist_del(&im->name_hash);
+
+       free(im);
+}
+
 void ll_init_map(struct rtnl_handle *rth)
 {
        static int initialized;