diff options
author | Tobias Jungel <tobias.jungel@bisdn.de> | 2018-04-17 11:40:53 (GMT) |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-06-25 11:57:34 (GMT) |
commit | ee16d50a688f645758fa44fc526b157a68a240eb (patch) | |
tree | fcd4ea8d9cc5a156615b666656a02f4b49e08f61 /lib | |
parent | 40fd4113f2d6cd5edb14e77afa7250655b89fe49 (diff) | |
download | libnl-ee16d50a688f645758fa44fc526b157a68a240eb.zip libnl-ee16d50a688f645758fa44fc526b157a68a240eb.tar.gz libnl-ee16d50a688f645758fa44fc526b157a68a240eb.tar.bz2 |
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.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/lib/route/neigh.c b/lib/route/neigh.c index dc321a8..60b1d65 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; |