]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/rfapi/rfapi_monitor.h
Merge remote-tracking branch 'origin/stable/2.0'
[mirror_frr.git] / bgpd / rfapi / rfapi_monitor.h
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 along
17 * with this program; see the file COPYING; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21 #ifndef QUAGGA_HGP_RFAPI_MONITOR_H
22 #define QUAGGA_HGP_RFAPI_MONITOR_H
23
24 #include "lib/zebra.h"
25 #include "lib/prefix.h"
26 #include "lib/table.h"
27
28 /*
29 * These get attached to the nodes in an import table (using "aggregate" ptr)
30 * to indicate which nves are interested in a prefix/target
31 */
32 struct rfapi_monitor_vpn
33 {
34 struct rfapi_monitor_vpn *next; /* chain from struct route_node */
35 struct rfapi_descriptor *rfd; /* which NVE requested the route */
36 struct prefix p; /* constant: pfx in original request */
37 struct route_node *node; /* node we're currently attached to */
38 uint32_t flags;
39 #define RFAPI_MON_FLAG_NEEDCALLBACK 0x00000001 /* deferred callback */
40
41 //int dcount; /* debugging counter */
42 struct thread *timer;
43 };
44
45 struct rfapi_monitor_encap
46 {
47 struct rfapi_monitor_encap *next;
48 struct rfapi_monitor_encap *prev;
49 struct route_node *node; /* VPN node */
50 struct bgp_info *bi; /* VPN bi */
51 struct route_node *rn; /* parent node */
52 };
53
54 struct rfapi_monitor_eth
55 {
56 struct rfapi_monitor_eth *next; /* for use in vpn0_queries list */
57 struct rfapi_descriptor *rfd; /* which NVE requested the route */
58 struct ethaddr macaddr;
59 uint32_t logical_net_id;
60 struct thread *timer;
61 };
62
63 /*
64 * This is referenced by the "aggregate" field of a route node
65 * in an RFAPI import table.
66 *
67 * node lock/unlock:
68 * - one lock increment for this structure itself
69 * - one lock per chained struct rfapi_monitor_vpn
70 * - one lock for the mon_eth skiplist itself
71 * - one lock per mon_eth skiplist entry
72 * - one lock for the ext skiplist itself
73 * - one lock for each ext skiplist entry
74 * remember to free skiplist when freeing rfapi_it_extra
75 * - one lock per chained struct rfapi_monitor_encap
76 *
77 */
78 struct rfapi_it_extra
79 {
80 union
81 {
82 struct
83 {
84 struct rfapi_monitor_vpn *v;
85 struct skiplist *idx_rd; /* RD index */
86 struct skiplist *mon_eth; /* ether queries */
87 struct
88 {
89 /* routes with UN addrs, either cached encap or Encap TLV */
90 int valid_interior_count;
91
92 /* unicast exterior routes, key=bi, val=allocated prefix */
93 struct skiplist *source;
94 } e;
95 } vpn;
96 struct
97 {
98 struct rfapi_monitor_encap *e;
99 } encap;
100 } u;
101 };
102
103 #define RFAPI_IT_EXTRA_GET(rn) ((struct rfapi_it_extra *)( \
104 (rn)->aggregate? (rn)->aggregate: \
105 (route_lock_node(rn), (rn)->aggregate = \
106 XCALLOC(MTYPE_RFAPI_IT_EXTRA,sizeof(struct rfapi_it_extra)))))
107
108 #define RFAPI_RDINDEX(rn) \
109 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd : NULL)
110
111 #define RFAPI_RDINDEX_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd)
112
113 #define RFAPI_MONITOR_ETH(rn) \
114 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.mon_eth : NULL)
115
116 #define RFAPI_MONITOR_ETH_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.mon_eth)
117
118 #define RFAPI_MONITOR_VPN(rn) \
119 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.v : NULL)
120
121 #define RFAPI_MONITOR_VPN_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.v)
122
123 #define RFAPI_MONITOR_ENCAP(rn) \
124 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.encap.e : NULL)
125
126 #define RFAPI_MONITOR_ENCAP_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.encap.e)
127
128 #define RFAPI_MONITOR_EXTERIOR(rn) (&(RFAPI_IT_EXTRA_GET(rn)->u.vpn.e))
129
130 #define RFAPI_HAS_MONITOR_EXTERIOR(rn) (rn && rn->aggregate && \
131 ((struct rfapi_it_extra *)(rn->aggregate))->u.vpn.e.source && \
132 !skiplist_first(((struct rfapi_it_extra *)(rn->aggregate))-> \
133 u.vpn.e.source, NULL, NULL))
134
135 extern void
136 rfapiMonitorLoopCheck (struct rfapi_monitor_vpn *mchain);
137
138 extern void
139 rfapiMonitorCleanCheck (struct bgp *bgp);
140
141 extern void
142 rfapiMonitorCheckAttachAllowed (void);
143
144 extern void
145 rfapiMonitorExtraFlush (safi_t safi, struct route_node *rn);
146
147 extern struct route_node *
148 rfapiMonitorGetAttachNode (struct rfapi_descriptor *rfd, struct prefix *p);
149
150 extern void
151 rfapiMonitorAttachImportHd (struct rfapi_descriptor *rfd);
152
153 extern struct route_node *
154 rfapiMonitorAdd (
155 struct bgp *bgp,
156 struct rfapi_descriptor *rfd,
157 struct prefix *p);
158
159 extern void
160 rfapiMonitorDetachImportHd (struct rfapi_descriptor *rfd);
161
162 extern void
163 rfapiMonitorDel (
164 struct bgp *bgp,
165 struct rfapi_descriptor *rfd,
166 struct prefix *p);
167
168 extern int
169 rfapiMonitorDelHd (struct rfapi_descriptor *rfd);
170
171 extern void
172 rfapiMonitorCallbacksOff (struct bgp *bgp);
173
174 extern void
175 rfapiMonitorCallbacksOn (struct bgp *bgp);
176
177 extern void
178 rfapiMonitorResponseRemovalOff (struct bgp *bgp);
179
180 extern void
181 rfapiMonitorResponseRemovalOn (struct bgp *bgp);
182
183 extern void
184 rfapiMonitorExtraPrune (safi_t safi, struct route_node *rn);
185
186 extern void
187 rfapiMonitorTimersRestart (struct rfapi_descriptor *rfd, struct prefix *p);
188
189 extern void
190 rfapiMonitorItNodeChanged (
191 struct rfapi_import_table *import_table,
192 struct route_node *it_node,
193 struct rfapi_monitor_vpn *monitor_list);
194
195 extern void
196 rfapiMonitorMovedUp (
197 struct rfapi_import_table *import_table,
198 struct route_node *old_node,
199 struct route_node *new_node,
200 struct rfapi_monitor_vpn *monitor_list);
201
202 extern struct route_node *
203 rfapiMonitorEthAdd (
204 struct bgp *bgp,
205 struct rfapi_descriptor *rfd,
206 struct ethaddr *macaddr,
207 uint32_t logical_net_id);
208
209 extern void
210 rfapiMonitorEthDel (
211 struct bgp *bgp,
212 struct rfapi_descriptor *rfd,
213 struct ethaddr *macaddr,
214 uint32_t logical_net_id);
215
216 #endif /* QUAGGA_HGP_RFAPI_MONITOR_H */