]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_advertise.h
Merge pull request #5717 from pguibert6WIND/flowspec_issue_redistribute
[mirror_frr.git] / bgpd / bgp_advertise.h
index 920cca63018567569268abf343fc73151dbbe543..c983598756e90612f69cb9b463204762a1892b26 100644 (file)
 #ifndef _QUAGGA_BGP_ADVERTISE_H
 #define _QUAGGA_BGP_ADVERTISE_H
 
-#include <lib/fifo.h>
+#include "lib/typesafe.h"
 
-struct update_subgroup;
+PREDECL_DLIST(bgp_adv_fifo)
 
-/* BGP advertise FIFO.  */
-struct bgp_advertise_fifo {
-       struct bgp_advertise *next;
-       struct bgp_advertise *prev;
-       uint32_t count;
-};
+struct update_subgroup;
 
 /* BGP advertise attribute.  */
 struct bgp_advertise_attr {
@@ -46,7 +41,7 @@ struct bgp_advertise_attr {
 
 struct bgp_advertise {
        /* FIFO for advertisement.  */
-       struct bgp_advertise_fifo fifo;
+       struct bgp_adv_fifo_item fifo;
 
        /* Link list for same attribute advertise.  */
        struct bgp_advertise *next;
@@ -62,14 +57,15 @@ struct bgp_advertise {
        struct bgp_advertise_attr *baa;
 
        /* BGP info.  */
-       struct bgp_info *binfo;
+       struct bgp_path_info *pathi;
 };
 
+DECLARE_DLIST(bgp_adv_fifo, struct bgp_advertise, fifo)
+
 /* BGP adjacency out.  */
 struct bgp_adj_out {
-       /* Lined list pointer.  */
-       struct bgp_adj_out *next;
-       struct bgp_adj_out *prev;
+       /* RB Tree of adjacency entries */
+       RB_ENTRY(bgp_adj_out) adj_entry;
 
        /* Advertised subgroup.  */
        struct update_subgroup *subgroup;
@@ -89,6 +85,10 @@ struct bgp_adj_out {
        struct bgp_advertise *adv;
 };
 
+RB_HEAD(bgp_adj_out_rb, bgp_adj_out);
+RB_PROTOTYPE(bgp_adj_out_rb, bgp_adj_out, adj_entry,
+            bgp_adj_out_compare);
+
 /* BGP adjacency in. */
 struct bgp_adj_in {
        /* Linked list pointer.  */
@@ -101,19 +101,22 @@ struct bgp_adj_in {
        /* Received attribute.  */
        struct attr *attr;
 
+       /* timestamp (monotime) */
+       time_t uptime;
+
        /* Addpath identifier */
        uint32_t addpath_rx_id;
 };
 
 /* BGP advertisement list.  */
 struct bgp_synchronize {
-       struct bgp_advertise_fifo update;
-       struct bgp_advertise_fifo withdraw;
-       struct bgp_advertise_fifo withdraw_low;
+       struct bgp_adv_fifo_head update;
+       struct bgp_adv_fifo_head withdraw;
+       struct bgp_adv_fifo_head withdraw_low;
 };
 
 /* BGP adjacency linked list.  */
-#define BGP_INFO_ADD(N, A, TYPE)                                               \
+#define BGP_PATH_INFO_ADD(N, A, TYPE)                                          \
        do {                                                                   \
                (A)->prev = NULL;                                              \
                (A)->next = (N)->TYPE;                                         \
@@ -122,7 +125,7 @@ struct bgp_synchronize {
                (N)->TYPE = (A);                                               \
        } while (0)
 
-#define BGP_INFO_DEL(N, A, TYPE)                                               \
+#define BGP_PATH_INFO_DEL(N, A, TYPE)                                          \
        do {                                                                   \
                if ((A)->next)                                                 \
                        (A)->next->prev = (A)->prev;                           \
@@ -132,40 +135,8 @@ struct bgp_synchronize {
                        (N)->TYPE = (A)->next;                                 \
        } while (0)
 
-#define BGP_ADJ_IN_ADD(N,A)    BGP_INFO_ADD(N,A,adj_in)
-#define BGP_ADJ_IN_DEL(N,A)    BGP_INFO_DEL(N,A,adj_in)
-#define BGP_ADJ_OUT_ADD(N,A)   BGP_INFO_ADD(N,A,adj_out)
-#define BGP_ADJ_OUT_DEL(N,A)   BGP_INFO_DEL(N,A,adj_out)
-
-#define BGP_ADV_FIFO_ADD(F, N)                                                 \
-       do {                                                                   \
-               FIFO_ADD((F), (N));                                            \
-               (F)->count++;                                                  \
-       } while (0)
-
-#define BGP_ADV_FIFO_DEL(F, N)                                                 \
-       do {                                                                   \
-               FIFO_DEL((N));                                                 \
-               (F)->count--;                                                  \
-       } while (0)
-
-#define BGP_ADV_FIFO_INIT(F)                                                   \
-       do {                                                                   \
-               FIFO_INIT((F));                                                \
-               (F)->count = 0;                                                \
-       } while (0)
-
-#define BGP_ADV_FIFO_COUNT(F) (F)->count
-
-#define BGP_ADV_FIFO_EMPTY(F)                                                  \
-       (((struct bgp_advertise_fifo *)(F))->next                              \
-        == (struct bgp_advertise *)(F))
-
-#define BGP_ADV_FIFO_HEAD(F)                                                   \
-       ((((struct bgp_advertise_fifo *)(F))->next                             \
-         == (struct bgp_advertise *)(F))                                      \
-                ? NULL                                                        \
-                : (F)->next)
+#define BGP_ADJ_IN_ADD(N, A) BGP_PATH_INFO_ADD(N, A, adj_in)
+#define BGP_ADJ_IN_DEL(N, A) BGP_PATH_INFO_DEL(N, A, adj_in)
 
 /* Prototypes.  */
 extern int bgp_adj_out_lookup(struct peer *, struct bgp_node *, uint32_t);
@@ -176,8 +147,8 @@ extern void bgp_adj_in_remove(struct bgp_node *, struct bgp_adj_in *);
 
 extern void bgp_sync_init(struct peer *);
 extern void bgp_sync_delete(struct peer *);
-extern unsigned int baa_hash_key(void *p);
-extern int baa_hash_cmp(const void *p1, const void *p2);
+extern unsigned int baa_hash_key(const void *p);
+extern bool baa_hash_cmp(const void *p1, const void *p2);
 extern void bgp_advertise_add(struct bgp_advertise_attr *baa,
                              struct bgp_advertise *adv);
 extern struct bgp_advertise *bgp_advertise_new(void);