diff mbox series

[RFCv8,net-next,48/55] net: adjust the prototype of validate_xmit_xfrm() and relative functions

Message ID 20220918094336.28958-49-shenjian15@huawei.com (mailing list archive)
State RFC
Delegated to: Netdev Maintainers
Headers show
Series net: extend the type of netdev_features_t to bitmap | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next, async
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Series has a cover letter
netdev/patch_count fail Series longer than 15 patches (and no cover letter)
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 247 this patch: 247
netdev/cc_maintainers warning 6 maintainers not CCed: edumazet@google.com yoshfuji@linux-ipv6.org pabeni@redhat.com steffen.klassert@secunet.com dsahern@kernel.org herbert@gondor.apana.org.au
netdev/build_clang fail Errors and warnings before: 1541 this patch: 484
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn fail Errors and warnings before: 903 this patch: 241
netdev/checkpatch warning WARNING: function definition argument 'struct xfrm_state *' should also have an identifier name WARNING: line length of 83 exceeds 80 columns WARNING: line length of 92 exceeds 80 columns
netdev/kdoc success Errors and warnings before: 2 this patch: 2
netdev/source_inline success Was 0 now: 0

Commit Message

shenjian (K) Sept. 18, 2022, 9:43 a.m. UTC
The functions validate_xmit_xfrm() and xfrm_type_offload.xmit()
using netdev_features_t as parameters.

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 *'.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
---
 include/net/xfrm.h      | 11 ++++++++---
 net/core/dev.c          |  2 +-
 net/ipv4/esp4_offload.c |  5 +++--
 net/ipv6/esp6_offload.c |  5 +++--
 net/xfrm/xfrm_device.c  | 15 +++++++++------
 5 files changed, 24 insertions(+), 14 deletions(-)
diff mbox series

Patch

diff --git a/include/net/xfrm.h b/include/net/xfrm.h
index 6e8fa98f786f..0646a47d8b18 100644
--- a/include/net/xfrm.h
+++ b/include/net/xfrm.h
@@ -415,7 +415,8 @@  struct xfrm_type_offload {
 	u8		proto;
 	void		(*encap)(struct xfrm_state *, struct sk_buff *pskb);
 	int		(*input_tail)(struct xfrm_state *x, struct sk_buff *skb);
-	int		(*xmit)(struct xfrm_state *, struct sk_buff *pskb, netdev_features_t features);
+	int		(*xmit)(struct xfrm_state *, struct sk_buff *pskb,
+				const netdev_features_t *features);
 };
 
 int xfrm_register_type_offload(const struct xfrm_type_offload *type, unsigned short family);
@@ -1877,7 +1878,9 @@  void __init xfrm_dev_init(void);
 #ifdef CONFIG_XFRM_OFFLOAD
 void xfrm_dev_resume(struct sk_buff *skb);
 void xfrm_dev_backlog(struct softnet_data *sd);
-struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t features, bool *again);
+struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb,
+				   const netdev_features_t *features,
+				   bool *again);
 int xfrm_dev_state_add(struct net *net, struct xfrm_state *x,
 		       struct xfrm_user_offload *xuo);
 bool xfrm_dev_offload_ok(struct sk_buff *skb, struct xfrm_state *x);
@@ -1937,7 +1940,9 @@  static inline void xfrm_dev_backlog(struct softnet_data *sd)
 {
 }
 
-static inline struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t features, bool *again)
+static inline struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb,
+						 const netdev_features_t *features,
+						 bool *again)
 {
 	return skb;
 }
diff --git a/net/core/dev.c b/net/core/dev.c
index b8bb83a65221..54cb150d9db1 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -3696,7 +3696,7 @@  static struct sk_buff *validate_xmit_skb(struct sk_buff *skb, struct net_device
 		}
 	}
 
-	skb = validate_xmit_xfrm(skb, features, again);
+	skb = validate_xmit_xfrm(skb, &features, again);
 
 	return skb;
 
diff --git a/net/ipv4/esp4_offload.c b/net/ipv4/esp4_offload.c
index 36d76cff3075..b72ec9e3447e 100644
--- a/net/ipv4/esp4_offload.c
+++ b/net/ipv4/esp4_offload.c
@@ -250,7 +250,8 @@  static int esp_input_tail(struct xfrm_state *x, struct sk_buff *skb)
 	return esp_input_done2(skb, 0);
 }
 
