]> git.proxmox.com Git - mirror_frr.git/blobdiff - lib/if.c
Merge pull request #7220 from idryzhov/fix-clear-isis
[mirror_frr.git] / lib / if.c
index 3620f20e4bdb0c3558c3aee639212014f023cecf..304840e5b9ee4710e982d87502c4d03eff6e5bb2 100644 (file)
--- a/lib/if.c
+++ b/lib/if.c
@@ -188,7 +188,9 @@ void if_destroy_via_zapi(struct interface *ifp)
        if (ifp_master.destroy_hook)
                (*ifp_master.destroy_hook)(ifp);
 
+       ifp->oldifindex = ifp->ifindex;
        if_set_index(ifp, IFINDEX_INTERNAL);
+
        if (!ifp->configured)
                if_delete(&ifp);
 }
@@ -217,16 +219,14 @@ struct interface *if_create_name(const char *name, vrf_id_t vrf_id)
        return ifp;
 }
 
-struct interface *if_create_ifindex(ifindex_t ifindex, vrf_id_t vrf_id,
-                                   char *optional_name)
+struct interface *if_create_ifindex(ifindex_t ifindex, vrf_id_t vrf_id)
 {
        struct interface *ifp;
 
        ifp = if_new(vrf_id);
 
        if_set_index(ifp, ifindex);
-       if (optional_name)
-               if_set_name(ifp, optional_name);
+
        hook_call(if_add, ifp);
        return ifp;
 }
@@ -573,8 +573,7 @@ struct interface *if_get_by_name(const char *name, vrf_id_t vrf_id)
        return NULL;
 }
 
-struct interface *if_get_by_ifindex(ifindex_t ifindex, vrf_id_t vrf_id,
-                                   char *optional_name)
+struct interface *if_get_by_ifindex(ifindex_t ifindex, vrf_id_t vrf_id)
 {
        struct interface *ifp;
 
@@ -584,7 +583,7 @@ struct interface *if_get_by_ifindex(ifindex_t ifindex, vrf_id_t vrf_id,
                ifp = if_lookup_by_ifindex(ifindex, vrf_id);
                if (ifp)
                        return ifp;
-               return if_create_ifindex(ifindex, vrf_id, optional_name);
+               return if_create_ifindex(ifindex, vrf_id);
        case VRF_BACKEND_VRF_LITE:
                ifp = if_lookup_by_index_all_vrf(ifindex);
                if (ifp) {
@@ -596,7 +595,7 @@ struct interface *if_get_by_ifindex(ifindex_t ifindex, vrf_id_t vrf_id,
                        if_update_to_new_vrf(ifp, vrf_id);
                        return ifp;
                }
-               return if_create_ifindex(ifindex, vrf_id, optional_name);
+               return if_create_ifindex(ifindex, vrf_id);
        }
 
        return NULL;
@@ -803,44 +802,6 @@ void if_dump_all(void)
                        if_dump(ifp);
 }
 
-#ifdef SUNOS_5
-/* Need to handle upgrade from SUNWzebra to Quagga. SUNWzebra created
- * a seperate struct interface for each logical interface, so config
- * file may be full of 'interface fooX:Y'. Solaris however does not
- * expose logical interfaces via PF_ROUTE, so trying to track logical
- * interfaces can be fruitless, for that reason Quagga only tracks
- * the primary IP interface.
- *
- * We try accomodate SUNWzebra by:
- * - looking up the interface name, to see whether it exists, if so
- *   its useable
- *   - for protocol daemons, this could only because zebra told us of
- *     the interface
- *   - for zebra, only because it learnt from kernel
- * - if not:
- *   - search the name to see if it contains a sub-ipif / logical interface
- *     seperator, the ':' char. If it does:
- *     - text up to that char must be the primary name - get that name.
- *     if not:
- *     - no idea, just get the name in its entirety.
- */
-static struct interface *if_sunwzebra_get(const char *name, vrf_id_t vrf_id)
-{
-       struct interface *ifp;
-       char *cp;
-
-       if ((ifp = if_lookup_by_name(name, vrf_id)) != NULL)
-               return ifp;
-
-       /* hunt the primary interface name... */
-       cp = strchr(name, ':');
-       if (cp)
-               *cp = '\0';
-
-       return if_get_by_name(name, vrf_id);
-}
-#endif /* SUNOS_5 */
-
 #if 0
 /* For debug purpose. */
 DEFUN (show_address,
@@ -1321,7 +1282,7 @@ void if_link_params_free(struct interface *ifp)
 /*
  * XPath: /frr-interface:lib/interface
  */
-DEFPY_NOSH (interface,
+DEFPY_YANG_NOSH (interface,
        interface_cmd,
        "interface IFNAME [vrf NAME$vrf_name]",
        "Select an interface to configure\n"
@@ -1384,6 +1345,7 @@ DEFPY_NOSH (interface,
                 * all interface-level commands are converted to the new
                 * northbound model.
                 */
+               nb_cli_pending_commit_check(vty);
                ifp = if_lookup_by_name(ifname, vrf_id);
                if (ifp)
                        VTY_PUSH_CONTEXT(INTERFACE_NODE, ifp);
@@ -1392,7 +1354,7 @@ DEFPY_NOSH (interface,
        return ret;
 }
 
-DEFPY (no_interface,
+DEFPY_YANG (no_interface,
        no_interface_cmd,
        "no interface IFNAME [vrf NAME$vrf_name]",
        NO_STR
@@ -1427,7 +1389,7 @@ static void cli_show_interface(struct vty *vty, struct lyd_node *dnode,
 /*
  * XPath: /frr-interface:lib/interface/description
  */
-DEFPY (interface_desc,
+DEFPY_YANG (interface_desc,
        interface_desc_cmd,
        "description LINE...",
        "Interface specific description\n"
@@ -1444,7 +1406,7 @@ DEFPY (interface_desc,
        return ret;
 }
 
-DEFPY  (no_interface_desc,
+DEFPY_YANG  (no_interface_desc,
        no_interface_desc_cmd,
        "no description",
        NO_STR
@@ -1554,11 +1516,7 @@ static int lib_interface_create(struct nb_cb_create_args *args)
        case NB_EV_APPLY:
                vrf = vrf_lookup_by_name(vrfname);
                assert(vrf);
-#ifdef SUNOS_5
-               ifp = if_sunwzebra_get(ifname, vrf->vrf_id);
-#else
                ifp = if_get_by_name(ifname, vrf->vrf_id);
-#endif /* SUNOS_5 */
 
                ifp->configured = true;
                nb_running_set_entry(args->dnode, ifp);