mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-13 16:26:10 +00:00
*: add errmsg to nb rpc
Display human readable error message in northbound rpc transaction failure. In case of vtysh nb client, the error message will be displayed to user. Testing: bharat# clear evpn dup-addr vni 1002 ip 11.11.11.11 Error type: generic error Error description: Requested IP's associated MAC aa:aa:aa:aa:aa:aa is still in duplicate state Signed-off-by: Chirag Shah <chirag@nvidia.com>
This commit is contained in:
parent
002bac8b5b
commit
f63f5f1947
@ -1142,7 +1142,8 @@ const void *nb_callback_lookup_entry(const struct nb_node *nb_node,
|
|||||||
}
|
}
|
||||||
|
|
||||||
int nb_callback_rpc(const struct nb_node *nb_node, const char *xpath,
|
int nb_callback_rpc(const struct nb_node *nb_node, const char *xpath,
|
||||||
const struct list *input, struct list *output)
|
const struct list *input, struct list *output, char *errmsg,
|
||||||
|
size_t errmsg_len)
|
||||||
{
|
{
|
||||||
struct nb_cb_rpc_args args = {};
|
struct nb_cb_rpc_args args = {};
|
||||||
|
|
||||||
@ -1151,6 +1152,8 @@ int nb_callback_rpc(const struct nb_node *nb_node, const char *xpath,
|
|||||||
args.xpath = xpath;
|
args.xpath = xpath;
|
||||||
args.input = input;
|
args.input = input;
|
||||||
args.output = output;
|
args.output = output;
|
||||||
|
args.errmsg = errmsg;
|
||||||
|
args.errmsg_len = errmsg_len;
|
||||||
return nb_node->cbs.rpc(&args);
|
return nb_node->cbs.rpc(&args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -258,6 +258,12 @@ struct nb_cb_rpc_args {
|
|||||||
|
|
||||||
/* List of output parameters to be populated by the callback. */
|
/* List of output parameters to be populated by the callback. */
|
||||||
struct list *output;
|
struct list *output;
|
||||||
|
|
||||||
|
/* Buffer to store human-readable error message in case of error. */
|
||||||
|
char *errmsg;
|
||||||
|
|
||||||
|
/* Size of errmsg. */
|
||||||
|
size_t errmsg_len;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -689,7 +695,8 @@ extern const void *nb_callback_lookup_entry(const struct nb_node *nb_node,
|
|||||||
const void *parent_list_entry,
|
const void *parent_list_entry,
|
||||||
const struct yang_list_keys *keys);
|
const struct yang_list_keys *keys);
|
||||||
extern int nb_callback_rpc(const struct nb_node *nb_node, const char *xpath,
|
extern int nb_callback_rpc(const struct nb_node *nb_node, const char *xpath,
|
||||||
const struct list *input, struct list *output);
|
const struct list *input, struct list *output,
|
||||||
|
char *errmsg, size_t errmsg_len);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a northbound node for all YANG schema nodes.
|
* Create a northbound node for all YANG schema nodes.
|
||||||
|
@ -284,10 +284,12 @@ int nb_cli_apply_changes(struct vty *vty, const char *xpath_base_fmt, ...)
|
|||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
int nb_cli_rpc(const char *xpath, struct list *input, struct list *output)
|
int nb_cli_rpc(struct vty *vty, const char *xpath, struct list *input,
|
||||||
|
struct list *output)
|
||||||
{
|
{
|
||||||
struct nb_node *nb_node;
|
struct nb_node *nb_node;
|
||||||
int ret;
|
int ret;
|
||||||
|
char errmsg[BUFSIZ] = {0};
|
||||||
|
|
||||||
nb_node = nb_node_find(xpath);
|
nb_node = nb_node_find(xpath);
|
||||||
if (!nb_node) {
|
if (!nb_node) {
|
||||||
@ -296,11 +298,14 @@ int nb_cli_rpc(const char *xpath, struct list *input, struct list *output)
|
|||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = nb_callback_rpc(nb_node, xpath, input, output);
|
ret = nb_callback_rpc(nb_node, xpath, input, output, errmsg,
|
||||||
|
sizeof(errmsg));
|
||||||
switch (ret) {
|
switch (ret) {
|
||||||
case NB_OK:
|
case NB_OK:
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
default:
|
default:
|
||||||
|
if (strlen(errmsg))
|
||||||
|
vty_show_nb_errors(vty, ret, errmsg);
|
||||||
return CMD_WARNING;
|
return CMD_WARNING;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -75,6 +75,9 @@ extern int nb_cli_apply_changes(struct vty *vty, const char *xpath_base_fmt,
|
|||||||
/*
|
/*
|
||||||
* Execute a YANG RPC or Action.
|
* Execute a YANG RPC or Action.
|
||||||
*
|
*
|
||||||
|
* vty
|
||||||
|
* The vty terminal to dump any error.
|
||||||
|
*
|
||||||
* xpath
|
* xpath
|
||||||
* XPath of the YANG RPC or Action node.
|
* XPath of the YANG RPC or Action node.
|
||||||
*
|
*
|
||||||
@ -90,7 +93,7 @@ extern int nb_cli_apply_changes(struct vty *vty, const char *xpath_base_fmt,
|
|||||||
* Returns:
|
* Returns:
|
||||||
* CMD_SUCCESS on success, CMD_WARNING otherwise.
|
* CMD_SUCCESS on success, CMD_WARNING otherwise.
|
||||||
*/
|
*/
|
||||||
extern int nb_cli_rpc(const char *xpath, struct list *input,
|
extern int nb_cli_rpc(struct vty *vty, const char *xpath, struct list *input,
|
||||||
struct list *output);
|
struct list *output);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1068,6 +1068,7 @@ static int frr_confd_action_execute(struct confd_user_info *uinfo,
|
|||||||
struct yang_data *data;
|
struct yang_data *data;
|
||||||
confd_tag_value_t *reply;
|
confd_tag_value_t *reply;
|
||||||
int ret = CONFD_OK;
|
int ret = CONFD_OK;
|
||||||
|
char errmsg[BUFSIZ] = {0};
|
||||||
|
|
||||||
/* Getting the XPath is tricky. */
|
/* Getting the XPath is tricky. */
|
||||||
if (kp) {
|
if (kp) {
|
||||||
@ -1115,7 +1116,9 @@ static int frr_confd_action_execute(struct confd_user_info *uinfo,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Execute callback registered for this XPath. */
|
/* Execute callback registered for this XPath. */
|
||||||
if (nb_callback_rpc(nb_node, xpath, input, output) != NB_OK) {
|
if (nb_callback_rpc(nb_node, xpath, input, output, errmsg,
|
||||||
|
sizeof(errmsg))
|
||||||
|
!= NB_OK) {
|
||||||
flog_warn(EC_LIB_NB_CB_RPC, "%s: rpc callback failed: %s",
|
flog_warn(EC_LIB_NB_CB_RPC, "%s: rpc callback failed: %s",
|
||||||
__func__, xpath);
|
__func__, xpath);
|
||||||
ret = CONFD_ERR;
|
ret = CONFD_ERR;
|
||||||
|
@ -962,6 +962,7 @@ class NorthboundImpl
|
|||||||
struct listnode *node;
|
struct listnode *node;
|
||||||
struct yang_data *data;
|
struct yang_data *data;
|
||||||
const char *xpath;
|
const char *xpath;
|
||||||
|
char errmsg[BUFSIZ] = {0};
|
||||||
|
|
||||||
switch (tag->state) {
|
switch (tag->state) {
|
||||||
case CREATE:
|
case CREATE:
|
||||||
@ -1012,7 +1013,7 @@ class NorthboundImpl
|
|||||||
|
|
||||||
// Execute callback registered for this XPath.
|
// Execute callback registered for this XPath.
|
||||||
if (nb_callback_rpc(nb_node, xpath, input_list,
|
if (nb_callback_rpc(nb_node, xpath, input_list,
|
||||||
output_list)
|
output_list, errmsg, sizeof(errmsg))
|
||||||
!= NB_OK) {
|
!= NB_OK) {
|
||||||
flog_warn(EC_LIB_NB_CB_RPC,
|
flog_warn(EC_LIB_NB_CB_RPC,
|
||||||
"%s: rpc callback failed: %s",
|
"%s: rpc callback failed: %s",
|
||||||
|
@ -414,6 +414,7 @@ static int frr_sr_config_rpc_cb(sr_session_ctx_t *session, const char *xpath,
|
|||||||
struct yang_data *data;
|
struct yang_data *data;
|
||||||
size_t cb_output_cnt;
|
size_t cb_output_cnt;
|
||||||
int ret = SR_ERR_OK;
|
int ret = SR_ERR_OK;
|
||||||
|
char errmsg[BUFSIZ] = {0};
|
||||||
|
|
||||||
nb_node = nb_node_find(xpath);
|
nb_node = nb_node_find(xpath);
|
||||||
if (!nb_node) {
|
if (!nb_node) {
|
||||||
@ -436,7 +437,9 @@ static int frr_sr_config_rpc_cb(sr_session_ctx_t *session, const char *xpath,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Execute callback registered for this XPath. */
|
/* Execute callback registered for this XPath. */
|
||||||
if (nb_callback_rpc(nb_node, xpath, input, output) != NB_OK) {
|
if (nb_callback_rpc(nb_node, xpath, input, output, errmsg,
|
||||||
|
sizeof(errmsg))
|
||||||
|
!= NB_OK) {
|
||||||
flog_warn(EC_LIB_NB_CB_RPC, "%s: rpc callback failed: %s",
|
flog_warn(EC_LIB_NB_CB_RPC, "%s: rpc callback failed: %s",
|
||||||
__func__, xpath);
|
__func__, xpath);
|
||||||
ret = SR_ERR_OPERATION_FAILED;
|
ret = SR_ERR_OPERATION_FAILED;
|
||||||
|
@ -1012,7 +1012,7 @@ DEFPY_YANG (clear_ip_rip,
|
|||||||
listnode_add(input, yang_vrf);
|
listnode_add(input, yang_vrf);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = nb_cli_rpc("/frr-ripd:clear-rip-route", input, NULL);
|
ret = nb_cli_rpc(vty, "/frr-ripd:clear-rip-route", input, NULL);
|
||||||
|
|
||||||
list_delete(&input);
|
list_delete(&input);
|
||||||
|
|
||||||
|
@ -496,7 +496,7 @@ DEFPY_YANG (clear_ipv6_rip,
|
|||||||
listnode_add(input, yang_vrf);
|
listnode_add(input, yang_vrf);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = nb_cli_rpc("/frr-ripngd:clear-ripng-route", input, NULL);
|
ret = nb_cli_rpc(vty, "/frr-ripngd:clear-ripng-route", input, NULL);
|
||||||
|
|
||||||
list_delete(&input);
|
list_delete(&input);
|
||||||
|
|
||||||
|
@ -3264,7 +3264,8 @@ DEFPY (clear_evpn_dup_addr,
|
|||||||
|
|
||||||
if (yang_dup) {
|
if (yang_dup) {
|
||||||
listnode_add(input, yang_dup);
|
listnode_add(input, yang_dup);
|
||||||
ret = nb_cli_rpc("/frr-zebra:clear-evpn-dup-addr", input, NULL);
|
ret = nb_cli_rpc(vty, "/frr-zebra:clear-evpn-dup-addr", input,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
list_delete(&input);
|
list_delete(&input);
|
||||||
|
Loading…
Reference in New Issue
Block a user