]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_advertise.h
zebra, lib: fix the ZEBRA_INTERFACE_VRF_UPDATE zapi message
[mirror_frr.git] / bgpd / bgp_advertise.h
index 03a1ffcb99199045e5734314ba7f522f51df9ded..9aa5a0eaff518c159dde3a2c03d1a4dd600ee543 100644 (file)
 struct update_subgroup;
 
 /* BGP advertise FIFO.  */
-struct bgp_advertise_fifo
-{
-  struct bgp_advertise *next;
-  struct bgp_advertise *prev;
-  u_int32_t count;
+struct bgp_advertise_fifo {
+       struct bgp_advertise *next;
+       struct bgp_advertise *prev;
+       uint32_t count;
 };
 
 /* BGP advertise attribute.  */
-struct bgp_advertise_attr
-{
-  /* Head of advertisement pointer. */
-  struct bgp_advertise *adv;
+struct bgp_advertise_attr {
+       /* Head of advertisement pointer. */
+       struct bgp_advertise *adv;
 
-  /* Reference counter.  */
-  unsigned long refcnt;
+       /* Reference counter.  */
+       unsigned long refcnt;
 
-  /* Attribute pointer to be announced.  */
-  struct attr *attr;
+       /* Attribute pointer to be announced.  */
+       struct attr *attr;
 };
 
-struct bgp_advertise
-{
-  /* FIFO for advertisement.  */
-  struct bgp_advertise_fifo fifo;
+struct bgp_advertise {
+       /* FIFO for advertisement.  */
+       struct bgp_advertise_fifo fifo;
 
-  /* Link list for same attribute advertise.  */
-  struct bgp_advertise *next;
-  struct bgp_advertise *prev;
+       /* Link list for same attribute advertise.  */
+       struct bgp_advertise *next;
+       struct bgp_advertise *prev;
 
-  /* Prefix information.  */
-  struct bgp_node *rn;
+       /* Prefix information.  */
+       struct bgp_node *rn;
 
-  /* Reference pointer.  */
-  struct bgp_adj_out *adj;
+       /* Reference pointer.  */
+       struct bgp_adj_out *adj;
 
-  /* Advertisement attribute.  */
-  struct bgp_advertise_attr *baa;
+       /* Advertisement attribute.  */
+       struct bgp_advertise_attr *baa;
 
-  /* BGP info.  */
-  struct bgp_info *binfo;
+       /* BGP info.  */
+       struct bgp_path_info *pathi;
 };
 
 /* BGP adjacency out.  */
-struct bgp_adj_out
-{
-  /* Lined list pointer.  */
-  struct bgp_adj_out *next;
-  struct bgp_adj_out *prev;
+struct bgp_adj_out {
+       /* RB Tree of adjacency entries */
+       RB_ENTRY(bgp_adj_out) adj_entry;
 
-  /* Advertised subgroup.  */
-  struct update_subgroup *subgroup;
+       /* Advertised subgroup.  */
+       struct update_subgroup *subgroup;
 
-  /* Threading that makes the adj part of subgroup's adj queue */
-  TAILQ_ENTRY(bgp_adj_out) subgrp_adj_train;
+       /* Threading that makes the adj part of subgroup's adj queue */
+       TAILQ_ENTRY(bgp_adj_out) subgrp_adj_train;
 
-  /* Prefix information.  */
-  struct bgp_node *rn;
+       /* Prefix information.  */
+       struct bgp_node *rn;
 
-  u_int32_t addpath_tx_id;
+       uint32_t addpath_tx_id;
 
-  /* Advertised attribute.  */
-  struct attr *attr;
+       /* Advertised attribute.  */
+       struct attr *attr;
 
-  /* Advertisement information.  */
-  struct bgp_advertise *adv;
+       /* Advertisement information.  */
+       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.  */
-  struct bgp_adj_in *next;
-  struct bgp_adj_in *prev;
+struct bgp_adj_in {
+       /* Linked list pointer.  */
+       struct bgp_adj_in *next;
+       struct bgp_adj_in *prev;
 
-  /* Received peer.  */
-  struct peer *peer;
+       /* Received peer.  */
+       struct peer *peer;
 
-  /* Received attribute.  */
-  struct attr *attr;
+       /* Received attribute.  */
+       struct attr *attr;
 
-  /* Addpath identifier */
-  u_int32_t addpath_rx_id;
+       /* 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_synchronize {
+       struct bgp_advertise_fifo update;
+       struct bgp_advertise_fifo withdraw;
+       struct bgp_advertise_fifo withdraw_low;
 };
 
 /* BGP adjacency linked list.  */
-#define BGP_INFO_ADD(N,A,TYPE)                        \
-  do {                                                \
-    (A)->prev = NULL;                                 \
-    (A)->next = (N)->TYPE;                            \
-    if ((N)->TYPE)                                    \
-      (N)->TYPE->prev = (A);                          \
-    (N)->TYPE = (A);                                  \
-  } while (0)
-
-#define BGP_INFO_DEL(N,A,TYPE)                        \
-  do {                                                \
-    if ((A)->next)                                    \
-      (A)->next->prev = (A)->prev;                    \
-    if ((A)->prev)                                    \
-      (A)->prev->next = (A)->next;                    \
-    else                                              \
-      (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_PATH_INFO_ADD(N, A, TYPE)                                          \
+       do {                                                                   \
+               (A)->prev = NULL;                                              \
+               (A)->next = (N)->TYPE;                                         \
+               if ((N)->TYPE)                                                 \
+                       (N)->TYPE->prev = (A);                                 \
+               (N)->TYPE = (A);                                               \
+       } while (0)
+
+#define BGP_PATH_INFO_DEL(N, A, TYPE)                                          \
+       do {                                                                   \
+               if ((A)->next)                                                 \
+                       (A)->next->prev = (A)->prev;                           \
+               if ((A)->prev)                                                 \
+                       (A)->prev->next = (A)->next;                           \
+               else                                                           \
+                       (N)->TYPE = (A)->next;                                 \
+       } while (0)
+
+#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)
+
+#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)
 
 /* Prototypes.  */
-extern int bgp_adj_out_lookup (struct peer *, struct bgp_node *, u_int32_t);
-extern void bgp_adj_in_set (struct bgp_node *, struct peer *, struct attr *, u_int32_t);
-extern int bgp_adj_in_unset (struct bgp_node *, struct peer *, u_int32_t);
-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 void bgp_advertise_add (struct bgp_advertise_attr *baa,
-                              struct bgp_advertise *adv);
-extern struct bgp_advertise *bgp_advertise_new (void);
-extern void bgp_advertise_free (struct bgp_advertise *adv);
-extern struct bgp_advertise_attr *
-bgp_advertise_intern (struct hash *hash, struct attr *attr);
-extern struct bgp_advertise_attr *baa_new (void);
-extern void
-bgp_advertise_delete (struct bgp_advertise_attr *baa,
-                     struct bgp_advertise *adv);
-extern void
-bgp_advertise_unintern (struct hash *hash, struct bgp_advertise_attr *baa);
+extern int bgp_adj_out_lookup(struct peer *, struct bgp_node *, uint32_t);
+extern void bgp_adj_in_set(struct bgp_node *, struct peer *, struct attr *,
+                          uint32_t);
+extern int bgp_adj_in_unset(struct bgp_node *, struct peer *, uint32_t);
+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 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);
+extern void bgp_advertise_free(struct bgp_advertise *adv);
+extern struct bgp_advertise_attr *bgp_advertise_intern(struct hash *hash,
+                                                      struct attr *attr);
+extern struct bgp_advertise_attr *baa_new(void);
+extern void bgp_advertise_delete(struct bgp_advertise_attr *baa,
+                                struct bgp_advertise *adv);
+extern void bgp_advertise_unintern(struct hash *hash,
+                                  struct bgp_advertise_attr *baa);
 
 #endif /* _QUAGGA_BGP_ADVERTISE_H */