]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_l2.h
Merge pull request #11842 from opensourcerouting/fix/topotests_platform_check
[mirror_frr.git] / zebra / zebra_l2.h
1 /*
2 * Zebra Layer-2 interface Data structures and definitions
3 * Copyright (C) 2016, 2017 Cumulus Networks, Inc.
4 *
5 * This file is part of FRR.
6 *
7 * FRR is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2, or (at your option) any
10 * later version.
11 *
12 * FRR is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with FRR; see the file COPYING. If not, write to the Free
19 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
20 * 02111-1307, USA.
21 */
22
23 #ifndef _ZEBRA_L2_H
24 #define _ZEBRA_L2_H
25
26 #include <zebra.h>
27
28 #include "if.h"
29 #include "vlan.h"
30 #include "vxlan.h"
31 #include "zebra/zebra_vrf.h"
32
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36
37 #define ZEBRA_BRIDGE_NO_ACTION (0)
38 #define ZEBRA_BRIDGE_MASTER_MAC_CHANGE (1 << 1)
39 #define ZEBRA_BRIDGE_MASTER_UP (1 << 2)
40
41 /* zebra L2 interface information - bridge slave (linkage to bridge) */
42 struct zebra_l2info_brslave {
43 ifindex_t bridge_ifindex; /* Bridge Master */
44 struct interface *br_if; /* Pointer to master */
45 ns_id_t ns_id; /* network namespace where bridge is */
46 };
47
48 struct zebra_l2info_bond {
49 struct list *mbr_zifs; /* slaves using this bond as a master */
50 };
51
52 /* zebra L2 interface information - bridge interface */
53 struct zebra_l2info_bridge {
54 uint8_t vlan_aware; /* VLAN-aware bridge? */
55 };
56
57 /* zebra L2 interface information - VLAN interface */
58 struct zebra_l2info_vlan {
59 vlanid_t vid; /* VLAN id */
60 };
61
62 /* zebra L2 interface information - GRE interface */
63 struct zebra_l2info_gre {
64 struct in_addr vtep_ip; /* IFLA_GRE_LOCAL */
65 struct in_addr vtep_ip_remote; /* IFLA_GRE_REMOTE */
66 uint32_t ikey;
67 uint32_t okey;
68 ifindex_t ifindex_link; /* Interface index of interface
69 * linked with GRE
70 */
71 ns_id_t link_nsid;
72 };
73
74 /* zebra L2 interface information - VXLAN interface */
75 struct zebra_l2info_vxlan {
76 vni_t vni; /* VNI */
77 struct in_addr vtep_ip; /* Local tunnel IP */
78 vlanid_t access_vlan; /* Access VLAN - for VLAN-aware bridge. */
79 struct in_addr mcast_grp;
80 ifindex_t ifindex_link; /* Interface index of interface
81 * linked with VXLAN
82 */
83 ns_id_t link_nsid;
84 };
85
86 struct zebra_l2info_bondslave {
87 ifindex_t bond_ifindex; /* Bridge Master */
88 struct interface *bond_if; /* Pointer to master */
89 };
90
91 union zebra_l2if_info {
92 struct zebra_l2info_bridge br;
93 struct zebra_l2info_vlan vl;
94 struct zebra_l2info_vxlan vxl;
95 struct zebra_l2info_gre gre;
96 };
97
98 /* NOTE: These macros are to be invoked only in the "correct" context.
99 * IOW, the macro VNI_FROM_ZEBRA_IF() will assume the interface is
100 * of type ZEBRA_IF_VXLAN.
101 */
102 #define VNI_FROM_ZEBRA_IF(zif) (zif)->l2info.vxl.vni
103 #define VLAN_ID_FROM_ZEBRA_IF(zif) (zif)->l2info.vl.vid
104
105 #define IS_ZEBRA_IF_BRIDGE_VLAN_AWARE(zif) ((zif)->l2info.br.vlan_aware == 1)
106
107 extern void zebra_l2_map_slave_to_bridge(struct zebra_l2info_brslave *br_slave,
108 struct zebra_ns *zns);
109 extern void
110 zebra_l2_unmap_slave_from_bridge(struct zebra_l2info_brslave *br_slave);
111 extern void zebra_l2_bridge_add_update(struct interface *ifp,
112 struct zebra_l2info_bridge *bridge_info,
113 int add);
114 extern void zebra_l2_bridge_del(struct interface *ifp);
115 extern void zebra_l2_vlanif_update(struct interface *ifp,
116 struct zebra_l2info_vlan *vlan_info);
117 extern void zebra_l2_greif_add_update(struct interface *ifp,
118 struct zebra_l2info_gre *vxlan_info,
119 int add);
120 extern void zebra_l2_vxlanif_add_update(struct interface *ifp,
121 struct zebra_l2info_vxlan *vxlan_info,
122 int add);
123 extern void zebra_l2_vxlanif_update_access_vlan(struct interface *ifp,
124 vlanid_t access_vlan);
125 extern void zebra_l2_greif_del(struct interface *ifp);
126 extern void zebra_l2_vxlanif_del(struct interface *ifp);
127 extern void zebra_l2if_update_bridge_slave(struct interface *ifp,
128 ifindex_t bridge_ifindex,
129 ns_id_t ns_id, uint8_t chgflags);
130
131 extern void zebra_l2if_update_bond_slave(struct interface *ifp,
132 ifindex_t bond_ifindex, bool bypass);
133 extern void zebra_vlan_bitmap_compute(struct interface *ifp,
134 uint32_t vid_start, uint16_t vid_end);
135 extern void zebra_vlan_mbr_re_eval(struct interface *ifp,
136 bitfield_t vlan_bitmap);
137 extern void zebra_l2if_update_bond(struct interface *ifp, bool add);
138 extern void zebra_l2if_update_bridge(struct interface *ifp, uint8_t chgflags);
139
140 #ifdef __cplusplus
141 }
142 #endif
143
144 #endif /* _ZEBRA_L2_H */