Print this page
10052 "dladm show-ether" should pick one kstat snapshot and stick with it
Reviewed by: Rob Johnston <rob.johnston@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Gergo Doma <domag02@gmail.com>
Reviewed by: Andy Fiddaman <andy@omniosce.org>
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/lib/libdladm/common/libdladm.c
+++ new/usr/src/lib/libdladm/common/libdladm.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
↓ open down ↓ |
14 lines elided |
↑ open up ↑ |
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21 /*
22 22 * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 */
24 24
25 +/*
26 + * Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
27 + */
28 +
25 29 #include <unistd.h>
26 30 #include <errno.h>
27 31 #include <ctype.h>
28 32 #include <fcntl.h>
29 33 #include <strings.h>
30 34 #include <dirent.h>
31 35 #include <stdlib.h>
32 36 #include <netinet/in.h>
33 37 #include <arpa/inet.h>
34 38 #include <sys/param.h>
35 39 #include <sys/stat.h>
36 40 #include <sys/dld.h>
37 41 #include <sys/dld_ioc.h>
38 42 #include <libdladm_impl.h>
39 43 #include <libintl.h>
40 44 #include <libdlpi.h>
41 45 #include <libdllink.h>
42 46
43 47 static char dladm_rootdir[MAXPATHLEN] = "/";
44 48
45 49 typedef struct media_type_desc {
46 50 uint32_t media_type;
47 51 #define MAX_MEDIA_TYPE_STRING 32
48 52 const char media_type_str[MAX_MEDIA_TYPE_STRING];
49 53 } media_type_t;
50 54
51 55 static media_type_t media_type_table[] = {
52 56 { DL_ETHER, "Ethernet" },
53 57 { DL_WIFI, "WiFi" },
54 58 { DL_IB, "Infiniband" },
55 59 { DL_IPV4, "IPv4Tunnel" },
56 60 { DL_IPV6, "IPv6Tunnel" },
57 61 { DL_6TO4, "6to4Tunnel" },
58 62 { DL_CSMACD, "CSMA/CD" },
59 63 { DL_TPB, "TokenBus" },
60 64 { DL_TPR, "TokenRing" },
61 65 { DL_METRO, "MetroNet" },
62 66 { DL_HDLC, "HDLC" },
63 67 { DL_CHAR, "SyncCharacter" },
64 68 { DL_CTCA, "CTCA" },
65 69 { DL_FDDI, "FDDI" },
66 70 { DL_FC, "FiberChannel" },
67 71 { DL_ATM, "ATM" },
68 72 { DL_IPATM, "ATM(ClassicIP)" },
69 73 { DL_X25, "X.25" },
70 74 { DL_IPX25, "X.25(ClassicIP)" },
71 75 { DL_ISDN, "ISDN" },
72 76 { DL_HIPPI, "HIPPI" },
73 77 { DL_100VG, "100BaseVGEthernet" },
74 78 { DL_100VGTPR, "100BaseVGTokenRing" },
75 79 { DL_ETH_CSMA, "IEEE802.3" },
76 80 { DL_100BT, "100BaseT" },
77 81 { DL_FRAME, "FrameRelay" },
78 82 { DL_MPFRAME, "MPFrameRelay" },
79 83 { DL_ASYNC, "AsyncCharacter" },
80 84 { DL_IPNET, "IPNET" },
81 85 { DL_OTHER, "Other" }
82 86 };
83 87 #define MEDIATYPECOUNT (sizeof (media_type_table) / sizeof (media_type_t))
84 88
85 89 typedef struct {
86 90 uint32_t lp_type;
87 91 char *lp_name;
88 92 } link_protect_t;
89 93
90 94 static link_protect_t link_protect_types[] = {
91 95 { MPT_MACNOSPOOF, "mac-nospoof" },
92 96 { MPT_RESTRICTED, "restricted" },
93 97 { MPT_IPNOSPOOF, "ip-nospoof" },
94 98 { MPT_DHCPNOSPOOF, "dhcp-nospoof" }
95 99 };
96 100 #define LPTYPES (sizeof (link_protect_types) / sizeof (link_protect_t))
97 101
98 102 dladm_status_t
99 103 dladm_open(dladm_handle_t *handle)
100 104 {
101 105 int dld_fd;
102 106
103 107 if (handle == NULL)
104 108 return (DLADM_STATUS_BADARG);
105 109
106 110 if ((dld_fd = open(DLD_CONTROL_DEV, O_RDWR)) < 0)
107 111 return (dladm_errno2status(errno));
108 112
109 113 /*
110 114 * Don't open DLMGMT_DOOR now. dlmgmtd(1M) is not able to
111 115 * open the door when the dladm handle is opened because the
112 116 * door hasn't been created yet at that time. Thus, we must
113 117 * open it on-demand in dladm_door_fd(). Move the open()
↓ open down ↓ |
79 lines elided |
↑ open up ↑ |
114 118 * to dladm_door_fd() for all cases.
115 119 */
116 120
117 121 if ((*handle = malloc(sizeof (struct dladm_handle))) == NULL) {
118 122 (void) close(dld_fd);
119 123 return (DLADM_STATUS_NOMEM);
120 124 }
121 125
122 126 (*handle)->dld_fd = dld_fd;
123 127 (*handle)->door_fd = -1;
128 + (*handle)->dld_kcp = NULL;
124 129
125 130 return (DLADM_STATUS_OK);
126 131 }
127 132
128 133 void
129 134 dladm_close(dladm_handle_t handle)
130 135 {
131 136 if (handle != NULL) {
132 137 (void) close(handle->dld_fd);
133 138 if (handle->door_fd != -1)
134 139 (void) close(handle->door_fd);
140 + if (handle->dld_kcp != NULL)
141 + (void) kstat_close(handle->dld_kcp);
135 142 free(handle);
136 143 }
137 144 }
138 145
139 146 int
140 147 dladm_dld_fd(dladm_handle_t handle)
141 148 {
142 149 return (handle->dld_fd);
143 150 }
144 151
152 +kstat_ctl_t *
153 +dladm_dld_kcp(dladm_handle_t handle)
154 +{
155 + if (handle->dld_kcp == NULL)
156 + handle->dld_kcp = kstat_open();
157 + return (handle->dld_kcp);
158 +}
159 +
145 160 /*
146 161 * If DLMGMT_DOOR hasn't been opened in the handle yet, open it.
147 162 */
148 163 dladm_status_t
149 164 dladm_door_fd(dladm_handle_t handle, int *door_fd)
150 165 {
151 166 int fd;
152 167
153 168 if (handle->door_fd == -1) {
154 169 if ((fd = open(DLMGMT_DOOR, O_RDONLY)) < 0)
155 170 return (dladm_errno2status(errno));
156 171 handle->door_fd = fd;
157 172 }
158 173 *door_fd = handle->door_fd;
159 174
160 175 return (DLADM_STATUS_OK);
161 176 }
162 177
163 178 const char *
164 179 dladm_status2str(dladm_status_t status, char *buf)
165 180 {
166 181 const char *s;
167 182
168 183 switch (status) {
169 184 case DLADM_STATUS_OK:
170 185 s = "ok";
171 186 break;
172 187 case DLADM_STATUS_BADARG:
173 188 s = "invalid argument";
174 189 break;
175 190 case DLADM_STATUS_FAILED:
176 191 s = "operation failed";
177 192 break;
178 193 case DLADM_STATUS_TOOSMALL:
179 194 s = "buffer size too small";
180 195 break;
181 196 case DLADM_STATUS_NOTSUP:
182 197 s = "operation not supported";
183 198 break;
184 199 case DLADM_STATUS_NOTFOUND:
185 200 s = "object not found";
186 201 break;
187 202 case DLADM_STATUS_BADVAL:
188 203 s = "invalid value";
189 204 break;
190 205 case DLADM_STATUS_NOMEM:
191 206 s = "insufficient memory";
192 207 break;
193 208 case DLADM_STATUS_EXIST:
194 209 s = "object already exists";
195 210 break;
196 211 case DLADM_STATUS_LINKINVAL:
197 212 s = "invalid link";
198 213 break;
199 214 case DLADM_STATUS_PROPRDONLY:
200 215 s = "read-only property";
201 216 break;
202 217 case DLADM_STATUS_BADVALCNT:
203 218 s = "invalid number of values";
204 219 break;
205 220 case DLADM_STATUS_DBNOTFOUND:
206 221 s = "database not found";
207 222 break;
208 223 case DLADM_STATUS_DENIED:
209 224 s = "permission denied";
210 225 break;
211 226 case DLADM_STATUS_IOERR:
212 227 s = "I/O error";
213 228 break;
214 229 case DLADM_STATUS_TEMPONLY:
215 230 s = "change cannot be persistent";
216 231 break;
217 232 case DLADM_STATUS_TIMEDOUT:
218 233 s = "operation timed out";
219 234 break;
220 235 case DLADM_STATUS_ISCONN:
221 236 s = "already connected";
222 237 break;
223 238 case DLADM_STATUS_NOTCONN:
224 239 s = "not connected";
225 240 break;
226 241 case DLADM_STATUS_REPOSITORYINVAL:
227 242 s = "invalid configuration repository";
228 243 break;
229 244 case DLADM_STATUS_MACADDRINVAL:
230 245 s = "invalid MAC address";
231 246 break;
232 247 case DLADM_STATUS_KEYINVAL:
233 248 s = "invalid key";
234 249 break;
235 250 case DLADM_STATUS_INVALIDMACADDRLEN:
236 251 s = "invalid MAC address length";
237 252 break;
238 253 case DLADM_STATUS_INVALIDMACADDRTYPE:
239 254 s = "invalid MAC address type";
240 255 break;
241 256 case DLADM_STATUS_LINKBUSY:
242 257 s = "link busy";
243 258 break;
244 259 case DLADM_STATUS_VIDINVAL:
245 260 s = "invalid VLAN identifier";
246 261 break;
247 262 case DLADM_STATUS_TRYAGAIN:
248 263 s = "try again later";
249 264 break;
250 265 case DLADM_STATUS_NONOTIF:
251 266 s = "link notification is not supported";
252 267 break;
253 268 case DLADM_STATUS_BADTIMEVAL:
254 269 s = "invalid time range";
255 270 break;
256 271 case DLADM_STATUS_INVALIDMACADDR:
257 272 s = "invalid MAC address value";
258 273 break;
259 274 case DLADM_STATUS_INVALIDMACADDRNIC:
260 275 s = "MAC address reserved for use by underlying data-link";
261 276 break;
262 277 case DLADM_STATUS_INVALIDMACADDRINUSE:
263 278 s = "MAC address is already in use";
264 279 break;
265 280 case DLADM_STATUS_MACFACTORYSLOTINVALID:
266 281 s = "invalid factory MAC address slot";
267 282 break;
268 283 case DLADM_STATUS_MACFACTORYSLOTUSED:
269 284 s = "factory MAC address slot already used";
270 285 break;
271 286 case DLADM_STATUS_MACFACTORYSLOTALLUSED:
272 287 s = "all factory MAC address slots are in use";
273 288 break;
274 289 case DLADM_STATUS_MACFACTORYNOTSUP:
275 290 s = "factory MAC address slots not supported";
276 291 break;
277 292 case DLADM_STATUS_INVALIDMACPREFIX:
278 293 s = "Invalid MAC address prefix value";
279 294 break;
280 295 case DLADM_STATUS_INVALIDMACPREFIXLEN:
281 296 s = "Invalid MAC address prefix length";
282 297 break;
283 298 case DLADM_STATUS_BADCPUID:
284 299 s = "non-existent processor ID";
285 300 break;
286 301 case DLADM_STATUS_CPUERR:
287 302 s = "could not determine processor status";
288 303 break;
289 304 case DLADM_STATUS_CPUNOTONLINE:
290 305 s = "processor not online";
291 306 break;
292 307 case DLADM_STATUS_TOOMANYELEMENTS:
293 308 s = "too many elements specified";
294 309 break;
295 310 case DLADM_STATUS_BADRANGE:
296 311 s = "invalid range";
297 312 break;
298 313 case DLADM_STATUS_DB_NOTFOUND:
299 314 s = "database not found";
300 315 break;
301 316 case DLADM_STATUS_DB_PARSE_ERR:
302 317 s = "database parse error";
303 318 break;
304 319 case DLADM_STATUS_PROP_PARSE_ERR:
305 320 s = "property parse error";
306 321 break;
307 322 case DLADM_STATUS_ATTR_PARSE_ERR:
308 323 s = "attribute parse error";
309 324 break;
310 325 case DLADM_STATUS_FLOW_DB_ERR:
311 326 s = "flow database error";
312 327 break;
313 328 case DLADM_STATUS_FLOW_DB_OPEN_ERR:
314 329 s = "flow database open error";
315 330 break;
316 331 case DLADM_STATUS_FLOW_DB_PARSE_ERR:
317 332 s = "flow database parse error";
318 333 break;
319 334 case DLADM_STATUS_FLOWPROP_DB_PARSE_ERR:
320 335 s = "flow property database parse error";
321 336 break;
322 337 case DLADM_STATUS_FLOW_ADD_ERR:
323 338 s = "flow add error";
324 339 break;
325 340 case DLADM_STATUS_FLOW_WALK_ERR:
326 341 s = "flow walk error";
327 342 break;
328 343 case DLADM_STATUS_FLOW_IDENTICAL:
329 344 s = "a flow with identical attributes exists";
330 345 break;
331 346 case DLADM_STATUS_FLOW_INCOMPATIBLE:
332 347 s = "flow(s) with incompatible attributes exists";
333 348 break;
334 349 case DLADM_STATUS_FLOW_EXISTS:
335 350 s = "link still has flows";
336 351 break;
337 352 case DLADM_STATUS_PERSIST_FLOW_EXISTS:
338 353 s = "persistent flow with the same name exists";
339 354 break;
340 355 case DLADM_STATUS_INVALID_IP:
341 356 s = "invalid IP address";
342 357 break;
343 358 case DLADM_STATUS_INVALID_PREFIXLEN:
344 359 s = "invalid IP prefix length";
345 360 break;
346 361 case DLADM_STATUS_INVALID_PROTOCOL:
347 362 s = "invalid IP protocol";
348 363 break;
349 364 case DLADM_STATUS_INVALID_PORT:
350 365 s = "invalid port number";
351 366 break;
352 367 case DLADM_STATUS_INVALID_DSF:
353 368 s = "invalid dsfield";
354 369 break;
355 370 case DLADM_STATUS_INVALID_DSFMASK:
356 371 s = "invalid dsfield mask";
357 372 break;
358 373 case DLADM_STATUS_INVALID_MACMARGIN:
359 374 s = "MTU check failed, use lower MTU or -f option";
360 375 break;
361 376 case DLADM_STATUS_BADPROP:
362 377 s = "invalid property";
363 378 break;
364 379 case DLADM_STATUS_MINMAXBW:
365 380 s = "minimum value for maxbw is 1200K";
366 381 break;
367 382 case DLADM_STATUS_NO_HWRINGS:
368 383 s = "request hw rings failed";
369 384 break;
370 385 case DLADM_STATUS_PERMONLY:
371 386 s = "change must be persistent";
372 387 break;
373 388 case DLADM_STATUS_OPTMISSING:
374 389 s = "optional software not installed";
375 390 break;
376 391 case DLADM_STATUS_IPTUNTYPE:
377 392 s = "invalid IP tunnel type";
378 393 break;
379 394 case DLADM_STATUS_IPTUNTYPEREQD:
380 395 s = "IP tunnel type required";
381 396 break;
382 397 case DLADM_STATUS_BADIPTUNLADDR:
383 398 s = "invalid local IP tunnel address";
384 399 break;
385 400 case DLADM_STATUS_BADIPTUNRADDR:
386 401 s = "invalid remote IP tunnel address";
387 402 break;
388 403 case DLADM_STATUS_ADDRINUSE:
389 404 s = "address already in use";
390 405 break;
391 406 case DLADM_STATUS_POOLCPU:
392 407 s = "pool and cpus property are mutually exclusive";
393 408 break;
394 409 case DLADM_STATUS_INVALID_PORT_INSTANCE:
395 410 s = "invalid IB phys link";
396 411 break;
397 412 case DLADM_STATUS_PORT_IS_DOWN:
398 413 s = "port is down";
399 414 break;
400 415 case DLADM_STATUS_PARTITION_EXISTS:
401 416 s = "partition already exists";
402 417 break;
403 418 case DLADM_STATUS_PKEY_NOT_PRESENT:
404 419 s = "PKEY is not present on the port";
405 420 break;
406 421 case DLADM_STATUS_INVALID_PKEY:
407 422 s = "invalid PKEY";
408 423 break;
409 424 case DLADM_STATUS_NO_IB_HW_RESOURCE:
410 425 s = "IB internal resource not available";
411 426 break;
412 427 case DLADM_STATUS_INVALID_PKEY_TBL_SIZE:
413 428 s = "invalid PKEY table size";
414 429 break;
415 430 case DLADM_STATUS_PORT_NOPROTO:
416 431 s = "local or remote port requires transport";
417 432 break;
418 433 case DLADM_STATUS_INVALID_MTU:
419 434 s = "MTU check failed, MTU outside of device's supported range";
420 435 break;
421 436 default:
422 437 s = "<unknown error>";
423 438 break;
424 439 }
425 440 (void) snprintf(buf, DLADM_STRSIZE, "%s", dgettext(TEXT_DOMAIN, s));
426 441 return (buf);
427 442 }
428 443
429 444 /*
430 445 * Convert a unix errno to a dladm_status_t.
431 446 * We only convert errnos that are likely to be encountered. All others
432 447 * are mapped to DLADM_STATUS_FAILED.
433 448 */
434 449 dladm_status_t
435 450 dladm_errno2status(int err)
436 451 {
437 452 switch (err) {
438 453 case 0:
439 454 return (DLADM_STATUS_OK);
440 455 case EINVAL:
441 456 return (DLADM_STATUS_BADARG);
442 457 case EEXIST:
443 458 return (DLADM_STATUS_EXIST);
444 459 case ENOENT:
445 460 return (DLADM_STATUS_NOTFOUND);
446 461 case ENOSPC:
447 462 return (DLADM_STATUS_TOOSMALL);
448 463 case ENOMEM:
449 464 return (DLADM_STATUS_NOMEM);
450 465 case ENOTSUP:
451 466 return (DLADM_STATUS_NOTSUP);
452 467 case ENETDOWN:
453 468 return (DLADM_STATUS_NONOTIF);
454 469 case EACCES:
455 470 case EPERM:
456 471 return (DLADM_STATUS_DENIED);
457 472 case EIO:
458 473 return (DLADM_STATUS_IOERR);
459 474 case EBUSY:
460 475 return (DLADM_STATUS_LINKBUSY);
461 476 case EAGAIN:
462 477 return (DLADM_STATUS_TRYAGAIN);
463 478 case ENOTEMPTY:
464 479 return (DLADM_STATUS_FLOW_EXISTS);
465 480 case EOPNOTSUPP:
466 481 return (DLADM_STATUS_FLOW_INCOMPATIBLE);
467 482 case EALREADY:
468 483 return (DLADM_STATUS_FLOW_IDENTICAL);
469 484 case EADDRINUSE:
470 485 return (DLADM_STATUS_ADDRINUSE);
471 486 default:
472 487 return (DLADM_STATUS_FAILED);
473 488 }
474 489 }
475 490
476 491 boolean_t
477 492 dladm_str2interval(char *oarg, uint32_t *interval)
478 493 {
479 494 int val;
480 495 char *endp = NULL;
481 496
482 497 errno = 0;
483 498 val = strtol(oarg, &endp, 10);
484 499 if (errno != 0 || val <= 0 || *endp != '\0')
485 500 return (B_FALSE);
486 501
487 502 *interval = val;
488 503
489 504 return (B_TRUE);
490 505 }
491 506
492 507 dladm_status_t
493 508 dladm_str2bw(char *oarg, uint64_t *bw)
494 509 {
495 510 char *endp = NULL;
496 511 int64_t n;
497 512 int mult = 1;
498 513
499 514 n = strtoull(oarg, &endp, 10);
500 515
501 516 if ((errno != 0) || (strlen(endp) > 1))
502 517 return (DLADM_STATUS_BADARG);
503 518
504 519 if (n < 0)
505 520 return (DLADM_STATUS_BADVAL);
506 521
507 522 switch (*endp) {
508 523 case 'k':
509 524 case 'K':
510 525 mult = 1000;
511 526 break;
512 527 case 'm':
513 528 case 'M':
514 529 case '\0':
515 530 mult = 1000000;
516 531 break;
517 532 case 'g':
518 533 case 'G':
519 534 mult = 1000000000;
520 535 break;
521 536 case '%':
522 537 /*
523 538 * percentages not supported for now,
524 539 * see RFE 6540675
525 540 */
526 541 return (DLADM_STATUS_NOTSUP);
527 542 default:
528 543 return (DLADM_STATUS_BADVAL);
529 544 }
530 545
531 546 *bw = n * mult;
532 547
533 548 /* check for overflow */
534 549 if (*bw / mult != n)
535 550 return (DLADM_STATUS_BADARG);
536 551
537 552 return (DLADM_STATUS_OK);
538 553 }
539 554
540 555 /*
541 556 * Convert bandwidth in bps to a string in Mbps. For values greater
542 557 * than 1Mbps or 1000000, print a whole Mbps value. For values that
543 558 * have fractional Mbps in whole Kbps, print the bandwidth in a manner
544 559 * similar to a floating point format.
545 560 *
546 561 * bps string
547 562 * 0 0
548 563 * 100 0
549 564 * 2000 0.002
550 565 * 431000 0.431
551 566 * 1000000 1
552 567 * 1030000 1.030
553 568 * 100000000 100
554 569 */
555 570 const char *
556 571 dladm_bw2str(int64_t bw, char *buf)
557 572 {
558 573 int kbps, mbps;
559 574
560 575 kbps = (bw%1000000)/1000;
561 576 mbps = bw/1000000;
562 577 if (kbps != 0) {
563 578 if (mbps == 0)
564 579 (void) snprintf(buf, DLADM_STRSIZE, "0.%03u", kbps);
565 580 else
566 581 (void) snprintf(buf, DLADM_STRSIZE, "%5u.%03u", mbps,
567 582 kbps);
568 583 } else {
569 584 (void) snprintf(buf, DLADM_STRSIZE, "%5u", mbps);
570 585 }
571 586
572 587 return (buf);
573 588 }
574 589
575 590 #define LOCK_DB_PERMS S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH
576 591
577 592 static int
578 593 i_dladm_lock_db(const char *lock_file, short type)
579 594 {
580 595 int lock_fd;
581 596 struct flock lock;
582 597
583 598 if ((lock_fd = open(lock_file, O_RDWR | O_CREAT | O_TRUNC,
584 599 LOCK_DB_PERMS)) < 0)
585 600 return (-1);
586 601
587 602 lock.l_type = type;
588 603 lock.l_whence = SEEK_SET;
589 604 lock.l_start = 0;
590 605 lock.l_len = 0;
591 606
592 607 if (fcntl(lock_fd, F_SETLKW, &lock) < 0) {
593 608 int err = errno;
594 609
595 610 (void) close(lock_fd);
596 611 (void) unlink(lock_file);
597 612 errno = err;
598 613 return (-1);
599 614 }
600 615 return (lock_fd);
601 616 }
602 617
603 618 static void
604 619 i_dladm_unlock_db(const char *lock_file, int fd)
605 620 {
606 621 struct flock lock;
607 622
608 623 if (fd < 0)
609 624 return;
610 625
611 626 lock.l_type = F_UNLCK;
612 627 lock.l_whence = SEEK_SET;
613 628 lock.l_start = 0;
614 629 lock.l_len = 0;
615 630
616 631 (void) fcntl(fd, F_SETLKW, &lock);
617 632 (void) close(fd);
618 633 (void) unlink(lock_file);
619 634 }
620 635
621 636 /*
622 637 * Given a link class, returns its class string.
623 638 */
624 639 const char *
625 640 dladm_class2str(datalink_class_t class, char *buf)
626 641 {
627 642 const char *s;
628 643
629 644 switch (class) {
630 645 case DATALINK_CLASS_PHYS:
631 646 s = "phys";
632 647 break;
633 648 case DATALINK_CLASS_VLAN:
634 649 s = "vlan";
635 650 break;
636 651 case DATALINK_CLASS_AGGR:
637 652 s = "aggr";
638 653 break;
639 654 case DATALINK_CLASS_VNIC:
640 655 s = "vnic";
641 656 break;
642 657 case DATALINK_CLASS_ETHERSTUB:
643 658 s = "etherstub";
644 659 break;
645 660 case DATALINK_CLASS_IPTUN:
646 661 s = "iptun";
647 662 break;
648 663 case DATALINK_CLASS_SIMNET:
649 664 s = "simnet";
650 665 break;
651 666 case DATALINK_CLASS_BRIDGE:
652 667 s = "bridge";
653 668 break;
654 669 case DATALINK_CLASS_PART:
655 670 s = "part";
656 671 break;
657 672 default:
658 673 s = "unknown";
659 674 break;
660 675 }
661 676
662 677 (void) snprintf(buf, DLADM_STRSIZE, "%s", s);
663 678 return (buf);
664 679 }
665 680
666 681 /*
667 682 * Given a physical link media type, returns its media type string.
668 683 */
669 684 const char *
670 685 dladm_media2str(uint32_t media, char *buf)
671 686 {
672 687 const char *s = "--";
673 688 media_type_t *mt;
674 689 int idx;
675 690
676 691 for (idx = 0; idx < MEDIATYPECOUNT; idx++) {
677 692 mt = media_type_table + idx;
678 693 if (mt->media_type == media) {
679 694 s = mt->media_type_str;
680 695 break;
681 696 }
682 697 }
683 698
684 699 (void) snprintf(buf, DLADM_STRSIZE, "%s", s);
685 700 return (buf);
686 701 }
687 702
688 703 /*
689 704 * Given a physical link media type string, returns its media type constant.
690 705 */
691 706 uint32_t
692 707 dladm_str2media(const char *buf)
693 708 {
694 709 media_type_t *mt;
695 710 int idx;
696 711
697 712 for (idx = 0; idx < MEDIATYPECOUNT; idx++) {
698 713 mt = media_type_table + idx;
699 714 if (strcasecmp(buf, mt->media_type_str) == 0)
700 715 return (mt->media_type);
701 716 }
702 717
703 718 return (DL_OTHER);
704 719 }
705 720
706 721 dladm_status_t
707 722 i_dladm_rw_db(dladm_handle_t handle, const char *db_file, mode_t db_perms,
708 723 dladm_status_t (*process_db)(dladm_handle_t, void *, FILE *, FILE *),
709 724 void *arg, boolean_t writeop)
710 725 {
711 726 dladm_status_t status = DLADM_STATUS_OK;
712 727 FILE *fp, *nfp = NULL;
713 728 char lock[MAXPATHLEN];
714 729 char file[MAXPATHLEN];
715 730 char newfile[MAXPATHLEN];
716 731 char *db_basename;
717 732 int nfd, lock_fd;
718 733
719 734 /*
720 735 * If we are called from a boot script such as net-physical,
721 736 * it's quite likely that the root fs is still not writable.
722 737 * For this case, it's ok for the lock creation to fail since
723 738 * no one else could be accessing our configuration file.
724 739 */
725 740 db_basename = strrchr(db_file, '/');
726 741 if (db_basename == NULL || db_basename[1] == '\0')
727 742 return (dladm_errno2status(EINVAL));
728 743 db_basename++;
729 744 (void) snprintf(lock, MAXPATHLEN, "/tmp/%s.lock", db_basename);
730 745 if ((lock_fd = i_dladm_lock_db
731 746 (lock, (writeop ? F_WRLCK : F_RDLCK))) < 0 && errno != EROFS)
732 747 return (dladm_errno2status(errno));
733 748
734 749 (void) snprintf(file, MAXPATHLEN, "%s/%s", dladm_rootdir, db_file);
735 750 if ((fp = fopen(file, (writeop ? "r+" : "r"))) == NULL) {
736 751 int err = errno;
737 752
738 753 i_dladm_unlock_db(lock, lock_fd);
739 754 if (err == ENOENT)
740 755 return (DLADM_STATUS_DBNOTFOUND);
741 756
742 757 return (dladm_errno2status(err));
743 758 }
744 759
745 760 if (writeop) {
746 761 (void) snprintf(newfile, MAXPATHLEN, "%s/%s.new",
747 762 dladm_rootdir, db_file);
748 763 if ((nfd = open(newfile, O_WRONLY | O_CREAT | O_TRUNC,
749 764 db_perms)) < 0) {
750 765 (void) fclose(fp);
751 766 i_dladm_unlock_db(lock, lock_fd);
752 767 return (dladm_errno2status(errno));
753 768 }
754 769
755 770 if ((nfp = fdopen(nfd, "w")) == NULL) {
756 771 (void) close(nfd);
757 772 (void) fclose(fp);
758 773 (void) unlink(newfile);
759 774 i_dladm_unlock_db(lock, lock_fd);
760 775 return (dladm_errno2status(errno));
761 776 }
762 777 }
763 778 status = (*process_db)(handle, arg, fp, nfp);
764 779 if (!writeop || status != DLADM_STATUS_OK)
765 780 goto done;
766 781
767 782 /* Set permissions on file to db_perms */
768 783 if (fchmod(nfd, db_perms) < 0) {
769 784 status = dladm_errno2status(errno);
770 785 goto done;
771 786 }
772 787
773 788 /*
774 789 * Configuration files need to be owned by the 'dladm' user and
775 790 * 'netadm' group.
776 791 */
777 792 if (fchown(nfd, UID_DLADM, GID_NETADM) < 0) {
778 793 status = dladm_errno2status(errno);
779 794 goto done;
780 795 }
781 796
782 797 if (fflush(nfp) == EOF) {
783 798 status = dladm_errno2status(errno);
784 799 goto done;
785 800 }
786 801 (void) fclose(fp);
787 802 (void) fclose(nfp);
788 803
789 804 if (rename(newfile, file) < 0) {
790 805 (void) unlink(newfile);
791 806 i_dladm_unlock_db(lock, lock_fd);
792 807 return (dladm_errno2status(errno));
793 808 }
794 809
795 810 i_dladm_unlock_db(lock, lock_fd);
796 811 return (DLADM_STATUS_OK);
797 812
798 813 done:
799 814 if (nfp != NULL) {
800 815 (void) fclose(nfp);
801 816 if (status != DLADM_STATUS_OK)
802 817 (void) unlink(newfile);
803 818 }
804 819 (void) fclose(fp);
805 820 i_dladm_unlock_db(lock, lock_fd);
806 821 return (status);
807 822 }
808 823
809 824 dladm_status_t
810 825 dladm_set_rootdir(const char *rootdir)
811 826 {
812 827 DIR *dp;
813 828
814 829 if (rootdir == NULL || *rootdir != '/' ||
815 830 (dp = opendir(rootdir)) == NULL)
816 831 return (DLADM_STATUS_BADARG);
817 832
818 833 (void) strncpy(dladm_rootdir, rootdir, MAXPATHLEN);
819 834 (void) closedir(dp);
820 835 return (DLADM_STATUS_OK);
821 836 }
822 837
823 838 boolean_t
824 839 dladm_valid_linkname(const char *link)
825 840 {
826 841 size_t len = strlen(link);
827 842 const char *cp;
828 843 int nd = 0;
829 844
830 845 if (len >= MAXLINKNAMELEN)
831 846 return (B_FALSE);
832 847
833 848 /* Link name cannot start with a digit */
834 849 if (isdigit(link[0]))
835 850 return (B_FALSE);
836 851 /* Link name must end with a number without leading zeroes */
837 852 cp = link + len - 1;
838 853 while (isdigit(*cp)) {
839 854 cp--;
840 855 nd++;
841 856 }
842 857 if (nd == 0 || (nd > 1 && *(cp + 1) == '0'))
843 858 return (B_FALSE);
844 859
845 860 /*
846 861 * The legal characters in a link name are:
847 862 * alphanumeric (a-z, A-Z, 0-9), underscore ('_'), and '.'.
848 863 */
849 864 for (cp = link; *cp != '\0'; cp++) {
850 865 if ((isalnum(*cp) == 0) && (*cp != '_') && (*cp != '.'))
851 866 return (B_FALSE);
852 867 }
853 868
854 869 return (B_TRUE);
855 870 }
856 871
857 872 /*
858 873 * Convert priority string to a value.
859 874 */
860 875 dladm_status_t
861 876 dladm_str2pri(char *token, mac_priority_level_t *pri)
862 877 {
863 878 if (strlen(token) == strlen("low") &&
864 879 strncasecmp(token, "low", strlen("low")) == 0) {
865 880 *pri = MPL_LOW;
866 881 } else if (strlen(token) == strlen("medium") &&
867 882 strncasecmp(token, "medium", strlen("medium")) == 0) {
868 883 *pri = MPL_MEDIUM;
869 884 } else if (strlen(token) == strlen("high") &&
870 885 strncasecmp(token, "high", strlen("high")) == 0) {
871 886 *pri = MPL_HIGH;
872 887 } else {
873 888 return (DLADM_STATUS_BADVAL);
874 889 }
875 890 return (DLADM_STATUS_OK);
876 891 }
877 892
878 893 /*
879 894 * Convert priority value to a string.
880 895 */
881 896 const char *
882 897 dladm_pri2str(mac_priority_level_t pri, char *buf)
883 898 {
884 899 const char *s;
885 900
886 901 switch (pri) {
887 902 case MPL_LOW:
888 903 s = "low";
889 904 break;
890 905 case MPL_MEDIUM:
891 906 s = "medium";
892 907 break;
893 908 case MPL_HIGH:
894 909 s = "high";
895 910 break;
896 911 default:
897 912 s = "--";
898 913 break;
899 914 }
900 915 (void) snprintf(buf, DLADM_STRSIZE, "%s", dgettext(TEXT_DOMAIN, s));
901 916 return (buf);
902 917 }
903 918
904 919 /*
905 920 * Convert protect string to a value.
906 921 */
907 922 dladm_status_t
908 923 dladm_str2protect(char *token, uint32_t *ptype)
909 924 {
910 925 link_protect_t *lp;
911 926 int i;
912 927
913 928 for (i = 0; i < LPTYPES; i++) {
914 929 lp = &link_protect_types[i];
915 930 if (strcmp(token, lp->lp_name) == 0) {
916 931 *ptype = lp->lp_type;
917 932 return (DLADM_STATUS_OK);
918 933 }
919 934 }
920 935 return (DLADM_STATUS_BADVAL);
921 936 }
922 937
923 938 /*
924 939 * Convert protect value to a string.
925 940 */
926 941 const char *
927 942 dladm_protect2str(uint32_t ptype, char *buf)
928 943 {
929 944 const char *s = "--";
930 945 link_protect_t *lp;
931 946 int i;
932 947
933 948 for (i = 0; i < LPTYPES; i++) {
934 949 lp = &link_protect_types[i];
935 950 if (lp->lp_type == ptype) {
936 951 s = lp->lp_name;
937 952 break;
938 953 }
939 954 }
940 955 (void) snprintf(buf, DLADM_STRSIZE, "%s", dgettext(TEXT_DOMAIN, s));
941 956 return (buf);
942 957 }
943 958
944 959 /*
945 960 * Convert an IPv4 address to/from a string.
946 961 */
947 962 const char *
948 963 dladm_ipv4addr2str(void *addr, char *buf)
949 964 {
950 965 if (inet_ntop(AF_INET, addr, buf, INET_ADDRSTRLEN) == NULL)
951 966 buf[0] = '\0';
952 967
953 968 return (buf);
954 969 }
955 970
956 971 dladm_status_t
957 972 dladm_str2ipv4addr(char *token, void *addr)
958 973 {
959 974 return (inet_pton(AF_INET, token, addr) == 1 ?
960 975 DLADM_STATUS_OK : DLADM_STATUS_INVALID_IP);
961 976 }
962 977
963 978 const char *
964 979 dladm_ipv6addr2str(void *addr, char *buf)
965 980 {
966 981 if (inet_ntop(AF_INET6, addr, buf, INET6_ADDRSTRLEN) == NULL)
967 982 buf[0] = '\0';
968 983
969 984 return (buf);
970 985 }
971 986
972 987 dladm_status_t
973 988 dladm_str2ipv6addr(char *token, void *addr)
974 989 {
975 990 return (inet_pton(AF_INET6, token, addr) == 1 ?
976 991 DLADM_STATUS_OK : DLADM_STATUS_INVALID_IP);
977 992 }
978 993
979 994 /*
980 995 * Find the set bits in a mask.
981 996 * This is used for expanding a bitmask into individual sub-masks
982 997 * which can be used for further processing.
983 998 */
984 999 void
985 1000 dladm_find_setbits32(uint32_t mask, uint32_t *list, uint32_t *cnt)
986 1001 {
987 1002 int i, c = 0;
988 1003
989 1004 for (i = 0; i < 32; i++) {
990 1005 if (((1 << i) & mask) != 0)
991 1006 list[c++] = 1 << i;
992 1007 }
993 1008 *cnt = c;
994 1009 }
995 1010
996 1011 void
997 1012 dladm_free_args(dladm_arg_list_t *list)
998 1013 {
999 1014 if (list != NULL) {
1000 1015 free(list->al_buf);
1001 1016 free(list);
1002 1017 }
1003 1018 }
1004 1019
1005 1020 dladm_status_t
1006 1021 dladm_parse_args(char *str, dladm_arg_list_t **listp, boolean_t novalues)
1007 1022 {
1008 1023 dladm_arg_list_t *list;
1009 1024 dladm_arg_info_t *aip;
1010 1025 char *buf, *curr;
1011 1026 int len, i;
1012 1027
1013 1028 if (str == NULL)
1014 1029 return (DLADM_STATUS_BADVAL);
1015 1030
1016 1031 if (str[0] == '\0')
1017 1032 return (DLADM_STATUS_OK);
1018 1033
1019 1034 list = malloc(sizeof (dladm_arg_list_t));
1020 1035 if (list == NULL)
1021 1036 return (dladm_errno2status(errno));
1022 1037
1023 1038 list->al_count = 0;
1024 1039 list->al_buf = buf = strdup(str);
1025 1040 if (buf == NULL)
1026 1041 return (dladm_errno2status(errno));
1027 1042
1028 1043 curr = buf;
1029 1044 len = strlen(buf);
1030 1045 aip = NULL;
1031 1046 for (i = 0; i < len; i++) {
1032 1047 char c = buf[i];
1033 1048 boolean_t match = (c == '=' || c == ',');
1034 1049
1035 1050 if (!match && i != len - 1)
1036 1051 continue;
1037 1052
1038 1053 if (match) {
1039 1054 buf[i] = '\0';
1040 1055 if (*curr == '\0')
1041 1056 goto fail;
1042 1057 }
1043 1058
1044 1059 if (aip != NULL && c != '=') {
1045 1060 if (aip->ai_count > DLADM_MAX_ARG_VALS)
1046 1061 goto fail;
1047 1062
1048 1063 if (novalues)
1049 1064 goto fail;
1050 1065
1051 1066 aip->ai_val[aip->ai_count] = curr;
1052 1067 aip->ai_count++;
1053 1068 } else {
1054 1069 if (list->al_count > DLADM_MAX_ARG_VALS)
1055 1070 goto fail;
1056 1071
1057 1072 aip = &list->al_info[list->al_count];
1058 1073 aip->ai_name = curr;
1059 1074 aip->ai_count = 0;
1060 1075 list->al_count++;
1061 1076 if (c == ',')
1062 1077 aip = NULL;
1063 1078 }
1064 1079 curr = buf + i + 1;
1065 1080 }
1066 1081
1067 1082 *listp = list;
1068 1083 return (DLADM_STATUS_OK);
1069 1084
1070 1085 fail:
1071 1086 dladm_free_args(list);
1072 1087 return (DLADM_STATUS_FAILED);
1073 1088 }
1074 1089
1075 1090 /*
1076 1091 * mac_propval_range_t functions. Currently implemented for only
1077 1092 * ranges of uint32_t elements, but can be expanded as required.
1078 1093 */
1079 1094 /*
1080 1095 * Convert an array of strings (which can be ranges or individual
1081 1096 * elements) into a single mac_propval_range_t structure which
1082 1097 * is allocated here but should be freed by the caller.
1083 1098 */
1084 1099 dladm_status_t
1085 1100 dladm_strs2range(char **prop_val, uint_t val_cnt, mac_propval_type_t type,
1086 1101 mac_propval_range_t **range)
1087 1102 {
1088 1103 int i;
1089 1104 char *endp;
1090 1105 mac_propval_range_t *rangep;
1091 1106 dladm_status_t status = DLADM_STATUS_OK;
1092 1107
1093 1108 switch (type) {
1094 1109 case MAC_PROPVAL_UINT32: {
1095 1110 mac_propval_uint32_range_t *ur;
1096 1111
1097 1112 /* Allocate range structure */
1098 1113 rangep = malloc(sizeof (mac_propval_range_t) +
1099 1114 (val_cnt-1)*(sizeof (mac_propval_uint32_range_t)));
1100 1115 if (rangep == NULL)
1101 1116 return (DLADM_STATUS_NOMEM);
1102 1117
1103 1118 rangep->mpr_count = 0;
1104 1119 ur = &rangep->mpr_range_uint32[0];
1105 1120 for (i = 0; i < val_cnt; i++, ur++) {
1106 1121 errno = 0;
1107 1122 if (strchr(prop_val[i], '-') == NULL) {
1108 1123 /* single element */
1109 1124 ur->mpur_min = ur->mpur_max =
1110 1125 strtol(prop_val[i], &endp, 10);
1111 1126 if ((endp != NULL) && (*endp != '\0')) {
1112 1127 return (DLADM_STATUS_BADRANGE);
1113 1128 }
1114 1129 } else {
1115 1130 /* range of elements */
1116 1131 ur->mpur_min = strtol(prop_val[i], &endp, 10);
1117 1132 if (*endp++ != '-')
1118 1133 return (DLADM_STATUS_BADRANGE);
1119 1134 ur->mpur_max = strtol(endp, &endp, 10);
1120 1135 if (endp != NULL && *endp != '\0' ||
1121 1136 ur->mpur_max < ur->mpur_min)
1122 1137 return (DLADM_STATUS_BADRANGE);
1123 1138 }
1124 1139 rangep->mpr_count++;
1125 1140 }
1126 1141 break;
1127 1142 }
1128 1143 default:
1129 1144 return (DLADM_STATUS_BADVAL);
1130 1145 }
1131 1146
1132 1147 rangep->mpr_type = type;
1133 1148 *range = rangep;
1134 1149
1135 1150 return (status);
1136 1151 }
1137 1152
1138 1153 /*
1139 1154 * Convert a mac_propval_range_t structure into an array of elements.
1140 1155 */
1141 1156 dladm_status_t
1142 1157 dladm_range2list(mac_propval_range_t *rangep, void *elem, uint_t *nelem)
1143 1158 {
1144 1159 int i, j, k;
1145 1160 dladm_status_t status = DLADM_STATUS_OK;
1146 1161
1147 1162 switch (rangep->mpr_type) {
1148 1163 case MAC_PROPVAL_UINT32: {
1149 1164 mac_propval_uint32_range_t *ur;
1150 1165 uint32_t *elem32 = elem;
1151 1166
1152 1167 k = 0;
1153 1168 ur = &rangep->mpr_range_uint32[0];
1154 1169 for (i = 0; i < rangep->mpr_count; i++, ur++) {
1155 1170 for (j = 0; j <= ur->mpur_max - ur->mpur_min; j++) {
1156 1171 elem32[k++] = ur->mpur_min + j;
1157 1172 if (k > *nelem) {
1158 1173 status = DLADM_STATUS_TOOMANYELEMENTS;
1159 1174 break;
1160 1175 }
1161 1176 }
1162 1177 }
1163 1178 *nelem = k;
1164 1179 break;
1165 1180 }
1166 1181 default:
1167 1182 status = DLADM_STATUS_BADVAL;
1168 1183 break;
1169 1184 }
1170 1185 return (status);
1171 1186 }
1172 1187
1173 1188 /*
1174 1189 * Convert a mac_propval_range_t structure into an array of strings
1175 1190 * of single elements or ranges.
1176 1191 */
1177 1192 int
1178 1193 dladm_range2strs(mac_propval_range_t *rangep, char **prop_val)
1179 1194 {
1180 1195 int i;
1181 1196
1182 1197 switch (rangep->mpr_type) {
1183 1198 case MAC_PROPVAL_UINT32: {
1184 1199 mac_propval_uint32_range_t *ur;
1185 1200
1186 1201 /* Write ranges and individual elements */
1187 1202 ur = &rangep->mpr_range_uint32[0];
1188 1203 for (i = 0; i < rangep->mpr_count; i++, ur++) {
1189 1204 if (ur->mpur_min == ur->mpur_max) {
1190 1205 /* single element */
1191 1206 (void) snprintf(prop_val[i], DLADM_PROP_VAL_MAX,
1192 1207 "%u", ur->mpur_min);
1193 1208 } else {
1194 1209 /* range of elements */
1195 1210 (void) snprintf(prop_val[i], DLADM_PROP_VAL_MAX,
1196 1211 "%u-%u", ur->mpur_min, ur->mpur_max);
1197 1212 }
1198 1213 }
1199 1214 return (0);
1200 1215 }
1201 1216 default:
1202 1217 break;
1203 1218 }
1204 1219 return (EINVAL);
1205 1220 }
1206 1221
1207 1222 static int
1208 1223 uint32cmp(const void *a, const void *b)
1209 1224 {
1210 1225 return (*(uint32_t *)a - *(uint32_t *)b);
1211 1226 }
1212 1227
1213 1228 /*
1214 1229 * Sort and convert an array of elements into a single
1215 1230 * mac_propval_range_t structure which is allocated here but
1216 1231 * should be freed by the caller.
1217 1232 */
1218 1233 dladm_status_t
1219 1234 dladm_list2range(void *elem, uint_t nelem, mac_propval_type_t type,
1220 1235 mac_propval_range_t **range)
1221 1236 {
1222 1237 int i;
1223 1238 uint_t nr = 0;
1224 1239 mac_propval_range_t *rangep;
1225 1240 dladm_status_t status = DLADM_STATUS_OK;
1226 1241
1227 1242 switch (type) {
1228 1243 case MAC_PROPVAL_UINT32: {
1229 1244 mac_propval_uint32_range_t *ur;
1230 1245 uint32_t *elem32 = elem;
1231 1246 uint32_t *sort32;
1232 1247
1233 1248 /* Allocate range structure */
1234 1249 rangep = malloc(sizeof (mac_propval_range_t) +
1235 1250 (nelem-1)*(sizeof (mac_propval_uint32_range_t)));
1236 1251 if (rangep == NULL)
1237 1252 return (DLADM_STATUS_NOMEM);
1238 1253
1239 1254 /* Allocate array for sorting */
1240 1255 sort32 = malloc(nelem * sizeof (uint32_t));
1241 1256 if (sort32 == NULL) {
1242 1257 free(rangep);
1243 1258 return (DLADM_STATUS_NOMEM);
1244 1259 }
1245 1260
1246 1261 /* Copy and sort list */
1247 1262 for (i = 0; i < nelem; i++)
1248 1263 sort32[i] = elem32[i];
1249 1264 if (nelem > 1)
1250 1265 qsort(sort32, nelem, sizeof (uint32_t), uint32cmp);
1251 1266
1252 1267 /* Convert list to ranges */
1253 1268 ur = &rangep->mpr_range_uint32[0];
1254 1269 ur->mpur_min = ur->mpur_max = sort32[0];
1255 1270 for (i = 1; i < nelem; i++) {
1256 1271 if (sort32[i]-sort32[i-1] == 1) {
1257 1272 /* part of current range */
1258 1273 ur->mpur_max = sort32[i];
1259 1274 } else {
1260 1275 /* start a new range */
1261 1276 nr++; ur++;
1262 1277 ur->mpur_min = ur->mpur_max = sort32[i];
1263 1278 }
1264 1279 }
1265 1280 free(sort32);
1266 1281 break;
1267 1282 }
1268 1283 default:
1269 1284 return (DLADM_STATUS_BADRANGE);
1270 1285 }
1271 1286
1272 1287 rangep->mpr_type = type;
1273 1288 rangep->mpr_count = nr + 1;
1274 1289 *range = rangep;
1275 1290
1276 1291 return (status);
1277 1292 }
↓ open down ↓ |
1123 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX