mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-07 15:01:44 +00:00
tcp: improve fastopen icmp handling
If a fast open socket is already accepted by the user, it should be treated like a connected socket to record the ICMP error in sk_softerr, so the user can fetch it. Do that in both tcp_v4_err and tcp_v6_err. Also refactor the sequence window check to improve readability (e.g., there were two local variables named 'req'). Signed-off-by: Yuchung Cheng <ycheng@google.com> Signed-off-by: Daniel Lee <longinus00@gmail.com> Signed-off-by: Jerry Chu <hkchu@google.com> Acked-by: Neal Cardwell <ncardwell@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
843f4a55e3
commit
0a672f7413
2 changed files with 31 additions and 26 deletions
|
@ -340,7 +340,8 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
|
|||
struct sock *sk;
|
||||
int err;
|
||||
struct tcp_sock *tp;
|
||||
__u32 seq;
|
||||
struct request_sock *fastopen;
|
||||
__u32 seq, snd_una;
|
||||
struct net *net = dev_net(skb->dev);
|
||||
|
||||
sk = inet6_lookup(net, &tcp_hashinfo, &hdr->daddr,
|
||||
|
@ -371,8 +372,11 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
|
|||
|
||||
tp = tcp_sk(sk);
|
||||
seq = ntohl(th->seq);
|
||||
/* XXX (TFO) - tp->snd_una should be ISN (tcp_create_openreq_child() */
|
||||
fastopen = tp->fastopen_rsk;
|
||||
snd_una = fastopen ? tcp_rsk(fastopen)->snt_isn : tp->snd_una;
|
||||
if (sk->sk_state != TCP_LISTEN &&
|
||||
!between(seq, tp->snd_una, tp->snd_nxt)) {
|
||||
!between(seq, snd_una, tp->snd_nxt)) {
|
||||
NET_INC_STATS_BH(net, LINUX_MIB_OUTOFWINDOWICMPS);
|
||||
goto out;
|
||||
}
|
||||
|
@ -436,8 +440,13 @@ static void tcp_v6_err(struct sk_buff *skb, struct inet6_skb_parm *opt,
|
|||
goto out;
|
||||
|
||||
case TCP_SYN_SENT:
|
||||
case TCP_SYN_RECV: /* Cannot happen.
|
||||
It can, it SYNs are crossed. --ANK */
|
||||
case TCP_SYN_RECV:
|
||||
/* Only in fast or simultaneous open. If a fast open socket is
|
||||
* is already accepted it is treated as a connected one below.
|
||||
*/
|
||||
if (fastopen && fastopen->sk == NULL)
|
||||
break;
|
||||
|
||||
if (!sock_owned_by_user(sk)) {
|
||||
sk->sk_err = err;
|
||||
sk->sk_error_report(sk); /* Wake people up to see the error (see connect in sock.c) */
|
||||
|
@ -1760,6 +1769,7 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
|
|||
const struct inet_sock *inet = inet_sk(sp);
|
||||
const struct tcp_sock *tp = tcp_sk(sp);
|
||||
const struct inet_connection_sock *icsk = inet_csk(sp);
|
||||
struct fastopen_queue *fastopenq = icsk->icsk_accept_queue.fastopenq;
|
||||
|
||||
dest = &sp->sk_v6_daddr;
|
||||
src = &sp->sk_v6_rcv_saddr;
|
||||
|
@ -1802,7 +1812,9 @@ static void get_tcp6_sock(struct seq_file *seq, struct sock *sp, int i)
|
|||
jiffies_to_clock_t(icsk->icsk_ack.ato),
|
||||
(icsk->icsk_ack.quick << 1) | icsk->icsk_ack.pingpong,
|
||||
tp->snd_cwnd,
|
||||
tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh
|
||||
sp->sk_state == TCP_LISTEN ?
|
||||
(fastopenq ? fastopenq->max_qlen : 0) :
|
||||
(tcp_in_initial_slowstart(tp) ? -1 : tp->snd_ssthresh)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue