diff options
Diffstat (limited to 'lib/if.c')
| -rw-r--r-- | lib/if.c | 51 |
1 files changed, 40 insertions, 11 deletions
@@ -35,11 +35,10 @@ #include "buffer.h" #include "log.h" #include "northbound_cli.h" -#ifndef VTYSH_EXTRACT_PL #include "lib/if_clippy.c" -#endif 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"); @@ -290,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; @@ -565,6 +564,20 @@ 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. */ @@ -1095,13 +1108,15 @@ const char *if_link_type_str(enum zebra_link_type llt) struct if_link_params *if_link_params_get(struct interface *ifp) { - int i; + return ifp->link_params; +} - if (ifp->link_params != NULL) - return ifp->link_params; +struct if_link_params *if_link_params_enable(struct interface *ifp) +{ + struct if_link_params *iflp; + int i; - struct if_link_params *iflp = - XCALLOC(MTYPE_IF_LINK_PARAMS, sizeof(struct if_link_params)); + iflp = if_link_params_init(ifp); /* Compute default bandwidth based on interface */ iflp->default_bw = @@ -1129,6 +1144,20 @@ struct if_link_params *if_link_params_get(struct interface *ifp) return iflp; } +struct if_link_params *if_link_params_init(struct interface *ifp) +{ + struct if_link_params *iflp = if_link_params_get(ifp); + + if (iflp) + return iflp; + + iflp = XCALLOC(MTYPE_IF_LINK_PARAMS, sizeof(struct if_link_params)); + + ifp->link_params = iflp; + + return iflp; +} + void if_link_params_free(struct interface *ifp) { XFREE(MTYPE_IF_LINK_PARAMS, ifp->link_params); @@ -1598,9 +1627,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; } @@ -1613,7 +1642,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; } |
