From patchwork Wed Oct 9 14:49:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Forissier X-Patchwork-Id: 833954 Delivered-To: patch@linaro.org Received: by 2002:adf:a1de:0:b0:37d:45d0:187 with SMTP id v30csp149864wrv; Wed, 9 Oct 2024 07:50:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCUKr5DFj8aP5JJJB0Rf8LsOecT/vlgsYhKoA6bbZqRzVYW/ZpvaEA7nUGN3oZxYMMUL9xsFqA==@linaro.org X-Google-Smtp-Source: AGHT+IEbc/+6crozN2D6FVV5pdIwY0+EatR6QvtStgkjdxe6gX/iE41uhQ8DTex64D3v+zHOk4sR X-Received: by 2002:a05:600c:444c:b0:42f:310f:de9 with SMTP id 5b1f17b1804b1-430ccf43d90mr18163915e9.15.1728485452651; Wed, 09 Oct 2024 07:50:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1728485452; cv=none; d=google.com; s=arc-20240605; b=WZ5v4X9vv1EXqWct+dZmjNKr4IXDsqIjix4uMDqjZkSf/3Tucrx9/Q6QFQ3QmJImUV gXR1b3gBanDCo6cNyW4kIQjsTgJjRrGRzsTWGMKcvuGVtuD3bS8HBnXh0INmezl6txg6 RH4ECrG10yJ4X13DtwOD8tEBBAyt4SFzeyPpOBG/wvO+dlRWX4oloufpG72oYEHHpmt0 FSWuZcpzLzOhSupod1CtX1OEesvXfASw2OTCvsCCzA7LCtO4DObu4gInCU/CEwmPHGiH TIaYm18LHwykyid5lWG99LOlwJ+mhOAm6EC41yu8Tn2FcTaOln49oRZq7PtssDEDz7Lk CnPA== 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=IV6l5iD74CaaMXLznyw/+b283aXrHS+vvl88PcmLnsX4mTUlIOYGbNUjlBl0Nd/5wz imYNg+Cry9p2mnLdVXOaTlpQrBV83Y5/3hBdvwBfQllIAdcjHEpYyoYUfcJWhRhlAxUD 5SuMOFCbZKxuKPlLaxEb+lfoh5eCgZHcANie11EjGt3PjuMeeBn/qhjT8fcwytGmQ9gJ C55hFR3ZzcgVjsdueEW3Sca1l8jyxzxk3CPBc/qUokJlF93kCzZlVE3DiKZ5WxJzuIr/ +By4jUtEUrwDzgRId9clpqVc14Cfc+wKRSGdQfHIYbRAMwsnuHPJWIi7H17xnBn5+pLR YOEQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bgRws23l; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id 5b1f17b1804b1-430d59b118esi8577015e9.144.2024.10.09.07.50.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 07:50:52 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bgRws23l; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 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 5F45D88E7A; Wed, 9 Oct 2024 16:50:30 +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="bgRws23l"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 24E5288EA7; Wed, 9 Oct 2024 16:50:29 +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-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) (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 0D57988FB7 for ; Wed, 9 Oct 2024 16:50:26 +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-wr1-x42e.google.com with SMTP id ffacd0b85a97d-37d47b38336so60592f8f.3 for ; Wed, 09 Oct 2024 07:50:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1728485425; x=1729090225; 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=bgRws23lKbR75/ovfck3D53lnjMIZykTyboy7LIWDdxyrAtUPodr5CD0yicZvezROH x4jG62dnyLi6XDeAnXtYJYGZp/ojRORuC8h1Br4cDMdZ1GslhekvqdYZQAKi/uX87HAL bQdzxSHAALxK3J9v4UoDRA6gibGLIrky7VHS0cA1ejhi7xNt+Ut3Q3gNYiTFVZrcfamM 2b3Ivyl3YRSGBQZGhUwwC80RKzHClLQpu/T4ot4CV41ennT7WllWKn/Zf2F+CSDPiZgy gRI/226IY4+RD1HCgA6pV5lMV3EuxEbC+pwR1KtUCOMB8QAcQUx3Mwnt9URnpNBNtNaL oe2A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728485425; x=1729090225; 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=BS9XVipVq0vQVxeM7vPVxD/gNn+SKre5oGiBLoGEvDsr3iGH0KJJVlim+guEx06sFn 42JnaSAJ6YkWf+eb6nL8b5mWGpNrsfbeS9Hy2Tqgz8Gn9aYnwltHVBnzQlE3VJSxC8ul mcAS3WQcU11xT5MmVJsRJtwKc4XgdDXmLnevouGFiNuwLvCxglirK0h9EkfFKQ/szHbO 1mPtVSGARAkRpNjwWBiqBfN87RkNENV6U7c+WHFVYc/SP2NwSjfIdVWLNDpUsra8zOfv Bx6LQlbvsjzT5oT9BBWjJ9PaEDtvjLUVbY//j8Twwrnj0qvuvlRecxYb5FVNYldwnWsQ NY8g== X-Gm-Message-State: AOJu0YyqOP2iEDWVdWgWGrU8CjsmX/avmV+rsBKXYIcALKdLS0l2dX/j 5QZy9PlyjAPZcdsilH01T/F0+Lj5544+0K6q5pzNrIKv2sfCyu1CbiQOXgBhqd285DM1+/XAR2H lNjIOYTmL X-Received: by 2002:adf:ed46:0:b0:37d:3196:76c1 with SMTP id ffacd0b85a97d-37d3a9f218bmr1544111f8f.25.1728485424669; Wed, 09 Oct 2024 07:50:24 -0700 (PDT) Received: from builder.. ([2a01:e0a:3cb:7bb0:9b46:2ad8:5153:1163]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d1691b5ddsm10700957f8f.47.2024.10.09.07.50.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Oct 2024 07:50:24 -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 v12 10/21] net: lwip: tftp: bind to TFTP port only when in server mode Date: Wed, 9 Oct 2024 16:49:51 +0200 Message-Id: <1cd53e876ddbc1aac935987aadcba566843abb67.1728482473.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;