Print this page
Overlay fabric router
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/overlay_target.h
+++ new/usr/src/uts/common/sys/overlay_target.h
1 1 /*
2 2 * This file and its contents are supplied under the terms of the
3 3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 4 * You may only use this file in accordance with the terms of version
5 5 * 1.0 of the CDDL.
6 6 *
7 7 * A full copy of the text of the CDDL should have accompanied this
8 8 * source. A copy of the CDDL is also available via the Internet at
9 9 * http://www.illumos.org/license/CDDL.
10 10 */
11 11
12 12 /*
13 13 * Copyright (c) 2018 Joyent, Inc.
14 14 */
15 15
16 16 #ifndef _OVERLAY_TARGET_H
17 17 #define _OVERLAY_TARGET_H
18 18
19 19 /*
20 20 * Overlay device varpd ioctl interface (/dev/overlay)
21 21 */
22 22
23 23 #include <sys/types.h>
24 24 #include <sys/ethernet.h>
25 25 #include <netinet/in.h>
26 26 #include <sys/overlay_common.h>
27 27
28 28 #ifdef __cplusplus
29 29 extern "C" {
30 30 #endif
31 31
32 32 /*
33 33 * The overlay_target_point_t structure represents the destination where
34 34 * encapsulated frames are sent. Currently supported virtualization protocls
35 35 * (i.e. vxlan) only use otp_ip and otp_port, but other methods might use
36 36 * a L2 address instead of an L3 address to represent a destination.
37 37 */
38 38 typedef struct overlay_target_point {
39 39 uint8_t otp_mac[ETHERADDRL];
40 40 struct in6_addr otp_ip;
41 41 uint16_t otp_port;
42 42 } overlay_target_point_t;
43 43
44 44 /*
45 45 * The overlay_target_route_t represents the information necessary to send
46 46 * packets to remote (routed) destinations. Note: we currently only include
47 47 * the L3 address prefix lengths since overlay can deduce the subnet address
48 48 * from the original VL3 IP in the request + the prefix length in the reply.
49 49 */
50 50 typedef struct overlay_target_route {
51 51 uint64_t otr_vnet;
52 52 uint16_t otr_vlan;
53 53 uint8_t otr_srcmac[ETHERADDRL];
54 54 uint32_t otr_dcid;
55 55 uint8_t otr_src_prefixlen;
56 56 uint8_t otr_dst_prefixlen;
57 57 } overlay_target_route_t;
58 58
59 59 #define OVERLAY_TARG_IOCTL (('o' << 24) | ('v' << 16) | ('t' << 8))
60 60
61 61 #define OVERLAY_TARG_INFO (OVERLAY_TARG_IOCTL | 0x01)
62 62
63 63 typedef enum overlay_targ_info_flags {
64 64 OVERLAY_TARG_INFO_F_ACTIVE = 0x01,
65 65 OVERLAY_TARG_INFO_F_DEGRADED = 0x02
66 66 } overlay_targ_info_flags_t;
67 67
68 68 /*
69 69 * Get target information about an overlay device
70 70 */
71 71 typedef struct overlay_targ_info {
72 72 datalink_id_t oti_linkid;
73 73 uint32_t oti_needs;
74 74 uint64_t oti_flags;
75 75 uint64_t oti_vnetid;
76 76 uint32_t oti_dcid;
77 77 } overlay_targ_info_t;
78 78
79 79 /*
80 80 * Declare an association between a given varpd instance and a datalink.
81 81 */
82 82 #define OVERLAY_TARG_ASSOCIATE (OVERLAY_TARG_IOCTL | 0x02)
83 83
84 84 typedef struct overlay_targ_associate {
85 85 datalink_id_t ota_linkid;
86 86 uint32_t ota_mode;
87 87 uint64_t ota_id;
88 88 uint32_t ota_provides;
89 89 overlay_target_point_t ota_point;
90 90 } overlay_targ_associate_t;
91 91
92 92 /*
93 93 * Remove an association from a device. If the device has already been started,
94 94 * this implies OVERLAY_TARG_DEGRADE.
95 95 */
96 96 #define OVERLAY_TARG_DISASSOCIATE (OVERLAY_TARG_IOCTL | 0x3)
97 97
98 98 /*
99 99 * Tells the kernel that while a varpd instance still exists, it basically isn't
100 100 * making any forward progress, so the device should consider itself degraded.
101 101 */
102 102 #define OVERLAY_TARG_DEGRADE (OVERLAY_TARG_IOCTL | 0x4)
103 103
104 104 typedef struct overlay_targ_degrade {
105 105 datalink_id_t otd_linkid;
106 106 uint32_t otd_pad;
107 107 char otd_buf[OVERLAY_STATUS_BUFLEN];
108 108 } overlay_targ_degrade_t;
109 109
110 110 /*
111 111 * Tells the kernel to remove the degraded status that it set on a device.
112 112 */
113 113 #define OVERLAY_TARG_RESTORE (OVERLAY_TARG_IOCTL | 0x5)
114 114
115 115 typedef struct overlay_targ_id {
116 116 datalink_id_t otid_linkid;
117 117 } overlay_targ_id_t;
118 118
119 119 /*
120 120 * The following ioctls are all used to support dynamic lookups from userland,
121 121 * generally serviced by varpd.
122 122 *
123 123 * The way this is designed to work is that user land will have threads sitting
124 124 * in OVERLAY_TARG_LOOKUP ioctls waiting to service requests. A thread will sit
125 125 * waiting for work for up to approximately one second of time before they will
126 126 * be sent back out to user land to give user land a chance to clean itself up
127 127 * or more generally, come back into the kernel for work. Once these threads
128 128 * return, they will have a request with which more action can be done. The
129 129 * following ioctls can all be used to answer the request.
130 130 *
131 131 * OVERLAY_TARG_RESPOND - overlay_targ_resp_t
132 132 *
133 133 * The overlay_targ_resp_t has the appropriate information from
134 134 * which a reply can be generated. The information is filled into
135 135 * an overlay_targ_point_t as appropriate based on the
136 136 * overlay_plugin_dest_t type.
137 137 *
138 138 *
139 139 * OVERLAY_TARG_DROP - overlay_targ_resp_t
140 140 *
141 141 * The overlay_targ_resp_t should identify a request for which to
142 142 * drop a packet.
143 143 *
144 144 *
145 145 * OVERLAY_TARG_INJECT - overlay_targ_pkt_t
146 146 *
147 147 * The overlay_targ_pkt_t injects a fully formed packet into the
148 148 * virtual network. It may either be identified by its data link id
149 149 * or by the request id. If both are specified, the
150 150 * datalink id will be used. Note, that an injection is not
151 151 * considered a reply and if this corresponds to a requeset, then
152 152 * that individual packet must still be dropped.
153 153 *
154 154 *
155 155 * OVERLAY_TARG_PKT - overlay_targ_pkt_t
156 156 *
157 157 * This ioctl can be used to copy data from a given request into a
158 158 * user buffer. This can be used in combination with
159 159 * OVERLAY_TARG_INJECT to implement services such as a proxy-arp.
160 160 *
161 161 *
162 162 * OVERLAY_TARG_RESEND - overlay_targ_pkt_t
163 163 *
164 164 * This ioctl is similar to the OVERLAY_TARG_INJECT, except instead
165 165 * of receiving it on the local mac handle, it queues it for
166 166 * retransmission again. This is useful if you have a packet that
167 167 * was originally destined for some broadcast or multicast address
168 168 * that you now want to send to a unicast address.
169 169 */
170 170 #define OVERLAY_TARG_LOOKUP (OVERLAY_TARG_IOCTL | 0x10)
171 171 #define OVERLAY_TARG_RESPOND (OVERLAY_TARG_IOCTL | 0x11)
172 172 #define OVERLAY_TARG_DROP (OVERLAY_TARG_IOCTL | 0x12)
173 173 #define OVERLAY_TARG_INJECT (OVERLAY_TARG_IOCTL | 0x13)
174 174 #define OVERLAY_TARG_PKT (OVERLAY_TARG_IOCTL | 0x14)
175 175 #define OVERLAY_TARG_RESEND (OVERLAY_TARG_IOCTL | 0x15)
176 176
177 177 typedef struct overlay_targ_l2 {
178 178 uint8_t otl2_srcaddr[ETHERADDRL];
179 179 uint8_t otl2_dstaddr[ETHERADDRL];
180 180 uint32_t otl2_dsttype;
181 181 uint32_t otl2_sap;
182 182 } overlay_targ_l2_t;
183 183
184 184 typedef struct overlay_targ_l3 {
185 185 struct in6_addr otl3_srcip;
186 186 struct in6_addr otl3_dstip;
187 187 } overlay_targ_l3_t;
188 188
189 189 typedef struct overlay_targ_lookup {
190 190 uint64_t otl_dlid;
191 191 uint64_t otl_reqid;
192 192 uint64_t otl_varpdid;
193 193 uint64_t otl_vnetid;
194 194 uint64_t otl_hdrsize;
195 195 uint64_t otl_pktsize;
196 196 union {
197 197 overlay_targ_l2_t otlu_l2;
198 198 overlay_targ_l3_t otlu_l3;
199 199 } otl_addru;
200 200 int32_t otl_vlan;
201 201 boolean_t otl_l3req;
202 202 } overlay_targ_lookup_t;
203 203
204 204
205 205 typedef struct overlay_targ_resp {
206 206 uint64_t otr_reqid;
207 207 overlay_target_point_t otr_answer;
208 208 overlay_target_route_t otr_route; /* Ignored for VL2->UL3 requests */
209 209 } overlay_targ_resp_t;
210 210
211 211 typedef struct overlay_targ_pkt {
212 212 uint64_t otp_linkid;
213 213 uint64_t otp_reqid;
214 214 uint64_t otp_size;
215 215 void *otp_buf;
216 216 } overlay_targ_pkt_t;
217 217
218 218 #ifdef _KERNEL
219 219
220 220 typedef struct overlay_targ_pkt32 {
221 221 uint64_t otp_linkid;
222 222 uint64_t otp_reqid;
223 223 uint64_t otp_size;
224 224 caddr32_t otp_buf;
225 225 } overlay_targ_pkt32_t;
226 226
227 227 #endif /* _KERNEL */
228 228
229 229 /*
230 230 * This provides a way to get a list of active overlay devices independently
231 231 * from dlmgmtd. At the end of the day the kernel always knows what will exist
232 232 * and this allows varpd which is an implementation of libdladm not to end up
233 233 * needing to call back into dlmgmtd via libdladm and create an unfortunate
234 234 * dependency cycle.
235 235 */
236 236
237 237 #define OVERLAY_TARG_LIST (OVERLAY_TARG_IOCTL | 0x20)
238 238
239 239 typedef struct overlay_targ_list {
240 240 uint32_t otl_nents;
241 241 uint32_t otl_ents[];
242 242 } overlay_targ_list_t;
243 243
244 244 /*
245 245 * The following family of ioctls all manipulate the target cache of a given
246 246 * device.
247 247 *
248 248 * OVERLAY_TARG_CACHE_GET - overlay_targ_cache_t
249 249 *
250 250 * The overlay_targ_cache_t should be have its link identifier and
251 251 * the desired mac address filled in. On return, it will fill in
252 252 * the otc_dest member, if the entry exists in the table.
253 253 *
254 254 *
255 255 * OVERLAY_TARG_CACHE_SET - overlay_targ_cache_t
256 256 *
257 257 * The cache table entry of the mac address referred to by otc_mac
258 258 * and otd_linkid will be filled in with the details provided by in
259 259 * the otc_dest member.
260 260 *
261 261 * OVERLAY_TARG_CACHE_REMOVE - overlay_targ_cache_t
262 262 *
263 263 * Removes the cache entry identified by otc_mac from the table.
264 264 * Note that this does not stop any in-flight lookups or deal with
265 265 * any data that is awaiting a lookup.
266 266 *
267 267 *
268 268 * OVERLAY_TARG_CACHE_FLUSH - overlay_targ_cache_t
269 269 *
270 270 * Similar to OVERLAY_TARG_CACHE_REMOVE, but functions on the
271 271 * entire table identified by otc_linkid. All other parameters are
272 272 * ignored.
273 273 *
274 274 *
275 275 * OVERLAY_TARG_CACHE_ITER - overlay_targ_cache_iter_t
276 276 *
277 277 * Iterates over the contents of a target cache identified by
278 278 * otci_linkid. Iteration is guaranteed to be exactly once for
279 279 * items which are in the hashtable at the beginning and end of
280 280 * iteration. For items which are added or removed after iteration
281 281 * has begun, only at most once semantics are guaranteed. Consumers
282 282 * should ensure that otci_marker is zeroed before starting
283 283 * iteration and should preserve its contents across calls.
284 284 *
285 285 * Before calling in, otci_count should be set to the number of
286 286 * entries that space has been allocated for in otci_ents. The
287 287 * value will be updated to indicate the total number written out.
288 288 */
289 289
290 290 #define OVERLAY_TARG_CACHE_GET (OVERLAY_TARG_IOCTL | 0x30)
291 291 #define OVERLAY_TARG_CACHE_SET (OVERLAY_TARG_IOCTL | 0x31)
292 292 #define OVERLAY_TARG_CACHE_REMOVE (OVERLAY_TARG_IOCTL | 0x32)
293 293 #define OVERLAY_TARG_CACHE_FLUSH (OVERLAY_TARG_IOCTL | 0x33)
294 294 #define OVERLAY_TARG_CACHE_ITER (OVERLAY_TARG_IOCTL | 0x34)
|
↓ open down ↓ |
294 lines elided |
↑ open up ↑ |
295 295
296 296 /*
297 297 * This is a pretty arbitrary number that we're constraining ourselves to
298 298 * for iteration. Basically the goal is to make sure that we can't have a user
299 299 * ask us to allocate too much memory on their behalf at any time. A more
300 300 * dynamic form may be necessary some day.
301 301 */
302 302 #define OVERLAY_TARGET_ITER_MAX 500
303 303
304 304 #define OVERLAY_TARGET_CACHE_DROP 0x01
305 +#define OVERLAY_TARGET_CACHE_ROUTER 0x02
305 306
306 307 typedef struct overlay_targ_cache_entry {
307 308 uint8_t otce_mac[ETHERADDRL];
308 309 uint16_t otce_flags;
309 310 uint32_t otce_dcid;
310 311 overlay_target_point_t otce_dest;
311 312 } overlay_targ_cache_entry_t;
312 313
313 314 typedef struct overlay_targ_cache {
314 315 datalink_id_t otc_linkid;
315 316 overlay_targ_cache_entry_t otc_entry;
316 317 } overlay_targ_cache_t;
317 318
318 319 typedef struct overlay_targ_cache_iter {
319 320 datalink_id_t otci_linkid;
320 321 uint32_t otci_pad;
321 322 uint64_t otci_marker;
322 323 uint16_t otci_count;
323 324 overlay_targ_cache_entry_t otci_ents[];
324 325 } overlay_targ_cache_iter_t;
325 326
326 327 #ifdef __cplusplus
327 328 }
328 329 #endif
329 330
330 331 #endif /* _OVERLAY_TARGET_H */
|
↓ open down ↓ |
16 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX