]> git.proxmox.com Git - mirror_frr.git/blame - zebra/zebra_router.h
Merge pull request #13649 from donaldsharp/unlock_the_node_or_else
[mirror_frr.git] / zebra / zebra_router.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
89272910
DS
2/* Zebra Router header.
3 * Copyright (C) 2018 Cumulus Networks, Inc.
4 * Donald Sharp
89272910
DS
5 */
6#ifndef __ZEBRA_ROUTER_H__
7#define __ZEBRA_ROUTER_H__
8
e96ba9da
DS
9#include "lib/mlag.h"
10
89272910
DS
11#include "zebra/zebra_ns.h"
12
51e94aa7
EDP
13#ifdef __cplusplus
14extern "C" {
15#endif
16
89272910
DS
17/*
18 * This header file contains the idea of a router and as such
19 * owns data that is associated with a router from zebra's
20 * perspective.
21 */
22
23struct zebra_router_table {
24 RB_ENTRY(zebra_router_table) zebra_router_table_entry;
25
26 uint32_t tableid;
27 afi_t afi;
28 safi_t safi;
29 ns_id_t ns_id;
30
31 struct route_table *table;
32};
33RB_HEAD(zebra_router_table_head, zebra_router_table);
34RB_PROTOTYPE(zebra_router_table_head, zebra_router_table,
35 zebra_router_table_entry, zebra_router_table_entry_compare)
36
526052fb
DS
37/* RPF lookup behaviour */
38enum multicast_mode {
39 MCAST_NO_CONFIG = 0, /* MIX_MRIB_FIRST, but no show in config write */
40 MCAST_MRIB_ONLY, /* MRIB only */
41 MCAST_URIB_ONLY, /* URIB only */
42 MCAST_MIX_MRIB_FIRST, /* MRIB, if nothing at all then URIB */
43 MCAST_MIX_DISTANCE, /* MRIB & URIB, lower distance wins */
44 MCAST_MIX_PFXLEN, /* MRIB & URIB, longer prefix wins */
45 /* on equal value, MRIB wins for last 2 */
46};
47
c36e442c
AK
48/* An interface can be error-disabled if a protocol (such as EVPN or
49 * VRRP) detects a problem with keeping it operationally-up.
50 * If any of the protodown bits are set protodown-on is programmed
51 * in the dataplane. This results in a carrier/L1 down on the
52 * physical device.
53 */
54enum protodown_reasons {
5d414138
SW
55 /* A process outside of FRR's control protodowned the interface */
56 ZEBRA_PROTODOWN_EXTERNAL = (1 << 0),
c36e442c
AK
57 /* On startup local ESs are held down for some time to
58 * allow the underlay to converge and EVPN routes to
59 * get learnt
60 */
5d414138 61 ZEBRA_PROTODOWN_EVPN_STARTUP_DELAY = (1 << 1),
c36e442c
AK
62 /* If all the uplinks are down the switch has lost access
63 * to the VxLAN overlay and must shut down the access
64 * ports to allow servers to re-direct their traffic to
65 * other switches on the Ethernet Segment
66 */
5d414138
SW
67 ZEBRA_PROTODOWN_EVPN_UPLINK_DOWN = (1 << 2),
68 ZEBRA_PROTODOWN_EVPN_ALL = (ZEBRA_PROTODOWN_EVPN_UPLINK_DOWN |
69 ZEBRA_PROTODOWN_EVPN_STARTUP_DELAY),
70 ZEBRA_PROTODOWN_VRRP = (1 << 3),
71 /* This reason used exclusively for testing */
0dcd8506
SW
72 ZEBRA_PROTODOWN_SHARP = (1 << 4),
73 /* Just used to clear our fields on shutdown, externel not included */
74 ZEBRA_PROTODOWN_ALL = (ZEBRA_PROTODOWN_EVPN_ALL | ZEBRA_PROTODOWN_VRRP |
75 ZEBRA_PROTODOWN_SHARP)
c36e442c
AK
76};
77#define ZEBRA_PROTODOWN_RC_STR_LEN 80
78
e96ba9da
DS
79struct zebra_mlag_info {
80 /* Role this zebra router is playing */
81 enum mlag_role role;
82
83 /* The peerlink being used for mlag */
84 char *peerlink;
85 ifindex_t peerlink_ifindex;
86
87 /* The system mac being used */
88 struct ethaddr mac;
ee235396
SK
89 /*
90 * Zebra will open the communication channel with MLAGD only if any
91 * clients are interested and it is controlled dynamically based on
92 * client registers & un-registers.
93 */
94 uint32_t clients_interested_cnt;
95
96 /* coomunication channel with MLAGD is established */
97 bool connected;
98
99 /* connection retry timer is running */
100 bool timer_running;
101
102 /* Holds the client data(unencoded) that need to be pushed to MCLAGD*/
103 struct stream_fifo *mlag_fifo;
104
105 /*
106 * A new Kernel thread will be created to post the data to MCLAGD.
107 * where as, read will be performed from the zebra main thread, because
108 * read involves accessing client registartion data structures.
109 */
110 struct frr_pthread *zebra_pth_mlag;
111
112 /* MLAG Thread context 'master' */
cd9d0537 113 struct event_loop *th_master;
ee235396 114
21a93a5f
SK
115 /*
116 * Event for Initial MLAG Connection setup & Data Read
117 * Read can be performed only after successful connection establishment,
118 * so no issues.
119 *
120 */
e6685141 121 struct event *t_read;
21a93a5f 122 /* Event for MLAG write */
e6685141 123 struct event *t_write;
e96ba9da
DS
124};
125
89272910 126struct zebra_router {
2fc69f03
MS
127 atomic_bool in_shutdown;
128
3801e764 129 /* Thread master */
cd9d0537 130 struct event_loop *master;
89272910 131
161e9ab7
DS
132 /* Lists of clients who have connected to us */
133 struct list *client_list;
134
8062cbe2
S
135 /* List of clients in GR */
136 struct list *stale_client_list;
137
89272910 138 struct zebra_router_table_head tables;
7f0ea8a4 139
89272910
DS
140 /* L3-VNI hash table (for EVPN). Only in default instance */
141 struct hash *l3vni_table;
7f0ea8a4 142
ce5160c0
AK
143 /* Tables and other global info maintained for EVPN multihoming */
144 struct zebra_evpn_mh_info *mh_info;
145
4cf4fad1
AK
146 struct zebra_neigh_info *neigh_info;
147
ce5160c0
AK
148 /* EVPN MH broadcast domains indexed by the VID */
149 struct hash *evpn_vlan_table;
150
7f0ea8a4 151 struct hash *rules_hash;
62f20a52
DS
152
153 struct hash *ipset_hash;
154
155 struct hash *ipset_entry_hash;
156
157 struct hash *iptable_hash;
a3be9fa1 158
c317d3f2
SY
159 struct hash *qdisc_hash;
160 struct hash *class_hash;
161 struct hash *filter_hash;
162
1485bbe7
DS
163 /* A sequence number used for tracking routes */
164 _Atomic uint32_t sequence_num;
b3d43ff4 165
489a9614
DS
166 /* rib work queue */
167#define ZEBRA_RIB_PROCESS_HOLD_TIME 10
168#define ZEBRA_RIB_PROCESS_RETRY_TIME 1
169 struct work_queue *ribq;
ea45a4e7
DS
170
171 /* Meta Queue Information */
172 struct meta_queue *mq;
e2353ec2
DS
173
174 /* LSP work queue */
175 struct work_queue *lsp_process_q;
5ec5a716
DS
176
177#define ZEBRA_ZAPI_PACKETS_TO_PROCESS 1000
178 _Atomic uint32_t packets_to_process;
e96ba9da
DS
179
180 /* Mlag information for the router */
181 struct zebra_mlag_info mlag_info;
0fb2ad05
T
182
183 /*
184 * The EVPN instance, if any
185 */
186 struct zebra_vrf *evpn_vrf;
b3f2b590
DS
187
188 uint32_t multipath_num;
d4644d41 189
526052fb
DS
190 /* RPF Lookup behavior */
191 enum multicast_mode ipv4_multicast_mode;
192
d4644d41
DS
193 /*
194 * Time for when we sweep the rib from old routes
195 */
196 time_t startup_time;
e6685141 197 struct event *sweeper;
69171da2
DS
198
199 /*
200 * The hash of nexthop groups associated with this router
201 */
202 struct hash *nhgs;
a95b8020 203 struct hash *nhgs_id;
4c56ce1c
DS
204
205 /*
206 * Does the underlying system provide an asic offload
207 */
208 bool asic_offloaded;
e4876266 209 bool notify_on_ack;
090ee856 210
06525c4f
DS
211 /*
212 * If the asic is notifying us about successful nexthop
213 * allocation/control. Some developers have made their
214 * asic take control of how many nexthops/ecmp they can
215 * have and will report what is successfull or not
216 */
217 bool asic_notification_nexthop_control;
218
090ee856 219 bool supports_nhgs;
c9af62e3 220
385d37ab
DS
221 bool all_mc_forwardingv4, default_mc_forwardingv4;
222 bool all_mc_forwardingv6, default_mc_forwardingv6;
223 bool all_linkdownv4, default_linkdownv4;
224 bool all_linkdownv6, default_linkdownv6;
225
c9af62e3
DS
226#define ZEBRA_DEFAULT_NHG_KEEP_TIMER 180
227 uint32_t nhg_keep;
88b0baa6
DS
228
229 /* Should we allow non FRR processes to delete our routes */
230 bool allow_delete;
89272910
DS
231};
232
d4644d41
DS
233#define GRACEFUL_RESTART_TIME 60
234
89272910 235extern struct zebra_router zrouter;
9fb83b55 236extern uint32_t rcvbufsize;
89272910 237
e4876266 238extern void zebra_router_init(bool asic_offload, bool notify_on_ack);
3e0372d2 239extern void zebra_router_cleanup(void);
89272910
DS
240extern void zebra_router_terminate(void);
241
9d86e091
CS
242extern struct zebra_router_table *zebra_router_find_zrt(struct zebra_vrf *zvrf,
243 uint32_t tableid,
244 afi_t afi, safi_t safi);
89272910
DS
245extern struct route_table *zebra_router_find_table(struct zebra_vrf *zvrf,
246 uint32_t tableid, afi_t afi,
247 safi_t safi);
248extern struct route_table *zebra_router_get_table(struct zebra_vrf *zvrf,
249 uint32_t tableid, afi_t afi,
250 safi_t safi);
bd4fb615
DS
251extern void zebra_router_release_table(struct zebra_vrf *zvrf, uint32_t tableid,
252 afi_t afi, safi_t safi);
89272910
DS
253
254extern int zebra_router_config_write(struct vty *vty);
255
89272910 256extern void zebra_router_sweep_route(void);
38e40db1 257extern void zebra_router_sweep_nhgs(void);
ac5aa23f
DS
258
259extern void zebra_router_show_table_summary(struct vty *vty);
1485bbe7
DS
260
261extern uint32_t zebra_router_get_next_sequence(void);
0fb2ad05
T
262
263static inline vrf_id_t zebra_vrf_get_evpn_id(void)
264{
265 return zrouter.evpn_vrf ? zvrf_id(zrouter.evpn_vrf) : VRF_DEFAULT;
266}
267static inline struct zebra_vrf *zebra_vrf_get_evpn(void)
268{
269 return zrouter.evpn_vrf ? zrouter.evpn_vrf
270 : zebra_vrf_lookup_by_id(VRF_DEFAULT);
271}
d074383c 272
526052fb
DS
273extern void multicast_mode_ipv4_set(enum multicast_mode mode);
274
275extern enum multicast_mode multicast_mode_ipv4_get(void);
276
e4876266
DS
277extern bool zebra_router_notify_on_ack(void);
278
090ee856
DS
279static inline void zebra_router_set_supports_nhgs(bool support)
280{
281 zrouter.supports_nhgs = support;
282}
283
0a5f9773
DS
284static inline bool zebra_router_in_shutdown(void)
285{
286 return atomic_load_explicit(&zrouter.in_shutdown, memory_order_relaxed);
287}
288
b87fa24d
RZ
289/* zebra_northbound.c */
290extern const struct frr_yang_module_info frr_zebra_info;
291
51e94aa7
EDP
292#ifdef __cplusplus
293}
294#endif
295
89272910 296#endif