From 54ff5e9b020784226f1a40038a50cedd785085a1 Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Fri, 11 May 2018 07:34:24 -0400 Subject: [PATCH] bgpd: Cleanup messages from getsockopt The handling of the return codes for getsockopt was slightly wrong. getsockopt returns -1 on error and errno is set. What to do with the return code at that point is dependent on what sockopt you are asking about. In this case status holds the error returned for SO_ERROR. Signed-off-by: Donald Sharp --- bgpd/bgp_fsm.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_fsm.c b/bgpd/bgp_fsm.c index a11a4f78f7..a22feaec84 100644 --- a/bgpd/bgp_fsm.c +++ b/bgpd/bgp_fsm.c @@ -1256,7 +1256,8 @@ static int bgp_connect_check(struct thread *thread) /* If getsockopt is fail, this is fatal error. */ if (ret < 0) { - zlog_info("can't get sockopt for nonblocking connect"); + zlog_info("can't get sockopt for nonblocking connect: %d(%s)", + errno, safe_strerror(errno)); BGP_EVENT_ADD(peer, TCP_fatal_error); return -1; } @@ -1267,8 +1268,8 @@ static int bgp_connect_check(struct thread *thread) return 1; } else { if (bgp_debug_neighbor_events(peer)) - zlog_debug("%s [Event] Connect failed (%s)", peer->host, - safe_strerror(errno)); + zlog_debug("%s [Event] Connect failed %d(%s)", + peer->host, status, safe_strerror(status)); BGP_EVENT_ADD(peer, TCP_connection_open_failed); return 0; }