From 3326001c75db96155f07920d4f596c25dcd1b750 Mon Sep 17 00:00:00 2001 From: pcarana Date: Fri, 13 Mar 2020 12:30:02 -0600 Subject: [PATCH] Update some PDU logs, stop sending PDUs on reset exchange error --- src/notify.c | 10 +++------- src/rtr/pdu.c | 24 ++++++++++++------------ src/rtr/pdu_handler.c | 3 +++ src/rtr/pdu_sender.c | 5 +++-- 4 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/notify.c b/src/notify.c index c9f79fbe..6d8ee3c5 100644 --- a/src/notify.c +++ b/src/notify.c @@ -11,17 +11,13 @@ static int send_notify(struct client *client, void *arg) { serial_t *serial = arg; - int error; /* Send Serial Notify PDU */ - error = send_serial_notify_pdu(client->fd, client->rtr_version, + send_serial_notify_pdu(client->fd, client->rtr_version, *serial); - /* Error? Log it... */ - if (error) - pr_warn("Error code %d sending notify PDU to client.", error); - - return 0; /* ...but do not interrupt notify to other clients */ + /* Errors already logged, do not interrupt notify to other clients */ + return 0; } int diff --git a/src/rtr/pdu.c b/src/rtr/pdu.c index 4cf45338..327e1c8c 100644 --- a/src/rtr/pdu.c +++ b/src/rtr/pdu.c @@ -16,28 +16,28 @@ pdutype2str(enum pdu_type type) { switch (type) { case PDU_TYPE_SERIAL_NOTIFY: - return "Serial Notify"; + return "Serial Notify PDU"; case PDU_TYPE_SERIAL_QUERY: - return "Serial Query"; + return "Serial Query PDU"; case PDU_TYPE_RESET_QUERY: - return "Reset Query"; + return "Reset Query PDU"; case PDU_TYPE_CACHE_RESPONSE: - return "Cache Response"; + return "Cache Response PDU"; case PDU_TYPE_IPV4_PREFIX: - return "IPv4 Prefix"; + return "IPv4 Prefix PDU"; case PDU_TYPE_IPV6_PREFIX: - return "IPv6 Prefix"; + return "IPv6 Prefix PDU"; case PDU_TYPE_END_OF_DATA: - return "End of Data"; + return "End of Data PDU"; case PDU_TYPE_CACHE_RESET: - return "Cache Reset"; + return "Cache Reset PDU"; case PDU_TYPE_ROUTER_KEY: - return "Router Key"; + return "Router Key PDU"; case PDU_TYPE_ERROR_REPORT: - return "Error Report"; + return "Error Report PDU"; } - return "(unknown)"; + return "unknown PDU"; } static int @@ -128,7 +128,7 @@ pdu_load(int fd, struct sockaddr_storage *client_addr, if (log_debug_enabled()) { char buffer[INET6_ADDRSTRLEN]; - pr_debug("Received a %s PDU from %s.", + pr_debug("Received a %s from %s.", pdutype2str(header.pdu_type), sockaddr2str(client_addr, buffer)); } diff --git a/src/rtr/pdu_handler.c b/src/rtr/pdu_handler.c index f8350465..4edb858d 100644 --- a/src/rtr/pdu_handler.c +++ b/src/rtr/pdu_handler.c @@ -186,6 +186,9 @@ handle_reset_query_pdu(int fd, struct rtr_request const *request) case EAGAIN: err_pdu_send_internal_error(fd, args.version); return error; + default: + /* Any other error must stop sending more PDUs */ + return error; } return send_end_of_data_pdu(fd, args.version, current_serial); diff --git a/src/rtr/pdu_sender.c b/src/rtr/pdu_sender.c index edd7355a..01e2d7a4 100644 --- a/src/rtr/pdu_sender.c +++ b/src/rtr/pdu_sender.c @@ -31,11 +31,12 @@ send_response(int fd, uint8_t pdu_type, unsigned char *data, size_t data_len) { int error; - pr_debug("Sending %s PDU to client.", pdutype2str(pdu_type)); + pr_debug("Sending %s to client.", pdutype2str(pdu_type)); error = write(fd, data, data_len); if (error < 0) - return pr_errno(errno, "Error sending response"); + return pr_errno(errno, "Error sending %s to client.", + pdutype2str(pdu_type)); return 0; } -- 2.47.2