]> granicus.if.org Git - libnl/commitdiff
route: neigh: use NDA_MASTER for neigh->n_master if available
authorRoopa Prabhu <roopa@cumulusnetworks.com>
Fri, 10 Feb 2017 05:15:26 +0000 (21:15 -0800)
committerThomas Haller <thaller@redhat.com>
Mon, 27 Feb 2017 13:15:15 +0000 (14:15 +0100)
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@cumulusnetworks.com>
include/linux-private/linux/neighbour.h
lib/route/neigh.c

index 969f352c66263f1537157cc51bb7c47e4aa2c901..641392ed47ca7a59ce492dbe30e50da58438acc2 100644 (file)
@@ -21,6 +21,10 @@ enum {
        NDA_CACHEINFO,
        NDA_PROBES,
        NDA_VLAN,
+       NDA_PORT,
+       NDA_VNI,
+       NDA_IFINDEX,
+       NDA_MASTER,
        __NDA_MAX
 };
 
index c8979ab8b6af101de915187ac0a9d6e8c3cf96c5..966f45d4aeaf79f3236ebbd8c8bc77ee5d7c4f5a 100644 (file)
@@ -422,17 +422,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);
                }
        }