]>
Commit | Line | Data |
---|---|---|
acddc0ed | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
718e3744 | 2 | /* BGP advertisement and adjacency |
896014f4 | 3 | * Copyright (C) 1996, 97, 98, 99, 2000 Kunihiro Ishiguro |
896014f4 | 4 | */ |
718e3744 | 5 | |
00d252cb | 6 | #ifndef _QUAGGA_BGP_ADVERTISE_H |
7 | #define _QUAGGA_BGP_ADVERTISE_H | |
8 | ||
a274fef8 | 9 | #include "lib/typesafe.h" |
ea863ec6 | 10 | |
960b9a53 | 11 | PREDECL_DLIST(bgp_adv_fifo); |
3f9c7369 | 12 | |
a274fef8 | 13 | struct update_subgroup; |
718e3744 | 14 | |
15 | /* BGP advertise attribute. */ | |
d62a17ae | 16 | struct bgp_advertise_attr { |
17 | /* Head of advertisement pointer. */ | |
18 | struct bgp_advertise *adv; | |
718e3744 | 19 | |
d62a17ae | 20 | /* Reference counter. */ |
21 | unsigned long refcnt; | |
718e3744 | 22 | |
d62a17ae | 23 | /* Attribute pointer to be announced. */ |
24 | struct attr *attr; | |
718e3744 | 25 | }; |
26 | ||
d62a17ae | 27 | struct bgp_advertise { |
28 | /* FIFO for advertisement. */ | |
a274fef8 | 29 | struct bgp_adv_fifo_item fifo; |
718e3744 | 30 | |
d62a17ae | 31 | /* Link list for same attribute advertise. */ |
32 | struct bgp_advertise *next; | |
33 | struct bgp_advertise *prev; | |
718e3744 | 34 | |
d62a17ae | 35 | /* Prefix information. */ |
9bcb3eef | 36 | struct bgp_dest *dest; |
718e3744 | 37 | |
d62a17ae | 38 | /* Reference pointer. */ |
39 | struct bgp_adj_out *adj; | |
718e3744 | 40 | |
d62a17ae | 41 | /* Advertisement attribute. */ |
42 | struct bgp_advertise_attr *baa; | |
718e3744 | 43 | |
d62a17ae | 44 | /* BGP info. */ |
9b6d8fcf | 45 | struct bgp_path_info *pathi; |
718e3744 | 46 | }; |
47 | ||
960b9a53 | 48 | DECLARE_DLIST(bgp_adv_fifo, struct bgp_advertise, fifo); |
a274fef8 | 49 | |
718e3744 | 50 | /* BGP adjacency out. */ |
d62a17ae | 51 | struct bgp_adj_out { |
a79c04e7 DS |
52 | /* RB Tree of adjacency entries */ |
53 | RB_ENTRY(bgp_adj_out) adj_entry; | |
718e3744 | 54 | |
d62a17ae | 55 | /* Advertised subgroup. */ |
56 | struct update_subgroup *subgroup; | |
3f9c7369 | 57 | |
d62a17ae | 58 | /* Threading that makes the adj part of subgroup's adj queue */ |
59 | TAILQ_ENTRY(bgp_adj_out) subgrp_adj_train; | |
3f9c7369 | 60 | |
d62a17ae | 61 | /* Prefix information. */ |
9bcb3eef | 62 | struct bgp_dest *dest; |
718e3744 | 63 | |
d7c0a89a | 64 | uint32_t addpath_tx_id; |
adbac85e | 65 | |
d62a17ae | 66 | /* Advertised attribute. */ |
67 | struct attr *attr; | |
718e3744 | 68 | |
d62a17ae | 69 | /* Advertisement information. */ |
70 | struct bgp_advertise *adv; | |
2adac256 DA |
71 | |
72 | /* Attribute hash */ | |
73 | uint32_t attr_hash; | |
718e3744 | 74 | }; |
75 | ||
a79c04e7 DS |
76 | RB_HEAD(bgp_adj_out_rb, bgp_adj_out); |
77 | RB_PROTOTYPE(bgp_adj_out_rb, bgp_adj_out, adj_entry, | |
78 | bgp_adj_out_compare); | |
79 | ||
718e3744 | 80 | /* BGP adjacency in. */ |
d62a17ae | 81 | struct bgp_adj_in { |
82 | /* Linked list pointer. */ | |
83 | struct bgp_adj_in *next; | |
84 | struct bgp_adj_in *prev; | |
718e3744 | 85 | |
d62a17ae | 86 | /* Received peer. */ |
87 | struct peer *peer; | |
718e3744 | 88 | |
d62a17ae | 89 | /* Received attribute. */ |
90 | struct attr *attr; | |
43143c8f | 91 | |
6566d669 DL |
92 | /* timestamp (monotime) */ |
93 | time_t uptime; | |
94 | ||
d62a17ae | 95 | /* Addpath identifier */ |
d7c0a89a | 96 | uint32_t addpath_rx_id; |
718e3744 | 97 | }; |
98 | ||
99 | /* BGP advertisement list. */ | |
d62a17ae | 100 | struct bgp_synchronize { |
a274fef8 DL |
101 | struct bgp_adv_fifo_head update; |
102 | struct bgp_adv_fifo_head withdraw; | |
103 | struct bgp_adv_fifo_head withdraw_low; | |
718e3744 | 104 | }; |
105 | ||
718e3744 | 106 | /* BGP adjacency linked list. */ |
1defdda8 | 107 | #define BGP_PATH_INFO_ADD(N, A, TYPE) \ |
d62a17ae | 108 | do { \ |
109 | (A)->prev = NULL; \ | |
110 | (A)->next = (N)->TYPE; \ | |
111 | if ((N)->TYPE) \ | |
112 | (N)->TYPE->prev = (A); \ | |
113 | (N)->TYPE = (A); \ | |
114 | } while (0) | |
115 | ||
1defdda8 | 116 | #define BGP_PATH_INFO_DEL(N, A, TYPE) \ |
d62a17ae | 117 | do { \ |
118 | if ((A)->next) \ | |
119 | (A)->next->prev = (A)->prev; \ | |
120 | if ((A)->prev) \ | |
121 | (A)->prev->next = (A)->next; \ | |
122 | else \ | |
123 | (N)->TYPE = (A)->next; \ | |
124 | } while (0) | |
718e3744 | 125 | |
1defdda8 DS |
126 | #define BGP_ADJ_IN_ADD(N, A) BGP_PATH_INFO_ADD(N, A, adj_in) |
127 | #define BGP_ADJ_IN_DEL(N, A) BGP_PATH_INFO_DEL(N, A, adj_in) | |
718e3744 | 128 | |
129 | /* Prototypes. */ | |
ff177030 DS |
130 | extern bool bgp_adj_out_lookup(struct peer *peer, struct bgp_dest *dest, |
131 | uint32_t addpath_tx_id); | |
132 | extern void bgp_adj_in_set(struct bgp_dest *dest, struct peer *peer, | |
133 | struct attr *attr, uint32_t addpath_id); | |
134 | extern bool bgp_adj_in_unset(struct bgp_dest *dest, struct peer *peer, | |
135 | uint32_t addpath_id); | |
136 | extern void bgp_adj_in_remove(struct bgp_dest *dest, struct bgp_adj_in *bai); | |
137 | ||
138 | extern void bgp_sync_init(struct peer *peer); | |
139 | extern void bgp_sync_delete(struct peer *peer); | |
4d28080c DA |
140 | extern unsigned int bgp_advertise_attr_hash_key(const void *p); |
141 | extern bool bgp_advertise_attr_hash_cmp(const void *p1, const void *p2); | |
d62a17ae | 142 | extern void bgp_advertise_add(struct bgp_advertise_attr *baa, |
143 | struct bgp_advertise *adv); | |
144 | extern struct bgp_advertise *bgp_advertise_new(void); | |
145 | extern void bgp_advertise_free(struct bgp_advertise *adv); | |
4d28080c DA |
146 | extern struct bgp_advertise_attr *bgp_advertise_attr_intern(struct hash *hash, |
147 | struct attr *attr); | |
148 | extern struct bgp_advertise_attr *bgp_advertise_attr_new(void); | |
d62a17ae | 149 | extern void bgp_advertise_delete(struct bgp_advertise_attr *baa, |
150 | struct bgp_advertise *adv); | |
4d28080c DA |
151 | extern void bgp_advertise_attr_unintern(struct hash *hash, |
152 | struct bgp_advertise_attr *baa); | |
153 | extern void bgp_advertise_attr_free(struct bgp_advertise_attr *baa); | |
00d252cb | 154 | |
155 | #endif /* _QUAGGA_BGP_ADVERTISE_H */ |