]>
Commit | Line | Data |
---|---|---|
7c551956 DS |
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 | * | |
896014f4 DL |
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 | |
7c551956 | 21 | */ |
736d41ad PG |
22 | #if !defined(__ZEBRA_VRF_H__) |
23 | #define __ZEBRA_VRF_H__ | |
7c551956 DS |
24 | |
25 | #include <zebra/zebra_ns.h> | |
6833ae01 | 26 | #include <zebra/zebra_pw.h> |
b7cfce93 | 27 | #include <lib/vxlan.h> |
7c551956 | 28 | |
1b6d5c7e | 29 | /* MPLS (Segment Routing) global block */ |
d62a17ae | 30 | typedef struct mpls_srgb_t_ { |
d7c0a89a QY |
31 | uint32_t start_label; |
32 | uint32_t end_label; | |
1b6d5c7e VV |
33 | } mpls_srgb_t; |
34 | ||
7c551956 | 35 | /* Routing table instance. */ |
d62a17ae | 36 | struct zebra_vrf { |
37 | /* Back pointer */ | |
38 | struct vrf *vrf; | |
7c551956 | 39 | |
d62a17ae | 40 | /* Description. */ |
41 | char *desc; | |
7c551956 | 42 | |
d62a17ae | 43 | /* FIB identifier. */ |
d7c0a89a | 44 | uint8_t fib_id; |
7c551956 | 45 | |
d62a17ae | 46 | /* Flags. */ |
d7c0a89a | 47 | uint16_t flags; |
7c551956 | 48 | #define ZEBRA_VRF_RIB_SCHEDULED (1 << 0) |
5a8dfcd8 | 49 | #define ZEBRA_VRF_RETAIN (2 << 0) |
7c551956 | 50 | |
d7c0a89a | 51 | uint32_t table_id; |
7c551956 | 52 | |
d62a17ae | 53 | /* Routing table. */ |
54 | struct route_table *table[AFI_MAX][SAFI_MAX]; | |
7c551956 | 55 | |
d62a17ae | 56 | /* Recursive Nexthop table */ |
57 | struct route_table *rnh_table[AFI_MAX]; | |
7c551956 | 58 | |
d62a17ae | 59 | /* Import check table (used mostly by BGP */ |
60 | struct route_table *import_check_table[AFI_MAX]; | |
7c551956 | 61 | |
d62a17ae | 62 | /* 2nd pointer type used primarily to quell a warning on |
63 | * ALL_LIST_ELEMENTS_RO | |
64 | */ | |
65 | struct list _rid_all_sorted_list; | |
66 | struct list _rid_lo_sorted_list; | |
67 | struct list *rid_all_sorted_list; | |
68 | struct list *rid_lo_sorted_list; | |
69 | struct prefix rid_user_assigned; | |
7c551956 | 70 | |
d62a17ae | 71 | /* |
72 | * Back pointer to the owning namespace. | |
73 | */ | |
74 | struct zebra_ns *zns; | |
54d48ea1 | 75 | |
c83c5e44 | 76 | /* MPLS Label to handle L3VPN <-> vrf popping */ |
7d061b3c | 77 | mpls_label_t label[AFI_MAX]; |
c83c5e44 | 78 | |
d62a17ae | 79 | /* MPLS static LSP config table */ |
80 | struct hash *slsp_table; | |
54d48ea1 | 81 | |
d62a17ae | 82 | /* MPLS label forwarding table */ |
83 | struct hash *lsp_table; | |
939fba27 | 84 | |
d62a17ae | 85 | /* MPLS FEC binding table */ |
86 | struct route_table *fec_table[AFI_MAX]; | |
f31e084c | 87 | |
d62a17ae | 88 | /* MPLS Segment Routing Global block */ |
89 | mpls_srgb_t mpls_srgb; | |
1b6d5c7e | 90 | |
6833ae01 | 91 | /* Pseudowires. */ |
92 | struct zebra_pw_head pseudowires; | |
2dd0d726 | 93 | struct zebra_static_pw_head static_pseudowires; |
6833ae01 | 94 | |
d62a17ae | 95 | /* MPLS processing flags */ |
d7c0a89a | 96 | uint16_t mpls_flags; |
939fba27 | 97 | #define MPLS_FLAG_SCHEDULE_LSPS (1 << 0) |
57282a31 | 98 | |
d62a17ae | 99 | /* |
100 | * VNI hash table (for EVPN). Only in default instance. | |
101 | */ | |
102 | struct hash *vni_table; | |
2853fed6 | 103 | |
d62a17ae | 104 | /* |
2853fed6 | 105 | * Whether EVPN is enabled or not. Only in default instance. |
d62a17ae | 106 | */ |
107 | int advertise_all_vni; | |
108 | ||
1a98c087 MK |
109 | /* |
110 | * Whether we are advertising g/w macip in EVPN or not. | |
2853fed6 | 111 | * Only in default instance. |
1a98c087 MK |
112 | */ |
113 | int advertise_gw_macip; | |
114 | ||
b7cfce93 MK |
115 | /* l3-vni info */ |
116 | vni_t l3vni; | |
117 | ||
d62a17ae | 118 | /* Route Installs */ |
119 | uint64_t installs; | |
120 | uint64_t removals; | |
121 | uint64_t neigh_updates; | |
122 | uint64_t lsp_installs; | |
123 | uint64_t lsp_removals; | |
7c551956 DS |
124 | }; |
125 | ||
d62a17ae | 126 | static inline vrf_id_t zvrf_id(struct zebra_vrf *zvrf) |
661512bf | 127 | { |
2c7d4021 PG |
128 | if (!zvrf || !zvrf->vrf) |
129 | return VRF_UNKNOWN; | |
d62a17ae | 130 | return zvrf->vrf->vrf_id; |
661512bf RW |
131 | } |
132 | ||
81c9005f PG |
133 | static inline const char *zvrf_ns_name(struct zebra_vrf *zvrf) |
134 | { | |
135 | if (!zvrf->vrf || !zvrf->vrf->ns_ctxt) | |
136 | return NULL; | |
137 | return ns_get_name((struct ns *)zvrf->vrf->ns_ctxt); | |
138 | } | |
139 | ||
d62a17ae | 140 | static inline const char *zvrf_name(struct zebra_vrf *zvrf) |
661512bf | 141 | { |
d62a17ae | 142 | return zvrf->vrf->name; |
661512bf RW |
143 | } |
144 | ||
81c9005f PG |
145 | static inline bool zvrf_is_active(struct zebra_vrf *zvrf) |
146 | { | |
147 | return zvrf->vrf->status & VRF_ACTIVE; | |
148 | } | |
149 | ||
d62a17ae | 150 | struct route_table *zebra_vrf_table_with_table_id(afi_t afi, safi_t safi, |
151 | vrf_id_t vrf_id, | |
d7c0a89a | 152 | uint32_t table_id); |
d62a17ae | 153 | |
d62a17ae | 154 | extern void zebra_vrf_update_all(struct zserv *client); |
155 | extern struct zebra_vrf *zebra_vrf_lookup_by_id(vrf_id_t vrf_id); | |
156 | extern struct zebra_vrf *zebra_vrf_lookup_by_name(const char *); | |
157 | extern struct zebra_vrf *zebra_vrf_alloc(void); | |
158 | extern struct route_table *zebra_vrf_table(afi_t, safi_t, vrf_id_t); | |
7e24fdf3 | 159 | |
d62a17ae | 160 | extern struct route_table * |
d7c0a89a | 161 | zebra_vrf_other_route_table(afi_t afi, uint32_t table_id, vrf_id_t vrf_id); |
22bd3e94 | 162 | extern int zebra_vrf_has_config(struct zebra_vrf *zvrf); |
d62a17ae | 163 | extern void zebra_vrf_init(void); |
5335613b DS |
164 | |
165 | extern void zebra_rtable_node_cleanup(struct route_table *table, | |
166 | struct route_node *node); | |
736d41ad | 167 | #endif /* ZEBRA_VRF_H */ |