]> git.puffer.fish Git - matthieu/frr.git/commitdiff
vrrpd: log errmsg, stricter nb validation
authorQuentin Young <qlyoung@nvidia.com>
Tue, 11 Aug 2020 18:24:56 +0000 (14:24 -0400)
committerQuentin Young <qlyoung@nvidia.com>
Tue, 11 Aug 2020 20:57:42 +0000 (16:57 -0400)
* 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>
vrrpd/vrrp_northbound.c

index bc5acdcd17c1f1489cbc48c9f717af53a6b0228b..f814963fe5407b7bc86b535dd47a2088a7f1548a 100644 (file)
@@ -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);