]> git.proxmox.com Git - mirror_frr.git/blame - zebra/zebra_router.h
Merge pull request #5706 from mjstapp/fix_nh_debug_show
[mirror_frr.git] / zebra / zebra_router.h
CommitLineData
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
30extern "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
39struct 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};
49RB_HEAD(zebra_router_table_head, zebra_router_table);
50RB_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 */
54enum 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
e96ba9da
DS
64struct zebra_mlag_info {
65 /* Role this zebra router is playing */
66 enum mlag_role role;
67
68 /* The peerlink being used for mlag */
69 char *peerlink;
70 ifindex_t peerlink_ifindex;
71
72 /* The system mac being used */
73 struct ethaddr mac;
ee235396
SK
74 /*
75 * Zebra will open the communication channel with MLAGD only if any
76 * clients are interested and it is controlled dynamically based on
77 * client registers & un-registers.
78 */
79 uint32_t clients_interested_cnt;
80
81 /* coomunication channel with MLAGD is established */
82 bool connected;
83
84 /* connection retry timer is running */
85 bool timer_running;
86
87 /* Holds the client data(unencoded) that need to be pushed to MCLAGD*/
88 struct stream_fifo *mlag_fifo;
89
90 /*
91 * A new Kernel thread will be created to post the data to MCLAGD.
92 * where as, read will be performed from the zebra main thread, because
93 * read involves accessing client registartion data structures.
94 */
95 struct frr_pthread *zebra_pth_mlag;
96
97 /* MLAG Thread context 'master' */
98 struct thread_master *th_master;
99
21a93a5f
SK
100 /*
101 * Event for Initial MLAG Connection setup & Data Read
102 * Read can be performed only after successful connection establishment,
103 * so no issues.
104 *
105 */
ee235396 106 struct thread *t_read;
21a93a5f 107 /* Event for MLAG write */
ee235396 108 struct thread *t_write;
e96ba9da
DS
109};
110
89272910 111struct zebra_router {
2fc69f03
MS
112 atomic_bool in_shutdown;
113
3801e764
DS
114 /* Thread master */
115 struct thread_master *master;
89272910 116
161e9ab7
DS
117 /* Lists of clients who have connected to us */
118 struct list *client_list;
119
89272910 120 struct zebra_router_table_head tables;
7f0ea8a4 121
89272910
DS
122 /* L3-VNI hash table (for EVPN). Only in default instance */
123 struct hash *l3vni_table;
7f0ea8a4
DS
124
125 struct hash *rules_hash;
62f20a52
DS
126
127 struct hash *ipset_hash;
128
129 struct hash *ipset_entry_hash;
130
131 struct hash *iptable_hash;
a3be9fa1 132
9245fe61
PG
133 /* used if vrf backend is not network namespace */
134 int rtadv_sock;
135
1485bbe7
DS
136 /* A sequence number used for tracking routes */
137 _Atomic uint32_t sequence_num;
b3d43ff4 138
489a9614
DS
139 /* rib work queue */
140#define ZEBRA_RIB_PROCESS_HOLD_TIME 10
141#define ZEBRA_RIB_PROCESS_RETRY_TIME 1
142 struct work_queue *ribq;
ea45a4e7
DS
143
144 /* Meta Queue Information */
145 struct meta_queue *mq;
e2353ec2
DS
146
147 /* LSP work queue */
148 struct work_queue *lsp_process_q;
5ec5a716
DS
149
150#define ZEBRA_ZAPI_PACKETS_TO_PROCESS 1000
151 _Atomic uint32_t packets_to_process;
e96ba9da
DS
152
153 /* Mlag information for the router */
154 struct zebra_mlag_info mlag_info;
0fb2ad05
T
155
156 /*
157 * The EVPN instance, if any
158 */
159 struct zebra_vrf *evpn_vrf;
b3f2b590
DS
160
161 uint32_t multipath_num;
d4644d41 162
526052fb
DS
163 /* RPF Lookup behavior */
164 enum multicast_mode ipv4_multicast_mode;
165
d4644d41
DS
166 /*
167 * Time for when we sweep the rib from old routes
168 */
169 time_t startup_time;
69171da2
DS
170
171 /*
172 * The hash of nexthop groups associated with this router
173 */
174 struct hash *nhgs;
a95b8020 175 struct hash *nhgs_id;
89272910
DS
176};
177
d4644d41
DS
178#define GRACEFUL_RESTART_TIME 60
179
89272910
DS
180extern struct zebra_router zrouter;
181
182extern void zebra_router_init(void);
3e0372d2 183extern void zebra_router_cleanup(void);
89272910
DS
184extern void zebra_router_terminate(void);
185
186extern struct route_table *zebra_router_find_table(struct zebra_vrf *zvrf,
187 uint32_t tableid, afi_t afi,
188 safi_t safi);
189extern struct route_table *zebra_router_get_table(struct zebra_vrf *zvrf,
190 uint32_t tableid, afi_t afi,
191 safi_t safi);
bd4fb615
DS
192extern void zebra_router_release_table(struct zebra_vrf *zvrf, uint32_t tableid,
193 afi_t afi, safi_t safi);
89272910
DS
194
195extern int zebra_router_config_write(struct vty *vty);
196
89272910 197extern void zebra_router_sweep_route(void);
38e40db1 198extern void zebra_router_sweep_nhgs(void);
ac5aa23f
DS
199
200extern void zebra_router_show_table_summary(struct vty *vty);
1485bbe7
DS
201
202extern uint32_t zebra_router_get_next_sequence(void);
0fb2ad05
T
203
204static inline vrf_id_t zebra_vrf_get_evpn_id(void)
205{
206 return zrouter.evpn_vrf ? zvrf_id(zrouter.evpn_vrf) : VRF_DEFAULT;
207}
208static inline struct zebra_vrf *zebra_vrf_get_evpn(void)
209{
210 return zrouter.evpn_vrf ? zrouter.evpn_vrf
211 : zebra_vrf_lookup_by_id(VRF_DEFAULT);
212}
d074383c 213
526052fb
DS
214extern void multicast_mode_ipv4_set(enum multicast_mode mode);
215
216extern enum multicast_mode multicast_mode_ipv4_get(void);
217
51e94aa7
EDP
218#ifdef __cplusplus
219}
220#endif
221
89272910 222#endif