netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: Add support for fill_slave_info to VRF device
@ 2016-02-02 15:43 David Ahern
  2016-02-02 15:43 ` [iproute2 net-next] vrf: Add support for slave_info David Ahern
  2016-02-07 19:03 ` [PATCH net-next] net: Add support for fill_slave_info to VRF device David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: David Ahern @ 2016-02-02 15:43 UTC (permalink / raw)
  To: netdev; +Cc: David Ahern

Allows userspace to have direct access to VRF table association
versus looking up master device and its table.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
 drivers/net/vrf.c            | 21 +++++++++++++++++++++
 include/uapi/linux/if_link.h |  8 ++++++++
 2 files changed, 29 insertions(+)

diff --git a/drivers/net/vrf.c b/drivers/net/vrf.c
index 66addb7a7911..76e1fc9d8748 100644
--- a/drivers/net/vrf.c
+++ b/drivers/net/vrf.c
@@ -877,6 +877,24 @@ static int vrf_fillinfo(struct sk_buff *skb,
 	return nla_put_u32(skb, IFLA_VRF_TABLE, vrf->tb_id);
 }
 
+static size_t vrf_get_slave_size(const struct net_device *bond_dev,
+				 const struct net_device *slave_dev)
+{
+	return nla_total_size(sizeof(u32));  /* IFLA_VRF_PORT_TABLE */
+}
+
+static int vrf_fill_slave_info(struct sk_buff *skb,
+			       const struct net_device *vrf_dev,
+			       const struct net_device *slave_dev)
+{
+	struct net_vrf *vrf = netdev_priv(vrf_dev);
+
+	if (nla_put_u32(skb, IFLA_VRF_PORT_TABLE, vrf->tb_id))
+		return -EMSGSIZE;
+
+	return 0;
+}
+
 static const struct nla_policy vrf_nl_policy[IFLA_VRF_MAX + 1] = {
 	[IFLA_VRF_TABLE] = { .type = NLA_U32 },
 };
@@ -890,6 +908,9 @@ static struct rtnl_link_ops vrf_link_ops __read_mostly = {
 	.validate	= vrf_validate,
 	.fill_info	= vrf_fillinfo,
 
+	.get_slave_size  = vrf_get_slave_size,
+	.fill_slave_info = vrf_fill_slave_info,
+
 	.newlink	= vrf_newlink,
 	.dellink	= vrf_dellink,
 	.setup		= vrf_setup,
diff --git a/include/uapi/linux/if_link.h b/include/uapi/linux/if_link.h
index a30b78090594..0a5dc5647cdb 100644
--- a/include/uapi/linux/if_link.h
+++ b/include/uapi/linux/if_link.h
@@ -401,6 +401,14 @@ enum {
 
 #define IFLA_VRF_MAX (__IFLA_VRF_MAX - 1)
 
+enum {
+	IFLA_VRF_PORT_UNSPEC,
+	IFLA_VRF_PORT_TABLE,
+	__IFLA_VRF_PORT_MAX
+};
+
+#define IFLA_VRF_PORT_MAX (__IFLA_VRF_PORT_MAX - 1)
+
 /* IPVLAN section */
 enum {
 	IFLA_IPVLAN_UNSPEC,
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [iproute2 net-next] vrf: Add support for slave_info
  2016-02-02 15:43 [PATCH net-next] net: Add support for fill_slave_info to VRF device David Ahern
@ 2016-02-02 15:43 ` David Ahern
  2016-02-18  1:54   ` Stephen Hemminger
  2016-02-07 19:03 ` [PATCH net-next] net: Add support for fill_slave_info to VRF device David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: David Ahern @ 2016-02-02 15:43 UTC (permalink / raw)
  To: netdev; +Cc: David Ahern

Print VRF slave_info attributes if present.

Signed-off-by: David Ahern <dsa@cumulusnetworks.com>
---
Requires IFLA_VRF_PORT_* from linux/if_link.h

 ip/iplink_vrf.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/ip/iplink_vrf.c b/ip/iplink_vrf.c
index 9b4b7728cf6f..abc796886a5f 100644
--- a/ip/iplink_vrf.c
+++ b/ip/iplink_vrf.c
@@ -64,6 +64,18 @@ static void vrf_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 		fprintf(f, "table %u ", rta_getattr_u32(tb[IFLA_VRF_TABLE]));
 }
 
+static void vrf_slave_print_opt(struct link_util *lu, FILE *f,
+				struct rtattr *tb[])
+{
+	if (!tb)
+		return;
+
+	if (tb[IFLA_VRF_PORT_TABLE]) {
+		fprintf(f, "table %u ",
+			rta_getattr_u32(tb[IFLA_VRF_PORT_TABLE]));
+	}
+}
+
 static void vrf_print_help(struct link_util *lu, int argc, char **argv,
 			      FILE *f)
 {
@@ -77,3 +89,10 @@ struct link_util vrf_link_util = {
 	.print_opt	= vrf_print_opt,
 	.print_help	= vrf_print_help,
 };
+
+struct link_util vrf_slave_link_util = {
+        .id             = "vrf",
+        .maxattr        = IFLA_VRF_PORT_MAX,
+	.print_opt	= vrf_slave_print_opt,
+        .slave          = true,
+};
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net-next] net: Add support for fill_slave_info to VRF device
  2016-02-02 15:43 [PATCH net-next] net: Add support for fill_slave_info to VRF device David Ahern
  2016-02-02 15:43 ` [iproute2 net-next] vrf: Add support for slave_info David Ahern
@ 2016-02-07 19:03 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2016-02-07 19:03 UTC (permalink / raw)
  To: dsa; +Cc: netdev

From: David Ahern <dsa@cumulusnetworks.com>
Date: Tue,  2 Feb 2016 07:43:45 -0800

> Allows userspace to have direct access to VRF table association
> versus looking up master device and its table.
> 
> Signed-off-by: David Ahern <dsa@cumulusnetworks.com>

Applied, thanks David.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [iproute2 net-next] vrf: Add support for slave_info
  2016-02-02 15:43 ` [iproute2 net-next] vrf: Add support for slave_info David Ahern
@ 2016-02-18  1:54   ` Stephen Hemminger
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Hemminger @ 2016-02-18  1:54 UTC (permalink / raw)
  To: David Ahern; +Cc: netdev

On Tue,  2 Feb 2016 07:43:46 -0800
David Ahern <dsa@cumulusnetworks.com> wrote:

> Print VRF slave_info attributes if present.
> 
> Signed-off-by: David Ahern <dsa@cumulusnetworks.com>

Applied to net-next

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-02-18  1:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-02 15:43 [PATCH net-next] net: Add support for fill_slave_info to VRF device David Ahern
2016-02-02 15:43 ` [iproute2 net-next] vrf: Add support for slave_info David Ahern
2016-02-18  1:54   ` Stephen Hemminger
2016-02-07 19:03 ` [PATCH net-next] net: Add support for fill_slave_info to VRF device David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).