From nobody Fri Mar 10 13:29:17 2023 X-Original-To: dev-commits-src-all@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 4PY6Mx5pnMz3xWqs; Fri, 10 Mar 2023 13:29:17 +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 4PY6Mx5KnWz3R4b; Fri, 10 Mar 2023 13:29:17 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678454957; 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=jKe3OQThoOONygio5tZ1DT7n6yLAA7y4oOdQJr9pC8A=; b=lldpAKQJXQQpiEBTKX1H+cVcQio12dg3e/Ctxb73Z4T7GvwVTfyfeptJCrXsIkRlBHKEnn uuUtwTbZwADdWnTxoskhbV//DkDhCA2lzv+RxyZnCLd+E1fddBoVIHw5tysJ/20a2AFjYX 1fkoT/ow0HtaoNTQBZzioW9ekamNifp5xKTVXyPMH7TdlE3mSD4JWQO+FP/uttL2Ly59QS zXPRM3rG8gxKgLDGYi16M+Q2JvOT2veKU/qZIHkh1Z69pRcQ7N1TEzkNUbokTKu2NwL4d2 3szwfOcBakogRlijfxPKv5WxYyKjec1e2+LGQbhCP4O6Y/m0my9OV++N2s7iYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1678454957; 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=jKe3OQThoOONygio5tZ1DT7n6yLAA7y4oOdQJr9pC8A=; b=REeZxaRKMRhI+NH14qiL6Nr0YmYzaV0JiUFPvSD0LpkHhauzkhw9i4MXg4/l5GilWyjv/x ED14ESfemPRm+VoN78OfK3D8tDrxdktc7qnVYH1HHroJpQuQcoFi4cx+6xP8X/5jtexVGq EHCbFxT4GXZ4cqIuijdSR+pYR5zQG+OV5eA0dQITGOu1LOAiFXARouQEX33JIPIX5Li5U1 zwRM9Ns245edUBnz0X9r/IYgl1g1yvIxdTcCsr+89zupSe4ipmajTSmT/cKOWoxL1fbpcJ UJwQ620W2z+eRiNPDyQVv9BMDhmY0vAzlEGUe7dq8M681pBnkKqaWUWMRuMpJg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1678454957; a=rsa-sha256; cv=none; b=meGuSP4q6LeBrs2Uj8zVv5x9IvJkDayZok7ZzctMGMd4+JCnOFaomB9t5NIg/StSe3y2Ws HvcfxGjhm0dr8Sdjd+QJKXR/9BDm1ZhhqgapaMmKMEVFnP8OIz8xnmv1KxS81GswVHGh3p rOlWh0Xv2ZYdwgPMv8/SUTw/mP6vQwmGl5dbzUjJE8A1ExOZeH6zPAkdYGQ7KHrjnnzehy AwIlr4jB+9/9QkxTA9dBiqNGjLeNJIoMowZASBMbOAzmsfrgvKuRdPsxbA56Mp8fEulOmw oD2GDWYR4DshWGlsw8QtaZhnvj0Mn0iXLrv69AnAe+Y95TBT2H/jX9awBD9KKw== 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 4PY6Mx4QFmzqfn; Fri, 10 Mar 2023 13:29:17 +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 32ADTHVH090033; Fri, 10 Mar 2023 13:29:17 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 32ADTHjJ090031; Fri, 10 Mar 2023 13:29:17 GMT (envelope-from git) Date: Fri, 10 Mar 2023 13:29:17 GMT Message-Id: <202303101329.32ADTHjJ090031@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Dag-Erling=20Sm=C3=B8rgrav?= Subject: git: 36242fc0e56c - main - tftpd: Make the transfer functions return success / failure. List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: des X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 36242fc0e56c5657d5d70e01fd2cfe1d7e7e7123 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by des: URL: https://cgit.FreeBSD.org/src/commit/?id=36242fc0e56c5657d5d70e01fd2cfe1d7e7e7123 commit 36242fc0e56c5657d5d70e01fd2cfe1d7e7e7123 Author: Dag-Erling Smørgrav AuthorDate: 2023-03-10 13:24:23 +0000 Commit: Dag-Erling Smørgrav CommitDate: 2023-03-10 13:25:16 +0000 tftpd: Make the transfer functions return success / failure. Sponsored by: Klara, Inc. Reviewed by: markj Differential Revision: https://reviews.freebsd.org/D38957 --- libexec/tftpd/tftp-transfer.c | 38 ++++++++++++++++++-------------------- libexec/tftpd/tftp-transfer.h | 4 ++-- 2 files changed, 20 insertions(+), 22 deletions(-) diff --git a/libexec/tftpd/tftp-transfer.c b/libexec/tftpd/tftp-transfer.c index 19854f2cc180..91f87a1159a4 100644 --- a/libexec/tftpd/tftp-transfer.c +++ b/libexec/tftpd/tftp-transfer.c @@ -58,7 +58,7 @@ struct block_data { /* * Send a file via the TFTP data session. */ -void +int tftp_send(int peer, uint16_t *block, struct tftp_stats *ts) { struct tftphdr *rp; @@ -86,7 +86,7 @@ read_block: if (size < 0) { tftp_log(LOG_ERR, "read_file returned %d", size); send_error(peer, errno + 100); - goto abort; + return -1; } window[windowblock].size = size; windowblock++; @@ -100,7 +100,7 @@ read_block: tftp_log(LOG_ERR, "Cannot send DATA packet #%d, " "giving up", *block); - return; + return -1; } tftp_log(LOG_ERR, "Cannot send DATA packet #%d, trying again", @@ -117,7 +117,7 @@ read_block: tftp_log(LOG_ERR, "Timeout #%d send ACK %d " "giving up", acktry, *block); - return; + return -1; } tftp_log(LOG_WARNING, "Timeout #%d on ACK %d", @@ -130,7 +130,7 @@ read_block: "seek_file failed: %s", strerror(errno)); send_error(peer, errno + 100); - goto abort; + return -1; } *block = window[0].block; windowblock = 0; @@ -141,7 +141,7 @@ read_block: if (debug & DEBUG_SIMPLE) tftp_log(LOG_ERR, "Aborting: %s", rp_strerror(n_ack)); - goto abort; + return -1; } if (rp->th_opcode == ACK) { /* @@ -170,7 +170,7 @@ read_block: "seek_file failed: %s", strerror(errno)); send_error(peer, errno + 100); - goto abort; + return -1; } *block = window[0].block; windowblock = 0; @@ -202,7 +202,7 @@ read_block: "seek_file failed: %s", strerror(errno)); send_error(peer, errno + 100); - goto abort; + return -1; } *block = window[i + 1].block; windowblock = 0; @@ -232,8 +232,7 @@ read_block: } gettimeofday(&(ts->tstop), NULL); } while (size == segsize); -abort: - return; + return 0; } /* @@ -243,7 +242,7 @@ abort: * trying to figure out if we were receiving options or not. In * that case it is passed to this function. */ -void +int tftp_receive(int peer, uint16_t *block, struct tftp_stats *ts, struct tftphdr *firstblock, size_t fb_size) { @@ -268,7 +267,7 @@ tftp_receive(int peer, uint16_t *block, struct tftp_stats *ts, tftp_log(LOG_ERR, "Cannot send ACK packet #%d, " "giving up", *block); - return; + return -1; } tftp_log(LOG_ERR, "Cannot send ACK packet #%d, trying again", @@ -283,7 +282,7 @@ tftp_receive(int peer, uint16_t *block, struct tftp_stats *ts, if (fb_size != segsize) { write_close(); gettimeofday(&(ts->tstop), NULL); - return; + return 0; } } @@ -319,7 +318,7 @@ tftp_receive(int peer, uint16_t *block, struct tftp_stats *ts, tftp_log(LOG_ERR, "Timeout #%d on DATA block %d, " "giving up", retry, *block); - return; + return -1; } if (n_data == RP_TIMEOUT) { tftp_log(LOG_WARNING, @@ -334,7 +333,7 @@ tftp_receive(int peer, uint16_t *block, struct tftp_stats *ts, if (debug & DEBUG_SIMPLE) tftp_log(LOG_DEBUG, "Aborting: %s", rp_strerror(n_data)); - goto abort; + return -1; } if (rp->th_opcode == DATA) { ts->blocks++; @@ -395,7 +394,7 @@ tftp_receive(int peer, uint16_t *block, struct tftp_stats *ts, send_error(peer, errno + 100); else send_error(peer, ENOSPACE); - goto abort; + return -1; } } if (n_data != segsize) @@ -414,7 +413,7 @@ send_ack: tftp_log(LOG_ERR, "Cannot send ACK packet #%d, " "giving up", *block); - return; + return -1; } tftp_log(LOG_ERR, @@ -433,7 +432,7 @@ send_ack: /* Don't do late packet management for the client implementation */ if (acting_as_client) - return; + return 0; for (i = 0; ; i++) { n_data = receive_packet(peer, (char *)rp, pktsize, @@ -446,6 +445,5 @@ send_ack: send_ack(peer, *block); /* resend final ack */ } -abort: - return; + return 0; } diff --git a/libexec/tftpd/tftp-transfer.h b/libexec/tftpd/tftp-transfer.h index cc575ddd8774..0cedc4b937de 100644 --- a/libexec/tftpd/tftp-transfer.h +++ b/libexec/tftpd/tftp-transfer.h @@ -28,6 +28,6 @@ #include __FBSDID("$FreeBSD$"); -void tftp_send(int peer, uint16_t *block, struct tftp_stats *tp); -void tftp_receive(int peer, uint16_t *block, struct tftp_stats *tp, +int tftp_send(int peer, uint16_t *block, struct tftp_stats *tp); +int tftp_receive(int peer, uint16_t *block, struct tftp_stats *tp, struct tftphdr *firstblock, size_t fb_size);