summaryrefslogtreecommitdiff
path: root/usr/src/lib/libdladm/common/linkprop.c
blob: 8e1ef849e98c844399b9242960b9f302749120cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License (the "License").
 * You may not use this file except in compliance with the License.
 *
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
 * or http://www.opensolaris.org/os/licensing.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
 * If applicable, add the following below this CDDL HEADER, with the
 * fields enclosed by brackets "[]" replaced with your own identifying
 * information: Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 */
/*
 * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
 * Use is subject to license terms.
 */

#pragma ident	"%Z%%M%	%I%	%E% SMI"

#include <stdlib.h>
#include <strings.h>
#include <errno.h>
#include <ctype.h>
#include <sys/stat.h>
#include <libwladm.h>
#include <libdladm_impl.h>

static dladm_status_t	i_dladm_set_prop_db(const char *, const char *,
			    char **, uint_t);
static dladm_status_t	i_dladm_get_prop_db(const char *, const char *,
			    char **, uint_t *);

/*
 * Convert a wladm_status_t to a dladm_status_t. This is used by wrappers
 * to libwladm routines (e.g. dladm_set_prop()). Note that the mapping is
 * not 1-1; whenever possible we try to look for an error code with a
 * similar meaning. Error codes with no suitable counterpart in libdladm
 * will be mapped to DLADM_STATUS_FAILED. Clients who require clearer error
 * reporting should use libwladm directly.
 */
static dladm_status_t
dladm_wladmstatus2status(wladm_status_t wstatus)
{
	switch (wstatus) {
	case WLADM_STATUS_OK:
		return (DLADM_STATUS_OK);
	case WLADM_STATUS_FAILED:
		return (DLADM_STATUS_FAILED);
	case WLADM_STATUS_NOTSUP:
		return (DLADM_STATUS_NOTSUP);
	case WLADM_STATUS_BADARG:
		return (DLADM_STATUS_BADARG);
	case WLADM_STATUS_NOTFOUND:
		return (DLADM_STATUS_NOTFOUND);
	case WLADM_STATUS_BADVAL:
		return (DLADM_STATUS_BADVAL);
	case WLADM_STATUS_LINKINVAL:
		return (DLADM_STATUS_LINKINVAL);
	case WLADM_STATUS_NOMEM:
		return (DLADM_STATUS_NOMEM);
	case WLADM_STATUS_PROPRDONLY:
		return (DLADM_STATUS_PROPRDONLY);
	case WLADM_STATUS_TOOSMALL:
		return (DLADM_STATUS_TOOSMALL);
	case WLADM_STATUS_BADVALCNT:
		return (DLADM_STATUS_BADVALCNT);
	default:
		return (DLADM_STATUS_FAILED);
	}
}

dladm_status_t
dladm_set_prop(const char *link, const char *prop_name, char **prop_val,
    uint_t val_cnt, uint_t flags)
{
	dladm_status_t		status = DLADM_STATUS_BADARG;

	if (link == NULL || (prop_val == NULL && val_cnt > 0) ||
	    (prop_val != NULL && val_cnt == 0) || flags == 0)
		return (DLADM_STATUS_BADARG);

	if ((flags & DLADM_OPT_TEMP) != 0) {
		if (wladm_is_valid(link)) {
			status = dladm_wladmstatus2status(
			    wladm_set_prop(link, prop_name,
			    prop_val, val_cnt));
		}
		if (status != DLADM_STATUS_OK)
			return (status);
	}
	if ((flags & DLADM_OPT_PERSIST) != 0) {
		status = i_dladm_set_prop_db(link, prop_name,
		    prop_val, val_cnt);
	}
	return (status);
}

dladm_status_t
dladm_walk_prop(const char *link, void *arg,
    boolean_t (*func)(void *, const char *))
{
	if (link == NULL || func == NULL)
		return (DLADM_STATUS_BADARG);

	if (wladm_is_valid(link)) {
		return (dladm_wladmstatus2status(
		    wladm_walk_prop(link, arg, func)));
	}
	return (DLADM_STATUS_BADARG);
}

