]>
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
{
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 */
38 #define RFAPI_MON_FLAG_NEEDCALLBACK 0x00000001 /* deferred callback */
40 // int dcount; /* debugging counter */
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 */
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
;
61 * This is referenced by the "aggregate" field of a route node
62 * in an RFAPI import table.
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
75 struct rfapi_it_extra
{
78 struct rfapi_monitor_vpn
*v
;
79 struct skiplist
*idx_rd
; /* RD index */
80 struct skiplist
*mon_eth
; /* ether queries */
82 /* routes with UN addrs, either cached encap or
84 int valid_interior_count
;
86 /* unicast exterior routes, key=bpi,
87 * val=allocated prefix */
88 struct skiplist
*source
;
92 struct rfapi_monitor_encap
*e
;
97 #define RFAPI_IT_EXTRA_GET(rn) \
98 ((struct rfapi_it_extra \
101 : (agg_lock_node(rn), \
102 (rn)->aggregate = XCALLOC( \
103 MTYPE_RFAPI_IT_EXTRA, \
104 sizeof(struct rfapi_it_extra)))))
106 #define RFAPI_RDINDEX(rn) \
107 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd : NULL)
109 #define RFAPI_RDINDEX_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd)
111 #define RFAPI_MONITOR_ETH(rn) \
112 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.mon_eth : NULL)
114 #define RFAPI_MONITOR_ETH_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.mon_eth)
116 #define RFAPI_MONITOR_VPN(rn) \
117 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.v : NULL)
119 #define RFAPI_MONITOR_VPN_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.v)
121 #define RFAPI_MONITOR_ENCAP(rn) \
122 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.encap.e : NULL)
124 #define RFAPI_MONITOR_ENCAP_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.encap.e)
126 #define RFAPI_MONITOR_EXTERIOR(rn) (&(RFAPI_IT_EXTRA_GET(rn)->u.vpn.e))
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)) \
135 extern void rfapiMonitorLoopCheck(struct rfapi_monitor_vpn
*mchain
);
137 extern void rfapiMonitorCleanCheck(struct bgp
*bgp
);
139 extern void rfapiMonitorCheckAttachAllowed(void);
141 extern void rfapiMonitorExtraFlush(safi_t safi
, struct agg_node
*rn
);
143 extern struct agg_node
*rfapiMonitorGetAttachNode(struct rfapi_descriptor
*rfd
,
146 extern void rfapiMonitorAttachImportHd(struct rfapi_descriptor
*rfd
);
148 extern struct agg_node
*rfapiMonitorAdd(struct bgp
*bgp
,
149 struct rfapi_descriptor
*rfd
,
152 extern void rfapiMonitorDetachImportHd(struct rfapi_descriptor
*rfd
);
154 extern void rfapiMonitorDel(struct bgp
*bgp
, struct rfapi_descriptor
*rfd
,
157 extern int rfapiMonitorDelHd(struct rfapi_descriptor
*rfd
);
159 extern void rfapiMonitorCallbacksOff(struct bgp
*bgp
);
161 extern void rfapiMonitorCallbacksOn(struct bgp
*bgp
);
163 extern void rfapiMonitorResponseRemovalOff(struct bgp
*bgp
);
165 extern void rfapiMonitorResponseRemovalOn(struct bgp
*bgp
);
167 extern void rfapiMonitorExtraPrune(safi_t safi
, struct agg_node
*rn
);
169 extern void rfapiMonitorTimersRestart(struct rfapi_descriptor
*rfd
,
170 const struct prefix
*p
);
172 extern void rfapiMonitorItNodeChanged(struct rfapi_import_table
*import_table
,
173 struct agg_node
*it_node
,
174 struct rfapi_monitor_vpn
*monitor_list
);
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
);
181 extern struct agg_node
*rfapiMonitorEthAdd(struct bgp
*bgp
,
182 struct rfapi_descriptor
*rfd
,
183 struct ethaddr
*macaddr
,
184 uint32_t logical_net_id
);
186 extern void rfapiMonitorEthDel(struct bgp
*bgp
, struct rfapi_descriptor
*rfd
,
187 struct ethaddr
*macaddr
,
188 uint32_t logical_net_id
);
190 #endif /* QUAGGA_HGP_RFAPI_MONITOR_H */