diff options
author | 2020-12-17 02:06:23 +0000 | |
---|---|---|
committer | 2020-12-17 02:06:23 +0000 | |
commit | 4a80bfc28fabab03857526271e1d6fb59a37b2a9 (patch) | |
tree | 67a03f586d2456139010915e927c47e7ac4de981 | |
parent | Remove echo headlines. (diff) | |
download | wireguard-openbsd-4a80bfc28fabab03857526271e1d6fb59a37b2a9.tar.xz wireguard-openbsd-4a80bfc28fabab03857526271e1d6fb59a37b2a9.zip |
Log reason a request is NAK'ed, as well as any problems sending the
NAK.
Suggestion & ok dlg@
-rw-r--r-- | usr.sbin/tftpd/tftpd.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/usr.sbin/tftpd/tftpd.c b/usr.sbin/tftpd/tftpd.c index 5581c4789db..75666c1c104 100644 --- a/usr.sbin/tftpd/tftpd.c +++ b/usr.sbin/tftpd/tftpd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: tftpd.c,v 1.44 2020/01/09 22:29:27 dlg Exp $ */ +/* $OpenBSD: tftpd.c,v 1.45 2020/12/17 02:06:23 krw Exp $ */ /* * Copyright (c) 2012 David Gwynne <dlg@uq.edu.au> @@ -1459,6 +1459,7 @@ nak(struct tftp_client *client, int error) struct tftphdr *tp; struct errmsg *pe; size_t length; + ssize_t rslt; tp = (struct tftphdr *)client->buf; tp->th_opcode = htons((u_short)ERROR); @@ -1477,8 +1478,14 @@ nak(struct tftp_client *client, int error) if (length > client->packet_size) length = client->packet_size; - if (send(client->sock, client->buf, length, 0) != length) - lwarn("nak"); + linfo("%s: nak: %s", getip(&client->ss), tp->th_msg); + + rslt = send(client->sock, client->buf, length, 0); + if (rslt == -1) + lwarn("%s: nak", getip(&client->ss)); + else if ((size_t)rslt != length) + lwarnx("%s: nak: sent %zd of %zu bytes", getip(&client->ss), + rslt, length); client_free(client); } |