summaryrefslogtreecommitdiff
path: root/include/net/ip.h
diff options
context:
space:
mode:
authorDavid Ahern <dsahern@gmail.com>2018-10-04 20:07:54 -0700
committerDavid S. Miller <davem@davemloft.net>2018-10-04 21:54:25 -0700
commit1620a33695d81611360d813a47ebde9386714036 (patch)
tree31389ac748a71fdac40f2ab6f4122267df29845b /include/net/ip.h
parente1255ed4b6dafd9966c99cde5105891cc1ac70df (diff)
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>
Diffstat (limited to 'include/net/ip.h')
-rw-r--r--include/net/ip.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/net/ip.h b/include/net/ip.h
index f9a7125b4bda..72593e171d14 100644
--- a/include/net/ip.h
+++ b/include/net/ip.h
@@ -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);
void __ip_select_ident(struct net *net, struct iphdr *iph, int segs);