]> git.proxmox.com Git - mirror_frr.git/blame - zebra/zebra_l2.h
Merge pull request #13458 from sri-mohan1/srib-ldpd
[mirror_frr.git] / zebra / zebra_l2.h
CommitLineData
acddc0ed 1// SPDX-License-Identifier: GPL-2.0-or-later
6675513d 2/*
3 * Zebra Layer-2 interface Data structures and definitions
4 * Copyright (C) 2016, 2017 Cumulus Networks, Inc.
6675513d 5 */
6
7#ifndef _ZEBRA_L2_H
8#define _ZEBRA_L2_H
9
10#include <zebra.h>
11
12#include "if.h"
13#include "vlan.h"
14#include "vxlan.h"
7ca9c407 15#include "zebra/zebra_vrf.h"
6675513d 16
51e94aa7
EDP
17#ifdef __cplusplus
18extern "C" {
19#endif
20
c7620108
PG
21#define ZEBRA_BRIDGE_NO_ACTION (0)
22#define ZEBRA_BRIDGE_MASTER_MAC_CHANGE (1 << 1)
f56a15b5 23#define ZEBRA_BRIDGE_MASTER_UP (1 << 2)
c7620108 24
6675513d 25/* zebra L2 interface information - bridge slave (linkage to bridge) */
d62a17ae 26struct zebra_l2info_brslave {
27 ifindex_t bridge_ifindex; /* Bridge Master */
28 struct interface *br_if; /* Pointer to master */
a6e0edf2 29 ns_id_t ns_id; /* network namespace where bridge is */
6675513d 30};
31
c36e442c
AK
32struct zebra_l2info_bond {
33 struct list *mbr_zifs; /* slaves using this bond as a master */
34};
35
784d88aa
SR
36struct zebra_l2_bridge_vlan {
37 vlanid_t vid;
38 struct zebra_evpn_access_bd *access_bd;
39};
40
41struct zebra_l2_bridge_if_ctx {
42 /* input */
43 struct zebra_if *zif;
9464e5b8
SR
44 int (*func)(struct zebra_if *zif, struct zebra_l2_bridge_vlan *vlan,
45 void *arg);
784d88aa
SR
46
47 /* input-output */
48 void *arg;
49};
50
51struct zebra_l2_bridge_if {
52 uint8_t vlan_aware;
53 struct zebra_if *br_zif;
54 struct hash *vlan_table;
55};
56
6675513d 57/* zebra L2 interface information - bridge interface */
d62a17ae 58struct zebra_l2info_bridge {
784d88aa 59 struct zebra_l2_bridge_if bridge;
6675513d 60};
61
62/* zebra L2 interface information - VLAN interface */
d62a17ae 63struct zebra_l2info_vlan {
64 vlanid_t vid; /* VLAN id */
6675513d 65};
66
077c07cc
PG
67/* zebra L2 interface information - GRE interface */
68struct zebra_l2info_gre {
69 struct in_addr vtep_ip; /* IFLA_GRE_LOCAL */
70 struct in_addr vtep_ip_remote; /* IFLA_GRE_REMOTE */
71 uint32_t ikey;
72 uint32_t okey;
73 ifindex_t ifindex_link; /* Interface index of interface
74 * linked with GRE
75 */
76 ns_id_t link_nsid;
77};
78
8d30ff3b 79struct zebra_vxlan_vni {
0bbad9d1 80 vni_t vni; /* VNI */
8d30ff3b
SR
81 vlanid_t access_vlan; /* Access VLAN - for VLAN-aware bridge. */
82 struct in_addr mcast_grp;
83};
84
9464e5b8 85enum {
8d30ff3b 86 ZEBRA_VXLAN_IF_VNI = 0, /* per vni vxlan if */
0bbad9d1 87 ZEBRA_VXLAN_IF_SVD /* single vxlan device */
9464e5b8 88};
8d30ff3b
SR
89
90struct zebra_vxlan_if_vlan_ctx {
91 vlanid_t vid;
92 struct zebra_vxlan_vni *vni;
93};
94
00d30205 95struct zebra_vxlan_if_update_ctx {
96 uint16_t chgflags;
97 struct in_addr old_vtep_ip;
98 struct zebra_vxlan_vni old_vni;
99 struct hash *old_vni_table;
100};
101
8d30ff3b
SR
102struct zebra_vxlan_if_ctx {
103 /* input */
104 struct zebra_if *zif;
9464e5b8
SR
105 int (*func)(struct zebra_if *zif, struct zebra_vxlan_vni *vni,
106 void *arg);
8d30ff3b
SR
107
108 /* input-output */
109 void *arg;
110};
111
112struct zebra_vxlan_vni_info {
9464e5b8 113 int iftype;
8d30ff3b
SR
114 union {
115 struct zebra_vxlan_vni vni; /* per vni vxlan device vni info */
116 struct hash
117 *vni_table; /* table of vni's assocated with this if */
118 };
119};
120
6675513d 121/* zebra L2 interface information - VXLAN interface */
d62a17ae 122struct zebra_l2info_vxlan {
8d30ff3b 123 struct zebra_vxlan_vni_info vni_info;
d62a17ae 124 struct in_addr vtep_ip; /* Local tunnel IP */
14ddb3d9
PG
125 ifindex_t ifindex_link; /* Interface index of interface
126 * linked with VXLAN
127 */
128 ns_id_t link_nsid;
6675513d 129};
130
b9368db9
DD
131struct zebra_l2info_bondslave {
132 ifindex_t bond_ifindex; /* Bridge Master */
133 struct interface *bond_if; /* Pointer to master */
134};
135
d62a17ae 136union zebra_l2if_info {
137 struct zebra_l2info_bridge br;
138 struct zebra_l2info_vlan vl;
139 struct zebra_l2info_vxlan vxl;
077c07cc 140 struct zebra_l2info_gre gre;
6675513d 141};
142
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.
146 */
8d30ff3b
SR
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)
6675513d 152#define VLAN_ID_FROM_ZEBRA_IF(zif) (zif)->l2info.vl.vid
153
784d88aa
SR
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)
6675513d 157
9771da71
PG
158extern void zebra_l2_map_slave_to_bridge(struct zebra_l2info_brslave *br_slave,
159 struct zebra_ns *zns);
d62a17ae 160extern void
161zebra_l2_unmap_slave_from_bridge(struct zebra_l2info_brslave *br_slave);
162extern void zebra_l2_bridge_add_update(struct interface *ifp,
163 struct zebra_l2info_bridge *bridge_info,
164 int add);
165extern void zebra_l2_bridge_del(struct interface *ifp);
166extern void zebra_l2_vlanif_update(struct interface *ifp,
167 struct zebra_l2info_vlan *vlan_info);
077c07cc
PG
168extern void zebra_l2_greif_add_update(struct interface *ifp,
169 struct zebra_l2info_gre *vxlan_info,
170 int add);
d62a17ae 171extern void zebra_l2_vxlanif_add_update(struct interface *ifp,
172 struct zebra_l2info_vxlan *vxlan_info,
173 int add);
174extern void zebra_l2_vxlanif_update_access_vlan(struct interface *ifp,
175 vlanid_t access_vlan);
077c07cc 176extern void zebra_l2_greif_del(struct interface *ifp);
d62a17ae 177extern void zebra_l2_vxlanif_del(struct interface *ifp);
178extern void zebra_l2if_update_bridge_slave(struct interface *ifp,
a6e0edf2 179 ifindex_t bridge_ifindex,
c7620108 180 ns_id_t ns_id, uint8_t chgflags);
6675513d 181
b9368db9 182extern void zebra_l2if_update_bond_slave(struct interface *ifp,
00a7710c 183 ifindex_t bond_ifindex, bool bypass);
ce5160c0
AK
184extern void zebra_vlan_bitmap_compute(struct interface *ifp,
185 uint32_t vid_start, uint16_t vid_end);
186extern void zebra_vlan_mbr_re_eval(struct interface *ifp,
187 bitfield_t vlan_bitmap);
c36e442c 188extern void zebra_l2if_update_bond(struct interface *ifp, bool add);
c7620108 189extern void zebra_l2if_update_bridge(struct interface *ifp, uint8_t chgflags);
51e94aa7
EDP
190
191#ifdef __cplusplus
192}
193#endif
194
6675513d 195#endif /* _ZEBRA_L2_H */