]>
Commit | Line | Data |
---|---|---|
65efcfce LB |
1 | /* |
2 | * | |
3 | * Copyright 2009-2016, LabN Consulting, L.L.C. | |
4 | * | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU General Public License | |
8 | * as published by the Free Software Foundation; either version 2 | |
9 | * of the License, or (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it will be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write to the Free Software | |
18 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
19 | * | |
20 | */ | |
21 | ||
22 | #ifndef QUAGGA_HGP_RFAPI_MONITOR_H | |
23 | #define QUAGGA_HGP_RFAPI_MONITOR_H | |
24 | ||
f8b6f499 LB |
25 | #include "lib/zebra.h" |
26 | #include "lib/prefix.h" | |
27 | #include "lib/table.h" | |
65efcfce LB |
28 | |
29 | /* | |
30 | * These get attached to the nodes in an import table (using "aggregate" ptr) | |
31 | * to indicate which nves are interested in a prefix/target | |
32 | */ | |
33 | struct rfapi_monitor_vpn | |
34 | { | |
35 | struct rfapi_monitor_vpn *next; /* chain from struct route_node */ | |
36 | struct rfapi_descriptor *rfd; /* which NVE requested the route */ | |
37 | struct prefix p; /* constant: pfx in original request */ | |
38 | struct route_node *node; /* node we're currently attached to */ | |
39 | uint32_t flags; | |
40 | #define RFAPI_MON_FLAG_NEEDCALLBACK 0x00000001 /* deferred callback */ | |
41 | ||
42 | //int dcount; /* debugging counter */ | |
43 | void *timer; | |
44 | }; | |
45 | ||
46 | struct rfapi_monitor_encap | |
47 | { | |
48 | struct rfapi_monitor_encap *next; | |
49 | struct rfapi_monitor_encap *prev; | |
50 | struct route_node *node; /* VPN node */ | |
51 | struct bgp_info *bi; /* VPN bi */ | |
52 | struct route_node *rn; /* parent node */ | |
53 | }; | |
54 | ||
55 | struct rfapi_monitor_eth | |
56 | { | |
57 | struct rfapi_monitor_eth *next; /* for use in vpn0_queries list */ | |
58 | struct rfapi_descriptor *rfd; /* which NVE requested the route */ | |
59 | struct ethaddr macaddr; | |
60 | uint32_t logical_net_id; | |
61 | void *timer; | |
62 | }; | |
63 | ||
64 | /* | |
65 | * This is referenced by the "aggregate" field of a route node | |
66 | * in an RFAPI import table. | |
67 | * | |
68 | * node lock/unlock: | |
69 | * - one lock increment for this structure itself | |
70 | * - one lock per chained struct rfapi_monitor_vpn | |
71 | * - one lock for the mon_eth skiplist itself | |
72 | * - one lock per mon_eth skiplist entry | |
73 | * - one lock for the ext skiplist itself | |
74 | * - one lock for each ext skiplist entry | |
75 | * remember to free skiplist when freeing rfapi_it_extra | |
76 | * - one lock per chained struct rfapi_monitor_encap | |
77 | * | |
78 | */ | |
79 | struct rfapi_it_extra | |
80 | { | |
81 | union | |
82 | { | |
83 | struct | |
84 | { | |
85 | struct rfapi_monitor_vpn *v; | |
86 | struct skiplist *idx_rd; /* RD index */ | |
87 | struct skiplist *mon_eth; /* ether queries */ | |
88 | struct | |
89 | { | |
90 | /* routes with UN addrs, either cached encap or Encap TLV */ | |
91 | int valid_interior_count; | |
92 | ||
93 | /* unicast exterior routes, key=bi, val=allocated prefix */ | |
94 | struct skiplist *source; | |
95 | } e; | |
96 | } vpn; | |
97 | struct | |
98 | { | |
99 | struct rfapi_monitor_encap *e; | |
100 | } encap; | |
101 | } u; | |
102 | }; | |
103 | ||
104 | #define RFAPI_IT_EXTRA_GET(rn) ((struct rfapi_it_extra *)( \ | |
105 | (rn)->aggregate? (rn)->aggregate: \ | |
106 | (route_lock_node(rn), (rn)->aggregate = \ | |
107 | XCALLOC(MTYPE_RFAPI_IT_EXTRA,sizeof(struct rfapi_it_extra))))) | |
108 | ||
109 | #define RFAPI_RDINDEX(rn) \ | |
110 | ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd : NULL) | |
111 | ||
112 | #define RFAPI_RDINDEX_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd) | |
113 | ||
114 | #define RFAPI_MONITOR_ETH(rn) \ | |
115 | ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.mon_eth : NULL) | |
116 | ||
117 | #define RFAPI_MONITOR_ETH_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.mon_eth) | |
118 | ||
119 | #define RFAPI_MONITOR_VPN(rn) \ | |
120 | ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.v : NULL) | |
121 | ||
122 | #define RFAPI_MONITOR_VPN_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.v) | |
123 | ||
124 | #define RFAPI_MONITOR_ENCAP(rn) \ | |
125 | ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.encap.e : NULL) | |
126 | ||
127 | #define RFAPI_MONITOR_ENCAP_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.encap.e) | |
128 | ||
129 | #define RFAPI_MONITOR_EXTERIOR(rn) (&(RFAPI_IT_EXTRA_GET(rn)->u.vpn.e)) | |
130 | ||
131 | #define RFAPI_HAS_MONITOR_EXTERIOR(rn) (rn && rn->aggregate && \ | |
132 | ((struct rfapi_it_extra *)(rn->aggregate))->u.vpn.e.source && \ | |
133 | !skiplist_first(((struct rfapi_it_extra *)(rn->aggregate))-> \ | |
134 | u.vpn.e.source, NULL, NULL)) | |
135 | ||
136 | extern void | |
137 | rfapiMonitorLoopCheck (struct rfapi_monitor_vpn *mchain); | |
138 | ||
139 | extern void | |
140 | rfapiMonitorCleanCheck (struct bgp *bgp); | |
141 | ||
142 | extern void | |
143 | rfapiMonitorCheckAttachAllowed (void); | |
144 | ||
145 | extern void | |
146 | rfapiMonitorExtraFlush (safi_t safi, struct route_node *rn); | |
147 | ||
148 | extern struct route_node * | |
149 | rfapiMonitorGetAttachNode (struct rfapi_descriptor *rfd, struct prefix *p); | |
150 | ||
151 | extern void | |
152 | rfapiMonitorAttachImportHd (struct rfapi_descriptor *rfd); | |
153 | ||
154 | extern struct route_node * | |
155 | rfapiMonitorAdd ( | |
156 | struct bgp *bgp, | |
157 | struct rfapi_descriptor *rfd, | |
158 | struct prefix *p); | |
159 | ||
160 | extern void | |
161 | rfapiMonitorDetachImportHd (struct rfapi_descriptor *rfd); | |
162 | ||
163 | extern void | |
164 | rfapiMonitorDel ( | |
165 | struct bgp *bgp, | |
166 | struct rfapi_descriptor *rfd, | |
167 | struct prefix *p); | |
168 | ||
169 | extern int | |
170 | rfapiMonitorDelHd (struct rfapi_descriptor *rfd); | |
171 | ||
172 | extern void | |
173 | rfapiMonitorCallbacksOff (struct bgp *bgp); | |
174 | ||
175 | extern void | |
176 | rfapiMonitorCallbacksOn (struct bgp *bgp); | |
177 | ||
178 | extern void | |
179 | rfapiMonitorResponseRemovalOff (struct bgp *bgp); | |
180 | ||
181 | extern void | |
182 | rfapiMonitorResponseRemovalOn (struct bgp *bgp); | |
183 | ||
184 | extern void | |
185 | rfapiMonitorExtraPrune (safi_t safi, struct route_node *rn); | |
186 | ||
187 | extern void | |
188 | rfapiMonitorTimersRestart (struct rfapi_descriptor *rfd, struct prefix *p); | |
189 | ||
190 | extern void | |
191 | rfapiMonitorItNodeChanged ( | |
192 | struct rfapi_import_table *import_table, | |
193 | struct route_node *it_node, | |
194 | struct rfapi_monitor_vpn *monitor_list); | |
195 | ||
196 | extern void | |
197 | rfapiMonitorMovedUp ( | |
198 | struct rfapi_import_table *import_table, | |
199 | struct route_node *old_node, | |
200 | struct route_node *new_node, | |
201 | struct rfapi_monitor_vpn *monitor_list); | |
202 | ||
203 | extern struct route_node * | |
204 | rfapiMonitorEthAdd ( | |
205 | struct bgp *bgp, | |
206 | struct rfapi_descriptor *rfd, | |
207 | struct ethaddr *macaddr, | |
208 | uint32_t logical_net_id); | |
209 | ||
210 | extern void | |
211 | rfapiMonitorEthDel ( | |
212 | struct bgp *bgp, | |
213 | struct rfapi_descriptor *rfd, | |
214 | struct ethaddr *macaddr, | |
215 | uint32_t logical_net_id); | |
216 | ||
217 | #endif /* QUAGGA_HGP_RFAPI_MONITOR_H */ |