]> 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 b909cbcb2b81913cbc9bc54d68f35caf1edd6223..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,21 +346,8 @@ int if_check_address(struct rip *rip, struct in_addr addr)
 }
 
 /* Inteface link down message processing. */
-int rip_interface_down(int command, struct zclient *zclient,
-                      zebra_size_t length, vrf_id_t vrf_id)
+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);
 
@@ -372,18 +361,8 @@ int rip_interface_down(int command, struct zclient *zclient,
 }
 
 /* Inteface link up message processing */
-int rip_interface_up(int command, struct zclient *zclient, zebra_size_t length,
-                    vrf_id_t vrf_id)
+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",
@@ -405,12 +384,8 @@ int rip_interface_up(int command, struct zclient *zclient, zebra_size_t length,
 }
 
 /* Inteface addition message from zebra. */
-int rip_interface_add(int command, struct zclient *zclient, zebra_size_t length,
-                     vrf_id_t vrf_id)
+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)
@@ -436,20 +411,8 @@ int rip_interface_add(int command, struct zclient *zclient, zebra_size_t length,
        return 0;
 }
 
-int rip_interface_delete(int command, struct zclient *zclient,
-                        zebra_size_t length, vrf_id_t vrf_id)
+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);
@@ -460,16 +423,11 @@ int rip_interface_delete(int command, struct zclient *zclient,
                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;
 }
 
 /* VRF update for an interface. */
-int rip_interface_vrf_update(int command, struct zclient *zclient,
-                            zebra_size_t length, vrf_id_t vrf_id)
+int rip_interface_vrf_update(ZAPI_CALLBACK_ARGS)
 {
        struct interface *ifp;
        vrf_id_t new_vrf_id;
@@ -615,8 +573,7 @@ static void rip_apply_address_add(struct connected *ifc)
                                     0);
 }
 
-int rip_interface_address_add(int command, struct zclient *zclient,
-                             zebra_size_t length, vrf_id_t vrf_id)
+int rip_interface_address_add(ZAPI_CALLBACK_ARGS)
 {
        struct connected *ifc;
        struct prefix *p;
@@ -669,8 +626,7 @@ static void rip_apply_address_del(struct connected *ifc)
                                &address, ifc->ifp->ifindex);
 }
 
-int rip_interface_address_delete(int command, struct zclient *zclient,
-                                zebra_size_t length, vrf_id_t vrf_id)
+int rip_interface_address_delete(ZAPI_CALLBACK_ARGS)
 {
        struct connected *ifc;
        struct prefix *p;
@@ -1268,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);
 }