]> git.proxmox.com Git - mirror_frr.git/blob - bgpd/rfapi/rfapi_monitor.h
doc: Add `show ipv6 rpf X:X::X:X` command to docs
[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 struct rfapi_monitor_vpn *next; /* chain from struct agg_node */
34 struct rfapi_descriptor *rfd; /* which NVE requested the route */
35 struct prefix p; /* constant: pfx in original request */
36 struct agg_node *node; /* node we're currently attached to */
37 uint32_t flags;
38 #define RFAPI_MON_FLAG_NEEDCALLBACK 0x00000001 /* deferred callback */
39
40 // int dcount; /* debugging counter */
41 struct thread *timer;
42 };
43
44 struct rfapi_monitor_encap {
45 struct rfapi_monitor_encap *next;
46 struct rfapi_monitor_encap *prev;
47 struct agg_node *node; /* VPN node */
48 struct bgp_path_info *bpi; /* VPN bpi */
49 struct agg_node *rn; /* parent node */
50 };
51
52 struct rfapi_monitor_eth {
53 struct rfapi_monitor_eth *next; /* for use in vpn0_queries list */
54 struct rfapi_descriptor *rfd; /* which NVE requested the route */
55 struct ethaddr macaddr;
56 uint32_t logical_net_id;
57 struct thread *timer;
58 };
59
60 /*
61 * This is referenced by the "aggregate" field of a route node
62 * in an RFAPI import table.
63 *
64 * node lock/unlock:
65 * - one lock increment for this structure itself
66 * - one lock per chained struct rfapi_monitor_vpn
67 * - one lock for the mon_eth skiplist itself
68 * - one lock per mon_eth skiplist entry
69 * - one lock for the ext skiplist itself
70 * - one lock for each ext skiplist entry
71 * remember to free skiplist when freeing rfapi_it_extra
72 * - one lock per chained struct rfapi_monitor_encap
73 *
74 */
75 struct rfapi_it_extra {
76 union {
77 struct {
78 struct rfapi_monitor_vpn *v;
79 struct skiplist *idx_rd; /* RD index */
80 struct skiplist *mon_eth; /* ether queries */
81 struct {
82 /* routes with UN addrs, either cached encap or
83 * Encap TLV */
84 int valid_interior_count;
85
86 /* unicast exterior routes, key=bpi,
87 * val=allocated prefix */
88 struct skiplist *source;
89 } e;
90 } vpn;
91 struct {
92 struct rfapi_monitor_encap *e;
93 } encap;
94 } u;
95 };
96
97 #define RFAPI_IT_EXTRA_GET(rn) \
98 ((struct rfapi_it_extra \
99 *)((rn)->aggregate \
100 ? (rn)->aggregate \
101 : (agg_lock_node(rn), \
102 (rn)->aggregate = XCALLOC( \
103 MTYPE_RFAPI_IT_EXTRA, \
104 sizeof(struct rfapi_it_extra)))))
105
106 #define RFAPI_RDINDEX(rn) \
107 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd : NULL)
108
109 #define RFAPI_RDINDEX_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd)
110
111 #define RFAPI_MONITOR_ETH(rn) \
112 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.mon_eth : NULL)
113
114 #define RFAPI_MONITOR_ETH_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.mon_eth)
115
116 #define RFAPI_MONITOR_VPN(rn) \
117 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.v : NULL)
118
119 #define RFAPI_MONITOR_VPN_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.v)
120
121 #define RFAPI_MONITOR_ENCAP(rn) \
122 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.encap.e : NULL)
123
124 #define RFAPI_MONITOR_ENCAP_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.encap.e)
125
126 #define RFAPI_MONITOR_EXTERIOR(rn) (&(RFAPI_IT_EXTRA_GET(rn)->u.vpn.e))
127
128 #define RFAPI_HAS_MONITOR_EXTERIOR(rn) \
129 (rn && rn->aggregate \
130 && ((struct rfapi_it_extra *)(rn->aggregate))->u.vpn.e.source \
131 && !skiplist_first(((struct rfapi_it_extra *)(rn->aggregate)) \
132 ->u.vpn.e.source, \
133 NULL, NULL))
134
135 extern void rfapiMonitorLoopCheck(struct rfapi_monitor_vpn *mchain);
136
137 extern void rfapiMonitorCleanCheck(struct bgp *bgp);
138
139 extern void rfapiMonitorCheckAttachAllowed(void);
140
141 extern void rfapiMonitorExtraFlush(safi_t safi, struct agg_node *rn);
142
143 extern struct agg_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd,
144 struct prefix *p);
145
146 extern void rfapiMonitorAttachImportHd(struct rfapi_descriptor *rfd);
147
148 extern struct agg_node *rfapiMonitorAdd(struct bgp *bgp,
149 struct rfapi_descriptor *rfd,
150 struct prefix *p);
151
152 extern void rfapiMonitorDetachImportHd(struct rfapi_descriptor *rfd);
153
154 extern void rfapiMonitorDel(struct bgp *bgp, struct rfapi_descriptor *rfd,
155 struct prefix *p);
156
157 extern int rfapiMonitorDelHd(struct rfapi_descriptor *rfd);
158
159 extern void rfapiMonitorCallbacksOff(struct bgp *bgp);
160
161 extern void rfapiMonitorCallbacksOn(struct bgp *bgp);
162
163 extern void rfapiMonitorResponseRemovalOff(struct bgp *bgp);
164
165 extern void rfapiMonitorResponseRemovalOn(struct bgp *bgp);
166
167 extern void rfapiMonitorExtraPrune(safi_t safi, struct agg_node *rn);
168
169 extern void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd,
170 const struct prefix *p);
171
172 extern void rfapiMonitorItNodeChanged(struct rfapi_import_table *import_table,
173 struct agg_node *it_node,
174 struct rfapi_monitor_vpn *monitor_list);
175
176 extern void rfapiMonitorMovedUp(struct rfapi_import_table *import_table,
177 struct agg_node *old_node,
178 struct agg_node *new_node,
179 struct rfapi_monitor_vpn *monitor_list);
180
181 extern struct agg_node *rfapiMonitorEthAdd(struct bgp *bgp,
182 struct rfapi_descriptor *rfd,
183 struct ethaddr *macaddr,
184 uint32_t logical_net_id);
185
186 extern void rfapiMonitorEthDel(struct bgp *bgp, struct rfapi_descriptor *rfd,
187 struct ethaddr *macaddr,
188 uint32_t logical_net_id);
189
190 #endif /* QUAGGA_HGP_RFAPI_MONITOR_H */