diff options
author | sri-mohan1 <sri.mohan@samsung.com> | 2023-05-06 16:22:34 +0200 |
---|---|---|
committer | sri-mohan1 <sri.mohan@samsung.com> | 2023-05-06 16:22:34 +0200 |
commit | 91cde6087d0af08ed2c2f91dc2f5afaf1ef12a59 (patch) | |
tree | a79c06da36c0d72febe27cfb114d8bd1868419ff /ldpd | |
parent | ldpd: changes for code maintainability (diff) | |
download | frr-91cde6087d0af08ed2c2f91dc2f5afaf1ef12a59.tar.xz frr-91cde6087d0af08ed2c2f91dc2f5afaf1ef12a59.zip |
ldpd: changes for code maintainability
these changes are for improving the code maintainability and readability
Signed-off-by: sri-mohan1 <sri.mohan@samsung.com>
Diffstat (limited to 'ldpd')
-rw-r--r-- | ldpd/ldpe.c | 59 |
1 files changed, 20 insertions, 39 deletions
diff --git a/ldpd/ldpe.c b/ldpd/ldpe.c index d3193b16d..e66b9e92d 100644 --- a/ldpd/ldpe.c +++ b/ldpd/ldpe.c @@ -257,8 +257,7 @@ ldpe_imsg_compose_lde(int type, uint32_t peerid, pid_t pid, void *data, { if (iev_lde->ibuf.fd == -1) return (0); - return (imsg_compose_event(iev_lde, type, peerid, pid, -1, - data, datalen)); + return (imsg_compose_event(iev_lde, type, peerid, pid, -1, data, datalen)); } /* ARGSUSED */ @@ -309,8 +308,7 @@ static void ldpe_dispatch_main(struct event *thread) switch (imsg.hdr.type) { case IMSG_IFSTATUS: - if (imsg.hdr.len != IMSG_HEADER_SIZE + - sizeof(struct kif)) + if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(struct kif)) fatalx("IFSTATUS imsg with wrong len"); kif = imsg.data; @@ -336,15 +334,13 @@ static void ldpe_dispatch_main(struct event *thread) } break; case IMSG_NEWADDR: - if (imsg.hdr.len != IMSG_HEADER_SIZE + - sizeof(struct kaddr)) + if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(struct kaddr)) fatalx("NEWADDR imsg with wrong len"); if_addr_add(imsg.data); break; case IMSG_DELADDR: - if (imsg.hdr.len != IMSG_HEADER_SIZE + - sizeof(struct kaddr)) + if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(struct kaddr)) fatalx("DELADDR imsg with wrong len"); if_addr_del(imsg.data); @@ -369,8 +365,7 @@ static void ldpe_dispatch_main(struct event *thread) iev_lde->ev_write = NULL; break; case IMSG_INIT: - if (imsg.hdr.len != IMSG_HEADER_SIZE + - sizeof(struct ldpd_init)) + if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(struct ldpd_init)) fatalx("INIT imsg with wrong len"); memcpy(&init, imsg.data, sizeof(init)); @@ -398,14 +393,11 @@ static void ldpe_dispatch_main(struct event *thread) disc_socket = -1; edisc_socket = -1; session_socket = -1; - if ((ldp_af_conf_get(leconf, af))->flags & - F_LDPD_AF_ENABLED) - ldpe_imsg_compose_parent(IMSG_REQUEST_SOCKETS, - af, NULL, 0); + if (CHECK_FLAG((ldp_af_conf_get(leconf, af))->flags, F_LDPD_AF_ENABLED)) + ldpe_imsg_compose_parent(IMSG_REQUEST_SOCKETS, af, NULL, 0); break; case IMSG_SOCKET_NET: - if (imsg.hdr.len != IMSG_HEADER_SIZE + - sizeof(enum socket_type)) + if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(enum socket_type)) fatalx("SOCKET_NET imsg with wrong len"); socket_type = imsg.data; @@ -434,15 +426,13 @@ static void ldpe_dispatch_main(struct event *thread) break; } - ldpe_setup_sockets(af, disc_socket, edisc_socket, - session_socket); + ldpe_setup_sockets(af, disc_socket, edisc_socket, session_socket); if_update_all(af); tnbr_update_all(af); RB_FOREACH(nbr, nbr_id_head, &nbrs_by_id) { if (nbr->af != af) continue; - nbr->laddr = (ldp_af_conf_get(leconf, - af))->trans_addr; + nbr->laddr = (ldp_af_conf_get(leconf, af))->trans_addr; #ifdef __OpenBSD__ nbrp = nbr_params_find(leconf, nbr->id); if (nbrp) { @@ -456,8 +446,7 @@ static void ldpe_dispatch_main(struct event *thread) } break; case IMSG_RTRID_UPDATE: - memcpy(&global.rtr_id, imsg.data, - sizeof(global.rtr_id)); + memcpy(&global.rtr_id, imsg.data, sizeof(global.rtr_id)); if (leconf->rtr_id.s_addr == INADDR_ANY) { ldpe_reset_nbrs(AF_UNSPEC); } @@ -465,8 +454,7 @@ static void ldpe_dispatch_main(struct event *thread) tnbr_update_all(AF_UNSPEC); break; case IMSG_RECONF_CONF: - if ((nconf = malloc(sizeof(struct ldpd_conf))) == - NULL) + if ((nconf = malloc(sizeof(struct ldpd_conf))) == NULL) fatal(NULL); memcpy(nconf, imsg.data, sizeof(struct ldpd_conf)); @@ -546,16 +534,13 @@ static void ldpe_dispatch_main(struct event *thread) memcpy(&ldp_debug, imsg.data, sizeof(ldp_debug)); break; case IMSG_FILTER_UPDATE: - if (imsg.hdr.len != IMSG_HEADER_SIZE + - sizeof(struct ldp_access)) { + if (imsg.hdr.len != IMSG_HEADER_SIZE + sizeof(struct ldp_access)) { log_warnx("%s: wrong imsg len", __func__); break; } laccess = imsg.data; - ldpe_check_filter_af(AF_INET, &leconf->ipv4, - laccess->name); - ldpe_check_filter_af(AF_INET6, &leconf->ipv6, - laccess->name); + ldpe_check_filter_af(AF_INET, &leconf->ipv4, laccess->name); + ldpe_check_filter_af(AF_INET6, &leconf->ipv6, laccess->name); break; case IMSG_LDP_SYNC_IF_STATE_REQUEST: if (imsg.hdr.len != IMSG_HEADER_SIZE + @@ -605,8 +590,7 @@ static void ldpe_dispatch_main(struct event *thread) } 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); @@ -650,8 +634,7 @@ static void ldpe_dispatch_lde(struct event *thread) case IMSG_RELEASE_ADD: case IMSG_REQUEST_ADD: case IMSG_WITHDRAW_ADD: - if (imsg.hdr.len - IMSG_HEADER_SIZE != - sizeof(struct map)) + if (imsg.hdr.len - IMSG_HEADER_SIZE != sizeof(struct map)) fatalx("invalid size of map request"); map = imsg.data; @@ -706,8 +689,7 @@ static void ldpe_dispatch_lde(struct event *thread) } break; case IMSG_NOTIFICATION_SEND: - if (imsg.hdr.len - IMSG_HEADER_SIZE != - sizeof(struct notify_msg)) + if (imsg.hdr.len - IMSG_HEADER_SIZE != sizeof(struct notify_msg)) fatalx("invalid size of OE request"); nm = imsg.data; @@ -741,8 +723,7 @@ static void ldpe_dispatch_lde(struct event *thread) session_shutdown(nbr,S_SHUTDOWN,0,0); 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); @@ -860,7 +841,7 @@ ldpe_remove_dynamic_tnbrs(int af) if (tnbr->af != af) continue; - tnbr->flags &= ~F_TNBR_DYNAMIC; + UNSET_FLAG(tnbr->flags, F_TNBR_DYNAMIC); tnbr_check(leconf, tnbr); } } |