]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_evpn.h
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / zebra / zebra_evpn.h
1 // SPDX-License-Identifier: GPL-2.0-or-later
2 /*
3 * Zebra EVPN Data structures and definitions
4 * These are "internal" to this function.
5 * Copyright (C) 2016, 2017 Cumulus Networks, Inc.
6 * Copyright (C) 2020 Volta Networks.
7 */
8
9 #ifndef _ZEBRA_EVPN_H
10 #define _ZEBRA_EVPN_H
11
12 #include <zebra.h>
13
14 #include "if.h"
15 #include "linklist.h"
16 #include "bitfield.h"
17
18 #include "zebra/zebra_l2.h"
19 #include "zebra/interface.h"
20 #include "zebra/zebra_vxlan.h"
21
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25
26 RB_HEAD(zebra_es_evi_rb_head, zebra_evpn_es_evi);
27 RB_PROTOTYPE(zebra_es_evi_rb_head, zebra_evpn_es_evi, rb_node,
28 zebra_es_evi_rb_cmp);
29
30 /* Private Structure to pass callback data for hash iterator */
31 struct zebra_evpn_show {
32 struct vty *vty;
33 json_object *json;
34 struct zebra_vrf *zvrf;
35 bool use_json;
36 };
37
38 /*
39 * VTEP info
40 *
41 * Right now, this just has each remote VTEP's IP address.
42 */
43 struct zebra_vtep {
44 /* Remote IP. */
45 /* NOTE: Can only be IPv4 right now. */
46 struct in_addr vtep_ip;
47 /* Flood mode (one of enum vxlan_flood_control) based on the PMSI
48 * tunnel type advertised by the remote VTEP
49 */
50 int flood_control;
51
52 /* Links. */
53 struct zebra_vtep *next;
54 struct zebra_vtep *prev;
55 };
56
57 /*
58 * VNI hash table
59 *
60 * Contains information pertaining to a VNI:
61 * - the list of remote VTEPs (with this VNI)
62 */
63 struct zebra_evpn {
64 /* VNI - key */
65 vni_t vni;
66
67 /* ES flags */
68 uint32_t flags;
69 #define ZEVPN_READY_FOR_BGP (1 << 0) /* ready to be sent to BGP */
70
71 /* Corresponding Bridge information */
72 vlanid_t vid;
73 struct interface *bridge_if;
74
75 /* Flag for advertising gw macip */
76 uint8_t advertise_gw_macip;
77
78 /* Flag for advertising svi macip */
79 uint8_t advertise_svi_macip;
80
81 /* Flag for advertising gw macip */
82 uint8_t advertise_subnet;
83
84 /* Corresponding VxLAN interface. */
85 struct interface *vxlan_if;
86
87 /* Corresponding SVI interface. */
88 struct interface *svi_if;
89
90 /* List of remote VTEPs */
91 struct zebra_vtep *vteps;
92
93 /* Local IP */
94 struct in_addr local_vtep_ip;
95
96 /* PIM-SM MDT group for BUM flooding */
97 struct in_addr mcast_grp;
98
99 /* tenant VRF, if any */
100 vrf_id_t vrf_id;
101
102 /* List of local or remote MAC */
103 struct hash *mac_table;
104
105 /* List of local or remote neighbors (MAC+IP) */
106 struct hash *neigh_table;
107
108 /* RB tree of ES-EVIs */
109 struct zebra_es_evi_rb_head es_evi_rb_tree;
110
111 /* List of local ESs */
112 struct list *local_es_evi_list;
113 };
114
115 /* for parsing evpn and vni contexts */
116 struct zebra_from_svi_param {
117 struct interface *br_if;
118 struct interface *svi_if;
119 struct zebra_if *zif;
120 uint8_t bridge_vlan_aware;
121 vlanid_t vid;
122 };
123
124 struct interface *zvni_map_to_svi(vlanid_t vid, struct interface *br_if);
125
126 static inline struct interface *zevpn_map_to_svi(struct zebra_evpn *zevpn)
127 {
128 struct interface *ifp;
129 struct zebra_if *zif = NULL;
130 struct zebra_vxlan_vni *vni;
131
132 ifp = zevpn->vxlan_if;
133 if (!ifp)
134 return NULL;
135 zif = ifp->info;
136 if (!zif)
137 return NULL;
138 vni = zebra_vxlan_if_vni_find(zif, zevpn->vni);
139 if (!vni)
140 return NULL;
141
142 /* If down or not mapped to a bridge, we're done. */
143 if (!if_is_operative(ifp) || !zif->brslave_info.br_if)
144 return NULL;
145
146 return zvni_map_to_svi(vni->access_vlan, zif->brslave_info.br_if);
147 }
148
149 int advertise_gw_macip_enabled(struct zebra_evpn *zevpn);
150 int advertise_svi_macip_enabled(struct zebra_evpn *zevpn);
151 void zebra_evpn_print(struct zebra_evpn *zevpn, void **ctxt);
152 void zebra_evpn_print_hash(struct hash_bucket *bucket, void *ctxt[]);
153 void zebra_evpn_print_hash_detail(struct hash_bucket *bucket, void *data);
154 int zebra_evpn_add_macip_for_intf(struct interface *ifp,
155 struct zebra_evpn *zevpn);
156 int zebra_evpn_del_macip_for_intf(struct interface *ifp,
157 struct zebra_evpn *zevpn);
158 int zebra_evpn_advertise_subnet(struct zebra_evpn *zevpn, struct interface *ifp,
159 int advertise);
160 int zebra_evpn_gw_macip_add(struct interface *ifp, struct zebra_evpn *zevpn,
161 struct ethaddr *macaddr, struct ipaddr *ip);
162 int zebra_evpn_gw_macip_del(struct interface *ifp, struct zebra_evpn *zevpn,
163 struct ipaddr *ip);
164 void zebra_evpn_gw_macip_del_for_evpn_hash(struct hash_bucket *bucket,
165 void *ctxt);
166 void zebra_evpn_gw_macip_add_for_evpn_hash(struct hash_bucket *bucket,
167 void *ctxt);
168 void zebra_evpn_svi_macip_del_for_evpn_hash(struct hash_bucket *bucket,
169 void *ctxt);
170 struct zebra_evpn *zebra_evpn_map_vlan(struct interface *ifp,
171 struct interface *br_if, vlanid_t vid);
172 struct zebra_evpn *zebra_evpn_from_svi(struct interface *ifp,
173 struct interface *br_if);
174 struct interface *zebra_evpn_map_to_macvlan(struct interface *br_if,
175 struct interface *svi_if);
176 void zebra_evpn_rem_mac_install_all(struct zebra_evpn *zevpn);
177 void zebra_evpn_rem_mac_uninstall_all(struct zebra_evpn *zevpn);
178 void zebra_evpn_read_mac_neigh(struct zebra_evpn *zevpn, struct interface *ifp);
179 unsigned int zebra_evpn_hash_keymake(const void *p);
180 bool zebra_evpn_hash_cmp(const void *p1, const void *p2);
181 int zebra_evpn_list_cmp(void *p1, void *p2);
182 void *zebra_evpn_alloc(void *p);
183 struct zebra_evpn *zebra_evpn_lookup(vni_t vni);
184 struct zebra_evpn *zebra_evpn_add(vni_t vni);
185 int zebra_evpn_del(struct zebra_evpn *zevpn);
186 int zebra_evpn_send_add_to_client(struct zebra_evpn *zevpn);
187 int zebra_evpn_send_del_to_client(struct zebra_evpn *zevpn);
188 struct zebra_vtep *zebra_evpn_vtep_find(struct zebra_evpn *zevpn,
189 struct in_addr *vtep_ip);
190 struct zebra_vtep *zebra_evpn_vtep_add(struct zebra_evpn *zevpn,
191 struct in_addr *vtep_ip,
192 int flood_control);
193 int zebra_evpn_vtep_del(struct zebra_evpn *zevpn, struct zebra_vtep *zvtep);
194 int zebra_evpn_vtep_del_all(struct zebra_evpn *zevpn, int uninstall);
195 int zebra_evpn_vtep_install(struct zebra_evpn *zevpn, struct zebra_vtep *zvtep);
196 int zebra_evpn_vtep_uninstall(struct zebra_evpn *zevpn,
197 struct in_addr *vtep_ip);
198 void zebra_evpn_handle_flooding_remote_vteps(struct hash_bucket *bucket,
199 void *zvrf);
200 void zebra_evpn_cleanup_all(struct hash_bucket *bucket, void *arg);
201 void zebra_evpn_rem_macip_add(vni_t vni, const struct ethaddr *macaddr,
202 uint16_t ipa_len, const struct ipaddr *ipaddr,
203 uint8_t flags, uint32_t seq,
204 struct in_addr vtep_ip, const esi_t *esi);
205 void zebra_evpn_rem_macip_del(vni_t vni, const struct ethaddr *macaddr,
206 uint16_t ipa_len, const struct ipaddr *ipaddr,
207 struct in_addr vtep_ip);
208 void zebra_evpn_cfg_cleanup(struct hash_bucket *bucket, void *ctxt);
209
210 #ifdef __cplusplus
211 }
212 #endif
213
214 #endif /*_ZEBRA_EVPN_H */