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 --git a/include/net/sock.h b/include/net/sock.h index 01f38c5..1baceb0 100644 --- a/include/net/sock.h +++ b/include/net/sock.h @@ -2065,6 +2065,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 60f9ef0..f5a8b66 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 29553fc..50ad159 100644 --- a/net/ipv4/tcp_output.c +++ b/net/ipv4/tcp_output.c @@ -1362,7 +1362,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 78e01d4..c7e0600 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;