summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTobias Jungel <tobias.jungel@bisdn.de>2018-04-17 13:40:53 +0200
committerThomas Haller <thaller@redhat.com>2018-06-25 13:57:34 +0200
commitee16d50a688f645758fa44fc526b157a68a240eb (patch)
treefcd4ea8d9cc5a156615b666656a02f4b49e08f61 /lib
parent40fd4113f2d6cd5edb14e77afa7250655b89fe49 (diff)
downloadlibnl-ee16d50a688f645758fa44fc526b157a68a240eb.tar.gz
neigh: cache updates as well query AF_BRIDGE neigh
This commit adds the query for AF_BRIDGE neighbours. A cache refresh now includes these objects as well. The result of `./src/nl-neigh-list --family=bridge` includes now as well the same entries you would retrieve from the kernel by calling `bridge fdb show`.
Diffstat (limited to 'lib')
-rw-r--r--lib/route/neigh.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/route/neigh.c b/lib/route/neigh.c
index dc321a8f..60b1d659 100644
--- a/lib/route/neigh.c
+++ b/lib/route/neigh.c
@@ -456,7 +456,31 @@ static int neigh_request_update(struct nl_cache *c, struct nl_sock *h)
{
int family = c->c_iarg1;
- return nl_rtgen_request(h, RTM_GETNEIGH, family, NLM_F_DUMP);
+ if (family == AF_UNSPEC) {
+ return nl_rtgen_request(h, RTM_GETNEIGH, family, NLM_F_DUMP);
+ } else if (family == AF_BRIDGE) {
+ struct ifinfomsg hdr = {.ifi_family = family};
+ struct nl_msg *msg;
+ int err;
+
+ msg = nlmsg_alloc_simple(RTM_GETNEIGH, NLM_F_REQUEST | NLM_F_DUMP);
+ if (!msg)
+ return -NLE_NOMEM;
+
+ err = -NLE_MSGSIZE;
+ if (nlmsg_append(msg, &hdr, sizeof(hdr), NLMSG_ALIGNTO) < 0)
+ goto nla_put_failure;
+
+ err = nl_send_auto(h, msg);
+ if (err > 0)
+ err = 0;
+
+ nla_put_failure:
+ nlmsg_free(msg);
+ return err;
+ }
+
+ return -NLE_INVAL;
}
@@ -610,6 +634,7 @@ struct rtnl_neigh * rtnl_neigh_get(struct nl_cache *cache, int ifindex,
nl_list_for_each_entry(neigh, &cache->c_items, ce_list) {
if (neigh->n_ifindex == ifindex &&
+ neigh->n_family == dst->a_family &&
!nl_addr_cmp(neigh->n_dst, dst)) {
nl_object_get((struct nl_object *) neigh);
return neigh;