-static int esp_xmit(struct xfrm_state *x, struct sk_buff *skb,  netdev_features_t features)
+static int esp_xmit(struct xfrm_state *x, struct sk_buff *skb,
+		    const netdev_features_t *features)
 {
 	int err;
 	int alen;
@@ -269,7 +270,7 @@  static int esp_xmit(struct xfrm_state *x, struct sk_buff *skb,  netdev_features_
 	if (!xo)
 		return -EINVAL;
 
-	if ((!netdev_feature_test(NETIF_F_HW_ESP_BIT, features) &&
+	if ((!netdev_feature_test(NETIF_F_HW_ESP_BIT, *features) &&
 	     !netdev_gso_partial_feature_test(skb->dev, NETIF_F_HW_ESP_BIT)) ||
 	    x->xso.dev != skb->dev) {
 		xo->flags |= CRYPTO_FALLBACK;
diff --git a/net/ipv6/esp6_offload.c b/net/ipv6/esp6_offload.c
index 4956a83d409a..ce7d02b5e184 100644
--- a/net/ipv6/esp6_offload.c
+++ b/net/ipv6/esp6_offload.c
@@ -287,7 +287,8 @@  static int esp6_input_tail(struct xfrm_state *x, struct sk_buff *skb)
 	return esp6_input_done2(skb, 0);
 }
 
-static int esp6_xmit(struct xfrm_state *x, struct sk_buff *skb,  netdev_features_t features)
+static int esp6_xmit(struct xfrm_state *x, struct sk_buff *skb,
+		     const netdev_features_t *features)
 {
 	int len;
 	int err;
@@ -306,7 +307,7 @@  static int esp6_xmit(struct xfrm_state *x, struct sk_buff *skb,  netdev_features
 	if (!xo)
 		return -EINVAL;
 
-	if (!netdev_feature_test(NETIF_F_HW_ESP_BIT, features) || x->xso.dev != skb->dev) {
+	if (!netdev_feature_test(NETIF_F_HW_ESP_BIT, *features) || x->xso.dev != skb->dev) {
 		xo->flags |= CRYPTO_FALLBACK;
 		hw_offload = false;
 	}
diff --git a/net/xfrm/xfrm_device.c b/net/xfrm/xfrm_device.c
index b53f142b02de..3a8f11aec189 100644
--- a/net/xfrm/xfrm_device.c
+++ b/net/xfrm/xfrm_device.c
@@ -97,23 +97,26 @@  static void xfrm_outer_mode_prep(struct xfrm_state *x, struct sk_buff *skb)
 	}
 }
 
-struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t features, bool *again)
+struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb,
+				   const netdev_features_t *features,
+				   bool *again)
 {
 	int err;
 	unsigned long flags;
 	struct xfrm_state *x;
 	struct softnet_data *sd;
 	struct sk_buff *skb2, *nskb, *pskb = NULL;
-	netdev_features_t esp_features = features;
 	struct xfrm_offload *xo = xfrm_offload(skb);
 	struct net_device *dev = skb->dev;
+	netdev_features_t esp_features;
 	struct sec_path *sp;
 
 	if (!xo || (xo->flags & XFRM_XMIT))
 		return skb;
 
-	if (!netdev_feature_test(NETIF_F_HW_ESP_BIT, features)) {
-		esp_features = features;
+	netdev_features_copy(esp_features, *features);
+	if (!netdev_feature_test(NETIF_F_HW_ESP_BIT, *features)) {
+		netdev_features_copy(esp_features, *features);
 		netdev_feature_del(NETIF_F_SG_BIT, esp_features);
 		netdev_features_clear(esp_features, NETIF_F_CSUM_MASK);
 	}
@@ -162,7 +165,7 @@  struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur
 
 		xo->flags |= XFRM_DEV_RESUME;
 
-		err = x->type_offload->xmit(x, skb, esp_features);
+		err = x->type_offload->xmit(x, skb, &esp_features);
 		if (err) {
 			if (err == -EINPROGRESS)
 				return NULL;
@@ -187,7 +190,7 @@  struct sk_buff *validate_xmit_xfrm(struct sk_buff *skb, netdev_features_t featur
 
 		xfrm_outer_mode_prep(x, skb2);
 
-		err = x->type_offload->xmit(x, skb2, esp_features);
+		err = x->type_offload->xmit(x, skb2, &esp_features);
 		if (!err) {
 			skb2->next = nskb;
 		} else if (err != -EINPROGRESS) {