]>
Commit | Line | Data |
---|---|---|
d62a17ae | 1 | /* |
65efcfce LB |
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 | * | |
896014f4 DL |
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 | |
65efcfce LB |
19 | */ |
20 | ||
21 | #ifndef QUAGGA_HGP_RFAPI_MONITOR_H | |
22 | #define QUAGGA_HGP_RFAPI_MONITOR_H | |
23 | ||
f8b6f499 LB |
24 | #include "lib/zebra.h" |
25 | #include "lib/prefix.h" | |
26 | #include "lib/table.h" | |
65efcfce LB |
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 | */ | |
d62a17ae | 32 | struct rfapi_monitor_vpn { |
fe08ba7e | 33 | struct rfapi_monitor_vpn *next; /* chain from struct agg_node */ |
d62a17ae | 34 | struct rfapi_descriptor *rfd; /* which NVE requested the route */ |
35 | struct prefix p; /* constant: pfx in original request */ | |
fe08ba7e | 36 | struct agg_node *node; /* node we're currently attached to */ |
d62a17ae | 37 | uint32_t flags; |
65efcfce LB |
38 | #define RFAPI_MON_FLAG_NEEDCALLBACK 0x00000001 /* deferred callback */ |
39 | ||
d62a17ae | 40 | // int dcount; /* debugging counter */ |
41 | struct thread *timer; | |
65efcfce LB |
42 | }; |
43 | ||
d62a17ae | 44 | struct rfapi_monitor_encap { |
45 | struct rfapi_monitor_encap *next; | |
46 | struct rfapi_monitor_encap *prev; | |
fe08ba7e | 47 | struct agg_node *node; /* VPN node */ |
40381db7 | 48 | struct bgp_path_info *bpi; /* VPN bpi */ |
fe08ba7e | 49 | struct agg_node *rn; /* parent node */ |
65efcfce LB |
50 | }; |
51 | ||
d62a17ae | 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; | |
65efcfce LB |
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 | */ | |
d62a17ae | 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 | ||
40381db7 | 86 | /* unicast exterior routes, key=bpi, |
d62a17ae | 87 | * val=allocated prefix */ |
88 | struct skiplist *source; | |
89 | } e; | |
90 | } vpn; | |
91 | struct { | |
92 | struct rfapi_monitor_encap *e; | |
93 | } encap; | |
94 | } u; | |
65efcfce LB |
95 | }; |
96 | ||
d62a17ae | 97 | #define RFAPI_IT_EXTRA_GET(rn) \ |
98 | ((struct rfapi_it_extra \ | |
99 | *)((rn)->aggregate \ | |
100 | ? (rn)->aggregate \ | |
fe08ba7e | 101 | : (agg_lock_node(rn), \ |
d62a17ae | 102 | (rn)->aggregate = XCALLOC( \ |
103 | MTYPE_RFAPI_IT_EXTRA, \ | |
104 | sizeof(struct rfapi_it_extra))))) | |
65efcfce | 105 | |
d62a17ae | 106 | #define RFAPI_RDINDEX(rn) \ |
107 | ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd : NULL) | |
65efcfce LB |
108 | |
109 | #define RFAPI_RDINDEX_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd) | |
110 | ||
d62a17ae | 111 | #define RFAPI_MONITOR_ETH(rn) \ |
112 | ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.mon_eth : NULL) | |
65efcfce LB |
113 | |
114 | #define RFAPI_MONITOR_ETH_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.mon_eth) | |
115 | ||
d62a17ae | 116 | #define RFAPI_MONITOR_VPN(rn) \ |
117 | ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.v : NULL) | |
65efcfce LB |
118 | |
119 | #define RFAPI_MONITOR_VPN_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.v) | |
120 | ||
d62a17ae | 121 | #define RFAPI_MONITOR_ENCAP(rn) \ |
122 | ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.encap.e : NULL) | |
65efcfce LB |
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 | ||
d62a17ae | 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)) | |
65efcfce | 134 | |
d62a17ae | 135 | extern void rfapiMonitorLoopCheck(struct rfapi_monitor_vpn *mchain); |
65efcfce | 136 | |
d62a17ae | 137 | extern void rfapiMonitorCleanCheck(struct bgp *bgp); |
65efcfce | 138 | |
d62a17ae | 139 | extern void rfapiMonitorCheckAttachAllowed(void); |
65efcfce | 140 | |
fe08ba7e | 141 | extern void rfapiMonitorExtraFlush(safi_t safi, struct agg_node *rn); |
65efcfce | 142 | |
fe08ba7e DS |
143 | extern struct agg_node *rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd, |
144 | struct prefix *p); | |
65efcfce | 145 | |
d62a17ae | 146 | extern void rfapiMonitorAttachImportHd(struct rfapi_descriptor *rfd); |
65efcfce | 147 | |
fe08ba7e DS |
148 | extern struct agg_node *rfapiMonitorAdd(struct bgp *bgp, |
149 | struct rfapi_descriptor *rfd, | |
150 | struct prefix *p); | |
65efcfce | 151 | |
d62a17ae | 152 | extern void rfapiMonitorDetachImportHd(struct rfapi_descriptor *rfd); |
65efcfce | 153 | |
d62a17ae | 154 | extern void rfapiMonitorDel(struct bgp *bgp, struct rfapi_descriptor *rfd, |
155 | struct prefix *p); | |
65efcfce | 156 | |
d62a17ae | 157 | extern int rfapiMonitorDelHd(struct rfapi_descriptor *rfd); |
65efcfce | 158 | |
d62a17ae | 159 | extern void rfapiMonitorCallbacksOff(struct bgp *bgp); |
65efcfce | 160 | |
d62a17ae | 161 | extern void rfapiMonitorCallbacksOn(struct bgp *bgp); |
65efcfce | 162 | |
d62a17ae | 163 | extern void rfapiMonitorResponseRemovalOff(struct bgp *bgp); |
65efcfce | 164 | |
d62a17ae | 165 | extern void rfapiMonitorResponseRemovalOn(struct bgp *bgp); |
65efcfce | 166 | |
fe08ba7e | 167 | extern void rfapiMonitorExtraPrune(safi_t safi, struct agg_node *rn); |
65efcfce | 168 | |
d62a17ae | 169 | extern void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd, |
170 | struct prefix *p); | |
65efcfce | 171 | |
d62a17ae | 172 | extern void rfapiMonitorItNodeChanged(struct rfapi_import_table *import_table, |
fe08ba7e | 173 | struct agg_node *it_node, |
d62a17ae | 174 | struct rfapi_monitor_vpn *monitor_list); |
65efcfce | 175 | |
d62a17ae | 176 | extern void rfapiMonitorMovedUp(struct rfapi_import_table *import_table, |
fe08ba7e DS |
177 | struct agg_node *old_node, |
178 | struct agg_node *new_node, | |
d62a17ae | 179 | struct rfapi_monitor_vpn *monitor_list); |
65efcfce | 180 | |
fe08ba7e DS |
181 | extern struct agg_node *rfapiMonitorEthAdd(struct bgp *bgp, |
182 | struct rfapi_descriptor *rfd, | |
183 | struct ethaddr *macaddr, | |
184 | uint32_t logical_net_id); | |
d62a17ae | 185 | |
186 | extern void rfapiMonitorEthDel(struct bgp *bgp, struct rfapi_descriptor *rfd, | |
187 | struct ethaddr *macaddr, | |
188 | uint32_t logical_net_id); | |
65efcfce LB |
189 | |
190 | #endif /* QUAGGA_HGP_RFAPI_MONITOR_H */ |