]> git.proxmox.com Git - mirror_frr.git/blame - zebra/zebra_vxlan.h
Merge pull request #12798 from donaldsharp/rib_match_multicast
[mirror_frr.git] / zebra / zebra_vxlan.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
13d60d35 2/*
3 * Zebra VxLAN (EVPN) Data structures and definitions
4 * These are public definitions referenced by other files.
5 * Copyright (C) 2016, 2017 Cumulus Networks, Inc.
13d60d35 6 */
7
8#ifndef _ZEBRA_VXLAN_H
9#define _ZEBRA_VXLAN_H
10
11#include <zebra.h>
0fb2ad05 12#include <zebra/zebra_router.h>
13d60d35 13
14#include "linklist.h"
15#include "if.h"
16#include "vlan.h"
17#include "vxlan.h"
18
4cce389e 19#include "lib/json.h"
13d60d35 20#include "zebra/zebra_vrf.h"
89f4e507 21#include "zebra/zserv.h"
036d93c0 22#include "zebra/zebra_dplane.h"
8d30ff3b 23#include "zebra/interface.h"
13d60d35 24
51e94aa7
EDP
25#ifdef __cplusplus
26extern "C" {
27#endif
28
13d60d35 29/* Is EVPN enabled? */
30#define EVPN_ENABLED(zvrf) (zvrf)->advertise_all_vni
4d762f26 31static inline int is_evpn_enabled(void)
2853fed6 32{
81157cbd 33 return EVPN_ENABLED(zebra_vrf_get_evpn());
2853fed6 34}
35
fbac9605 36static inline int
4d762f26 37is_vxlan_flooding_head_end(void)
fbac9605 38{
cff8f33b 39 struct zebra_vrf *zvrf = zebra_vrf_get_evpn();
fbac9605
DS
40 return (zvrf->vxlan_flood_ctrl == VXLAN_FLOOD_HEAD_END_REPL);
41}
13d60d35 42
43/* VxLAN interface change flags of interest. */
3d434f5c
AK
44#define ZEBRA_VXLIF_LOCAL_IP_CHANGE (1 << 0)
45#define ZEBRA_VXLIF_MASTER_CHANGE (1 << 1)
46#define ZEBRA_VXLIF_VLAN_CHANGE (1 << 2)
47#define ZEBRA_VXLIF_MCAST_GRP_CHANGE (1 << 3)
c7620108 48#define ZEBRA_VXLIF_MASTER_MAC_CHANGE (1 << 4)
3d434f5c 49
8d30ff3b
SR
50#define ZEBRA_VXLIF_VNI_UPDATE(__flags) \
51 ((__flags) & (ZEBRA_VXLIF_VLAN_CHANGE | ZEBRA_VXLIF_MCAST_GRP_CHANGE))
52#define ZEBRA_VXLIF_UPDATE(__flags) \
53 ((__flags) & (ZEBRA_VXLIF_LOCAL_IP_CHANGE | ZEBRA_VXLIF_MASTER_CHANGE))
13d60d35 54
cd233079
CS
55#define VNI_STR_LEN 32
56
1002497a 57/* ZAPI message handlers */
89f4e507
QY
58extern void zebra_vxlan_remote_macip_add(ZAPI_HANDLER_ARGS);
59extern void zebra_vxlan_remote_macip_del(ZAPI_HANDLER_ARGS);
7e5b0b2b
MS
60extern void zebra_vxlan_remote_vtep_add_zapi(ZAPI_HANDLER_ARGS);
61extern void zebra_vxlan_remote_vtep_del_zapi(ZAPI_HANDLER_ARGS);
62void zebra_vxlan_remote_vtep_add(vrf_id_t vrf_id, vni_t vni,
63 struct in_addr vtep_ip, int flood_control);
64extern void zebra_vxlan_remote_vtep_del(vrf_id_t vrf_id, vni_t vni,
65 struct in_addr vtep_ip);
fbac9605 66extern void zebra_vxlan_flood_control(ZAPI_HANDLER_ARGS);
89f4e507 67extern void zebra_vxlan_advertise_subnet(ZAPI_HANDLER_ARGS);
278e26de 68extern void zebra_vxlan_advertise_svi_macip(ZAPI_HANDLER_ARGS);
89f4e507
QY
69extern void zebra_vxlan_advertise_gw_macip(ZAPI_HANDLER_ARGS);
70extern void zebra_vxlan_advertise_all_vni(ZAPI_HANDLER_ARGS);
3950b52c 71extern void zebra_vxlan_dup_addr_detection(ZAPI_HANDLER_ARGS);
ecbbc3a7 72extern void zebra_vxlan_sg_replay(ZAPI_HANDLER_ARGS);
89f4e507 73
c48d9f5f 74extern int is_l3vni_for_prefix_routes_only(vni_t vni);
d3135ba3 75extern ifindex_t get_l3vni_svi_ifindex(vrf_id_t vrf_id);
b260197d
SW
76extern ifindex_t get_l3vni_vxlan_ifindex(vrf_id_t vrf_id);
77extern vni_t get_l3vni_vni(vrf_id_t vrf_id);
78extern bool is_vrf_l3vni_svd_backed(vrf_id_t vrf_id);
523cafc4 79extern int zebra_vxlan_vrf_delete(struct zebra_vrf *zvrf);
84915b0a 80extern int zebra_vxlan_vrf_enable(struct zebra_vrf *zvrf);
81extern int zebra_vxlan_vrf_disable(struct zebra_vrf *zvrf);
82extern int zebra_vxlan_vrf_delete(struct zebra_vrf *zvrf);
9aa741ea 83extern void zebra_vxlan_print_specific_nh_l3vni(struct vty *vty, vni_t l3vni,
9f049418 84 struct ipaddr *ip, bool uj);
088f1098 85extern void zebra_vxlan_print_evpn(struct vty *vty, bool uj);
9aa741ea 86extern void zebra_vxlan_print_specific_rmac_l3vni(struct vty *vty, vni_t l3vni,
316f4ca4 87 struct ethaddr *rmac,
9f049418 88 bool use_json);
d62a17ae 89extern void zebra_vxlan_print_macs_vni(struct vty *vty, struct zebra_vrf *zvrf,
283ef1b0 90 vni_t vni, bool use_json, bool detail);
d62a17ae 91extern void zebra_vxlan_print_macs_all_vni(struct vty *vty,
cd233079 92 struct zebra_vrf *zvrf,
1374d4db 93 bool print_dup,
9f049418 94 bool use_json);
cffe7580
NS
95extern void zebra_vxlan_print_macs_all_vni_detail(struct vty *vty,
96 struct zebra_vrf *zvrf,
97 bool print_dup,
98 bool use_json);
d62a17ae 99extern void zebra_vxlan_print_macs_all_vni_vtep(struct vty *vty,
100 struct zebra_vrf *zvrf,
cd233079 101 struct in_addr vtep_ip,
9f049418 102 bool use_json);
d62a17ae 103extern void zebra_vxlan_print_specific_mac_vni(struct vty *vty,
104 struct zebra_vrf *zvrf,
24cdbd0d
DS
105 vni_t vni, struct ethaddr *mac,
106 bool use_json);
d62a17ae 107extern void zebra_vxlan_print_macs_vni_vtep(struct vty *vty,
108 struct zebra_vrf *zvrf, vni_t vni,
cd233079 109 struct in_addr vtep_ip,
9f049418 110 bool use_json);
1374d4db
CS
111extern void zebra_vxlan_print_macs_vni_dad(struct vty *vty,
112 struct zebra_vrf *zvrf, vni_t vni,
113 bool use_json);
d62a17ae 114extern void zebra_vxlan_print_neigh_vni(struct vty *vty, struct zebra_vrf *zvrf,
9f049418 115 vni_t vni, bool use_json);
d62a17ae 116extern void zebra_vxlan_print_neigh_all_vni(struct vty *vty,
cd233079 117 struct zebra_vrf *zvrf,
1374d4db 118 bool print_dup,
9f049418 119 bool use_json);
e3fac919
NS
120extern void zebra_vxlan_print_neigh_all_vni_detail(struct vty *vty,
121 struct zebra_vrf *zvrf,
122 bool print_dup,
123 bool use_json);
d62a17ae 124extern void zebra_vxlan_print_specific_neigh_vni(struct vty *vty,
125 struct zebra_vrf *zvrf,
cd233079 126 vni_t vni, struct ipaddr *ip,
9f049418 127 bool use_json);
d62a17ae 128extern void zebra_vxlan_print_neigh_vni_vtep(struct vty *vty,
129 struct zebra_vrf *zvrf, vni_t vni,
cd233079 130 struct in_addr vtep_ip,
9f049418 131 bool use_json);
1374d4db
CS
132extern void zebra_vxlan_print_neigh_vni_dad(struct vty *vty,
133 struct zebra_vrf *zvrf, vni_t vni,
134 bool use_json);
d62a17ae 135extern void zebra_vxlan_print_vni(struct vty *vty, struct zebra_vrf *zvrf,
06931fdb
LK
136 vni_t vni, bool use_json,
137 json_object *json_array);
cd233079 138extern void zebra_vxlan_print_vnis(struct vty *vty, struct zebra_vrf *zvrf,
9f049418 139 bool use_json);
09af6961
NS
140extern void zebra_vxlan_print_vnis_detail(struct vty *vty,
141 struct zebra_vrf *zvrf,
142 bool use_json);
996c9314 143extern void zebra_vxlan_print_rmacs_l3vni(struct vty *vty, vni_t vni,
9f049418
DS
144 bool use_json);
145extern void zebra_vxlan_print_rmacs_all_l3vni(struct vty *vty, bool use_json);
996c9314 146extern void zebra_vxlan_print_nh_l3vni(struct vty *vty, vni_t vni,
9f049418 147 bool use_json);
d44fc240 148extern void zebra_vxlan_print_nh_svd(struct vty *vty, bool use_json);
9f049418
DS
149extern void zebra_vxlan_print_nh_all_l3vni(struct vty *vty, bool use_json);
150extern void zebra_vxlan_print_l3vni(struct vty *vty, vni_t vni, bool use_json);
4cce389e
MK
151extern void zebra_vxlan_print_vrf_vni(struct vty *vty, struct zebra_vrf *zvrf,
152 json_object *json_vrfs);
7e5b0b2b
MS
153extern int zebra_vxlan_add_del_gw_macip(struct interface *ifp,
154 const struct prefix *p, int add);
d62a17ae 155extern int zebra_vxlan_svi_up(struct interface *ifp, struct interface *link_if);
156extern int zebra_vxlan_svi_down(struct interface *ifp,
157 struct interface *link_if);
ee69da27 158extern int zebra_vxlan_handle_kernel_neigh_update(
d62a17ae 159 struct interface *ifp, struct interface *link_if, struct ipaddr *ip,
a37f4598 160 struct ethaddr *macaddr, uint16_t state, bool is_ext,
b169fd6f 161 bool is_router, bool local_inactive, bool dp_static);
ee69da27 162extern int zebra_vxlan_handle_kernel_neigh_del(struct interface *ifp,
d62a17ae 163 struct interface *link_if,
164 struct ipaddr *ip);
d62a17ae 165extern int zebra_vxlan_local_mac_add_update(struct interface *ifp,
166 struct interface *br_if,
167 struct ethaddr *mac, vlanid_t vid,
b169fd6f
AK
168 bool sticky, bool local_inactive,
169 bool dp_static);
d62a17ae 170extern int zebra_vxlan_local_mac_del(struct interface *ifp,
171 struct interface *br_if,
172 struct ethaddr *mac, vlanid_t vid);
784d88aa 173extern int zebra_vxlan_check_readd_vtep(struct interface *ifp, vni_t vni,
4b3f26f4 174 struct in_addr vtep_ip);
d62a17ae 175extern int zebra_vxlan_if_up(struct interface *ifp);
176extern int zebra_vxlan_if_down(struct interface *ifp);
177extern int zebra_vxlan_if_add(struct interface *ifp);
00d30205 178extern int zebra_vxlan_if_update(struct interface *ifp,
179 struct zebra_vxlan_if_update_ctx *ctx);
d62a17ae 180extern int zebra_vxlan_if_del(struct interface *ifp);
523cafc4 181extern int zebra_vxlan_process_vrf_vni_cmd(struct zebra_vrf *zvrf, vni_t vni,
996c9314
LB
182 char *err, int err_str_sz,
183 int filter, int add);
d62a17ae 184extern void zebra_vxlan_init_tables(struct zebra_vrf *zvrf);
185extern void zebra_vxlan_close_tables(struct zebra_vrf *);
84915b0a 186extern void zebra_vxlan_cleanup_tables(struct zebra_vrf *);
6548050a
PG
187extern void zebra_vxlan_init(void);
188extern void zebra_vxlan_disable(void);
2dbad57f 189extern void zebra_vxlan_evpn_vrf_route_add(vrf_id_t vrf_id,
e4a1ec74
MS
190 const struct ethaddr *rmac,
191 const struct ipaddr *ip,
192 const struct prefix *host_prefix);
2dbad57f 193extern void zebra_vxlan_evpn_vrf_route_del(vrf_id_t vrf_id,
6134fd82 194 struct ipaddr *vtep_ip,
195 struct prefix *host_prefix);
e20755b2 196extern int zebra_vxlan_clear_dup_detect_vni_mac(struct zebra_vrf *zvrf,
1883de66 197 vni_t vni,
9bee0232
CS
198 struct ethaddr *macaddr,
199 char *errmsg,
200 size_t errmsg_len);
e20755b2 201extern int zebra_vxlan_clear_dup_detect_vni_ip(struct zebra_vrf *zvrf,
9bee0232
CS
202 vni_t vni, struct ipaddr *ip,
203 char *errmsg, size_t errmsg_len);
e20755b2
CS
204extern int zebra_vxlan_clear_dup_detect_vni_all(struct zebra_vrf *zvrf);
205extern int zebra_vxlan_clear_dup_detect_vni(struct zebra_vrf *zvrf, vni_t vni);
036d93c0
MS
206extern void zebra_vxlan_handle_result(struct zebra_dplane_ctx *ctx);
207
27627f9a 208extern void zebra_evpn_init(void);
0056f687
CS
209extern void zebra_vxlan_macvlan_up(struct interface *ifp);
210extern void zebra_vxlan_macvlan_down(struct interface *ifp);
ce5160c0 211extern int vni_list_cmp(void *p1, void *p2);
15400f95
AK
212extern int zebra_vxlan_dp_network_mac_add(struct interface *ifp,
213 struct interface *br_if,
214 struct ethaddr *macaddr, vlanid_t vid,
784d88aa
SR
215 vni_t vni, uint32_t nhg_id,
216 bool sticky, bool dp_static);
15400f95
AK
217extern int zebra_vxlan_dp_network_mac_del(struct interface *ifp,
218 struct interface *br_if,
784d88aa
SR
219 struct ethaddr *macaddr, vlanid_t vid,
220 vni_t vni);
13d60d35 221
7d99ad7f 222extern void zebra_vxlan_set_accept_bgp_seq(bool set);
da823882 223extern bool zebra_vxlan_get_accept_bgp_seq(void);
7d99ad7f 224
51e94aa7
EDP
225#ifdef __cplusplus
226}
227#endif
228
13d60d35 229#endif /* _ZEBRA_VXLAN_H */