]>
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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
22 #ifndef QUAGGA_HGP_RFAPI_MONITOR_H
23 #define QUAGGA_HGP_RFAPI_MONITOR_H
25 #include "lib/zebra.h"
26 #include "lib/prefix.h"
27 #include "lib/table.h"
30 * These get attached to the nodes in an import table (using "aggregate" ptr)
31 * to indicate which nves are interested in a prefix/target
33 struct rfapi_monitor_vpn
35 struct rfapi_monitor_vpn
*next
; /* chain from struct route_node */
36 struct rfapi_descriptor
*rfd
; /* which NVE requested the route */
37 struct prefix p
; /* constant: pfx in original request */
38 struct route_node
*node
; /* node we're currently attached to */
40 #define RFAPI_MON_FLAG_NEEDCALLBACK 0x00000001 /* deferred callback */
42 //int dcount; /* debugging counter */
46 struct rfapi_monitor_encap
48 struct rfapi_monitor_encap
*next
;
49 struct rfapi_monitor_encap
*prev
;
50 struct route_node
*node
; /* VPN node */
51 struct bgp_info
*bi
; /* VPN bi */
52 struct route_node
*rn
; /* parent node */
55 struct rfapi_monitor_eth
57 struct rfapi_monitor_eth
*next
; /* for use in vpn0_queries list */
58 struct rfapi_descriptor
*rfd
; /* which NVE requested the route */
59 struct ethaddr macaddr
;
60 uint32_t logical_net_id
;
65 * This is referenced by the "aggregate" field of a route node
66 * in an RFAPI import table.
69 * - one lock increment for this structure itself
70 * - one lock per chained struct rfapi_monitor_vpn
71 * - one lock for the mon_eth skiplist itself
72 * - one lock per mon_eth skiplist entry
73 * - one lock for the ext skiplist itself
74 * - one lock for each ext skiplist entry
75 * remember to free skiplist when freeing rfapi_it_extra
76 * - one lock per chained struct rfapi_monitor_encap
85 struct rfapi_monitor_vpn
*v
;
86 struct skiplist
*idx_rd
; /* RD index */
87 struct skiplist
*mon_eth
; /* ether queries */
90 /* routes with UN addrs, either cached encap or Encap TLV */
91 int valid_interior_count
;
93 /* unicast exterior routes, key=bi, val=allocated prefix */
94 struct skiplist
*source
;
99 struct rfapi_monitor_encap
*e
;
104 #define RFAPI_IT_EXTRA_GET(rn) ((struct rfapi_it_extra *)( \
105 (rn)->aggregate? (rn)->aggregate: \
106 (route_lock_node(rn), (rn)->aggregate = \
107 XCALLOC(MTYPE_RFAPI_IT_EXTRA,sizeof(struct rfapi_it_extra)))))
109 #define RFAPI_RDINDEX(rn) \
110 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd : NULL)
112 #define RFAPI_RDINDEX_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.idx_rd)
114 #define RFAPI_MONITOR_ETH(rn) \
115 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.mon_eth : NULL)
117 #define RFAPI_MONITOR_ETH_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.mon_eth)
119 #define RFAPI_MONITOR_VPN(rn) \
120 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.vpn.v : NULL)
122 #define RFAPI_MONITOR_VPN_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.vpn.v)
124 #define RFAPI_MONITOR_ENCAP(rn) \
125 ((rn)->aggregate ? RFAPI_IT_EXTRA_GET(rn)->u.encap.e : NULL)
127 #define RFAPI_MONITOR_ENCAP_W_ALLOC(rn) (RFAPI_IT_EXTRA_GET(rn)->u.encap.e)
129 #define RFAPI_MONITOR_EXTERIOR(rn) (&(RFAPI_IT_EXTRA_GET(rn)->u.vpn.e))
131 #define RFAPI_HAS_MONITOR_EXTERIOR(rn) (rn && rn->aggregate && \
132 ((struct rfapi_it_extra *)(rn->aggregate))->u.vpn.e.source && \
133 !skiplist_first(((struct rfapi_it_extra *)(rn->aggregate))-> \
134 u.vpn.e.source, NULL, NULL))
137 rfapiMonitorLoopCheck (struct rfapi_monitor_vpn
*mchain
);
140 rfapiMonitorCleanCheck (struct bgp
*bgp
);
143 rfapiMonitorCheckAttachAllowed (void);
146 rfapiMonitorExtraFlush (safi_t safi
, struct route_node
*rn
);
148 extern struct route_node
*
149 rfapiMonitorGetAttachNode (struct rfapi_descriptor
*rfd
, struct prefix
*p
);
152 rfapiMonitorAttachImportHd (struct rfapi_descriptor
*rfd
);
154 extern struct route_node
*
157 struct rfapi_descriptor
*rfd
,
161 rfapiMonitorDetachImportHd (struct rfapi_descriptor
*rfd
);
166 struct rfapi_descriptor
*rfd
,
170 rfapiMonitorDelHd (struct rfapi_descriptor
*rfd
);
173 rfapiMonitorCallbacksOff (struct bgp
*bgp
);
176 rfapiMonitorCallbacksOn (struct bgp
*bgp
);
179 rfapiMonitorResponseRemovalOff (struct bgp
*bgp
);
182 rfapiMonitorResponseRemovalOn (struct bgp
*bgp
);
185 rfapiMonitorExtraPrune (safi_t safi
, struct route_node
*rn
);
188 rfapiMonitorTimersRestart (struct rfapi_descriptor
*rfd
, struct prefix
*p
);
191 rfapiMonitorItNodeChanged (
192 struct rfapi_import_table
*import_table
,
193 struct route_node
*it_node
,
194 struct rfapi_monitor_vpn
*monitor_list
);
197 rfapiMonitorMovedUp (
198 struct rfapi_import_table
*import_table
,
199 struct route_node
*old_node
,
200 struct route_node
*new_node
,
201 struct rfapi_monitor_vpn
*monitor_list
);
203 extern struct route_node
*
206 struct rfapi_descriptor
*rfd
,
207 struct ethaddr
*macaddr
,
208 uint32_t logical_net_id
);
213 struct rfapi_descriptor
*rfd
,
214 struct ethaddr
*macaddr
,
215 uint32_t logical_net_id
);
217 #endif /* QUAGGA_HGP_RFAPI_MONITOR_H */