bug in nl_cache_mngr_data_ready / nl_cache_refill / nl_cache_resync

Brett Ciphery brett.ciphery at windriver.com
Wed Apr 11 10:55:44 EDT 2012


I've been using the libnl cache facilities recently for route and have
been seeing some interesting results when explicitly repopulating the
cache.  It seems the update functions won't process all the new events
in a single invocation.

The test case:

----------------------
...

        while(1) {
                err = nl_cache_mngr_data_ready(mngr);
                printf("err: %d\n", err);
                if (err > 0) {
                        count = 0;
                        nl_cache_foreach(route_cache, route_process, NULL);
                        printf("count: %d\n", count);
                }
                sleep(5);
        }

...
----------------------

count is a global variable which is incremented in route_process.  If I
run this program and in a separate terminal do:

for i in {1..10} ; do sudo ip route add $i.$i.$i.0/24 dev br0 ; done

then the count printf is incremented by 1 each time the loop runs.. e.g.
from 4 -> 14.  Similarly it's decremented from 14 -> 4 when I delete the
routes.

Using nl_cache_refill is a little different in that count remains
constant at 4 until I add the 10 routes, and then it drops to 1 but
route_process only sees/parses every odd route 2.2.2.0/24, 4.4.4.0/24
... 10.10.0.0/24.  Then count goes to 0 for a few iterations, and then
back to 14 (as expected).

I'm going to dig into this but it looks like it could be a little hairy.
Any thoughts as to which might be the offending function would help.

Cheers.
Brett



More information about the libnl mailing list