summaryrefslogtreecommitdiffstats
path: root/ldpd
diff options
context:
space:
mode:
authorsri-mohan1 <sri.mohan@samsung.com>2023-05-08 11:58:50 +0200
committersri-mohan1 <sri.mohan@samsung.com>2023-05-08 11:58:50 +0200
commit0352223846b30353653575a0743fd07fbfaeebd5 (patch)
tree39c5b345c6b272b430ef2ea2d702b0a3889f6d0d /ldpd
parentldpd: changes for code maintainability (diff)
downloadfrr-0352223846b30353653575a0743fd07fbfaeebd5.tar.xz
frr-0352223846b30353653575a0743fd07fbfaeebd5.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/interface.c18
-rw-r--r--ldpd/lde_lib.c19
-rw-r--r--ldpd/neighbor.c36
3 files changed, 29 insertions, 44 deletions
diff --git a/ldpd/interface.c b/ldpd/interface.c
index ad5d853b6..f0e70cbac 100644
--- a/ldpd/interface.c
+++ b/ldpd/interface.c
@@ -138,14 +138,13 @@ void
if_update_info(struct iface *iface, struct kif *kif)
{
/* get type */
- if (kif->flags & IFF_POINTOPOINT)
+ if (CHECK_FLAG(kif->flags, IFF_POINTOPOINT))
iface->type = IF_TYPE_POINTOPOINT;
- if (kif->flags & IFF_BROADCAST &&
- kif->flags & IFF_MULTICAST)
+ if (CHECK_FLAG(kif->flags, IFF_BROADCAST) &&
+ CHECK_FLAG(kif->flags, IFF_MULTICAST))
iface->type = IF_TYPE_BROADCAST;
- if (ldpd_process == PROC_LDP_ENGINE && iface->operative &&
- !kif->operative)
+ if (ldpd_process == PROC_LDP_ENGINE && iface->operative && !kif->operative)
ldp_sync_fsm(iface, LDP_SYNC_EVT_IFACE_SHUTDOWN);
/* get index and flags */
@@ -276,8 +275,7 @@ if_start(struct iface *iface, int af)
struct iface_af *ia;
struct timeval now;
- log_debug("%s: %s address-family %s", __func__, iface->name,
- af_name(af));
+ log_debug("%s: %s address-family %s", __func__, iface->name, af_name(af));
ia = iface_af_get(iface, af);
@@ -560,8 +558,7 @@ if_join_ipv4_group(struct iface *iface, struct in_addr *addr)
{
struct in_addr if_addr;
- log_debug("%s: interface %s addr %pI4", __func__, iface->name,
- addr);
+ log_debug("%s: interface %s addr %pI4", __func__, iface->name, addr);
if_addr.s_addr = if_get_ipv4_addr(iface);
@@ -579,8 +576,7 @@ if_leave_ipv4_group(struct iface *iface, struct in_addr *addr)
{
struct in_addr if_addr;
- log_debug("%s: interface %s addr %pI4", __func__, iface->name,
- addr);
+ log_debug("%s: interface %s addr %pI4", __func__, iface->name, addr);
if_addr.s_addr = if_get_ipv4_addr(iface);
diff --git a/ldpd/lde_lib.c b/ldpd/lde_lib.c
index cb6b8986b..04bff9015 100644
--- a/ldpd/lde_lib.c
+++ b/ldpd/lde_lib.c
@@ -17,17 +17,16 @@
#include "mpls.h"
static __inline int fec_compare(const struct fec *, const struct fec *);
-static int lde_nbr_is_nexthop(struct fec_node *,
- struct lde_nbr *);
-static void fec_free(void *);
-static struct fec_node *fec_add(struct fec *fec);
-static struct fec_nh *fec_nh_add(struct fec_node *, int, union ldpd_addr *,
+static int lde_nbr_is_nexthop(struct fec_node *, struct lde_nbr *);
+static void fec_free(void *);
+static struct fec_node *fec_add(struct fec *fec);
+static struct fec_nh *fec_nh_add(struct fec_node *, int, union ldpd_addr *,
ifindex_t, uint8_t, unsigned short);
-static void fec_nh_del(struct fec_nh *);
+static void fec_nh_del(struct fec_nh *);
RB_GENERATE(fec_tree, fec, entry, fec_compare)
-struct fec_tree ft = RB_INITIALIZER(&ft);
+struct fec_tree ft = RB_INITIALIZER(&ft);
struct event *gc_timer;
/* FEC tree functions */
@@ -869,8 +868,7 @@ lde_check_withdraw(struct map *map, struct lde_nbr *ln)
continue;
/* LWd.9: check if previously sent a label mapping */
- me = (struct lde_map *)fec_find(&lnbr->sent_map,
- &fn->fec);
+ me = (struct lde_map *)fec_find(&lnbr->sent_map, &fn->fec);
/*
* LWd.10: does label sent to peer "map" to withdraw
@@ -909,8 +907,7 @@ lde_check_withdraw_wcard(struct map *map, struct lde_nbr *ln)
switch (f->type) {
case FEC_TYPE_IPV4:
case FEC_TYPE_IPV6:
- if (!lde_address_find(ln, fnh->af,
- &fnh->nexthop))
+ if (!lde_address_find(ln, fnh->af, &fnh->nexthop))
continue;
break;
case FEC_TYPE_PWID:
diff --git a/ldpd/neighbor.c b/ldpd/neighbor.c
index 6f9177fe8..5209c55bb 100644
--- a/ldpd/neighbor.c
+++ b/ldpd/neighbor.c
@@ -19,10 +19,8 @@ DEFINE_HOOK(ldp_nbr_state_change, (struct nbr * nbr, int old_state),
(nbr, old_state));
static __inline int nbr_id_compare(const struct nbr *, const struct nbr *);
-static __inline int nbr_addr_compare(const struct nbr *,
- const struct nbr *);
-static __inline int nbr_pid_compare(const struct nbr *,
- const struct nbr *);
+static __inline int nbr_addr_compare(const struct nbr *, const struct nbr *);
+static __inline int nbr_pid_compare(const struct nbr *, const struct nbr *);
static void nbr_update_peerid(struct nbr *);
static void nbr_ktimer(struct event *thread);
static void nbr_start_ktimer(struct nbr *);
@@ -127,7 +125,7 @@ nbr_fsm(struct nbr *nbr, enum nbr_event event)
old_state = nbr->state;
for (i = 0; nbr_fsm_tbl[i].state != -1; i++)
- if ((nbr_fsm_tbl[i].state & old_state) &&
+ if (CHECK_FLAG(nbr_fsm_tbl[i].state, old_state) &&
(nbr_fsm_tbl[i].event == event)) {
new_state = nbr_fsm_tbl[i].new_state;
break;
@@ -196,8 +194,7 @@ nbr_fsm(struct nbr *nbr, enum nbr_event event)
send_keepalive(nbr);
break;
case NBR_ACT_CLOSE_SESSION:
- ldpe_imsg_compose_lde(IMSG_NEIGHBOR_DOWN, nbr->peerid, 0,
- NULL, 0);
+ ldpe_imsg_compose_lde(IMSG_NEIGHBOR_DOWN, nbr->peerid, 0, NULL, 0);
session_close(nbr);
break;
case NBR_ACT_NOTHING:
@@ -606,8 +603,7 @@ nbr_establish_connection(struct nbr *nbr)
return (-1);
}
#else
- sock_set_md5sig(nbr->fd, nbr->af, &nbr->raddr,
- nbrp->auth.md5key);
+ sock_set_md5sig(nbr->fd, nbr->af, &nbr->raddr, nbrp->auth.md5key);
#endif
}
@@ -646,8 +642,7 @@ nbr_establish_connection(struct nbr *nbr)
send_hello(adj->source.type, adj->source.link.ia,
adj->source.target);
- if (connect(nbr->fd, &remote_su.sa, sockaddr_len(&remote_su.sa))
- == -1) {
+ if (connect(nbr->fd, &remote_su.sa, sockaddr_len(&remote_su.sa)) == -1) {
if (errno == EINPROGRESS) {
event_add_write(master, nbr_connect_cb, nbr, nbr->fd,
&nbr->ev_connect);
@@ -674,14 +669,14 @@ nbr_gtsm_enabled(struct nbr *nbr, struct nbr_params *nbrp)
* statically (e.g., via configuration) and/or dynamically override the
* default behavior and enable/disable GTSM on a per-peer basis".
*/
- if (nbrp && (nbrp->flags & F_NBRP_GTSM))
+ if (nbrp && CHECK_FLAG(nbrp->flags, F_NBRP_GTSM))
return (nbrp->gtsm_enabled);
- if ((ldp_af_conf_get(leconf, nbr->af))->flags & F_LDPD_AF_NO_GTSM)
+ if (CHECK_FLAG((ldp_af_conf_get(leconf, nbr->af))->flags, F_LDPD_AF_NO_GTSM))
return (0);
/* By default, GTSM support has to be negotiated for LDPv4 */
- if (nbr->af == AF_INET && !(nbr->flags & F_NBR_GTSM_NEGOTIATED))
+ if (nbr->af == AF_INET && !CHECK_FLAG(nbr->flags, F_NBR_GTSM_NEGOTIATED))
return (0);
return (1);
@@ -692,7 +687,7 @@ nbr_gtsm_setup(int fd, int af, struct nbr_params *nbrp)
{
int ttl = 255;
- if (nbrp && (nbrp->flags & F_NBRP_GTSM_HOPS))
+ if (nbrp && CHECK_FLAG(nbrp->flags, F_NBRP_GTSM_HOPS))
ttl = 256 - nbrp->gtsm_hops;
switch (af) {
@@ -740,8 +735,7 @@ nbr_gtsm_check(int fd, struct nbr *nbr, struct nbr_params *nbrp)
}
if (nbr_gtsm_setup(fd, nbr->af, nbrp) == -1) {
- log_warnx("%s: error enabling GTSM for lsr-id %pI4", __func__,
- &nbr->id);
+ log_warnx("%s: error enabling GTSM for lsr-id %pI4", __func__, &nbr->id);
return (-1);
}
@@ -772,8 +766,7 @@ nbr_act_session_operational(struct nbr *nbr)
static void
nbr_send_labelmappings(struct nbr *nbr)
{
- ldpe_imsg_compose_lde(IMSG_LABEL_MAPPING_FULL, nbr->peerid, 0,
- NULL, 0);
+ ldpe_imsg_compose_lde(IMSG_LABEL_MAPPING_FULL, nbr->peerid, 0, NULL, 0);
}
static __inline int
@@ -810,7 +803,7 @@ nbr_get_keepalive(int af, struct in_addr lsr_id)
struct nbr_params *nbrp;
nbrp = nbr_params_find(leconf, lsr_id);
- if (nbrp && (nbrp->flags & F_NBRP_KEEPALIVE))
+ if (nbrp && CHECK_FLAG(nbrp->flags, F_NBRP_KEEPALIVE))
return (nbrp->keepalive);
return ((ldp_af_conf_get(leconf, af))->keepalive);
@@ -834,8 +827,7 @@ nbr_to_ctl(struct nbr *nbr)
nctl.stats = nbr->stats;
nctl.flags = nbr->flags;
nctl.max_pdu_len = nbr->max_pdu_len;
- nctl.hold_time_remaining =
- event_timer_remain_second(nbr->keepalive_timer);
+ nctl.hold_time_remaining = event_timer_remain_second(nbr->keepalive_timer);
gettimeofday(&now, NULL);
if (nbr->state == NBR_STA_OPER) {