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: <20220918094336.28958-46-shenjian15@huawei.com>
Date:   Sun, 18 Sep 2022 09:43:26 +0000
From:   Jian Shen <shenjian15@...wei.com>
To:     <davem@...emloft.net>, <kuba@...nel.org>, <ecree.xilinx@...il.com>,
        <andrew@...n.ch>, <hkallweit1@...il.com>,
        <alexandr.lobakin@...el.com>, <saeed@...nel.org>, <leon@...nel.org>
CC:     <netdev@...r.kernel.org>, <linuxarm@...wei.com>
Subject: [RFCv8 PATCH net-next 45/55] net: vlan: adjust the prototype of vlan functions

There are some functions of vlan driver using netdev_features_t
as parameters or return netdev_features_t directly or both.

For the prototype of netdev_features_t will be extended to be
larger than 8 bytes, so change the prototype of the function,
change the prototype of input features to 'netdev_features_t *',
and return the features pointer as output parameter.

Signed-off-by: Jian Shen <shenjian15@...wei.com>
---
 include/linux/if_vlan.h |  6 +++---
 net/8021q/vlan.c        |  4 ++--
 net/8021q/vlan.h        | 26 ++++++++++++--------------
 net/8021q/vlan_dev.c    |  4 ++--
 net/core/dev.c          |  4 ++--
 net/core/netpoll.c      |  2 +-
 6 files changed, 22 insertions(+), 24 deletions(-)

diff --git a/include/linux/if_vlan.h b/include/linux/if_vlan.h
index 4fef74864267..3179db99ebc2 100644
--- a/include/linux/if_vlan.h
+++ b/include/linux/if_vlan.h
@@ -316,14 +316,14 @@ static inline bool eth_type_vlan(__be16 ethertype)
 	}
 }
 
