From patchwork Thu Feb 16 23:53:40 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rose, Gregory V" X-Patchwork-Id: 141715 X-Patchwork-Delegate: shemminger@vyatta.com Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 61809B6FB7 for ; Fri, 17 Feb 2012 10:53:41 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755340Ab2BPXxd (ORCPT ); Thu, 16 Feb 2012 18:53:33 -0500 Received: from mga01.intel.com ([192.55.52.88]:48556 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754841Ab2BPXxc (ORCPT ); Thu, 16 Feb 2012 18:53:32 -0500 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga101.fm.intel.com with ESMTP; 16 Feb 2012 15:53:32 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.71,315,1320652800"; d="scan'208";a="118443549" Received: from gitlad.jf.intel.com ([10.23.23.37]) by fmsmga001.fm.intel.com with ESMTP; 16 Feb 2012 15:53:31 -0800 Received: from gitlad.jf.intel.com (gitlad.jf.intel.com [127.0.0.1]) by gitlad.jf.intel.com (8.14.2/8.14.2) with ESMTP id q1GNrela006519; Thu, 16 Feb 2012 15:53:40 -0800 From: Greg Rose Subject: [RFC V2 PATCH] iproute2: Add netlink attribute to filter dump requests To: netdev@vger.kernel.org Cc: davem@davemloft.net, shemminger@vyatta.com Date: Thu, 16 Feb 2012 15:53:40 -0800 Message-ID: <20120216235340.6490.58652.stgit@gitlad.jf.intel.com> User-Agent: StGIT/0.14.2 MIME-Version: 1.0 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Add a new netlink attribute type to the dump request to allow filtering of the information returned for the respective matching interfaces. At this time the only filter defined is to request virtual function (VF) device info for interfaces that attached VFs. It will also be possible to extend the request with other yet to be defined netlink attributes in the future. Signed-off-by: Greg Rose --- include/linux/if_link.h | 1 + include/linux/rtnetlink.h | 5 +++-- lib/libnetlink.c | 7 +++++++ 3 files changed, 11 insertions(+), 2 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/if_link.h b/include/linux/if_link.h index d3bc04c..06a3a47 100644 --- a/include/linux/if_link.h +++ b/include/linux/if_link.h @@ -137,6 +137,7 @@ enum { IFLA_AF_SPEC, IFLA_GROUP, /* Group the device belongs to */ IFLA_NET_NS_FD, + IFLA_EXT_MASK, /* Extended info mask, VFs, etc */ __IFLA_MAX }; diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h index 12b19e6..1d30f85 100644 --- a/include/linux/rtnetlink.h +++ b/include/linux/rtnetlink.h @@ -600,8 +600,9 @@ struct tcamsg { #define TCA_ACT_TAB 1 /* attr type must be >=1 */ #define TCAA_MAX 1 -/* End of information exported to user level */ - +/* New 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/libnetlink.c b/lib/libnetlink.c index c581e11..878911e 100644 --- a/lib/libnetlink.c +++ b/lib/libnetlink.c @@ -94,6 +94,9 @@ int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type) struct { struct nlmsghdr nlh; struct rtgenmsg g; + __u16 align_rta; /* attribute has to be 32bit aligned */ + struct rtattr ext_req; + __u32 ext_filter_mask; } req; memset(&req, 0, sizeof(req)); @@ -104,6 +107,10 @@ int rtnl_wilddump_request(struct rtnl_handle *rth, int family, int type) req.nlh.nlmsg_seq = rth->dump = ++rth->seq; req.g.rtgen_family = family; + req.ext_req.rta_type = IFLA_EXT_MASK; + req.ext_req.rta_len = RTA_LENGTH(sizeof(__u32)); + req.ext_filter_mask = RTEXT_FILTER_VF; + return send(rth->fd, (void*)&req, sizeof(req), 0); }