From 5afba51d83e80129709f01e67888a53fd8f7ccbe Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Wed, 19 Apr 2017 18:14:20 -0300 Subject: [PATCH] ldpd: fix small style issues Signed-off-by: Renato Westphal --- ldpd/lde.c | 80 ++++++++++++++++++++++++--------------------- ldpd/ldp_vty_conf.c | 2 +- 2 files changed, 43 insertions(+), 39 deletions(-) diff --git a/ldpd/lde.c b/ldpd/lde.c index 95cacf927c..a903a8bfde 100644 --- a/ldpd/lde.c +++ b/ldpd/lde.c @@ -54,9 +54,9 @@ static void lde_map_free(void *); static int lde_address_add(struct lde_nbr *, struct lde_addr *); static int lde_address_del(struct lde_nbr *, struct lde_addr *); static void lde_address_list_free(struct lde_nbr *); -static void zclient_sync_init (u_short instance); +static void zclient_sync_init(u_short instance); static void lde_label_list_init(void); -static int lde_get_label_chunk (void); +static int lde_get_label_chunk(void); static void on_get_label_chunk_response(uint32_t start, uint32_t end); static uint32_t lde_get_next_label(void); @@ -93,8 +93,11 @@ static struct zebra_privs_t lde_privs = }; /* List of chunks of labels externally assigned by Zebra */ -struct list *label_chunk_list; -struct listnode *current_label_chunk; +static struct list *label_chunk_list; +static struct listnode *current_label_chunk; + +/* Synchronous zclient to request labels */ +static struct zclient *zclient_sync; /* SIGINT / SIGTERM handler. */ static void @@ -119,28 +122,6 @@ static struct quagga_signal_t lde_signals[] = }, }; -struct zclient *zclient_sync = NULL; -static void -zclient_sync_init(u_short instance) -{ - /* Initialize special zclient for synchronous message exchanges. */ - log_debug("Initializing synchronous zclient for label manager"); - zclient_sync = zclient_new(master); - zclient_sync->sock = -1; - zclient_sync->redist_default = ZEBRA_ROUTE_LDP; - zclient_sync->instance = instance; - while (zclient_socket_connect (zclient_sync) < 0) { - log_warnx("Error connecting synchronous zclient!"); - sleep(1); - } - - /* Connect to label manager */ - while (lm_label_manager_connect (zclient_sync) != 0) { - log_warnx("Error connecting to label manager!"); - sleep(1); - } -} - /* label decision engine */ void lde(void) @@ -733,7 +714,7 @@ lde_update_label(struct fec_node *fn) fn->local_label > MPLS_LABEL_RESERVED_MAX) return (fn->local_label); - return lde_get_next_label (); + return (lde_get_next_label()); } void @@ -1594,21 +1575,42 @@ lde_address_list_free(struct lde_nbr *ln) } } +static void +zclient_sync_init(u_short instance) +{ + /* Initialize special zclient for synchronous message exchanges. */ + log_debug("Initializing synchronous zclient for label manager"); + zclient_sync = zclient_new(master); + zclient_sync->sock = -1; + zclient_sync->redist_default = ZEBRA_ROUTE_LDP; + zclient_sync->instance = instance; + while (zclient_socket_connect(zclient_sync) < 0) { + log_warnx("Error connecting synchronous zclient!"); + sleep(1); + } + + /* Connect to label manager */ + while (lm_label_manager_connect(zclient_sync) != 0) { + log_warnx("Error connecting to label manager!"); + sleep(1); + } +} + static void lde_del_label_chunk(void *val) { free(val); } + static int lde_get_label_chunk(void) { - int ret; - uint32_t start, end; + int ret; + uint32_t start, end; log_debug("Getting label chunk"); ret = lm_get_label_chunk(zclient_sync, 0, CHUNK_SIZE, &start, &end); - if (ret < 0) - { + if (ret < 0) { log_warnx("Error getting label chunk!"); close(zclient_sync->sock); zclient_sync->sock = -1; @@ -1617,8 +1619,9 @@ lde_get_label_chunk(void) on_get_label_chunk_response(start, end); - return 0; + return (0); } + static void lde_label_list_init(void) { @@ -1659,9 +1662,9 @@ on_get_label_chunk_response(uint32_t start, uint32_t end) static uint32_t lde_get_next_label(void) { - struct label_chunk *label_chunk; - uint32_t i, pos, size; - uint32_t label = NO_LABEL; + struct label_chunk *label_chunk; + uint32_t i, pos, size; + uint32_t label = NO_LABEL; while (current_label_chunk) { label_chunk = listgetdata(current_label_chunk); @@ -1683,12 +1686,13 @@ lde_get_next_label(void) end: /* we moved till the last chunk, or were not able to find a label, so let's ask for another one */ - if (!current_label_chunk || current_label_chunk == listtail(label_chunk_list) - || label == NO_LABEL) { + if (!current_label_chunk || + current_label_chunk == listtail(label_chunk_list) || + label == NO_LABEL) { if (lde_get_label_chunk() != 0) log_warn("%s: Error getting label chunk!", __func__); } - return label; + return (label); } diff --git a/ldpd/ldp_vty_conf.c b/ldpd/ldp_vty_conf.c index e4fc7b0054..6943e8edc6 100644 --- a/ldpd/ldp_vty_conf.c +++ b/ldpd/ldp_vty_conf.c @@ -1641,7 +1641,7 @@ iface_new_api(struct ldpd_conf *conf, const char *name) struct iface *iface; if (ldp_iface_is_configured(conf, ifname)) - return NULL; + return (NULL); iface = if_new(name); RB_INSERT(iface_head, &conf->iface_tree, iface); -- 2.39.5