]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: do static mroute loop check in NB VALIDATE 8148/head
authorQuentin Young <qlyoung@nvidia.com>
Wed, 24 Feb 2021 22:57:26 +0000 (17:57 -0500)
committerQuentin Young <qlyoung@nvidia.com>
Wed, 24 Feb 2021 22:57:26 +0000 (17:57 -0500)
We can proactively check whether this mroute will be nacked by loopfree
MFC checks so let's do it in the apply phase and emit a useful error
message.

Signed-off-by: Quentin Young <qlyoung@nvidia.com>
pimd/pim_nb_config.c

index 4bc78529a83a9b9c53dcc1fdfcc77f29c2a72043..11cfe09964389a7c6e99add26d4d03fc3b940be6 100644 (file)
@@ -2394,6 +2394,13 @@ int lib_interface_pim_address_family_mroute_oif_modify(
        struct ipaddr group_addr;
        const struct lyd_node *if_dnode;
 
+       iif = nb_running_get_entry(args->dnode, NULL, true);
+       pim_iifp = iif->info;
+       pim = pim_iifp->pim;
+
+       oifname = yang_dnode_get_string(args->dnode, NULL);
+       oif = if_lookup_by_name(oifname, pim->vrf_id);
+
        switch (args->event) {
        case NB_EV_VALIDATE:
                if_dnode = yang_dnode_get_parent(args->dnode, "interface");
@@ -2402,18 +2409,20 @@ int lib_interface_pim_address_family_mroute_oif_modify(
                                 "%% Enable PIM and/or IGMP on this interface first");
                        return NB_ERR_VALIDATION;
                }
+
+#ifdef PIM_ENFORCE_LOOPFREE_MFC
+               if (iif->ifindex == oif->ifindex) {
+                       strlcpy(args->errmsg,
+                               "% IIF same as OIF and loopfree enforcement is enabled; rejecting",
+                               args->errmsg_len);
+                       return NB_ERR_VALIDATION;
+               }
+#endif
                break;
        case NB_EV_PREPARE:
        case NB_EV_ABORT:
                break;
        case NB_EV_APPLY:
-               iif = nb_running_get_entry(args->dnode, NULL, true);
-               pim_iifp = iif->info;
-               pim = pim_iifp->pim;
-
-               oifname = yang_dnode_get_string(args->dnode, NULL);
-               oif = if_lookup_by_name(oifname, pim->vrf_id);
-
                if (!oif) {
                        snprintf(args->errmsg, args->errmsg_len,
                                 "No such interface name %s",