From patchwork Mon Jun 21 10:38:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rong Zhang X-Patchwork-Id: 464898 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B17FCC48BE5 for ; Mon, 21 Jun 2021 10:38:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 98772600D1 for ; Mon, 21 Jun 2021 10:38:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230075AbhFUKlE (ORCPT ); Mon, 21 Jun 2021 06:41:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229804AbhFUKlD (ORCPT ); Mon, 21 Jun 2021 06:41:03 -0400 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 163F6C061574; Mon, 21 Jun 2021 03:38:48 -0700 (PDT) Received: by mail-qk1-x734.google.com with SMTP id q64so22784285qke.7; Mon, 21 Jun 2021 03:38:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wqPsiTjn3y34NIB0txQqm3bYJeUD7nTZah6VlYwyDvw=; b=fRNs9Zi/uOSEbURx7ABqOmbwARWVSC+180v2trvI2kOex9/oQ27tA0DkbHuk3l/EHt r//uDv/OPjfvnvcl8/dFZ3QfK6gEN0y0nLKvZLKZ8hS8PphiXnrBifC3jcKEbJN9dOrX Hm4tNTwPjkywwVmCYRVRGOureCrWwDxE7WqELo2Cdm5S0AthAAw8ECaC9hhJBbhhLmLI DqnCS3chMhsJtkV7RWtdhL7Y0+UKX+K3nrI+VR52LJ0+Xf3Cjl0mWp9pa0/FuSGhBmDN OyVyZSHLKKrjdrEmf91VX+aSa2i30vuP2SK+miGkxHbn7G4pRazjjgPrxRKlBF7cvc8m fLyg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=wqPsiTjn3y34NIB0txQqm3bYJeUD7nTZah6VlYwyDvw=; b=SUpBHuVSOxtJMKPLHNOgDXg/KV6s7b+lmmtsX0Fb3jPib6stDExrO1zmtGlVM3QKfj xaoNUXBe7Z5cm5kL7SqYbf7DU0+y8QcB40xiqVaEE/LA+Do5We/n9hC+8Kv3bAgwzAW4 LfubmTMdpEmuXQhITMOnuKTVGlL8NSBIjxmeKCB42akGhFuSk2azh0rFKEkPdIlV2/0o p1yb72Kk676Xtkhgox1UpRmTsbcynLwtVsE2VSKdxtVdvWPkRq8B9JgrKdgKNKnTKwOI q4GxNN3t+TOTtmHzgtIkDK+ThMSGd0p2Jsp7kDLUukqM0g6AQfrV1dC8EUv4kbFtzy2L tHYg== X-Gm-Message-State: AOAM530RKyjEMCTitGCwdbl4S16TX0Lv2pyjwopZ61+ZkK+KXVaKI3qC NBfAbYwYy/YUV3GE9VpcMeM= X-Google-Smtp-Source: ABdhPJzEHDMzYkCX84hBARARNxsv87s7p5D0N2hRoR9/criB4+J8tMwOUsEUpQgnAGCQc4MHl9Unog== X-Received: by 2002:a37:46c2:: with SMTP id t185mr20561684qka.466.1624271927300; Mon, 21 Jun 2021 03:38:47 -0700 (PDT) Received: from localhost.localdomain (email.nillco.net. [139.177.202.100]) by smtp.gmail.com with ESMTPSA id q25sm2149031qkm.33.2021.06.21.03.38.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 03:38:46 -0700 (PDT) From: Rong Zhang To: davem@davemloft.net, kuznet@ms2.inr.ac.ru, jmorris@namei.org, yoshfuji@linux-ipv6.org, kaber@trash.net Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Rong Zhang Subject: [PATCH] tcp: fix ipv6 tproxy doesn't work on kernel 4.4.x Date: Mon, 21 Jun 2021 18:38:29 +0800 Message-Id: <20210621103829.506112-1-ulin0208@gmail.com> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org Not only in tcp_v4_init_req() but also in tcp_v6_init_req() need to initialize no_srccheck, otherwise ipv6 tproxy doesn't work. So move it before init_req(). Signed-off-by: Rong Zhang --- net/ipv4/tcp_input.c | 1 + net/ipv4/tcp_ipv4.c | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/net/ipv4/tcp_input.c b/net/ipv4/tcp_input.c index 0919183b003f..e2bfcb30564d 100644 --- a/net/ipv4/tcp_input.c +++ b/net/ipv4/tcp_input.c @@ -6360,6 +6360,7 @@ int tcp_conn_request(struct request_sock_ops *rsk_ops, tmp_opt.tstamp_ok = tmp_opt.saw_tstamp; tcp_openreq_init(req, &tmp_opt, skb, sk); + inet_rsk(req)->no_srccheck = inet_sk(sk)->transparent; /* Note: tcp_v6_init_req() might override ir_iif for link locals */ inet_rsk(req)->ir_iif = sk->sk_bound_dev_if; diff --git a/net/ipv4/tcp_ipv4.c b/net/ipv4/tcp_ipv4.c index 3826745a160e..91c7a76f3bb3 100644 --- a/net/ipv4/tcp_ipv4.c +++ b/net/ipv4/tcp_ipv4.c @@ -1206,7 +1206,6 @@ static void tcp_v4_init_req(struct request_sock *req, sk_rcv_saddr_set(req_to_sk(req), ip_hdr(skb)->daddr); sk_daddr_set(req_to_sk(req), ip_hdr(skb)->saddr); - ireq->no_srccheck = inet_sk(sk_listener)->transparent; RCU_INIT_POINTER(ireq->ireq_opt, tcp_v4_save_options(skb)); }