From 77905c394958020075b701ff48becab43ec18b19 Mon Sep 17 00:00:00 2001 From: Brady Johnson Date: Thu, 16 Apr 2020 11:52:34 +0200 Subject: [PATCH] CLANG Formatting changes for previous patch - I forgot to run clang formatting on the previous patch, so here are the formatting fixes. --- pathd/path_pcep.c | 78 +++++++++++++++++++++--------------- pathd/path_pcep_controller.c | 2 +- pathd/path_pcep_debug.c | 12 ++++-- pathd/path_pcep_lib.c | 27 +++++++------ pathd/path_pcep_pcc.c | 52 ++++++++++++++---------- 5 files changed, 98 insertions(+), 73 deletions(-) diff --git a/pathd/path_pcep.c b/pathd/path_pcep.c index 9991d1904c64..3cf99dea828d 100644 --- a/pathd/path_pcep.c +++ b/pathd/path_pcep.c @@ -247,16 +247,17 @@ DEFUN(show_pcep_counters, show_pcep_counters_cmd, "show pcep counters", return CMD_SUCCESS; } -DEFUN_NOSH(pcep_cli_pcc, pcep_cli_pcc_cmd, - "pcc [] [port (1024-65535)] [force_stateless]", - "PCC configuration\n" - "PCC source ip\n" - "PCC source IPv4 address\n" - "PCC source ip\n" - "PCC source IPv6 address\n" - "PCC source port\n" - "PCC source port value\n" - "Force the PCC to use computation requests\n") +DEFUN_NOSH( + pcep_cli_pcc, pcep_cli_pcc_cmd, + "pcc [] [port (1024-65535)] [force_stateless]", + "PCC configuration\n" + "PCC source ip\n" + "PCC source IPv4 address\n" + "PCC source ip\n" + "PCC source IPv6 address\n" + "PCC source port\n" + "PCC source port value\n" + "Force the PCC to use computation requests\n") { struct ipaddr pcc_addr; @@ -272,7 +273,8 @@ DEFUN_NOSH(pcep_cli_pcc, pcep_cli_pcc_cmd, i++; if (i >= argc) return CMD_ERR_NO_MATCH; - if (!inet_pton(AF_INET6, argv[i]->arg, &pcc_addr.ipaddr_v6)) + if (!inet_pton(AF_INET6, argv[i]->arg, + &pcc_addr.ipaddr_v6)) return CMD_ERR_INCOMPLETE; pcc_addr.ipa_type = IPADDR_V6; i++; @@ -282,7 +284,8 @@ DEFUN_NOSH(pcep_cli_pcc, pcep_cli_pcc_cmd, i++; if (i >= argc) return CMD_ERR_NO_MATCH; - if (!inet_pton(AF_INET, argv[i]->arg, &pcc_addr.ipaddr_v4.s_addr)) + if (!inet_pton(AF_INET, argv[i]->arg, + &pcc_addr.ipaddr_v4.s_addr)) return CMD_ERR_INCOMPLETE; pcc_addr.ipa_type = IPADDR_V4; i++; @@ -309,9 +312,10 @@ DEFUN_NOSH(pcep_cli_pcc, pcep_cli_pcc_cmd, opts = XCALLOC(MTYPE_PCEP, sizeof(*opts)); opts->addr.ipa_type = pcc_addr.ipa_type; if (IS_IPADDR_V6(&pcc_addr)) { - memcpy(&opts->addr.ipaddr_v6, &pcc_addr.ipaddr_v6, sizeof(struct in6_addr)); + memcpy(&opts->addr.ipaddr_v6, &pcc_addr.ipaddr_v6, + sizeof(struct in6_addr)); } else { - opts->addr.ipaddr_v4.s_addr = pcc_addr.ipaddr_v4.s_addr; + opts->addr.ipaddr_v4.s_addr = pcc_addr.ipaddr_v4.s_addr; } opts->port = pcc_port; opts->force_stateless = force_stateless; @@ -363,13 +367,13 @@ DEFUN(pcep_cli_pce_opts, pcep_cli_pce_opts_cmd, return CMD_ERR_NO_MATCH; } if (IS_IPADDR_V6(&pce_addr)) { - if (!inet_pton(AF_INET6, argv[i]->arg, &pce_addr.ipaddr_v6)) { - return CMD_ERR_INCOMPLETE; - } + if (!inet_pton(AF_INET6, argv[i]->arg, &pce_addr.ipaddr_v6)) { + return CMD_ERR_INCOMPLETE; + } } else { - if (!inet_pton(AF_INET, argv[i]->arg, &pce_addr.ipaddr_v4)) { - return CMD_ERR_INCOMPLETE; - } + if (!inet_pton(AF_INET, argv[i]->arg, &pce_addr.ipaddr_v4)) { + return CMD_ERR_INCOMPLETE; + } } /* Handle the rest of the arguments */ @@ -396,9 +400,10 @@ DEFUN(pcep_cli_pce_opts, pcep_cli_pce_opts_cmd, pce_opts = XCALLOC(MTYPE_PCEP, sizeof(*pce_opts)); pce_opts->addr.ipa_type = pce_addr.ipa_type; if (IS_IPADDR_V6(&pce_addr)) { - memcpy(&pce_opts->addr.ipaddr_v6, &pce_addr.ipaddr_v6, sizeof(struct in6_addr)); + memcpy(&pce_opts->addr.ipaddr_v6, &pce_addr.ipaddr_v6, + sizeof(struct in6_addr)); } else { - pce_opts->addr.ipaddr_v4 = pce_addr.ipaddr_v4; + pce_opts->addr.ipaddr_v4 = pce_addr.ipaddr_v4; } pce_opts->port = pce_port; pce_opts->draft07 = draft07; @@ -501,15 +506,19 @@ int pcep_cli_pcc_config_write(struct vty *vty) if (NULL != pcep_g->pcc_opts) { if (IS_IPADDR_V6(&pcep_g->pcc_opts->addr)) { - if (0 != memcmp(&in6addr_any, &pcep_g->pcc_opts->addr.ipaddr_v6, sizeof(struct in6_addr))) { - csnprintfrr(buff, sizeof(buff), " ip %pI6", - &pcep_g->pcc_opts->addr.ipaddr_v6); - } + if (0 + != memcmp(&in6addr_any, + &pcep_g->pcc_opts->addr.ipaddr_v6, + sizeof(struct in6_addr))) { + csnprintfrr(buff, sizeof(buff), " ip %pI6", + &pcep_g->pcc_opts->addr.ipaddr_v6); + } } else { - if (INADDR_ANY != pcep_g->pcc_opts->addr.ipaddr_v4.s_addr) { - csnprintfrr(buff, sizeof(buff), " ip %pI4", - &pcep_g->pcc_opts->addr.ipaddr_v4); - } + if (INADDR_ANY + != pcep_g->pcc_opts->addr.ipaddr_v4.s_addr) { + csnprintfrr(buff, sizeof(buff), " ip %pI4", + &pcep_g->pcc_opts->addr.ipaddr_v4); + } } if (PCEP_DEFAULT_PORT != pcep_g->pcc_opts->port) csnprintfrr(buff, sizeof(buff), " port %d", @@ -526,14 +535,17 @@ int pcep_cli_pcc_config_write(struct vty *vty) " port %d", pce_opts->port); } if (true == pce_opts->draft07) { - csnprintfrr(buff, sizeof(buff), " sr-draft07"); + csnprintfrr(buff, sizeof(buff), + " sr-draft07"); } if (IS_IPADDR_V6(&pce_opts->addr)) { vty_out(vty, " pce ipv6 %pI6%s\n", - &pce_opts->addr.ipaddr_v6, buff); + &pce_opts->addr.ipaddr_v6, + buff); } else { vty_out(vty, " pce ip %pI4%s\n", - &pce_opts->addr.ipaddr_v4, buff); + &pce_opts->addr.ipaddr_v4, + buff); } buff[0] = 0; lines++; diff --git a/pathd/path_pcep_controller.c b/pathd/path_pcep_controller.c index 29f32c72f848..16a8d85da0b2 100644 --- a/pathd/path_pcep_controller.c +++ b/pathd/path_pcep_controller.c @@ -184,7 +184,7 @@ int pcep_ctrl_initialize(struct thread_master *main_thread, ctrl_state->t_poll = NULL; ctrl_state->pcc_count = 0; ctrl_state->pcc_opts = - XCALLOC(MTYPE_PCEP, sizeof(*ctrl_state->pcc_opts)); + XCALLOC(MTYPE_PCEP, sizeof(*ctrl_state->pcc_opts)); /* Default to IPv4 */ ctrl_state->pcc_opts->addr.ipa_type = IPADDR_V4; ctrl_state->pcc_opts->addr.ipaddr_v4.s_addr = INADDR_ANY; diff --git a/pathd/path_pcep_debug.c b/pathd/path_pcep_debug.c index bbf55058f0eb..6700706dc77a 100644 --- a/pathd/path_pcep_debug.c +++ b/pathd/path_pcep_debug.c @@ -571,9 +571,11 @@ void _format_pcc_opts(int ps, struct pcc_opts *opts) int ps2 = ps + DEBUG_IDENT_SIZE; PCEP_FORMAT("\n"); if (IS_IPADDR_V6(&opts->addr)) { - PCEP_FORMAT("%*saddr: %pI6\n", ps2, "", &opts->addr.ipaddr_v6); + PCEP_FORMAT("%*saddr: %pI6\n", ps2, "", + &opts->addr.ipaddr_v6); } else { - PCEP_FORMAT("%*saddr: %pI4\n", ps2, "", &opts->addr.ipaddr_v4); + PCEP_FORMAT("%*saddr: %pI4\n", ps2, "", + &opts->addr.ipaddr_v4); } PCEP_FORMAT("%*sport: %i\n", ps2, "", opts->port); } @@ -587,9 +589,11 @@ void _format_pce_opts(int ps, struct pce_opts *opts) int ps2 = ps + DEBUG_IDENT_SIZE; PCEP_FORMAT("\n"); if (IS_IPADDR_V6(&opts->addr)) { - PCEP_FORMAT("%*saddr: %pI6\n", ps2, "", &opts->addr.ipaddr_v6); + PCEP_FORMAT("%*saddr: %pI6\n", ps2, "", + &opts->addr.ipaddr_v6); } else { - PCEP_FORMAT("%*saddr: %pI4\n", ps2, "", &opts->addr.ipaddr_v4); + PCEP_FORMAT("%*saddr: %pI4\n", ps2, "", + &opts->addr.ipaddr_v4); } PCEP_FORMAT("%*sport: %i\n", ps2, "", opts->port); } diff --git a/pathd/path_pcep_lib.c b/pathd/path_pcep_lib.c index c09ed2b2a42b..8b61c108dd4d 100644 --- a/pathd/path_pcep_lib.c +++ b/pathd/path_pcep_lib.c @@ -86,11 +86,12 @@ pcep_session *pcep_lib_connect(struct pcc_opts *pcc_opts, config->dst_pcep_port = pce_opts->port; config->src_pcep_port = pcc_opts->port; if (IS_IPADDR_V6(&pcc_opts->addr)) { - config->is_src_ipv6 = true; - memcpy(&config->src_ip.src_ipv6, &pcc_opts->addr.ipaddr_v6, sizeof(struct in6_addr)); + config->is_src_ipv6 = true; + memcpy(&config->src_ip.src_ipv6, &pcc_opts->addr.ipaddr_v6, + sizeof(struct in6_addr)); } else { - config->is_src_ipv6 = false; - config->src_ip.src_ipv4 = pcc_opts->addr.ipaddr_v4; + config->is_src_ipv6 = false; + config->src_ip.src_ipv4 = pcc_opts->addr.ipaddr_v4; } config->support_stateful_pce_lsp_update = !pcc_opts->force_stateless; @@ -106,9 +107,9 @@ pcep_session *pcep_lib_connect(struct pcc_opts *pcc_opts, pce_opts->draft07; if (IS_IPADDR_V6(&pce_opts->addr)) { - sess = connect_pce_ipv6(config, &pce_opts->addr.ipaddr_v6); + sess = connect_pce_ipv6(config, &pce_opts->addr.ipaddr_v6); } else { - sess = connect_pce(config, &pce_opts->addr.ipaddr_v4); + sess = connect_pce(config, &pce_opts->addr.ipaddr_v4); } destroy_pcep_configuration(config); return sess; @@ -129,7 +130,7 @@ struct pcep_message *pcep_lib_format_report(struct path *path) struct pcep_message *pcep_lib_format_request(uint32_t reqid, struct ipaddr *src, struct ipaddr *dst) { - assert(src->ipa_type ==dst->ipa_type); + assert(src->ipa_type == dst->ipa_type); double_linked_list *rp_tlvs; struct pcep_object_tlv_path_setup_type *setup_type_tlv; @@ -143,13 +144,13 @@ struct pcep_message *pcep_lib_format_request(uint32_t reqid, struct ipaddr *src, rp = pcep_obj_create_rp(0, false, false, false, reqid, rp_tlvs); if (IS_IPADDR_V6(src)) { - endpoints_ipv6 = - pcep_obj_create_endpoint_ipv6(&src->ipaddr_v6, &dst->ipaddr_v6); - return pcep_msg_create_request_ipv6(rp, endpoints_ipv6, NULL); + endpoints_ipv6 = pcep_obj_create_endpoint_ipv6(&src->ipaddr_v6, + &dst->ipaddr_v6); + return pcep_msg_create_request_ipv6(rp, endpoints_ipv6, NULL); } else { - endpoints_ipv4 = - pcep_obj_create_endpoint_ipv4(&src->ipaddr_v4, &dst->ipaddr_v4); - return pcep_msg_create_request(rp, endpoints_ipv4, NULL); + endpoints_ipv4 = pcep_obj_create_endpoint_ipv4(&src->ipaddr_v4, + &dst->ipaddr_v4); + return pcep_msg_create_request(rp, endpoints_ipv4, NULL); } } diff --git a/pathd/path_pcep_pcc.c b/pathd/path_pcep_pcc.c index bffa7a02724a..8c3a79e9abfb 100644 --- a/pathd/path_pcep_pcc.c +++ b/pathd/path_pcep_pcc.c @@ -196,19 +196,21 @@ int pcep_pcc_enable(struct ctrl_state *ctrl_state, struct pcc_state *pcc_state) if (NULL == pcc_state->sess) { if (IS_IPADDR_V6(&pcc_state->pce_opts->addr)) { - flog_warn(EC_PATH_PCEP_LIB_CONNECT, - "failed to connect to PCE %pI6:%d from %pI6:%d", - &pcc_state->pce_opts->addr.ipaddr_v6, - pcc_state->pce_opts->port, - &pcc_state->pcc_opts->addr.ipaddr_v6, - pcc_state->pcc_opts->port); + flog_warn( + EC_PATH_PCEP_LIB_CONNECT, + "failed to connect to PCE %pI6:%d from %pI6:%d", + &pcc_state->pce_opts->addr.ipaddr_v6, + pcc_state->pce_opts->port, + &pcc_state->pcc_opts->addr.ipaddr_v6, + pcc_state->pcc_opts->port); } else { - flog_warn(EC_PATH_PCEP_LIB_CONNECT, - "failed to connect to PCE %pI4:%d from %pI4:%d", - &pcc_state->pce_opts->addr.ipaddr_v4, - pcc_state->pce_opts->port, - &pcc_state->pcc_opts->addr.ipaddr_v4, - pcc_state->pcc_opts->port); + flog_warn( + EC_PATH_PCEP_LIB_CONNECT, + "failed to connect to PCE %pI4:%d from %pI4:%d", + &pcc_state->pce_opts->addr.ipaddr_v4, + pcc_state->pce_opts->port, + &pcc_state->pcc_opts->addr.ipaddr_v4, + pcc_state->pcc_opts->port); } schedule_reconnect(ctrl_state, pcc_state); return 0; @@ -413,11 +415,13 @@ void handle_pcep_lsp_update(struct ctrl_state *ctrl_state, struct path *path; path = pcep_lib_parse_path(msg); if (IS_IPADDR_V6(&pcc_state->pce_opts->addr)) { - path->sender.ipa_type = IPADDR_V6; - memcpy(&path->sender.ipaddr_v6, &pcc_state->pce_opts->addr.ipaddr_v6, sizeof(struct in6_addr)); + path->sender.ipa_type = IPADDR_V6; + memcpy(&path->sender.ipaddr_v6, + &pcc_state->pce_opts->addr.ipaddr_v6, + sizeof(struct in6_addr)); } else { - path->sender.ipa_type = IPADDR_V4; - path->sender.ipaddr_v4 = pcc_state->pce_opts->addr.ipaddr_v4; + path->sender.ipa_type = IPADDR_V4; + path->sender.ipaddr_v4 = pcc_state->pce_opts->addr.ipaddr_v4; } lookup_nbkey(pcc_state, path); @@ -526,10 +530,13 @@ void send_comp_request(struct ctrl_state *ctrl_state, /* The source address need to be defined explicitly for now */ if (IS_IPADDR_V6(&pcc_state->pcc_opts->addr)) { - assert(0 != memcmp(&in6addr_any, &pcc_state->pcc_opts->addr.ipaddr_v6, - sizeof(struct in6_addr))); + assert(0 + != memcmp(&in6addr_any, + &pcc_state->pcc_opts->addr.ipaddr_v6, + sizeof(struct in6_addr))); } else { - assert(INADDR_ANY != pcc_state->pcc_opts->addr.ipaddr_v4.s_addr); + assert(INADDR_ANY + != pcc_state->pcc_opts->addr.ipaddr_v4.s_addr); } reqid = push_req(pcc_state, nbkey); @@ -541,10 +548,11 @@ void send_comp_request(struct ctrl_state *ctrl_state, src.ipa_type = pcc_state->pcc_opts->addr.ipa_type; if (IS_IPADDR_V6(&pcc_state->pcc_opts->addr)) { - memcpy(&src.ipaddr_v6, &pcc_state->pcc_opts->addr.ipaddr_v6, - sizeof(struct in6_addr)); + memcpy(&src.ipaddr_v6, &pcc_state->pcc_opts->addr.ipaddr_v6, + sizeof(struct in6_addr)); } else { - src.ipaddr_v4.s_addr = pcc_state->pcc_opts->addr.ipaddr_v4.s_addr; + src.ipaddr_v4.s_addr = + pcc_state->pcc_opts->addr.ipaddr_v4.s_addr; } msg = pcep_lib_format_request(reqid, &src, &nbkey->endpoint);