]> git.proxmox.com Git - mirror_frr.git/blob - zebra/zebra_vxlan_private.h
zebra: rib: use nexthop ptr in rib_add/delete
[mirror_frr.git] / zebra / zebra_vxlan_private.h
1 /*
2 * Zebra VxLAN (EVPN) Data structures and definitions
3 * These are "internal" to this function.
4 * Copyright (C) 2016, 2017 Cumulus Networks, Inc.
5 *
6 * This file is part of FRR.
7 *
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
11 * later version.
12 *
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.
17 *
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
21 * 02111-1307, USA.
22 */
23
24 #ifndef _ZEBRA_VXLAN_PRIVATE_H
25 #define _ZEBRA_VXLAN_PRIVATE_H
26
27 #include <zebra.h>
28
29 #include <zebra.h>
30
31 #include "if.h"
32 #include "linklist.h"
33
34 /* definitions */
35 typedef struct zebra_vni_t_ zebra_vni_t;
36 typedef struct zebra_vtep_t_ zebra_vtep_t;
37 typedef struct zebra_mac_t_ zebra_mac_t;
38 typedef struct zebra_neigh_t_ zebra_neigh_t;
39
40 /*
41 * VTEP info
42 *
43 * Right now, this just has each remote VTEP's IP address.
44 */
45 struct zebra_vtep_t_ {
46 /* Remote IP. */
47 /* NOTE: Can only be IPv4 right now. */
48 struct in_addr vtep_ip;
49
50 /* Links. */
51 struct zebra_vtep_t_ *next;
52 struct zebra_vtep_t_ *prev;
53 };
54
55
56 /*
57 * VNI hash table
58 *
59 * Contains information pertaining to a VNI:
60 * - the list of remote VTEPs (with this VNI)
61 */
62 struct zebra_vni_t_ {
63 /* VNI - key */
64 vni_t vni;
65
66 /* Flag for advertising gw macip */
67 u_int8_t advertise_gw_macip;
68
69 /* Corresponding VxLAN interface. */
70 struct interface *vxlan_if;
71
72 /* List of remote VTEPs */
73 zebra_vtep_t *vteps;
74
75 /* Local IP */
76 struct in_addr local_vtep_ip;
77
78 /* List of local or remote MAC */
79 struct hash *mac_table;
80
81 /* List of local or remote neighbors (MAC+IP) */
82 struct hash *neigh_table;
83 };
84
85 /*
86 * MAC hash table.
87 *
88 * This table contains the MAC addresses pertaining to this VNI.
89 * This includes local MACs learnt on an attached VLAN that maps
90 * to this VNI as well as remote MACs learnt and installed by BGP.
91 * Local MACs will be known either on a VLAN sub-interface or
92 * on (port, VLAN); however, it is sufficient for zebra to maintain
93 * against the VNI i.e., it does not need to retain the local "port"
94 * information. The correct VNI will be obtained as zebra maintains
95 * the mapping (of VLAN to VNI).
96 */
97 struct zebra_mac_t_ {
98 /* MAC address. */
99 struct ethaddr macaddr;
100
101 u_int32_t flags;
102 #define ZEBRA_MAC_LOCAL 0x01
103 #define ZEBRA_MAC_REMOTE 0x02
104 #define ZEBRA_MAC_AUTO 0x04 /* Auto created for neighbor. */
105 #define ZEBRA_MAC_STICKY 0x08 /* Static MAC */
106
107 /* Local or remote info. */
108 union {
109 struct {
110 ifindex_t ifindex;
111 vlanid_t vid;
112 } local;
113
114 struct in_addr r_vtep_ip;
115 } fwd_info;
116
117 u_int32_t neigh_refcnt;
118
119 /* List of neigh associated with this mac */
120 struct list *neigh_list;
121 };
122
123 /*
124 * Context for MAC hash walk - used by callbacks.
125 */
126 struct mac_walk_ctx {
127 zebra_vni_t *zvni; /* VNI hash */
128 struct zebra_vrf *zvrf; /* VRF - for client notification. */
129 int uninstall; /* uninstall from kernel? */
130 int upd_client; /* uninstall from client? */
131
132 u_int32_t flags;
133 #define DEL_LOCAL_MAC 0x1
134 #define DEL_REMOTE_MAC 0x2
135 #define DEL_ALL_MAC (DEL_LOCAL_MAC | DEL_REMOTE_MAC)
136 #define DEL_REMOTE_MAC_FROM_VTEP 0x4
137 #define SHOW_REMOTE_MAC_FROM_VTEP 0x8
138
139 struct in_addr r_vtep_ip; /* To walk MACs from specific VTEP */
140
141 struct vty *vty; /* Used by VTY handlers */
142 u_int32_t count; /* Used by VTY handlers */
143 struct json_object *json; /* Used for JSON Output */
144 };
145
146 enum zebra_neigh_state { ZEBRA_NEIGH_INACTIVE = 0, ZEBRA_NEIGH_ACTIVE = 1 };
147
148 #define IS_ZEBRA_NEIGH_ACTIVE(n) n->state == ZEBRA_NEIGH_ACTIVE
149
150 #define IS_ZEBRA_NEIGH_INACTIVE(n) n->state == ZEBRA_NEIGH_INACTIVE
151
152 #define ZEBRA_NEIGH_SET_ACTIVE(n) n->state = ZEBRA_NEIGH_ACTIVE
153
154 #define ZEBRA_NEIGH_SET_INACTIVE(n) n->state = ZEBRA_NEIGH_INACTIVE
155
156 /*
157 * Neighbor hash table.
158 *
159 * This table contains the neighbors (IP to MAC bindings) pertaining to
160 * this VNI. This includes local neighbors learnt on the attached VLAN
161 * device that maps to this VNI as well as remote neighbors learnt and
162 * installed by BGP.
163 * Local neighbors will be known against the VLAN device (SVI); however,
164 * it is sufficient for zebra to maintain against the VNI. The correct
165 * VNI will be obtained as zebra maintains the mapping (of VLAN to VNI).
166 */
167 struct zebra_neigh_t_ {
168 /* IP address. */
169 struct ipaddr ip;
170
171 /* MAC address. */
172 struct ethaddr emac;
173
174 /* Underlying interface. */
175 ifindex_t ifindex;
176
177 u_int32_t flags;
178 #define ZEBRA_NEIGH_LOCAL 0x01
179 #define ZEBRA_NEIGH_REMOTE 0x02
180
181 enum zebra_neigh_state state;
182
183 /* Remote VTEP IP - applicable only for remote neighbors. */
184 struct in_addr r_vtep_ip;
185 };
186
187 /*
188 * Context for neighbor hash walk - used by callbacks.
189 */
190 struct neigh_walk_ctx {
191 zebra_vni_t *zvni; /* VNI hash */
192 struct zebra_vrf *zvrf; /* VRF - for client notification. */
193 int uninstall; /* uninstall from kernel? */
194 int upd_client; /* uninstall from client? */
195
196 u_int32_t flags;
197 #define DEL_LOCAL_NEIGH 0x1
198 #define DEL_REMOTE_NEIGH 0x2
199 #define DEL_ALL_NEIGH (DEL_LOCAL_NEIGH | DEL_REMOTE_NEIGH)
200 #define DEL_REMOTE_NEIGH_FROM_VTEP 0x4
201 #define SHOW_REMOTE_NEIGH_FROM_VTEP 0x8
202
203 struct in_addr r_vtep_ip; /* To walk neighbors from specific VTEP */
204
205 struct vty *vty; /* Used by VTY handlers */
206 u_int32_t count; /* Used by VTY handlers */
207 u_char addr_width; /* Used by VTY handlers */
208 struct json_object *json; /* Used for JSON Output */
209 };
210
211 #endif /* _ZEBRA_VXLAN_PRIVATE_H */