dladm_status_t
dladm_get_prop(const char *link, dladm_prop_type_t type,
    const char *prop_name, char **prop_val, uint_t *val_cntp)
{
	if (link == NULL || prop_name == NULL || prop_val == NULL ||
	    val_cntp == NULL || *val_cntp == 0)
		return (DLADM_STATUS_BADARG);

	if (type == DLADM_PROP_VAL_PERSISTENT) {
		return (i_dladm_get_prop_db(link, prop_name,
		    prop_val, val_cntp));
	}

	if (wladm_is_valid(link)) {
		wladm_prop_type_t	wtype;

		switch (type) {
		case DLADM_PROP_VAL_CURRENT:
			wtype = WLADM_PROP_VAL_CURRENT;
			break;
		case DLADM_PROP_VAL_DEFAULT:
			wtype = WLADM_PROP_VAL_DEFAULT;
			break;
		case DLADM_PROP_VAL_MODIFIABLE:
			wtype = WLADM_PROP_VAL_MODIFIABLE;
			break;
		default:
			return (DLADM_STATUS_BADARG);
		}

		return (dladm_wladmstatus2status(
		    wladm_get_prop(link, wtype, prop_name,
		    prop_val, val_cntp)));
	}
	return (DLADM_STATUS_BADARG);
}

/*
 * Data structures used for implementing persistent link properties
 */
typedef struct linkprop_val {
	const char		*lv_name;
	struct linkprop_val	*lv_nextval;
} linkprop_val_t;

typedef struct linkprop_info {
	const char		*li_name;
	struct linkprop_info	*li_nextprop;
	struct linkprop_val	*li_val;
} linkprop_info_t;

typedef struct linkprop_db_state	linkprop_db_state_t;

typedef boolean_t (*linkprop_db_op_t)(linkprop_db_state_t *,
    char *, linkprop_info_t *, dladm_status_t *);

struct linkprop_db_state {
	linkprop_db_op_t	ls_op;
	const char		*ls_link;
	const char		*ls_propname;
	char			**ls_propval;
	uint_t			*ls_valcntp;
};

static void
free_linkprops(linkprop_info_t *lip)
{
	linkprop_info_t	*lip_next;
	linkprop_val_t	*lvp, *lvp_next;

	for (; lip != NULL; lip = lip_next) {
		lip_next = lip->li_nextprop;
		for (lvp = lip->li_val; lvp != NULL; lvp = lvp_next) {
			lvp_next = lvp->lv_nextval;
			free(lvp);
		}
		free(lip);
	}
}

/*
 * Generate an entry in the link property database.
 * Each entry has this format:
 * <linkname>	<prop0>=<val0>,...,<valn>;...;<propn>=<val0>,...,<valn>;
 */
static void
generate_linkprop_line(linkprop_db_state_t *lsp, char *buf,
    linkprop_info_t *listp, dladm_status_t *statusp)
{
	char		tmpbuf[MAXLINELEN];
	char		*ptr, *lim = tmpbuf + MAXLINELEN;
	linkprop_info_t	*lip = listp;
	linkprop_val_t	*lvp = NULL;

	/*
	 * Delete line if there are no properties left.
	 */
	if (lip == NULL ||
	    (lip->li_val == NULL && lip->li_nextprop == NULL)) {
		buf[0] = '\0';
		return;
	}
	ptr = tmpbuf;
	ptr += snprintf(ptr, BUFLEN(lim, ptr), "%s\t", lsp->ls_link);
	for (; lip != NULL; lip = lip->li_nextprop) {
		/*
		 * Skip properties without values.
		 */
		if (lip->li_val == NULL)
			continue;

		ptr += snprintf(ptr, BUFLEN(lim, ptr), "%s=", lip->li_name);
		for (lvp = lip->li_val; lvp != NULL; lvp = lvp->lv_nextval) {
			ptr += snprintf(ptr, BUFLEN(lim, ptr), "%s%c",
			    lvp->lv_name,
			    ((lvp->lv_nextval == NULL) ? ';' : ','));
		}
	}
	if (ptr > lim) {
		*statusp = DLADM_STATUS_TOOSMALL;
		return;
	}
	(void) snprintf(buf, MAXLINELEN, "%s\n", tmpbuf);
}

/*
 * This function is used to update or create an entry in the persistent db.
 * process_linkprop_db() will first scan the db for an entry matching the
 * specified link. If a match is found, this function is invoked with the
 * entry's contents (buf) and its linked-list representation (listp). lsp
 * holds the name and values of the property to be added or updated; this
 * information will be merged with listp. Subsequently, an updated entry
 * will be written to buf, which will in turn be written to disk by
 * process_linkprop_db(). If no entry matches the specified link, listp
 * will be NULL; a new entry will be generated in this case and it will
 * contain only the property information in lsp.
 */
static boolean_t
process_linkprop_set(linkprop_db_state_t *lsp, char *buf,
    linkprop_info_t *listp, dladm_status_t *statusp)
{
	dladm_status_t	status;
	linkprop_info_t	*lastp = NULL, *lip = listp, *nlip = NULL;
	linkprop_val_t	**lvpp;
	int		i;

	if (lsp->ls_propname == NULL) {
		buf[0] = '\0';
		return (B_FALSE);
	}

	/*
	 * Find the linkprop we want to change.
	 */
	for (; lip != NULL; lip = lip->li_nextprop) {
		if (strcmp(lip->li_name, lsp->ls_propname) == 0)
			break;

		lastp = lip;
	}

	if (lip == NULL) {
		/*
		 * If the linkprop is not found, append it to the list.
		 */
		if ((nlip = malloc(sizeof (linkprop_info_t))) == NULL) {
			status = DLADM_STATUS_NOMEM;
			goto fail;
		}
		/*
		 * nlip will need to be freed later if there is no list to
		 * append to.
		 */
		if (lastp != NULL)
			lastp->li_nextprop = nlip;
		nlip->li_name = lsp->ls_propname;
		nlip->li_nextprop = NULL;
		nlip->li_val = NULL;
		lvpp = &nlip->li_val;
	} else {
		linkprop_val_t	*lvp, *lvp_next;

		/*
		 * If the linkprop is found, delete the existing values from it.
		 */
		for (lvp = lip->li_val; lvp != NULL; lvp = lvp_next) {
			lvp_next = lvp->lv_nextval;
			free(lvp);
		}
		lip->li_val = NULL;
		lvpp = &lip->li_val;
	}

	/*
	 * Fill our linkprop with the specified values.
	 */
	for (i = 0; i < *lsp->ls_valcntp; i++) {
		if ((*lvpp = malloc(sizeof (linkprop_val_t))) == NULL) {
			status = DLADM_STATUS_NOMEM;
			goto fail;
		}
		(*lvpp)->lv_name = lsp->ls_propval[i];
		(*lvpp)->lv_nextval = NULL;
		lvpp = &(*lvpp)->lv_nextval;
	}

	if (listp != NULL) {
		generate_linkprop_line(lsp, buf, listp, statusp);
	} else {
		generate_linkprop_line(lsp, buf, nlip, statusp);
		free_linkprops(nlip);
	}
	return (B_FALSE);

fail:
	*statusp = status;
	if (listp == NULL)
		free_linkprops(nlip);

	return (B_FALSE);
}

/*
 * This function is used for retrieving the values for a specific property.
 * It gets called if an entry matching the specified link exists in the db.
 * The entry is converted into a linked-list listp. This list is then scanned
 * for the specified property name; if a matching property exists, its
 * associated values are copied to the array lsp->ls_propval.
 */
/* ARGSUSED */
static boolean_t
process_linkprop_get(linkprop_db_state_t *lsp, char *buf,
    linkprop_info_t *listp, dladm_status_t *statusp)
{
	linkprop_info_t	*lip = listp;
	linkprop_val_t	*lvp;
	uint_t		valcnt = 0;

	/*
	 * Find the linkprop we want to get.
	 */
	for (; lip != NULL; lip = lip->li_nextprop) {
		if (strcmp(lip->li_name, lsp->ls_propname) == 0)
			break;
	}
	if (lip == NULL) {
		*statusp = DLADM_STATUS_NOTFOUND;
		return (B_FALSE);
	}

	for (lvp = lip->li_val; lvp != NULL; lvp = lvp->lv_nextval) {
		(void) strncpy(lsp->ls_propval[valcnt], lvp->lv_name,
		    DLADM_PROP_VAL_MAX);

		if (++valcnt >= *lsp->ls_valcntp && lvp->lv_nextval != NULL) {
			*statusp = DLADM_STATUS_TOOSMALL;
			return (B_FALSE);
		}
	}
	/*
	 * This function is meant to be called at most once for each call
	 * to process_linkprop_db(). For this reason, it's ok to overwrite
	 * the caller's valcnt array size with the actual number of values
	 * returned.
	 */
	*lsp->ls_valcntp = valcnt;
	return (B_FALSE);
}

/*
 * This is used for initializing link properties.
 * Unlike the other routines, this gets called for every entry in the
 * database. lsp->ls_link is not user-specified but instead is set to
 * the current link being processed.
 */
