summaryrefslogtreecommitdiffstats
path: root/lib/route/link.c
diff options
context:
space:
mode:
authorDavid Ahern <dsa@cumulusnetworks.com>2015-10-27 22:40:48 (GMT)
committerThomas Haller <thaller@redhat.com>2015-11-19 15:48:21 (GMT)
commit18d60cb9d72f61f2070f3758bcd347bb2e3747c1 (patch)
tree56b5794a49531dc4ebaa6d1511196ba8e3b8a95d /lib/route/link.c
parent7ea15f60a726de67f02e6868a8125a59570e956d (diff)
downloadlibnl-18d60cb9d72f61f2070f3758bcd347bb2e3747c1.zip
libnl-18d60cb9d72f61f2070f3758bcd347bb2e3747c1.tar.gz
libnl-18d60cb9d72f61f2070f3758bcd347bb2e3747c1.tar.bz2
link/neigh: add flags option to link and neighbor caches
Both link and neighbor cache support specify multiple groups (nl_af_group), but the alloc_cache functions for both do not set the NL_CACHE_AF_ITER flag before populating the cache so only the first group is used by default. This patch adds an API to pass in flags to make that happen and updates the nl-neigh-list command to make use of it. http://lists.infradead.org/pipermail/libnl/2015-October/001996.html Signed-off-by: David Ahern <dsa@cumulusnetworks.com> Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'lib/route/link.c')
-rw-r--r--lib/route/link.c39
1 files changed, 37 insertions, 2 deletions
diff --git a/lib/route/link.c b/lib/route/link.c
index 5c32550..6dc416b 100644
--- a/lib/route/link.c
+++ b/lib/route/link.c
@@ -1008,6 +1008,7 @@ static char *link_attrs2str(int attrs, char *buf, size_t len)
* @arg sk Netlink socket.
* @arg family Link address family or AF_UNSPEC
* @arg result Pointer to store resulting cache.
+ * @arg flags Flags to set in link cache before filling
*
* Allocates and initializes a new link cache. If \c sk is valid, a netlink
* message is sent to the kernel requesting a full dump of all configured
@@ -1027,7 +1028,8 @@ static char *link_attrs2str(int attrs, char *buf, size_t len)
* @see rtnl_link_get_by_name()
* @return 0 on success or a negative error code.
*/
-int rtnl_link_alloc_cache(struct nl_sock *sk, int family, struct nl_cache **result)
+int rtnl_link_alloc_cache_flags(struct nl_sock *sk, int family,
+ struct nl_cache **result, unsigned int flags)
{
struct nl_cache * cache;
int err;
@@ -1037,7 +1039,10 @@ int rtnl_link_alloc_cache(struct nl_sock *sk, int family, struct nl_cache **resu
return -NLE_NOMEM;
cache->c_iarg1 = family;
-
+
+ if (flags)
+ nl_cache_set_flags(cache, flags);
+
if (sk && (err = nl_cache_refill(sk, cache)) < 0) {
nl_cache_free(cache);
return err;
@@ -1048,6 +1053,36 @@ int rtnl_link_alloc_cache(struct nl_sock *sk, int family, struct nl_cache **resu
}
/**
+ * Allocate link cache and fill in all configured links.
+ * @arg sk Netlink socket.
+ * @arg family Link address family or AF_UNSPEC
+ * @arg result Pointer to store resulting cache.
+ *
+ * Allocates and initializes a new link cache. If \c sk is valid, a netlink
+ * message is sent to the kernel requesting a full dump of all configured
+ * links. The returned messages are parsed and filled into the cache. If
+ * the operation succeeds, the resulting cache will contain a link object for
+ * each link configured in the kernel. If \c sk is NULL, returns 0 but the
+ * cache is still empty.
+ *
+ * If \c family is set to an address family other than \c AF_UNSPEC the
+ * contents of the cache can be limited to a specific address family.
+ * Currently the following address families are supported:
+ * - AF_BRIDGE
+ * - AF_INET6
+ *
+ * @route_doc{link_list, Get List of Links}
+ * @see rtnl_link_get()
+ * @see rtnl_link_get_by_name()
+ * @return 0 on success or a negative error code.
+ */
+int rtnl_link_alloc_cache(struct nl_sock *sk, int family, struct nl_cache **result)
+{
+ return rtnl_link_alloc_cache_flags(sk, family, result, 0);
+}
+
+
+/**
* Lookup link in cache by interface index
* @arg cache Link cache
* @arg ifindex Interface index