summaryrefslogtreecommitdiff
path: root/lib/if.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/if.c')
-rw-r--r--lib/if.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/lib/if.c b/lib/if.c
index 76568071ef..6766a04b37 100644
--- a/lib/if.c
+++ b/lib/if.c
@@ -38,6 +38,7 @@
#include "lib/if_clippy.c"
DEFINE_MTYPE_STATIC(LIB, IF, "Interface");
+DEFINE_MTYPE_STATIC(LIB, IFDESC, "Intf Desc");
DEFINE_MTYPE_STATIC(LIB, CONNECTED, "Connected");
DEFINE_MTYPE_STATIC(LIB, NBR_CONNECTED, "Neighbor Connected");
DEFINE_MTYPE(LIB, CONNECTED_LABEL, "Connected interface label");
@@ -288,7 +289,7 @@ void if_delete(struct interface **ifp)
if_link_params_free(ptr);
- XFREE(MTYPE_TMP, ptr->desc);
+ XFREE(MTYPE_IFDESC, ptr->desc);
XFREE(MTYPE_IF, ptr);
*ifp = NULL;
@@ -563,9 +564,24 @@ size_t if_lookup_by_hwaddr(const uint8_t *hw_addr, size_t addrsz,
return count;
}
+/* Get the VRF loopback interface, i.e. the loopback on the default VRF
+ * or the VRF interface.
+ */
+struct interface *if_get_vrf_loopback(vrf_id_t vrf_id)
+{
+ struct interface *ifp = NULL;
+ struct vrf *vrf = vrf_lookup_by_id(vrf_id);
+
+ FOR_ALL_INTERFACES (vrf, ifp)
+ if (if_is_loopback(ifp))
+ return ifp;
+
+ return NULL;
+}
/* Get interface by name if given name interface doesn't exist create
- one. */
+ * one.
+ */
struct interface *if_get_by_name(const char *name, vrf_id_t vrf_id,
const char *vrf_name)
{
@@ -1612,9 +1628,9 @@ static int lib_interface_description_modify(struct nb_cb_modify_args *args)
return NB_OK;
ifp = nb_running_get_entry(args->dnode, NULL, true);
- XFREE(MTYPE_TMP, ifp->desc);
+ XFREE(MTYPE_IFDESC, ifp->desc);
description = yang_dnode_get_string(args->dnode, NULL);
- ifp->desc = XSTRDUP(MTYPE_TMP, description);
+ ifp->desc = XSTRDUP(MTYPE_IFDESC, description);
return NB_OK;
}
@@ -1627,7 +1643,7 @@ static int lib_interface_description_destroy(struct nb_cb_destroy_args *args)
return NB_OK;
ifp = nb_running_get_entry(args->dnode, NULL, true);
- XFREE(MTYPE_TMP, ifp->desc);
+ XFREE(MTYPE_IFDESC, ifp->desc);
return NB_OK;
}