]> git.proxmox.com Git - mirror_frr.git/blame - zebra/zebra_evpn.h
Merge pull request #13235 from Orange-OpenSource/link-state
[mirror_frr.git] / zebra / zebra_evpn.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
b2998086
PR
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.
b2998086
PR
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"
7cbae20a
PR
16#include "bitfield.h"
17
18#include "zebra/zebra_l2.h"
19#include "zebra/interface.h"
8d30ff3b 20#include "zebra/zebra_vxlan.h"
b2998086
PR
21
22#ifdef __cplusplus
23extern "C" {
24#endif
25
b2998086
PR
26RB_HEAD(zebra_es_evi_rb_head, zebra_evpn_es_evi);
27RB_PROTOTYPE(zebra_es_evi_rb_head, zebra_evpn_es_evi, rb_node,
28 zebra_es_evi_rb_cmp);
29
8b5fdf2e
PR
30/* Private Structure to pass callback data for hash iterator */
31struct zebra_evpn_show {
32 struct vty *vty;
33 json_object *json;
34 struct zebra_vrf *zvrf;
35 bool use_json;
36};
37
b2998086
PR
38/*
39 * VTEP info
40 *
41 * Right now, this just has each remote VTEP's IP address.
42 */
c172c032 43struct zebra_vtep {
b2998086
PR
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. */
c172c032
DS
53 struct zebra_vtep *next;
54 struct zebra_vtep *prev;
b2998086
PR
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 */
f6371c34 63struct zebra_evpn {
b2998086
PR
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
efde4f25
SR
71 /* Corresponding Bridge information */
72 vlanid_t vid;
73 struct interface *bridge_if;
74
b2998086
PR
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
9daa5d47
AD
87 /* Corresponding SVI interface. */
88 struct interface *svi_if;
89
b2998086 90 /* List of remote VTEPs */
c172c032 91 struct zebra_vtep *vteps;
b2998086
PR
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
a237058f
PG
115/* for parsing evpn and vni contexts */
116struct zebra_from_svi_param {
117 struct interface *br_if;
a1ce03e1 118 struct interface *svi_if;
a237058f
PG
119 struct zebra_if *zif;
120 uint8_t bridge_vlan_aware;
121 vlanid_t vid;
122};
123
7cbae20a
PR
124struct interface *zvni_map_to_svi(vlanid_t vid, struct interface *br_if);
125
f6371c34 126static inline struct interface *zevpn_map_to_svi(struct zebra_evpn *zevpn)
7cbae20a
PR
127{
128 struct interface *ifp;
129 struct zebra_if *zif = NULL;
8d30ff3b 130 struct zebra_vxlan_vni *vni;
7cbae20a
PR
131
132 ifp = zevpn->vxlan_if;
133 if (!ifp)
134 return NULL;
135 zif = ifp->info;
136 if (!zif)
137 return NULL;
8d30ff3b
SR
138 vni = zebra_vxlan_if_vni_find(zif, zevpn->vni);
139 if (!vni)
140 return NULL;
7cbae20a
PR
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;
8d30ff3b
SR
145
146 return zvni_map_to_svi(vni->access_vlan, zif->brslave_info.br_if);
7cbae20a
PR
147}
148
f6371c34
DS
149int advertise_gw_macip_enabled(struct zebra_evpn *zevpn);
150int advertise_svi_macip_enabled(struct zebra_evpn *zevpn);
151void zebra_evpn_print(struct zebra_evpn *zevpn, void **ctxt);
8b5fdf2e
PR
152void zebra_evpn_print_hash(struct hash_bucket *bucket, void *ctxt[]);
153void zebra_evpn_print_hash_detail(struct hash_bucket *bucket, void *data);
f6371c34
DS
154int zebra_evpn_add_macip_for_intf(struct interface *ifp,
155 struct zebra_evpn *zevpn);
156int zebra_evpn_del_macip_for_intf(struct interface *ifp,
157 struct zebra_evpn *zevpn);
158int zebra_evpn_advertise_subnet(struct zebra_evpn *zevpn, struct interface *ifp,
8b5fdf2e 159 int advertise);
f6371c34 160int zebra_evpn_gw_macip_add(struct interface *ifp, struct zebra_evpn *zevpn,
8b5fdf2e 161 struct ethaddr *macaddr, struct ipaddr *ip);
f6371c34 162int zebra_evpn_gw_macip_del(struct interface *ifp, struct zebra_evpn *zevpn,
8b5fdf2e
PR
163 struct ipaddr *ip);
164void zebra_evpn_gw_macip_del_for_evpn_hash(struct hash_bucket *bucket,
165 void *ctxt);
166void zebra_evpn_gw_macip_add_for_evpn_hash(struct hash_bucket *bucket,
167 void *ctxt);
168void zebra_evpn_svi_macip_del_for_evpn_hash(struct hash_bucket *bucket,
169 void *ctxt);
f6371c34
DS
170struct zebra_evpn *zebra_evpn_map_vlan(struct interface *ifp,
171 struct interface *br_if, vlanid_t vid);
172struct zebra_evpn *zebra_evpn_from_svi(struct interface *ifp,
173 struct interface *br_if);
8b5fdf2e
PR
174struct interface *zebra_evpn_map_to_macvlan(struct interface *br_if,
175 struct interface *svi_if);
00d30205 176void zebra_evpn_rem_mac_install_all(struct zebra_evpn *zevpn);
177void zebra_evpn_rem_mac_uninstall_all(struct zebra_evpn *zevpn);
f6371c34 178void zebra_evpn_read_mac_neigh(struct zebra_evpn *zevpn, struct interface *ifp);
8b5fdf2e
PR
179unsigned int zebra_evpn_hash_keymake(const void *p);
180bool zebra_evpn_hash_cmp(const void *p1, const void *p2);
181int zebra_evpn_list_cmp(void *p1, void *p2);
182void *zebra_evpn_alloc(void *p);
f6371c34
DS
183struct zebra_evpn *zebra_evpn_lookup(vni_t vni);
184struct zebra_evpn *zebra_evpn_add(vni_t vni);
185int zebra_evpn_del(struct zebra_evpn *zevpn);
186int zebra_evpn_send_add_to_client(struct zebra_evpn *zevpn);
187int zebra_evpn_send_del_to_client(struct zebra_evpn *zevpn);
c172c032
DS
188struct zebra_vtep *zebra_evpn_vtep_find(struct zebra_evpn *zevpn,
189 struct in_addr *vtep_ip);
190struct zebra_vtep *zebra_evpn_vtep_add(struct zebra_evpn *zevpn,
191 struct in_addr *vtep_ip,
192 int flood_control);
193int zebra_evpn_vtep_del(struct zebra_evpn *zevpn, struct zebra_vtep *zvtep);
f6371c34 194int zebra_evpn_vtep_del_all(struct zebra_evpn *zevpn, int uninstall);
c172c032 195int zebra_evpn_vtep_install(struct zebra_evpn *zevpn, struct zebra_vtep *zvtep);
f6371c34
DS
196int zebra_evpn_vtep_uninstall(struct zebra_evpn *zevpn,
197 struct in_addr *vtep_ip);
8b5fdf2e
PR
198void zebra_evpn_handle_flooding_remote_vteps(struct hash_bucket *bucket,
199 void *zvrf);
200void zebra_evpn_cleanup_all(struct hash_bucket *bucket, void *arg);
1a3bd37f
MS
201void zebra_evpn_rem_macip_add(vni_t vni, const struct ethaddr *macaddr,
202 uint16_t ipa_len, const struct ipaddr *ipaddr,
8b5fdf2e 203 uint8_t flags, uint32_t seq,
1a3bd37f
MS
204 struct in_addr vtep_ip, const esi_t *esi);
205void zebra_evpn_rem_macip_del(vni_t vni, const struct ethaddr *macaddr,
206 uint16_t ipa_len, const struct ipaddr *ipaddr,
8b5fdf2e
PR
207 struct in_addr vtep_ip);
208void zebra_evpn_cfg_cleanup(struct hash_bucket *bucket, void *ctxt);
224315f3 209
b2998086
PR
210#ifdef __cplusplus
211}
212#endif
213
214#endif /*_ZEBRA_EVPN_H */