diff options
-rw-r--r-- | lib/lib_vty.c | 4 | ||||
-rw-r--r-- | lib/northbound.c | 26 | ||||
-rw-r--r-- | lib/northbound.h | 9 | ||||
-rw-r--r-- | lib/vty.c | 58 | ||||
-rw-r--r-- | lib/vty.h | 12 | ||||
-rw-r--r-- | staticd/static_vty.c | 62 | ||||
-rw-r--r-- | vtysh/vtysh.h | 2 |
7 files changed, 83 insertions, 90 deletions
diff --git a/lib/lib_vty.c b/lib/lib_vty.c index 3e4dc9d78..c13d88a1e 100644 --- a/lib/lib_vty.c +++ b/lib/lib_vty.c @@ -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 diff --git a/lib/northbound.c b/lib/northbound.c index b91308fb1..24f7ecd70 100644 --- a/lib/northbound.c +++ b/lib/northbound.c @@ -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__); diff --git a/lib/northbound.h b/lib/northbound.h index 96f257c8d..4b5028c87 100644 --- a/lib/northbound.h +++ b/lib/northbound.h @@ -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. @@ -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; } @@ -3471,7 +3466,7 @@ int vty_mgmt_send_lockds_req(struct vty *vty, Mgmtd__DatastoreId ds_id, if (mgmt_lib_hndl && vty->mgmt_session_id) { vty->mgmt_req_id++; ret = mgmt_fe_lock_ds(mgmt_lib_hndl, vty->mgmt_session_id, - vty->mgmt_req_id, ds_id, lock); + vty->mgmt_req_id, ds_id, lock); if (ret != MGMTD_SUCCESS) { zlog_err( "Failed to send %sLOCK-DS-REQ to MGMTD for req-id %llu.", @@ -3493,7 +3488,7 @@ int vty_mgmt_send_config_data(struct vty *vty) Mgmtd__YangDataValue value[VTY_MAXCFGCHANGES]; Mgmtd__YangData cfg_data[VTY_MAXCFGCHANGES]; Mgmtd__YangCfgDataReq cfg_req[VTY_MAXCFGCHANGES]; - Mgmtd__YangCfgDataReq * cfgreq[VTY_MAXCFGCHANGES] = {0}; + Mgmtd__YangCfgDataReq *cfgreq[VTY_MAXCFGCHANGES] = {0}; size_t indx; int cnt; bool implicit_commit = false; @@ -3508,7 +3503,7 @@ int vty_mgmt_send_config_data(struct vty *vty) value[cnt].encoded_str_val = (char *)vty->cfg_changes[indx].value; value[cnt].value_case = - MGMTD__YANG_DATA_VALUE__VALUE_ENCODED_STR_VAL; + MGMTD__YANG_DATA_VALUE__VALUE_ENCODED_STR_VAL; cfg_data[cnt].value = &value[cnt]; } @@ -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( - mgmt_lib_hndl, vty->mgmt_session_id, - vty->mgmt_req_id, MGMTD_DS_CANDIDATE, cfgreq, - cnt, implicit_commit, MGMTD_DS_RUNNING) - != MGMTD_SUCCESS) { + 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) { zlog_err("Failed to send %d Config Xpaths to MGMTD!!", (int)indx); return -1; @@ -3595,7 +3589,7 @@ int vty_mgmt_send_get_config(struct vty *vty, Mgmtd__DatastoreId datastore, enum mgmt_result ret; Mgmtd__YangData yang_data[VTY_MAXCFGCHANGES]; Mgmtd__YangGetDataReq get_req[VTY_MAXCFGCHANGES]; - Mgmtd__YangGetDataReq * getreq[VTY_MAXCFGCHANGES]; + Mgmtd__YangGetDataReq *getreq[VTY_MAXCFGCHANGES]; int i; vty->mgmt_req_id++; @@ -3610,8 +3604,8 @@ int vty_mgmt_send_get_config(struct vty *vty, Mgmtd__DatastoreId datastore, getreq[i] = &get_req[i]; } ret = mgmt_fe_get_config_data(mgmt_lib_hndl, vty->mgmt_session_id, - vty->mgmt_req_id, datastore, getreq, - num_req); + vty->mgmt_req_id, datastore, getreq, + num_req); if (ret != MGMTD_SUCCESS) { zlog_err("Failed to send GET-CONFIG to MGMTD for req-id %llu.", @@ -3631,7 +3625,7 @@ int vty_mgmt_send_get_data(struct vty *vty, Mgmtd__DatastoreId datastore, enum mgmt_result ret; Mgmtd__YangData yang_data[VTY_MAXCFGCHANGES]; Mgmtd__YangGetDataReq get_req[VTY_MAXCFGCHANGES]; - Mgmtd__YangGetDataReq * getreq[VTY_MAXCFGCHANGES]; + Mgmtd__YangGetDataReq *getreq[VTY_MAXCFGCHANGES]; int i; vty->mgmt_req_id++; @@ -3646,7 +3640,7 @@ int vty_mgmt_send_get_data(struct vty *vty, Mgmtd__DatastoreId datastore, getreq[i] = &get_req[i]; } ret = mgmt_fe_get_data(mgmt_lib_hndl, vty->mgmt_session_id, - vty->mgmt_req_id, datastore, getreq, num_req); + vty->mgmt_req_id, datastore, getreq, num_req); if (ret != MGMTD_SUCCESS) { zlog_err("Failed to send GET-DATA to MGMTD for req-id %llu.", @@ -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,11 +404,10 @@ 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) - ? false - : true) - : false); + ? ((vty->pending_allowed || vty->no_implicit_commit) + ? false + : true) + : false); } #ifdef __cplusplus diff --git a/staticd/static_vty.c b/staticd/static_vty.c index 2761b63e8..386b255a8 100644 --- a/staticd/static_vty.c +++ b/staticd/static_vty.c @@ -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,49 +370,48 @@ 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), - FRR_DEL_S_ROUTE_SRC_NH_KEY_XPATH, - "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); + 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), + buf_src_prefix, table_id, distance, + 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), - FRR_DEL_S_ROUTE_NH_KEY_XPATH, - "frr-staticd:staticd", "staticd", - args->vrf, buf_prefix, - yang_afi_safi_value2identity(args->afi, - args->safi), - table_id, distance, buf_nh_type, - args->nexthop_vrf, buf_gate_str, - args->interface_name); + 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), + table_id, distance, buf_nh_type, + args->nexthop_vrf, buf_gate_str, + args->interface_name); else snprintf( ab_xpath, sizeof(ab_xpath), 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); diff --git a/vtysh/vtysh.h b/vtysh/vtysh.h index 1a3b1a0de..2c202c353 100644 --- a/vtysh/vtysh.h +++ b/vtysh/vtysh.h @@ -34,7 +34,7 @@ extern struct thread_master *master; #define VTYSH_VRRPD 0x40000 #define VTYSH_PATHD 0x80000 #define VTYSH_PIM6D 0x100000 -#define VTYSH_MGMTD 0x200000 +#define VTYSH_MGMTD 0x200000 #define VTYSH_WAS_ACTIVE (-2) |