Commit 2809c095 authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

ipv6: addrlabel: remove refcounting

After previous patch ("ipv6: addrlabel: rework ip6addrlbl_get()")
we can remove the refcount from struct ip6addrlbl_entry,
since it is no longer elevated in p6addrlbl_get()
Signed-off-by: default avatarEric Dumazet <edumazet@google.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 66c77ff3
...@@ -18,7 +18,6 @@ ...@@ -18,7 +18,6 @@
#include <linux/if_addrlabel.h> #include <linux/if_addrlabel.h>
#include <linux/netlink.h> #include <linux/netlink.h>
#include <linux/rtnetlink.h> #include <linux/rtnetlink.h>
#include <linux/refcount.h>
#if 0 #if 0
#define ADDRLABEL(x...) printk(x) #define ADDRLABEL(x...) printk(x)
...@@ -36,7 +35,6 @@ struct ip6addrlbl_entry { ...@@ -36,7 +35,6 @@ struct ip6addrlbl_entry {
int addrtype; int addrtype;
u32 label; u32 label;
struct hlist_node list; struct hlist_node list;
refcount_t refcnt;
struct rcu_head rcu; struct rcu_head rcu;
}; };
...@@ -111,28 +109,6 @@ static const __net_initconst struct ip6addrlbl_init_table ...@@ -111,28 +109,6 @@ static const __net_initconst struct ip6addrlbl_init_table
} }
}; };
/* Object management */
static inline void ip6addrlbl_free(struct ip6addrlbl_entry *p)
{
kfree(p);
}
static void ip6addrlbl_free_rcu(struct rcu_head *h)
{
ip6addrlbl_free(container_of(h, struct ip6addrlbl_entry, rcu));
}
static bool ip6addrlbl_hold(struct ip6addrlbl_entry *p)
{
return refcount_inc_not_zero(&p->refcnt);
}
static inline void ip6addrlbl_put(struct ip6addrlbl_entry *p)
{
if (refcount_dec_and_test(&p->refcnt))
call_rcu(&p->rcu, ip6addrlbl_free_rcu);
}
/* Find label */ /* Find label */
static bool __ip6addrlbl_match(const struct ip6addrlbl_entry *p, static bool __ip6addrlbl_match(const struct ip6addrlbl_entry *p,
const struct in6_addr *addr, const struct in6_addr *addr,
...@@ -219,7 +195,6 @@ static struct ip6addrlbl_entry *ip6addrlbl_alloc(const struct in6_addr *prefix, ...@@ -219,7 +195,6 @@ static struct ip6addrlbl_entry *ip6addrlbl_alloc(const struct in6_addr *prefix,
newp->addrtype = addrtype; newp->addrtype = addrtype;
newp->label = label; newp->label = label;
INIT_HLIST_NODE(&newp->list); INIT_HLIST_NODE(&newp->list);
refcount_set(&newp->refcnt, 1);
return newp; return newp;
} }
...@@ -243,7 +218,7 @@ static int __ip6addrlbl_add(struct net *net, struct ip6addrlbl_entry *newp, ...@@ -243,7 +218,7 @@ static int __ip6addrlbl_add(struct net *net, struct ip6addrlbl_entry *newp,
goto out; goto out;
} }
hlist_replace_rcu(&p->list, &newp->list); hlist_replace_rcu(&p->list, &newp->list);
ip6addrlbl_put(p); kfree_rcu(p, rcu);
goto out; goto out;
} else if ((p->prefixlen == newp->prefixlen && !p->ifindex) || } else if ((p->prefixlen == newp->prefixlen && !p->ifindex) ||
(p->prefixlen < newp->prefixlen)) { (p->prefixlen < newp->prefixlen)) {
...@@ -281,7 +256,7 @@ static int ip6addrlbl_add(struct net *net, ...@@ -281,7 +256,7 @@ static int ip6addrlbl_add(struct net *net,
ret = __ip6addrlbl_add(net, newp, replace); ret = __ip6addrlbl_add(net, newp, replace);
spin_unlock(&net->ipv6.ip6addrlbl_table.lock); spin_unlock(&net->ipv6.ip6addrlbl_table.lock);
if (ret) if (ret)
ip6addrlbl_free(newp); kfree(newp);
return ret; return ret;
} }
...@@ -302,7 +277,7 @@ static int __ip6addrlbl_del(struct net *net, ...@@ -302,7 +277,7 @@ static int __ip6addrlbl_del(struct net *net,
p->ifindex == ifindex && p->ifindex == ifindex &&
ipv6_addr_equal(&p->prefix, prefix)) { ipv6_addr_equal(&p->prefix, prefix)) {
hlist_del_rcu(&p->list); hlist_del_rcu(&p->list);
ip6addrlbl_put(p); kfree_rcu(p, rcu);
ret = 0; ret = 0;
break; break;
} }
...@@ -360,7 +335,7 @@ static void __net_exit ip6addrlbl_net_exit(struct net *net) ...@@ -360,7 +335,7 @@ static void __net_exit ip6addrlbl_net_exit(struct net *net)
spin_lock(&net->ipv6.ip6addrlbl_table.lock); spin_lock(&net->ipv6.ip6addrlbl_table.lock);
hlist_for_each_entry_safe(p, n, &net->ipv6.ip6addrlbl_table.head, list) { hlist_for_each_entry_safe(p, n, &net->ipv6.ip6addrlbl_table.head, list) {
hlist_del_rcu(&p->list); hlist_del_rcu(&p->list);
ip6addrlbl_put(p); kfree_rcu(p, rcu);
} }
spin_unlock(&net->ipv6.ip6addrlbl_table.lock); spin_unlock(&net->ipv6.ip6addrlbl_table.lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment