[PATCH v2 3/3] Add NL_CACHE_AF_ITER support during refill and resync
roopa at cumulusnetworks.com
roopa at cumulusnetworks.com
Mon Nov 12 15:38:33 EST 2012
From: roopa <roopa at cumulusnetworks.com>
This patch adds support to iter over all supported families
during cache fill and resync.
The motivation for this was previously introduced at
http://lists.infradead.org/pipermail/libnl/2012-November/000734.html
In short, this patch allows caches to request dump on all supported
families instead of only AF_UNSPEC as done today.
With feedback from thomas this patch makes the iter over all families
conditional on per cache flag NL_CACHE_AF_ITER
---
lib/cache.c | 60 ++++++++++++++++++++++++++++++++++++++++------------------
1 files changed, 41 insertions(+), 19 deletions(-)
diff --git a/lib/cache.c b/lib/cache.c
index f21df2b..7b70324 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -779,6 +779,7 @@ int nl_cache_resync(struct nl_sock *sk, struct nl_cache *cache,
change_func_t change_cb, void *data)
{
struct nl_object *obj, *next;
+ struct nl_af_group *grp;
struct nl_cache_assoc ca = {
.ca_cache = cache,
.ca_change = change_cb,
@@ -792,19 +793,28 @@ int nl_cache_resync(struct nl_sock *sk, struct nl_cache *cache,
NL_DBG(1, "Resyncing cache %p <%s>...\n", cache, nl_cache_name(cache));
-restart:
/* Mark all objects so we can see if some of them are obsolete */
nl_cache_mark_all(cache);
- err = nl_cache_request_full_dump(sk, cache);
- if (err < 0)
- goto errout;
+ grp = cache->c_ops->co_groups;
+ do {
+ if (grp && grp->ag_group &&
+ (cache->c_flags & NL_CACHE_AF_ITER))
+ nl_cache_set_arg1(cache, grp->ag_family);
- err = __cache_pickup(sk, cache, &p);
- if (err == -NLE_DUMP_INTR)
- goto restart;
- else if (err < 0)
- goto errout;
+restart:
+ err = nl_cache_request_full_dump(sk, cache);
+ if (err < 0)
+ goto errout;
+
+ err = __cache_pickup(sk, cache, &p);
+ if (err == -NLE_DUMP_INTR)
+ goto restart;
+ else if (err < 0)
+ goto errout;
+ grp++;
+ } while (grp && grp->ag_group &&
+ (cache->c_flags & NL_CACHE_AF_ITER));
nl_list_for_each_entry_safe(obj, next, &cache->c_items, ce_list) {
if (nl_object_is_marked(obj)) {
@@ -886,23 +896,35 @@ int nl_cache_parse_and_add(struct nl_cache *cache, struct nl_msg *msg)
*/
int nl_cache_refill(struct nl_sock *sk, struct nl_cache *cache)
{
+ struct nl_af_group *grp;
int err;
+ nl_cache_clear(cache);
+ grp = cache->c_ops->co_groups;
+ do {
+ if (grp && grp->ag_group &&
+ (cache->c_flags & NL_CACHE_AF_ITER))
+ nl_cache_set_arg1(cache, grp->ag_family);
+
restart:
- err = nl_cache_request_full_dump(sk, cache);
- if (err < 0)
- return err;
+ err = nl_cache_request_full_dump(sk, cache);
+ if (err < 0)
+ return err;
+
+ err = nl_cache_pickup(sk, cache);
+ if (err == -NLE_DUMP_INTR) {
+ fprintf(stderr, "dump interrupted, restarting!\n");
+ goto restart;
+ } else if (err < 0)
+ break;
+
+ grp++;
+ } while (grp && grp->ag_group &&
+ (cache->c_flags & NL_CACHE_AF_ITER));
NL_DBG(2, "Upading cache %p <%s>, request sent, waiting for dump...\n",
cache, nl_cache_name(cache));
- nl_cache_clear(cache);
- err = nl_cache_pickup(sk, cache);
- if (err == -NLE_DUMP_INTR) {
- fprintf(stderr, "dump interrupted, restarting!\n");
- goto restart;
- }
-
return err;
}
--
1.7.2.5
More information about the libnl
mailing list