[PATCH 1/3] Add support for per cache flags

Roopa Prabhu roopa at cumulusnetworks.com
Mon Nov 12 09:15:11 EST 2012


On 11/12/12 1:40 AM, Thomas Graf wrote:
> On 11/11/12 at 05:08pm, roopa at cumulusnetworks.com wrote:
>> From: roopa<roopa at cumulusnetworks.com>
>>
>> This patch adds support for per cache flags
>> and adds a flag NL_CACHE_AF_ITER to iter over all
>> supported families when filling the cache.
>
>> @@ -246,6 +254,16 @@ struct nl_cache_ops
>>   	int   (*co_include_event)(struct nl_cache *cache, struct nl_object *obj,
>>   				  change_func_t change_cb, void *data);
>>
>> +	/**
>> +	 * Called to set cache flags
>> +	 */
>> +	int   (*co_set_flags)(struct nl_cache *, unsigned int flags);
>> +
>> +	/**
>> +	 * Called to get cache flags
>> +	 */
>> +	unsigned int    (*co_get_flags)(struct nl_cache *);
>> +
>
> What are you intending to use these for?

Initially i was thinking of making the api reset the flags, so had a get 
and a set. After that i left it in there for symmetry.
I can remove it since there is no use for it today.

>
>
>> @@ -566,6 +566,36 @@ void nl_cache_set_arg2(struct nl_cache *cache, int arg)
>>   }
>>
>>   /**
>> + * Set cache flags
>> + * @arg cache		Cache
>> + * @arg arg		flags
>> + *
>> + */
>> +void nl_cache_set_flags(struct nl_cache *cache, unsigned int flags)
>> +{
>> +	if (cache->c_ops->co_set_flags) {
>> +		cache->c_ops->co_set_flags(cache, flags);
>> +		return;
>> +	}
>> +
>> +	cache->c_ops->co_flags |= flags;
>> +}
>
> Storing the flag in the cache ops is OK but it should only be used as
> the default for the per cache object flags.
>
> We want to allow having two link cache objects, one having ITER
> enabled while the other link cache doesn't.
>
> I think we need:
>
> Use Case 1: (Change default setting of a cache type)
>          struct nl_cache_ops *ops;
>          struct nl_cache *link_cache;
>
> 	ops  = nl_cache_ops_lookup("route/link");
>          nl_cache_ops_set_flags(ops, NL_CACHE_AF_ITER)
>          link_cache = rtnl_link_alloc_cache([...]);

ok did not have this use case in mind.ie, changing cache ops directly.

>
> Use Case 2: (Change setting of an individual cache)
>          struct nl_cache *link_cache;
>
>          link_cache = rtnl_link_alloc_cache([...]);
Am guessing you meant nl_alloc_cache here
> 	nl_cache_set_flags(link_cache, NL_CACHE_AFTER_ITER);

And NL_CACHE_AF_ITER here
> 	nl_cache_mngr_add_cache([...], link_cache);
>
> i.e. add a new c_flags to struct nl_cache and inherit its value
> from ops->co_flags and always use cache->c_flags when checking
> whether the feature is enabled.

ok I will respin. Just so i am clear,

void nl_cache_ops_set_flags(struct nl_cache_ops *ops, unsigned int flags)
{
         ops->co_flags |= flags	
}


void nl_cache_set_flags(struct nl_cache *cache, unsigned int flags)
{

         cache->c_flags |= flags;
}

And in alloc cache cache->c_flags |= ops->co_flags
plus use cache->c_flags in fill and resync


thanks.

>
> _______________________________________________
> libnl mailing list
> libnl at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/libnl




More information about the libnl mailing list