diff options
Diffstat (limited to 'zebra/zebra_fpm.c')
| -rw-r--r-- | zebra/zebra_fpm.c | 71 |
1 files changed, 41 insertions, 30 deletions
diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c index afa557096c..405b2e9f79 100644 --- a/zebra/zebra_fpm.c +++ b/zebra/zebra_fpm.c @@ -25,10 +25,12 @@ #include <zebra.h> #include "log.h" +#include "libfrr.h" #include "stream.h" #include "thread.h" #include "network.h" #include "command.h" +#include "version.h" #include "zebra/rib.h" #include "zebra/zserv.h" @@ -36,7 +38,6 @@ #include "zebra/zebra_vrf.h" #include "fpm/fpm.h" -#include "zebra_fpm.h" #include "zebra_fpm_private.h" /* @@ -254,6 +255,8 @@ typedef struct zfpm_glob_t_ static zfpm_glob_t zfpm_glob_space; static zfpm_glob_t *zfpm_g = &zfpm_glob_space; +static int zfpm_trigger_update (struct route_node *rn, const char *reason); + static int zfpm_read_cb (struct thread *thread); static int zfpm_write_cb (struct thread *thread); @@ -1296,7 +1299,6 @@ zfpm_start_connect_timer (const char *reason) zfpm_set_state (ZFPM_STATE_ACTIVE, reason); } -#if defined (HAVE_FPM) /* * zfpm_is_enabled * @@ -1307,7 +1309,6 @@ zfpm_is_enabled (void) { return zfpm_g->enabled; } -#endif /* * zfpm_conn_is_up @@ -1331,7 +1332,7 @@ zfpm_conn_is_up (void) * The zebra code invokes this function to indicate that we should * send an update to the FPM about the given route_node. */ -void +static int zfpm_trigger_update (struct route_node *rn, const char *reason) { rib_dest_t *dest; @@ -1342,7 +1343,7 @@ zfpm_trigger_update (struct route_node *rn, const char *reason) * all destinations once the connection comes up. */ if (!zfpm_conn_is_up ()) - return; + return 0; dest = rib_dest_from_rnode (rn); @@ -1353,12 +1354,12 @@ zfpm_trigger_update (struct route_node *rn, const char *reason) if (!zfpm_is_table_for_fpm (rib_dest_table (dest))) { zfpm_g->stats.non_fpm_table_triggers++; - return; + return 0; } if (CHECK_FLAG (dest->flags, RIB_DEST_UPDATE_FPM)) { zfpm_g->stats.redundant_triggers++; - return; + return 0; } if (reason) @@ -1375,9 +1376,10 @@ zfpm_trigger_update (struct route_node *rn, const char *reason) * Make sure that writes are enabled. */ if (zfpm_g->t_write) - return; + return 0; zfpm_write_on (); + return 0; } /* @@ -1411,7 +1413,6 @@ zfpm_stats_timer_cb (struct thread *t) return 0; } -#if defined (HAVE_FPM) /* * zfpm_stop_stats_timer */ @@ -1424,7 +1425,6 @@ zfpm_stop_stats_timer (void) zfpm_debug ("Stopping existing stats timer"); THREAD_TIMER_OFF (zfpm_g->t_stats); } -#endif /* * zfpm_start_stats_timer @@ -1447,7 +1447,6 @@ zfpm_start_stats_timer (void) zfpm_g->last_ivl_stats.counter, VTY_NEWLINE); \ } while (0) -#if defined (HAVE_FPM) /* * zfpm_show_stats */ @@ -1600,7 +1599,6 @@ DEFUN ( no_fpm_remote_ip, return CMD_SUCCESS; } -#endif /* * zfpm_init_message_format @@ -1670,7 +1668,7 @@ zfpm_init_message_format (const char *format) * Returns ZERO on success. */ -int fpm_remote_srv_write (struct vty *vty ) +static int fpm_remote_srv_write (struct vty *vty) { struct in_addr in; @@ -1684,6 +1682,15 @@ int fpm_remote_srv_write (struct vty *vty ) } +/* Zebra node */ +static struct cmd_node zebra_node = +{ + ZEBRA_NODE, + "", + 1 +}; + + /** * zfpm_init * @@ -1695,17 +1702,12 @@ int fpm_remote_srv_write (struct vty *vty ) * * Returns TRUE on success. */ -int -zfpm_init (struct thread_master *master, int enable, uint16_t port, - const char *format) +static int +zfpm_init (struct thread_master *master) { - static int initialized = 0; - - if (initialized) { - return 1; - } - - initialized = 1; + int enable = 1; + uint16_t port = 0; + const char *format = THIS_MODULE->load_args; memset (zfpm_g, 0, sizeof (*zfpm_g)); zfpm_g->master = master; @@ -1717,12 +1719,11 @@ zfpm_init (struct thread_master *master, int enable, uint16_t port, zfpm_stats_init (&zfpm_g->last_ivl_stats); zfpm_stats_init (&zfpm_g->cumulative_stats); -#if defined (HAVE_FPM) + install_node (&zebra_node, fpm_remote_srv_write); install_element (ENABLE_NODE, &show_zebra_fpm_stats_cmd); install_element (ENABLE_NODE, &clear_zebra_fpm_stats_cmd); install_element (CONFIG_NODE, &fpm_remote_ip_cmd); install_element (CONFIG_NODE, &no_fpm_remote_ip_cmd); -#endif zfpm_init_message_format(format); @@ -1734,10 +1735,6 @@ zfpm_init (struct thread_master *master, int enable, uint16_t port, zfpm_g->enabled = enable; - if (!enable) { - return 1; - } - if (!zfpm_g->fpm_server) zfpm_g->fpm_server = FPM_DEFAULT_IP; @@ -1751,6 +1748,20 @@ zfpm_init (struct thread_master *master, int enable, uint16_t port, zfpm_start_stats_timer (); zfpm_start_connect_timer ("initialized"); + return 0; +} - return 1; +static int +zebra_fpm_module_init (void) +{ + hook_register(rib_update, zfpm_trigger_update); + hook_register(frr_late_init, zfpm_init); + return 0; } + +FRR_MODULE_SETUP( + .name = "zebra_fpm", + .version = FRR_VERSION, + .description = "zebra FPM (Forwarding Plane Manager) module", + .init = zebra_fpm_module_init, +) |
