rtnl_route_alloc_cache lost some route messages

Thomas Graf tgraf at infradead.org
Thu Apr 19 13:10:24 EDT 2012


On Tue, Apr 17, 2012 at 09:52:25AM +0000, Hanks Wang wrote:
> Hi all,
> 
> In libnl3, I found a little problem.
> When use NL_AUTO_PROVIDE as the third parameter for rtnl_route_alloc_cache, some routing info has been lost! Then use rtnl_route_get_flags to get flags, the result of flags is right.
> Use 0 as the third parameter "int flags" for rtnl_route_alloc_cache, the routing info is correct, but then use rtnl_route_get_flags to get flags, it will always return zero.
> 
> I found that GNOME group also found this problem, but I have not found the similar bug in our bug queue. How to understand this problem?
> 
> uint32_t rtnl_route_get_flags(struct rtnl_route *route)
> {
>                 return route->rt_flags;
> }
> 
> 
> int rtnl_route_alloc_cache(struct nl_sock *sk, int family, int flags,
>                                                    struct nl_cache **result)
> {
>                 struct nl_cache *cache;
>                 int err;
> 
>                 if (!(cache = nl_cache_alloc(&rtnl_route_ops)))
>                                 return -NLE_NOMEM;
> 
>                 cache->c_iarg1 = family;
>                 cache->c_iarg2 = flags;
> 
>                 if (sk && (err = nl_cache_refill(sk, cache)) < 0) {
>                                 free(cache);
>                                 return err;
>                 }
> 
>                 *result = cache;
>                 return 0;
> }
> 
> Reference for GNOME on this libnl issue:
> http://mail.gnome.org/archives/networkmanager-list/2011-September/msg00233.html

This is definitely a bug! Is there any chance someone is abusing
your route cache while you access it?



More information about the libnl mailing list