]>
git.proxmox.com Git - mirror_frr.git/blob - bgpd/rfapi/rfapi_monitor.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright 2009-2016, LabN Consulting, L.L.C.
8 #ifndef QUAGGA_HGP_RFAPI_MONITOR_H
9 #define QUAGGA_HGP_RFAPI_MONITOR_H
11 #include "lib/zebra.h"
12 #include "lib/prefix.h"
13 #include "lib/table.h"
16 * These get attached to the nodes in an import table (using "aggregate" ptr)
17 * to indicate which nves are interested in a prefix/target
19 struct rfapi_monitor_vpn
{
20 struct rfapi_monitor_vpn
*next
; /* chain from struct agg_node */
21 struct rfapi_descriptor
*rfd
; /* which NVE requested the route */
22 struct prefix p
; /* constant: pfx in original request */
23 struct agg_node
*node
; /* node we're currently attached to */
25 #define RFAPI_MON_FLAG_NEEDCALLBACK 0x00000001 /* deferred callback */
27 // int dcount; /* debugging counter */
31 struct rfapi_monitor_encap
{
32 struct rfapi_monitor_encap
*next
;
33 struct rfapi_monitor_encap
*prev
;
34 struct agg_node
*node
; /* VPN node */
35 struct bgp_path_info
*bpi
; /* VPN bpi */
36 struct agg_node
*rn
; /* parent node */
39 struct rfapi_monitor_eth
{
40 struct rfapi_monitor_eth
*next
; /* for use in vpn0_queries list */
41 struct rfapi_descriptor
*rfd
; /* which NVE requested the route */
42 struct ethaddr macaddr
;
43 uint32_t logical_net_id
;
48 * This is referenced by the "aggregate" field of a route node
49 * in an RFAPI import table.
52 * - one lock increment for this structure itself
53 * - one lock per chained struct rfapi_monitor_vpn
54 * - one lock for the mon_eth skiplist itself
55 * - one lock per mon_eth skiplist entry
56 * - one lock for the ext skiplist itself
57 * - one lock for each ext skiplist entry
58 * remember to free skiplist when freeing rfapi_it_extra
59 * - one lock per chained struct rfapi_monitor_encap
62 struct rfapi_it_extra
{
65 struct rfapi_monitor_vpn
*v
;
66 struct skiplist
*idx_rd
; /* RD index */
67 struct skiplist
*mon_eth
; /* ether queries */
69 /* routes with UN addrs, either cached encap or
71 int valid_interior_count
;
73 /* unicast exterior routes, key=bpi,
74 * val=allocated prefix */
75 struct skiplist
*source
;
79 struct rfapi_monitor_encap
*e
;
84 #define RFAPI_IT_EXTRA_GET(rn) \
85 ((struct rfapi_it_extra \
88 : (agg_lock_node(rn), \
89 (rn)->aggregate = XCALLOC( \
90 MTYPE_RFAPI_IT_EXTRA, \
91 sizeof(struct rfapi_it_extra)))))
93 #define RFAPI_RDINDEX(rn) \
94 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd : NULL)
96 #define RFAPI_RDINDEX_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd)
98 #define RFAPI_MONITOR_ETH(rn) \
99 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.mon_eth : NULL)
101 #define RFAPI_MONITOR_ETH_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.mon_eth)
103 #define RFAPI_MONITOR_VPN(rn) \
104 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.v : NULL)
106 #define RFAPI_MONITOR_VPN_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.v)
108 #define RFAPI_MONITOR_ENCAP(rn) \
109 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.encap.e : NULL)
111 #define RFAPI_MONITOR_ENCAP_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.encap.e)
113 #define RFAPI_MONITOR_EXTERIOR(rn) (&(RFAPI_IT_EXTRA_GET(rn)->u.vpn.e))
115 #define RFAPI_HAS_MONITOR_EXTERIOR(rn) \
116 (rn && rn->aggregate \
117 && ((struct rfapi_it_extra *)(rn->aggregate))->u.vpn.e.source \
118 && !skiplist_first(((struct rfapi_it_extra *)(rn->aggregate)) \
122 extern void rfapiMonitorLoopCheck(struct rfapi_monitor_vpn
*mchain
);
124 extern void rfapiMonitorCleanCheck(struct bgp
*bgp
);
126 extern void rfapiMonitorCheckAttachAllowed(void);
128 extern void rfapiMonitorExtraFlush(safi_t safi
, struct agg_node
*rn
);
130 extern struct agg_node
*rfapiMonitorGetAttachNode(struct rfapi_descriptor
*rfd
,
133 extern void rfapiMonitorAttachImportHd(struct rfapi_descriptor
*rfd
);
135 extern struct agg_node
*rfapiMonitorAdd(struct bgp
*bgp
,
136 struct rfapi_descriptor
*rfd
,
139 extern void rfapiMonitorDetachImportHd(struct rfapi_descriptor
*rfd
);
141 extern void rfapiMonitorDel(struct bgp
*bgp
, struct rfapi_descriptor
*rfd
,
144 extern int rfapiMonitorDelHd(struct rfapi_descriptor
*rfd
);
146 extern void rfapiMonitorCallbacksOff(struct bgp
*bgp
);
148 extern void rfapiMonitorCallbacksOn(struct bgp
*bgp
);
150 extern void rfapiMonitorResponseRemovalOff(struct bgp
*bgp
);
152 extern void rfapiMonitorResponseRemovalOn(struct bgp
*bgp
);
154 extern void rfapiMonitorExtraPrune(safi_t safi
, struct agg_node
*rn
);
156 extern void rfapiMonitorTimersRestart(struct rfapi_descriptor
*rfd
,
157 const struct prefix
*p
);
159 extern void rfapiMonitorItNodeChanged(struct rfapi_import_table
*import_table
,
160 struct agg_node
*it_node
,
161 struct rfapi_monitor_vpn
*monitor_list
);
163 extern void rfapiMonitorMovedUp(struct rfapi_import_table
*import_table
,
164 struct agg_node
*old_node
,
165 struct agg_node
*new_node
,
166 struct rfapi_monitor_vpn
*monitor_list
);
168 extern struct agg_node
*rfapiMonitorEthAdd(struct bgp
*bgp
,
169 struct rfapi_descriptor
*rfd
,
170 struct ethaddr
*macaddr
,
171 uint32_t logical_net_id
);
173 extern void rfapiMonitorEthDel(struct bgp
*bgp
, struct rfapi_descriptor
*rfd
,
174 struct ethaddr
*macaddr
,
175 uint32_t logical_net_id
);
177 #endif /* QUAGGA_HGP_RFAPI_MONITOR_H */