/* ARGSUSED */
static boolean_t
process_linkprop_init(linkprop_db_state_t *lsp, char *buf,
    linkprop_info_t *listp, dladm_status_t *statusp)
{
	dladm_status_t	status = DLADM_STATUS_OK;
	linkprop_info_t	*lip = listp;
	linkprop_val_t	*lvp;
	uint_t		valcnt, i;
	char		**propval;

	for (; lip != NULL; lip = lip->li_nextprop) {
		/*
		 * Construct the propval array and fill it with
		 * values from listp.
		 */
		for (lvp = lip->li_val, valcnt = 0;
		    lvp != NULL; lvp = lvp->lv_nextval, valcnt++);

		propval = malloc(sizeof (char *) * valcnt);
		if (propval == NULL) {
			*statusp = DLADM_STATUS_NOMEM;
			break;
		}
		lvp = lip->li_val;
		for (i = 0; i < valcnt; i++, lvp = lvp->lv_nextval)
			propval[i] = (char *)lvp->lv_name;

		status = dladm_set_prop(lsp->ls_link, lip->li_name,
		    propval, valcnt, DLADM_OPT_TEMP);

		/*
		 * We continue with initializing other properties even
		 * after encountering an error. This error will be
		 * propagated to the caller via 'statusp'.
		 */
		if (status != DLADM_STATUS_OK)
			*statusp = status;

		free(propval);
	}
	return (B_TRUE);
}

static int
parse_linkprops(char *buf, linkprop_info_t **lipp)
{
	int			i, len;
	char			*curr;
	linkprop_info_t		*lip = NULL;
	linkprop_info_t		**tailp = lipp;
	linkprop_val_t		*lvp = NULL;
	linkprop_val_t		**vtailp = NULL;

	curr = buf;
	len = strlen(buf);
	for (i = 0; i < len; i++) {
		char		c = buf[i];
		boolean_t	match = (c == '=' || c == ',' || c == ';');

		/*
		 * Move to the next character if there is no match and
		 * if we have not reached the last character.
		 */
		if (!match && i != len - 1)
			continue;

		if (match) {
			/*
			 * Nul-terminate the string pointed to by 'curr'.
			 */
			buf[i] = '\0';
			if (*curr == '\0')
				goto fail;
		}

		if (lip != NULL) {
			/*
			 * We get here after we have processed the "<prop>="
			 * pattern. The pattern we are now interested in is
			 * "<val0>,<val1>,...,<valn>;". For each value we
			 * find, a linkprop_val_t will be allocated and
			 * added to the current 'lip'.
			 */
			if (c == '=')
				goto fail;

			lvp = malloc(sizeof (*lvp));
			if (lvp == NULL)
				goto fail;

			lvp->lv_name = curr;
			lvp->lv_nextval = NULL;
			*vtailp = lvp;
			vtailp = &lvp->lv_nextval;

			if (c == ';') {
				tailp = &lip->li_nextprop;
				vtailp = NULL;
				lip = NULL;
			}
		} else {
			/*
			 * lip == NULL indicates that 'curr' must be refering
			 * to a property name. We allocate a new linkprop_info_t
			 * append it to the list given by the caller.
			 */
			if (c != '=')
				goto fail;

			lip = malloc(sizeof (*lip));
			if (lip == NULL)
				goto fail;

			lip->li_name = curr;
			lip->li_val = NULL;
			lip->li_nextprop = NULL;
			*tailp = lip;
			vtailp = &lip->li_val;
		}
		curr = buf + i + 1;
	}
	/*
	 * The list must be non-empty and the last character must be ';'.
	 */
	if (*lipp == NULL || lip != NULL)
		goto fail;

	return (0);

fail:
	free_linkprops(*lipp);
	*lipp = NULL;
	return (-1);
}

