]>
git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_vxlan_private.h
2 * Zebra VxLAN (EVPN) Data structures and definitions
3 * These are "internal" to this function.
4 * Copyright (C) 2016, 2017 Cumulus Networks, Inc.
6 * This file is part of FRR.
8 * FRR is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2, or (at your option) any
13 * FRR is distributed in the hope that it will be useful, but
14 * WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with FRR; see the file COPYING. If not, write to the Free
20 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
24 #ifndef _ZEBRA_VXLAN_PRIVATE_H
25 #define _ZEBRA_VXLAN_PRIVATE_H
31 #include "zebra_vxlan.h"
32 #include "zebra_vxlan_if.h"
33 #include "zebra_evpn.h"
34 #include "zebra_evpn_mac.h"
40 #define ERR_STR_SZ 256
42 /* L3 VNI hash table */
52 #define PREFIX_ROUTES_ONLY (1 << 0) /* l3-vni used for prefix routes only */
54 /* Corresponding Bridge information */
56 struct interface
*bridge_if
;
59 struct in_addr local_vtep_ip
;
61 /* kernel interface for l3vni */
62 struct interface
*vxlan_if
;
64 /* SVI interface corresponding to the l3vni */
65 struct interface
*svi_if
;
67 struct interface
*mac_vlan_if
;
69 /* list of L2 VNIs associated with the L3 VNI */
72 /* list of remote router-macs */
73 struct hash
*rmac_table
;
75 /* list of remote vtep-ip neigh */
76 struct hash
*nh_table
;
79 #define IS_ZL3VNI_SVD_BACKED(zl3vni) \
80 (zl3vni->vxlan_if && zl3vni->vxlan_if->info && \
81 IS_ZEBRA_VXLAN_IF_SVD((struct zebra_if *)zl3vni->vxlan_if->info))
83 /* get the vx-intf name for l3vni */
84 static inline const char *zl3vni_vxlan_if_name(struct zebra_l3vni
*zl3vni
)
86 return zl3vni
->vxlan_if
? zl3vni
->vxlan_if
->name
: "None";
89 /* get the svi intf name for l3vni */
90 static inline const char *zl3vni_svi_if_name(struct zebra_l3vni
*zl3vni
)
92 return zl3vni
->svi_if
? zl3vni
->svi_if
->name
: "None";
95 /* get the vrf name for l3vni */
96 static inline const char *zl3vni_vrf_name(struct zebra_l3vni
*zl3vni
)
98 return vrf_id_to_name(zl3vni
->vrf_id
);
101 /* get the rmac string */
102 static inline const char *zl3vni_rmac2str(struct zebra_l3vni
*zl3vni
, char *buf
,
108 ptr
= XMALLOC(MTYPE_TMP
, ETHER_ADDR_STRLEN
* sizeof(char));
110 assert(size
>= ETHER_ADDR_STRLEN
);
114 if (zl3vni
->mac_vlan_if
)
115 snprintf(ptr
, (ETHER_ADDR_STRLEN
),
116 "%02x:%02x:%02x:%02x:%02x:%02x",
117 (uint8_t)zl3vni
->mac_vlan_if
->hw_addr
[0],
118 (uint8_t)zl3vni
->mac_vlan_if
->hw_addr
[1],
119 (uint8_t)zl3vni
->mac_vlan_if
->hw_addr
[2],
120 (uint8_t)zl3vni
->mac_vlan_if
->hw_addr
[3],
121 (uint8_t)zl3vni
->mac_vlan_if
->hw_addr
[4],
122 (uint8_t)zl3vni
->mac_vlan_if
->hw_addr
[5]);
123 else if (zl3vni
->svi_if
)
124 snprintf(ptr
, (ETHER_ADDR_STRLEN
),
125 "%02x:%02x:%02x:%02x:%02x:%02x",
126 (uint8_t)zl3vni
->svi_if
->hw_addr
[0],
127 (uint8_t)zl3vni
->svi_if
->hw_addr
[1],
128 (uint8_t)zl3vni
->svi_if
->hw_addr
[2],
129 (uint8_t)zl3vni
->svi_if
->hw_addr
[3],
130 (uint8_t)zl3vni
->svi_if
->hw_addr
[4],
131 (uint8_t)zl3vni
->svi_if
->hw_addr
[5]);
133 snprintf(ptr
, ETHER_ADDR_STRLEN
, "None");
138 /* get the sys mac string */
139 static inline const char *zl3vni_sysmac2str(struct zebra_l3vni
*zl3vni
,
145 ptr
= XMALLOC(MTYPE_TMP
, ETHER_ADDR_STRLEN
* sizeof(char));
147 assert(size
>= ETHER_ADDR_STRLEN
);
152 snprintf(ptr
, (ETHER_ADDR_STRLEN
),
153 "%02x:%02x:%02x:%02x:%02x:%02x",
154 (uint8_t)zl3vni
->svi_if
->hw_addr
[0],
155 (uint8_t)zl3vni
->svi_if
->hw_addr
[1],
156 (uint8_t)zl3vni
->svi_if
->hw_addr
[2],
157 (uint8_t)zl3vni
->svi_if
->hw_addr
[3],
158 (uint8_t)zl3vni
->svi_if
->hw_addr
[4],
159 (uint8_t)zl3vni
->svi_if
->hw_addr
[5]);
161 snprintf(ptr
, ETHER_ADDR_STRLEN
, "None");
167 * l3-vni is oper up when:
168 * 0. if EVPN is enabled (advertise-all-vni cfged)
169 * 1. it is associated to a vxlan-intf
170 * 2. Associated vxlan-intf is oper up
171 * 3. it is associated to an SVI
172 * 4. associated SVI is oper up
174 static inline int is_l3vni_oper_up(struct zebra_l3vni
*zl3vni
)
176 return (is_evpn_enabled() && zl3vni
&& (zl3vni
->vrf_id
!= VRF_UNKNOWN
)
177 && zl3vni
->vxlan_if
&& if_is_operative(zl3vni
->vxlan_if
)
178 && zl3vni
->svi_if
&& if_is_operative(zl3vni
->svi_if
));
181 static inline const char *zl3vni_state2str(struct zebra_l3vni
*zl3vni
)
186 if (is_l3vni_oper_up(zl3vni
))
194 static inline vrf_id_t
zl3vni_vrf_id(struct zebra_l3vni
*zl3vni
)
196 return zl3vni
->vrf_id
;
199 static inline void zl3vni_get_svi_rmac(struct zebra_l3vni
*zl3vni
,
200 struct ethaddr
*rmac
)
205 if (!is_l3vni_oper_up(zl3vni
))
208 if (zl3vni
->svi_if
&& if_is_operative(zl3vni
->svi_if
))
209 memcpy(rmac
->octet
, zl3vni
->svi_if
->hw_addr
, ETH_ALEN
);
213 /* context for neigh hash walk - update l3vni and rmac */
214 struct neigh_l3info_walk_ctx
{
216 struct zebra_evpn
*zevpn
;
217 struct zebra_l3vni
*zl3vni
;
224 struct json_object
*json
;
227 extern struct zebra_l3vni
*zl3vni_from_vrf(vrf_id_t vrf_id
);
228 extern struct interface
*zl3vni_map_to_vxlan_if(struct zebra_l3vni
*zl3vni
);
229 extern struct interface
*zl3vni_map_to_svi_if(struct zebra_l3vni
*zl3vni
);
230 extern struct interface
*zl3vni_map_to_mac_vlan_if(struct zebra_l3vni
*zl3vni
);
231 extern struct zebra_l3vni
*zl3vni_lookup(vni_t vni
);
232 extern vni_t
vni_id_from_svi(struct interface
*ifp
, struct interface
*br_if
);
234 DECLARE_HOOK(zebra_rmac_update
,
235 (struct zebra_mac
* rmac
, struct zebra_l3vni
*zl3vni
, bool delete,
237 (rmac
, zl3vni
, delete, reason
));
245 * Multicast hash table.
247 * This table contains -
248 * 1. The (S, G) entries used for encapsulating and forwarding BUM traffic.
249 * S is the local VTEP-IP and G is a BUM mcast group address.
250 * 2. The (X, G) entries used for terminating a BUM flow.
251 * Multiple L2-VNIs can share the same MDT hence the need to maintain
252 * an aggregated table that pimd can consume without much
255 struct zebra_vxlan_sg
{
256 struct zebra_vrf
*zvrf
;
259 char sg_str
[PREFIX_SG_STR_LEN
];
261 /* For SG - num of L2 VNIs using this entry for sending BUM traffic */
262 /* For XG - num of SG using this as parent */
266 extern struct zebra_evpn
*zevpn_lookup(vni_t vni
);
267 extern void zebra_vxlan_sync_mac_dp_install(struct zebra_mac
*mac
,
269 bool force_clear_static
,
271 extern bool zebra_evpn_do_dup_addr_detect(struct zebra_vrf
*zvrf
);
272 extern void zebra_vxlan_sg_ref(struct in_addr local_vtep_ip
,
273 struct in_addr mcast_grp
);
274 extern void zebra_vxlan_sg_deref(struct in_addr local_vtep_ip
,
275 struct in_addr mcast_grp
);
276 extern void zebra_vxlan_process_l3vni_oper_up(struct zebra_l3vni
*zl3vni
);
277 extern void zebra_vxlan_process_l3vni_oper_down(struct zebra_l3vni
*zl3vni
);
278 extern int zebra_evpn_vxlan_del(struct zebra_evpn
*zevpn
);
280 #endif /* _ZEBRA_VXLAN_PRIVATE_H */