]> git.proxmox.com Git - mirror_frr.git/blame - bgpd/rfapi/rfapi_monitor.h
*: reindent
[mirror_frr.git] / bgpd / rfapi / rfapi_monitor.h
CommitLineData
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 32struct rfapi_monitor_vpn {
33 struct rfapi_monitor_vpn *next; /* chain from struct route_node */
34 struct rfapi_descriptor *rfd; /* which NVE requested the route */
35 struct prefix p; /* constant: pfx in original request */
36 struct route_node *node; /* node we're currently attached to */
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 44struct rfapi_monitor_encap {
45 struct rfapi_monitor_encap *next;
46 struct rfapi_monitor_encap *prev;
47 struct route_node *node; /* VPN node */
48 struct bgp_info *bi; /* VPN bi */
49 struct route_node *rn; /* parent node */
65efcfce
LB
50};
51
d62a17ae 52struct 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 75struct 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
86 /* unicast exterior routes, key=bi,
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 \
101 : (route_lock_node(rn), \
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 135extern void rfapiMonitorLoopCheck(struct rfapi_monitor_vpn *mchain);
65efcfce 136
d62a17ae 137extern void rfapiMonitorCleanCheck(struct bgp *bgp);
65efcfce 138
d62a17ae 139extern void rfapiMonitorCheckAttachAllowed(void);
65efcfce 140
d62a17ae 141extern void rfapiMonitorExtraFlush(safi_t safi, struct route_node *rn);
65efcfce
LB
142
143extern struct route_node *
d62a17ae 144rfapiMonitorGetAttachNode(struct rfapi_descriptor *rfd, struct prefix *p);
65efcfce 145
d62a17ae 146extern void rfapiMonitorAttachImportHd(struct rfapi_descriptor *rfd);
65efcfce 147
d62a17ae 148extern struct route_node *rfapiMonitorAdd(struct bgp *bgp,
149 struct rfapi_descriptor *rfd,
150 struct prefix *p);
65efcfce 151
d62a17ae 152extern void rfapiMonitorDetachImportHd(struct rfapi_descriptor *rfd);
65efcfce 153
d62a17ae 154extern void rfapiMonitorDel(struct bgp *bgp, struct rfapi_descriptor *rfd,
155 struct prefix *p);
65efcfce 156
d62a17ae 157extern int rfapiMonitorDelHd(struct rfapi_descriptor *rfd);
65efcfce 158
d62a17ae 159extern void rfapiMonitorCallbacksOff(struct bgp *bgp);
65efcfce 160
d62a17ae 161extern void rfapiMonitorCallbacksOn(struct bgp *bgp);
65efcfce 162
d62a17ae 163extern void rfapiMonitorResponseRemovalOff(struct bgp *bgp);
65efcfce 164
d62a17ae 165extern void rfapiMonitorResponseRemovalOn(struct bgp *bgp);
65efcfce 166
d62a17ae 167extern void rfapiMonitorExtraPrune(safi_t safi, struct route_node *rn);
65efcfce 168
d62a17ae 169extern void rfapiMonitorTimersRestart(struct rfapi_descriptor *rfd,
170 struct prefix *p);
65efcfce 171
d62a17ae 172extern void rfapiMonitorItNodeChanged(struct rfapi_import_table *import_table,
173 struct route_node *it_node,
174 struct rfapi_monitor_vpn *monitor_list);
65efcfce 175
d62a17ae 176extern void rfapiMonitorMovedUp(struct rfapi_import_table *import_table,
177 struct route_node *old_node,
178 struct route_node *new_node,
179 struct rfapi_monitor_vpn *monitor_list);
65efcfce 180
d62a17ae 181extern struct route_node *rfapiMonitorEthAdd(struct bgp *bgp,
182 struct rfapi_descriptor *rfd,
183 struct ethaddr *macaddr,
184 uint32_t logical_net_id);
185
186extern 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 */