]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_vrf.h
zebra: adapt the vrf and logical router initialisation
[mirror_frr.git] / zebra / zebra_vrf.h
1 /*
2 * Zebra Vrf Header
3 * Copyright (C) 2016 Cumulus Networks
4 * Donald Sahrp
5 *
6 * This file is part of Quagga.
7 *
8 * Quagga is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
11 * later version.
12 *
13 * Quagga is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License along
19 * with this program; see the file COPYING; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 */
22 #if !defined(__ZEBRA_VRF_H__)
23 #define __ZEBRA_VRF_H__
24
25 #include <zebra/zebra_ns.h>
26 #include <zebra/zebra_pw.h>
27 #include <lib/vxlan.h>
28
29 /* MPLS (Segment Routing) global block */
30 typedef struct mpls_srgb_t_ {
31 u_int32_t start_label;
32 u_int32_t end_label;
33 } mpls_srgb_t;
34
35 /* Routing table instance. */
36 struct zebra_vrf {
37 /* Back pointer */
38 struct vrf *vrf;
39
40 /* Description. */
41 char *desc;
42
43 /* FIB identifier. */
44 u_char fib_id;
45
46 /* Flags. */
47 u_int16_t flags;
48 #define ZEBRA_VRF_RIB_SCHEDULED (1 << 0)
49 #define ZEBRA_VRF_RETAIN (2 << 0)
50
51 u_int32_t table_id;
52
53 /* Routing table. */
54 struct route_table *table[AFI_MAX][SAFI_MAX];
55
56 /* Static route configuration. */
57 struct route_table *stable[AFI_MAX][SAFI_MAX];
58
59 /* Recursive Nexthop table */
60 struct route_table *rnh_table[AFI_MAX];
61
62 /* Import check table (used mostly by BGP */
63 struct route_table *import_check_table[AFI_MAX];
64
65 /* 2nd pointer type used primarily to quell a warning on
66 * ALL_LIST_ELEMENTS_RO
67 */
68 struct list _rid_all_sorted_list;
69 struct list _rid_lo_sorted_list;
70 struct list *rid_all_sorted_list;
71 struct list *rid_lo_sorted_list;
72 struct prefix rid_user_assigned;
73
74 /*
75 * Back pointer to the owning namespace.
76 */
77 struct zebra_ns *zns;
78
79 /* MPLS Label to handle L3VPN <-> vrf popping */
80 mpls_label_t label[AFI_MAX];
81
82 /* MPLS static LSP config table */
83 struct hash *slsp_table;
84
85 /* MPLS label forwarding table */
86 struct hash *lsp_table;
87
88 /* MPLS FEC binding table */
89 struct route_table *fec_table[AFI_MAX];
90
91 /* MPLS Segment Routing Global block */
92 mpls_srgb_t mpls_srgb;
93
94 /* Pseudowires. */
95 struct zebra_pw_head pseudowires;
96 struct zebra_static_pw_head static_pseudowires;
97
98 /* MPLS processing flags */
99 u_int16_t mpls_flags;
100 #define MPLS_FLAG_SCHEDULE_LSPS (1 << 0)
101
102 /*
103 * VNI hash table (for EVPN). Only in default instance.
104 */
105 struct hash *vni_table;
106
107 /*
108 * Whether EVPN is enabled or not. Only in default instance.
109 */
110 int advertise_all_vni;
111
112 /*
113 * Whether we are advertising g/w macip in EVPN or not.
114 * Only in default instance.
115 */
116 int advertise_gw_macip;
117
118 /* l3-vni info */
119 vni_t l3vni;
120
121 /* Route Installs */
122 uint64_t installs;
123 uint64_t removals;
124 uint64_t neigh_updates;
125 uint64_t lsp_installs;
126 uint64_t lsp_removals;
127 };
128
129 static inline vrf_id_t zvrf_id(struct zebra_vrf *zvrf)
130 {
131 if (!zvrf || !zvrf->vrf)
132 return VRF_UNKNOWN;
133 return zvrf->vrf->vrf_id;
134 }
135
136 static inline const char *zvrf_ns_name(struct zebra_vrf *zvrf)
137 {
138 if (!zvrf->vrf || !zvrf->vrf->ns_ctxt)
139 return NULL;
140 return ns_get_name((struct ns *)zvrf->vrf->ns_ctxt);
141 }
142
143 static inline const char *zvrf_name(struct zebra_vrf *zvrf)
144 {
145 return zvrf->vrf->name;
146 }
147
148 static inline bool zvrf_is_active(struct zebra_vrf *zvrf)
149 {
150 return zvrf->vrf->status & VRF_ACTIVE;
151 }
152
153 struct route_table *zebra_vrf_table_with_table_id(afi_t afi, safi_t safi,
154 vrf_id_t vrf_id,
155 u_int32_t table_id);
156
157 extern void zebra_vrf_update_all(struct zserv *client);
158 extern struct zebra_vrf *zebra_vrf_lookup_by_id(vrf_id_t vrf_id);
159 extern struct zebra_vrf *zebra_vrf_lookup_by_name(const char *);
160 extern struct zebra_vrf *zebra_vrf_alloc(void);
161 extern struct route_table *zebra_vrf_table(afi_t, safi_t, vrf_id_t);
162 extern struct route_table *zebra_vrf_static_table(afi_t, safi_t,
163 struct zebra_vrf *zvrf);
164 extern struct route_table *
165 zebra_vrf_other_route_table(afi_t afi, u_int32_t table_id, vrf_id_t vrf_id);
166 extern int zebra_vrf_has_config(struct zebra_vrf *zvrf);
167 extern void zebra_vrf_init(void);
168
169 extern void zebra_rtable_node_cleanup(struct route_table *table,
170 struct route_node *node);
171 #endif /* ZEBRA_VRF_H */