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-37-shenjian15@huawei.com>
Date:   Wed, 29 Sep 2021 23:51:23 +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 036/167] macsec: 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/macsec.c | 39 ++++++++++++++++++++++++---------------
 1 file changed, 24 insertions(+), 15 deletions(-)

diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index 601b833a40bd..5526d54c0a14 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -347,7 +347,8 @@ static bool macsec_check_offload(enum macsec_offload offload,
 		return macsec->real_dev->phydev &&
 		       macsec->real_dev->phydev->macsec_ops;
 	else if (offload == MACSEC_OFFLOAD_MAC)
-		return macsec->real_dev->features & NETIF_F_HW_MACSEC &&
+		return netdev_feature_test_bit(NETIF_F_HW_MACSEC_BIT,
+					       macsec->real_dev->features) &&
 		       macsec->real_dev->macsec_ops;
 
 	return false;
@@ -3419,13 +3420,6 @@ static netdev_tx_t macsec_start_xmit(struct sk_buff *skb,
 #define SW_MACSEC_FEATURES \
 	(NETIF_F_SG | NETIF_F_HIGHDMA | NETIF_F_FRAGLIST)
 
-/* If h/w offloading is enabled, use real device features save for
- *   VLAN_FEATURES - they require additional ops
- *   HW_MACSEC - no reason to report it
- */
-#define REAL_DEV_FEATURES(dev) \
-	((dev)->features & ~(NETIF_F_VLAN_FEATURES | NETIF_F_HW_MACSEC))
-
 static int macsec_dev_init(struct net_device *dev)
 {
 	struct macsec_dev *macsec = macsec_priv(dev);
@@ -3443,10 +3437,19 @@ static int macsec_dev_init(struct net_device *dev)
 	}
 
 	if (macsec_is_offloaded(macsec)) {
-		dev->features = REAL_DEV_FEATURES(real_dev);
+		/* If h/w offloading is enabled, use real device features save for
+		 *   VLAN_FEATURES - they require additional ops
+		 *   HW_MACSEC - no reason to report it
+		 */
+		netdev_feature_copy(&dev->features, real_dev->features);
+		netdev_feature_clear_bits(NETIF_F_VLAN_FEATURES |
+					  NETIF_F_HW_MACSEC,
+					  &dev->features);
 	} else {
-		dev->features = real_dev->features & SW_MACSEC_FEATURES;
-		dev->features |= NETIF_F_LLTX | NETIF_F_GSO_SOFTWARE;
+		netdev_feature_copy(&dev->features, real_dev->features);
+		netdev_feature_and_bits(SW_MACSEC_FEATURES, &dev->features);
+		netdev_feature_set_bits(NETIF_F_LLTX | NETIF_F_GSO_SOFTWARE,
+					&dev->features);
 	}
 
 	dev->needed_headroom = real_dev->needed_headroom +
@@ -3475,15 +3478,21 @@ static void macsec_fix_features(struct net_device *dev,
 {
 	struct macsec_dev *macsec = macsec_priv(dev);
 	struct net_device *real_dev = macsec->real_dev;
+	netdev_features_t tmp;
 
 	if (macsec_is_offloaded(macsec)) {
-		*features = REAL_DEV_FEATURES(real_dev);
+		netdev_feature_copy(features, real_dev->features);
+		netdev_feature_clear_bits(NETIF_F_VLAN_FEATURES |
+					  NETIF_F_HW_MACSEC, features);
 		return;
 	}
 
-	*features &= (real_dev->features & SW_MACSEC_FEATURES) |
-		    NETIF_F_GSO_SOFTWARE | NETIF_F_SOFT_FEATURES;
-	*features |= NETIF_F_LLTX;
+	netdev_feature_copy(&tmp, real_dev->features);
+	netdev_feature_and_bits(SW_MACSEC_FEATURES, &tmp);
+	netdev_feature_set_bits(NETIF_F_GSO_SOFTWARE | NETIF_F_SOFT_FEATURES,
+				&tmp);
+	netdev_feature_and(features, *features, tmp);
+	netdev_feature_set_bit(NETIF_F_LLTX_BIT, features);
 }
 
 static int macsec_dev_open(struct net_device *dev)
-- 
2.33.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