From nobody Thu Jan 13 09:48:59 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 407A212D1DBD; Thu, 13 Jan 2022 09:49:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JZKQ41HGKz4jFX; Thu, 13 Jan 2022 09:49:00 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642067340; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=knXomLcBmPJ83feqnz7IRLn3CK09sHJvhUwTsOx6x3s=; b=U8C/V/zXbJ5tybKOgGgPj/CYl2Cr8PPPQBbZdMCd+D0IrFY6Lx2Byg451grPgJImmxo6Nj 9dU1VUqZdmhHr+XKJue9lv9enh9nqq9Kz7DwH4cDA+VX2JbuOJ2myjng4ZkdnpPD4ibr0j ufiPdUhKOoVxeqw92q9XdP/A1kZVyeu7ItuTQQgdq69fwzD0xOWg8QAq/wLKsjKKIJ5HEQ LIXvn08yWw+aznyUtu2uafy1DU8EHAyJ/zDWeMHlAeM9yNiwZUkoIfkl+uhNmmpdKUcOjH EoXtXLCiVT6GSpuxP24OB2CAhnxRaVKfBKRZi62eOD1Tb8rqvbIA4eoU6EPydw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 0CF7B1E3C5; Thu, 13 Jan 2022 09:49:00 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 20D9mxU9095799; Thu, 13 Jan 2022 09:48:59 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20D9mxv2095798; Thu, 13 Jan 2022 09:48:59 GMT (envelope-from git) Date: Thu, 13 Jan 2022 09:48:59 GMT Message-Id: <202201130948.20D9mxv2095798@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Emmanuel Vadot Subject: git: 62c7a7774fc7 - stable/13 - loader: tftp: Don't error on tftp error 0 List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: manu X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 62c7a7774fc73ba7d3bec16346c7e0522ceafb40 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642067340; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=knXomLcBmPJ83feqnz7IRLn3CK09sHJvhUwTsOx6x3s=; b=Wc6xmjflIApayzd1g62SzjZDPT13dnMkhX6SbSmxOLiq9tps7nEabm/QBpo3em1YtUcoEV Yse08Cj19A+vY89rq8ZxAnww9xxTiGTfwTYri4vNoogQe/7vYfvoX+aYZFxgp9lMjAVU2b T9B64iU5t4npIlw93qrxZ1mKrErVvsy1594fIw5fgEjS6sRSwSfLHJvHEWiB/bH2vBgou+ LHeCfYz4+KBbusoV2cvgT8NEgNv9E4jaEF/4W8ORW/5tnTyaidnZKAebW1rb/BCMLE+EcN LhbDiM4L2Ut8DU2s3nl0GQEdtcoVdTqtclekF4s7CrlADbPRN3p5xzfCLagV1A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642067340; a=rsa-sha256; cv=none; b=qch+/PXpETz9clQHH5BSS/HjRTadnQbHz+1hPcHfW8olTchnWZEcwhHUXaya8r+ssryKkr nAEW7ZExbylIk7pS+EKUgs8yDlQwDNNnJwWTbdM6uNJaur0R+Hi1rXd5QGJ1k3d02ay13s 050+eyIXXpl0R/ZYWiugnEdut/nJw2ja5BoCmagG9VqHryAiv9X03b9+HTqO/8AFiX1pQT Hgon3XhHEvPnk3k1M+nyoqTf3dDSfW1l3LrVW4V+ym70Bl/T65fOsXO86hW9gza7bzc7du 3QRvp3OspUynqY7hmaiBu6Qh6J8AWxzlbmazhm7pQPBx9kiI+lezb3w1qFq8nQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by manu: URL: https://cgit.FreeBSD.org/src/commit/?id=62c7a7774fc73ba7d3bec16346c7e0522ceafb40 commit 62c7a7774fc73ba7d3bec16346c7e0522ceafb40 Author: Emmanuel Vadot AuthorDate: 2021-12-08 15:18:49 +0000 Commit: Emmanuel Vadot CommitDate: 2022-01-13 07:55:22 +0000 loader: tftp: Don't error on tftp error 0 tftp-hpa sends NAK with tftp error set to 0 when trying to get a directory and this is the first thing that loader tries to do and this make it hangs. Reviewed by: imp, tsoome MFC after: 2 weeks Sponsored by: Beckhoff Automation GmbH & Co. KG Differential Revision: https://reviews.freebsd.org/D33406 (cherry picked from commit bf07f2f8623d5e29e814b9dc49a0cdff920778c3) --- stand/libsa/tftp.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/stand/libsa/tftp.c b/stand/libsa/tftp.c index 22e03ab58da1..6cfa670b6e22 100644 --- a/stand/libsa/tftp.c +++ b/stand/libsa/tftp.c @@ -121,7 +121,7 @@ struct tftprecv_extra { #define TFTP_MAX_ERRCODE EOPTNEG static const int tftperrors[TFTP_MAX_ERRCODE + 1] = { - 0, /* ??? */ + 0, /* NAK */ ENOENT, EPERM, ENOSPC, @@ -187,6 +187,7 @@ recvtftp(struct iodesc *d, void **pkt, void **payload, time_t tleft, struct tftphdr *t; void *ptr = NULL; ssize_t len; + int tftp_error; errno = 0; extra = recv_extra; @@ -233,16 +234,20 @@ recvtftp(struct iodesc *d, void **pkt, void **payload, time_t tleft, return (got); } case ERROR: - if ((unsigned)ntohs(t->th_code) > TFTP_MAX_ERRCODE) { - printf("illegal tftp error %d\n", ntohs(t->th_code)); + tftp_error = ntohs(t->th_code); + if ((unsigned)tftp_error > TFTP_MAX_ERRCODE) { + printf("illegal tftp error %d\n", tftp_error); errno = EIO; } else { #ifdef TFTP_DEBUG - printf("tftp-error %d\n", ntohs(t->th_code)); + printf("tftp-error %d\n", tftp_error); #endif - errno = tftperrors[ntohs(t->th_code)]; + errno = tftperrors[tftp_error]; } free(ptr); + /* If we got a NAK return 0, it's usually a directory */ + if (tftp_error == 0) + return (0); return (-1); case OACK: { struct udphdr *uh;