From patchwork Thu Oct 3 15:46:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsOpcsO0bWUgRm9yaXNzaWVy?= X-Patchwork-Id: 832412 Delivered-To: patch@linaro.org Received: by 2002:adf:8b52:0:b0:367:895a:4699 with SMTP id v18csp353717wra; Thu, 3 Oct 2024 08:47:11 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX2jMZWBGI8xtAmZM8S1wgiHnR+mvfcZ9FzaUvPvEbfjXkWs1wGrdjvVR1IjiyyE2FpVK0+Mw==@linaro.org X-Google-Smtp-Source: AGHT+IEtGjAx2mwvWaufkGE/M2EwUrFMoPRjgVwX4XWLqWc4LI5d+BzAV5aRew7ipGVh7Wi5mFnL X-Received: by 2002:a05:6602:340d:b0:82c:d843:edcc with SMTP id ca18e2360f4ac-834d8518081mr664150939f.11.1727970430747; Thu, 03 Oct 2024 08:47:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727970430; cv=none; d=google.com; s=arc-20240605; b=WusdEmWUZ00Rw9Sj5L19XQVCldgDI2lQhq51LUQrmcMuSLRk/cL1oXwHpCbtixTXEC BKWmwCGRAuol2JFsFBRd9XWm78R8N0aZwYUAjb65BR0N93aSwNXeUrOcfK3Fd5rYgr8J DRmP3TBtSI/dHb5gG/AzzdLkp4y0RbrlcUKIXOJTBsrTvlbcT0bGSCyfof7fpy+cdoRP uuF40FM/2IlDqCvzsKAcmRTptX6F+PF1pimv3XbZVwfHORRjisL0eUliFiuVsSC1BUsa QaNzL38KvO0k6xwXlNsiRjhmQFHo3mQfYjuk13wrJ6KoCfbCgMrWJxkgsu+G1W+Jl+MR h3Cw== 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=wj69R6ikNoWeeLXnoHmRr+jR91T4/HWFHpytBi3xnWU=; fh=ThdVVZAeTRhYRIsitiRafY870JZ08RRoQKK9619Vak0=; b=On39KJBpslDvuzeSv5m6ydMV+M3ztvH8AckhfNE/I7yQrxHsL/phnAR64tqbpB1Y41 /bP+ZRTFpPyd+GzgISW7b+7sGg/ZbrKc4dqp6/0ZigQCWzM34Im6pJrdXhVPIiRaA7Uq xdvHzlqIb7Cawpz8ukaugLZUItHc1RMS5cdQWgWBLiqRIQ7opO+Dd675PNeePFJm7+s9 4IJAzzbhEb3vUXmO2yIWywn5QhDeGohZwf5AkSN/xD1wE12UfY3Ns3zG/JPp+cE5+Jtr lZu23+jRY6I5eGDLINe4EQ97qD1WObZNh/FhJ452nQclOOPGIcCN+0/nOj94g6nSyap5 MAOQ==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=xRLOKtI7; 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 ca18e2360f4ac-834efe3bff6si69781139f.90.2024.10.03.08.47.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2024 08:47:10 -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=xRLOKtI7; 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 40619884DB; Thu, 3 Oct 2024 17:47:09 +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="xRLOKtI7"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 1F88487FED; Thu, 3 Oct 2024 17:47:08 +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-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) (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 8B4C288E3F for ; Thu, 3 Oct 2024 17:47: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=jerome.forissier@linaro.org Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-37ce18b042fso895452f8f.1 for ; Thu, 03 Oct 2024 08:47:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1727970424; x=1728575224; 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=wj69R6ikNoWeeLXnoHmRr+jR91T4/HWFHpytBi3xnWU=; b=xRLOKtI7cVGwe6nnE5tty4sTG8JmMgti3zSDIAxagzr1lBZ6NCMlRCNRtA4PE3XMxW YXCV1M0KD+h3l/mFZQBRwfdk88EhtxTPfe5aYgPCP43VdK2OVc4hRsP1pvqz8IGOAb8s ixnXXnqx4D0PfAuctsKz78mbUsIz2z+WJuY0uApMI3Dz4Ftx9LQX/y+i0ubGiNyRluF8 G1HEBmTC6AZRUhXyaeivMwUwpRISM41H1J9ijX95AiRWix1YSQn5JABp5otDMT4Dywjk 7ABvHFYXX1/w49KgaBbhp01TgOKoKT9AauI//o/m000aZ4uQUzL4EzEIzRAali3nXB3u zpRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727970424; x=1728575224; 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=wj69R6ikNoWeeLXnoHmRr+jR91T4/HWFHpytBi3xnWU=; b=nwU6+qfWlWcuA0g7OTBvNVI0sKiAIkLO5dgg43bqNRVr8lPto4ToFMJFTzm9B11dN3 310En4J7y1uTyKyPwmKQMgjSP9WZitQ9qdYCCANRg05hLNdd4AipjthZ+BNz5ADsMHBG dlga8+TtlRw+HwlnYXlCzY4XOJKB+pTJVKpc30YqPZn1Z2oZJEYyj/oE16Hf9W09/YzI 4Vq20Tu8IMpaZuxDjFGkTf0WuEgRCQOOMVC+dcCIFe1Mzp0uZUTpbviv3fxMa5+wL3KI aQVWcGmSeGsylJjgF6TrNLqASnlqaTp0iFB9edEzbs3GDD0RTwGtI/qlpzB4QSMRJJfA Rzmg== X-Gm-Message-State: AOJu0Yzhr0M8Lan7q4wpnL930MciCgvbWA3uglTVCiDB5OiReq5/ozFP l6CCMOg3kr/VHLPsaTnZ8ReAlq7u3NGulqoN9oTBlXgLeVIoaUn7Ln3JOQbkDJPTNGi5vPHUHYS f0M9uupDd X-Received: by 2002:a5d:464f:0:b0:37c:d23f:e464 with SMTP id ffacd0b85a97d-37cfba0694fmr4393669f8f.38.1727970424248; Thu, 03 Oct 2024 08:47:04 -0700 (PDT) Received: from builder.. ([2a01:e0a:3cb:7bb0:d888:7a58:deed:47d6]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-37d08245059sm1541748f8f.55.2024.10.03.08.47.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Oct 2024 08:47:02 -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 v11 14/29] lwip: tftp: bind to TFTP port only when in server mode Date: Thu, 3 Oct 2024 17:46:18 +0200 Message-Id: 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). 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;