lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20210929155334.12454-44-shenjian15@huawei.com>
Date:   Wed, 29 Sep 2021 23:51:30 +0800
From:   Jian Shen <shenjian15@...wei.com>
To:     <davem@...emloft.net>, <kuba@...nel.org>, <andrew@...n.ch>,
        <hkallweit1@...il.com>
CC:     <netdev@...r.kernel.org>, <linuxarm@...neuler.org>
Subject: [RFCv2 net-next 043/167] net_failover: use netdev feature helpers

Use netdev_feature_xxx helpers to replace the logical operation
for netdev features.

Signed-off-by: Jian Shen <shenjian15@...wei.com>
---
 drivers/net/net_failover.c | 57 +++++++++++++++++++++++++-------------
 1 file changed, 37 insertions(+), 20 deletions(-)

diff --git a/drivers/net/net_failover.c b/drivers/net/net_failover.c
index 878cad216aaf..704e691530f7 100644
--- a/drivers/net/net_failover.c
+++ b/drivers/net/net_failover.c
@@ -379,23 +379,33 @@ static rx_handler_result_t net_failover_handle_frame(struct sk_buff **pskb)
 
 static void net_failover_compute_features(struct net_device *dev)
 {
-	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 |
 					IFF_XMIT_DST_RELEASE_PERM;
 	struct net_failover_info *nfo_info = netdev_priv(dev);
 	struct net_device *primary_dev, *standby_dev;
+	netdev_features_t vlan_features;
+	netdev_features_t enc_features;
+	netdev_features_t vlan_mask;
+	netdev_features_t enc_mask;
+
+	netdev_feature_zero(&vlan_features);
+	netdev_feature_set_bits(FAILOVER_VLAN_FEATURES & NETIF_F_ALL_FOR_ALL,
+				&vlan_features);
+	netdev_feature_zero(&enc_features);
+	netdev_feature_set_bits(FAILOVER_ENC_FEATURES, &enc_features);
+	netdev_feature_zero(&vlan_mask);
+	netdev_feature_set_bits(FAILOVER_VLAN_FEATURES, &vlan_mask);
+	netdev_feature_copy(&enc_mask, enc_features);
 
 	primary_dev = rcu_dereference(nfo_info->primary_dev);
 	if (primary_dev) {
 		netdev_increment_features(&vlan_features, vlan_features,
 					  primary_dev->vlan_features,
-					  FAILOVER_VLAN_FEATURES);
+					  vlan_mask);
 		netdev_increment_features(&enc_features, enc_features,
 					  primary_dev->hw_enc_features,
-					  FAILOVER_ENC_FEATURES);
+					  enc_features);
 
 		dst_release_flag &= primary_dev->priv_flags;
 		if (primary_dev->hard_header_len > max_hard_header_len)
@@ -406,18 +416,19 @@ static void net_failover_compute_features(struct net_device *dev)
 	if (standby_dev) {
 		netdev_increment_features(&vlan_features, vlan_features,
 					  standby_dev->vlan_features,
-					  FAILOVER_VLAN_FEATURES);
+					  vlan_mask);
 		netdev_increment_features(&enc_features, enc_features,
 					  standby_dev->hw_enc_features,
-					  FAILOVER_ENC_FEATURES);
+					  enc_features);
 
 		dst_release_flag &= standby_dev->priv_flags;
 		if (standby_dev->hard_header_len > max_hard_header_len)
 			max_hard_header_len = standby_dev->hard_header_len;
 	}
 
-	dev->vlan_features = vlan_features;
-	dev->hw_enc_features = enc_features | NETIF_F_GSO_ENCAP_ALL;
+	netdev_feature_copy(&dev->vlan_features, vlan_features);
+	netdev_feature_copy(&dev->hw_enc_features, enc_features);
+	netdev_feature_set_bits(NETIF_F_GSO_ENCAP_ALL, &dev->hw_enc_features);
 	dev->hard_header_len = max_hard_header_len;
 
 	dev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
@@ -481,7 +492,8 @@ static int net_failover_slave_pre_register(struct net_device *slave_dev,
 				  !dev_is_pci(slave_dev->dev.parent)))
 		return -EINVAL;
 
-	if (failover_dev->features & NETIF_F_VLAN_CHALLENGED &&
+	if (netdev_feature_test_bit(NETIF_F_VLAN_CHALLENGED_BIT,
+				    failover_dev->features) &&
 	    vlan_uses_dev(failover_dev)) {
 		netdev_err(failover_dev, "Device %s is VLAN challenged and failover device has VLAN set up\n",
 			   failover_dev->name);
@@ -731,18 +743,23 @@ struct failover *net_failover_create(struct net_device *standby_dev)
 				       IFF_TX_SKB_SHARING);
 
 	/* don't acquire failover netdev's netif_tx_lock when transmitting */
-	failover_dev->features |= NETIF_F_LLTX;
+	netdev_feature_set_bit(NETIF_F_LLTX_BIT, &failover_dev->features);
 
 	/* Don't allow failover devices to change network namespaces. */
-	failover_dev->features |= NETIF_F_NETNS_LOCAL;
-
-	failover_dev->hw_features = FAILOVER_VLAN_FEATURES |
-				    NETIF_F_HW_VLAN_CTAG_TX |
-				    NETIF_F_HW_VLAN_CTAG_RX |
-				    NETIF_F_HW_VLAN_CTAG_FILTER;
-
-	failover_dev->hw_features |= NETIF_F_GSO_ENCAP_ALL;
-	failover_dev->features |= failover_dev->hw_features;
+	netdev_feature_set_bit(NETIF_F_NETNS_LOCAL_BIT,
+			       &failover_dev->features);
+
+	netdev_feature_zero(&failover_dev->hw_features);
+	netdev_feature_set_bits(FAILOVER_VLAN_FEATURES |
+				NETIF_F_HW_VLAN_CTAG_TX |
+				NETIF_F_HW_VLAN_CTAG_RX |
+				NETIF_F_HW_VLAN_CTAG_FILTER,
+				&failover_dev->hw_features);
+
+	netdev_feature_set_bits(NETIF_F_GSO_ENCAP_ALL,
+				&failover_dev->hw_features);
+	netdev_feature_or(&failover_dev->features, failover_dev->features,
+			  failover_dev->hw_features);
 
 	memcpy(failover_dev->dev_addr, standby_dev->dev_addr,
 	       failover_dev->addr_len);
-- 
2.33.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