[RFC PATCH 2/4] Add AF_BRIDGE to neigh cache
roopa at cumulusnetworks.com
roopa at cumulusnetworks.com
Mon Nov 5 08:39:37 EST 2012
From: roopa <roopa at cumulusnetworks.com>
This patch adds AF_BRIDGE to the list of families
supported by the cache. Implements oo_id_attrs_get to
declare id attributes depending on the family the
object belongs to.
Signed-off-by: Roopa Prabhu <roopa at cumulusnetworks.com>
Reviewed-by: Nolan Leake <nolan at cumulusnetworks.com>
Reviewed-by: Shrijeet Mukherjee <shm at cumulusnetworks.com>
Reviewed-by: Wilson Kok <wkok at cumulusnetworks.com>
---
lib/route/neigh.c | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/lib/route/neigh.c b/lib/route/neigh.c
index bb61571..dec71d5 100644
--- a/lib/route/neigh.c
+++ b/lib/route/neigh.c
@@ -245,6 +245,16 @@ static char *neigh_attrs2str(int attrs, char *buf, size_t len)
ARRAY_SIZE(neigh_attrs));
}
+static uint32_t neigh_id_attrs_get(struct nl_object *obj)
+{
+ struct rtnl_neigh *neigh = (struct rtnl_neigh *)obj;
+
+ if (neigh->n_family == AF_BRIDGE)
+ return (NEIGH_ATTR_LLADDR | NEIGH_ATTR_FAMILY);
+ else
+ return (NEIGH_ATTR_IFINDEX | NEIGH_ATTR_DST | NEIGH_ATTR_FAMILY);
+}
+
static struct nla_policy neigh_policy[NDA_MAX+1] = {
[NDA_CACHEINFO] = { .minlen = sizeof(struct nda_cacheinfo) },
[NDA_PROBES] = { .type = NLA_U32 },
@@ -342,7 +352,9 @@ errout:
static int neigh_request_update(struct nl_cache *c, struct nl_sock *h)
{
- return nl_rtgen_request(h, RTM_GETNEIGH, AF_UNSPEC, NLM_F_DUMP);
+ int family = c->c_iarg1;
+
+ return nl_rtgen_request(h, RTM_GETNEIGH, family, NLM_F_DUMP);
}
@@ -826,11 +838,12 @@ static struct nl_object_ops neigh_obj_ops = {
},
.oo_compare = neigh_compare,
.oo_attrs2str = neigh_attrs2str,
- .oo_id_attrs = (NEIGH_ATTR_IFINDEX | NEIGH_ATTR_DST | NEIGH_ATTR_FAMILY),
+ .oo_id_attrs_get = neigh_id_attrs_get
};
static struct nl_af_group neigh_groups[] = {
{ AF_UNSPEC, RTNLGRP_NEIGH },
+ { AF_BRIDGE, RTNLGRP_NEIGH },
{ END_OF_GROUP_LIST },
};
--
1.7.2.5
More information about the libnl
mailing list