diff options
author | David Ahern <dsahern@gmail.com> | 2018-10-04 23:07:53 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-10-05 00:54:19 -0400 |
commit | e1255ed4b6dafd9966c99cde5105891cc1ac70df (patch) | |
tree | a8118d6d76a79bc59220ce115663b9567365ce1a /include/net/ip.h | |
parent | cc5f0eb2164f9aa11fe631f8d905192e0233e262 (diff) |
net: common metrics init helper for dst_entry
ipv4 and ipv6 both use refcounted metrics if FIB entries have metrics set.
Move the common initialization code to a helper and use for both protocols.
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.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/net/ip.h b/include/net/ip.h index 8fdd58ce580d..f9a7125b4bda 100644 --- a/include/net/ip.h +++ b/include/net/ip.h | |||
@@ -429,6 +429,18 @@ static inline void ip_fib_metrics_put(struct dst_metrics *fib_metrics) | |||
429 | kfree(fib_metrics); | 429 | kfree(fib_metrics); |
430 | } | 430 | } |
431 | 431 | ||
432 | /* ipv4 and ipv6 both use refcounted metrics if it is not the default */ | ||
433 | static inline | ||
434 | void ip_dst_init_metrics(struct dst_entry *dst, struct dst_metrics *fib_metrics) | ||
435 | { | ||
436 | dst_init_metrics(dst, fib_metrics->metrics, true); | ||
437 | |||
438 | if (fib_metrics != &dst_default_metrics) { | ||
439 | dst->_metrics |= DST_METRICS_REFCOUNTED; | ||
440 | refcount_inc(&fib_metrics->refcnt); | ||
441 | } | ||
442 | } | ||
443 | |||
432 | u32 ip_idents_reserve(u32 hash, int segs); | 444 | u32 ip_idents_reserve(u32 hash, int segs); |
433 | void __ip_select_ident(struct net *net, struct iphdr *iph, int segs); | 445 | void __ip_select_ident(struct net *net, struct iphdr *iph, int segs); |
434 | 446 | ||