[PATCH] link: Support RTEXT_FILTER_VF
Jef Oliver
jef.oliver at intel.com
Wed May 11 15:01:27 PDT 2016
Extend rtnl_link_build_get_request() and link_request_update()
to provide IFLA_EXT_MASK with RTEXT_FILTER_VF.
Define RTEXT_FILTER_VF
This enables rtnl_link_get_num_vf to properly return the number
of VFs defined for a link.
Signed-off-by: Jef Oliver <jef.oliver at intel.com>
---
include/linux-private/linux/rtnetlink.h | 3 +++
lib/route/link.c | 26 ++++++++++++++++++++++++--
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/include/linux-private/linux/rtnetlink.h b/include/linux-private/linux/rtnetlink.h
index 2363c18..1e0425e 100644
--- a/include/linux-private/linux/rtnetlink.h
+++ b/include/linux-private/linux/rtnetlink.h
@@ -600,6 +600,9 @@ struct tcamsg {
#define TCA_ACT_TAB 1 /* attr type must be >=1 */
#define TCAA_MAX 1
+/* Extended info filters for IFLA_EXT_MASK */
+#define RTEXT_FILTER_VF (1 << 0)
+
/* End of information exported to user level */
#endif /* __LINUX_RTNETLINK_H */
diff --git a/lib/route/link.c b/lib/route/link.c
index 0b3238f..6cce85e 100644
--- a/lib/route/link.c
+++ b/lib/route/link.c
@@ -640,9 +640,29 @@ errout:
static int link_request_update(struct nl_cache *cache, struct nl_sock *sk)
{
- int family = cache->c_iarg1;
+ struct ifinfomsg ifi;
+ struct nl_msg *msg;
+ int err = 0;
+
+ memset(&ifi, 0, sizeof(ifi));
+
+ if (!(msg = nlmsg_alloc_simple(RTM_GETLINK, NLM_F_DUMP)))
+ return -NLE_NOMEM;
+
+ ifi.ifi_family = cache->c_iarg1;
+
+ if (nlmsg_append(msg, &ifi, sizeof(ifi), NLMSG_ALIGNTO < 0)) {
+ err = -NLE_MSGSIZE;
+ goto nla_put_failure;
+ }
+
+ NLA_PUT_U32(msg, IFLA_EXT_MASK, RTEXT_FILTER_VF);
+
+ nl_send_auto(sk, msg);
- return nl_rtgen_request(sk, RTM_GETLINK, family, NLM_F_DUMP);
+nla_put_failure:
+ nlmsg_free(msg);
+ return err;
}
static void link_dump_line(struct nl_object *obj, struct nl_dump_params *p)
@@ -1139,6 +1159,8 @@ int rtnl_link_build_get_request(int ifindex, const char *name,
if (name)
NLA_PUT_STRING(msg, IFLA_IFNAME, name);
+ NLA_PUT_U32(msg, IFLA_EXT_MASK, RTEXT_FILTER_VF);
+
*result = msg;
return 0;
--
2.8.2
More information about the libnl
mailing list