dlmgmt_door.c revision 308903890e892f9c21ee582e3a52fdd67e52870b
/*
* 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
* 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 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* Main door handler functions used by dlmgmtd to process the different door
* call requests. Door call requests can come from the user-land applications,
* or from the kernel.
*/
#include <assert.h>
#include <alloca.h>
#include <errno.h>
#include <priv_utils.h>
#include <stdlib.h>
#include <strings.h>
#include <libdlmgmt.h>
#include "dlmgmt_impl.h"
typedef void dlmgmt_door_handler_t(void *, void *);
typedef struct dlmgmt_door_info_s {
static dlmgmt_link_t *
dlmgmt_getlink_by_dev(char *devname)
{
return (linkp);
}
}
return (NULL);
}
static void
{
char link[MAXLINKNAMELEN];
int err;
/*
* Determine whether this link is persistent. Note that this request
* is coming from kernel so this link must be active.
*/
/*
* Hold the writer lock to update the link table.
*/
/*
* Check to see whether this is the reattachment of an existing
* physical link. If so, return its linkid.
*/
if ((class == DATALINK_CLASS_PHYS) &&
if (err != 0)
goto done;
if (err != 0)
goto done;
goto done;
}
/*
* The link name already exists. Return error if this is a
* non-physical link (in that case, the link name must be
* the same as the given name).
*/
if (class != DATALINK_CLASS_PHYS)
goto done;
/*
* The physical link's name already exists, request
* a suggested link name: net<nextppa>
*/
if (err != 0)
goto done;
}
if (err != 0)
goto done;
/*
* This is a new link. Only need to persist link attributes for
* physical links.
*/
if (class == DATALINK_CLASS_PHYS &&
sizeof (uint64_t), DLADM_TYPE_UINT64)) != 0) ||
sizeof (uint64_t), DLADM_TYPE_UINT64)) != 0))) {
goto done;
}
done:
}
if (err == 0)
}
static void
{
int err = 0;
/*
* Hold the writer lock to update the link table.
*/
/*
* Check to see whether this is the reattachment of an existing
* physical link. If so, return its linkid.
*/
goto done;
}
/*
* Assume a DL_ETHER link ce0, a DL_WIFI link ath0
* 1. # dladm rename-link ce0 net0
* 2. DR out ce0. net0 is down.
* 3. use rename-link to have the ath0 device inherit
* the configuration from net0
* # dladm rename-link ath0 net0
* 4. DR in ath0.
* As ath0 and ce0 do not have the same media type, ath0
* cannot inherit the configuration of net0.
*/
/*
* Return the media type of the existing link to indicate the
* reason for the name conflict.
*/
goto done;
}
if (update->ld_novanity &&
/*
* Return an error if this is a physical link that does not
* support vanity naming, but the link name is not the same
* as the given device name.
*/
goto done;
}
done:
}
static void
{
int err = 0;
/*
* Hold the writer lock to update the link table.
*/
goto done;
}
goto done;
}
if (dflags != 0)
dflags |= DLMGMT_PERSIST;
goto done;
}
done:
}
static void
{
int err = 0;
/*
* Hold the reader lock to access the link
*/
/*
* The link does not exists.
*/
goto done;
}
goto done;
}
done:
}
static void
{
int err = 0;
/*
* Hold the reader lock to access the link
*/
/*
* The link does not exists.
*/
goto done;
}
done:
}
static void
{
int err = 0;
/*
* Hold the reader lock to access the link
*/
break;
}
} else {
}
}
static void
{
/*
* Hold the reader lock to access the link
*/
/*
* The link does not exist.
*/
goto done;
}
done:
}
static void
{
char link[MAXLINKNAMELEN];
int err;
/*
* Hold the writer lock to update the dlconf table.
*/
if (err != 0)
goto done;
} else {
&linkp);
}
if (err == 0) {
/*
* Keep the active mapping.
*/
}
done:
}
static void
{
int err = 0;
/*
* Hold the writer lock to update the link table.
*/
goto done;
}
goto done;
/*
* Delete the active mapping.
*/
if (flags & DLMGMT_ACTIVE)
done:
}
/*
* Remap a linkid to a given link name, i.e., rename an existing link1
* (ld_linkid) to a non-existent link2 (ld_link): rename link1's name to
* the given link name.
*/
static void
{
int err = 0;
return;
}
/*
* Hold the writer lock to update the link table.
*/
goto done;
}
goto done;
}
/*
* If we renamed a temporary link, update the temporary repository.
*/
done:
}
static void
{
int err = 0;
/*
* Hold the writer lock to update the link table.
*/
goto done;
}
goto done;
}
done:
}
static void
{
int err;
/*
* Hold the writer lock to update the dlconf table.
*/
goto done;
}
done:
}
static void
{
int err = 0;
/*
* Hold the writer lock to update the dlconf table.
*/
goto done;
}
done:
}
static void
{
int err = 0;
/*
* Hold the writer lock to update the dlconf table.
*/
goto done;
}
done:
}
/*
* Note that dlmgmt_readconf() returns a conf ID of a conf AVL tree entry,
* which is managed by dlmgmtd. The ID is used to find the conf entry when
* dlmgmt_write_conf() is called. The conf entry contains an ld_gen value
* (which is the generation number - ll_gen) of the dlmgmt_link_t at the time
* of dlmgmt_readconf(), and ll_gen changes every time the dlmgmt_link_t
* changes its attributes. Therefore, dlmgmt_write_conf() can compare ld_gen
* in the conf entry against the latest dlmgmt_link_t ll_gen value to see if
* anything has changed between the dlmgmt_read_conf() and dlmgmt_writeconf()
* calls. If so, EAGAIN is returned. This mechanism can ensures atomicity
* across the pair of dladm_read_conf() and dladm_write_conf() calls.
*/
static void
{
int err = 0;
/*
* Hold the read lock to access the dlconf table.
*/
goto done;
}
/*
* Hold the writer lock to update the link table.
*/
/*
* The link does not exist.
*/
goto done;
}
/*
* Something has changed the link configuration; try again.
*/
goto done;
}
/*
* Delete the old attribute list.
*/
}
/*
* Set the new attribute.
*/
goto done;
}
}
done:
}
static void
{
int err;
}
static void
{
int err = 0;
/*
* Hold the writer lock to update the dlconf table.
*/
goto done;
}
done:
}
/*
* See the comments above dladm_write_conf() to see how ld_gen is used to
* ensure atomicity across the {dlmgmt_readconf(), dlmgmt_writeconf()} pair.
*/
static void
{
int err = 0;
/*
* Hold the writer lock to update the dlconf table.
*/
/*
* Hold the reader lock to access the link
*/
/*
* The persistent link configuration does not exists.
*/
goto done;
}
goto done;
}
goto done;
}
}
done:
}
/*
* Note: the caller must free *retvalpp in case of success.
*/
static void
{
/*
* Hold the read lock to access the dlconf table.
*/
goto done;
}
done:
}
static void
{
/*
* Ignore wifi links until wifi property ioctls are converted
* to generic property ioctls. This avoids deadlocks due to
* not the DLD control device.
*/
else
if (do_linkprop)
}
static dlmgmt_door_info_t i_dlmgmt_door_info_tbl[] = {
sizeof (dlmgmt_create_retval_t), dlmgmt_upcall_create },
sizeof (dlmgmt_getattr_retval_t), dlmgmt_upcall_getattr },
sizeof (dlmgmt_destroy_retval_t), dlmgmt_upcall_destroy },
sizeof (dlmgmt_getname_retval_t), dlmgmt_getname },
sizeof (dlmgmt_getlinkid_retval_t), dlmgmt_getlinkid },
sizeof (dlmgmt_getnext_retval_t), dlmgmt_getnext },
sizeof (dlmgmt_update_retval_t), dlmgmt_upcall_update },
sizeof (dlmgmt_createid_retval_t), dlmgmt_createid },
sizeof (dlmgmt_destroyid_retval_t), dlmgmt_destroyid },
sizeof (dlmgmt_remapid_retval_t), dlmgmt_remapid },
sizeof (dlmgmt_createconf_retval_t), dlmgmt_createconf },
sizeof (dlmgmt_readconf_retval_t), dlmgmt_readconf },
sizeof (dlmgmt_writeconf_retval_t), dlmgmt_writeconf },
sizeof (dlmgmt_upid_retval_t), dlmgmt_upid },
sizeof (dlmgmt_setattr_retval_t), dlmgmt_setattr },
sizeof (dlmgmt_unsetattr_retval_t), dlmgmt_unsetconfattr },
sizeof (dlmgmt_removeconf_retval_t), dlmgmt_removeconf },
sizeof (dlmgmt_destroyconf_retval_t), dlmgmt_destroyconf },
sizeof (dlmgmt_getattr_retval_t), dlmgmt_getattr },
sizeof (dlmgmt_door_linkprop_init_t),
sizeof (dlmgmt_linkprop_init_retval_t),
};
#define DLMGMT_INFO_TABLE_SIZE (sizeof (i_dlmgmt_door_info_tbl) / \
sizeof (i_dlmgmt_door_info_tbl[0]))
/* ARGSUSED */
void
{
void *retvalp;
int err;
int i;
for (i = 0; i < DLMGMT_INFO_TABLE_SIZE; i++) {
if (i_dlmgmt_door_info_tbl[i].di_cmd ==
infop = i_dlmgmt_door_info_tbl + i;
break;
}
}
goto fail;
}
const priv_set_t *eset;
if (door_ucred(&cred) != 0) {
goto fail;
}
goto fail;
}
}
/*
* We cannot use malloc() here because door_return never returns, and
* memory allocated by malloc() would get leaked. Use alloca() instead.
*/
return;
fail:
}