diff options
Diffstat (limited to 'lib/route/link.c')
-rw-r--r-- | lib/route/link.c | 39 |
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 |