From patchwork Wed Feb 12 13:13:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13971585 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qk1-f201.google.com (mail-qk1-f201.google.com [209.85.222.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0E32320E31E for ; Wed, 12 Feb 2025 13:13:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739366015; cv=none; b=Tr6Pxx6VA7Jz2oyBOqpWcZAi3AMdmxBN6JSBLm0WivZCkxanvY4AWHSOLyDJNeUGgsJfbLpKFBFfQUpGmKeIAy1j5XyPNAz6IZ1fMBti3jSn8lZkkLXi6eqa3KFwLwEXngcuGn+bmm9rwJJ4nOsAbyS8ycr+fSD5pS5ANzFAxzo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739366015; c=relaxed/simple; bh=yoh/UoF/t6i7/T/SmK22QBFx4z1Jil4Bph+7RqtEyW4=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lzuUN/pJRZh/+KeZMIUAr/Lu4oj35DxMTlYJ5EWAzVDlPHPnAwxqHGeLtO9qWHqSqQrXZj6BMZZ9pemahOcdzPttMC7zH8cz/nCHr2oBPtasPCM76VIfAwYEZSsJeMgZSUcb7ubcsxrngKq5Kekj28d3dKvQYCHStN6Rbir4I3M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=4d/Ghbzi; arc=none smtp.client-ip=209.85.222.201 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="4d/Ghbzi" Received: by mail-qk1-f201.google.com with SMTP id af79cd13be357-7c078ebcc7fso13022285a.1 for ; Wed, 12 Feb 2025 05:13:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739366013; x=1739970813; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=7XXzZgAcxEur3fQE0La9o0DqvjAxE2gRn70cTzuQdow=; b=4d/Ghbzi1wX3exqG65TUlWARnD7njEGZ5d5xJiQvXZn6WESDQgBkJXV+PIiuWs5UtZ zY1CodfGc4TsEdXFlKgNzQnMwjeLX3g4ru03dFQmisTYe4wgKVVzAVenRc2G+KXOB7xt yxZXb63fowqqExsqWp9S8HV2UYPvWxjJXoeKhGc8fX/vRTuoqCdsZbg8SJZBvY7bq/nG FWikBT7lI54U3tc0KsYdmn6AaZdZJFT8EDHSBajLT5O5Za8tQYAP2CoI/oYVSUV++hJY ownUOZxsioljAT/O3G2YFV6VEbFmC86UA4TRHtTFRHCnp0k90CG2JML5T/23OYYbGvbL gnTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739366013; x=1739970813; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=7XXzZgAcxEur3fQE0La9o0DqvjAxE2gRn70cTzuQdow=; b=hB06kvr0k1Y3pLcpMlE2Le1DhlktPrO+qGJDoDzXCxOYCkwoAVovTIUOjVm0nlSpUI JKOwfoHv6XaAIizUCxpWI8FmxGvhz44sqFEvKDOz4voCj32QOM89T+zQxV4nzUqSX0bY 4MJrDM+yLF3OX+b7oHgLlvTm1Y8OCC+77jJ8tEBduL+7pBCke3myi3zbzAXVgplGPyFy XNZQjw99wb02mZY0j7eSYJPwGMDq+wA1IJIsly0/5sMD6JHyDK6CO3TisSzoccitpNMr vqhPBBYZY97CidM3qgvcebvgWpvNzBHmK6+P5/IeSjxl9+jlzZckNXPLQ72CNWTp4yAy Z3yg== X-Gm-Message-State: AOJu0Yxap2AKtDh+gyYsBp/6X4+geCLYg5me0e/LEKcaK4EnG2SrrHt3 VJ32H4w2xCl+9Fvofvbg7WdptBhPIf6oWffpUcwagHQiwqzsIPssVPGUfyWzkWLwP9m+sgvApjS BIw/uw64k3w== X-Google-Smtp-Source: AGHT+IEQX4rSjr/kZRfC7zOwobfycARZ7d1ZgKpvD36rK+/gTb4XlM1yWBLA+AFPeD0xByqbAxzFxoAG7jwT3w== X-Received: from qkbea8.prod.google.com ([2002:a05:620a:4888:b0:7c0:6053:5dec]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:a05:620a:2b9a:b0:7c0:5807:d6 with SMTP id af79cd13be357-7c070798bebmr465099585a.57.1739366012950; Wed, 12 Feb 2025 05:13:32 -0800 (PST) Date: Wed, 12 Feb 2025 13:13:27 +0000 In-Reply-To: <20250212131328.1514243-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250212131328.1514243-1-edumazet@google.com> X-Mailer: git-send-email 2.48.1.502.g6dc24dfdaf-goog Message-ID: <20250212131328.1514243-2-edumazet@google.com> Subject: [PATCH net-next 1/2] inet: reduce inet_csk_clone_lock() indent level From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, Simon Horman , Neal Cardwell , Kuniyuki Iwashima , eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org Return early from inet_csk_clone_lock() if the socket allocation failed, to reduce the indentation level. Signed-off-by: Eric Dumazet Reviewed-by: Kuniyuki Iwashima --- net/ipv4/inet_connection_sock.c | 50 ++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 23 deletions(-) diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 2b7775b90a0907727fa3e4d04cfa77f6e76e82b0..1c00069552ccfbf8c0d0d91d14cf951a39711273 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -1237,39 +1237,43 @@ struct sock *inet_csk_clone_lock(const struct sock *sk, const gfp_t priority) { struct sock *newsk = sk_clone_lock(sk, priority); + struct inet_connection_sock *newicsk; - if (newsk) { - struct inet_connection_sock *newicsk = inet_csk(newsk); + if (!newsk) + return NULL; - inet_sk_set_state(newsk, TCP_SYN_RECV); - newicsk->icsk_bind_hash = NULL; - newicsk->icsk_bind2_hash = NULL; + newicsk = inet_csk(newsk); - inet_sk(newsk)->inet_dport = inet_rsk(req)->ir_rmt_port; - inet_sk(newsk)->inet_num = inet_rsk(req)->ir_num; - inet_sk(newsk)->inet_sport = htons(inet_rsk(req)->ir_num); + inet_sk_set_state(newsk, TCP_SYN_RECV); + newicsk->icsk_bind_hash = NULL; + newicsk->icsk_bind2_hash = NULL; - /* listeners have SOCK_RCU_FREE, not the children */ - sock_reset_flag(newsk, SOCK_RCU_FREE); + inet_sk(newsk)->inet_dport = inet_rsk(req)->ir_rmt_port; + inet_sk(newsk)->inet_num = inet_rsk(req)->ir_num; + inet_sk(newsk)->inet_sport = htons(inet_rsk(req)->ir_num); - inet_sk(newsk)->mc_list = NULL; + /* listeners have SOCK_RCU_FREE, not the children */ + sock_reset_flag(newsk, SOCK_RCU_FREE); - newsk->sk_mark = inet_rsk(req)->ir_mark; - atomic64_set(&newsk->sk_cookie, - atomic64_read(&inet_rsk(req)->ir_cookie)); + inet_sk(newsk)->mc_list = NULL; - newicsk->icsk_retransmits = 0; - newicsk->icsk_backoff = 0; - newicsk->icsk_probes_out = 0; - newicsk->icsk_probes_tstamp = 0; + newsk->sk_mark = inet_rsk(req)->ir_mark; + atomic64_set(&newsk->sk_cookie, + atomic64_read(&inet_rsk(req)->ir_cookie)); - /* Deinitialize accept_queue to trap illegal accesses. */ - memset(&newicsk->icsk_accept_queue, 0, sizeof(newicsk->icsk_accept_queue)); + newicsk->icsk_retransmits = 0; + newicsk->icsk_backoff = 0; + newicsk->icsk_probes_out = 0; + newicsk->icsk_probes_tstamp = 0; - inet_clone_ulp(req, newsk, priority); + /* Deinitialize accept_queue to trap illegal accesses. */ + memset(&newicsk->icsk_accept_queue, 0, + sizeof(newicsk->icsk_accept_queue)); + + inet_clone_ulp(req, newsk, priority); + + security_inet_csk_clone(newsk, req); - security_inet_csk_clone(newsk, req); - } return newsk; } EXPORT_SYMBOL_GPL(inet_csk_clone_lock); From patchwork Wed Feb 12 13:13:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 13971586 X-Patchwork-Delegate: kuba@kernel.org Received: from mail-qt1-f202.google.com (mail-qt1-f202.google.com [209.85.160.202]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 84C9C20E332 for ; Wed, 12 Feb 2025 13:13:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.202 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739366017; cv=none; b=tdvKy+d7ME6QOfFqmczIbRmugojjnldKqpvH0ZUuY4EhwkQmDzdWCc567oIO96dbrC/OSMFzYte0ULbfomYTGT4W6ixEIJrO4DuLPi3pQ1jX7Z/MOqR5aNpViGfSqx6NgkCe8qetz/vxWKAUmAVWRckH5HtOd6At4hfBOTSZLLM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1739366017; c=relaxed/simple; bh=VSUoxJXGe14tF3DdmTl+gVJ/A9/G9sdsIdw9GYj2Opk=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=lA35KAHUeywc+ea54lAtvnWkBOw5fDF/C8fNToMcOyQy5g5LqonfFVfI0Dd0vRP3yflC7n8A2joZwiwl0Qv3ela6RPmRJWxmSSawolWqIvsQLg3qLWNygD0dH8HBKzuhQUMLuJLOi63OvNANkeS6Re8XlYor+SkPYS2kA+0XVaI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=aVJgq2/I; arc=none smtp.client-ip=209.85.160.202 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--edumazet.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="aVJgq2/I" Received: by mail-qt1-f202.google.com with SMTP id d75a77b69052e-471b9ccf86dso5339321cf.3 for ; Wed, 12 Feb 2025 05:13:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1739366014; x=1739970814; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=2W3DSQyzKm60sxGI2lx2gpnMLFsJSreBDk/Uk4I4YC4=; b=aVJgq2/IsAQzDHzBLbM4lNS+bojlSkqEfXYVs/Iv0+/O6C3kXuwymgC+IQ/VIeyVuO FIFoyDUMiS6app9Aq0bx/ufzaZ55zvIJzFqeeeADvBI3nPCyY8RuFZT2y49NF5DA10ia YOzQBC+nFFvg9JJAVNaLmqi31EfPcI9U/di+RdDEw2mI2YLPA67AKDWx3xTE9g7J8C0j f2uroH+/SboXMG2v5/rd/wtlPbRzYZbN7WTkuA2proUcnPd9YKMibBLLrT5A6KFr4Jzu 8EAIeY86Q1TlBRNejlFNktsDJC++WMR9u7AyyZxQtFhmMgmSAxsvGQbBePWjNHEM6nPT G3nA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1739366014; x=1739970814; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2W3DSQyzKm60sxGI2lx2gpnMLFsJSreBDk/Uk4I4YC4=; b=bNKH8fhMuk+4LNovYNm/DSQFB0clBri3KFVMAfMt76UlF1OFB+nn50pARzgm1KdrVs nplUWWMZdwdnDUV0H6bizp2KW88gUU1BD3wnrqSAiZ1CjiT4tuSSYx9iVRB6LB19Kh4o QsCowXqNswNxcQmK/z0JxlI38FYUssRjp7xnBb/8JE15kQLUxIuf700V5c8Jznnk2pZR pAEajPIGsJ4r2Z1w1Atz/vLhatztuE6WSFWpd+7XkVLeK9Ok1a0E0Xo4UE5ahZqtK0HM 1aoZzNlCl1mh2Gb5OmXPhKYZ9joQuqrfOLxo31Fe2D+u0gk5GvqeaJ21dikJUI4QnNcK cAng== X-Gm-Message-State: AOJu0Yyoi1avV74WqO/2igPw2bh9jmXIkSAgjdIF4EmJTDqY3OOI/p6j qVHpukVjbi306OA18H6Am9eUZRe8wZWwvkGnoqBmgPTp2ONb/SjPBe9vKHfT+sl2bjG4tq2XFGd mvW6neK6hQw== X-Google-Smtp-Source: AGHT+IH7WhbTMh/KV2r/stnCMVK8cjhZs3C3XLs2c6E/w3i5qSbcPXlCUeqwfQjPe0GHvCE4J4671kktAcpYtw== X-Received: from qtbfb16.prod.google.com ([2002:a05:622a:4810:b0:471:919a:e569]) (user=edumazet job=prod-delivery.src-stubby-dispatcher) by 2002:ac8:5fd2:0:b0:471:959e:bc13 with SMTP id d75a77b69052e-471afecce0amr39155491cf.40.1739366014366; Wed, 12 Feb 2025 05:13:34 -0800 (PST) Date: Wed, 12 Feb 2025 13:13:28 +0000 In-Reply-To: <20250212131328.1514243-1-edumazet@google.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20250212131328.1514243-1-edumazet@google.com> X-Mailer: git-send-email 2.48.1.502.g6dc24dfdaf-goog Message-ID: <20250212131328.1514243-3-edumazet@google.com> Subject: [PATCH net-next 2/2] inet: consolidate inet_csk_clone_lock() From: Eric Dumazet To: "David S . Miller" , Jakub Kicinski , Paolo Abeni Cc: netdev@vger.kernel.org, Simon Horman , Neal Cardwell , Kuniyuki Iwashima , eric.dumazet@gmail.com, Eric Dumazet X-Patchwork-Delegate: kuba@kernel.org Current inet_sock_set_state trace from inet_csk_clone_lock() is missing many details : ... sock:inet_sock_set_state: family=AF_INET6 protocol=IPPROTO_TCP \ sport=4901 dport=0 \ saddr=127.0.0.6 daddr=0.0.0.0 \ saddrv6=:: daddrv6=:: \ oldstate=TCP_LISTEN newstate=TCP_SYN_RECV Only the sport gives the listener port, no other parts of the n-tuple are correct. In this patch, I initialize relevant fields of the new socket before calling inet_sk_set_state(newsk, TCP_SYN_RECV). We now have a trace including all the source/destination bits. ... sock:inet_sock_set_state: family=AF_INET6 protocol=IPPROTO_TCP \ sport=4901 dport=47648 \ saddr=127.0.0.6 daddr=127.0.0.6 \ saddrv6=2002:a05:6830:1f85:: daddrv6=2001:4860:f803:65::3 \ oldstate=TCP_LISTEN newstate=TCP_SYN_RECV Signed-off-by: Eric Dumazet Reviewed-by: Kuniyuki Iwashima --- net/dccp/ipv4.c | 3 --- net/dccp/ipv6.c | 9 +++------ net/ipv4/inet_connection_sock.c | 24 ++++++++++++++++++++---- net/ipv4/tcp_ipv4.c | 4 ---- net/ipv6/tcp_ipv6.c | 8 ++------ 5 files changed, 25 insertions(+), 23 deletions(-) diff --git a/net/dccp/ipv4.c b/net/dccp/ipv4.c index be515ba821e2d4d6a7bca973b5e7c2363a2f13cc..bfa529a54acab6abd279c9e4a600e699e8904d8a 100644 --- a/net/dccp/ipv4.c +++ b/net/dccp/ipv4.c @@ -426,9 +426,6 @@ struct sock *dccp_v4_request_recv_sock(const struct sock *sk, newinet = inet_sk(newsk); ireq = inet_rsk(req); - sk_daddr_set(newsk, ireq->ir_rmt_addr); - sk_rcv_saddr_set(newsk, ireq->ir_loc_addr); - newinet->inet_saddr = ireq->ir_loc_addr; RCU_INIT_POINTER(newinet->inet_opt, rcu_dereference(ireq->ireq_opt)); newinet->mc_index = inet_iif(skb); newinet->mc_ttl = ip_hdr(skb)->ttl; diff --git a/net/dccp/ipv6.c b/net/dccp/ipv6.c index d6649246188d72b3df6c74750779b7aa5910dcb7..39ae9d89d7d43fc8730dd2ec20d6e1cf72d20bf3 100644 --- a/net/dccp/ipv6.c +++ b/net/dccp/ipv6.c @@ -365,6 +365,9 @@ static int dccp_v6_conn_request(struct sock *sk, struct sk_buff *skb) ireq = inet_rsk(req); ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr; ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr; + ireq->ir_rmt_addr = LOOPBACK4_IPV6; + ireq->ir_loc_addr = LOOPBACK4_IPV6; + ireq->ireq_family = AF_INET6; ireq->ir_mark = inet_request_mark(sk, skb); @@ -504,10 +507,7 @@ static struct sock *dccp_v6_request_recv_sock(const struct sock *sk, memcpy(newnp, np, sizeof(struct ipv6_pinfo)); - newsk->sk_v6_daddr = ireq->ir_v6_rmt_addr; newnp->saddr = ireq->ir_v6_loc_addr; - newsk->sk_v6_rcv_saddr = ireq->ir_v6_loc_addr; - newsk->sk_bound_dev_if = ireq->ir_iif; /* Now IPv6 options... @@ -546,9 +546,6 @@ static struct sock *dccp_v6_request_recv_sock(const struct sock *sk, dccp_sync_mss(newsk, dst_mtu(dst)); - newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6; - newinet->inet_rcv_saddr = LOOPBACK4_IPV6; - if (__inet_inherit_port(sk, newsk) < 0) { inet_csk_prepare_forced_close(newsk); dccp_done(newsk); diff --git a/net/ipv4/inet_connection_sock.c b/net/ipv4/inet_connection_sock.c index 1c00069552ccfbf8c0d0d91d14cf951a39711273..bf9ce0c196575910b4b03fca13001979d4326297 100644 --- a/net/ipv4/inet_connection_sock.c +++ b/net/ipv4/inet_connection_sock.c @@ -1238,19 +1238,33 @@ struct sock *inet_csk_clone_lock(const struct sock *sk, { struct sock *newsk = sk_clone_lock(sk, priority); struct inet_connection_sock *newicsk; + struct inet_request_sock *ireq; + struct inet_sock *newinet; if (!newsk) return NULL; newicsk = inet_csk(newsk); + newinet = inet_sk(newsk); + ireq = inet_rsk(req); - inet_sk_set_state(newsk, TCP_SYN_RECV); newicsk->icsk_bind_hash = NULL; newicsk->icsk_bind2_hash = NULL; - inet_sk(newsk)->inet_dport = inet_rsk(req)->ir_rmt_port; - inet_sk(newsk)->inet_num = inet_rsk(req)->ir_num; - inet_sk(newsk)->inet_sport = htons(inet_rsk(req)->ir_num); + newinet->inet_dport = ireq->ir_rmt_port; + newinet->inet_num = ireq->ir_num; + newinet->inet_sport = htons(ireq->ir_num); + + newsk->sk_bound_dev_if = ireq->ir_iif; + + newsk->sk_daddr = ireq->ir_rmt_addr; + newsk->sk_rcv_saddr = ireq->ir_loc_addr; + newinet->inet_saddr = ireq->ir_loc_addr; + +#if IS_ENABLED(CONFIG_IPV6) + newsk->sk_v6_daddr = ireq->ir_v6_rmt_addr; + newsk->sk_v6_rcv_saddr = ireq->ir_v6_loc_addr; +#endif /* listeners have SOCK_RCU_FREE, not the children */ sock_reset_flag(newsk, SOCK_RCU_FREE); @@ -1270,6 +1284,8 @@ struct sock *inet_csk_clone_lock(const struct sock *sk, memset(&newicsk->icsk_accept_queue, 0, sizeof(newicsk->icsk_accept_queue)); + inet_sk_set_state(newsk, TCP_SYN_RECV); + inet_clone_ulp(req, newsk, priority); security_inet_csk_clone(newsk, req); diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index d1fd2128ac6cce9b845b1f8d278a194c511db87b..56949eb289ce330448b771f91d5c3130d6b2ac96 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1769,10 +1769,6 @@ struct sock *tcp_v4_syn_recv_sock(const struct sock *sk, struct sk_buff *skb, newtp = tcp_sk(newsk); newinet = inet_sk(newsk); ireq = inet_rsk(req); - sk_daddr_set(newsk, ireq->ir_rmt_addr); - sk_rcv_saddr_set(newsk, ireq->ir_loc_addr); - newsk->sk_bound_dev_if = ireq->ir_iif; - newinet->inet_saddr = ireq->ir_loc_addr; inet_opt = rcu_dereference(ireq->ireq_opt); RCU_INIT_POINTER(newinet->inet_opt, inet_opt); newinet->mc_index = inet_iif(skb); diff --git a/net/ipv6/tcp_ipv6.c b/net/ipv6/tcp_ipv6.c index 2debdf085a3b4d2452b2b316cb5368507b17efc8..a806082602985fd351c5184f52dc3011c71540a9 100644 --- a/net/ipv6/tcp_ipv6.c +++ b/net/ipv6/tcp_ipv6.c @@ -798,6 +798,8 @@ static void tcp_v6_init_req(struct request_sock *req, ireq->ir_v6_rmt_addr = ipv6_hdr(skb)->saddr; ireq->ir_v6_loc_addr = ipv6_hdr(skb)->daddr; + ireq->ir_rmt_addr = LOOPBACK4_IPV6; + ireq->ir_loc_addr = LOOPBACK4_IPV6; /* So that link locals have meaning */ if ((!sk_listener->sk_bound_dev_if || l3_slave) && @@ -1451,10 +1453,7 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff * ip6_dst_store(newsk, dst, NULL, NULL); - newsk->sk_v6_daddr = ireq->ir_v6_rmt_addr; newnp->saddr = ireq->ir_v6_loc_addr; - newsk->sk_v6_rcv_saddr = ireq->ir_v6_loc_addr; - newsk->sk_bound_dev_if = ireq->ir_iif; /* Now IPv6 options... @@ -1507,9 +1506,6 @@ static struct sock *tcp_v6_syn_recv_sock(const struct sock *sk, struct sk_buff * tcp_initialize_rcv_mss(newsk); - newinet->inet_daddr = newinet->inet_saddr = LOOPBACK4_IPV6; - newinet->inet_rcv_saddr = LOOPBACK4_IPV6; - #ifdef CONFIG_TCP_MD5SIG l3index = l3mdev_master_ifindex_by_index(sock_net(sk), ireq->ir_iif);