]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_router.h
Merge pull request #5088 from pogojotz/revert-asm-equiv-in-MTYPE
[mirror_frr.git] / zebra / zebra_router.h
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
25 #include "lib/mlag.h"
26
27 #include "zebra/zebra_ns.h"
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32
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
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
64 struct 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;
74 };
75
76 struct zebra_router {
77 atomic_bool in_shutdown;
78
79 /* Thread master */
80 struct thread_master *master;
81
82 /* Lists of clients who have connected to us */
83 struct list *client_list;
84
85 struct zebra_router_table_head tables;
86
87 /* L3-VNI hash table (for EVPN). Only in default instance */
88 struct hash *l3vni_table;
89
90 struct hash *rules_hash;
91
92 struct hash *ipset_hash;
93
94 struct hash *ipset_entry_hash;
95
96 struct hash *iptable_hash;
97
98 /* used if vrf backend is not network namespace */
99 int rtadv_sock;
100
101 /* A sequence number used for tracking routes */
102 _Atomic uint32_t sequence_num;
103
104 /* rib work queue */
105 #define ZEBRA_RIB_PROCESS_HOLD_TIME 10
106 #define ZEBRA_RIB_PROCESS_RETRY_TIME 1
107 struct work_queue *ribq;
108
109 /* Meta Queue Information */
110 struct meta_queue *mq;
111
112 /* LSP work queue */
113 struct work_queue *lsp_process_q;
114
115 #define ZEBRA_ZAPI_PACKETS_TO_PROCESS 1000
116 _Atomic uint32_t packets_to_process;
117
118 /* Mlag information for the router */
119 struct zebra_mlag_info mlag_info;
120
121 /*
122 * The EVPN instance, if any
123 */
124 struct zebra_vrf *evpn_vrf;
125
126 uint32_t multipath_num;
127
128 /* RPF Lookup behavior */
129 enum multicast_mode ipv4_multicast_mode;
130
131 /*
132 * Time for when we sweep the rib from old routes
133 */
134 time_t startup_time;
135 };
136
137 #define GRACEFUL_RESTART_TIME 60
138
139 extern struct zebra_router zrouter;
140
141 extern void zebra_router_init(void);
142 extern void zebra_router_terminate(void);
143
144 extern struct route_table *zebra_router_find_table(struct zebra_vrf *zvrf,
145 uint32_t tableid, afi_t afi,
146 safi_t safi);
147 extern struct route_table *zebra_router_get_table(struct zebra_vrf *zvrf,
148 uint32_t tableid, afi_t afi,
149 safi_t safi);
150 extern void zebra_router_release_table(struct zebra_vrf *zvrf, uint32_t tableid,
151 afi_t afi, safi_t safi);
152
153 extern int zebra_router_config_write(struct vty *vty);
154
155 extern void zebra_router_sweep_route(void);
156
157 extern void zebra_router_show_table_summary(struct vty *vty);
158
159 extern uint32_t zebra_router_get_next_sequence(void);
160
161 static inline vrf_id_t zebra_vrf_get_evpn_id(void)
162 {
163 return zrouter.evpn_vrf ? zvrf_id(zrouter.evpn_vrf) : VRF_DEFAULT;
164 }
165 static inline struct zebra_vrf *zebra_vrf_get_evpn(void)
166 {
167 return zrouter.evpn_vrf ? zrouter.evpn_vrf
168 : zebra_vrf_lookup_by_id(VRF_DEFAULT);
169 }
170
171 extern void multicast_mode_ipv4_set(enum multicast_mode mode);
172
173 extern enum multicast_mode multicast_mode_ipv4_get(void);
174
175 #ifdef __cplusplus
176 }
177 #endif
178
179 #endif