Commit a465419b authored by Eric Dumazet's avatar Eric Dumazet Committed by David S. Miller

net: Introduce sk_route_nocaps

TCP-MD5 sessions have intermittent failures, when route cache is
invalidated. ip_queue_xmit() has to find a new route, calls
sk_setup_caps(sk, &rt->u.dst), destroying the 

sk->sk_route_caps &= ~NETIF_F_GSO_MASK

that MD5 desperately try to make all over its way (from
tcp_transmit_skb() for example)

So we send few bad packets, and everything is fine when
tcp_transmit_skb() is called again for this socket.

Since ip_queue_xmit() is at a lower level than TCP-MD5, I chose to use a
socket field, sk_route_nocaps, containing bits to mask on sk_route_caps.
Reported-by: default avatarBhaskar Dutta <bhaskie@gmail.com>
Signed-off-by: default avatarEric Dumazet <eric.dumazet@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3b098e2d
...@@ -177,6 +177,7 @@ struct sock_common { ...@@ -177,6 +177,7 @@ struct sock_common {
* %SO_OOBINLINE settings, %SO_TIMESTAMPING settings * %SO_OOBINLINE settings, %SO_TIMESTAMPING settings
* @sk_no_check: %SO_NO_CHECK setting, wether or not checkup packets * @sk_no_check: %SO_NO_CHECK setting, wether or not checkup 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_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_lingertime: %SO_LINGER l_linger setting * @sk_lingertime: %SO_LINGER l_linger setting
...@@ -276,6 +277,7 @@ struct sock { ...@@ -276,6 +277,7 @@ struct sock {
int sk_forward_alloc; int sk_forward_alloc;
gfp_t sk_allocation; gfp_t sk_allocation;
int sk_route_caps; int sk_route_caps;
int sk_route_nocaps;
int sk_gso_type; int sk_gso_type;
unsigned int sk_gso_max_size; unsigned int sk_gso_max_size;
int sk_rcvlowat; int sk_rcvlowat;
...@@ -1335,6 +1337,12 @@ static inline int sk_can_gso(const struct sock *sk) ...@@ -1335,6 +1337,12 @@ static inline int sk_can_gso(const struct sock *sk)
extern void sk_setup_caps(struct sock *sk, struct dst_entry *dst); extern void sk_setup_caps(struct sock *sk, struct dst_entry *dst);
static inline void sk_nocaps_add(struct sock *sk, int flags)
{
sk->sk_route_nocaps |= flags;
sk->sk_route_caps &= ~flags;
}
static inline int skb_copy_to_page(struct sock *sk, char __user *from, static inline int skb_copy_to_page(struct sock *sk, char __user *from,
struct sk_buff *skb, struct page *page, struct sk_buff *skb, struct page *page,
int off, int copy) int off, int copy)
......
...@@ -1231,6 +1231,7 @@ void sk_setup_caps(struct sock *sk, struct dst_entry *dst) ...@@ -1231,6 +1231,7 @@ void sk_setup_caps(struct sock *sk, struct dst_entry *dst)
sk->sk_route_caps = dst->dev->features; sk->sk_route_caps = dst->dev->features;
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 (sk_can_gso(sk)) { if (sk_can_gso(sk)) {
if (dst->header_len) { if (dst->header_len) {
sk->sk_route_caps &= ~NETIF_F_GSO_MASK; sk->sk_route_caps &= ~NETIF_F_GSO_MASK;
......
...@@ -891,7 +891,7 @@ int tcp_v4_md5_do_add(struct sock *sk, __be32 addr, ...@@ -891,7 +891,7 @@ int tcp_v4_md5_do_add(struct sock *sk, __be32 addr,
kfree(newkey); kfree(newkey);
return -ENOMEM; return -ENOMEM;
} }
sk->sk_route_caps &= ~NETIF_F_GSO_MASK; sk_nocaps_add(sk, NETIF_F_GSO_MASK);
} }
if (tcp_alloc_md5sig_pool(sk) == NULL) { if (tcp_alloc_md5sig_pool(sk) == NULL) {
kfree(newkey); kfree(newkey);
...@@ -1021,7 +1021,7 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, char __user *optval, ...@@ -1021,7 +1021,7 @@ static int tcp_v4_parse_md5_keys(struct sock *sk, char __user *optval,
return -EINVAL; return -EINVAL;
tp->md5sig_info = p; tp->md5sig_info = p;
sk->sk_route_caps &= ~NETIF_F_GSO_MASK; sk_nocaps_add(sk, NETIF_F_GSO_MASK);
} }
newkey = kmemdup(cmd.tcpm_key, cmd.tcpm_keylen, sk->sk_allocation); newkey = kmemdup(cmd.tcpm_key, cmd.tcpm_keylen, sk->sk_allocation);
...@@ -1462,7 +1462,7 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb, ...@@ -1462,7 +1462,7 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
if (newkey != NULL) if (newkey != NULL)
tcp_v4_md5_do_add(newsk, newinet->inet_daddr, tcp_v4_md5_do_add(newsk, newinet->inet_daddr,
newkey, key->keylen); newkey, key->keylen);
newsk->sk_route_caps &= ~NETIF_F_GSO_MASK; sk_nocaps_add(newsk, NETIF_F_GSO_MASK);
} }
#endif #endif
......
...@@ -873,7 +873,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it, ...@@ -873,7 +873,7 @@ static int tcp_transmit_skb(struct sock *sk, struct sk_buff *skb, int clone_it,
#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->sk_route_caps &= ~NETIF_F_GSO_MASK; sk_nocaps_add(sk, NETIF_F_GSO_MASK);
tp->af_specific->calc_md5_hash(opts.hash_location, tp->af_specific->calc_md5_hash(opts.hash_location,
md5, sk, NULL, skb); md5, sk, NULL, skb);
} }
......
...@@ -604,7 +604,7 @@ static int tcp_v6_md5_do_add(struct sock *sk, struct in6_addr *peer, ...@@ -604,7 +604,7 @@ static int tcp_v6_md5_do_add(struct sock *sk, struct in6_addr *peer,
kfree(newkey); kfree(newkey);
return -ENOMEM; return -ENOMEM;
} }
sk->sk_route_caps &= ~NETIF_F_GSO_MASK; sk_nocaps_add(sk, NETIF_F_GSO_MASK);
} }
if (tcp_alloc_md5sig_pool(sk) == NULL) { if (tcp_alloc_md5sig_pool(sk) == NULL) {
kfree(newkey); kfree(newkey);
...@@ -741,7 +741,7 @@ static int tcp_v6_parse_md5_keys (struct sock *sk, char __user *optval, ...@@ -741,7 +741,7 @@ static int tcp_v6_parse_md5_keys (struct sock *sk, char __user *optval,
return -ENOMEM; return -ENOMEM;
tp->md5sig_info = p; tp->md5sig_info = p;
sk->sk_route_caps &= ~NETIF_F_GSO_MASK; sk_nocaps_add(sk, NETIF_F_GSO_MASK);
} }
newkey = kmemdup(cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL); newkey = kmemdup(cmd.tcpm_key, cmd.tcpm_keylen, GFP_KERNEL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment