/*
* 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
*/
/*
*/
#include <string.h>
#include <strings.h>
#include <sys/dls_mgmt.h>
#include <errno.h>
#include <unistd.h>
#include <libdladm_impl.h>
#include <libdllink.h>
#include <libdlaggr.h>
#include <libdlsim.h>
/* New simnet instance creation */
static dladm_status_t
{
int rc;
}
if (rc < 0)
if (status != DLADM_STATUS_OK)
return (status);
return (status);
}
/* Modify existing simnet instance */
static dladm_status_t
{
int rc;
if (rc < 0)
return (status);
}
/* Delete simnet instance */
static dladm_status_t
{
int rc;
if (rc < 0)
return (status);
}
/* Retrieve simnet instance information */
static dladm_status_t
{
int rc;
if (rc < 0) {
return (status);
}
return (status);
}
/* Retrieve simnet configuratin */
static dladm_status_t
{
&conf)) != DLADM_STATUS_OK)
return (status);
sizeof (u64));
if (status != DLADM_STATUS_OK)
goto done;
sizeof (u64));
if (status != DLADM_STATUS_OK)
goto done;
sizeof (macstr));
if (status != DLADM_STATUS_OK)
goto done;
/* Peer field is optional and only set when peer is attached */
sizeof (simnetpeer)) == DLADM_STATUS_OK) {
} else {
}
done:
return (status);
}
{
if (!(flags & DLADM_OPT_ACTIVE))
return (DLADM_STATUS_NOTSUP);
&simnet_id)) != DLADM_STATUS_OK)
return (status);
if (status != DLADM_STATUS_OK)
goto done;
if (!(flags & DLADM_OPT_PERSIST))
goto done;
if (status != DLADM_STATUS_OK) {
goto done;
}
done:
if (status != DLADM_STATUS_OK) {
}
return (status);
}
/* Update existing simnet configuration */
static dladm_status_t
{
if (status != DLADM_STATUS_OK)
return (status);
/* First clear previous peer if any in configuration */
if (peer_simnet_id != DATALINK_INVALID_LINKID) {
sizeof (simnetpeer))) == DLADM_STATUS_OK) {
}
if (status != DLADM_STATUS_OK)
goto fail;
}
fail:
return (status);
}
/* Modify attached simnet peer */
{
if (!(flags & DLADM_OPT_ACTIVE))
return (DLADM_STATUS_NOTSUP);
return (DLADM_STATUS_BADARG);
if (class != DATALINK_CLASS_SIMNET)
return (DLADM_STATUS_BADARG);
if (peer_simnet_id != DATALINK_INVALID_LINKID) {
return (DLADM_STATUS_BADARG);
if (class != DATALINK_CLASS_SIMNET)
return (DLADM_STATUS_BADARG);
/* Check to ensure the peer link has identical flags */
if (peerlinkflags != linkflags)
return (DLADM_STATUS_BADARG);
}
/* Retrieve previous attrs before modification */
flags)) != DLADM_STATUS_OK)
return (status);
return (status);
/* First we clear link's existing peer field in config */
if (status != DLADM_STATUS_OK)
return (status);
/* Clear the previous peer link's existing peer field in config */
if (status != DLADM_STATUS_OK)
return (status);
}
/* Update the configuration in both simnets with any new peer link */
if (peer_simnet_id != DATALINK_INVALID_LINKID) {
if (status == DLADM_STATUS_OK)
}
return (status);
}
{
return (DLADM_STATUS_BADARG);
if (class != DATALINK_CLASS_SIMNET)
return (DLADM_STATUS_BADARG);
/* Check current simnet attributes before deletion */
flags)) != DLADM_STATUS_OK)
return (status);
if (flags & DLADM_OPT_ACTIVE) {
if (status == DLADM_STATUS_OK) {
NULL, 0, DLADM_OPT_ACTIVE);
} else if (status != DLADM_STATUS_NOTFOUND) {
return (status);
}
}
if (flags & DLADM_OPT_PERSIST) {
/* Update any attached peer configuration */
}
return (status);
}
/* Retrieve simnet information either active or from configuration */
{
return (DLADM_STATUS_BADARG);
if (class != DATALINK_CLASS_SIMNET)
return (DLADM_STATUS_BADARG);
if (flags & DLADM_OPT_ACTIVE) {
/*
* If no active simnet found then return any simnet
* from stored config if requested.
*/
if (status == DLADM_STATUS_NOTFOUND &&
(flags & DLADM_OPT_PERSIST))
return (status);
} else if (flags & DLADM_OPT_PERSIST) {
} else {
return (DLADM_STATUS_BADARG);
}
}
/* Bring up simnet from stored configuration */
static int
{
if (status != DLADM_STATUS_OK)
goto done;
if (status != DLADM_STATUS_OK)
goto done;
/*
* When bringing up check if the peer link is available, if it
* is then modify the simnet and attach the peer link.
*/
DLADM_OPT_ACTIVE) == DLADM_STATUS_OK)) {
if (status != DLADM_STATUS_OK)
goto done;
}
goto done;
}
done:
return (DLADM_WALK_CONTINUE);
}
/* Bring up simnet instance(s) from configuration */
/* ARGSUSED */
{
if (simnet_id == DATALINK_ALL_LINKID) {
return (DLADM_STATUS_OK);
} else {
return (status);
}
}
/* Store simnet configuration */
static dladm_status_t
{
return (status);
if (status != DLADM_STATUS_OK)
goto done;
DLADM_TYPE_UINT64, &u64);
if (status != DLADM_STATUS_OK)
goto done;
DLADM_TYPE_UINT64, &u64);
if (status != DLADM_STATUS_OK)
goto done;
done:
return (status);
}