From 5aa19dd3f40502525aab925703ad2665e4bfc810 Mon Sep 17 00:00:00 2001 From: Richard Cochran Date: Thu, 30 Apr 2020 06:20:17 -0700 Subject: [PATCH] port: Convey targeted forwarding errors to the caller. The port_forward_to() method clobbers the specific error code returned by the transport layer with -1. This patch lets the code preserve the specific error in question. Signed-off-by: Richard Cochran --- port.c | 6 ++++-- port.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/port.c b/port.c index 6104061..48fff1c 100644 --- a/port.c +++ b/port.c @@ -2737,8 +2737,10 @@ int port_forward_to(struct port *p, struct ptp_message *msg) { int cnt; cnt = transport_sendto(p->trp, &p->fda, TRANS_GENERAL, msg); - if (cnt <= 0) { - return -1; + if (cnt < 0) { + return cnt; + } else if (!cnt) { + return -EIO; } port_stats_inc_tx(p, msg); return 0; diff --git a/port.h b/port.h index a45a7a4..e347e36 100644 --- a/port.h +++ b/port.h @@ -94,7 +94,7 @@ int port_forward(struct port *p, struct ptp_message *msg); * Forward a message on a given port to the address stored in the message. * @param port A pointer previously obtained via port_open(). * @param msg The message to send. Must be in network byte order. - * @return Zero on success, non-zero otherwise. + * @return Zero on success, negative errno value otherwise. */ int port_forward_to(struct port *p, struct ptp_message *msg);