]>
Commit | Line | Data |
---|---|---|
89272910 DS |
1 | /* Zebra Router header. |
2 | * Copyright (C) 2018 Cumulus Networks, Inc. | |
3 | * Donald Sharp | |
4 | * | |
5 | * This file is part of FRR. | |
6 | * | |
7 | * FRR is free software; you can redistribute it and/or modify it | |
8 | * under the terms of the GNU General Public License as published by the | |
9 | * Free Software Foundation; either version 2, or (at your option) any | |
10 | * later version. | |
11 | * | |
12 | * FRR is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with FRR; see the file COPYING. If not, write to the Free | |
19 | * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA | |
20 | * 02111-1307, USA. | |
21 | */ | |
22 | #ifndef __ZEBRA_ROUTER_H__ | |
23 | #define __ZEBRA_ROUTER_H__ | |
24 | ||
e96ba9da DS |
25 | #include "lib/mlag.h" |
26 | ||
89272910 DS |
27 | #include "zebra/zebra_ns.h" |
28 | ||
51e94aa7 EDP |
29 | #ifdef __cplusplus |
30 | extern "C" { | |
31 | #endif | |
32 | ||
89272910 DS |
33 | /* |
34 | * This header file contains the idea of a router and as such | |
35 | * owns data that is associated with a router from zebra's | |
36 | * perspective. | |
37 | */ | |
38 | ||
39 | struct zebra_router_table { | |
40 | RB_ENTRY(zebra_router_table) zebra_router_table_entry; | |
41 | ||
42 | uint32_t tableid; | |
43 | afi_t afi; | |
44 | safi_t safi; | |
45 | ns_id_t ns_id; | |
46 | ||
47 | struct route_table *table; | |
48 | }; | |
49 | RB_HEAD(zebra_router_table_head, zebra_router_table); | |
50 | RB_PROTOTYPE(zebra_router_table_head, zebra_router_table, | |
51 | zebra_router_table_entry, zebra_router_table_entry_compare) | |
52 | ||
526052fb DS |
53 | /* RPF lookup behaviour */ |
54 | enum multicast_mode { | |
55 | MCAST_NO_CONFIG = 0, /* MIX_MRIB_FIRST, but no show in config write */ | |
56 | MCAST_MRIB_ONLY, /* MRIB only */ | |
57 | MCAST_URIB_ONLY, /* URIB only */ | |
58 | MCAST_MIX_MRIB_FIRST, /* MRIB, if nothing at all then URIB */ | |
59 | MCAST_MIX_DISTANCE, /* MRIB & URIB, lower distance wins */ | |
60 | MCAST_MIX_PFXLEN, /* MRIB & URIB, longer prefix wins */ | |
61 | /* on equal value, MRIB wins for last 2 */ | |
62 | }; | |
63 | ||
c36e442c AK |
64 | /* An interface can be error-disabled if a protocol (such as EVPN or |
65 | * VRRP) detects a problem with keeping it operationally-up. | |
66 | * If any of the protodown bits are set protodown-on is programmed | |
67 | * in the dataplane. This results in a carrier/L1 down on the | |
68 | * physical device. | |
69 | */ | |
70 | enum protodown_reasons { | |
71 | /* On startup local ESs are held down for some time to | |
72 | * allow the underlay to converge and EVPN routes to | |
73 | * get learnt | |
74 | */ | |
75 | ZEBRA_PROTODOWN_EVPN_STARTUP_DELAY = (1 << 0), | |
76 | /* If all the uplinks are down the switch has lost access | |
77 | * to the VxLAN overlay and must shut down the access | |
78 | * ports to allow servers to re-direct their traffic to | |
79 | * other switches on the Ethernet Segment | |
80 | */ | |
81 | ZEBRA_PROTODOWN_EVPN_UPLINK_DOWN = (1 << 1), | |
82 | ZEBRA_PROTODOWN_EVPN_ALL = (ZEBRA_PROTODOWN_EVPN_UPLINK_DOWN | |
83 | | ZEBRA_PROTODOWN_EVPN_STARTUP_DELAY) | |
84 | }; | |
85 | #define ZEBRA_PROTODOWN_RC_STR_LEN 80 | |
86 | ||
e96ba9da DS |
87 | struct zebra_mlag_info { |
88 | /* Role this zebra router is playing */ | |
89 | enum mlag_role role; | |
90 | ||
91 | /* The peerlink being used for mlag */ | |
92 | char *peerlink; | |
93 | ifindex_t peerlink_ifindex; | |
94 | ||
95 | /* The system mac being used */ | |
96 | struct ethaddr mac; | |
ee235396 SK |
97 | /* |
98 | * Zebra will open the communication channel with MLAGD only if any | |
99 | * clients are interested and it is controlled dynamically based on | |
100 | * client registers & un-registers. | |
101 | */ | |
102 | uint32_t clients_interested_cnt; | |
103 | ||
104 | /* coomunication channel with MLAGD is established */ | |
105 | bool connected; | |
106 | ||
107 | /* connection retry timer is running */ | |
108 | bool timer_running; | |
109 | ||
110 | /* Holds the client data(unencoded) that need to be pushed to MCLAGD*/ | |
111 | struct stream_fifo *mlag_fifo; | |
112 | ||
113 | /* | |
114 | * A new Kernel thread will be created to post the data to MCLAGD. | |
115 | * where as, read will be performed from the zebra main thread, because | |
116 | * read involves accessing client registartion data structures. | |
117 | */ | |
118 | struct frr_pthread *zebra_pth_mlag; | |
119 | ||
120 | /* MLAG Thread context 'master' */ | |
121 | struct thread_master *th_master; | |
122 | ||
21a93a5f SK |
123 | /* |
124 | * Event for Initial MLAG Connection setup & Data Read | |
125 | * Read can be performed only after successful connection establishment, | |
126 | * so no issues. | |
127 | * | |
128 | */ | |
ee235396 | 129 | struct thread *t_read; |
21a93a5f | 130 | /* Event for MLAG write */ |
ee235396 | 131 | struct thread *t_write; |
e96ba9da DS |
132 | }; |
133 | ||
89272910 | 134 | struct zebra_router { |
2fc69f03 MS |
135 | atomic_bool in_shutdown; |
136 | ||
3801e764 DS |
137 | /* Thread master */ |
138 | struct thread_master *master; | |
89272910 | 139 | |
161e9ab7 DS |
140 | /* Lists of clients who have connected to us */ |
141 | struct list *client_list; | |
142 | ||
8062cbe2 S |
143 | /* List of clients in GR */ |
144 | struct list *stale_client_list; | |
145 | ||
89272910 | 146 | struct zebra_router_table_head tables; |
7f0ea8a4 | 147 | |
89272910 DS |
148 | /* L3-VNI hash table (for EVPN). Only in default instance */ |
149 | struct hash *l3vni_table; | |
7f0ea8a4 | 150 | |
ce5160c0 AK |
151 | /* Tables and other global info maintained for EVPN multihoming */ |
152 | struct zebra_evpn_mh_info *mh_info; | |
153 | ||
154 | /* EVPN MH broadcast domains indexed by the VID */ | |
155 | struct hash *evpn_vlan_table; | |
156 | ||
7f0ea8a4 | 157 | struct hash *rules_hash; |
62f20a52 DS |
158 | |
159 | struct hash *ipset_hash; | |
160 | ||
161 | struct hash *ipset_entry_hash; | |
162 | ||
163 | struct hash *iptable_hash; | |
a3be9fa1 | 164 | |
9245fe61 PG |
165 | /* used if vrf backend is not network namespace */ |
166 | int rtadv_sock; | |
167 | ||
1485bbe7 DS |
168 | /* A sequence number used for tracking routes */ |
169 | _Atomic uint32_t sequence_num; | |
b3d43ff4 | 170 | |
489a9614 DS |
171 | /* rib work queue */ |
172 | #define ZEBRA_RIB_PROCESS_HOLD_TIME 10 | |
173 | #define ZEBRA_RIB_PROCESS_RETRY_TIME 1 | |
174 | struct work_queue *ribq; | |
ea45a4e7 DS |
175 | |
176 | /* Meta Queue Information */ | |
177 | struct meta_queue *mq; | |
e2353ec2 DS |
178 | |
179 | /* LSP work queue */ | |
180 | struct work_queue *lsp_process_q; | |
5ec5a716 DS |
181 | |
182 | #define ZEBRA_ZAPI_PACKETS_TO_PROCESS 1000 | |
183 | _Atomic uint32_t packets_to_process; | |
e96ba9da DS |
184 | |
185 | /* Mlag information for the router */ | |
186 | struct zebra_mlag_info mlag_info; | |
0fb2ad05 T |
187 | |
188 | /* | |
189 | * The EVPN instance, if any | |
190 | */ | |
191 | struct zebra_vrf *evpn_vrf; | |
b3f2b590 DS |
192 | |
193 | uint32_t multipath_num; | |
d4644d41 | 194 | |
526052fb DS |
195 | /* RPF Lookup behavior */ |
196 | enum multicast_mode ipv4_multicast_mode; | |
197 | ||
d4644d41 DS |
198 | /* |
199 | * Time for when we sweep the rib from old routes | |
200 | */ | |
201 | time_t startup_time; | |
69171da2 DS |
202 | |
203 | /* | |
204 | * The hash of nexthop groups associated with this router | |
205 | */ | |
206 | struct hash *nhgs; | |
a95b8020 | 207 | struct hash *nhgs_id; |
4c56ce1c DS |
208 | |
209 | /* | |
210 | * Does the underlying system provide an asic offload | |
211 | */ | |
212 | bool asic_offloaded; | |
e4876266 | 213 | bool notify_on_ack; |
89272910 DS |
214 | }; |
215 | ||
d4644d41 DS |
216 | #define GRACEFUL_RESTART_TIME 60 |
217 | ||
89272910 DS |
218 | extern struct zebra_router zrouter; |
219 | ||
e4876266 | 220 | extern void zebra_router_init(bool asic_offload, bool notify_on_ack); |
3e0372d2 | 221 | extern void zebra_router_cleanup(void); |
89272910 DS |
222 | extern void zebra_router_terminate(void); |
223 | ||
9d86e091 CS |
224 | extern struct zebra_router_table *zebra_router_find_zrt(struct zebra_vrf *zvrf, |
225 | uint32_t tableid, | |
226 | afi_t afi, safi_t safi); | |
89272910 DS |
227 | extern struct route_table *zebra_router_find_table(struct zebra_vrf *zvrf, |
228 | uint32_t tableid, afi_t afi, | |
229 | safi_t safi); | |
230 | extern struct route_table *zebra_router_get_table(struct zebra_vrf *zvrf, | |
231 | uint32_t tableid, afi_t afi, | |
232 | safi_t safi); | |
bd4fb615 DS |
233 | extern void zebra_router_release_table(struct zebra_vrf *zvrf, uint32_t tableid, |
234 | afi_t afi, safi_t safi); | |
89272910 DS |
235 | |
236 | extern int zebra_router_config_write(struct vty *vty); | |
237 | ||
89272910 | 238 | extern void zebra_router_sweep_route(void); |
38e40db1 | 239 | extern void zebra_router_sweep_nhgs(void); |
ac5aa23f DS |
240 | |
241 | extern void zebra_router_show_table_summary(struct vty *vty); | |
1485bbe7 DS |
242 | |
243 | extern uint32_t zebra_router_get_next_sequence(void); | |
0fb2ad05 T |
244 | |
245 | static inline vrf_id_t zebra_vrf_get_evpn_id(void) | |
246 | { | |
247 | return zrouter.evpn_vrf ? zvrf_id(zrouter.evpn_vrf) : VRF_DEFAULT; | |
248 | } | |
249 | static inline struct zebra_vrf *zebra_vrf_get_evpn(void) | |
250 | { | |
251 | return zrouter.evpn_vrf ? zrouter.evpn_vrf | |
252 | : zebra_vrf_lookup_by_id(VRF_DEFAULT); | |
253 | } | |
d074383c | 254 | |
526052fb DS |
255 | extern void multicast_mode_ipv4_set(enum multicast_mode mode); |
256 | ||
257 | extern enum multicast_mode multicast_mode_ipv4_get(void); | |
258 | ||
e4876266 DS |
259 | extern bool zebra_router_notify_on_ack(void); |
260 | ||
b87fa24d RZ |
261 | /* zebra_northbound.c */ |
262 | extern const struct frr_yang_module_info frr_zebra_info; | |
263 | ||
51e94aa7 EDP |
264 | #ifdef __cplusplus |
265 | } | |
266 | #endif | |
267 | ||
89272910 | 268 | #endif |