From patchwork Wed Oct 16 10:04:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Forissier X-Patchwork-Id: 835797 Delivered-To: patch@linaro.org Received: by 2002:a5d:6804:0:b0:37d:45d0:187 with SMTP id w4csp346457wru; Wed, 16 Oct 2024 03:05:35 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCVDiCHync0Pw4uBOZiBiOz63W4y2G2bbcLNo4cBQKHnoxlmEkr3gRsjilu12KluLStOJr+5dw==@linaro.org X-Google-Smtp-Source: AGHT+IGaltxlVign4DPJpunGMAwoyONw7vZHMISHLyI66tJ4ammG/cJGYWDU9nJcTjPdmxgwpwZ1 X-Received: by 2002:a05:6e02:1389:b0:3a2:6d54:33df with SMTP id e9e14a558f8ab-3a3dbe7bcc1mr26377265ab.4.1729073135428; Wed, 16 Oct 2024 03:05:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1729073135; cv=none; d=google.com; s=arc-20240605; b=kSR0Fb/d0WabnZNPQUAqfUzgR7+1GjbqOCRPvH7HtJ3sJ2NuGN0U5gVZmqespZUfy4 usLSDKfr5ZKWxVQQo/33T4rUxoAV2nUXv452aX+OCkRs2SoRwD1NkUoq3ONwCBH9abJc t1tWwL7lxMuIAMyp78S6GDZ2lCpCANSSLRkNnbVOUjnU5KKAhTKR86Ee4bX+H4ipSGBo udcDUkdUhYz7U8RZkIIQUPgLIShVgza+GVuuGVb2tnOZRtlIQWSH6AgoSsWegCz2uifn dwNFQBkvJ8z2u+bxU/Up7f5p7ORcAg5epMizdjwX9L03OT6DiU8dQZuVW23AlY5Tq8fh PZMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=faheA9ipuCMxyKpZyBroaFBcMuTa6BH6eUOSG4QJjNo=; fh=ThdVVZAeTRhYRIsitiRafY870JZ08RRoQKK9619Vak0=; b=VAUu06mgSN8rgG0VFJH5deMlDu/5U2MtC6hY7qHtCFDtBl5f4XX9vjHh8qASLc2msu pdxsSMpNa4JABMnTnkkRAU1p4sqbxlnYAdQBT3q3CB1dSKv/qa82Tp/5kDt7rXt2wME/ 6RPFZ/35XUnpRVaFxjxhBVQ63XMOhFab57ChUHpOQxO5wWV3bA/mEMrgbdT8fPqcRFbl 58Kp0lBP/V2bCkhhtShZAYyq69H2pjz1aKms7QW5mPC5dBSmY3BZUXyuD5H21iuIISzg DCmxRfGPSL9T3/4rc7NwezdPAow5TJvAhfpLsBzDZ7EO2izGvPKXyavei+9/iQ0NvWqr g5QQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Iqcmbf1i; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id 8926c6da1cb9f-4dbecce0e69si1491021173.161.2024.10.16.03.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 03:05:35 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Iqcmbf1i; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org; dara=neutral header.i=@linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7A2EF88FED; Wed, 16 Oct 2024 12:05:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="Iqcmbf1i"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 9ABB68900B; Wed, 16 Oct 2024 12:05:03 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-lf1-x12a.google.com (mail-lf1-x12a.google.com [IPv6:2a00:1450:4864:20::12a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 48FCC88FF1 for ; Wed, 16 Oct 2024 12:04:56 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=jerome.forissier@linaro.org Received: by mail-lf1-x12a.google.com with SMTP id 2adb3069b0e04-539f8490856so3392520e87.2 for ; Wed, 16 Oct 2024 03:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1729073095; x=1729677895; darn=lists.denx.de; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=faheA9ipuCMxyKpZyBroaFBcMuTa6BH6eUOSG4QJjNo=; b=Iqcmbf1iKDzvEvw/v8jhyQRJ090j9hxCOjyg8nX4rxF89o1kwSG7Z6g7E5H5zOqeH9 C0/a68sd6erL7iGPfn3bfQpmxgq/E/aZCuQqwPG29Y4qVQlOQikrONvOO893r+lUVF9p f1wWgISPWlQAe+YARKVnd3xWfeN8ThqGmFeQP0gj6drITkyQ1VYWArTHVg9BT3cEx6nD Df8EGnzQDgifvcdHv/VxmbrX2jYKufGNt33MauYREnQbrxr2UutcF+JkKqz4a89KcSyh xO8FLbw4cUV4NzTKI35f/rEFdS/cXn8jBbQuKGGAKw90w/RcaK7FLvJSDxihN/mabWed BP1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729073095; x=1729677895; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=faheA9ipuCMxyKpZyBroaFBcMuTa6BH6eUOSG4QJjNo=; b=ViclFH3Idnq9l9KTCaeUI0w4KTtWnQ5YtGatDG3qFUfTVKQ/fF0ONo8UzwRzQm/UTY EAnj6nXl17x2LtFkn4sbIvhi/KoUL9nRyyRh/XfphVh3A4nsJ7OssOfOX5yICbJ9u0j0 xfVggMoWujrf5o5+YxyjNiR5hkHh7LAlEVChXOTY7QB0NoGzyudyMEwycRYpZg3iWeYn 6L3fmBNedB9DdaFLaC/s8AiRpkE0Ze9rBiFCzbsaTzlMahZPTKDLY7DeG3A8eEuzcKGX St9lUeG4koApo1tlzhyYkUROqZTb6QlZw70S41RYrH8o6u+1cqGYlK7PuETems4LC90H DByQ== X-Gm-Message-State: AOJu0YzjFeXPBPDIEWSGVC8TCfvKOnGqFzIAKG2zOILcoFX34cLUBgBG Ny0YbbUrykGOjINM2uPxe6XarhvFxm/G2wU1H0tHX8/cdJ8Q7hmGbxaEL4MWhr1yeLF9BRLQGy9 5Xb6oqbQW X-Received: by 2002:a05:6512:114f:b0:535:6992:f2cb with SMTP id 2adb3069b0e04-539da586e45mr8919786e87.42.1729073095199; Wed, 16 Oct 2024 03:04:55 -0700 (PDT) Received: from builder.. ([2a01:e0a:3cb:7bb0:6417:8cf6:a7f7:ee38]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4313f56f241sm44634515e9.22.2024.10.16.03.04.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 16 Oct 2024 03:04:54 -0700 (PDT) From: Jerome Forissier To: u-boot@lists.denx.de Cc: Ilias Apalodimas , Javier Tia , Raymond Mao , Maxim Uvarov , Tim Harvey , Anton Antonov , Jerome Forissier , Tom Rini Subject: [PATCH v13 10/21] net: lwip: tftp: bind to TFTP port only when in server mode Date: Wed, 16 Oct 2024 12:04:04 +0200 Message-Id: <5484ceb32b3ddbe7cafd997a45cfddec5c8acbbd.1729070678.git.jerome.forissier@linaro.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean The TFTP app should not bind to the TFTP server port when configured as a client. Instead, the local port should be chosen from the dynamic range (49152 ~ 65535) so that if the application is stopped and started again, the remote server will not consider the new packets as part of the same context (which would cause an error since a new RRQ would be unexpected). Submitted upstream: https://savannah.nongnu.org/patch/?10480 Signed-off-by: Jerome Forissier Reviewed-by: Ilias Apalodimas --- lib/lwip/lwip/src/apps/tftp/tftp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/lib/lwip/lwip/src/apps/tftp/tftp.c b/lib/lwip/lwip/src/apps/tftp/tftp.c index ddfdbfc0c1b..74fc1fbe586 100644 --- a/lib/lwip/lwip/src/apps/tftp/tftp.c +++ b/lib/lwip/lwip/src/apps/tftp/tftp.c @@ -454,10 +454,12 @@ tftp_init_common(u8_t mode, const struct tftp_context *ctx) return ERR_MEM; } - ret = udp_bind(pcb, IP_ANY_TYPE, TFTP_PORT); - if (ret != ERR_OK) { - udp_remove(pcb); - return ret; + if (mode == LWIP_TFTP_MODE_SERVER) { + ret = udp_bind(pcb, IP_ANY_TYPE, TFTP_PORT); + if (ret != ERR_OK) { + udp_remove(pcb); + return ret; + } } tftp_state.handle = NULL;