summaryrefslogtreecommitdiff
path: root/zebra/zebra_fpm.c
diff options
context:
space:
mode:
authorAmeya Dharkar <adharkar@vmware.com>2019-05-16 16:40:19 -0700
committerAmeya Dharkar <adharkar@vmware.com>2019-06-17 12:05:38 -0700
commitfbe748e59fdff41a0ae8a07c42041bcfecb39f92 (patch)
treedd1d33150284e13eecfc9ae573c903b785cade74 /zebra/zebra_fpm.c
parent21d814eb0bf5918ed8d34de6e8c1c866e6681f09 (diff)
Zebra: Handle FPM connection up/down events
- When the connection with the FPM socket is established, iterate through all the L3VNIs and send all the RMACs for FPM processing zfpm_conn_up_thread_cb" - We have already handled connection down even in previous commits. When the FPM connection goes down, empty mac_q and FPM mac info hash table "zfpm_conn_down_thread_cb" Signed-off-by: Ameya Dharkar <adharkar@vmware.com>
Diffstat (limited to 'zebra/zebra_fpm.c')
-rw-r--r--zebra/zebra_fpm.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/zebra/zebra_fpm.c b/zebra/zebra_fpm.c
index 46fd405761..83d0dba61f 100644
--- a/zebra/zebra_fpm.c
+++ b/zebra/zebra_fpm.c
@@ -50,7 +50,6 @@ DEFINE_MTYPE_STATIC(ZEBRA, FPM_MAC_INFO, "FPM_MAC_INFO");
* Interval at which we attempt to connect to the FPM.
*/
#define ZFPM_CONNECT_RETRY_IVL 5
-#define FPM_MAX_MAC_MSG_LEN 512
/*
* Sizes of outgoing and incoming stream buffers for writing/reading
@@ -69,6 +68,9 @@ DEFINE_MTYPE_STATIC(ZEBRA, FPM_MAC_INFO, "FPM_MAC_INFO");
* Interval over which we collect statistics.
*/
#define ZFPM_STATS_IVL_SECS 10
+#define FPM_MAX_MAC_MSG_LEN 512
+
+static void zfpm_iterate_rmac_table(struct hash_backet *backet, void *args);
/*
* Structure that holds state for iterating over all route_node
@@ -519,6 +521,9 @@ static int zfpm_conn_up_thread_cb(struct thread *thread)
goto done;
}
+ /* Enqueue FPM updates for all the RMAC entries */
+ hash_iterate(zrouter.l3vni_table, zfpm_iterate_rmac_table, NULL);
+
while ((rnode = zfpm_rnodes_iter_next(iter))) {
dest = rib_dest_from_rnode(rnode);
@@ -1635,6 +1640,33 @@ static int zfpm_trigger_rmac_update(zebra_mac_t *rmac, zebra_l3vni_t *zl3vni,
}
/*
+ * This function is called when the FPM connections is established.
+ * Iterate over all the RMAC entries for the given L3VNI
+ * and enqueue the RMAC for FPM processing.
+ */
+static void zfpm_trigger_rmac_update_wrapper(struct hash_backet *backet,
+ void *args)
+{
+ zebra_mac_t *zrmac = (zebra_mac_t *)backet->data;
+ zebra_l3vni_t *zl3vni = (zebra_l3vni_t *)args;
+
+ zfpm_trigger_rmac_update(zrmac, zl3vni, false, "RMAC added");
+}
+
+/*
+ * This function is called when the FPM connections is established.
+ * This function iterates over all the L3VNIs to trigger
+ * FPM updates for RMACs currently available.
+ */
+static void zfpm_iterate_rmac_table(struct hash_backet *backet, void *args)
+{
+ zebra_l3vni_t *zl3vni = (zebra_l3vni_t *)backet->data;
+
+ hash_iterate(zl3vni->rmac_table, zfpm_trigger_rmac_update_wrapper,
+ (void *)zl3vni);
+}
+
+/*
* zfpm_stats_timer_cb
*/
static int zfpm_stats_timer_cb(struct thread *t)
@@ -1951,8 +1983,8 @@ static int zfpm_init(struct thread_master *master)
/* Create hash table for fpm_mac_info_t enties */
zfpm_g->fpm_mac_info_table = hash_create(zfpm_mac_info_hash_keymake,
- zfpm_mac_info_cmp,
- "FPM MAC info hash table");
+ zfpm_mac_info_cmp,
+ "FPM MAC info hash table");
zfpm_g->sock = -1;
zfpm_g->state = ZFPM_STATE_IDLE;