15895Syz147064 /*
25895Syz147064 * CDDL HEADER START
35895Syz147064 *
45895Syz147064 * The contents of this file are subject to the terms of the
55895Syz147064 * Common Development and Distribution License (the "License").
65895Syz147064 * You may not use this file except in compliance with the License.
75895Syz147064 *
85895Syz147064 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95895Syz147064 * or http://www.opensolaris.org/os/licensing.
105895Syz147064 * See the License for the specific language governing permissions
115895Syz147064 * and limitations under the License.
125895Syz147064 *
135895Syz147064 * When distributing Covered Code, include this CDDL HEADER in each
145895Syz147064 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155895Syz147064 * If applicable, add the following below this CDDL HEADER, with the
165895Syz147064 * fields enclosed by brackets "[]" replaced with your own identifying
175895Syz147064 * information: Portions Copyright [yyyy] [name of copyright owner]
185895Syz147064 *
195895Syz147064 * CDDL HEADER END
205895Syz147064 */
215895Syz147064 /*
2212824SCathy.Zhou@Sun.COM * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
235895Syz147064 */
245895Syz147064
255895Syz147064 #include <door.h>
265895Syz147064 #include <errno.h>
275895Syz147064 #include <assert.h>
285895Syz147064 #include <stdio.h>
295895Syz147064 #include <stdlib.h>
305895Syz147064 #include <unistd.h>
315895Syz147064 #include <string.h>
325895Syz147064 #include <strings.h>
3310616SSebastien.Roy@Sun.COM #include <zone.h>
345895Syz147064 #include <sys/types.h>
355895Syz147064 #include <sys/stat.h>
365895Syz147064 #include <sys/aggr.h>
379107Sjames.d.carlson@sun.com #include <sys/mman.h>
385895Syz147064 #include <fcntl.h>
395895Syz147064 #include <libdladm.h>
405895Syz147064 #include <libdladm_impl.h>
415895Syz147064 #include <libdllink.h>
425895Syz147064 #include <libdlmgmt.h>
435895Syz147064
445895Syz147064 /*
455895Syz147064 * Table of data type sizes indexed by dladm_datatype_t.
465895Syz147064 */
475895Syz147064 static size_t dladm_datatype_size[] = {
485895Syz147064 0, /* DLADM_TYPE_STR, use strnlen() */
495895Syz147064 sizeof (boolean_t), /* DLADM_TYPE_BOOLEAN */
505895Syz147064 sizeof (uint64_t) /* DLADM_TYPE_UINT64 */
515895Syz147064 };
525895Syz147064
535895Syz147064 static dladm_status_t
dladm_door_call(dladm_handle_t handle,void * arg,size_t asize,void * rbuf,size_t * rsizep)548453SAnurag.Maskey@Sun.COM dladm_door_call(dladm_handle_t handle, void *arg, size_t asize, void *rbuf,
5512824SCathy.Zhou@Sun.COM size_t *rsizep)
565895Syz147064 {
575895Syz147064 door_arg_t darg;
588453SAnurag.Maskey@Sun.COM int door_fd;
59*12953SRishi.Srivatsavai@Sun.COM dladm_status_t status;
60*12953SRishi.Srivatsavai@Sun.COM boolean_t reopen = B_FALSE;
615895Syz147064
625895Syz147064 darg.data_ptr = arg;
635895Syz147064 darg.data_size = asize;
645895Syz147064 darg.desc_ptr = NULL;
655895Syz147064 darg.desc_num = 0;
665895Syz147064 darg.rbuf = rbuf;
6712824SCathy.Zhou@Sun.COM darg.rsize = *rsizep;
685895Syz147064
69*12953SRishi.Srivatsavai@Sun.COM reopen:
708453SAnurag.Maskey@Sun.COM /* The door descriptor is opened if it isn't already */
718453SAnurag.Maskey@Sun.COM if ((status = dladm_door_fd(handle, &door_fd)) != DLADM_STATUS_OK)
728453SAnurag.Maskey@Sun.COM return (status);
73*12953SRishi.Srivatsavai@Sun.COM if (door_call(door_fd, &darg) == -1) {
74*12953SRishi.Srivatsavai@Sun.COM /*
75*12953SRishi.Srivatsavai@Sun.COM * Stale door descriptor is possible if dlmgmtd was re-started
76*12953SRishi.Srivatsavai@Sun.COM * since last door_fd open so try re-opening door file.
77*12953SRishi.Srivatsavai@Sun.COM */
78*12953SRishi.Srivatsavai@Sun.COM if (!reopen && errno == EBADF) {
79*12953SRishi.Srivatsavai@Sun.COM (void) close(handle->door_fd);
80*12953SRishi.Srivatsavai@Sun.COM handle->door_fd = -1;
81*12953SRishi.Srivatsavai@Sun.COM reopen = B_TRUE;
82*12953SRishi.Srivatsavai@Sun.COM goto reopen;
83*12953SRishi.Srivatsavai@Sun.COM }
845895Syz147064 status = dladm_errno2status(errno);
85*12953SRishi.Srivatsavai@Sun.COM }
865895Syz147064 if (status != DLADM_STATUS_OK)
875895Syz147064 return (status);
885895Syz147064
895895Syz147064 if (darg.rbuf != rbuf) {
905895Syz147064 /*
915895Syz147064 * The size of the input rbuf is not big enough so that
9212824SCathy.Zhou@Sun.COM * the door allocate the rbuf itself. In this case, return
9312824SCathy.Zhou@Sun.COM * the required size to the caller.
945895Syz147064 */
955895Syz147064 (void) munmap(darg.rbuf, darg.rsize);
9612824SCathy.Zhou@Sun.COM *rsizep = darg.rsize;
975895Syz147064 return (DLADM_STATUS_TOOSMALL);
9812824SCathy.Zhou@Sun.COM } else if (darg.rsize != *rsizep) {
9912824SCathy.Zhou@Sun.COM return (DLADM_STATUS_FAILED);
1005895Syz147064 }
1015895Syz147064
1026263Sseb return (dladm_errno2status(((dlmgmt_retval_t *)rbuf)->lr_err));
1035895Syz147064 }
1045895Syz147064
1055895Syz147064 /*
1065895Syz147064 * Allocate a new linkid with the given name. Return the new linkid.
1075895Syz147064 */
1085895Syz147064 dladm_status_t
dladm_create_datalink_id(dladm_handle_t handle,const char * link,datalink_class_t class,uint32_t media,uint32_t flags,datalink_id_t * linkidp)1098453SAnurag.Maskey@Sun.COM dladm_create_datalink_id(dladm_handle_t handle, const char *link,
1108453SAnurag.Maskey@Sun.COM datalink_class_t class, uint32_t media, uint32_t flags,
1118453SAnurag.Maskey@Sun.COM datalink_id_t *linkidp)
1125895Syz147064 {
1136263Sseb dlmgmt_door_createid_t createid;
1145895Syz147064 dlmgmt_createid_retval_t retval;
1156263Sseb uint32_t dlmgmt_flags;
1166263Sseb dladm_status_t status;
11712824SCathy.Zhou@Sun.COM size_t sz = sizeof (retval);
1185895Syz147064
1196263Sseb if (link == NULL || class == DATALINK_CLASS_ALL ||
1205895Syz147064 !(flags & (DLADM_OPT_ACTIVE | DLADM_OPT_PERSIST)) ||
1215895Syz147064 linkidp == NULL) {
1225895Syz147064 return (DLADM_STATUS_BADARG);
1235895Syz147064 }
1245895Syz147064
1255895Syz147064 dlmgmt_flags = (flags & DLADM_OPT_ACTIVE) ? DLMGMT_ACTIVE : 0;
1265895Syz147064 dlmgmt_flags |= (flags & DLADM_OPT_PERSIST) ? DLMGMT_PERSIST : 0;
1275895Syz147064
1285895Syz147064 (void) strlcpy(createid.ld_link, link, MAXLINKNAMELEN);
1295895Syz147064 createid.ld_class = class;
1305895Syz147064 createid.ld_media = media;
1315895Syz147064 createid.ld_flags = dlmgmt_flags;
1325895Syz147064 createid.ld_cmd = DLMGMT_CMD_CREATE_LINKID;
1335895Syz147064 createid.ld_prefix = (flags & DLADM_OPT_PREFIX);
1345895Syz147064
1358453SAnurag.Maskey@Sun.COM if ((status = dladm_door_call(handle, &createid, sizeof (createid),
13612824SCathy.Zhou@Sun.COM &retval, &sz)) == DLADM_STATUS_OK) {
1376263Sseb *linkidp = retval.lr_linkid;
1386263Sseb }
1396263Sseb return (status);
1405895Syz147064 }
1415895Syz147064
1425895Syz147064 /*
1435895Syz147064 * Destroy the given link ID.
1445895Syz147064 */
1455895Syz147064 dladm_status_t
dladm_destroy_datalink_id(dladm_handle_t handle,datalink_id_t linkid,uint32_t flags)1468453SAnurag.Maskey@Sun.COM dladm_destroy_datalink_id(dladm_handle_t handle, datalink_id_t linkid,
1478453SAnurag.Maskey@Sun.COM uint32_t flags)
1485895Syz147064 {
1495895Syz147064 dlmgmt_door_destroyid_t destroyid;
1505895Syz147064 dlmgmt_destroyid_retval_t retval;
1515895Syz147064 uint32_t dlmgmt_flags;
15212824SCathy.Zhou@Sun.COM size_t sz = sizeof (retval);
1535895Syz147064
1545895Syz147064 dlmgmt_flags = (flags & DLADM_OPT_ACTIVE) ? DLMGMT_ACTIVE : 0;
1555895Syz147064 dlmgmt_flags |= ((flags & DLADM_OPT_PERSIST) ? DLMGMT_PERSIST : 0);
1565895Syz147064
1575895Syz147064 destroyid.ld_cmd = DLMGMT_CMD_DESTROY_LINKID;
1585895Syz147064 destroyid.ld_linkid = linkid;
1595895Syz147064 destroyid.ld_flags = dlmgmt_flags;
1605895Syz147064
16112824SCathy.Zhou@Sun.COM return (dladm_door_call(handle, &destroyid, sizeof (destroyid),
16212824SCathy.Zhou@Sun.COM &retval, &sz));
1635895Syz147064 }
1645895Syz147064
1655895Syz147064 /*
1665895Syz147064 * Remap a given link ID to a new name.
1675895Syz147064 */
1685895Syz147064 dladm_status_t
dladm_remap_datalink_id(dladm_handle_t handle,datalink_id_t linkid,const char * link)1698453SAnurag.Maskey@Sun.COM dladm_remap_datalink_id(dladm_handle_t handle, datalink_id_t linkid,
1708453SAnurag.Maskey@Sun.COM const char *link)
1715895Syz147064 {
1725895Syz147064 dlmgmt_door_remapid_t remapid;
1735895Syz147064 dlmgmt_remapid_retval_t retval;
17412824SCathy.Zhou@Sun.COM size_t sz = sizeof (retval);
1755895Syz147064
1765895Syz147064 remapid.ld_cmd = DLMGMT_CMD_REMAP_LINKID;
1775895Syz147064 remapid.ld_linkid = linkid;
1785895Syz147064 (void) strlcpy(remapid.ld_link, link, MAXLINKNAMELEN);
1795895Syz147064
18012824SCathy.Zhou@Sun.COM return (dladm_door_call(handle, &remapid, sizeof (remapid),
18112824SCathy.Zhou@Sun.COM &retval, &sz));
1825895Syz147064 }
1835895Syz147064
1845895Syz147064 /*
1855895Syz147064 * Make a given link ID active.
1865895Syz147064 */
1875895Syz147064 dladm_status_t
dladm_up_datalink_id(dladm_handle_t handle,datalink_id_t linkid)1888453SAnurag.Maskey@Sun.COM dladm_up_datalink_id(dladm_handle_t handle, datalink_id_t linkid)
1895895Syz147064 {
1906263Sseb dlmgmt_door_upid_t upid;
1916263Sseb dlmgmt_upid_retval_t retval;
19212824SCathy.Zhou@Sun.COM size_t sz = sizeof (retval);
1935895Syz147064
1945895Syz147064 upid.ld_cmd = DLMGMT_CMD_UP_LINKID;
1955895Syz147064 upid.ld_linkid = linkid;
1965895Syz147064
19712824SCathy.Zhou@Sun.COM return (dladm_door_call(handle, &upid, sizeof (upid), &retval, &sz));
1985895Syz147064 }
1995895Syz147064
2005895Syz147064 /*
2015895Syz147064 * Create a new link with the given name. Return the new link's handle
2025895Syz147064 */
2035895Syz147064 dladm_status_t
dladm_create_conf(dladm_handle_t handle,const char * link,datalink_id_t linkid,datalink_class_t class,uint32_t media,dladm_conf_t * confp)2048453SAnurag.Maskey@Sun.COM dladm_create_conf(dladm_handle_t handle, const char *link, datalink_id_t linkid,
2055895Syz147064 datalink_class_t class, uint32_t media, dladm_conf_t *confp)
2065895Syz147064 {
2076263Sseb dlmgmt_door_createconf_t createconf;
2086263Sseb dlmgmt_createconf_retval_t retval;
2096263Sseb dladm_status_t status;
21012824SCathy.Zhou@Sun.COM size_t sz = sizeof (retval);
2115895Syz147064
2126263Sseb if (link == NULL || confp == NULL)
2135895Syz147064 return (DLADM_STATUS_BADARG);
2145895Syz147064
2155895Syz147064 (void) strlcpy(createconf.ld_link, link, MAXLINKNAMELEN);
2165895Syz147064 createconf.ld_class = class;
2175895Syz147064 createconf.ld_media = media;
2185895Syz147064 createconf.ld_linkid = linkid;
2195895Syz147064 createconf.ld_cmd = DLMGMT_CMD_CREATECONF;
22012824SCathy.Zhou@Sun.COM confp->ds_confid = DLADM_INVALID_CONF;
2215895Syz147064
2228453SAnurag.Maskey@Sun.COM if ((status = dladm_door_call(handle, &createconf, sizeof (createconf),
22312824SCathy.Zhou@Sun.COM &retval, &sz)) == DLADM_STATUS_OK) {
22412824SCathy.Zhou@Sun.COM confp->ds_readonly = B_FALSE;
22512824SCathy.Zhou@Sun.COM confp->ds_confid = retval.lr_confid;
2266263Sseb }
2276263Sseb return (status);
2285895Syz147064 }
2295895Syz147064
2305895Syz147064 /*
2315895Syz147064 * An active physical link reported by the dlmgmtd daemon might not be active
2325895Syz147064 * anymore as this link might be removed during system shutdown. Check its
2335895Syz147064 * real status by calling dladm_phys_info().
2345895Syz147064 */
2355895Syz147064 dladm_status_t
i_dladm_phys_status(dladm_handle_t handle,datalink_id_t linkid,uint32_t * flagsp)2368453SAnurag.Maskey@Sun.COM i_dladm_phys_status(dladm_handle_t handle, datalink_id_t linkid,
2378453SAnurag.Maskey@Sun.COM uint32_t *flagsp)
2385895Syz147064 {
2395895Syz147064 dladm_phys_attr_t dpa;
2405895Syz147064 dladm_status_t status;
2415895Syz147064
2425895Syz147064 assert((*flagsp) & DLMGMT_ACTIVE);
2435895Syz147064
2448453SAnurag.Maskey@Sun.COM status = dladm_phys_info(handle, linkid, &dpa, DLADM_OPT_ACTIVE);
2455895Syz147064 if (status == DLADM_STATUS_NOTFOUND) {
2465895Syz147064 /*
2475895Syz147064 * No active status, this link was removed. Update its status
2485895Syz147064 * in the daemon and delete all active linkprops.
2498120SCathy.Zhou@Sun.COM *
2508120SCathy.Zhou@Sun.COM * Note that the operation could fail. If it does, return
2518120SCathy.Zhou@Sun.COM * failure now since otherwise dladm_set_linkprop() might
2528120SCathy.Zhou@Sun.COM * call back to i_dladm_phys_status() recursively.
2535895Syz147064 */
2548453SAnurag.Maskey@Sun.COM if ((status = dladm_destroy_datalink_id(handle, linkid,
2558453SAnurag.Maskey@Sun.COM DLADM_OPT_ACTIVE)) != DLADM_STATUS_OK)
2568120SCathy.Zhou@Sun.COM return (status);
2578120SCathy.Zhou@Sun.COM
2588453SAnurag.Maskey@Sun.COM (void) dladm_set_linkprop(handle, linkid, NULL, NULL, 0,
2595895Syz147064 DLADM_OPT_ACTIVE);
2605895Syz147064
2615895Syz147064 (*flagsp) &= ~DLMGMT_ACTIVE;
2625895Syz147064 status = DLADM_STATUS_OK;
2635895Syz147064 }
2645895Syz147064 return (status);
2655895Syz147064 }
2665895Syz147064
2675895Syz147064 /*
2685895Syz147064 * Walk each entry in the data link configuration repository and
2695895Syz147064 * call fn on the linkid and arg.
2705895Syz147064 */
2715895Syz147064 dladm_status_t
dladm_walk_datalink_id(int (* fn)(dladm_handle_t,datalink_id_t,void *),dladm_handle_t handle,void * argp,datalink_class_t class,datalink_media_t dmedia,uint32_t flags)2728453SAnurag.Maskey@Sun.COM dladm_walk_datalink_id(int (*fn)(dladm_handle_t, datalink_id_t, void *),
2738453SAnurag.Maskey@Sun.COM dladm_handle_t handle, void *argp, datalink_class_t class,
2748453SAnurag.Maskey@Sun.COM datalink_media_t dmedia, uint32_t flags)
2755895Syz147064 {
2765895Syz147064 dlmgmt_door_getnext_t getnext;
2775895Syz147064 dlmgmt_getnext_retval_t retval;
2785895Syz147064 uint32_t dlmgmt_flags;
2795895Syz147064 datalink_id_t linkid = DATALINK_INVALID_LINKID;
2805895Syz147064 dladm_status_t status = DLADM_STATUS_OK;
28112824SCathy.Zhou@Sun.COM size_t sz = sizeof (retval);
2825895Syz147064
2835895Syz147064 if (fn == NULL)
2845895Syz147064 return (DLADM_STATUS_BADARG);
2855895Syz147064
2865895Syz147064 dlmgmt_flags = (flags & DLADM_OPT_ACTIVE) ? DLMGMT_ACTIVE : 0;
2875895Syz147064 dlmgmt_flags |= ((flags & DLADM_OPT_PERSIST) ? DLMGMT_PERSIST : 0);
2885895Syz147064
2895895Syz147064 getnext.ld_cmd = DLMGMT_CMD_GETNEXT;
2905895Syz147064 getnext.ld_class = class;
2915895Syz147064 getnext.ld_dmedia = dmedia;
2925895Syz147064 getnext.ld_flags = dlmgmt_flags;
2935895Syz147064
2945895Syz147064 do {
2955895Syz147064 getnext.ld_linkid = linkid;
2968453SAnurag.Maskey@Sun.COM if ((status = dladm_door_call(handle, &getnext,
29712824SCathy.Zhou@Sun.COM sizeof (getnext), &retval, &sz)) != DLADM_STATUS_OK) {
2985895Syz147064 /*
29911009SCathy.Zhou@Sun.COM * Done with walking. If no next datalink is found,
30011009SCathy.Zhou@Sun.COM * return success.
3015895Syz147064 */
30211009SCathy.Zhou@Sun.COM if (status == DLADM_STATUS_NOTFOUND)
30311009SCathy.Zhou@Sun.COM status = DLADM_STATUS_OK;
3045895Syz147064 break;
3055895Syz147064 }
3065895Syz147064
3075895Syz147064 linkid = retval.lr_linkid;
3085895Syz147064 if ((retval.lr_class == DATALINK_CLASS_PHYS) &&
3095895Syz147064 (retval.lr_flags & DLMGMT_ACTIVE)) {
3105895Syz147064 /*
3115895Syz147064 * An active physical link reported by the dlmgmtd
3125895Syz147064 * daemon might not be active anymore. Check its
3135895Syz147064 * real status.
3145895Syz147064 */
3158453SAnurag.Maskey@Sun.COM if (i_dladm_phys_status(handle, linkid,
3168453SAnurag.Maskey@Sun.COM &retval.lr_flags) != DLADM_STATUS_OK) {
3175895Syz147064 continue;
3185895Syz147064 }
3195895Syz147064
3205895Syz147064 if (!(dlmgmt_flags & retval.lr_flags))
3215895Syz147064 continue;
3225895Syz147064 }
3235895Syz147064
3248453SAnurag.Maskey@Sun.COM if (fn(handle, linkid, argp) == DLADM_WALK_TERMINATE)
3255895Syz147064 break;
3265895Syz147064 } while (linkid != DATALINK_INVALID_LINKID);
3275895Syz147064
3285895Syz147064 return (status);
3295895Syz147064 }
3305895Syz147064
3315895Syz147064 /*
33212824SCathy.Zhou@Sun.COM * Get a handle of a copy of the link configuration (kept in the daemon)
33312824SCathy.Zhou@Sun.COM * for the given link so it can be updated later by dladm_write_conf().
3345895Syz147064 */
3355895Syz147064 dladm_status_t
dladm_open_conf(dladm_handle_t handle,datalink_id_t linkid,dladm_conf_t * confp)33612824SCathy.Zhou@Sun.COM dladm_open_conf(dladm_handle_t handle, datalink_id_t linkid,
3378453SAnurag.Maskey@Sun.COM dladm_conf_t *confp)
3385895Syz147064 {
33912824SCathy.Zhou@Sun.COM dlmgmt_door_openconf_t openconf;
34012824SCathy.Zhou@Sun.COM dlmgmt_openconf_retval_t retval;
3415895Syz147064 dladm_status_t status;
34212824SCathy.Zhou@Sun.COM size_t sz;
3435895Syz147064
3445895Syz147064 if (linkid == DATALINK_INVALID_LINKID || confp == NULL)
3455895Syz147064 return (DLADM_STATUS_BADARG);
3465895Syz147064
34712824SCathy.Zhou@Sun.COM sz = sizeof (retval);
34812824SCathy.Zhou@Sun.COM openconf.ld_linkid = linkid;
34912824SCathy.Zhou@Sun.COM openconf.ld_cmd = DLMGMT_CMD_OPENCONF;
35012824SCathy.Zhou@Sun.COM confp->ds_confid = DLADM_INVALID_CONF;
35112824SCathy.Zhou@Sun.COM if ((status = dladm_door_call(handle, &openconf,
35212824SCathy.Zhou@Sun.COM sizeof (openconf), &retval, &sz)) == DLADM_STATUS_OK) {
35312824SCathy.Zhou@Sun.COM confp->ds_readonly = B_FALSE;
35412824SCathy.Zhou@Sun.COM confp->ds_confid = retval.lr_confid;
35512824SCathy.Zhou@Sun.COM }
35612824SCathy.Zhou@Sun.COM
35712824SCathy.Zhou@Sun.COM return (status);
35812824SCathy.Zhou@Sun.COM }
35912824SCathy.Zhou@Sun.COM
36012824SCathy.Zhou@Sun.COM /*
36112824SCathy.Zhou@Sun.COM * Get the handle of a local snapshot of the link configuration. Note that
36212824SCathy.Zhou@Sun.COM * any operations with this handle are read-only, i.e., one can not update
36312824SCathy.Zhou@Sun.COM * the configuration with this handle.
36412824SCathy.Zhou@Sun.COM */
36512824SCathy.Zhou@Sun.COM dladm_status_t
dladm_getsnap_conf(dladm_handle_t handle,datalink_id_t linkid,dladm_conf_t * confp)36612824SCathy.Zhou@Sun.COM dladm_getsnap_conf(dladm_handle_t handle, datalink_id_t linkid,
36712824SCathy.Zhou@Sun.COM dladm_conf_t *confp)
36812824SCathy.Zhou@Sun.COM {
36912824SCathy.Zhou@Sun.COM dlmgmt_door_getconfsnapshot_t snapshot;
37012824SCathy.Zhou@Sun.COM dlmgmt_getconfsnapshot_retval_t *retvalp;
37112824SCathy.Zhou@Sun.COM char *nvlbuf;
37212824SCathy.Zhou@Sun.COM dladm_status_t status;
37312824SCathy.Zhou@Sun.COM int err;
37412824SCathy.Zhou@Sun.COM size_t sz;
3755895Syz147064
37612824SCathy.Zhou@Sun.COM if (linkid == DATALINK_INVALID_LINKID || confp == NULL)
37712824SCathy.Zhou@Sun.COM return (DLADM_STATUS_BADARG);
37812824SCathy.Zhou@Sun.COM
37912824SCathy.Zhou@Sun.COM sz = sizeof (dlmgmt_getconfsnapshot_retval_t);
38012824SCathy.Zhou@Sun.COM snapshot.ld_linkid = linkid;
38112824SCathy.Zhou@Sun.COM snapshot.ld_cmd = DLMGMT_CMD_GETCONFSNAPSHOT;
38212824SCathy.Zhou@Sun.COM again:
38312824SCathy.Zhou@Sun.COM if ((retvalp = malloc(sz)) == NULL)
38412824SCathy.Zhou@Sun.COM return (DLADM_STATUS_NOMEM);
38512824SCathy.Zhou@Sun.COM
38612824SCathy.Zhou@Sun.COM if ((status = dladm_door_call(handle, &snapshot, sizeof (snapshot),
38712824SCathy.Zhou@Sun.COM retvalp, &sz)) == DLADM_STATUS_TOOSMALL) {
38812824SCathy.Zhou@Sun.COM free(retvalp);
38912824SCathy.Zhou@Sun.COM goto again;
3906263Sseb }
39112824SCathy.Zhou@Sun.COM
39212824SCathy.Zhou@Sun.COM if (status != DLADM_STATUS_OK) {
39312824SCathy.Zhou@Sun.COM free(retvalp);
39412824SCathy.Zhou@Sun.COM return (status);
39512824SCathy.Zhou@Sun.COM }
39612824SCathy.Zhou@Sun.COM
39712824SCathy.Zhou@Sun.COM confp->ds_readonly = B_TRUE;
39812824SCathy.Zhou@Sun.COM nvlbuf = (char *)retvalp + sizeof (dlmgmt_getconfsnapshot_retval_t);
39912824SCathy.Zhou@Sun.COM if ((err = nvlist_unpack(nvlbuf, retvalp->lr_nvlsz,
40012824SCathy.Zhou@Sun.COM &(confp->ds_nvl), NV_ENCODE_NATIVE)) != 0) {
40112824SCathy.Zhou@Sun.COM status = dladm_errno2status(err);
40212824SCathy.Zhou@Sun.COM }
40312824SCathy.Zhou@Sun.COM free(retvalp);
4046263Sseb return (status);
4055895Syz147064 }
4065895Syz147064
4075895Syz147064 /*
4085895Syz147064 * Commit the given link to the data link configuration repository so
4095895Syz147064 * that it will persist across reboots.
4105895Syz147064 */
4115895Syz147064 dladm_status_t
dladm_write_conf(dladm_handle_t handle,dladm_conf_t conf)4128453SAnurag.Maskey@Sun.COM dladm_write_conf(dladm_handle_t handle, dladm_conf_t conf)
4135895Syz147064 {
4145895Syz147064 dlmgmt_door_writeconf_t writeconf;
4155895Syz147064 dlmgmt_writeconf_retval_t retval;
41612824SCathy.Zhou@Sun.COM size_t sz = sizeof (retval);
4175895Syz147064
41812824SCathy.Zhou@Sun.COM if (conf.ds_confid == DLADM_INVALID_CONF)
4195895Syz147064 return (DLADM_STATUS_BADARG);
4205895Syz147064
42112824SCathy.Zhou@Sun.COM if (conf.ds_readonly)
42212824SCathy.Zhou@Sun.COM return (DLADM_STATUS_DENIED);
42312824SCathy.Zhou@Sun.COM
4245895Syz147064 writeconf.ld_cmd = DLMGMT_CMD_WRITECONF;
42512824SCathy.Zhou@Sun.COM writeconf.ld_confid = conf.ds_confid;
4265895Syz147064
42712824SCathy.Zhou@Sun.COM return (dladm_door_call(handle, &writeconf, sizeof (writeconf),
42812824SCathy.Zhou@Sun.COM &retval, &sz));
4295895Syz147064 }
4305895Syz147064
4315895Syz147064 /*
43212824SCathy.Zhou@Sun.COM * Given a dladm_conf_t, get the specific configuration field
43312824SCathy.Zhou@Sun.COM *
43412824SCathy.Zhou@Sun.COM * If the specified dladm_conf_t is a read-only snapshot of the configuration,
43512824SCathy.Zhou@Sun.COM * get a specific link propertie from that snapshot (nvl), otherwise, get
43612824SCathy.Zhou@Sun.COM * the link protperty from the dlmgmtd daemon using the given confid.
4375895Syz147064 */
4385895Syz147064 dladm_status_t
dladm_get_conf_field(dladm_handle_t handle,dladm_conf_t conf,const char * attr,void * attrval,size_t attrsz)4398453SAnurag.Maskey@Sun.COM dladm_get_conf_field(dladm_handle_t handle, dladm_conf_t conf, const char *attr,
4408453SAnurag.Maskey@Sun.COM void *attrval, size_t attrsz)
4415895Syz147064 {
44212824SCathy.Zhou@Sun.COM dladm_status_t status = DLADM_STATUS_OK;
44312824SCathy.Zhou@Sun.COM
44412824SCathy.Zhou@Sun.COM if (attrval == NULL || attrsz == 0 || attr == NULL)
44512824SCathy.Zhou@Sun.COM return (DLADM_STATUS_BADARG);
4465895Syz147064
44712824SCathy.Zhou@Sun.COM if (conf.ds_readonly) {
44812824SCathy.Zhou@Sun.COM uchar_t *oattrval;
44912824SCathy.Zhou@Sun.COM uint32_t oattrsz;
45012824SCathy.Zhou@Sun.COM int err;
45112824SCathy.Zhou@Sun.COM
45212824SCathy.Zhou@Sun.COM if ((err = nvlist_lookup_byte_array(conf.ds_nvl, (char *)attr,
45312824SCathy.Zhou@Sun.COM &oattrval, &oattrsz)) != 0) {
45412824SCathy.Zhou@Sun.COM return (dladm_errno2status(err));
45512824SCathy.Zhou@Sun.COM }
45612824SCathy.Zhou@Sun.COM if (oattrsz > attrsz)
45712824SCathy.Zhou@Sun.COM return (DLADM_STATUS_TOOSMALL);
4585895Syz147064
45912824SCathy.Zhou@Sun.COM bcopy(oattrval, attrval, oattrsz);
46012824SCathy.Zhou@Sun.COM } else {
46112824SCathy.Zhou@Sun.COM dlmgmt_door_getattr_t getattr;
46212824SCathy.Zhou@Sun.COM dlmgmt_getattr_retval_t retval;
46312824SCathy.Zhou@Sun.COM size_t sz = sizeof (retval);
46412824SCathy.Zhou@Sun.COM
46512824SCathy.Zhou@Sun.COM if (conf.ds_confid == DLADM_INVALID_CONF)
46612824SCathy.Zhou@Sun.COM return (DLADM_STATUS_BADARG);
4675895Syz147064
46812824SCathy.Zhou@Sun.COM getattr.ld_cmd = DLMGMT_CMD_GETATTR;
46912824SCathy.Zhou@Sun.COM getattr.ld_confid = conf.ds_confid;
47012824SCathy.Zhou@Sun.COM (void) strlcpy(getattr.ld_attr, attr, MAXLINKATTRLEN);
4715895Syz147064
47212824SCathy.Zhou@Sun.COM if ((status = dladm_door_call(handle, &getattr,
47312824SCathy.Zhou@Sun.COM sizeof (getattr), &retval, &sz)) != DLADM_STATUS_OK) {
47412824SCathy.Zhou@Sun.COM return (status);
47512824SCathy.Zhou@Sun.COM }
4765895Syz147064
47712824SCathy.Zhou@Sun.COM if (retval.lr_attrsz > attrsz)
47812824SCathy.Zhou@Sun.COM return (DLADM_STATUS_TOOSMALL);
47912824SCathy.Zhou@Sun.COM
48012824SCathy.Zhou@Sun.COM bcopy(retval.lr_attrval, attrval, retval.lr_attrsz);
48112824SCathy.Zhou@Sun.COM }
48212824SCathy.Zhou@Sun.COM return (status);
4835895Syz147064 }
4845895Syz147064
4855895Syz147064 /*
4868460SArtem.Kachitchkin@Sun.COM * Get next property attribute from data link configuration repository.
48712824SCathy.Zhou@Sun.COM * If last_attr is "", return the first property.
4888460SArtem.Kachitchkin@Sun.COM */
48912824SCathy.Zhou@Sun.COM /* ARGSUSED */
4908460SArtem.Kachitchkin@Sun.COM dladm_status_t
dladm_getnext_conf_linkprop(dladm_handle_t handle,dladm_conf_t conf,const char * last_attr,char * attr,void * attrval,size_t attrsz,size_t * attrszp)4918460SArtem.Kachitchkin@Sun.COM dladm_getnext_conf_linkprop(dladm_handle_t handle, dladm_conf_t conf,
4928460SArtem.Kachitchkin@Sun.COM const char *last_attr, char *attr, void *attrval, size_t attrsz,
4938460SArtem.Kachitchkin@Sun.COM size_t *attrszp)
4948460SArtem.Kachitchkin@Sun.COM {
49512824SCathy.Zhou@Sun.COM nvlist_t *nvl = conf.ds_nvl;
49612824SCathy.Zhou@Sun.COM nvpair_t *last = NULL, *nvp;
49712824SCathy.Zhou@Sun.COM uchar_t *oattrval;
49812824SCathy.Zhou@Sun.COM uint32_t oattrsz;
49912824SCathy.Zhou@Sun.COM int err;
5008460SArtem.Kachitchkin@Sun.COM
50112824SCathy.Zhou@Sun.COM if (nvl == NULL || attrval == NULL || attrsz == 0 || attr == NULL ||
50212824SCathy.Zhou@Sun.COM !conf.ds_readonly)
5038460SArtem.Kachitchkin@Sun.COM return (DLADM_STATUS_BADARG);
50412824SCathy.Zhou@Sun.COM
50512824SCathy.Zhou@Sun.COM while ((nvp = nvlist_next_nvpair(nvl, last)) != NULL) {
50612824SCathy.Zhou@Sun.COM if (last_attr[0] == '\0')
50712824SCathy.Zhou@Sun.COM break;
50812824SCathy.Zhou@Sun.COM if (last != NULL && strcmp(last_attr, nvpair_name(last)) == 0)
50912824SCathy.Zhou@Sun.COM break;
51012824SCathy.Zhou@Sun.COM last = nvp;
5118460SArtem.Kachitchkin@Sun.COM }
5128460SArtem.Kachitchkin@Sun.COM
51312824SCathy.Zhou@Sun.COM if (nvp == NULL)
51412824SCathy.Zhou@Sun.COM return (DLADM_STATUS_NOTFOUND);
5158460SArtem.Kachitchkin@Sun.COM
51612824SCathy.Zhou@Sun.COM if ((err = nvpair_value_byte_array(nvp, (uchar_t **)&oattrval,
51712824SCathy.Zhou@Sun.COM &oattrsz)) != NULL) {
51812824SCathy.Zhou@Sun.COM return (dladm_errno2status(err));
5198460SArtem.Kachitchkin@Sun.COM }
5208460SArtem.Kachitchkin@Sun.COM
52112824SCathy.Zhou@Sun.COM *attrszp = oattrsz;
52212824SCathy.Zhou@Sun.COM if (oattrsz > attrsz)
5238460SArtem.Kachitchkin@Sun.COM return (DLADM_STATUS_TOOSMALL);
5248460SArtem.Kachitchkin@Sun.COM
52512824SCathy.Zhou@Sun.COM (void) strlcpy(attr, nvpair_name(nvp), MAXLINKATTRLEN);
52612824SCathy.Zhou@Sun.COM bcopy(oattrval, attrval, oattrsz);
5278460SArtem.Kachitchkin@Sun.COM return (DLADM_STATUS_OK);
5288460SArtem.Kachitchkin@Sun.COM }
5298460SArtem.Kachitchkin@Sun.COM
5308460SArtem.Kachitchkin@Sun.COM /*
5315895Syz147064 * Get the link ID that is associated with the given name.
5325895Syz147064 */
5335895Syz147064 dladm_status_t
dladm_name2info(dladm_handle_t handle,const char * link,datalink_id_t * linkidp,uint32_t * flagp,datalink_class_t * classp,uint32_t * mediap)5348453SAnurag.Maskey@Sun.COM dladm_name2info(dladm_handle_t handle, const char *link, datalink_id_t *linkidp,
5358453SAnurag.Maskey@Sun.COM uint32_t *flagp, datalink_class_t *classp, uint32_t *mediap)
5365895Syz147064 {
5375895Syz147064 dlmgmt_door_getlinkid_t getlinkid;
5385895Syz147064 dlmgmt_getlinkid_retval_t retval;
5395895Syz147064 datalink_id_t linkid;
5405895Syz147064 dladm_status_t status;
54112824SCathy.Zhou@Sun.COM size_t sz = sizeof (retval);
5425895Syz147064
5435895Syz147064 getlinkid.ld_cmd = DLMGMT_CMD_GETLINKID;
5445895Syz147064 (void) strlcpy(getlinkid.ld_link, link, MAXLINKNAMELEN);
5455895Syz147064
5468453SAnurag.Maskey@Sun.COM if ((status = dladm_door_call(handle, &getlinkid, sizeof (getlinkid),
54712824SCathy.Zhou@Sun.COM &retval, &sz)) != DLADM_STATUS_OK) {
5485895Syz147064 return (status);
5496263Sseb }
5505895Syz147064
5515895Syz147064 linkid = retval.lr_linkid;
5525895Syz147064 if (retval.lr_class == DATALINK_CLASS_PHYS &&
5535895Syz147064 retval.lr_flags & DLMGMT_ACTIVE) {
5545895Syz147064 /*
5555895Syz147064 * An active physical link reported by the dlmgmtd daemon
5565895Syz147064 * might not be active anymore. Check and set its real status.
5575895Syz147064 */
5588453SAnurag.Maskey@Sun.COM status = i_dladm_phys_status(handle, linkid, &retval.lr_flags);
5595895Syz147064 if (status != DLADM_STATUS_OK)
5605895Syz147064 return (status);
5615895Syz147064 }
5625895Syz147064
5635895Syz147064 if (linkidp != NULL)
5645895Syz147064 *linkidp = linkid;
5655895Syz147064 if (flagp != NULL) {
5665895Syz147064 *flagp = retval.lr_flags & DLMGMT_ACTIVE ? DLADM_OPT_ACTIVE : 0;
5675895Syz147064 *flagp |= (retval.lr_flags & DLMGMT_PERSIST) ?
5685895Syz147064 DLADM_OPT_PERSIST : 0;
5695895Syz147064 }
5705895Syz147064 if (classp != NULL)
5715895Syz147064 *classp = retval.lr_class;
5725895Syz147064 if (mediap != NULL)
5735895Syz147064 *mediap = retval.lr_media;
5745895Syz147064
5755895Syz147064 return (DLADM_STATUS_OK);
5765895Syz147064 }
5775895Syz147064
5785895Syz147064 /*
5795895Syz147064 * Get the link name that is associated with the given id.
5805895Syz147064 */
5815895Syz147064 dladm_status_t
dladm_datalink_id2info(dladm_handle_t handle,datalink_id_t linkid,uint32_t * flagp,datalink_class_t * classp,uint32_t * mediap,char * link,size_t len)5828453SAnurag.Maskey@Sun.COM dladm_datalink_id2info(dladm_handle_t handle, datalink_id_t linkid,
5838453SAnurag.Maskey@Sun.COM uint32_t *flagp, datalink_class_t *classp, uint32_t *mediap, char *link,
5848453SAnurag.Maskey@Sun.COM size_t len)
5855895Syz147064 {
5866263Sseb dlmgmt_door_getname_t getname;
5876263Sseb dlmgmt_getname_retval_t retval;
5886263Sseb dladm_status_t status;
58912824SCathy.Zhou@Sun.COM size_t sz = sizeof (retval);
5905895Syz147064
5915895Syz147064 if ((linkid == DATALINK_INVALID_LINKID) || (link != NULL && len == 0) ||
5925895Syz147064 (link == NULL && len != 0)) {
5935895Syz147064 return (DLADM_STATUS_BADARG);
5945895Syz147064 }
5955895Syz147064
5965895Syz147064 getname.ld_cmd = DLMGMT_CMD_GETNAME;
5975895Syz147064 getname.ld_linkid = linkid;
5988453SAnurag.Maskey@Sun.COM if ((status = dladm_door_call(handle, &getname, sizeof (getname),
59912824SCathy.Zhou@Sun.COM &retval, &sz)) != DLADM_STATUS_OK) {
6005895Syz147064 return (status);
6016263Sseb }
6025895Syz147064
6036263Sseb if (len != 0 && (strlen(retval.lr_link) + 1 > len))
6045895Syz147064 return (DLADM_STATUS_TOOSMALL);
6055895Syz147064
6065895Syz147064 if (retval.lr_class == DATALINK_CLASS_PHYS &&
6075895Syz147064 retval.lr_flags & DLMGMT_ACTIVE) {
6085895Syz147064 /*
6095895Syz147064 * An active physical link reported by the dlmgmtd daemon
6105895Syz147064 * might not be active anymore. Check and set its real status.
6115895Syz147064 */
6128453SAnurag.Maskey@Sun.COM status = i_dladm_phys_status(handle, linkid, &retval.lr_flags);
6135895Syz147064 if (status != DLADM_STATUS_OK)
6145895Syz147064 return (status);
6155895Syz147064 }
6165895Syz147064
6175895Syz147064 if (link != NULL)
6185895Syz147064 (void) strlcpy(link, retval.lr_link, len);
6195895Syz147064 if (classp != NULL)
6205895Syz147064 *classp = retval.lr_class;
6215895Syz147064 if (mediap != NULL)
6225895Syz147064 *mediap = retval.lr_media;
6235895Syz147064 if (flagp != NULL) {
6245895Syz147064 *flagp = retval.lr_flags & DLMGMT_ACTIVE ?
6255895Syz147064 DLADM_OPT_ACTIVE : 0;
6265895Syz147064 *flagp |= (retval.lr_flags & DLMGMT_PERSIST) ?
6275895Syz147064 DLADM_OPT_PERSIST : 0;
6285895Syz147064 }
6295895Syz147064 return (DLADM_STATUS_OK);
6305895Syz147064 }
6315895Syz147064
6325895Syz147064 /*
6335895Syz147064 * Set the given attr with the given attrval for the given link.
6345895Syz147064 */
6355895Syz147064 dladm_status_t
dladm_set_conf_field(dladm_handle_t handle,dladm_conf_t conf,const char * attr,dladm_datatype_t type,const void * attrval)6368453SAnurag.Maskey@Sun.COM dladm_set_conf_field(dladm_handle_t handle, dladm_conf_t conf, const char *attr,
6375895Syz147064 dladm_datatype_t type, const void *attrval)
6385895Syz147064 {
6396263Sseb dlmgmt_door_setattr_t setattr;
6406263Sseb dlmgmt_setattr_retval_t retval;
6416263Sseb size_t attrsz;
64212824SCathy.Zhou@Sun.COM size_t sz = sizeof (retval);
6435895Syz147064
6446263Sseb if (attr == NULL || attrval == NULL)
6455895Syz147064 return (DLADM_STATUS_BADARG);
6465895Syz147064
64712824SCathy.Zhou@Sun.COM if (conf.ds_readonly)
64812824SCathy.Zhou@Sun.COM return (DLADM_STATUS_DENIED);
64912824SCathy.Zhou@Sun.COM
6505895Syz147064 if (type == DLADM_TYPE_STR)
6515895Syz147064 attrsz = strlen(attrval) + 1;
6525895Syz147064 else
6535895Syz147064 attrsz = dladm_datatype_size[type];
6545895Syz147064
6556263Sseb if (attrsz > MAXLINKATTRVALLEN)
6566263Sseb return (DLADM_STATUS_TOOSMALL);
6575895Syz147064
6586263Sseb setattr.ld_cmd = DLMGMT_CMD_SETATTR;
65912824SCathy.Zhou@Sun.COM setattr.ld_confid = conf.ds_confid;
6606263Sseb (void) strlcpy(setattr.ld_attr, attr, MAXLINKATTRLEN);
6616263Sseb setattr.ld_attrsz = attrsz;
6626263Sseb setattr.ld_type = type;
6636263Sseb bcopy(attrval, &setattr.ld_attrval, attrsz);
6645895Syz147064
66512824SCathy.Zhou@Sun.COM return (dladm_door_call(handle, &setattr, sizeof (setattr),
66612824SCathy.Zhou@Sun.COM &retval, &sz));
6675895Syz147064 }
6685895Syz147064
6695895Syz147064 /*
6705895Syz147064 * Unset the given attr the given link.
6715895Syz147064 */
6725895Syz147064 dladm_status_t
dladm_unset_conf_field(dladm_handle_t handle,dladm_conf_t conf,const char * attr)6738453SAnurag.Maskey@Sun.COM dladm_unset_conf_field(dladm_handle_t handle, dladm_conf_t conf,
6748453SAnurag.Maskey@Sun.COM const char *attr)
6755895Syz147064 {
6765895Syz147064 dlmgmt_door_unsetattr_t unsetattr;
6775895Syz147064 dlmgmt_unsetattr_retval_t retval;
67812824SCathy.Zhou@Sun.COM size_t sz = sizeof (retval);
6795895Syz147064
6806263Sseb if (attr == NULL)
6815895Syz147064 return (DLADM_STATUS_BADARG);
6825895Syz147064
68312824SCathy.Zhou@Sun.COM if (conf.ds_readonly)
68412824SCathy.Zhou@Sun.COM return (DLADM_STATUS_DENIED);
68512824SCathy.Zhou@Sun.COM
6865895Syz147064 unsetattr.ld_cmd = DLMGMT_CMD_UNSETATTR;
68712824SCathy.Zhou@Sun.COM unsetattr.ld_confid = conf.ds_confid;
6885895Syz147064 (void) strlcpy(unsetattr.ld_attr, attr, MAXLINKATTRLEN);
6895895Syz147064
69012824SCathy.Zhou@Sun.COM return (dladm_door_call(handle, &unsetattr, sizeof (unsetattr),
69112824SCathy.Zhou@Sun.COM &retval, &sz));
6925895Syz147064 }
6935895Syz147064
6945895Syz147064 /*
6955895Syz147064 * Remove the given link ID and its entry from the data link configuration
6965895Syz147064 * repository.
6975895Syz147064 */
6985895Syz147064 dladm_status_t
dladm_remove_conf(dladm_handle_t handle,datalink_id_t linkid)6998453SAnurag.Maskey@Sun.COM dladm_remove_conf(dladm_handle_t handle, datalink_id_t linkid)
7005895Syz147064 {
7015895Syz147064 dlmgmt_door_removeconf_t removeconf;
7025895Syz147064 dlmgmt_removeconf_retval_t retval;
70312824SCathy.Zhou@Sun.COM size_t sz = sizeof (retval);
7045895Syz147064
7055895Syz147064 removeconf.ld_cmd = DLMGMT_CMD_REMOVECONF;
7065895Syz147064 removeconf.ld_linkid = linkid;
7075895Syz147064
7088453SAnurag.Maskey@Sun.COM return (dladm_door_call(handle, &removeconf, sizeof (removeconf),
70912824SCathy.Zhou@Sun.COM &retval, &sz));
7105895Syz147064 }
7115895Syz147064
7125895Syz147064 /*
7135895Syz147064 * Free the contents of the link structure.
7145895Syz147064 */
7155895Syz147064 void
dladm_destroy_conf(dladm_handle_t handle,dladm_conf_t conf)7168453SAnurag.Maskey@Sun.COM dladm_destroy_conf(dladm_handle_t handle, dladm_conf_t conf)
7175895Syz147064 {
71812824SCathy.Zhou@Sun.COM dlmgmt_door_destroyconf_t dconf;
7195895Syz147064 dlmgmt_destroyconf_retval_t retval;
72012824SCathy.Zhou@Sun.COM size_t sz = sizeof (retval);
7215895Syz147064
72212824SCathy.Zhou@Sun.COM if (conf.ds_readonly) {
72312824SCathy.Zhou@Sun.COM nvlist_free(conf.ds_nvl);
72412824SCathy.Zhou@Sun.COM } else {
72512824SCathy.Zhou@Sun.COM if (conf.ds_confid == DLADM_INVALID_CONF)
72612824SCathy.Zhou@Sun.COM return;
7275895Syz147064
72812824SCathy.Zhou@Sun.COM dconf.ld_cmd = DLMGMT_CMD_DESTROYCONF;
72912824SCathy.Zhou@Sun.COM dconf.ld_confid = conf.ds_confid;
73012824SCathy.Zhou@Sun.COM
73112824SCathy.Zhou@Sun.COM (void) dladm_door_call(handle, &dconf, sizeof (dconf),
73212824SCathy.Zhou@Sun.COM &retval, &sz);
73312824SCathy.Zhou@Sun.COM }
7345895Syz147064 }
73510616SSebastien.Roy@Sun.COM
73610616SSebastien.Roy@Sun.COM dladm_status_t
dladm_zone_boot(dladm_handle_t handle,zoneid_t zoneid)73710616SSebastien.Roy@Sun.COM dladm_zone_boot(dladm_handle_t handle, zoneid_t zoneid)
73810616SSebastien.Roy@Sun.COM {
73910616SSebastien.Roy@Sun.COM dlmgmt_door_zoneboot_t zoneboot;
74010616SSebastien.Roy@Sun.COM dlmgmt_zoneboot_retval_t retval;
74112824SCathy.Zhou@Sun.COM size_t sz = sizeof (retval);
74210616SSebastien.Roy@Sun.COM
74310616SSebastien.Roy@Sun.COM zoneboot.ld_cmd = DLMGMT_CMD_ZONEBOOT;
74410616SSebastien.Roy@Sun.COM zoneboot.ld_zoneid = zoneid;
74512824SCathy.Zhou@Sun.COM return (dladm_door_call(handle, &zoneboot, sizeof (zoneboot),
74612824SCathy.Zhou@Sun.COM &retval, &sz));
74710616SSebastien.Roy@Sun.COM }
74810616SSebastien.Roy@Sun.COM
74910616SSebastien.Roy@Sun.COM dladm_status_t
dladm_zone_halt(dladm_handle_t handle,zoneid_t zoneid)75010616SSebastien.Roy@Sun.COM dladm_zone_halt(dladm_handle_t handle, zoneid_t zoneid)
75110616SSebastien.Roy@Sun.COM {
75210616SSebastien.Roy@Sun.COM dlmgmt_door_zonehalt_t zonehalt;
75310616SSebastien.Roy@Sun.COM dlmgmt_zonehalt_retval_t retval;
75412824SCathy.Zhou@Sun.COM size_t sz = sizeof (retval);
75510616SSebastien.Roy@Sun.COM
75610616SSebastien.Roy@Sun.COM zonehalt.ld_cmd = DLMGMT_CMD_ZONEHALT;
75710616SSebastien.Roy@Sun.COM zonehalt.ld_zoneid = zoneid;
75812824SCathy.Zhou@Sun.COM return (dladm_door_call(handle, &zonehalt, sizeof (zonehalt),
75912824SCathy.Zhou@Sun.COM &retval, &sz));
76010616SSebastien.Roy@Sun.COM }
761