Skip to content

Commit

Permalink
Merge pull request #8 from opensourcerouting/pathd-pcep-clang-formatting
Browse files Browse the repository at this point in the history
CLANG Formatting changes for previous patch
  • Loading branch information
GalaxyGorilla authored Apr 16, 2020
2 parents e90958c + 77905c3 commit 9a113eb
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 73 deletions.
78 changes: 45 additions & 33 deletions pathd/path_pcep.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 [<ip A.B.C.D | ipv6 X:X::X:X>] [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 [<ip A.B.C.D | ipv6 X:X::X:X>] [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;
Expand All @@ -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++;
Expand All @@ -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++;
Expand All @@ -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;
Expand Down Expand Up @@ -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 */
Expand All @@ -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;
Expand Down Expand Up @@ -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",
Expand All @@ -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++;
Expand Down
2 changes: 1 addition & 1 deletion pathd/path_pcep_controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 8 additions & 4 deletions pathd/path_pcep_debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}
Expand Down
27 changes: 14 additions & 13 deletions pathd/path_pcep_lib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -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);
}
}

Expand Down
52 changes: 30 additions & 22 deletions pathd/path_pcep_pcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 9a113eb

Please sign in to comment.