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-36-shenjian15@huawei.com>
Date:   Wed, 29 Sep 2021 23:51:22 +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 035/167] macvlan: 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/macvlan.c | 49 +++++++++++++++++++++++++++----------------
 1 file changed, 31 insertions(+), 18 deletions(-)

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index 3c408653e864..9ac38e22ccfc 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -620,7 +620,8 @@ static int macvlan_open(struct net_device *dev)
 	/* Attempt to populate accel_priv which is used to offload the L2
 	 * forwarding requests for unicast packets.
 	 */
-	if (lowerdev->features & NETIF_F_HW_L2FW_DOFFLOAD)
+	if (netdev_feature_test_bit(NETIF_F_HW_L2FW_DOFFLOAD_BIT,
+				    lowerdev->features))
 		vlan->accel_priv =
 		      lowerdev->netdev_ops->ndo_dfwd_add_station(lowerdev, dev);
 
@@ -893,12 +894,15 @@ static int macvlan_init(struct net_device *dev)
 
 	dev->state		= (dev->state & ~MACVLAN_STATE_MASK) |
 				  (lowerdev->state & MACVLAN_STATE_MASK);
-	dev->features 		= lowerdev->features & MACVLAN_FEATURES;
-	dev->features		|= ALWAYS_ON_FEATURES;
-	dev->hw_features	|= NETIF_F_LRO;
-	dev->vlan_features	= lowerdev->vlan_features & MACVLAN_FEATURES;
-	dev->vlan_features	|= ALWAYS_ON_OFFLOADS;
-	dev->hw_enc_features    |= dev->features;
+	netdev_feature_copy(&dev->features, lowerdev->features);
+	netdev_feature_and_bits(MACVLAN_FEATURES, &dev->features);
+	netdev_feature_set_bits(ALWAYS_ON_FEATURES, &dev->features);
+	netdev_feature_set_bit(NETIF_F_LRO_BIT, &dev->hw_features);
+	netdev_feature_copy(&dev->vlan_features, lowerdev->vlan_features);
+	netdev_feature_and_bits(MACVLAN_FEATURES, &dev->vlan_features);
+	netdev_feature_set_bits(ALWAYS_ON_OFFLOADS, &dev->vlan_features);
+	netdev_feature_or(&dev->hw_enc_features, dev->hw_enc_features,
+			  dev->features);
 	dev->gso_max_size	= lowerdev->gso_max_size;
 	dev->gso_max_segs	= lowerdev->gso_max_segs;
 	dev->hard_header_len	= lowerdev->hard_header_len;
@@ -1071,17 +1075,25 @@ static void macvlan_fix_features(struct net_device *dev,
 				 netdev_features_t *features)
 {
 	struct macvlan_dev *vlan = netdev_priv(dev);
-	netdev_features_t lowerdev_features = vlan->lowerdev->features;
-	netdev_features_t mask;
-
-	*features |= NETIF_F_ALL_FOR_ALL;
-	*features &= (vlan->set_features | ~MACVLAN_FEATURES);
-	mask = *features;
-
-	lowerdev_features &= (*features | ~NETIF_F_LRO);
+	netdev_features_t lowerdev_features;
+	netdev_features_t mask, tmp;
+
+	netdev_feature_copy(&lowerdev_features, vlan->lowerdev->features);
+	netdev_feature_set_bits(NETIF_F_ALL_FOR_ALL, features);
+	netdev_feature_fill(&tmp);
+	netdev_feature_clear_bits(MACVLAN_FEATURES, &tmp);
+	netdev_feature_or(&tmp, tmp, vlan->set_features);
+	netdev_feature_and(features, *features, tmp);
+	netdev_feature_copy(&mask, *features);
+
+	netdev_feature_fill(&tmp);
+	netdev_feature_clear_bit(NETIF_F_LRO_BIT, &tmp);
+	netdev_feature_or(&tmp, tmp, *features);
+	netdev_feature_and(&lowerdev_features, lowerdev_features, tmp);
 	netdev_increment_features(features, lowerdev_features, *features, mask);
-	*features |= ALWAYS_ON_FEATURES;
-	*features &= (ALWAYS_ON_FEATURES | MACVLAN_FEATURES);
+	netdev_feature_set_bits(ALWAYS_ON_FEATURES, features);
+	netdev_feature_and_bits(ALWAYS_ON_FEATURES | MACVLAN_FEATURES,
+				features);
 }
 
 #ifdef CONFIG_NET_POLL_CONTROLLER
@@ -1458,7 +1470,8 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
 	vlan->lowerdev = lowerdev;
 	vlan->dev      = dev;
 	vlan->port     = port;
-	vlan->set_features = MACVLAN_FEATURES;
+	netdev_feature_zero(&vlan->set_features);
+	netdev_feature_set_bits(MACVLAN_FEATURES, &vlan->set_features);
 
 	vlan->mode     = MACVLAN_MODE_VEPA;
 	if (data && data[IFLA_MACVLAN_MODE])
-- 
2.33.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