[PATCH 2/4] Add new rtnl_link_af_data_compare function to compare af_data

Roopa Prabhu roopa at cumulusnetworks.com
Sun Jan 13 18:09:09 EST 2013


On 1/12/13 2:45 AM, Thomas Graf wrote:
> On 01/08/13 at 05:29am, roopa at cumulusnetworks.com wrote:
>> +/**
>> + * Compare af data for a link address family
>> + * @arg a		Link object a
>> + * @arg b		Link object b
>> + * @arg family		Link address family
>> + *
>> + * This function will compare af_data between two links
>> + * a and b of family given by arg family
>> + *
>> + * @return 0 on compare success or 1 on compare failure
>> + */
>> +int rtnl_link_af_data_compare(struct rtnl_link *a, struct rtnl_link *b,
>> +			      int family, uint32_t attrs, int flags)
>> +{
>> +	struct rtnl_link_af_ops *af_ops = rtnl_link_af_ops_lookup(family);
>> +
>> +	if (!a->l_af_data[family]&&  !b->l_af_data[family])
>> +		return 0;
>> +
>> +	if (!a->l_af_data[family] || !b->l_af_data[family])
>> +		return ~0;
>> +
>> +	if (af_ops->ao_compare)
>> +		return af_ops->ao_compare(a, b, family, attrs, flags);
>> +
>> +	return 0;
>> +}
>
> Are you planning to make this function part of the public API? If so,
> please make the required change in the header file.

yes, i will submit this change.

>
> It seems it would be more sensible to depend on a->l_family after
> checking a->l_family == b->l_family instead of taking 'family'
> as attribute.

The reason i did not add this check because this api could be used for 
comparing IFLA_AF_SPEC too. In which case the IFLA_AF_SPEC family might 
not be same as l_family.

Right now link_compare only compares IFLA_PROTINFO. But it could be 
extended to compare af_data belonging to IFLA_AF_SPEC as well.

Let me know what you think.

thanks.



More information about the libnl mailing list