diff options
author | Thomas Graf <tgraf@suug.ch> | 2012-11-16 01:11:55 +0100 |
---|---|---|
committer | Thomas Graf <tgraf@suug.ch> | 2012-11-16 01:11:55 +0100 |
commit | 00132b46968fff7975eb8d20a307c626dfefe2f1 (patch) | |
tree | e2d6ea3d7535358435ea136019e03c35c22c19ba /lib/route/nexthop.c | |
parent | 23c4ef67c735813fd41f66f6722b996d1ad7314a (diff) | |
download | libnl-00132b46968fff7975eb8d20a307c626dfefe2f1.tar.gz |
cache: provide safe variant of nl_cache_mngt_require() and use it
This makes runtime removal of cache operations possible if non-safe
API is not in use by application. The non-safe API will be removed
in the next major version.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Diffstat (limited to 'lib/route/nexthop.c')
-rw-r--r-- | lib/route/nexthop.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/route/nexthop.c b/lib/route/nexthop.c index 189bccd..9990c51 100644 --- a/lib/route/nexthop.c +++ b/lib/route/nexthop.c @@ -109,7 +109,7 @@ static void nh_dump_line(struct rtnl_nexthop *nh, struct nl_dump_params *dp) struct nl_cache *link_cache; char buf[128]; - link_cache = nl_cache_mngt_require("route/link"); + link_cache = nl_cache_mngt_require_safe("route/link"); nl_dump(dp, "via"); @@ -128,6 +128,9 @@ static void nh_dump_line(struct rtnl_nexthop *nh, struct nl_dump_params *dp) } nl_dump(dp, " "); + + if (link_cache) + nl_cache_put(link_cache); } static void nh_dump_details(struct rtnl_nexthop *nh, struct nl_dump_params *dp) @@ -135,7 +138,7 @@ static void nh_dump_details(struct rtnl_nexthop *nh, struct nl_dump_params *dp) struct nl_cache *link_cache; char buf[128]; - link_cache = nl_cache_mngt_require("route/link"); + link_cache = nl_cache_mngt_require_safe("route/link"); nl_dump(dp, "nexthop"); @@ -164,6 +167,9 @@ static void nh_dump_details(struct rtnl_nexthop *nh, struct nl_dump_params *dp) if (nh->ce_mask & NH_ATTR_FLAGS) nl_dump(dp, " <%s>", rtnl_route_nh_flags2str(nh->rtnh_flags, buf, sizeof(buf))); + + if (link_cache) + nl_cache_put(link_cache); } void rtnl_route_nh_dump(struct rtnl_nexthop *nh, struct nl_dump_params *dp) |