summaryrefslogtreecommitdiffstats
path: root/vrrpd/vrrp_northbound.c
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@nvidia.com>2020-08-11 20:24:56 +0200
committerQuentin Young <qlyoung@nvidia.com>2020-08-11 22:57:42 +0200
commit8a601eb7fdf0482e856db3c5a54b8cbe4b443420 (patch)
tree2531a4860d32b5eb72b138fcd77e156de78838ba /vrrpd/vrrp_northbound.c
parentvrrpd: fix improper NB query during validation (diff)
downloadfrr-8a601eb7fdf0482e856db3c5a54b8cbe4b443420.tar.xz
frr-8a601eb7fdf0482e856db3c5a54b8cbe4b443420.zip
vrrpd: log errmsg, stricter nb validation
* When failing a config transaction due to a VRID conflict, describe the error in the provided space * When validating, allow the NB userdata lookup for interface object to soft fail; but when applying, assert if it does not exist Signed-off-by: Quentin Young <qlyoung@nvidia.com>
Diffstat (limited to 'vrrpd/vrrp_northbound.c')
-rw-r--r--vrrpd/vrrp_northbound.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/vrrpd/vrrp_northbound.c b/vrrpd/vrrp_northbound.c
index bc5acdcd1..f814963fe 100644
--- a/vrrpd/vrrp_northbound.c
+++ b/vrrpd/vrrp_northbound.c
@@ -40,16 +40,21 @@ static int lib_interface_vrrp_vrrp_group_create(struct nb_cb_create_args *args)
uint8_t version = 3;
struct vrrp_vrouter *vr;
- ifp = nb_running_get_entry(args->dnode, NULL, false);
vrid = yang_dnode_get_uint8(args->dnode, "./virtual-router-id");
version = yang_dnode_get_enum(args->dnode, "./version");
switch (args->event) {
case NB_EV_VALIDATE:
+ ifp = nb_running_get_entry(args->dnode, NULL, false);
if (ifp) {
vr = vrrp_lookup(ifp, vrid);
- if (vr && vr->autoconf)
+ if (vr && vr->autoconf) {
+ snprintf(
+ args->errmsg, args->errmsg_len,
+ "Virtual Router with ID %d already exists on interface '%s'; created by VRRP autoconfiguration",
+ vrid, ifp->name);
return NB_ERR_VALIDATION;
+ }
}
return NB_OK;
case NB_EV_PREPARE:
@@ -59,6 +64,7 @@ static int lib_interface_vrrp_vrrp_group_create(struct nb_cb_create_args *args)
break;
}
+ ifp = nb_running_get_entry(args->dnode, NULL, true);
vr = vrrp_vrouter_create(ifp, vrid, version);
nb_running_set_entry(args->dnode, vr);