static boolean_t
process_linkprop_line(linkprop_db_state_t *lsp, char *buf,
    dladm_status_t *statusp)
{
	linkprop_info_t		*lip = NULL;
	int			i, len, llen;
	char			*str, *lasts;
	boolean_t		cont, nolink = B_FALSE;

	/*
	 * Skip leading spaces, blank lines, and comments.
	 */
	len = strlen(buf);
	for (i = 0; i < len; i++) {
		if (!isspace(buf[i]))
			break;
	}
	if (i == len || buf[i] == '#')
		return (B_TRUE);

	str = buf + i;
	if (lsp->ls_link != NULL) {
		/*
		 * Skip links we're not interested in.
		 * Note that strncmp() and isspace() are used here
		 * instead of strtok() and strcmp() because we don't
		 * want to modify buf in case it does not contain the
		 * specified link.
		 */
		llen = strlen(lsp->ls_link);
		if (strncmp(str, lsp->ls_link, llen) != 0 ||
		    !isspace(str[llen]))
			return (B_TRUE);
	} else {
		/*
		 * If a link is not specified, find the link name
		 * and assign it to lsp->ls_link.
		 */
		if (strtok_r(str, " \n\t", &lasts) == NULL)
			goto fail;

		llen = strlen(str);
		lsp->ls_link = str;
		nolink = B_TRUE;
	}
	str += llen + 1;
	if (str >= buf + len)
		goto fail;

	/*
	 * Now find the list of link properties.
	 */
	if ((str = strtok_r(str, " \n\t", &lasts)) == NULL)
		goto fail;

	if (parse_linkprops(str, &lip) < 0)
		goto fail;

	cont = (*lsp->ls_op)(lsp, buf, lip, statusp);
	free_linkprops(lip);
	if (nolink)
		lsp->ls_link = NULL;
	return (cont);

fail:
	free_linkprops(lip);
	if (nolink)
		lsp->ls_link = NULL;

	/*
	 * Delete corrupted line.
	 */
	buf[0] = '\0';
	return (B_TRUE);
}

static dladm_status_t
process_linkprop_db(void *arg, FILE *fp, FILE *nfp)
{
	linkprop_db_state_t	*lsp = arg;
	dladm_status_t		status = DLADM_STATUS_OK;
	char			buf[MAXLINELEN];
	boolean_t		cont = B_TRUE;

	/*
	 * This loop processes each line of the configuration file.
	 * buf can potentially be modified by process_linkprop_line().
	 * If this is a write operation and buf is not truncated, buf will
	 * be written to disk. process_linkprop_line() will no longer be
	 * called after it returns B_FALSE; at which point the remainder
	 * of the file will continue to be read and, if necessary, written
	 * to disk as well.
	 */
	while (fgets(buf, MAXLINELEN, fp) != NULL) {
		if (cont)
			cont = process_linkprop_line(lsp, buf, &status);

		if (nfp != NULL && buf[0] != '\0' && fputs(buf, nfp) == EOF) {
			status = dladm_errno2status(errno);
			break;
		}
	}

	if (status != DLADM_STATUS_OK || !cont)
		return (status);

	if (lsp->ls_op == process_linkprop_set) {
		/*
		 * If the specified link is not found above, we add the
		 * link and its properties to the configuration file.
		 */
		(void) (*lsp->ls_op)(lsp, buf, NULL, &status);
		if (status == DLADM_STATUS_OK && fputs(buf, nfp) == EOF)
			status = dladm_errno2status(errno);
	}

	if (lsp->ls_op == process_linkprop_get)
		status = DLADM_STATUS_NOTFOUND;

	return (status);
}

#define	LINKPROP_RW_DB(statep, writeop) \
	(i_dladm_rw_db("/etc/dladm/linkprop.conf", \
	S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH, process_linkprop_db, \
	(statep), (writeop)))

static dladm_status_t
i_dladm_set_prop_db(const char *link, const char *prop_name,
    char **prop_val, uint_t val_cnt)
{
	linkprop_db_state_t	state;

	state.ls_op = process_linkprop_set;
	state.ls_link = link;
	state.ls_propname = prop_name;
	state.ls_propval = prop_val;
	state.ls_valcntp = &val_cnt;

	return (LINKPROP_RW_DB(&state, B_TRUE));
}

static dladm_status_t
i_dladm_get_prop_db(const char *link, const char *prop_name,
    char **prop_val, uint_t *val_cntp)
{
	linkprop_db_state_t	state;

	state.ls_op = process_linkprop_get;
	state.ls_link = link;
	state.ls_propname = prop_name;
	state.ls_propval = prop_val;
	state.ls_valcntp = val_cntp;

	return (LINKPROP_RW_DB(&state, B_FALSE));
}

dladm_status_t
dladm_init_linkprop(void)
{
	linkprop_db_state_t	state;

	state.ls_op = process_linkprop_init;
	state.ls_link = NULL;
	state.ls_propname = NULL;
	state.ls_propval = NULL;
	state.ls_valcntp = NULL;

	return (LINKPROP_RW_DB(&state, B_FALSE));
}