Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ldpd: changes for code maintainability #13742

Merged
merged 1 commit into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions ldpd/control.c
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,7 @@ static void control_accept(struct event *thread)
*/
if (errno == ENFILE || errno == EMFILE)
accept_pause();
else if (errno != EWOULDBLOCK && errno != EINTR &&
errno != ECONNABORTED)
else if (errno != EWOULDBLOCK && errno != EINTR && errno != ECONNABORTED)
log_warn("%s: accept", __func__);
return;
}
Expand Down Expand Up @@ -192,8 +191,7 @@ static void control_dispatch_imsg(struct event *thread)

c->iev.ev_read = NULL;

if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) ||
n == 0) {
if (((n = imsg_read(&c->iev.ibuf)) == -1 && errno != EAGAIN) || n == 0) {
control_close(fd);
return;
}
Expand All @@ -217,12 +215,10 @@ static void control_dispatch_imsg(struct event *thread)
/* ignore */
break;
case IMSG_CTL_SHOW_INTERFACE:
if (imsg.hdr.len == IMSG_HEADER_SIZE +
sizeof(ifidx)) {
if (imsg.hdr.len == IMSG_HEADER_SIZE + sizeof(ifidx)) {
memcpy(&ifidx, imsg.data, sizeof(ifidx));
ldpe_iface_ctl(c, ifidx);
imsg_compose_event(&c->iev, IMSG_CTL_END, 0,
0, -1, NULL, 0);
imsg_compose_event(&c->iev, IMSG_CTL_END, 0, 0, -1, NULL, 0);
}
break;
case IMSG_CTL_SHOW_DISCOVERY:
Expand All @@ -242,8 +238,7 @@ static void control_dispatch_imsg(struct event *thread)
ldpe_nbr_ctl(c);
break;
case IMSG_CTL_CLEAR_NBR:
if (imsg.hdr.len != IMSG_HEADER_SIZE +
sizeof(struct ctl_nbr))
if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(struct ctl_nbr))
break;

nbr_clear_ctl(imsg.data);
Expand All @@ -255,8 +250,7 @@ static void control_dispatch_imsg(struct event *thread)
/* ignore */
break;
default:
log_debug("%s: error handling imsg %d", __func__,
imsg.hdr.type);
log_debug("%s: error handling imsg %d", __func__, imsg.hdr.type);
break;
}
imsg_free(&imsg);
Expand Down
9 changes: 3 additions & 6 deletions ldpd/ldp_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ ldp_vty_debug(struct vty *vty, const char *negate, const char *type_str,
DEBUG_ON(zebra, LDP_DEBUG_ZEBRA);
}

main_imsg_compose_both(IMSG_DEBUG_UPDATE, &ldp_debug,
sizeof(ldp_debug));
main_imsg_compose_both(IMSG_DEBUG_UPDATE, &ldp_debug, sizeof(ldp_debug));

return (CMD_SUCCESS);
}
Expand All @@ -119,13 +118,11 @@ ldp_vty_show_debugging(struct vty *vty)
if (LDP_DEBUG(labels, LDP_DEBUG_LABELS))
vty_out (vty, " LDP labels debugging is on\n");
if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV_ALL))
vty_out (vty,
" LDP detailed messages debugging is on (inbound)\n");
vty_out (vty, " LDP detailed messages debugging is on (inbound)\n");
else if (LDP_DEBUG(msg, LDP_DEBUG_MSG_RECV))
vty_out (vty," LDP messages debugging is on (inbound)\n");
if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND_ALL))
vty_out (vty,
" LDP detailed messages debugging is on (outbound)\n");
vty_out (vty, " LDP detailed messages debugging is on (outbound)\n");
else if (LDP_DEBUG(msg, LDP_DEBUG_MSG_SEND))
vty_out (vty," LDP messages debugging is on (outbound)\n");
if (LDP_DEBUG(sync, LDP_DEBUG_SYNC))
Expand Down
12 changes: 4 additions & 8 deletions ldpd/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ vlog(int pri, const char *fmt, va_list ap)
switch (ldpd_process) {
case PROC_LDE_ENGINE:
vsnprintfrr(buf, sizeof(buf), fmt, ap);
lde_imsg_compose_parent_sync(IMSG_LOG, pri, buf,
strlen(buf) + 1);
lde_imsg_compose_parent_sync(IMSG_LOG, pri, buf, strlen(buf) + 1);
break;
case PROC_LDP_ENGINE:
vsnprintfrr(buf, sizeof(buf), fmt, ap);
ldpe_imsg_compose_parent_sync(IMSG_LOG, pri, buf,
strlen(buf) + 1);
ldpe_imsg_compose_parent_sync(IMSG_LOG, pri, buf, strlen(buf) + 1);
break;
case PROC_MAIN:
vzlog(pri, fmt, ap);
Expand Down Expand Up @@ -121,15 +119,13 @@ void
fatal(const char *emsg)
{
if (emsg == NULL)
logit(LOG_CRIT, "fatal in %s: %s", log_procname,
strerror(errno));
logit(LOG_CRIT, "fatal in %s: %s", log_procname, strerror(errno));
else
if (errno)
logit(LOG_CRIT, "fatal in %s: %s: %s",
log_procname, emsg, strerror(errno));
else
logit(LOG_CRIT, "fatal in %s: %s",
log_procname, emsg);
logit(LOG_CRIT, "fatal in %s: %s", log_procname, emsg);

exit(1);
}
Expand Down
6 changes: 2 additions & 4 deletions ldpd/logmsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ log_addr(int af, const union ldpd_addr *addr)
switch (af) {
case AF_INET:
round = (round + 1) % NUM_LOGS;
if (inet_ntop(AF_INET, &addr->v4, buf[round],
sizeof(buf[round])) == NULL)
if (inet_ntop(AF_INET, &addr->v4, buf[round], sizeof(buf[round])) == NULL)
return ("???");
return (buf[round]);
case AF_INET6:
Expand Down Expand Up @@ -166,8 +165,7 @@ log_hello_src(const struct hello_source *src)

switch (src->type) {
case HELLO_LINK:
snprintf(buf, sizeof(buf), "iface %s",
src->link.ia->iface->name);
snprintf(buf, sizeof(buf), "iface %s", src->link.ia->iface->name);
break;
case HELLO_TARGETED:
snprintf(buf, sizeof(buf), "source %s",
Expand Down
6 changes: 2 additions & 4 deletions ldpd/pfkey.c
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,7 @@ pfkey_read(int sd, struct sadb_msg *h)
}

/* XXX: Only one message can be outstanding. */
if (hdr.sadb_msg_seq == sadb_msg_seq &&
hdr.sadb_msg_pid == pid) {
if (hdr.sadb_msg_seq == sadb_msg_seq && hdr.sadb_msg_pid == pid) {
if (h)
*h = hdr;
return (0);
Expand Down Expand Up @@ -412,8 +411,7 @@ pfkey_establish(struct nbr *nbr, struct nbr_params *nbrp)
{
switch (nbr->auth.method) {
case AUTH_MD5SIG:
strlcpy(nbr->auth.md5key, nbrp->auth.md5key,
sizeof(nbr->auth.md5key));
strlcpy(nbr->auth.md5key, nbrp->auth.md5key, sizeof(nbr->auth.md5key));
return pfkey_md5sig_establish(nbr, nbrp);
case AUTH_NONE:
return 0;
Expand Down