]> git.proxmox.com Git - mirror_frr.git/blobdiff - zebra/zserv.h
Merge pull request #6033 from rubenk/lib-do-not-use-aliased-inet-ntop-on-apple
[mirror_frr.git] / zebra / zserv.h
index ccc8d92aa2d6f5d311e2dcbdb0ec86d3d1fec119..6a075cc9a738a99d7f53a1ae5d45d97591cf1163 100644 (file)
@@ -52,6 +52,42 @@ extern "C" {
 
 #define ZEBRA_RMAP_DEFAULT_UPDATE_TIMER 5 /* disabled by default */
 
+
+/* Stale route marker timer */
+#define ZEBRA_DEFAULT_STALE_UPDATE_DELAY 1
+
+/* Count of stale routes processed in timer context */
+#define ZEBRA_MAX_STALE_ROUTE_COUNT 50000
+
+/* Graceful Restart information */
+struct client_gr_info {
+       /* VRF for which GR enabled */
+       vrf_id_t vrf_id;
+
+       /* AFI */
+       afi_t current_afi;
+
+       /* Stale time and GR cap */
+       uint32_t stale_removal_time;
+       enum zserv_client_capabilities capabilities;
+
+       /* GR commands */
+       bool delete;
+       bool gr_enable;
+       bool stale_client;
+
+       /* Route sync and enable flags for AFI/SAFI */
+       bool af_enabled[AFI_MAX][SAFI_MAX];
+       bool route_sync[AFI_MAX][SAFI_MAX];
+
+       /* Book keeping */
+       struct prefix *current_prefix;
+       void *stale_client_ptr;
+       struct thread *t_stale_removal;
+
+       TAILQ_ENTRY(client_gr_info) gr_info;
+};
+
 /* Client structure. */
 struct zserv {
        /* Client pthread */
@@ -146,6 +182,7 @@ struct zserv {
        uint32_t v6_nh_watch_rem_cnt;
        uint32_t vxlan_sg_add_cnt;
        uint32_t vxlan_sg_del_cnt;
+       uint32_t error_cnt;
 
        time_t nh_reg_time;
        time_t nh_dereg_time;
@@ -169,6 +206,19 @@ struct zserv {
        _Atomic uint32_t last_read_cmd;
        /* command code of last message written */
        _Atomic uint32_t last_write_cmd;
+
+       /*
+        * Number of instances configured with
+        * graceful restart
+        */
+       uint32_t gr_instance_count;
+       time_t restart_time;
+
+       /*
+        * Graceful restart information for
+        * each instance
+        */
+       TAILQ_HEAD(info_list, client_gr_info) gr_info_queue;
 };
 
 #define ZAPI_HANDLER_ARGS                                                      \
@@ -179,6 +229,10 @@ struct zserv {
 DECLARE_HOOK(zserv_client_connect, (struct zserv *client), (client));
 DECLARE_KOOH(zserv_client_close, (struct zserv *client), (client));
 
+#define DYNAMIC_CLIENT_GR_DISABLED(_client)                                    \
+       ((_client->proto <= ZEBRA_ROUTE_CONNECT)                               \
+        || !(_client->gr_instance_count))
+
 /*
  * Initialize Zebra API server.
  *
@@ -229,7 +283,6 @@ extern int zserv_send_message(struct zserv *client, struct stream *msg);
  */
 extern struct zserv *zserv_find_client(uint8_t proto, unsigned short instance);
 
-
 /*
  * Close a client.
  *
@@ -241,7 +294,6 @@ extern struct zserv *zserv_find_client(uint8_t proto, unsigned short instance);
  */
 extern void zserv_close_client(struct zserv *client);
 
-
 /*
  * Log a ZAPI message hexdump.
  *
@@ -264,6 +316,16 @@ extern void zserv_read_file(char *input);
 /* TODO */
 int zebra_finalize(struct thread *event);
 
+/*
+ * Graceful restart functions.
+ */
+extern int zebra_gr_client_disconnect(struct zserv *client);
+extern void zebra_gr_client_reconnect(struct zserv *client);
+extern void zebra_gr_stale_client_cleanup(struct list *client_list);
+extern void zread_client_capabilities(struct zserv *client, struct zmsghdr *hdr,
+                                     struct stream *msg,
+                                     struct zebra_vrf *zvrf);
+
 #ifdef __cplusplus
 }
 #endif