]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net: Handle null dst in rtnl_put_cacheinfo
authorDavid Ahern <dsahern@gmail.com>
Wed, 18 Apr 2018 00:33:08 +0000 (17:33 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 18 Apr 2018 03:41:15 +0000 (23:41 -0400)
Need to keep expires time for IPv6 routes in a dump of FIB entries.
Update rtnl_put_cacheinfo to allow dst to be NULL in which case
rta_cacheinfo will only contain non-dst data.

Signed-off-by: David Ahern <dsahern@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/rtnetlink.c

index 45936922d7e231acaad4dc06ebf445b5c1149b20..80802546c279722fe7a110704a4b006e15aa35ec 100644 (file)
@@ -785,13 +785,15 @@ int rtnl_put_cacheinfo(struct sk_buff *skb, struct dst_entry *dst, u32 id,
                       long expires, u32 error)
 {
        struct rta_cacheinfo ci = {
-               .rta_lastuse = jiffies_delta_to_clock_t(jiffies - dst->lastuse),
-               .rta_used = dst->__use,
-               .rta_clntref = atomic_read(&(dst->__refcnt)),
                .rta_error = error,
                .rta_id =  id,
        };
 
+       if (dst) {
+               ci.rta_lastuse = jiffies_delta_to_clock_t(jiffies - dst->lastuse);
+               ci.rta_used = dst->__use;
+               ci.rta_clntref = atomic_read(&dst->__refcnt);
+       }
        if (expires) {
                unsigned long clock;