]>
git.proxmox.com Git - mirror_frr.git/blob - bgpd/rfapi/rfapi_monitor.h
3 * Copyright 2009-2016, LabN Consulting, L.L.C.
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.
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.
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
21 #ifndef QUAGGA_HGP_RFAPI_MONITOR_H
22 #define QUAGGA_HGP_RFAPI_MONITOR_H
24 #include "lib/zebra.h"
25 #include "lib/prefix.h"
26 #include "lib/table.h"
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
32 struct rfapi_monitor_vpn
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 */
39 #define RFAPI_MON_FLAG_NEEDCALLBACK 0x00000001 /* deferred callback */
41 //int dcount; /* debugging counter */
45 struct rfapi_monitor_encap
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 */
54 struct rfapi_monitor_eth
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
;
64 * This is referenced by the "aggregate" field of a route node
65 * in an RFAPI import table.
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
84 struct rfapi_monitor_vpn
*v
;
85 struct skiplist
*idx_rd
; /* RD index */
86 struct skiplist
*mon_eth
; /* ether queries */
89 /* routes with UN addrs, either cached encap or Encap TLV */
90 int valid_interior_count
;
92 /* unicast exterior routes, key=bi, val=allocated prefix */
93 struct skiplist
*source
;
98 struct rfapi_monitor_encap
*e
;
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)))))
108 #define RFAPI_RDINDEX(rn) \
109 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd : NULL)
111 #define RFAPI_RDINDEX_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd)
113 #define RFAPI_MONITOR_ETH(rn) \
114 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.mon_eth : NULL)
116 #define RFAPI_MONITOR_ETH_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.mon_eth)
118 #define RFAPI_MONITOR_VPN(rn) \
119 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.v : NULL)
121 #define RFAPI_MONITOR_VPN_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.v)
123 #define RFAPI_MONITOR_ENCAP(rn) \
124 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.encap.e : NULL)
126 #define RFAPI_MONITOR_ENCAP_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.encap.e)
128 #define RFAPI_MONITOR_EXTERIOR(rn) (&(RFAPI_IT_EXTRA_GET(rn)->u.vpn.e))
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))
136 rfapiMonitorLoopCheck (struct rfapi_monitor_vpn
*mchain
);
139 rfapiMonitorCleanCheck (struct bgp
*bgp
);
142 rfapiMonitorCheckAttachAllowed (void);
145 rfapiMonitorExtraFlush (safi_t safi
, struct route_node
*rn
);
147 extern struct route_node
*
148 rfapiMonitorGetAttachNode (struct rfapi_descriptor
*rfd
, struct prefix
*p
);
151 rfapiMonitorAttachImportHd (struct rfapi_descriptor
*rfd
);
153 extern struct route_node
*
156 struct rfapi_descriptor
*rfd
,
160 rfapiMonitorDetachImportHd (struct rfapi_descriptor
*rfd
);
165 struct rfapi_descriptor
*rfd
,
169 rfapiMonitorDelHd (struct rfapi_descriptor
*rfd
);
172 rfapiMonitorCallbacksOff (struct bgp
*bgp
);
175 rfapiMonitorCallbacksOn (struct bgp
*bgp
);
178 rfapiMonitorResponseRemovalOff (struct bgp
*bgp
);
181 rfapiMonitorResponseRemovalOn (struct bgp
*bgp
);
184 rfapiMonitorExtraPrune (safi_t safi
, struct route_node
*rn
);
187 rfapiMonitorTimersRestart (struct rfapi_descriptor
*rfd
, struct prefix
*p
);
190 rfapiMonitorItNodeChanged (
191 struct rfapi_import_table
*import_table
,
192 struct route_node
*it_node
,
193 struct rfapi_monitor_vpn
*monitor_list
);
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
);
202 extern struct route_node
*
205 struct rfapi_descriptor
*rfd
,
206 struct ethaddr
*macaddr
,
207 uint32_t logical_net_id
);
212 struct rfapi_descriptor
*rfd
,
213 struct ethaddr
*macaddr
,
214 uint32_t logical_net_id
);
216 #endif /* QUAGGA_HGP_RFAPI_MONITOR_H */