1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Zebra Layer-2 interface Data structures and definitions
4 * Copyright (C) 2016, 2017 Cumulus Networks, Inc.
15 #include "zebra/zebra_vrf.h"
21 #define ZEBRA_BRIDGE_NO_ACTION (0)
22 #define ZEBRA_BRIDGE_MASTER_MAC_CHANGE (1 << 1)
23 #define ZEBRA_BRIDGE_MASTER_UP (1 << 2)
25 /* zebra L2 interface information - bridge slave (linkage to bridge) */
26 struct zebra_l2info_brslave
{
27 ifindex_t bridge_ifindex
; /* Bridge Master */
28 struct interface
*br_if
; /* Pointer to master */
29 ns_id_t ns_id
; /* network namespace where bridge is */
32 struct zebra_l2info_bond
{
33 struct list
*mbr_zifs
; /* slaves using this bond as a master */
36 struct zebra_l2_bridge_vlan
{
38 struct zebra_evpn_access_bd
*access_bd
;
41 struct zebra_l2_bridge_if_ctx
{
44 int (*func
)(struct zebra_if
*zif
, struct zebra_l2_bridge_vlan
*vlan
,
51 struct zebra_l2_bridge_if
{
53 struct zebra_if
*br_zif
;
54 struct hash
*vlan_table
;
57 /* zebra L2 interface information - bridge interface */
58 struct zebra_l2info_bridge
{
59 struct zebra_l2_bridge_if bridge
;
62 /* zebra L2 interface information - VLAN interface */
63 struct zebra_l2info_vlan
{
64 vlanid_t vid
; /* VLAN id */
67 /* zebra L2 interface information - GRE interface */
68 struct zebra_l2info_gre
{
69 struct in_addr vtep_ip
; /* IFLA_GRE_LOCAL */
70 struct in_addr vtep_ip_remote
; /* IFLA_GRE_REMOTE */
73 ifindex_t ifindex_link
; /* Interface index of interface
79 struct zebra_vxlan_vni
{
81 vlanid_t access_vlan
; /* Access VLAN - for VLAN-aware bridge. */
82 struct in_addr mcast_grp
;
86 ZEBRA_VXLAN_IF_VNI
= 0, /* per vni vxlan if */
87 ZEBRA_VXLAN_IF_SVD
/* single vxlan device */
90 struct zebra_vxlan_if_vlan_ctx
{
92 struct zebra_vxlan_vni
*vni
;
95 struct zebra_vxlan_if_update_ctx
{
97 struct in_addr old_vtep_ip
;
98 struct zebra_vxlan_vni old_vni
;
99 struct hash
*old_vni_table
;
102 struct zebra_vxlan_if_ctx
{
104 struct zebra_if
*zif
;
105 int (*func
)(struct zebra_if
*zif
, struct zebra_vxlan_vni
*vni
,
112 struct zebra_vxlan_vni_info
{
115 struct zebra_vxlan_vni vni
; /* per vni vxlan device vni info */
117 *vni_table
; /* table of vni's assocated with this if */
121 /* zebra L2 interface information - VXLAN interface */
122 struct zebra_l2info_vxlan
{
123 struct zebra_vxlan_vni_info vni_info
;
124 struct in_addr vtep_ip
; /* Local tunnel IP */
125 ifindex_t ifindex_link
; /* Interface index of interface
131 struct zebra_l2info_bondslave
{
132 ifindex_t bond_ifindex
; /* Bridge Master */
133 struct interface
*bond_if
; /* Pointer to master */
136 union zebra_l2if_info
{
137 struct zebra_l2info_bridge br
;
138 struct zebra_l2info_vlan vl
;
139 struct zebra_l2info_vxlan vxl
;
140 struct zebra_l2info_gre gre
;
143 /* NOTE: These macros are to be invoked only in the "correct" context.
144 * IOW, the macro VNI_FROM_ZEBRA_IF() will assume the interface is
145 * of type ZEBRA_IF_VXLAN.
147 #define VNI_INFO_FROM_ZEBRA_IF(zif) (&((zif)->l2info.vxl.vni_info))
148 #define IS_ZEBRA_VXLAN_IF_SVD(zif) \
149 ((zif)->l2info.vxl.vni_info.iftype == ZEBRA_VXLAN_IF_SVD)
150 #define IS_ZEBRA_VXLAN_IF_VNI(zif) \
151 ((zif)->l2info.vxl.vni_info.iftype == ZEBRA_VXLAN_IF_VNI)
152 #define VLAN_ID_FROM_ZEBRA_IF(zif) (zif)->l2info.vl.vid
154 #define BRIDGE_FROM_ZEBRA_IF(zif) (&((zif)->l2info.br.bridge))
155 #define IS_ZEBRA_IF_BRIDGE_VLAN_AWARE(zif) \
156 ((zif)->l2info.br.bridge.vlan_aware == 1)
158 extern void zebra_l2_map_slave_to_bridge(struct zebra_l2info_brslave
*br_slave
,
159 struct zebra_ns
*zns
);
161 zebra_l2_unmap_slave_from_bridge(struct zebra_l2info_brslave
*br_slave
);
162 extern void zebra_l2_bridge_add_update(struct interface
*ifp
,
163 struct zebra_l2info_bridge
*bridge_info
,
165 extern void zebra_l2_bridge_del(struct interface
*ifp
);
166 extern void zebra_l2_vlanif_update(struct interface
*ifp
,
167 struct zebra_l2info_vlan
*vlan_info
);
168 extern void zebra_l2_greif_add_update(struct interface
*ifp
,
169 struct zebra_l2info_gre
*vxlan_info
,
171 extern void zebra_l2_vxlanif_add_update(struct interface
*ifp
,
172 struct zebra_l2info_vxlan
*vxlan_info
,
174 extern void zebra_l2_vxlanif_update_access_vlan(struct interface
*ifp
,
175 vlanid_t access_vlan
);
176 extern void zebra_l2_greif_del(struct interface
*ifp
);
177 extern void zebra_l2_vxlanif_del(struct interface
*ifp
);
178 extern void zebra_l2if_update_bridge_slave(struct interface
*ifp
,
179 ifindex_t bridge_ifindex
,
180 ns_id_t ns_id
, uint8_t chgflags
);
182 extern void zebra_l2if_update_bond_slave(struct interface
*ifp
,
183 ifindex_t bond_ifindex
, bool bypass
);
184 extern void zebra_vlan_bitmap_compute(struct interface
*ifp
,
185 uint32_t vid_start
, uint16_t vid_end
);
186 extern void zebra_vlan_mbr_re_eval(struct interface
*ifp
,
187 bitfield_t vlan_bitmap
);
188 extern void zebra_l2if_update_bond(struct interface
*ifp
, bool add
);
189 extern void zebra_l2if_update_bridge(struct interface
*ifp
, uint8_t chgflags
);
195 #endif /* _ZEBRA_L2_H */