Dangling results with rtnl_route_alloc_cache(...,NL_AUTO_PROVIDE,...)

Loïc Touraine ltouraine at envivio.com
Tue Aug 21 09:17:15 EDT 2012


Hi everyone,
Can anyone tell me why I obtain dangle results using the following piece of code (i.e. the returned list of routes changes from one execution to another) ?
What does NL_AUTO_PROVIDE mean in this context ? :

if (rtnl_route_alloc_cache          (sock,AF_INET,NL_AUTO_PROVIDE,&route_cache) < 0) {
        cout<<"error allocating route cache"<<endl;    /* error */
    }
   int nbnhops = rtnl_route_get_nnexthops   ( route   ) ;
   cout<<"Route ifindex "<<rtnl_route_get_iif (route)<<" src "<<srcaddress<<" dest "<<dstaddress<<" nbnhops "<<nbnhops<<endl;
    for (unsigned long i = 0 ; i< nbnhops ; i++) {
             struct rtnl_nexthop * nhop = rtnl_route_nexthop_n (route,i);
             struct nl_addr *   gwAddr = rtnl_route_nh_get_gateway (nhop);
             nl_addr2str(gwAddr,gateway,40);
             cout<<"Rtnh ifindex "<<rtnl_route_nh_get_ifindex    (nhop) <<" gateway is "<<gateway<<endl;
    }

When I replace the NL_AUTO_PROVIDE flag with 0, the returned route list becomes stable between two executions.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/libnl/attachments/20120821/cf79856a/attachment.html>


More information about the libnl mailing list