]> git.proxmox.com Git - mirror_frr.git/blobdiff - ripd/rip_interface.c
Merge pull request #5197 from SumitAgarwal123/BFD_ADMIN_DOWN
[mirror_frr.git] / ripd / rip_interface.c
index 307785cdb46500ff926d2d0452311a2c245a1e45..3173277ba7553fd449a90b91ea24fa6db090a781 100644 (file)
@@ -43,6 +43,8 @@
 #include "ripd/rip_debug.h"
 #include "ripd/rip_interface.h"
 
+DEFINE_MTYPE_STATIC(RIPD, RIP_INTERFACE, "RIP interface")
+DEFINE_MTYPE(RIPD, RIP_INTERFACE_STRING, "RIP Interface String")
 DEFINE_HOOK(rip_ifaddr_add, (struct connected * ifc), (ifc))
 DEFINE_HOOK(rip_ifaddr_del, (struct connected * ifc), (ifc))
 
@@ -344,48 +346,27 @@ int if_check_address(struct rip *rip, struct in_addr addr)
 }
 
 /* Inteface link down message processing. */
-int rip_interface_down(ZAPI_CALLBACK_ARGS)
+static int rip_ifp_down(struct interface *ifp)
 {
-       struct interface *ifp;
-       struct stream *s;
-
-       s = zclient->ibuf;
-
-       /* zebra_interface_state_read() updates interface structure in
-          iflist. */
-       ifp = zebra_interface_state_read(s, vrf_id);
-
-       if (ifp == NULL)
-               return 0;
-
        rip_interface_sync(ifp);
        rip_if_down(ifp);
 
        if (IS_RIP_DEBUG_ZEBRA)
                zlog_debug(
                        "interface %s vrf %u index %d flags %llx metric %d mtu %d is down",
-                       ifp->name, ifp->vrf->vrf_id, ifp->ifindex,
+                       ifp->name, ifp->vrf_id, ifp->ifindex,
                        (unsigned long long)ifp->flags, ifp->metric, ifp->mtu);
 
        return 0;
 }
 
 /* Inteface link up message processing */
-int rip_interface_up(ZAPI_CALLBACK_ARGS)
+static int rip_ifp_up(struct interface *ifp)
 {
-       struct interface *ifp;
-
-       /* zebra_interface_state_read () updates interface structure in
-          iflist. */
-       ifp = zebra_interface_state_read(zclient->ibuf, vrf_id);
-
-       if (ifp == NULL)
-               return 0;
-
        if (IS_RIP_DEBUG_ZEBRA)
                zlog_debug(
                        "interface %s vrf %u index %d flags %#llx metric %d mtu %d is up",
-                       ifp->name, ifp->vrf->vrf_id, ifp->ifindex,
+                       ifp->name, ifp->vrf_id, ifp->ifindex,
                        (unsigned long long)ifp->flags, ifp->metric, ifp->mtu);
 
        rip_interface_sync(ifp);
@@ -403,17 +384,14 @@ int rip_interface_up(ZAPI_CALLBACK_ARGS)
 }
 
 /* Inteface addition message from zebra. */
-int rip_interface_add(ZAPI_CALLBACK_ARGS)
+static int rip_ifp_create(struct interface *ifp)
 {
-       struct interface *ifp;
-
-       ifp = zebra_interface_add_read(zclient->ibuf, vrf_id);
        rip_interface_sync(ifp);
 
        if (IS_RIP_DEBUG_ZEBRA)
                zlog_debug(
                        "interface add %s vrf %u index %d flags %#llx metric %d mtu %d",
-                       ifp->name, ifp->vrf->vrf_id, ifp->ifindex,
+                       ifp->name, ifp->vrf_id, ifp->ifindex,
                        (unsigned long long)ifp->flags, ifp->metric, ifp->mtu);
 
        /* Check if this interface is RIP enabled or not.*/
@@ -433,19 +411,8 @@ int rip_interface_add(ZAPI_CALLBACK_ARGS)
        return 0;
 }
 
-int rip_interface_delete(ZAPI_CALLBACK_ARGS)
+static int rip_ifp_destroy(struct interface *ifp)
 {
-       struct interface *ifp;
-       struct stream *s;
-
-
-       s = zclient->ibuf;
-       /* zebra_interface_state_read() updates interface structure in iflist */
-       ifp = zebra_interface_state_read(s, vrf_id);
-
-       if (ifp == NULL)
-               return 0;
-
        rip_interface_sync(ifp);
        if (if_is_up(ifp)) {
                rip_if_down(ifp);
@@ -453,13 +420,9 @@ int rip_interface_delete(ZAPI_CALLBACK_ARGS)
 
        zlog_info(
                "interface delete %s vrf %u index %d flags %#llx metric %d mtu %d",
-               ifp->name, ifp->vrf->vrf_id, ifp->ifindex,
+               ifp->name, ifp->vrf_id, ifp->ifindex,
                (unsigned long long)ifp->flags, ifp->metric, ifp->mtu);
 
-       /* To support pseudo interface do not free interface structure.  */
-       /* if_delete(ifp); */
-       if_set_index(ifp, IFINDEX_INTERNAL);
-
        return 0;
 }
 
@@ -468,21 +431,17 @@ int rip_interface_vrf_update(ZAPI_CALLBACK_ARGS)
 {
        struct interface *ifp;
        vrf_id_t new_vrf_id;
-       struct vrf *new_vrf;
 
        ifp = zebra_interface_vrf_update_read(zclient->ibuf, vrf_id,
                                              &new_vrf_id);
        if (!ifp)
                return 0;
 
-       new_vrf = vrf_lookup_by_id(new_vrf_id);
-
        if (IS_RIP_DEBUG_ZEBRA)
                zlog_debug("interface %s VRF change vrf_id %u new vrf id %u",
                           ifp->name, vrf_id, new_vrf_id);
 
-       if_update_to_new_vrf(ifp, new_vrf);
-
+       if_update_to_new_vrf(ifp, new_vrf_id);
        rip_interface_sync(ifp);
 
        return 0;
@@ -1227,7 +1186,7 @@ void rip_interface_sync(struct interface *ifp)
 {
        struct vrf *vrf;
 
-       vrf = ifp->vrf;
+       vrf = vrf_lookup_by_id(ifp->vrf_id);
        if (vrf) {
                struct rip_interface *ri;
 
@@ -1265,4 +1224,6 @@ void rip_if_init(void)
        /* Install interface node. */
        install_node(&interface_node, rip_interface_config_write);
        if_cmd_init();
+       if_zapi_callbacks(rip_ifp_create, rip_ifp_up,
+                         rip_ifp_down, rip_ifp_destroy);
 }