]>
Commit | Line | Data |
---|---|---|
6675513d | 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 | ||
51e94aa7 EDP |
32 | #ifdef __cplusplus |
33 | extern "C" { | |
34 | #endif | |
35 | ||
c7620108 PG |
36 | #define ZEBRA_BRIDGE_NO_ACTION (0) |
37 | #define ZEBRA_BRIDGE_MASTER_MAC_CHANGE (1 << 1) | |
f56a15b5 | 38 | #define ZEBRA_BRIDGE_MASTER_UP (1 << 2) |
c7620108 | 39 | |
6675513d | 40 | /* zebra L2 interface information - bridge slave (linkage to bridge) */ |
d62a17ae | 41 | struct zebra_l2info_brslave { |
42 | ifindex_t bridge_ifindex; /* Bridge Master */ | |
43 | struct interface *br_if; /* Pointer to master */ | |
a6e0edf2 | 44 | ns_id_t ns_id; /* network namespace where bridge is */ |
6675513d | 45 | }; |
46 | ||
c36e442c AK |
47 | struct zebra_l2info_bond { |
48 | struct list *mbr_zifs; /* slaves using this bond as a master */ | |
49 | }; | |
50 | ||
6675513d | 51 | /* zebra L2 interface information - bridge interface */ |
d62a17ae | 52 | struct zebra_l2info_bridge { |
d7c0a89a | 53 | uint8_t vlan_aware; /* VLAN-aware bridge? */ |
6675513d | 54 | }; |
55 | ||
56 | /* zebra L2 interface information - VLAN interface */ | |
d62a17ae | 57 | struct zebra_l2info_vlan { |
58 | vlanid_t vid; /* VLAN id */ | |
6675513d | 59 | }; |
60 | ||
077c07cc PG |
61 | /* zebra L2 interface information - GRE interface */ |
62 | struct zebra_l2info_gre { | |
63 | struct in_addr vtep_ip; /* IFLA_GRE_LOCAL */ | |
64 | struct in_addr vtep_ip_remote; /* IFLA_GRE_REMOTE */ | |
65 | uint32_t ikey; | |
66 | uint32_t okey; | |
67 | ifindex_t ifindex_link; /* Interface index of interface | |
68 | * linked with GRE | |
69 | */ | |
70 | ns_id_t link_nsid; | |
71 | }; | |
72 | ||
6675513d | 73 | /* zebra L2 interface information - VXLAN interface */ |
d62a17ae | 74 | struct zebra_l2info_vxlan { |
75 | vni_t vni; /* VNI */ | |
76 | struct in_addr vtep_ip; /* Local tunnel IP */ | |
77 | vlanid_t access_vlan; /* Access VLAN - for VLAN-aware bridge. */ | |
3d434f5c | 78 | struct in_addr mcast_grp; |
14ddb3d9 PG |
79 | ifindex_t ifindex_link; /* Interface index of interface |
80 | * linked with VXLAN | |
81 | */ | |
82 | ns_id_t link_nsid; | |
6675513d | 83 | }; |
84 | ||
b9368db9 DD |
85 | struct zebra_l2info_bondslave { |
86 | ifindex_t bond_ifindex; /* Bridge Master */ | |
87 | struct interface *bond_if; /* Pointer to master */ | |
88 | }; | |
89 | ||
d62a17ae | 90 | union zebra_l2if_info { |
91 | struct zebra_l2info_bridge br; | |
92 | struct zebra_l2info_vlan vl; | |
93 | struct zebra_l2info_vxlan vxl; | |
077c07cc | 94 | struct zebra_l2info_gre gre; |
6675513d | 95 | }; |
96 | ||
97 | /* NOTE: These macros are to be invoked only in the "correct" context. | |
98 | * IOW, the macro VNI_FROM_ZEBRA_IF() will assume the interface is | |
99 | * of type ZEBRA_IF_VXLAN. | |
100 | */ | |
101 | #define VNI_FROM_ZEBRA_IF(zif) (zif)->l2info.vxl.vni | |
102 | #define VLAN_ID_FROM_ZEBRA_IF(zif) (zif)->l2info.vl.vid | |
103 | ||
d62a17ae | 104 | #define IS_ZEBRA_IF_BRIDGE_VLAN_AWARE(zif) ((zif)->l2info.br.vlan_aware == 1) |
6675513d | 105 | |
9771da71 PG |
106 | extern void zebra_l2_map_slave_to_bridge(struct zebra_l2info_brslave *br_slave, |
107 | struct zebra_ns *zns); | |
d62a17ae | 108 | extern void |
109 | zebra_l2_unmap_slave_from_bridge(struct zebra_l2info_brslave *br_slave); | |
110 | extern void zebra_l2_bridge_add_update(struct interface *ifp, | |
111 | struct zebra_l2info_bridge *bridge_info, | |
112 | int add); | |
113 | extern void zebra_l2_bridge_del(struct interface *ifp); | |
114 | extern void zebra_l2_vlanif_update(struct interface *ifp, | |
115 | struct zebra_l2info_vlan *vlan_info); | |
077c07cc PG |
116 | extern void zebra_l2_greif_add_update(struct interface *ifp, |
117 | struct zebra_l2info_gre *vxlan_info, | |
118 | int add); | |
d62a17ae | 119 | extern void zebra_l2_vxlanif_add_update(struct interface *ifp, |
120 | struct zebra_l2info_vxlan *vxlan_info, | |
121 | int add); | |
122 | extern void zebra_l2_vxlanif_update_access_vlan(struct interface *ifp, | |
123 | vlanid_t access_vlan); | |
077c07cc | 124 | extern void zebra_l2_greif_del(struct interface *ifp); |
d62a17ae | 125 | extern void zebra_l2_vxlanif_del(struct interface *ifp); |
126 | extern void zebra_l2if_update_bridge_slave(struct interface *ifp, | |
a6e0edf2 | 127 | ifindex_t bridge_ifindex, |
c7620108 | 128 | ns_id_t ns_id, uint8_t chgflags); |
6675513d | 129 | |
b9368db9 | 130 | extern void zebra_l2if_update_bond_slave(struct interface *ifp, |
00a7710c | 131 | ifindex_t bond_ifindex, bool bypass); |
ce5160c0 AK |
132 | extern void zebra_vlan_bitmap_compute(struct interface *ifp, |
133 | uint32_t vid_start, uint16_t vid_end); | |
134 | extern void zebra_vlan_mbr_re_eval(struct interface *ifp, | |
135 | bitfield_t vlan_bitmap); | |
c36e442c | 136 | extern void zebra_l2if_update_bond(struct interface *ifp, bool add); |
c7620108 | 137 | extern void zebra_l2if_update_bridge(struct interface *ifp, uint8_t chgflags); |
51e94aa7 EDP |
138 | |
139 | #ifdef __cplusplus | |
140 | } | |
141 | #endif | |
142 | ||
6675513d | 143 | #endif /* _ZEBRA_L2_H */ |