]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/if.c
zebra: if multiple connecteds, select loopback or vrf if present
[mirror_frr.git] / lib / if.c
index e31ccd8563f2744a30ee695e012e33113286fc35..2bf0c6e6b5ae4a93f65bbaacda9a9864eff9eaa0 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -23,6 +23,7 @@
 
 #include "linklist.h"
 #include "vector.h"
+#include "lib_errors.h"
 #include "vty.h"
 #include "command.h"
 #include "vrf.h"
@@ -392,7 +393,8 @@ struct interface *if_get_by_name(const char *name, vrf_id_t vrf_id, int vty)
         * this should not be considered as an update
         * then create the new interface
         */
-       if (ifp->vrf_id != vrf_id && vrf_is_mapped_on_netns(vrf_id))
+       if (ifp->vrf_id != vrf_id && vrf_is_mapped_on_netns(
+                                       vrf_lookup_by_id(vrf_id)))
                return if_create(name, vrf_id);
        /* If it came from the kernel
         * or by way of zclient, believe it and update
@@ -470,6 +472,14 @@ int if_is_vrf(struct interface *ifp)
        return CHECK_FLAG(ifp->status, ZEBRA_INTERFACE_VRF_LOOPBACK);
 }
 
+bool if_is_loopback_or_vrf(struct interface *ifp)
+{
+       if (if_is_loopback(ifp) || if_is_vrf(ifp))
+               return true;
+
+       return false;
+}
+
 /* Does this interface support broadcast ? */
 int if_is_broadcast(struct interface *ifp)
 {
@@ -626,7 +636,7 @@ static struct interface *if_sunwzebra_get(char *name, vrf_id_t vrf_id)
 }
 #endif /* SUNOS_5 */
 
-DEFUN (interface,
+DEFUN_NOSH (interface,
        interface_cmd,
        "interface IFNAME [vrf NAME]",
        "Select an interface to configure\n"
@@ -669,13 +679,13 @@ DEFUN (interface,
        return CMD_SUCCESS;
 }
 
-DEFUN_NOSH (no_interface,
-           no_interface_cmd,
-           "no interface IFNAME [vrf NAME]",
-           NO_STR
-           "Delete a pseudo interface's configuration\n"
-           "Interface's name\n"
-           VRF_CMD_HELP_STR)
+DEFUN (no_interface,
+       no_interface_cmd,
+       "no interface IFNAME [vrf NAME]",
+       NO_STR
+       "Delete a pseudo interface's configuration\n"
+       "Interface's name\n"
+       VRF_CMD_HELP_STR)
 {
        int idx_vrf = 4;
        const char *ifname = argv[2]->arg;
@@ -1139,7 +1149,7 @@ const char *if_link_type_str(enum zebra_link_type llt)
                llts(ZEBRA_LLT_IEEE802154, "IEEE 802.15.4");
                llts(ZEBRA_LLT_IEEE802154_PHY, "IEEE 802.15.4 Phy");
        default:
-               zlog_warn("Unknown value %d", llt);
+               flog_err(LIB_ERR_DEVELOPMENT, "Unknown value %d", llt);
                return "Unknown type!";
 #undef llts
        }