diff mbox series

[1/2,net-next] net_failover: fix net_failover_compute_features()

Message ID 20180531120124.pc4txiifxnrslbei@kili.mountain
State Changes Requested, archived
Delegated to: David Miller
Headers show
Series [1/2,net-next] net_failover: fix net_failover_compute_features() | expand

Commit Message

Dan Carpenter May 31, 2018, 12:01 p.m. UTC
This has an '&' vs '|' typo so it starts with vlan_features set to none.
Also a u32 type isn't large enough to hold all the feature bits, it
should be netdev_features_t.

Fixes: cfc80d9a1163 ("net: Introduce net_failover driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Comments

Samudrala, Sridhar May 31, 2018, 5:30 p.m. UTC | #1
On 5/31/2018 5:01 AM, Dan Carpenter wrote:
> This has an '&' vs '|' typo so it starts with vlan_features set to none.
> Also a u32 type isn't large enough to hold all the feature bits, it
> should be netdev_features_t.
>
> Fixes: cfc80d9a1163 ("net: Introduce net_failover driver")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

The patch looks correct, but this code is based on team/bonding drivers.
So would like to get a confirmation from Jiri/Jay and if a similar fix is
needed in those drivers too.


>
> diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c
> index 8b508e2cf29b..ef50158e90a9 100644
> --- a/drivers/net/net_failover.c
> +++ b/drivers/net/net_failover.c
> @@ -380,7 +380,8 @@ static rx_handler_result_t net_failover_handle_frame(struct sk_buff **pskb)
>   
>   static void net_failover_compute_features(struct net_device *dev)
>   {
> -	u32 vlan_features = FAILOVER_VLAN_FEATURES & NETIF_F_ALL_FOR_ALL;
> +	netdev_features_t vlan_features = FAILOVER_VLAN_FEATURES |
> +					  NETIF_F_ALL_FOR_ALL;
>   	netdev_features_t enc_features  = FAILOVER_ENC_FEATURES;
>   	unsigned short max_hard_header_len = ETH_HLEN;
>   	unsigned int dst_release_flag = IFF_XMIT_DST_RELEASE |
David Miller June 4, 2018, 1:31 p.m. UTC | #2
From: Dan Carpenter <dan.carpenter@oracle.com>
Date: Thu, 31 May 2018 15:01:25 +0300

> @@ -380,7 +380,8 @@ static rx_handler_result_t net_failover_handle_frame(struct sk_buff **pskb)
>  
>  static void net_failover_compute_features(struct net_device *dev)
>  {
> -	u32 vlan_features = FAILOVER_VLAN_FEATURES & NETIF_F_ALL_FOR_ALL;
> +	netdev_features_t vlan_features = FAILOVER_VLAN_FEATURES |
> +					  NETIF_F_ALL_FOR_ALL;

The type does need to be corrected to netdev_features_t, but the
logical operation is correct.

It's a policy operation that was simply by-hand propagated all
over the place where these kinds of calculations are performed.

So vlan_features is starting with a value of 0 intentionally.
diff mbox series

Patch

diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c
index 8b508e2cf29b..ef50158e90a9 100644
--- a/drivers/net/net_failover.c
+++ b/drivers/net/net_failover.c
@@ -380,7 +380,8 @@  static rx_handler_result_t net_failover_handle_frame(struct sk_buff **pskb)
 
 static void net_failover_compute_features(struct net_device *dev)
 {
-	u32 vlan_features = FAILOVER_VLAN_FEATURES & NETIF_F_ALL_FOR_ALL;
+	netdev_features_t vlan_features = FAILOVER_VLAN_FEATURES |
+					  NETIF_F_ALL_FOR_ALL;
 	netdev_features_t enc_features  = FAILOVER_ENC_FEATURES;
 	unsigned short max_hard_header_len = ETH_HLEN;
 	unsigned int dst_release_flag = IFF_XMIT_DST_RELEASE |