Skip to content

Commit fae6ef8

Browse files
nealcardwelldavem330
authored andcommitted
net: tcp: move sk_rx_dst_set call after tcp_create_openreq_child()
This commit removes the sk_rx_dst_set calls from tcp_create_openreq_child(), because at that point the icsk_af_ops field of ipv6_mapped TCP sockets has not been set to its proper final value. Instead, to make sure we get the right sk_rx_dst_set variant appropriate for the address family of the new connection, we have tcp_v{4,6}_syn_recv_sock() directly call the appropriate function shortly after the call to tcp_create_openreq_child() returns. This also moves inet6_sk_rx_dst_set() to avoid a forward declaration with the new approach. Signed-off-by: Neal Cardwell <ncardwell@google.com> Reported-by: Artem Savkov <artem.savkov@gmail.com> Cc: Eric Dumazet <edumazet@google.com> Acked-by: Eric Dumazet <edumazet@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3de7a37 commit fae6ef8

3 files changed

Lines changed: 14 additions & 14 deletions

File tree

‎net/ipv4/tcp_ipv4.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,6 +1462,7 @@ struct sock *tcp_v4_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
14621462
goto exit_nonewsk;
14631463

14641464
newsk->sk_gso_type = SKB_GSO_TCPV4;
1465+
inet_sk_rx_dst_set(newsk, skb);
14651466

14661467
newtp = tcp_sk(newsk);
14671468
newinet = inet_sk(newsk);

‎net/ipv4/tcp_minisocks.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -387,8 +387,6 @@ struct sock *tcp_create_openreq_child(struct sock *sk, struct request_sock *req,
387387
struct tcp_sock *oldtp = tcp_sk(sk);
388388
struct tcp_cookie_values *oldcvp = oldtp->cookie_values;
389389

390-
newicsk->icsk_af_ops->sk_rx_dst_set(newsk, skb);
391-
392390
/* TCP Cookie Transactions require space for the cookie pair,
393391
* as it differs for each connection. There is no need to
394392
* copy any s_data_payload stored at the original socket.

‎net/ipv6/tcp_ipv6.c‎

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ static struct tcp_md5sig_key *tcp_v6_md5_do_lookup(struct sock *sk,
9494
}
9595
#endif
9696

97+
static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
98+
{
99+
struct dst_entry *dst = skb_dst(skb);
100+
const struct rt6_info *rt = (const struct rt6_info *)dst;
101+
102+
dst_hold(dst);
103+
sk->sk_rx_dst = dst;
104+
inet_sk(sk)->rx_dst_ifindex = skb->skb_iif;
105+
if (rt->rt6i_node)
106+
inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
107+
}
108+
97109
static void tcp_v6_hash(struct sock *sk)
98110
{
99111
if (sk->sk_state != TCP_CLOSE) {
@@ -1270,6 +1282,7 @@ static struct sock * tcp_v6_syn_recv_sock(struct sock *sk, struct sk_buff *skb,
12701282

12711283
newsk->sk_gso_type = SKB_GSO_TCPV6;
12721284
__ip6_dst_store(newsk, dst, NULL, NULL);
1285+
inet6_sk_rx_dst_set(newsk, skb);
12731286

12741287
newtcp6sk = (struct tcp6_sock *)newsk;
12751288
inet_sk(newsk)->pinet6 = &newtcp6sk->inet6;
@@ -1729,18 +1742,6 @@ static struct timewait_sock_ops tcp6_timewait_sock_ops = {
17291742
.twsk_destructor= tcp_twsk_destructor,
17301743
};
17311744

1732-
static void inet6_sk_rx_dst_set(struct sock *sk, const struct sk_buff *skb)
1733-
{
1734-
struct dst_entry *dst = skb_dst(skb);
1735-
const struct rt6_info *rt = (const struct rt6_info *)dst;
1736-
1737-
dst_hold(dst);
1738-
sk->sk_rx_dst = dst;
1739-
inet_sk(sk)->rx_dst_ifindex = skb->skb_iif;
1740-
if (rt->rt6i_node)
1741-
inet6_sk(sk)->rx_dst_cookie = rt->rt6i_node->fn_sernum;
1742-
}
1743-
17441745
static const struct inet_connection_sock_af_ops ipv6_specific = {
17451746
.queue_xmit = inet6_csk_xmit,
17461747
.send_check = tcp_v6_send_check,

0 commit comments

Comments
 (0)