mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-11-01 09:13:37 +00:00
net: Move free of dst_metrics to helper
Move the refcounting and potential free of dst metrics associated for ipv4 and ipv6 to a common helper. Signed-off-by: David Ahern <dsahern@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
e1255ed4b6
commit
1620a33695
3 changed files with 11 additions and 8 deletions
|
|
@ -441,6 +441,15 @@ void ip_dst_init_metrics(struct dst_entry *dst, struct dst_metrics *fib_metrics)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline
|
||||||
|
void ip_dst_metrics_put(struct dst_entry *dst)
|
||||||
|
{
|
||||||
|
struct dst_metrics *p = (struct dst_metrics *)DST_METRICS_PTR(dst);
|
||||||
|
|
||||||
|
if (p != &dst_default_metrics && refcount_dec_and_test(&p->refcnt))
|
||||||
|
kfree(p);
|
||||||
|
}
|
||||||
|
|
||||||
u32 ip_idents_reserve(u32 hash, int segs);
|
u32 ip_idents_reserve(u32 hash, int segs);
|
||||||
void __ip_select_ident(struct net *net, struct iphdr *iph, int segs);
|
void __ip_select_ident(struct net *net, struct iphdr *iph, int segs);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1476,12 +1476,9 @@ void rt_del_uncached_list(struct rtable *rt)
|
||||||
|
|
||||||
static void ipv4_dst_destroy(struct dst_entry *dst)
|
static void ipv4_dst_destroy(struct dst_entry *dst)
|
||||||
{
|
{
|
||||||
struct dst_metrics *p = (struct dst_metrics *)DST_METRICS_PTR(dst);
|
|
||||||
struct rtable *rt = (struct rtable *)dst;
|
struct rtable *rt = (struct rtable *)dst;
|
||||||
|
|
||||||
if (p != &dst_default_metrics && refcount_dec_and_test(&p->refcnt))
|
ip_dst_metrics_put(dst);
|
||||||
kfree(p);
|
|
||||||
|
|
||||||
rt_del_uncached_list(rt);
|
rt_del_uncached_list(rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -364,14 +364,11 @@ EXPORT_SYMBOL(ip6_dst_alloc);
|
||||||
|
|
||||||
static void ip6_dst_destroy(struct dst_entry *dst)
|
static void ip6_dst_destroy(struct dst_entry *dst)
|
||||||
{
|
{
|
||||||
struct dst_metrics *p = (struct dst_metrics *)DST_METRICS_PTR(dst);
|
|
||||||
struct rt6_info *rt = (struct rt6_info *)dst;
|
struct rt6_info *rt = (struct rt6_info *)dst;
|
||||||
struct fib6_info *from;
|
struct fib6_info *from;
|
||||||
struct inet6_dev *idev;
|
struct inet6_dev *idev;
|
||||||
|
|
||||||
if (p != &dst_default_metrics && refcount_dec_and_test(&p->refcnt))
|
ip_dst_metrics_put(dst);
|
||||||
kfree(p);
|
|
||||||
|
|
||||||
rt6_uncached_list_del(rt);
|
rt6_uncached_list_del(rt);
|
||||||
|
|
||||||
idev = rt->rt6i_idev;
|
idev = rt->rt6i_idev;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue