[PATCH libnl] route: neigh: use NDA_MASTER for neigh->n_master if available

Roopa Prabhu roopa at cumulusnetworks.com
Fri Feb 10 09:42:58 PST 2017


Thomas, this is again patches from me not making the list. I am not sure what the problem is. can I request you to please re-post or forward on my behalf ?. Thank you.

On 2/9/17, 9:15 PM, Roopa Prabhu wrote:
> From: Roopa Prabhu <roopa at cumulusnetworks.com>
>
> fdb cache is per bridge and hence hashed by:
> <bridge_ifindex, family, mac>
>
> newer kernels send bridge ifindex in NDA_MASTER.
> Use NDA_MASTER for neigh->n_master when available.
>
> Also imports a few more NDA_* attributes from upstream
> to keep linux/neighbour.h NDA_* attributes in sync with
> upstream.
>
> Signed-off-by: Roopa Prabhu <roopa at cumulusnetworks.com>
> ---
>  include/linux-private/linux/neighbour.h |  4 ++++
>  lib/route/neigh.c                       | 24 ++++++++++++++----------
>  2 files changed, 18 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux-private/linux/neighbour.h b/include/linux-private/linux/neighbour.h
> index 3a6b3e8..1ec4d84 100644
> --- a/include/linux-private/linux/neighbour.h
> +++ b/include/linux-private/linux/neighbour.h
> @@ -21,6 +21,10 @@ enum {
>  	NDA_CACHEINFO,
>  	NDA_PROBES,
>  	NDA_VLAN,
> +	NDA_PORT,
> +	NDA_VNI,
> +	NDA_IFINDEX,
> +	NDA_MASTER,
>  	__NDA_MAX
>  };
>  
> diff --git a/lib/route/neigh.c b/lib/route/neigh.c
> index a00db1c..03029a5 100644
> --- a/lib/route/neigh.c
> +++ b/lib/route/neigh.c
> @@ -471,17 +471,21 @@ int rtnl_neigh_parse(struct nlmsghdr *n, struct rtnl_neigh **result)
>  	 * Get the bridge index for AF_BRIDGE family entries
>  	 */
>  	if (neigh->n_family == AF_BRIDGE) {
> -		struct nl_cache *lcache = nl_cache_mngt_require_safe("route/link");
> -		if (lcache ) {
> -			struct rtnl_link *link = rtnl_link_get(lcache,
> -							neigh->n_ifindex);
> -			if (link) {
> -				neigh->n_master = link->l_master;
> -				rtnl_link_put(link);
> -				neigh->ce_mask |= NEIGH_ATTR_MASTER;
> +		if (tb[NDA_MASTER]) {
> +			neigh->n_master = nla_get_u32(tb[NDA_MASTER]);
> +			neigh->ce_mask |= NEIGH_ATTR_MASTER;
> +		} else {
> +			struct nl_cache *lcache = nl_cache_mngt_require_safe("route/link");
> +			if (lcache ) {
> +				struct rtnl_link *link = rtnl_link_get(lcache,
> +								       neigh->n_ifindex);
> +				if (link) {
> +					neigh->n_master = link->l_master;
> +					rtnl_link_put(link);
> +					neigh->ce_mask |= NEIGH_ATTR_MASTER;
> +				}
> +				nl_cache_put(lcache);
>  			}
> -
> -			nl_cache_put(lcache);
>  		}
>  	}
>  




More information about the libnl mailing list