diff mbox

[net-next,v3,16/17] bridge: add brport flags to dflt bridge_getlink

Message ID 1416911328-10979-17-git-send-email-jiri@resnulli.us
State Changes Requested, archived
Delegated to: David Miller
Headers show

Commit Message

Jiri Pirko Nov. 25, 2014, 10:28 a.m. UTC
From: Scott Feldman <sfeldma@gmail.com>

To allow brport device to return current brport flags set on port.  Add
returned flags to nested IFLA_PROTINFO netlink msg built in dflt getlink.
With this change, netlink msg returned for bridge_getlink contains the port's
offloaded flag settings (the port's SELF settings).

Signed-off-by: Scott Feldman <sfeldma@gmail.com>
Signed-off-by: Jiri Pirko <jiri@resnulli.us>
---
new in v3
---
 drivers/net/ethernet/emulex/benet/be_main.c   |  3 ++-
 drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |  2 +-
 include/linux/rtnetlink.h                     |  3 ++-
 net/core/rtnetlink.c                          | 39 ++++++++++++++++++++++++++-
 4 files changed, 43 insertions(+), 4 deletions(-)

Comments

Jamal Hadi Salim Nov. 25, 2014, 4:08 p.m. UTC | #1
On 11/25/14 05:28, Jiri Pirko wrote:
> From: Scott Feldman <sfeldma@gmail.com>
>
> To allow brport device to return current brport flags set on port.  Add
> returned flags to nested IFLA_PROTINFO netlink msg built in dflt getlink.
> With this change, netlink msg returned for bridge_getlink contains the port's
> offloaded flag settings (the port's SELF settings).
>
> Signed-off-by: Scott Feldman <sfeldma@gmail.com>
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>

Not sure i followed this. VEPA etc are offload modes, no?
I like the harvesting from netlink->internal format but
not sure i followed the rest: VEPA etc are offload modes, no?

cheers,
jamal
--
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
Scott Feldman Nov. 25, 2014, 5:02 p.m. UTC | #2
On Tue, Nov 25, 2014 at 8:08 AM, Jamal Hadi Salim <jhs@mojatatu.com> wrote:
> On 11/25/14 05:28, Jiri Pirko wrote:
>>
>> From: Scott Feldman <sfeldma@gmail.com>
>>
>> To allow brport device to return current brport flags set on port.  Add
>> returned flags to nested IFLA_PROTINFO netlink msg built in dflt getlink.
>> With this change, netlink msg returned for bridge_getlink contains the
>> port's
>> offloaded flag settings (the port's SELF settings).
>>
>> Signed-off-by: Scott Feldman <sfeldma@gmail.com>
>> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>
>
> Not sure i followed this. VEPA etc are offload modes, no?
> I like the harvesting from netlink->internal format but
> not sure i followed the rest: VEPA etc are offload modes, no?

VEPA etc are offload modes.

> cheers,
> jamal
--
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
Andy Gospodarek Nov. 25, 2014, 5:48 p.m. UTC | #3
On Tue, Nov 25, 2014 at 11:28:47AM +0100, Jiri Pirko wrote:
> From: Scott Feldman <sfeldma@gmail.com>
> 
> To allow brport device to return current brport flags set on port.  Add
> returned flags to nested IFLA_PROTINFO netlink msg built in dflt getlink.
> With this change, netlink msg returned for bridge_getlink contains the port's
> offloaded flag settings (the port's SELF settings).
> 
> Signed-off-by: Scott Feldman <sfeldma@gmail.com>
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>

Seems fine.

Acked-by: Andy Gospodarek <gospo@cumulusnetworks.com>

> ---
> new in v3
> ---
>  drivers/net/ethernet/emulex/benet/be_main.c   |  3 ++-
>  drivers/net/ethernet/intel/ixgbe/ixgbe_main.c |  2 +-
>  include/linux/rtnetlink.h                     |  3 ++-
>  net/core/rtnetlink.c                          | 39 ++++++++++++++++++++++++++-
>  4 files changed, 43 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
> index 9070b98..6510ec8 100644
> --- a/drivers/net/ethernet/emulex/benet/be_main.c
> +++ b/drivers/net/ethernet/emulex/benet/be_main.c
> @@ -4362,7 +4362,8 @@ static int be_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
>  
>  	return ndo_dflt_bridge_getlink(skb, pid, seq, dev,
>  				       hsw_mode == PORT_FWD_TYPE_VEPA ?
> -				       BRIDGE_MODE_VEPA : BRIDGE_MODE_VEB);
> +				       BRIDGE_MODE_VEPA : BRIDGE_MODE_VEB,
> +				       0, 0);
>  }
>  
>  #ifdef CONFIG_BE2NET_VXLAN
> diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> index 1bad9f4..eb2a04b 100644
> --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
> @@ -7773,7 +7773,7 @@ static int ixgbe_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
>  	else
>  		mode = BRIDGE_MODE_VEPA;
>  
> -	return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode);
> +	return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode, 0, 0);
>  }
>  
>  static void *ixgbe_fwd_add(struct net_device *pdev, struct net_device *vdev)
> diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
> index 063f0f5..3b04190 100644
> --- a/include/linux/rtnetlink.h
> +++ b/include/linux/rtnetlink.h
> @@ -103,5 +103,6 @@ extern int ndo_dflt_fdb_del(struct ndmsg *ndm,
>  			    u16 vid);
>  
>  extern int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
> -				   struct net_device *dev, u16 mode);
> +				   struct net_device *dev, u16 mode,
> +				   u32 flags, u32 mask);
>  #endif	/* __LINUX_RTNETLINK_H */
> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index bd5e783..91e5368 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -2687,12 +2687,22 @@ static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
>  	return skb->len;
>  }
>  
> +static int brport_nla_put_flag(struct sk_buff *skb, u32 flags, u32 mask,
> +			       unsigned int attrnum, unsigned int flag)
> +{
> +	if (mask & flag)
> +		return nla_put_u8(skb, attrnum, !!(flags & flag));
> +	return 0;
> +}
> +
>  int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
> -			    struct net_device *dev, u16 mode)
> +			    struct net_device *dev, u16 mode,
> +			    u32 flags, u32 mask)
>  {
>  	struct nlmsghdr *nlh;
>  	struct ifinfomsg *ifm;
>  	struct nlattr *br_afspec;
> +	struct nlattr *protinfo;
>  	u8 operstate = netif_running(dev) ? dev->operstate : IF_OPER_DOWN;
>  	struct net_device *br_dev = netdev_master_upper_dev_get(dev);
>  
> @@ -2731,6 +2741,33 @@ int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
>  	}
>  	nla_nest_end(skb, br_afspec);
>  
> +	protinfo = nla_nest_start(skb, IFLA_PROTINFO | NLA_F_NESTED);
> +	if (!protinfo)
> +		goto nla_put_failure;
> +
> +	if (brport_nla_put_flag(skb, flags, mask,
> +				IFLA_BRPORT_MODE, BR_HAIRPIN_MODE) ||
> +	    brport_nla_put_flag(skb, flags, mask,
> +				IFLA_BRPORT_GUARD, BR_BPDU_GUARD) ||
> +	    brport_nla_put_flag(skb, flags, mask,
> +				IFLA_BRPORT_FAST_LEAVE,
> +				BR_MULTICAST_FAST_LEAVE) ||
> +	    brport_nla_put_flag(skb, flags, mask,
> +				IFLA_BRPORT_PROTECT, BR_ROOT_BLOCK) ||
> +	    brport_nla_put_flag(skb, flags, mask,
> +				IFLA_BRPORT_LEARNING, BR_LEARNING) ||
> +	    brport_nla_put_flag(skb, flags, mask,
> +				IFLA_BRPORT_LEARNING_SYNC, BR_LEARNING_SYNC) ||
> +	    brport_nla_put_flag(skb, flags, mask,
> +				IFLA_BRPORT_UNICAST_FLOOD, BR_FLOOD) ||
> +	    brport_nla_put_flag(skb, flags, mask,
> +				IFLA_BRPORT_PROXYARP, BR_PROXYARP)) {
> +		nla_nest_cancel(skb, protinfo);
> +		goto nla_put_failure;
> +	}
> +
> +	nla_nest_end(skb, protinfo);
> +
>  	return nlmsg_end(skb, nlh);
>  nla_put_failure:
>  	nlmsg_cancel(skb, nlh);
> -- 
> 1.9.3
> 
--
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
Thomas Graf Nov. 25, 2014, 10:07 p.m. UTC | #4
On 11/25/14 at 11:28am, Jiri Pirko wrote:
> From: Scott Feldman <sfeldma@gmail.com>
> 
> To allow brport device to return current brport flags set on port.  Add
> returned flags to nested IFLA_PROTINFO netlink msg built in dflt getlink.
> With this change, netlink msg returned for bridge_getlink contains the port's
> offloaded flag settings (the port's SELF settings).
> 
> Signed-off-by: Scott Feldman <sfeldma@gmail.com>
> Signed-off-by: Jiri Pirko <jiri@resnulli.us>

Minor nit below. Otherwise:

Acked-by: Thomas Graf <tgraf@suug.ch>

> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
> index bd5e783..91e5368 100644
> --- a/net/core/rtnetlink.c
> +++ b/net/core/rtnetlink.c
> @@ -2687,12 +2687,22 @@ static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
>  	return skb->len;
>  }
>  
> +static int brport_nla_put_flag(struct sk_buff *skb, u32 flags, u32 mask,
> +			       unsigned int attrnum, unsigned int flag)
> +{
> +	if (mask & flag)
> +		return nla_put_u8(skb, attrnum, !!(flags & flag));

nla_put_flag()?

--
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
Jiri Pirko Nov. 26, 2014, 9:25 a.m. UTC | #5
Tue, Nov 25, 2014 at 11:07:53PM CET, tgraf@suug.ch wrote:
>On 11/25/14 at 11:28am, Jiri Pirko wrote:
>> From: Scott Feldman <sfeldma@gmail.com>
>> 
>> To allow brport device to return current brport flags set on port.  Add
>> returned flags to nested IFLA_PROTINFO netlink msg built in dflt getlink.
>> With this change, netlink msg returned for bridge_getlink contains the port's
>> offloaded flag settings (the port's SELF settings).
>> 
>> Signed-off-by: Scott Feldman <sfeldma@gmail.com>
>> Signed-off-by: Jiri Pirko <jiri@resnulli.us>
>
>Minor nit below. Otherwise:
>
>Acked-by: Thomas Graf <tgraf@suug.ch>
>
>> diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
>> index bd5e783..91e5368 100644
>> --- a/net/core/rtnetlink.c
>> +++ b/net/core/rtnetlink.c
>> @@ -2687,12 +2687,22 @@ static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
>>  	return skb->len;
>>  }
>>  
>> +static int brport_nla_put_flag(struct sk_buff *skb, u32 flags, u32 mask,
>> +			       unsigned int attrnum, unsigned int flag)
>> +{
>> +	if (mask & flag)
>> +		return nla_put_u8(skb, attrnum, !!(flags & flag));
>
>nla_put_flag()?

No, that is not the same. nla_put_flag works differently. The attr is
either present or not. But in this case, attr is always present and has
value of either 0 or 1.

>
--
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
Thomas Graf Nov. 26, 2014, 10:48 a.m. UTC | #6
On 11/26/14 at 10:25am, Jiri Pirko wrote:
> Tue, Nov 25, 2014 at 11:07:53PM CET, tgraf@suug.ch wrote:
> >> +static int brport_nla_put_flag(struct sk_buff *skb, u32 flags, u32 mask,
> >> +			       unsigned int attrnum, unsigned int flag)
> >> +{
> >> +	if (mask & flag)
> >> +		return nla_put_u8(skb, attrnum, !!(flags & flag));
> >
> >nla_put_flag()?
> 
> No, that is not the same. nla_put_flag works differently. The attr is
> either present or not. But in this case, attr is always present and has
> value of either 0 or 1.

So this reports the driver capabilities through this interface as
well.  Cool. Wasn't obvious to me before but that justifies the waste.
--
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 mbox

Patch

diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 9070b98..6510ec8 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -4362,7 +4362,8 @@  static int be_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
 
 	return ndo_dflt_bridge_getlink(skb, pid, seq, dev,
 				       hsw_mode == PORT_FWD_TYPE_VEPA ?
-				       BRIDGE_MODE_VEPA : BRIDGE_MODE_VEB);
+				       BRIDGE_MODE_VEPA : BRIDGE_MODE_VEB,
+				       0, 0);
 }
 
 #ifdef CONFIG_BE2NET_VXLAN
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 1bad9f4..eb2a04b 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -7773,7 +7773,7 @@  static int ixgbe_ndo_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
 	else
 		mode = BRIDGE_MODE_VEPA;
 
-	return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode);
+	return ndo_dflt_bridge_getlink(skb, pid, seq, dev, mode, 0, 0);
 }
 
 static void *ixgbe_fwd_add(struct net_device *pdev, struct net_device *vdev)
