summaryrefslogtreecommitdiff
path: root/bfdd/control.c
diff options
context:
space:
mode:
Diffstat (limited to 'bfdd/control.c')
-rw-r--r--bfdd/control.c54
1 files changed, 25 insertions, 29 deletions
diff --git a/bfdd/control.c b/bfdd/control.c
index ae6f5a3e79..3b954c64f8 100644
--- a/bfdd/control.c
+++ b/bfdd/control.c
@@ -86,13 +86,13 @@ static int sock_set_nonblock(int fd)
flags = fcntl(fd, F_GETFL, 0);
if (flags == -1) {
- log_warning("%s: fcntl F_GETFL: %s", __func__, strerror(errno));
+ zlog_warn("%s: fcntl F_GETFL: %s", __func__, strerror(errno));
return -1;
}
flags |= O_NONBLOCK;
if (fcntl(fd, F_SETFL, flags) == -1) {
- log_warning("%s: fcntl F_SETFL: %s", __func__, strerror(errno));
+ zlog_warn("%s: fcntl F_SETFL: %s", __func__, strerror(errno));
return -1;
}
@@ -116,20 +116,20 @@ int control_init(const char *path)
sd = socket(AF_UNIX, SOCK_STREAM, PF_UNSPEC);
if (sd == -1) {
- log_error("%s: socket: %s", __func__, strerror(errno));
+ zlog_err("%s: socket: %s", __func__, strerror(errno));
return -1;
}
umval = umask(0);
if (bind(sd, (struct sockaddr *)&sun_, sizeof(sun_)) == -1) {
- log_error("%s: bind: %s", __func__, strerror(errno));
+ zlog_err("%s: bind: %s", __func__, strerror(errno));
close(sd);
return -1;
}
umask(umval);
if (listen(sd, SOMAXCONN) == -1) {
- log_error("%s: listen: %s", __func__, strerror(errno));
+ zlog_err("%s: listen: %s", __func__, strerror(errno));
close(sd);
return -1;
}
@@ -164,12 +164,11 @@ int control_accept(struct thread *t)
csock = accept(sd, NULL, 0);
if (csock == -1) {
- log_warning("%s: accept: %s", __func__, strerror(errno));
+ zlog_warn("%s: accept: %s", __func__, strerror(errno));
return 0;
}
- if (control_new(csock) == NULL)
- close(csock);
+ control_new(csock);
bglobal.bg_csockev = NULL;
thread_add_read(master, control_accept, NULL, sd, &bglobal.bg_csockev);
@@ -334,8 +333,6 @@ static int control_queue_enqueue(struct bfd_control_socket *bcs,
struct bfd_control_buffer *bcb;
bcq = control_queue_new(bcs);
- if (bcq == NULL)
- return -1;
bcb = &bcq->bcq_bcb;
bcb->bcb_left = sizeof(struct bfd_control_msg) + ntohl(bcm->bcm_length);
@@ -440,7 +437,7 @@ static int control_read(struct thread *t)
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)
goto schedule_next_read;
- log_warning("%s: read: %s", __func__, strerror(errno));
+ zlog_warn("%s: read: %s", __func__, strerror(errno));
control_free(bcs);
return 0;
}
@@ -448,15 +445,15 @@ static int control_read(struct thread *t)
/* Validate header fields. */
plen = ntohl(bcm.bcm_length);
if (plen < 2) {
- log_debug("%s: client closed due small message length: %d",
- __func__, bcm.bcm_length);
+ zlog_debug("%s: client closed due small message length: %d",
+ __func__, bcm.bcm_length);
control_free(bcs);
return 0;
}
if (bcm.bcm_ver != BMV_VERSION_1) {
- log_debug("%s: client closed due bad version: %d", __func__,
- bcm.bcm_ver);
+ zlog_debug("%s: client closed due bad version: %d", __func__,
+ bcm.bcm_ver);
control_free(bcs);
return 0;
}
@@ -470,8 +467,8 @@ static int control_read(struct thread *t)
bcb->bcb_buf = XMALLOC(MTYPE_BFDD_NOTIFICATION,
sizeof(bcm) + bcb->bcb_left + 1);
if (bcb->bcb_buf == NULL) {
- log_warning("%s: not enough memory for message size: %zu",
- __func__, bcb->bcb_left);
+ zlog_warn("%s: not enough memory for message size: %zu",
+ __func__, bcb->bcb_left);
control_free(bcs);
return 0;
}
@@ -492,7 +489,7 @@ skip_header:
if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR)
goto schedule_next_read;
- log_warning("%s: read: %s", __func__, strerror(errno));
+ zlog_warn("%s: read: %s", __func__, strerror(errno));
control_free(bcs);
return 0;
}
@@ -521,8 +518,8 @@ skip_header:
break;
default:
- log_debug("%s: unhandled message type: %d", __func__,
- bcb->bcb_bcm->bcm_type);
+ zlog_debug("%s: unhandled message type: %d", __func__,
+ bcb->bcb_bcm->bcm_type);
control_response(bcs, bcb->bcb_bcm->bcm_id, BCM_RESPONSE_ERROR,
"invalid message type");
break;
@@ -559,7 +556,7 @@ static int control_write(struct thread *t)
return 0;
}
- log_warning("%s: write: %s", __func__, strerror(errno));
+ zlog_warn("%s: write: %s", __func__, strerror(errno));
control_free(bcs);
return 0;
}
@@ -656,8 +653,7 @@ static int notify_add_cb(struct bfd_peer_cfg *bpc, void *arg)
if (bs == NULL)
return -1;
- if (control_notifypeer_new(bcs, bs) == NULL)
- return -1;
+ control_notifypeer_new(bcs, bs);
/* Notify peer status. */
_control_notify(bcs, bs);
@@ -723,8 +719,8 @@ static void control_response(struct bfd_control_socket *bcs, uint16_t id,
/* Generate JSON response. */
jsonstr = config_response(status, error);
if (jsonstr == NULL) {
- log_warning("%s: config_response: failed to get JSON str",
- __func__);
+ zlog_warn("%s: config_response: failed to get JSON str",
+ __func__);
return;
}
@@ -753,8 +749,8 @@ static void _control_notify(struct bfd_control_socket *bcs,
/* Generate JSON response. */
jsonstr = config_notify(bs);
if (jsonstr == NULL) {
- log_warning("%s: config_notify: failed to get JSON str",
- __func__);
+ zlog_warn("%s: config_notify: failed to get JSON str",
+ __func__);
return;
}
@@ -816,8 +812,8 @@ static void _control_notify_config(struct bfd_control_socket *bcs,
/* Generate JSON response. */
jsonstr = config_notify_config(op, bs);
if (jsonstr == NULL) {
- log_warning("%s: config_notify_config: failed to get JSON str",
- __func__);
+ zlog_warn("%s: config_notify_config: failed to get JSON str",
+ __func__);
return;
}