diff mbox series

[RFCv2,net-next,165/167] net: sock: add helper sk_nocaps_add_gso()

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

Commit Message

shenjian (K) Sept. 29, 2021, 3:53 p.m. UTC
Add helper sk_nocaps_add_gso, to avoid declare netdev_features_t anyware.

Signed-off-by: Jian Shen <shenjian15@huawei.com>
---
 include/net/sock.h    | 9 +++++++++
 net/ipv4/tcp_ipv4.c   | 4 ++--
 net/ipv4/tcp_output.c | 2 +-
 net/ipv6/ip6_output.c | 2 +-
 4 files changed, 13 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/include/net/sock.h b/include/net/sock.h
index 5c76b5c7ee34..f7ba322c63bd 100644
--- a/include/net/sock.h
+++ b/include/net/sock.h
@@ -2054,6 +2054,15 @@  static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
 	netdev_feature_andnot(&sk->sk_route_caps, sk->sk_route_caps, flags);
 }
 
+static inline void sk_nocaps_add_gso(struct sock *sk)
+{
+	netdev_features_t gso_flags;
+
+	netdev_feature_zero(&gso_flags);
+	netdev_feature_set_bits(NETIF_F_GSO_MASK, &gso_flags);
+	sk_nocaps_add(sk, gso_flags);
+}
+
 static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,
 					   struct iov_iter *from, char *to,
 					   int copy, int offset)
diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c
index a3720304fa81..5b42b4e8e83f 100644
--- a/net/ipv4/tcp_ipv4.c
+++ b/net/ipv4/tcp_ipv4.c
@@ -1164,7 +1164,7 @@  int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
 		if (!md5sig)
 			return -ENOMEM;
 
-		sk_nocaps_add(sk, NETIF_F_GSO_MASK);
+		sk_nocaps_add_gso(sk);
 		INIT_HLIST_HEAD(&md5sig->head);
 		rcu_assign_pointer(tp->md5sig_info, md5sig);
 	}
@@ -1598,7 +1598,7 @@  struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
 		 */
 		tcp_md5_do_add(newsk, addr, AF_INET, 32, l3index,
 			       key->key, key->keylen, GFP_ATOMIC);
-		sk_nocaps_add(newsk, NETIF_F_GSO_MASK);
+		sk_nocaps_add_gso(newsk);
 	}
 #endif
 
diff --git a/net/ipv4/tcp_output.c b/net/ipv4/tcp_output.c
index fdc39b4fbbfa..d6e69705d69f 100644
--- a/net/ipv4/tcp_output.c
+++ b/net/ipv4/tcp_output.c
@@ -1360,7 +1360,7 @@  static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb,
 #ifdef CONFIG_TCP_MD5SIG
 	/* Calculate the MD5 hash, as we have all we need now */
 	if (md5) {
-		sk_nocaps_add(sk, NETIF_F_GSO_MASK);
+		sk_nocaps_add_gso(sk);
 		tp->af_specific->calc_md5_hash(opts.hash_location,
 					       md5, sk, skb);
 	}
diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c
index 78e01d4faf09..c7e060064686 100644
--- a/net/ipv6/ip6_output.c
+++ b/net/ipv6/ip6_output.c
@@ -977,7 +977,7 @@  int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
 
 fail_toobig:
 	if (skb->sk && dst_allfrag(skb_dst(skb)))
-		sk_nocaps_add(skb->sk, NETIF_F_GSO_MASK);
+		sk_nocaps_add_gso(skb->sk);
 
 	icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
 	err = -EMSGSIZE;