Instead of using a full netdev_features_t, we can use a single bit,
as sk_route_nocaps is only used to remove NETIF_F_GSO_MASK from
sk->sk_route_cap.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Eric Dumazet 2021-11-15 11:02:35 -08:00 коммит произвёл David S. Miller
Родитель d0d598ca86
Коммит aba546565b
5 изменённых файлов: 11 добавлений и 11 удалений

Просмотреть файл

@ -284,7 +284,7 @@ struct bpf_local_storage;
* @sk_no_check_tx: %SO_NO_CHECK setting, set checksum in TX packets * @sk_no_check_tx: %SO_NO_CHECK setting, set checksum in TX packets
* @sk_no_check_rx: allow zero checksum in RX packets * @sk_no_check_rx: allow zero checksum in RX packets
* @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO) * @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO)
* @sk_route_nocaps: forbidden route capabilities (e.g NETIF_F_GSO_MASK) * @sk_gso_disabled: if set, NETIF_F_GSO_MASK is forbidden.
* @sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4) * @sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4)
* @sk_gso_max_size: Maximum GSO segment size to build * @sk_gso_max_size: Maximum GSO segment size to build
* @sk_gso_max_segs: Maximum number of GSO segments * @sk_gso_max_segs: Maximum number of GSO segments
@ -458,7 +458,6 @@ struct sock {
unsigned long sk_max_pacing_rate; unsigned long sk_max_pacing_rate;
struct page_frag sk_frag; struct page_frag sk_frag;
netdev_features_t sk_route_caps; netdev_features_t sk_route_caps;
netdev_features_t sk_route_nocaps;
int sk_gso_type; int sk_gso_type;
unsigned int sk_gso_max_size; unsigned int sk_gso_max_size;
gfp_t sk_allocation; gfp_t sk_allocation;
@ -468,7 +467,7 @@ struct sock {
* Because of non atomicity rules, all * Because of non atomicity rules, all
* changes are protected by socket lock. * changes are protected by socket lock.
*/ */
u8 sk_padding : 1, u8 sk_gso_disabled : 1,
sk_kern_sock : 1, sk_kern_sock : 1,
sk_no_check_tx : 1, sk_no_check_tx : 1,
sk_no_check_rx : 1, sk_no_check_rx : 1,
@ -2121,10 +2120,10 @@ static inline bool sk_can_gso(const struct sock *sk)
void sk_setup_caps(struct sock *sk, struct dst_entry *dst); void sk_setup_caps(struct sock *sk, struct dst_entry *dst);
static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags) static inline void sk_gso_disable(struct sock *sk)
{ {
sk->sk_route_nocaps |= flags; sk->sk_gso_disabled = 1;
sk->sk_route_caps &= ~flags; sk->sk_route_caps &= ~NETIF_F_GSO_MASK;
} }
static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb, static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,

Просмотреть файл

@ -2249,7 +2249,8 @@ void sk_setup_caps(struct sock *sk, struct dst_entry *dst)
sk->sk_route_caps |= NETIF_F_GSO; sk->sk_route_caps |= NETIF_F_GSO;
if (sk->sk_route_caps & NETIF_F_GSO) if (sk->sk_route_caps & NETIF_F_GSO)
sk->sk_route_caps |= NETIF_F_GSO_SOFTWARE; sk->sk_route_caps |= NETIF_F_GSO_SOFTWARE;
sk->sk_route_caps &= ~sk->sk_route_nocaps; if (unlikely(sk->sk_gso_disabled))
sk->sk_route_caps &= ~NETIF_F_GSO_MASK;
if (sk_can_gso(sk)) { if (sk_can_gso(sk)) {
if (dst->header_len && !xfrm_dst_offload_ok(dst)) { if (dst->header_len && !xfrm_dst_offload_ok(dst)) {
sk->sk_route_caps &= ~NETIF_F_GSO_MASK; sk->sk_route_caps &= ~NETIF_F_GSO_MASK;

Просмотреть файл

@ -1182,7 +1182,7 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
if (!md5sig) if (!md5sig)
return -ENOMEM; return -ENOMEM;
sk_nocaps_add(sk, NETIF_F_GSO_MASK); sk_gso_disable(sk);
INIT_HLIST_HEAD(&md5sig->head); INIT_HLIST_HEAD(&md5sig->head);
rcu_assign_pointer(tp->md5sig_info, md5sig); rcu_assign_pointer(tp->md5sig_info, md5sig);
} }
@ -1620,7 +1620,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->flags, tcp_md5_do_add(newsk, addr, AF_INET, 32, l3index, key->flags,
key->key, key->keylen, GFP_ATOMIC); key->key, key->keylen, GFP_ATOMIC);
sk_nocaps_add(newsk, NETIF_F_GSO_MASK); sk_gso_disable(newsk);
} }
#endif #endif

Просмотреть файл

@ -1359,7 +1359,7 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb,
#ifdef CONFIG_TCP_MD5SIG #ifdef CONFIG_TCP_MD5SIG
/* Calculate the MD5 hash, as we have all we need now */ /* Calculate the MD5 hash, as we have all we need now */
if (md5) { if (md5) {
sk_nocaps_add(sk, NETIF_F_GSO_MASK); sk_gso_disable(sk);
tp->af_specific->calc_md5_hash(opts.hash_location, tp->af_specific->calc_md5_hash(opts.hash_location,
md5, sk, skb); md5, sk, skb);
} }

Просмотреть файл

@ -977,7 +977,7 @@ slow_path:
fail_toobig: fail_toobig:
if (skb->sk && dst_allfrag(skb_dst(skb))) if (skb->sk && dst_allfrag(skb_dst(skb)))
sk_nocaps_add(skb->sk, NETIF_F_GSO_MASK); sk_gso_disable(skb->sk);
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu); icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
err = -EMSGSIZE; err = -EMSGSIZE;