lib: staticd: vtysh: apply frrbot style requirements

Signed-off-by: Christian Hopps <chopps@labn.net>
This commit is contained in:
Christian Hopps 2023-03-20 15:07:44 -04:00 committed by Christian Hopps
parent 1401ee8bf7
commit 39c329bbd1
7 changed files with 83 additions and 90 deletions

View File

@ -242,8 +242,8 @@ DEFUN_NOSH(end_config, end_config_cmd, "XFRR_end_configuration",
ret = nb_cli_pending_commit_check(vty);
zlog_info("Configuration Read in Took: %s", readin_time_str);
zlog_debug("%s: VTY:%p, pending SET-CFG: %u",
__func__, vty, (uint32_t)vty->mgmt_num_pending_setcfg);
zlog_debug("%s: VTY:%p, pending SET-CFG: %u", __func__, vty,
(uint32_t)vty->mgmt_num_pending_setcfg);
/*
* If (and only if) we have sent any CLI config commands to MGMTd

View File

@ -846,8 +846,8 @@ void nb_candidate_edit_config_changes(
/* Handle relative XPaths. */
memset(xpath, 0, sizeof(xpath));
if (xpath_index > 0
&& (xpath_base[0] == '.' || change->xpath[0] == '.'))
if (xpath_index > 0 &&
(xpath_base[0] == '.' || change->xpath[0] == '.'))
strlcpy(xpath, curr_xpath, sizeof(xpath));
if (xpath_base[0]) {
if (xpath_base[0] == '.')
@ -947,9 +947,9 @@ int nb_candidate_validate_yang(struct nb_config *candidate, bool no_state,
char *errmsg, size_t errmsg_len)
{
if (lyd_validate_all(&candidate->dnode, ly_native_ctx,
no_state ? LYD_VALIDATE_NO_STATE :
LYD_VALIDATE_PRESENT, NULL)
!= 0) {
no_state ? LYD_VALIDATE_NO_STATE
: LYD_VALIDATE_PRESENT,
NULL) != 0) {
yang_print_errors(ly_native_ctx, errmsg, errmsg_len);
return NB_ERR_VALIDATION;
}
@ -1005,8 +1005,7 @@ int nb_candidate_diff_and_validate_yang(struct nb_context *context,
char *errmsg, size_t errmsg_len)
{
if (nb_candidate_validate_yang(candidate, true, errmsg,
sizeof(errmsg_len))
!= NB_OK)
sizeof(errmsg_len)) != NB_OK)
return NB_ERR_VALIDATION;
RB_INIT(nb_config_cbs, changes);
@ -1043,9 +1042,9 @@ int nb_candidate_commit_prepare(struct nb_context context,
{
struct nb_config_cbs changes;
if (!skip_validate
&& nb_candidate_validate_yang(candidate, true, errmsg, errmsg_len)
!= NB_OK) {
if (!skip_validate &&
nb_candidate_validate_yang(candidate, true, errmsg, errmsg_len) !=
NB_OK) {
flog_warn(EC_LIB_NB_CANDIDATE_INVALID,
"%s: failed to validate candidate configuration",
__func__);
@ -1061,10 +1060,9 @@ int nb_candidate_commit_prepare(struct nb_context context,
return NB_ERR_NO_CHANGES;
}
if (!skip_validate
&& nb_candidate_validate_code(&context, candidate, &changes, errmsg,
errmsg_len)
!= NB_OK) {
if (!skip_validate &&
nb_candidate_validate_code(&context, candidate, &changes, errmsg,
errmsg_len) != NB_OK) {
flog_warn(EC_LIB_NB_CANDIDATE_INVALID,
"%s: failed to validate candidate configuration",
__func__);

View File

@ -50,8 +50,8 @@ struct nb_yang_xpath {
};
#define NB_YANG_XPATH_KEY(__xpath, __indx1, __indx2) \
((__xpath->num_tags > __indx1) \
&& (__xpath->tags[__indx1].num_keys > __indx2) \
((__xpath->num_tags > __indx1) && \
(__xpath->tags[__indx1].num_keys > __indx2) \
? &__xpath->tags[__indx1].keys[__indx2] \
: NULL)
@ -1006,8 +1006,9 @@ extern void nb_config_diff(const struct nb_config *reference,
* Returns:
* NB_OK on success, NB_ERR_VALIDATION otherwise
*/
extern int nb_candidate_validate_yang(struct nb_config *candidate, bool no_state,
char *errmsg, size_t errmsg_len);
extern int nb_candidate_validate_yang(struct nb_config *candidate,
bool no_state, char *errmsg,
size_t errmsg_len);
/*
* Perform code-level validation using the northbound callbacks.

View File

@ -1627,10 +1627,9 @@ struct vty *vty_new(void)
if (mgmt_lib_hndl) {
new->mgmt_client_id = mgmt_client_id_next++;
if (mgmt_fe_create_client_session(mgmt_lib_hndl,
new->mgmt_client_id,
(uintptr_t)new)
!= MGMTD_SUCCESS)
if (mgmt_fe_create_client_session(
mgmt_lib_hndl, new->mgmt_client_id,
(uintptr_t) new) != MGMTD_SUCCESS)
zlog_err(
"Failed to open a MGMTD Frontend session for VTY session %p!!",
new);
@ -2697,8 +2696,7 @@ int vty_config_enter(struct vty *vty, bool private_config, bool exclusive)
if (vty_mgmt_fe_enabled()) {
if (!mgmt_candidate_ds_wr_locked) {
if (vty_mgmt_send_lockds_req(vty, MGMTD_DS_CANDIDATE,
true)
!= 0) {
true) != 0) {
vty_out(vty, "Not able to lock candidate DS\n");
return CMD_WARNING;
}
@ -2763,10 +2761,10 @@ int vty_config_node_exit(struct vty *vty)
{
vty->xpath_index = 0;
if (vty_mgmt_fe_enabled() && mgmt_candidate_ds_wr_locked
&& vty->mgmt_locked_candidate_ds) {
if (vty_mgmt_send_lockds_req(vty, MGMTD_DS_CANDIDATE, false)
!= 0) {
if (vty_mgmt_fe_enabled() && mgmt_candidate_ds_wr_locked &&
vty->mgmt_locked_candidate_ds) {
if (vty_mgmt_send_lockds_req(vty, MGMTD_DS_CANDIDATE, false) !=
0) {
vty_out(vty, "Not able to unlock candidate DS\n");
return CMD_WARNING;
}
@ -3363,8 +3361,8 @@ static void vty_mgmt_set_config_result_notified(
static void vty_mgmt_commit_config_result_notified(
uintptr_t lib_hndl, uintptr_t usr_data, uint64_t client_id,
uintptr_t session_id, uintptr_t session_ctx, uint64_t req_id,
bool success, Mgmtd__DatastoreId src_ds_id, Mgmtd__DatastoreId dst_ds_id,
bool validate_only, char *errmsg_if_any)
bool success, Mgmtd__DatastoreId src_ds_id,
Mgmtd__DatastoreId dst_ds_id, bool validate_only, char *errmsg_if_any)
{
struct vty *vty;
@ -3436,18 +3434,15 @@ static struct mgmt_fe_client_params client_params = {
.client_connect_notify = vty_mgmt_server_connected,
.client_session_notify = vty_mgmt_session_created,
.lock_ds_notify = vty_mgmt_ds_lock_notified,
.set_config_notify =
vty_mgmt_set_config_result_notified,
.commit_config_notify =
vty_mgmt_commit_config_result_notified,
.set_config_notify = vty_mgmt_set_config_result_notified,
.commit_config_notify = vty_mgmt_commit_config_result_notified,
.get_data_notify = vty_mgmt_get_data_result_notified,
};
void vty_init_mgmt_fe(void)
{
if (!vty_master) {
zlog_err(
"Always call vty_mgmt_init_fe() after vty_init()!!");
zlog_err("Always call vty_mgmt_init_fe() after vty_init()!!");
return;
}
@ -3547,12 +3542,11 @@ int vty_mgmt_send_config_data(struct vty *vty)
vty->mgmt_req_id++;
implicit_commit = vty_needs_implicit_commit(vty);
if (cnt
&& mgmt_fe_set_config_data(
if (cnt && mgmt_fe_set_config_data(
mgmt_lib_hndl, vty->mgmt_session_id,
vty->mgmt_req_id, MGMTD_DS_CANDIDATE, cfgreq,
cnt, implicit_commit, MGMTD_DS_RUNNING)
!= MGMTD_SUCCESS) {
cnt, implicit_commit,
MGMTD_DS_RUNNING) != MGMTD_SUCCESS) {
zlog_err("Failed to send %d Config Xpaths to MGMTD!!",
(int)indx);
return -1;

View File

@ -392,7 +392,8 @@ extern bool vty_mgmt_fe_enabled(void);
extern int vty_mgmt_send_config_data(struct vty *vty);
extern int vty_mgmt_send_commit_config(struct vty *vty, bool validate_only,
bool abort);
extern int vty_mgmt_send_get_config(struct vty *vty, Mgmtd__DatastoreId datastore,
extern int vty_mgmt_send_get_config(struct vty *vty,
Mgmtd__DatastoreId datastore,
const char **xpath_list, int num_req);
extern int vty_mgmt_send_get_data(struct vty *vty, Mgmtd__DatastoreId datastore,
const char **xpath_list, int num_req);
@ -403,8 +404,7 @@ extern void vty_mgmt_resume_response(struct vty *vty, bool success);
static inline bool vty_needs_implicit_commit(struct vty *vty)
{
return (frr_get_cli_mode() == FRR_CLI_CLASSIC
? ((vty->pending_allowed
|| vty->no_implicit_commit)
? ((vty->pending_allowed || vty->no_implicit_commit)
? false
: true)
: false);

View File

@ -285,9 +285,10 @@ static int static_route_nb_run(struct vty *vty, struct static_route_args *args)
nb_cli_enqueue_change(vty, ab_xpath,
NB_OP_MODIFY, "false");
}
if (type == STATIC_IPV4_GATEWAY || type == STATIC_IPV6_GATEWAY
|| type == STATIC_IPV4_GATEWAY_IFNAME
|| type == STATIC_IPV6_GATEWAY_IFNAME) {
if (type == STATIC_IPV4_GATEWAY ||
type == STATIC_IPV6_GATEWAY ||
type == STATIC_IPV4_GATEWAY_IFNAME ||
type == STATIC_IPV6_GATEWAY_IFNAME) {
strlcpy(ab_xpath, xpath_nexthop, sizeof(ab_xpath));
strlcat(ab_xpath, FRR_STATIC_ROUTE_NH_COLOR_XPATH,
sizeof(ab_xpath));
@ -369,36 +370,34 @@ static int static_route_nb_run(struct vty *vty, struct static_route_args *args)
} else {
if (args->source) {
if (args->distance)
snprintf(
ab_xpath, sizeof(ab_xpath),
snprintf(ab_xpath, sizeof(ab_xpath),
FRR_DEL_S_ROUTE_SRC_NH_KEY_XPATH,
"frr-staticd:staticd", "staticd", args->vrf,
buf_prefix,
yang_afi_safi_value2identity(args->afi,
args->safi),
"frr-staticd:staticd", "staticd",
args->vrf, buf_prefix,
yang_afi_safi_value2identity(
args->afi, args->safi),
buf_src_prefix, table_id, distance,
buf_nh_type, args->nexthop_vrf, buf_gate_str,
args->interface_name);
buf_nh_type, args->nexthop_vrf,
buf_gate_str, args->interface_name);
else
snprintf(
ab_xpath, sizeof(ab_xpath),
FRR_DEL_S_ROUTE_SRC_NH_KEY_NO_DISTANCE_XPATH,
"frr-staticd:staticd", "staticd", args->vrf,
buf_prefix,
yang_afi_safi_value2identity(args->afi,
args->safi),
"frr-staticd:staticd", "staticd",
args->vrf, buf_prefix,
yang_afi_safi_value2identity(
args->afi, args->safi),
buf_src_prefix, table_id, buf_nh_type,
args->nexthop_vrf, buf_gate_str,
args->interface_name);
} else {
if (args->distance)
snprintf(
ab_xpath, sizeof(ab_xpath),
snprintf(ab_xpath, sizeof(ab_xpath),
FRR_DEL_S_ROUTE_NH_KEY_XPATH,
"frr-staticd:staticd", "staticd",
args->vrf, buf_prefix,
yang_afi_safi_value2identity(args->afi,
args->safi),
yang_afi_safi_value2identity(
args->afi, args->safi),
table_id, distance, buf_nh_type,
args->nexthop_vrf, buf_gate_str,
args->interface_name);
@ -408,10 +407,11 @@ static int static_route_nb_run(struct vty *vty, struct static_route_args *args)
FRR_DEL_S_ROUTE_NH_KEY_NO_DISTANCE_XPATH,
"frr-staticd:staticd", "staticd",
args->vrf, buf_prefix,
yang_afi_safi_value2identity(args->afi,
args->safi),
table_id, buf_nh_type, args->nexthop_vrf,
buf_gate_str, args->interface_name);
yang_afi_safi_value2identity(
args->afi, args->safi),
table_id, buf_nh_type,
args->nexthop_vrf, buf_gate_str,
args->interface_name);
}
dnode = yang_dnode_get(vty->candidate_config->dnode, ab_xpath);