]> git.puffer.fish Git - matthieu/frr.git/commitdiff
isisd: fix interface ldp-sync configuration
authorIgor Ryzhov <iryzhov@nfware.com>
Tue, 22 Jun 2021 21:27:55 +0000 (00:27 +0300)
committerIgor Ryzhov <iryzhov@nfware.com>
Wed, 23 Jun 2021 12:52:37 +0000 (15:52 +0300)
There are two checks done when configuring ldp-sync on an interface:
- interface is not a loopback
- interface is in the default VRF
Both checks are incorrectly done using the operational data.

The second check can be done using only config data - do that.

The first check can't be done using only configurational data, but it's
not necessary. LDP sync code doesn't operate on loopback interfaces
already. There's no harm in allowing this to be configured.

Signed-off-by: Igor Ryzhov <iryzhov@nfware.com>
isisd/isis_nb_config.c

index a0da19fce86bf4cb0c3fa20ea448aedd8879c2a8..4a01c728f0732a2336a173f532efe10a809db3f2 100644 (file)
@@ -3204,26 +3204,14 @@ int lib_interface_isis_mpls_ldp_sync_modify(struct nb_cb_modify_args *args)
        struct isis_circuit *circuit;
        struct ldp_sync_info *ldp_sync_info;
        bool ldp_sync_enable;
-       struct interface *ifp;
+       const char *vrfname;
 
        switch (args->event) {
        case NB_EV_VALIDATE:
-               ifp = nb_running_get_entry(
-                       lyd_parent(lyd_parent(lyd_parent(args->dnode))), NULL,
-                       false);
-               if (ifp == NULL)
-                       return NB_ERR_VALIDATION;
-               if (if_is_loopback(ifp)) {
-                       snprintf(args->errmsg, args->errmsg_len,
-                                "LDP-Sync does not run on loopback interface");
-                       return NB_ERR_VALIDATION;
-               }
-
-               circuit = nb_running_get_entry(args->dnode, NULL, false);
-               if (circuit == NULL || circuit->area == NULL)
-                       break;
-
-               if (circuit->isis->vrf_id != VRF_DEFAULT) {
+               vrfname = yang_dnode_get_string(
+                       lyd_parent(lyd_parent(lyd_parent(args->dnode))),
+                       "./vrf");
+               if (strcmp(vrfname, VRF_DEFAULT_NAME)) {
                        snprintf(args->errmsg, args->errmsg_len,
                                 "LDP-Sync only runs on Default VRF");
                        return NB_ERR_VALIDATION;
@@ -3260,27 +3248,14 @@ int lib_interface_isis_mpls_holddown_modify(struct nb_cb_modify_args *args)
        struct isis_circuit *circuit;
        struct ldp_sync_info *ldp_sync_info;
        uint16_t holddown;
-       struct interface *ifp;
+       const char *vrfname;
 
        switch (args->event) {
        case NB_EV_VALIDATE:
-
-               ifp = nb_running_get_entry(
-                       lyd_parent(lyd_parent(lyd_parent(args->dnode))), NULL,
-                       false);
-               if (ifp == NULL)
-                       return NB_ERR_VALIDATION;
-               if (if_is_loopback(ifp)) {
-                       snprintf(args->errmsg, args->errmsg_len,
-                                "LDP-Sync does not run on loopback interface");
-                       return NB_ERR_VALIDATION;
-               }
-
-               circuit = nb_running_get_entry(args->dnode, NULL, false);
-               if (circuit == NULL || circuit->area == NULL)
-                       break;
-
-               if (circuit->isis->vrf_id != VRF_DEFAULT) {
+               vrfname = yang_dnode_get_string(
+                       lyd_parent(lyd_parent(lyd_parent(args->dnode))),
+                       "./vrf");
+               if (strcmp(vrfname, VRF_DEFAULT_NAME)) {
                        snprintf(args->errmsg, args->errmsg_len,
                                 "LDP-Sync only runs on Default VRF");
                        return NB_ERR_VALIDATION;
@@ -3306,26 +3281,14 @@ int lib_interface_isis_mpls_holddown_destroy(struct nb_cb_destroy_args *args)
 {
        struct isis_circuit *circuit;
        struct ldp_sync_info *ldp_sync_info;
-       struct interface *ifp;
+       const char *vrfname;
 
        switch (args->event) {
        case NB_EV_VALIDATE:
-               ifp = nb_running_get_entry(
-                       lyd_parent(lyd_parent(lyd_parent(args->dnode))), NULL,
-                       false);
-               if (ifp == NULL)
-                       return NB_ERR_VALIDATION;
-               if (if_is_loopback(ifp)) {
-                       snprintf(args->errmsg, args->errmsg_len,
-                                "LDP-Sync does not run on loopback interface");
-                       return NB_ERR_VALIDATION;
-               }
-
-               circuit = nb_running_get_entry(args->dnode, NULL, false);
-               if (circuit == NULL || circuit->area == NULL)
-                       break;
-
-               if (circuit->isis->vrf_id != VRF_DEFAULT) {
+               vrfname = yang_dnode_get_string(
+                       lyd_parent(lyd_parent(lyd_parent(args->dnode))),
+                       "./vrf");
+               if (strcmp(vrfname, VRF_DEFAULT_NAME)) {
                        snprintf(args->errmsg, args->errmsg_len,
                                 "LDP-Sync only runs on Default VRF");
                        return NB_ERR_VALIDATION;