Skip to content

Commit aba5465

Browse files
edumazetdavem330
authored andcommitted
net: remove sk_route_nocaps
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 <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent d0d598c commit aba5465

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

include/net/sock.h

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ struct bpf_local_storage;
284284
* @sk_no_check_tx: %SO_NO_CHECK setting, set checksum in TX packets
285285
* @sk_no_check_rx: allow zero checksum in RX packets
286286
* @sk_route_caps: route capabilities (e.g. %NETIF_F_TSO)
287-
* @sk_route_nocaps: forbidden route capabilities (e.g NETIF_F_GSO_MASK)
287+
* @sk_gso_disabled: if set, NETIF_F_GSO_MASK is forbidden.
288288
* @sk_gso_type: GSO type (e.g. %SKB_GSO_TCPV4)
289289
* @sk_gso_max_size: Maximum GSO segment size to build
290290
* @sk_gso_max_segs: Maximum number of GSO segments
@@ -458,7 +458,6 @@ struct sock {
458458
unsigned long sk_max_pacing_rate;
459459
struct page_frag sk_frag;
460460
netdev_features_t sk_route_caps;
461-
netdev_features_t sk_route_nocaps;
462461
int sk_gso_type;
463462
unsigned int sk_gso_max_size;
464463
gfp_t sk_allocation;
@@ -468,7 +467,7 @@ struct sock {
468467
* Because of non atomicity rules, all
469468
* changes are protected by socket lock.
470469
*/
471-
u8 sk_padding : 1,
470+
u8 sk_gso_disabled : 1,
472471
sk_kern_sock : 1,
473472
sk_no_check_tx : 1,
474473
sk_no_check_rx : 1,
@@ -2121,10 +2120,10 @@ static inline bool sk_can_gso(const struct sock *sk)
21212120

21222121
void sk_setup_caps(struct sock *sk, struct dst_entry *dst);
21232122

2124-
static inline void sk_nocaps_add(struct sock *sk, netdev_features_t flags)
2123+
static inline void sk_gso_disable(struct sock *sk)
21252124
{
2126-
sk->sk_route_nocaps |= flags;
2127-
sk->sk_route_caps &= ~flags;
2125+
sk->sk_gso_disabled = 1;
2126+
sk->sk_route_caps &= ~NETIF_F_GSO_MASK;
21282127
}
21292128

21302129
static inline int skb_do_copy_data_nocache(struct sock *sk, struct sk_buff *skb,

net/core/sock.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2249,7 +2249,8 @@ void sk_setup_caps(struct sock *sk, struct dst_entry *dst)
22492249
sk->sk_route_caps |= NETIF_F_GSO;
22502250
if (sk->sk_route_caps & NETIF_F_GSO)
22512251
sk->sk_route_caps |= NETIF_F_GSO_SOFTWARE;
2252-
sk->sk_route_caps &= ~sk->sk_route_nocaps;
2252+
if (unlikely(sk->sk_gso_disabled))
2253+
sk->sk_route_caps &= ~NETIF_F_GSO_MASK;
22532254
if (sk_can_gso(sk)) {
22542255
if (dst->header_len && !xfrm_dst_offload_ok(dst)) {
22552256
sk->sk_route_caps &= ~NETIF_F_GSO_MASK;

net/ipv4/tcp_ipv4.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,7 +1182,7 @@ int tcp_md5_do_add(struct sock *sk, const union tcp_md5_addr *addr,
11821182
if (!md5sig)
11831183
return -ENOMEM;
11841184

1185-
sk_nocaps_add(sk, NETIF_F_GSO_MASK);
1185+
sk_gso_disable(sk);
11861186
INIT_HLIST_HEAD(&md5sig->head);
11871187
rcu_assign_pointer(tp->md5sig_info, md5sig);
11881188
}
@@ -1620,7 +1620,7 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb,
16201620
*/
16211621
tcp_md5_do_add(newsk, addr, AF_INET, 32, l3index, key->flags,
16221622
key->key, key->keylen, GFP_ATOMIC);
1623-
sk_nocaps_add(newsk, NETIF_F_GSO_MASK);
1623+
sk_gso_disable(newsk);
16241624
}
16251625
#endif
16261626

net/ipv4/tcp_output.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1359,7 +1359,7 @@ static int __tcp_transmit_skb(struct sock *sk, struct sk_buff *skb,
13591359
#ifdef CONFIG_TCP_MD5SIG
13601360
/* Calculate the MD5 hash, as we have all we need now */
13611361
if (md5) {
1362-
sk_nocaps_add(sk, NETIF_F_GSO_MASK);
1362+
sk_gso_disable(sk);
13631363
tp->af_specific->calc_md5_hash(opts.hash_location,
13641364
md5, sk, skb);
13651365
}

net/ipv6/ip6_output.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -977,7 +977,7 @@ int ip6_fragment(struct net *net, struct sock *sk, struct sk_buff *skb,
977977

978978
fail_toobig:
979979
if (skb->sk && dst_allfrag(skb_dst(skb)))
980-
sk_nocaps_add(skb->sk, NETIF_F_GSO_MASK);
980+
sk_gso_disable(skb->sk);
981981

982982
icmpv6_send(skb, ICMPV6_PKT_TOOBIG, 0, mtu);
983983
err = -EMSGSIZE;

0 commit comments

Comments
 (0)