dlmgmt_door.c revision d62bc4badc1c1f1549c961cfb8b420e650e1272b
/*
* 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,
* which will be handled by dlmgmt_call_handler(); or they can come from the
* kernel, which will be handled by dlmgmt_upcall_handler().
*/
#include <assert.h>
#include <stdlib.h>
#include <alloca.h>
#include <strings.h>
#include <libdlmgmt.h>
#include "dlmgmt_impl.h"
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 {
}
}
/*
* Note that the caller needs to free the memory of *retvalp, when it returns
* success.
*/
static int
{
int err = 0;
/*
* Hold the reader lock to access the link
*/
/*
* The link does not exist.
*/
goto done;
}
done:
return (err);
}
static void
{
switch (cmd) {
case DLMGMT_CMD_DLS_CREATE: {
break;
}
case DLMGMT_CMD_DLS_UPDATE: {
break;
}
case DLMGMT_CMD_DLS_GETATTR: {
int err;
} else {
/*
* For the successful case, retvalp points to
* memory that was allocated with malloc. But, since
* door_return never returns, that memory gets leaked.
* Use alloca and free retvalp.
*/
}
break;
}
case DLMGMT_CMD_DLS_DESTROY: {
break;
}
case DLMGMT_CMD_GETNAME: {
break;
}
case DLMGMT_CMD_GETLINKID: {
break;
}
case DLMGMT_CMD_GETNEXT: {
break;
}
default: {
struct dlmgmt_null_retval_s retval;
break;
}
}
}
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;
if (argsz < sizeof (dlmgmt_door_setattr_t) ||
return;
}
/*
* 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 int
{
int err = 0;
/*
* Hold the writer lock to update the dlconf table.
*/
goto done;
}
done:
return (err);
}
static void
{
switch (cmd) {
case DLMGMT_CMD_CREATE_LINKID: {
break;
}
case DLMGMT_CMD_DESTROY_LINKID: {
break;
}
case DLMGMT_CMD_REMAP_LINKID: {
break;
}
case DLMGMT_CMD_UP_LINKID: {
break;
}
case DLMGMT_CMD_CREATECONF: {
break;
}
case DLMGMT_CMD_SETATTR: {
break;
}
case DLMGMT_CMD_UNSETATTR: {
break;
}
case DLMGMT_CMD_WRITECONF: {
break;
}
case DLMGMT_CMD_REMOVECONF: {
break;
}
case DLMGMT_CMD_DESTROYCONF: {
break;
}
case DLMGMT_CMD_READCONF: {
break;
}
case DLMGMT_CMD_GETATTR: {
int err;
} else {
/*
* For the successful case, retvalp points to memory
* that was allocated in dlmgmt_getattr(). Since
* door_return never returns, that memory would get
* leaked. So we use alloca instead, and free retvalp.
*/
}
break;
}
default: {
struct dlmgmt_null_retval_s retval;
break;
}
}
}
/* ARGSUSED */
void
{
if (cmd < DLMGMT_CMD_BASE) {
/*
* Upcall request from the dls module.
*/
} else {
/*
* Door call request from libdladm.
*/
}
}