]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zebra_mlag_private.c
zebra: Unlock the route node when sending route notifications
[mirror_frr.git] / zebra / zebra_mlag_private.c
index aaf93b4dc17ffd7429ecd77d6a4f25117bec917e..f348c50755c121e03148a6a3fc902d84ee54841c 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
  * This is an implementation of MLAG Functionality
  *
@@ -6,29 +7,15 @@
  * Author: sathesh Kumar karra <sathk@cumulusnetworks.com>
  *
  * Copyright (C) 2019 Cumulus Networks http://www.cumulusnetworks.com
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the Free
- * Software Foundation; either version 2 of the License, or (at your option)
- * any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; see the file COPYING; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  */
 #include "zebra.h"
 
 #include "hook.h"
 #include "module.h"
-#include "thread.h"
+#include "frrevent.h"
 #include "frr_pthread.h"
 #include "libfrr.h"
-#include "version.h"
+#include "lib/version.h"
 #include "network.h"
 
 #include "lib/stream.h"
  *
  */
 
-static struct thread_master *zmlag_master;
+static struct event_loop *zmlag_master;
 static int mlag_socket;
 
-static int zebra_mlag_connect(struct thread *thread);
-static int zebra_mlag_read(struct thread *thread);
+static void zebra_mlag_connect(struct event *thread);
+static void zebra_mlag_read(struct event *thread);
 
 /*
  * Write the data to MLAGD
@@ -68,11 +55,11 @@ static int zebra_mlag_private_write_data(uint8_t *data, uint32_t len)
 
 static void zebra_mlag_sched_read(void)
 {
-       thread_add_read(zmlag_master, zebra_mlag_read, NULL, mlag_socket,
-                       &zrouter.mlag_info.t_read);
+       event_add_read(zmlag_master, zebra_mlag_read, NULL, mlag_socket,
+                      &zrouter.mlag_info.t_read);
 }
 
-static int zebra_mlag_read(struct thread *thread)
+static void zebra_mlag_read(struct event *thread)
 {
        static uint32_t mlag_rd_buf_offset;
        uint32_t *msglen;
@@ -98,13 +85,13 @@ static int zebra_mlag_read(struct thread *thread)
                                           mlag_socket);
                        close(mlag_socket);
                        zebra_mlag_handle_process_state(MLAG_DOWN);
-                       return -1;
+                       return;
                }
                mlag_rd_buf_offset += data_len;
                if (data_len != (ssize_t)(ZEBRA_MLAG_LEN_SIZE - curr_len)) {
                        /* Try again later */
                        zebra_mlag_sched_read();
-                       return 0;
+                       return;
                }
                curr_len = ZEBRA_MLAG_LEN_SIZE;
        }
@@ -136,13 +123,13 @@ static int zebra_mlag_read(struct thread *thread)
                                           mlag_socket);
                        close(mlag_socket);
                        zebra_mlag_handle_process_state(MLAG_DOWN);
-                       return -1;
+                       return;
                }
                mlag_rd_buf_offset += data_len;
                if (data_len != (ssize_t)(tot_len - curr_len)) {
                        /* Try again later */
                        zebra_mlag_sched_read();
-                       return 0;
+                       return;
                }
        }
 
@@ -162,10 +149,9 @@ static int zebra_mlag_read(struct thread *thread)
        zebra_mlag_reset_read_buffer();
        mlag_rd_buf_offset = 0;
        zebra_mlag_sched_read();
-       return 0;
 }
 
-static int zebra_mlag_connect(struct thread *thread)
+static void zebra_mlag_connect(struct event *thread)
 {
        struct sockaddr_un svr = {0};
 
@@ -178,7 +164,7 @@ static int zebra_mlag_connect(struct thread *thread)
 
        mlag_socket = socket(svr.sun_family, SOCK_STREAM, 0);
        if (mlag_socket < 0)
-               return -1;
+               return;
 
        if (connect(mlag_socket, (struct sockaddr *)&svr, sizeof(svr)) == -1) {
                if (IS_ZEBRA_DEBUG_MLAG)
@@ -187,9 +173,9 @@ static int zebra_mlag_connect(struct thread *thread)
                                svr.sun_path);
                close(mlag_socket);
                zrouter.mlag_info.timer_running = true;
-               thread_add_timer(zmlag_master, zebra_mlag_connect, NULL, 10,
-                                &zrouter.mlag_info.t_read);
-               return 0;
+               event_add_timer(zmlag_master, zebra_mlag_connect, NULL, 10,
+                               &zrouter.mlag_info.t_read);
+               return;
        }
 
        set_nonblocking(mlag_socket);
@@ -198,13 +184,12 @@ static int zebra_mlag_connect(struct thread *thread)
                zlog_debug("%s: Connection with MLAG is established ",
                           __func__);
 
-       thread_add_read(zmlag_master, zebra_mlag_read, NULL, mlag_socket,
-                       &zrouter.mlag_info.t_read);
+       event_add_read(zmlag_master, zebra_mlag_read, NULL, mlag_socket,
+                      &zrouter.mlag_info.t_read);
        /*
         * Connection is established with MLAGD, post to clients
         */
        zebra_mlag_handle_process_state(MLAG_UP);
-       return 0;
 }
 
 /*
@@ -212,8 +197,8 @@ static int zebra_mlag_connect(struct thread *thread)
  */
 static int zebra_mlag_private_monitor_state(void)
 {
-       thread_add_event(zmlag_master, zebra_mlag_connect, NULL, 0,
-                        &zrouter.mlag_info.t_read);
+       event_add_event(zmlag_master, zebra_mlag_connect, NULL, 0,
+                       &zrouter.mlag_info.t_read);
        return 0;
 }
 
@@ -240,8 +225,8 @@ static int zebra_mlag_private_open_channel(void)
                /*
                 * Connect only if any clients are showing interest
                 */
-               thread_add_event(zmlag_master, zebra_mlag_connect, NULL, 0,
-                                &zrouter.mlag_info.t_read);
+               event_add_event(zmlag_master, zebra_mlag_connect, NULL, 0,
+                               &zrouter.mlag_info.t_read);
        }
        return 0;
 }