]> git.proxmox.com Git - mirror_iproute2.git/commitdiff
ll_map: Add function to remove link cache entry by index
authorDavid Ahern <dsahern@gmail.com>
Mon, 7 Jan 2019 22:29:15 +0000 (14:29 -0800)
committerDavid Ahern <dsahern@gmail.com>
Sat, 23 Feb 2019 02:51:15 +0000 (18:51 -0800)
Add ll_drop_by_index to remove an entry from the link cache.

Signed-off-by: David Ahern <dsahern@gmail.com>
include/ll_map.h
lib/ll_map.c

index 511fe00b8567603fe5ae985e1b79ae078928d5aa..4de1041e2746271485e90ae9f1f33691982b77da 100644 (file)
@@ -9,6 +9,7 @@ unsigned ll_name_to_index(const char *name);
 const char *ll_index_to_name(unsigned idx);
 int ll_index_to_type(unsigned idx);
 int ll_index_to_flags(unsigned idx);
+void ll_drop_by_index(unsigned index);
 unsigned namehash(const char *str);
 
 const char *ll_idx_n2a(unsigned int idx);
index 1ab8ef0758ac566072bea9882a0baa379ae5c2d0..8e8a0b1e9c9d9880bcbecccffd225fe4ebe9a1c6 100644 (file)
@@ -210,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;