-static inline bool vlan_hw_offload_capable(netdev_features_t features,
+static inline bool vlan_hw_offload_capable(const netdev_features_t *features,
 					   __be16 proto)
 {
 	if (proto == htons(ETH_P_8021Q) &&
-	    netdev_feature_test(NETIF_F_HW_VLAN_CTAG_TX_BIT, features))
+	    netdev_feature_test(NETIF_F_HW_VLAN_CTAG_TX_BIT, *features))
 		return true;
 	if (proto == htons(ETH_P_8021AD) &&
-	    netdev_feature_test(NETIF_F_HW_VLAN_STAG_TX_BIT, features))
+	    netdev_feature_test(NETIF_F_HW_VLAN_STAG_TX_BIT, *features))
 		return true;
 	return false;
 }
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c
index aec2e74ccfd9..f366f4048e3d 100644
--- a/net/8021q/vlan.c
+++ b/net/8021q/vlan.c
@@ -321,7 +321,7 @@ static void vlan_transfer_features(struct net_device *dev,
 
 	netif_inherit_tso_max(vlandev, dev);
 
-	if (vlan_hw_offload_capable(dev->features, vlan->vlan_proto))
+	if (vlan_hw_offload_capable(&dev->features, vlan->vlan_proto))
 		vlandev->hard_header_len = dev->hard_header_len;
 	else
 		vlandev->hard_header_len = dev->hard_header_len + VLAN_HLEN;
@@ -332,7 +332,7 @@ static void vlan_transfer_features(struct net_device *dev,
 
 	vlandev->priv_flags &= ~IFF_XMIT_DST_RELEASE;
 	vlandev->priv_flags |= (vlan->real_dev->priv_flags & IFF_XMIT_DST_RELEASE);
-	vlandev->hw_enc_features = vlan_tnl_features(vlan->real_dev);
+	vlan_tnl_features(vlan->real_dev, &vlandev->hw_enc_features);
 
 	netdev_update_features(vlandev);
 }
diff --git a/net/8021q/vlan.h b/net/8021q/vlan.h
index 2acb89660ab5..c72413f438e2 100644
--- a/net/8021q/vlan.h
+++ b/net/8021q/vlan.h
@@ -104,22 +104,20 @@ static inline struct net_device *vlan_find_dev(struct net_device *real_dev,
 	return NULL;
 }
 
-static inline netdev_features_t vlan_tnl_features(struct net_device *real_dev)
+static inline void vlan_tnl_features(struct net_device *real_dev,
+				     netdev_features_t *features)
 {
-	netdev_features_t ret;
-
-	netdev_features_or(ret, NETIF_F_CSUM_MASK, NETIF_F_GSO_SOFTWARE);
-	netdev_features_set(ret, NETIF_F_GSO_ENCAP_ALL);
-	netdev_features_mask(ret, real_dev->hw_enc_features);
-
-	if (netdev_features_intersects(ret, NETIF_F_GSO_ENCAP_ALL) &&
-	    netdev_features_intersects(ret, NETIF_F_CSUM_MASK)) {
-		netdev_features_clear(ret, NETIF_F_CSUM_MASK);
-		netdev_feature_add(NETIF_F_HW_CSUM_BIT, ret);
-		return ret;
+	netdev_features_or(*features, NETIF_F_CSUM_MASK, NETIF_F_GSO_SOFTWARE);
+	netdev_features_set(*features, NETIF_F_GSO_ENCAP_ALL);
+	netdev_features_mask(*features, real_dev->hw_enc_features);
+
+	if (netdev_features_intersects(*features, NETIF_F_GSO_ENCAP_ALL) &&
+	    netdev_features_intersects(*features, NETIF_F_CSUM_MASK)) {
+		netdev_features_clear(*features, NETIF_F_CSUM_MASK);
+		netdev_feature_add(NETIF_F_HW_CSUM_BIT, *features);
+		return;
 	}
-	netdev_features_zero(ret);
-	return ret;
+	netdev_features_zero(*features);
 }
 
 #define vlan_group_for_each_dev(grp, i, dev) \
diff --git a/net/8021q/vlan_dev.c b/net/8021q/vlan_dev.c
index 2fa0b4ea260b..321adf534177 100644
--- a/net/8021q/vlan_dev.c
+++ b/net/8021q/vlan_dev.c
@@ -583,7 +583,7 @@ static int vlan_dev_init(struct net_device *dev)
 
 	netdev_vlan_features_andnot(dev, real_dev->vlan_features,
 				    NETIF_F_ALL_FCOE);
-	dev->hw_enc_features = vlan_tnl_features(real_dev);
+	vlan_tnl_features(real_dev, &dev->hw_enc_features);
 	dev->mpls_features = real_dev->mpls_features;
 
 	/* ipv6 shared card related stuff */
@@ -601,7 +601,7 @@ static int vlan_dev_init(struct net_device *dev)
 #endif
 
 	dev->needed_headroom = real_dev->needed_headroom;
-	if (vlan_hw_offload_capable(real_dev->features, vlan->vlan_proto)) {
+	if (vlan_hw_offload_capable(&real_dev->features, vlan->vlan_proto)) {
 		dev->header_ops      = &vlan_passthru_header_ops;
 		dev->hard_header_len = real_dev->hard_header_len;
 	} else {
diff --git a/net/core/dev.c b/net/core/dev.c
index ad6202d2543e..21ef38eeb38a 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3622,7 +3622,7 @@ struct sk_buff *dev_hard_start_xmit(struct sk_buff *first, struct net_device *de
 }
 
 static struct sk_buff *validate_xmit_vlan(struct sk_buff *skb,
-					  netdev_features_t features)
+					  const netdev_features_t *features)
 {
 	if (skb_vlan_tag_present(skb) &&
 	    !vlan_hw_offload_capable(features, skb->vlan_proto))
@@ -3657,7 +3657,7 @@ static struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device
 	netdev_features_t features;
 
 	netif_skb_features(skb, &features);
-	skb = validate_xmit_vlan(skb, features);
+	skb = validate_xmit_vlan(skb, &features);
 	if (unlikely(!skb))
 		goto out_null;
 
diff --git a/net/core/netpoll.c b/net/core/netpoll.c
index 94dd11aa1b83..17af85316407 100644
--- a/net/core/netpoll.c
+++ b/net/core/netpoll.c
@@ -80,7 +80,7 @@ static netdev_tx_t netpoll_start_xmit(struct sk_buff *skb,
 	netif_skb_features(skb, &features);
 
 	if (skb_vlan_tag_present(skb) &&
-	    !vlan_hw_offload_capable(features, skb->vlan_proto)) {
+	    !vlan_hw_offload_capable(&features, skb->vlan_proto)) {
 		skb = __vlan_hwaccel_push_inside(skb);
 		if (unlikely(!skb)) {
 			/* This is actually a packet drop, but we
-- 
2.33.0

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