diff --git a/include/linux/rtnetlink.h b/include/linux/rtnetlink.h
index 063f0f5..3b04190 100644
--- a/include/linux/rtnetlink.h
+++ b/include/linux/rtnetlink.h
@@ -103,5 +103,6 @@  extern int ndo_dflt_fdb_del(struct ndmsg *ndm,
 			    u16 vid);
 
 extern int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
-				   struct net_device *dev, u16 mode);
+				   struct net_device *dev, u16 mode,
+				   u32 flags, u32 mask);
 #endif	/* __LINUX_RTNETLINK_H */
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index bd5e783..91e5368 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2687,12 +2687,22 @@  static int rtnl_fdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
 	return skb->len;
 }
 
+static int brport_nla_put_flag(struct sk_buff *skb, u32 flags, u32 mask,
+			       unsigned int attrnum, unsigned int flag)
+{
+	if (mask & flag)
+		return nla_put_u8(skb, attrnum, !!(flags & flag));
+	return 0;
+}
+
 int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
-			    struct net_device *dev, u16 mode)
+			    struct net_device *dev, u16 mode,
+			    u32 flags, u32 mask)
 {
 	struct nlmsghdr *nlh;
 	struct ifinfomsg *ifm;
 	struct nlattr *br_afspec;
+	struct nlattr *protinfo;
 	u8 operstate = netif_running(dev) ? dev->operstate : IF_OPER_DOWN;
 	struct net_device *br_dev = netdev_master_upper_dev_get(dev);
 
@@ -2731,6 +2741,33 @@  int ndo_dflt_bridge_getlink(struct sk_buff *skb, u32 pid, u32 seq,
 	}
 	nla_nest_end(skb, br_afspec);
 
+	protinfo = nla_nest_start(skb, IFLA_PROTINFO | NLA_F_NESTED);
+	if (!protinfo)
+		goto nla_put_failure;
+
+	if (brport_nla_put_flag(skb, flags, mask,
+				IFLA_BRPORT_MODE, BR_HAIRPIN_MODE) ||
+	    brport_nla_put_flag(skb, flags, mask,
+				IFLA_BRPORT_GUARD, BR_BPDU_GUARD) ||
+	    brport_nla_put_flag(skb, flags, mask,
+				IFLA_BRPORT_FAST_LEAVE,
+				BR_MULTICAST_FAST_LEAVE) ||
+	    brport_nla_put_flag(skb, flags, mask,
+				IFLA_BRPORT_PROTECT, BR_ROOT_BLOCK) ||
+	    brport_nla_put_flag(skb, flags, mask,
+				IFLA_BRPORT_LEARNING, BR_LEARNING) ||
+	    brport_nla_put_flag(skb, flags, mask,
+				IFLA_BRPORT_LEARNING_SYNC, BR_LEARNING_SYNC) ||
+	    brport_nla_put_flag(skb, flags, mask,
+				IFLA_BRPORT_UNICAST_FLOOD, BR_FLOOD) ||
+	    brport_nla_put_flag(skb, flags, mask,
+				IFLA_BRPORT_PROXYARP, BR_PROXYARP)) {
+		nla_nest_cancel(skb, protinfo);
+		goto nla_put_failure;
+	}
+
+	nla_nest_end(skb, protinfo);
+
 	return nlmsg_end(skb, nlh);
 nla_put_failure:
 	nlmsg_cancel(skb, nlh);