/*
* 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 <stdlib.h>
#include <string.h>
#include <strings.h>
#include <errno.h>
#include <ctype.h>
#include <stddef.h>
#include <fcntl.h>
#include <unistd.h>
#include <libdevinfo.h>
#include <zone.h>
#include <libdllink.h>
#include <libdladm_impl.h>
#include <libdlflow_impl.h>
#include <libdlwlan_impl.h>
#include <libdlwlan.h>
#include <libdlvlan.h>
#include <libdlvnic.h>
#include <libdlflow.h>
#include <libdlib.h>
#include <libintl.h>
#include <dlfcn.h>
#include <link.h>
#include <inet/wifi_ioctl.h>
#include <libdladm.h>
#include <libdlstat.h>
#include <inttypes.h>
#include <sys/ethernet.h>
#include <sys/sysmacros.h>
#include <libdlbridge.h>
#include <stp_in.h>
#include <net/if_types.h>
#include <libinetutil.h>
#include <pool.h>
#include <libdlmgmt.h>
#include <libnvpair.h>
#include <liblldp.h>
/*
* The linkprop get() callback.
* - pd: pointer to the prop_desc_t
* - propstrp: a property string array to keep the returned property.
* Caller allocated.
* - cntp: number of returned properties.
* Caller also uses it to indicate how many it expects.
*/
struct prop_desc;
/*
* The linkprop set() callback.
* - propval: a val_desc_t array which keeps the property values to be set.
* - cnt: number of properties to be set.
* - flags: additional flags passed down the system call.
*
* pd_set takes val_desc_t given by pd_check(), translates it into
* a format suitable for kernel consumption. This may require allocation
* of ioctl buffers etc. pd_set() may call another common routine (used
* by all other pd_sets) which invokes the ioctl.
*/
/*
* The linkprop check() callback.
* - propstrp: property string array which keeps the property to be checked.
* - cnt: number of properties.
* - propval: return value; the property values of the given property strings.
*
* pd_check checks that the input values are valid. It does so by
* iteraring through the pd_modval list for the property. If
* the modifiable values cannot be expressed as a list, a pd_check
* specific to this property can be used. If the input values are
* verified to be valid, pd_check allocates a val_desc_t and fills it
* with either a val_desc_t found on the pd_modval list or something
* generated on the fly.
*/
typedef struct link_attr_s {
char *pp_name;
} link_attr_t;
typedef struct dladm_linkprop_args_s {
const char *, uint_t, dladm_status_t *);
const char *, char **, uint_t *, dladm_prop_type_t,
uint_t);
static const char *dladm_perm2str(uint_t, char *);
static link_attr_t *dladm_name2prop(const char *);
struct prop_desc {
/*
* link property name
*/
char *pd_name;
/*
* default property value, can be set to { "", NULL }
*/
/*
* list of optional property values, can be NULL.
*
* This is set to non-NULL if there is a list of possible property
* values. pd_optval would point to the array of possible values.
*/
/*
* count of the above optional property values. 0 if pd_optval is NULL.
*/
/*
* callback to set link property; set to NULL if this property is
* read-only and may be called before or after permanent update; see
* flags.
*/
/*
* callback to get modifiable link property
*/
/*
* callback to get current link property
*/
/*
* callback to validate link property value, set to NULL if pd_optval
* is not NULL. In that case, validate the value by comparing it with
* the pd_optval. Return a val_desc_t array pointer if the value is
* valid.
*/
/*
* indicate link classes this property applies to.
*/
/*
* indicate link media type this property applies to.
*/
};
/*
* Supported link properties enumerated in the prop_table[] array are
* computed using the callback functions in that array. To compute the
* property value, multiple distinct system calls may be needed (e.g.,
* rates). The link_attr[] table enumerates the interfaces to the kernel,
*/
{ MAC_PROP_FLOWCTRL_EFFECTIVE, sizeof (link_flowctrl_t),
"flowctrl-effective"},
/* wl_rates_t has variable length */
/* wl_rates_t has variable length */
/* wl_wpa_ess_t has variable length */
/* wl_wpa_ie_t has variable length */
{ MAC_PROP_VLAN_ANNOUNCE, sizeof (mac_vlan_announce_t),
"vlan-announce"},
{ MAC_PROP_RESOURCE_EFF, sizeof (mac_resource_props_t),
"resource-effective"},
{ MAC_PROP_MAX_TX_RINGS_AVAIL, sizeof (uint_t),
"txrings-available"},
{ MAC_PROP_MAX_RX_RINGS_AVAIL, sizeof (uint_t),
"rxrings-available"},
{ MAC_PROP_PRIVATE, 0, "driver-private"}
};
typedef struct bridge_public_prop_s {
const char *bpp_name;
int bpp_code;
{ "stp", PT_CFG_NON_STP },
{ "stp_priority", PT_CFG_PRIO },
{ "stp_cost", PT_CFG_COST },
{ "stp_edge", PT_CFG_EDGE },
{ "stp_p2p", PT_CFG_P2P },
{ "stp_mcheck", PT_CFG_MCHECK },
{ NULL, 0 }
};
{ "half", LINK_DUPLEX_HALF },
{ "full", LINK_DUPLEX_HALF }
};
{ "up", LINK_STATE_UP },
{ "down", LINK_STATE_DOWN }
};
{ "1", 1 },
{ "0", 0 }
};
{ "no", LINK_FLOWCTRL_NONE },
{ "tx", LINK_FLOWCTRL_TX },
{ "rx", LINK_FLOWCTRL_RX },
{ "bi", LINK_FLOWCTRL_BI },
{ "pfc", LINK_FLOWCTRL_PFC },
{ "auto", LINK_FLOWCTRL_AUTO }
};
{ "low", MPL_LOW },
{ "medium", MPL_MEDIUM },
{ "high", MPL_HIGH }
};
{ "normal", LINK_TAGMODE_NORMAL },
{ "vlanonly", LINK_TAGMODE_VLANONLY }
};
{ "mac-nospoof", MPT_MACNOSPOOF },
{ "restricted", MPT_RESTRICTED },
{ "ip-nospoof", MPT_IPNOSPOOF },
{ "dhcp-nospoof", MPT_DHCPNOSPOOF },
};
{ "on", DLADM_WLAN_RADIO_ON },
{ "off", DLADM_WLAN_RADIO_OFF }
};
{ "off", DLADM_WLAN_PM_OFF },
{ "fast", DLADM_WLAN_PM_FAST },
{ "max", DLADM_WLAN_PM_MAX }
};
{ "true", P2P_FORCE_TRUE },
{ "false", P2P_FORCE_FALSE },
{ "auto", P2P_AUTO }
};
{ "off", MAC_VLAN_ANNOUNCE_OFF },
{ "gvrp", MAC_VLAN_ANNOUNCE_GVRP }
};
{ "cm", DLADM_PART_CM_MODE },
{ "ud", DLADM_PART_UD_MODE },
};
{ "none", MVE_ENCODING_NONE },
{ "oracle_v1", MVE_ORACLE_VSIMGRID_V1 }
};
{ "on", LINK_LRO_ON },
{ "off", LINK_LRO_OFF },
{ "auto", LINK_LRO_AUTO }
};
{ "on", B_TRUE },
{ "off", B_FALSE }
};
{ "channel", { NULL, 0 },
get_channel, NULL, 0,
get_powermode, NULL, 0,
get_rate, check_rate, 0,
{ "duplex", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "adv_autoneg_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "flowctrl", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "flowctrl-effective", { "--", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "adv_10gfdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "en_10gfdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "adv_1000fdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "en_1000fdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "adv_1000hdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "en_1000hdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "adv_100fdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "en_100fdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "adv_100hdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "en_100hdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "adv_10fdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "en_10fdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "adv_10hdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
{ "en_10hdx_cap", { "", 0 },
0, DATALINK_CLASS_PHYS, DL_ETHER },
get_cpus, check_cpus, 0,
{ "cpus-effective", { "--", 0 },
get_cpus, 0, 0,
{ "rxfanout-effective", { "--", 0 },
get_rxfanout, NULL, 0,
{ "pool-effective", { "--", 0 },
get_pool, 0, 0,
NULL, 0,
DL_ETHER },
{ "forward", { "1", 1 },
get_uint32, check_uint32, 0,
check_uint32, 0,
check_uint32, 0,
{ "stp", { "1", 1 },
{ "stp_edge", { "1", 1 },
{ "stp_mcheck", { "0", 0 },
{ "mac-address", { "", 0 },
{ "allowed-ips", { "--", 0 },
{ "allowed-dhcp-cids", { "--", 0 },
{ "rxrings-effective", { "--", 0 },
get_rxrings, NULL, 0,
{ "txrings-effective", { "--", 0 },
get_txrings, NULL, 0,
get_pfcmap, check_pfcmap, 0,
{ "pfcmap-lcl-effective", { NULL, 0 },
{ "pfcmap-rmt-effective", { NULL, 0 },
get_pfcmap_rmt, NULL, 0,
DL_ETHER},
DL_ETHER},
DL_ETHER},
{ "vsi-mgrid-enc",
{ "oracle_v1", MVE_ORACLE_VSIMGRID_V1 },
{ "lro", { "auto", 0 },
{ "lro-effective", { "off", 0 },
};
{"maxbw", extract_maxbw},
{"priority", extract_priority},
{"cpus", extract_cpus},
{"cpus-effective", extract_cpus},
{"rxfanout", extract_rxfanout},
{"rxfanout-effective", extract_rxfanout},
{"pool", extract_pool},
{"pool-effective", extract_pool},
{"protection", extract_protection},
{"allowed-ips", extract_allowedips},
{"allowed-dhcp-cids", extract_allowedcids},
{"rxrings", extract_rxrings},
{"rxrings-effective", extract_rxrings},
{"txrings", extract_txrings},
{"txrings-effective", extract_txrings},
{"vsi-typeid", extract_vsitypeid},
{"vsi-typeid-effective", extract_vsitypeid},
{"vsi-vers", extract_vsiversion},
{"vsi-vers-effective", extract_vsiversion},
{"vsi-mgrid", extract_vsimgrid},
{"vsi-mgrid-effective", extract_vsimgrid},
{"vsi-mgrid-enc", extract_vsimgrenc},
{"vsi-mgrid-enc-effective", extract_vsimgrenc},
{"pfcmap", extract_pfcmap},
{"pfcmap-lcl-effective", extract_pfcmap},
{"cos", extract_cos},
{"etsbw-lcl", extract_etsbw},
{"etsbw-lcl-effective", extract_etsbw}
};
sizeof (resource_prop_t))
/*
* when retrieving private properties, we pass down a buffer with
* DLADM_PROP_BUF_CHUNK of space for the driver to return the property value.
*/
const char *, char **, uint_t);
const char *, char **, uint_t *);
datalink_id_t, void *, int (*)(dladm_handle_t,
datalink_id_t, const char *, void *));
static prop_desc_t *i_dladm_get_prop_desc(const char *);
/*
* Unfortunately, MAX_SCAN_SUPPORT_RATES is too small to allow all
* rates to be retrieved. However, we cannot increase it at this
* time because it will break binary compatibility with unbundled
* WiFi drivers and utilities. So for now we define an additional
* constant, MAX_SUPPORT_RATES, to allow all rates to be retrieved.
*/
/* ARGSUSED */
static dladm_status_t
{
int i, j;
for (j = 0; j < val_cnt; j++) {
for (i = 0; i < pdp->pd_noptval; i++) {
if (strcasecmp(prop_val[j],
break;
}
}
if (i == pdp->pd_noptval)
return (DLADM_STATUS_BADVAL);
}
return (DLADM_STATUS_OK);
}
static dladm_status_t
{
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_TEMPONLY);
if (flags & DLADM_OPT_PERSIST) {
/*
* Before setting the link property in both active and
* persistent modes, first check if we can persist
* the link property change. Otherwise, we fail this
* call to set the active link property. For Auto VNICs
* which are temporary, this call will fail.
*/
return (DLADM_STATUS_TEMPONLY);
}
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_OK);
return (DLADM_STATUS_PROPRDONLY);
return (DLADM_STATUS_PROPRDONLY);
return (DLADM_STATUS_NOMEM);
} else {
}
if (status != DLADM_STATUS_OK)
goto done;
} else {
return (DLADM_STATUS_NOTSUP);
cnt = 1;
return (DLADM_STATUS_NOMEM);
if (defval) {
sizeof (val_desc_t));
if (status != DLADM_STATUS_OK)
goto done;
}
return (DLADM_STATUS_NOMEM);
} else {
return (status);
}
}
} else {
}
if (needfree) {
for (i = 0; i < cnt; i++)
}
done:
return (status);
}
static dladm_status_t
{
int i;
NULL, 0);
if (status != DLADM_STATUS_OK)
return (status);
for (i = 0; i < DLADM_MAX_PROPS; i++) {
continue;
status = s;
break;
} else {
if (s != DLADM_STATUS_OK &&
s != DLADM_STATUS_NOTSUP)
status = s;
}
}
if (!found) {
if (prop_name[0] == '_') {
/* other private properties */
} else {
}
}
return (status);
}
/*
*/
{
return (DLADM_STATUS_BADARG);
}
/*
* Check for valid link property against the flags passed
* and set the link property when active flag is passed.
*/
if (status != DLADM_STATUS_OK)
return (status);
if (flags & DLADM_OPT_PERSIST) {
/*
* don't persist properties with PD_DONT_PERSIST flag is set.
* these properties are persisted in SCF.
*/
return (DLADM_STATUS_OK);
0, flags, 0);
}
}
}
return (status);
}
static int
{
if (status != DLADM_STATUS_OK &&
return (DLADM_WALK_CONTINUE);
}
static int
void *arg)
{
return (DLADM_WALK_CONTINUE);
}
/*
* Walk all link properties and (re)set them to the default value.
*/
{
if (flags == 0)
return (DLADM_STATUS_BADARG);
if (linkid == DATALINK_ALL_LINKID) {
flags);
} else {
}
return (dla.dla_status);
}
/*
* Walk all link properties of the given specific link.
*
* Note: this function currently lacks the ability to walk _all_ private
* properties if the link, because there is no kernel interface to
* retrieve all known private property names. Once such an interface
* is added, this function should be fixed accordingly.
*/
{
int i;
return (DLADM_STATUS_BADARG);
NULL, 0);
if (status != DLADM_STATUS_OK)
return (status);
/* public */
for (i = 0; i < DLADM_MAX_PROPS; i++) {
continue;
continue;
break;
}
}
/* private */
return (status);
}
/*
* Get linkprop of the given specific link.
*/
{
int i;
if (type == DLADM_PROP_VAL_DEFAULT)
else if (type == DLADM_PROP_VAL_MODIFIABLE)
return (DLADM_STATUS_BADARG);
for (i = 0; i < DLADM_MAX_PROPS; i++)
break;
if (i == DLADM_MAX_PROPS) {
if (prop_name[0] == '_') {
/*
* private property.
*/
if (type == DLADM_PROP_VAL_PERSISTENT)
else
dld_flags));
} else {
return (DLADM_STATUS_NOTFOUND);
}
}
pdp = &prop_table[i];
NULL, 0);
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_BADARG);
switch (type) {
case DLADM_PROP_VAL_CURRENT:
break;
case DLADM_PROP_VAL_PERM:
} else {
}
*prop_val[0] = '\0';
*val_cntp = 1;
if (status == DLADM_STATUS_OK)
break;
case DLADM_PROP_VAL_DEFAULT:
/*
* If defaults are not defined for the property,
* pd_defval.vd_name should be null. If the driver
* has to be contacted for the value, vd_name should
* be the empty string (""). Otherwise, dladm will
* just print whatever is in the table.
*/
break;
}
} else {
}
*val_cntp = 1;
break;
break;
}
if (cnt == 0) {
} else {
for (i = 0; i < cnt; i++) {
}
}
break;
return (DLADM_STATUS_TEMPONLY);
} else {
}
break;
default:
break;
}
return (status);
}
/*
* Get linkprop of the given specific link and run any possible conversion
* of the values using the check function for the property. Fails if the
* check function doesn't succeed for the property value.
*/
{
int valc, i;
char **prop_val;
return (DLADM_STATUS_BADARG);
break;
return (DLADM_STATUS_NOTFOUND);
return (DLADM_STATUS_BADARG);
NULL, 0);
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_NOMEM);
switch (type) {
case DLADM_PROP_VAL_CURRENT:
break;
case DLADM_PROP_VAL_DEFAULT:
/*
* If defaults are not defined for the property,
* pd_defval.vd_name should be null. If the driver
* has to be contacted for the value, vd_name should
* be the empty string (""). Otherwise, dladm will
* just print whatever is in the table.
*/
break;
}
*val_cntp = 1;
return (DLADM_STATUS_OK);
}
break;
else
break;
default:
break;
}
if (status == DLADM_STATUS_OK) {
else
if (status == DLADM_STATUS_OK) {
}
} else {
for (i = 0; i < pdp->pd_noptval; i++) {
break;
}
}
if (i == pdp->pd_noptval) {
break;
}
}
}
}
return (status);
}
/*ARGSUSED*/
static int
{
DLADM_MAX_PROP_VALCNT)) == NULL) {
return (DLADM_WALK_CONTINUE);
}
for (i = 0; i < valcnt; i++) {
sizeof (char *) * DLADM_MAX_PROP_VALCNT +
i * DLADM_PROP_VAL_MAX;
}
goto done;
}
if (status != DLADM_STATUS_OK)
done:
return (DLADM_WALK_CONTINUE);
}
/*ARGSUSED*/
static int
{
NULL, 0);
if (status != DLADM_STATUS_OK)
return (DLADM_WALK_TERMINATE);
return (DLADM_WALK_CONTINUE);
}
{
return (DLADM_STATUS_NOMEM);
if (linkid == DATALINK_ALL_LINKID) {
} else if (any_media ||
0) == DLADM_STATUS_OK) &&
}
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
if (flags != 0)
return (DLADM_STATUS_NOTSUP);
if (status != DLADM_STATUS_OK)
return (status);
*val_cnt = 1;
if (zid != GLOBAL_ZONEID) {
return (dladm_errno2status(errno));
}
} else {
*prop_val[0] = '\0';
}
return (DLADM_STATUS_OK);
}
static int
{
void *dlhandle;
void *sym;
int ret;
return (-1);
return (-1);
}
return (ret);
}
static dladm_status_t
{
int ret;
return (dladm_errno2status(errno));
return (dladm_errno2status(errno));
return (dladm_errno2status(errno));
if (status != DLADM_STATUS_OK)
goto cleanup;
if (add)
else
if (ret != 0) {
goto cleanup;
}
if (di_prof_commit(prof) != 0)
if (prof)
return (status);
}
/*
* Wrappers to add and remove flows on the top of the link whose "zone" prop
* will be set
*/
static int
{
else
return (DLADM_WALK_CONTINUE);
}
static int
{
else
return (DLADM_WALK_CONTINUE);
}
/* ARGSUSED */
static dladm_status_t
{
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_OK);
/*
* If the 'zone' property is being set to another zone from a ngz,
* remove any ngz flows on top of this link before setting the property.
*/
if (zid_old != GLOBAL_ZONEID)
return (status);
/*
* It is okay to fail to update the /dev entry (some vanity-named
* links do not have a /dev entry).
*/
if (zid_old != GLOBAL_ZONEID) {
B_FALSE);
}
if (zid_new != GLOBAL_ZONEID) {
/*
* After assign link to a ngz, add any flows that ngz had
* configured on this link.
*/
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
char *zone_name;
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
return (DLADM_STATUS_NOMEM);
goto done;
}
if (zoneid != GLOBAL_ZONEID) {
sizeof (flags)) < 0) {
goto done;
}
if (!(flags & ZF_NET_EXCL)) {
goto done;
}
}
return (DLADM_STATUS_OK);
done:
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
if (status != DLADM_STATUS_OK)
return (status);
*val_cnt = 0;
return (DLADM_STATUS_OK);
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
{
else
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
return (DLADM_STATUS_NOMEM);
errno = 0;
return (DLADM_STATUS_BADVAL);
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
if (status != DLADM_STATUS_OK)
return (status);
*val_cnt = 0;
return (DLADM_STATUS_OK);
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
return (DLADM_STATUS_NOMEM);
if (status != DLADM_STATUS_OK) {
return (status);
}
return (DLADM_STATUS_MINMAXBW);
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
{
} else {
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
int i;
char *ptr;
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
i = 0;
pfcmap = 0;
if (*ptr == '1')
pfcmap |= 1 << i;
else if (*ptr != '0')
goto err;
if (++i > 8) {
goto err;
}
ptr--;
}
return (DLADM_STATUS_OK);
err:
return (DLADM_STATUS_BADVAL);
}
{
NULL, 0);
if (status != DLADM_STATUS_OK)
return (status);
if (class != DATALINK_CLASS_PHYS)
return (DLADM_STATUS_NOTSUP);
if (status != DLADM_STATUS_OK)
return (status);
/* We know prop_val is of length DLADM_PROP_VAL_MAX */
if (etsflags == MDEP_ETSBAT_LCL)
else if (etsflags == MDEP_ETSBAT_LCLEFF)
else if (etsflags == MDEP_ETSBAT_REM)
else
return (DLADM_STATUS_OK);
}
{
int i;
int sum = 0;
if (arr_cnt > MAX_DCB_NTCS)
return (DLADM_STATUS_BADVALCNT);
NULL, 0);
if (status != DLADM_STATUS_OK)
return (status);
if (class != DATALINK_CLASS_PHYS)
return (DLADM_STATUS_NOTSUP);
return (DLADM_STATUS_NOMEM);
/*
* The caller could set only the MDEP_ETSBAT_USELADV/MDEP_ETSBAT_USELCL
* flag.
*/
if ((etsflags & MDEP_ETSBAT_LCL) != 0)
else if ((etsflags & MDEP_ETSBAT_REM) != 0)
else if ((etsflags & MDEP_ETSBAT_LADV) != 0)
/* Validate if we are not resetting the bandwidth array */
for (i = 0; i < arr_cnt; i++) {
}
if (sum != 100) {
goto fail;
}
for (i = arr_cnt; i < MAX_DCB_NTCS; i++)
bw[i] = 0;
}
goto fail;
fail:
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
/*
* We need to use strlen("etsbw-lcl-effective") below
* as pd_name could be etsbw-lcl-effective.
*/
strlen("etsbw-lcl-effective")) == 0) {
restype = "resource";
}
if (status != DLADM_STATUS_OK)
return (status);
strlen("etsbw-lcl-effective")) == 0 ||
strlen("etsbw-lcl-effective")) == 0) {
strlen("etsbw-lcl-advice")) == 0) {
strlen("etsbw-rmt-effective")) == 0) {
} else {
return (DLADM_STATUS_BADVAL);
}
*val_cnt = 0;
return (DLADM_STATUS_OK);
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
return (DLADM_STATUS_NOMEM);
errno = 0;
return (DLADM_STATUS_BADVAL);
}
return (DLADM_STATUS_MINETSBW);
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
{
} else {
sizeof (uint32_t));
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
{
else
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
int err;
sizeof (mrp));
} else {
}
if (status != DLADM_STATUS_OK)
return (status);
*val_cnt = 0;
return (DLADM_STATUS_OK);
}
/* Sort CPU list and convert it to a mac_propval_range */
if (status != DLADM_STATUS_OK)
return (status);
/* Check to see if all the ranges fit in **prop_val */
return (DLADM_STATUS_TOOSMALL);
}
/* Write CPU ranges and individual CPUs */
if (err != 0) {
return (dladm_errno2status(err));
}
/* Update the number of values to the number of ranges */
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
int i, j, rc;
/* Get the current pool property */
if (status == DLADM_STATUS_OK) {
/* Can't set cpus if a pool is set */
return (DLADM_STATUS_POOLCPU);
}
/* Read ranges and convert to mac_propval_range */
&pv_range);
if (status != DLADM_STATUS_OK)
goto done1;
/* Convert mac_propval_range to a single CPU list */
if (status != DLADM_STATUS_OK)
goto done1;
/*
* If a range of CPUs was entered, update value count and reallocate
* the array of val_desc_t's. The array allocated was sized for
* indvidual elements, but needs to be reallocated to accomodate the
* expanded list of CPUs.
*/
goto done1;
}
}
/* Check if all CPUs in the list are online */
for (i = 0; i < ncpus; i++) {
goto done2;
}
if (rc < 1) {
goto done2;
}
goto done2;
}
}
/* Check for duplicate CPUs */
for (i = 0; i < ncpus; i++) {
for (j = i + 1; j < ncpus; j++) {
goto done2;
}
}
}
/* Update *val_cntp and *vdpp if everything was OK */
}
goto done1;
return (status);
}
/* ARGSUSED */
{
int i;
return (DLADM_STATUS_OK);
}
for (i = 0; i < cnt; i++)
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
sizeof (mrp));
if (status != DLADM_STATUS_OK)
return (status);
} else {
if (status != DLADM_STATUS_OK)
return (status);
*val_cnt = 0;
return (DLADM_STATUS_OK);
}
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
val_desc_t *v = *vp;
if (val_cnt != 1)
return (DLADM_STATUS_BADVAL);
if (v->vd_val == 0)
return (DLADM_STATUS_BADVAL);
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
{
else
return (DLADM_STATUS_OK);
}
/*
* Get the pool datalink property from the kernel. This is used
* for both the user specified pool and effective pool properties.
*/
/* ARGSUSED */
static dladm_status_t
{
sizeof (mrp));
} else {
}
if (status != DLADM_STATUS_OK)
return (status);
(*prop_val)[0] = '\0';
} else {
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
char *poolname;
/* Get the current cpus property */
if (status == DLADM_STATUS_OK) {
/* Can't set pool if cpus are set */
return (DLADM_STATUS_POOLCPU);
}
/* Check for pool's availability if not booting */
if ((flags & DLADM_OPT_BOOT) == 0) {
/* Allocate and open pool configuration */
return (DLADM_STATUS_BADVAL);
!= PO_SUCCESS) {
return (DLADM_STATUS_BADVAL);
}
/* Look for pool name */
(void) pool_conf_close(poolconf);
return (DLADM_STATUS_BADVAL);
}
(void) pool_conf_close(poolconf);
}
return (DLADM_STATUS_NOMEM);
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
{
return (DLADM_STATUS_OK);
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
if (status != DLADM_STATUS_OK)
return (status);
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
{
if (cnt != 1)
return (DLADM_STATUS_BADVAL);
return (DLADM_STATUS_OK);
}
/*
* Determines the size of the structure that needs to be sent to drivers
* for retrieving the property range values.
*/
static int
{
*sz = sizeof (mac_propval_range_t);
--count;
switch (r->mpr_type) {
case MAC_PROPVAL_UINT32:
return (0);
default:
break;
}
*sz = 0;
*rcount = 0;
return (EINVAL);
}
/* ARGSUSED */
static dladm_status_t
{
val_desc_t *v = *vp;
if (val_cnt != 1)
return (DLADM_STATUS_BADVAL);
v->vd_val = UNSPEC_VAL;
v->vd_val = 0;
} else {
if (v->vd_val == 0)
return (DLADM_STATUS_BADVAL);
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
sz = sizeof (mac_propval_range_t);
return (status);
if (status != DLADM_STATUS_OK)
return (status);
*val_cnt = 1;
(*prop_val)[0] = '\0';
/*
* This is the case where the dev supports rings, but static
* grouping.
*/
/*
* This is the case where the dev supports rings and dynamic
* grouping, but has only one value (say 2 rings and 2 groups).
*/
/*
* This is the case where the dev supports rings and dynamic
* grouping and has a range of rings.
*/
} else {
}
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
/*
* Get the number of (effective-)rings from the resource property.
*/
sizeof (mrp));
} else {
/*
* Get the permissions from the "rxrings" property.
*/
if (status != DLADM_STATUS_OK)
return (status);
}
if (status != DLADM_STATUS_OK)
return (status);
*val_cnt = 0;
return (DLADM_STATUS_OK);
}
*val_cnt = 1;
else if (nrings == 0)
else
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
{
mrp->mrp_nrxrings = 0;
else
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
/*
* Get the number of (effective-)rings from the resource property.
*/
sizeof (mrp));
} else {
/*
* Get the permissions from the "txrings" property.
*/
if (status != DLADM_STATUS_OK)
return (status);
/*
* Get the number of rings from the "resource" property.
*/
}
if (status != DLADM_STATUS_OK)
return (status);
*val_cnt = 0;
return (DLADM_STATUS_OK);
}
*val_cnt = 1;
else if (nrings == 0)
else
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
{
mrp->mrp_ntxrings = 0;
else
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
if (flags & DLD_PROP_DEFAULT)
return (DLADM_STATUS_NOTDEFINED);
flags, perm_flags));
}
/* ARGSUSED */
static dladm_status_t
{
int i;
return (status);
for (i = 0; i < DLADM_MAX_RSRC_PROP; i++) {
continue;
if (status != DLADM_STATUS_OK)
goto done;
break;
}
if (flags == DLADM_OPT_EFFECTIVE)
done:
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
mac_protect_t *p;
if (status != DLADM_STATUS_OK)
return (status);
p = &mrp.mrp_protect;
*val_cnt = 0;
return (DLADM_STATUS_OK);
}
return (DLADM_STATUS_BADVALCNT);
for (i = 0; i < cnt; i++)
return (DLADM_STATUS_OK);
}
static void
{
int i;
for (i = 0; i < pd->pd_noptval; i++) {
return;
}
}
}
/* ARGSUSED */
static dladm_status_t
{
if (status != DLADM_STATUS_OK)
return (status);
*val_cntp = 1;
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
if (status != DLADM_STATUS_OK)
return (status);
*val_cntp = 1;
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
}
/* ARGSUSED */
static dladm_status_t
{
int len;
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_PROPRDONLY);
return (DLADM_STATUS_NOMEM);
return (status);
}
} else {
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
}
/* ARGSUSED */
static dladm_status_t
{
char *str;
if (status != DLADM_STATUS_OK)
return (status);
if (status != DLADM_STATUS_OK)
return (status);
*val_cnt = 1;
else
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
/*
* Since this link property has already been persistently stored
* (PD_AFTER_PERM flag in the prop_table table), there is nothing to
* do here. No kernel changes are required.
*/
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
if (flags != 0)
return (DLADM_STATUS_NOTSUP);
/* Retrieve the persistent value */
val_cnt) != DLADM_STATUS_OK) {
/*
* If we can't get the persistent value, just return the
* default value.
*/
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
mac_protect_t *p;
int i;
if (status != DLADM_STATUS_OK)
return (status);
p = &mrp.mrp_protect;
if (p->mp_ipaddrcnt == 0) {
*val_cnt = 0;
return (DLADM_STATUS_OK);
}
if (p->mp_ipaddrcnt > *val_cnt)
return (DLADM_STATUS_BADVALCNT);
for (i = 0; i < p->mp_ipaddrcnt; i++) {
} else {
prop_val[i]);
}
}
*val_cnt = p->mp_ipaddrcnt;
return (DLADM_STATUS_OK);
}
{
int i;
for (i = 0; i < cnt; i++)
return (DLADM_STATUS_OK);
}
{
int i;
} else {
for (i = 0; i < cnt; i++) {
sizeof (mac_ipaddr_t));
}
}
p->mp_ipaddrcnt = cnt;
return (DLADM_STATUS_OK);
}
static dladm_status_t
{
if (status == DLADM_STATUS_INVALID_IP) {
if (status == DLADM_STATUS_OK)
}
if (status != DLADM_STATUS_OK)
return (status);
if (isv4) {
if (v4addr == INADDR_ANY)
return (DLADM_STATUS_INVALID_IP);
} else {
if (IN6_IS_ADDR_UNSPECIFIED(&v6addr))
return (DLADM_STATUS_INVALID_IP);
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
int i;
if (val_cnt > MPT_MAXIPADDR)
return (DLADM_STATUS_BADVALCNT);
for (i = 0; i < val_cnt; i++) {
goto fail;
}
if (status != DLADM_STATUS_OK)
goto fail;
}
return (DLADM_STATUS_OK);
fail:
for (i = 0; i < val_cnt; i++) {
}
return (status);
}
static void
{
case CIDFORM_TYPED: {
char *lladdr;
goto fail;
switch (duidtype) {
case DHCPV6_DUID_LLT: {
goto fail;
goto fail;
break;
}
case DHCPV6_DUID_EN: {
goto fail;
goto fail;
break;
}
case DHCPV6_DUID_LL: {
goto fail;
goto fail;
break;
}
default: {
goto fail;
}
}
break;
}
case CIDFORM_HEX: {
goto fail;
break;
}
case CIDFORM_STR: {
int i;
goto fail;
}
break;
}
default:
goto fail;
}
return;
fail:
}
{
char *cp;
int addrlen;
errno = 0;
return (DLADM_STATUS_BADARG);
errno = 0;
return (DLADM_STATUS_BADARG);
}
switch (duidtype) {
case DHCPV6_DUID_LLT: {
errno = 0;
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_TOOSMALL);
}
break;
}
case DHCPV6_DUID_LL: {
return (DLADM_STATUS_BADARG);
return (DLADM_STATUS_TOOSMALL);
}
break;
}
default: {
return (DLADM_STATUS_BADARG);
if (duidtype == DHCPV6_DUID_EN) {
return (DLADM_STATUS_TOOSMALL);
hexlen);
} else {
return (DLADM_STATUS_TOOSMALL);
hexlen);
}
break;
}
}
ptr += 2;
&hexlen) != 0) {
return (DLADM_STATUS_BADARG);
}
return (DLADM_STATUS_TOOSMALL);
} else {
return (DLADM_STATUS_TOOSMALL);
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
mac_protect_t *p;
int i;
if (status != DLADM_STATUS_OK)
return (status);
p = &mrp.mrp_protect;
if (p->mp_cidcnt == 0) {
*val_cnt = 0;
return (DLADM_STATUS_OK);
}
return (DLADM_STATUS_BADVALCNT);
for (i = 0; i < p->mp_cidcnt; i++) {
}
return (DLADM_STATUS_OK);
}
{
int i;
} else {
for (i = 0; i < cnt; i++) {
sizeof (mac_dhcpcid_t));
}
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
int i;
if (val_cnt > MPT_MAXCID)
return (DLADM_STATUS_BADVALCNT);
for (i = 0; i < val_cnt; i++) {
goto fail;
}
if (status != DLADM_STATUS_OK)
goto fail;
}
return (DLADM_STATUS_OK);
fail:
for (i = 0; i < val_cnt; i++) {
}
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
int i, len;
if (flags & DLD_PROP_DEFAULT)
return (DLADM_STATUS_NOTDEFINED);
if (status != DLADM_STATUS_OK)
return (status);
*val_cnt = 0;
return (DLADM_STATUS_OK);
}
if (i != 0) {
len += 1;
}
}
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/*
* Add the specified module to the dlautopush structure; returns a
* DLADM_STATUS_* code.
*/
{
return (DLADM_STATUS_BADVAL);
/*
* We don't allow multiple anchors, and the anchor must
* be after at least one module.
*/
if (dlap->dap_anchor != 0)
return (DLADM_STATUS_BADVAL);
return (DLADM_STATUS_BADVAL);
return (DLADM_STATUS_OK);
}
return (DLADM_STATUS_BADVALCNT);
FMNAMESZ + 1);
return (DLADM_STATUS_OK);
}
/*
* Currently, both '.' and ' '(space) can be used as the delimiters between
* autopush modules. The former is used in dladm set-linkprop, and the
* latter is used in the autopush(1M) file.
*/
/* ARGSUSED */
static dladm_status_t
{
char *module;
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
return (DLADM_STATUS_NOMEM);
if (status != DLADM_STATUS_OK)
return (status);
}
} else {
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
uint_t i;
return (DLADM_STATUS_NOMEM);
B_FALSE);
if (status != DLADM_STATUS_OK)
goto done;
goto done;
}
if (wrp->wl_rates_rates[0] == 0) {
prop_val[0][0] = '\0';
*val_cnt = 1;
goto done;
}
for (i = 0; i < wrp->wl_rates_num; i++) {
}
done:
return (status);
}
static dladm_status_t
{
}
}
/* ARGSUSED */
static dladm_status_t
{
switch (media) {
case DL_ETHER:
/*
* Speed for ethernet links is unbounded. E.g., 802.11b
* links can have a speed of 5.5 Gbps.
*/
return (DLADM_STATUS_NOTSUP);
case DL_WIFI:
default:
return (DLADM_STATUS_BADARG);
}
}
static dladm_status_t
{
int i;
return (DLADM_STATUS_NOMEM);
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
/*
* can currently set rate on WIFI links only.
*/
return (DLADM_STATUS_PROPRDONLY);
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
int i;
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
goto done;
}
for (i = 0; i < MAX_SUPPORT_RATES; i++) {
i * DLADM_STRSIZE;
}
media, 0, &perm_flags);
if (status != DLADM_STATUS_OK)
goto done;
for (i = 0; i < modval_cnt; i++) {
break;
}
}
if (i == modval_cnt)
done:
return (status);
}
static dladm_status_t
int buflen)
{
}
/* ARGSUSED */
static dladm_status_t
{
!= DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_NOTFOUND);
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
const char *s;
return (status);
switch (mode.wl_ps_mode) {
case WL_PM_AM:
s = "off";
break;
case WL_PM_MPS:
s = "max";
break;
case WL_PM_FAST:
s = "fast";
break;
default:
return (DLADM_STATUS_NOTFOUND);
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
switch (powermode) {
case DLADM_WLAN_PM_OFF:
break;
case DLADM_WLAN_PM_MAX:
break;
case DLADM_WLAN_PM_FAST:
break;
default:
return (DLADM_STATUS_NOTSUP);
}
}
/* ARGSUSED */
static dladm_status_t
{
const char *s;
return (status);
switch (radio) {
case B_TRUE:
s = "on";
break;
case B_FALSE:
s = "off";
break;
default:
return (DLADM_STATUS_NOTFOUND);
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
wl_radio_t r;
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
switch (radio) {
case DLADM_WLAN_RADIO_ON:
r = B_TRUE;
break;
case DLADM_WLAN_RADIO_OFF:
r = B_FALSE;
break;
default:
return (DLADM_STATUS_NOTSUP);
}
sizeof (r), B_TRUE));
}
/* ARGSUSED */
static dladm_status_t
{
char *ep;
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
errno = 0;
return (DLADM_STATUS_BADVAL);
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
char *ep;
return (DLADM_STATUS_BADARG);
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
errno = 0;
return (DLADM_STATUS_BADVAL);
return (DLADM_STATUS_OK);
}
static dladm_status_t
{
int i;
if (status != DLADM_STATUS_OK)
return (status);
/*
* reset case.
*/
if (val_cnt == 0) {
if (status == DLADM_STATUS_OK)
goto done;
}
buf[0] = '\0';
for (i = 0; i < val_cnt; i++) {
return (DLADM_STATUS_DB_LONGLINE);
if (i != val_cnt - 1)
}
buf);
if (status == DLADM_STATUS_OK)
done:
return (status);
}
static dladm_status_t
{
if (status != DLADM_STATUS_OK)
return (status);
if (status != DLADM_STATUS_OK)
goto done;
goto done;
}
}
done:
return (status);
}
/*
* Walk persistent private link properties of a link.
*/
static dladm_status_t
{
return (DLADM_STATUS_BADARG);
if (status != DLADM_STATUS_OK)
return (status);
last_attr[0] = '\0';
if (attr[0] == '_') {
break;
}
}
return (DLADM_STATUS_OK);
}
static link_attr_t *
{
link_attr_t *p;
break;
}
return (p);
}
static link_attr_t *
{
link_attr_t *p;
break;
}
return (p);
}
static dld_ioc_macprop_t *
{
int dsize;
return (NULL);
}
return (dip);
}
static dld_ioc_macprop_t *
{
link_attr_t *p;
p = dladm_name2prop(prop_name);
}
static dld_ioc_macprop_t *
{
link_attr_t *p;
p = dladm_id2prop(propid);
}
/* ARGSUSED */
static dladm_status_t
{
void *val;
return (status);
else {
/*
* No need (yet) to distinguish these from arrays of same size.
*/
switch (dip->pr_valsize) {
case 1:
break;
case 2:
break;
case 4:
break;
default:
break;
}
}
else
dip->pr_valsize = 0;
done:
return (status);
}
{
errno = 0;
return (status);
}
static dladm_status_t
{
return (DLADM_STATUS_NOMEM);
if (status != DLADM_STATUS_OK) {
return (status);
}
if (perm_flags != NULL)
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
val_desc_t *v = *vp;
if (val_cnt != 1)
return (DLADM_STATUS_BADVAL);
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
KSTAT_DATA_UINT32, &link_duplex)) != 0)
return (status);
switch (link_duplex) {
case LINK_DUPLEX_FULL:
break;
case LINK_DUPLEX_HALF:
break;
default:
break;
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
KSTAT_DATA_UINT64, &ifspeed)) != 0)
return (status);
if ((ifspeed % 1000000) != 0) {
} else {
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
if (status != DLADM_STATUS_OK)
return (status);
switch (link_state) {
case LINK_STATE_UP:
break;
case LINK_STATE_DOWN:
break;
default:
break;
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
uint_t v = 0;
perm_flags, &v, sizeof (v));
if (status != DLADM_STATUS_OK)
return (status);
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
uint8_t v = 0;
int i;
char *ptr;
char *restype;
return (DLADM_STATUS_BADVAL);
restype = "resource-effective";
restype = "resource";
if (status != DLADM_STATUS_OK)
return (status);
mask = MRP_PFCMAP;
*val_cnt = 0;
return (DLADM_STATUS_OK);
}
/* We know prop_val is of length DLADM_PROP_VAL_MAX */
for (i = 7; i >= 0; i--)
*ptr = '\0';
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
int i;
char *ptr;
if (status != DLADM_STATUS_OK)
return (status);
goto done;
for (i = 7; i >= 0; i--)
'1' : '0';
done:
*ptr = '\0';
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
"00000000-11111111");
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
uint8_t v = 0;
perm_flags, &v, sizeof (v));
if (status != DLADM_STATUS_OK)
return (status);
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
uint32_t v = 0;
perm_flags, &v, sizeof (v));
if (status != DLADM_STATUS_OK)
return (status);
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
/*
* As caller we don't know number of value ranges, the driver
* supports. To begin with we assume that number to be 1. If the
* buffer size is insufficient, driver returns back with the
* actual count of value ranges. See mac.h for more details.
*/
sz = sizeof (mac_propval_range_t);
rcount = 1;
return (status);
if (status != DLADM_STATUS_OK) {
if (status == DLADM_STATUS_TOOSMALL) {
int err;
== 0) {
goto retry;
} else {
}
}
return (status);
}
*val_cnt = 1;
goto done;
}
case MAC_PROPVAL_UINT32: {
} else {
}
}
break;
}
default:
break;
}
done:
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
if (status != DLADM_STATUS_OK)
return (status);
switch (mode) {
case LINK_TAGMODE_NORMAL:
break;
case LINK_TAGMODE_VLANONLY:
break;
default:
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
perm_flags, &v, sizeof (v));
if (status != DLADM_STATUS_OK)
return (status);
switch (v) {
case LINK_FLOWCTRL_NONE:
break;
case LINK_FLOWCTRL_RX:
break;
case LINK_FLOWCTRL_TX:
break;
case LINK_FLOWCTRL_BI:
break;
case LINK_FLOWCTRL_PFC:
break;
case LINK_FLOWCTRL_AUTO:
break;
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
{
if (cnt != 1)
return (DLADM_STATUS_BADVAL);
else
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
{
if (cnt != 1)
return (DLADM_STATUS_BADVAL);
else
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
if (val_cnt > 1)
return (DLADM_STATUS_BADVAL);
return (DLADM_STATUS_NOMEM);
if (val_cnt != 0)
if (status != DLADM_STATUS_OK)
return (status);
}
/* ARGSUSED */
{
if (cnt == 0) {
} else if (cnt != 1) {
return (DLADM_STATUS_BADVAL);
} else {
sizeof (in6_addr_t));
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
{
if (cnt != 1)
return (DLADM_STATUS_BADVAL);
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
sizeof (mrp));
if (status != DLADM_STATUS_OK)
return (status);
} else {
if (status != DLADM_STATUS_OK)
return (status);
}
*val_cnt = 0;
return (DLADM_STATUS_OK);
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
sizeof (mrp));
if (status != DLADM_STATUS_OK)
return (status);
} else {
if (status != DLADM_STATUS_OK)
return (status);
}
*val_cnt = 0;
*prop_val[0] = '\0';
return (DLADM_STATUS_OK);
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
sizeof (mrp));
if (status != DLADM_STATUS_OK)
return (status);
} else {
if (status != DLADM_STATUS_OK)
return (status);
}
*val_cnt = 0;
return (DLADM_STATUS_OK);
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
sizeof (mrp));
if (status != DLADM_STATUS_OK)
return (status);
} else {
if (status != DLADM_STATUS_OK)
return (status);
}
*val_cnt = 0;
return (DLADM_STATUS_OK);
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
{
int i;
for (i = 0; i < val_cnt; i++) {
if (strcasecmp(encstr,
vsimgrid_encoding_vals[i].vd_name) == 0) {
break;
}
}
if (i == val_cnt)
return (DLADM_STATUS_BADVAL);
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static dladm_status_t
{
int i, slen;
int bufsize = 0;
link_attr_t *p;
return (DLADM_STATUS_BADARG);
p = dladm_name2prop(prop_name);
if (p->pp_id != MAC_PROP_PRIVATE)
return (DLADM_STATUS_BADARG);
if (!(flags & DLADM_OPT_ACTIVE))
return (DLADM_STATUS_OK);
/*
* private properties: all parsing is done in the kernel.
* allocate a enough space for each property + its separator (',').
*/
for (i = 0; i < val_cnt; i++) {
}
/*
* getting default value. so use more buffer space.
*/
}
return (status);
slen = 0;
} else {
for (i = 0; i < val_cnt; i++) {
int plen = 0;
/*
* add a "," separator and update dp.
*/
if (i != (val_cnt -1))
}
}
if (status == DLADM_STATUS_OK)
return (status);
}
static dladm_status_t
{
link_attr_t *p;
return (DLADM_STATUS_BADARG);
p = dladm_name2prop(prop_name);
if (p->pp_id != MAC_PROP_PRIVATE)
return (DLADM_STATUS_BADARG);
/*
* private properties: all parsing is done in the kernel.
*/
return (status);
if (type == DLADM_PROP_VAL_PERM) {
} else if (type == DLADM_PROP_VAL_MODIFIABLE) {
*prop_val[0] = '\0';
} else {
}
*val_cnt = 1;
} else if ((status == DLADM_STATUS_NOTSUP) &&
(type == DLADM_PROP_VAL_CURRENT)) {
}
return (status);
}
static dladm_status_t
{
int i;
/*
* Allocate buffer needed for prop_vals array. We can have at most
* DLADM_MAX_PROP_VALCNT char *prop_vals[] entries, where
* each entry has max size DLADM_PROP_VAL_MAX
*/
bufsize =
(sizeof (char *) + DLADM_PROP_VAL_MAX) * DLADM_MAX_PROP_VALCNT;
for (i = 0; i < DLADM_MAX_PROP_VALCNT; i++) {
sizeof (char *) * DLADM_MAX_PROP_VALCNT +
i * DLADM_PROP_VAL_MAX;
}
/*
* For properties which have pdp->pd_defval.vd_name as a non-empty
* string, the "" itself is used to reset the property (exceptions
* are zone and autopush, which populate vdp->vd_val). So
* libdladm can copy pdp->pd_defval over to the val_desc_t passed
* down on the setprop using the global values in the table. For
* other cases (vd_name is ""), doing reset-linkprop will cause
* libdladm to do a getprop to find the default value and then do
* a setprop to reset the value to default.
*/
if (status == DLADM_STATUS_OK) {
if (perm_flags == MAC_PROP_PERM_RW) {
} else
}
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
int val, i;
if (flags != 0)
return (DLADM_STATUS_NOTSUP);
*val_cnt = 1;
break;
/* If the daemon isn't running, then return the persistent value */
if (retv == DLADM_STATUS_NOTFOUND) {
return (DLADM_STATUS_OK);
}
if (retv != DLADM_STATUS_OK) {
return (retv);
}
return (DLADM_STATUS_OK);
}
for (i = 0; i < pd->pd_noptval; i++) {
return (DLADM_STATUS_OK);
}
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED1 */
static dladm_status_t
{
/*
* Special case for mcheck: the daemon resets the value to zero, and we
* don't want the daemon to refresh itself; it leads to deadlock.
*/
if (flags & DLADM_OPT_NOREFRESH)
return (DLADM_STATUS_OK);
/* Tell the running daemon, if any */
}
/*
* This is used only for stp_priority, stp_cost, and stp_mcheck.
*/
/* ARGSUSED */
static dladm_status_t
{
char *cp;
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
} else {
/* Only stp_priority and stp_cost use this function */
/* Illegal value 0 is allowed to mean "automatic" */
} else {
errno = 0;
return (DLADM_STATUS_BADVAL);
}
}
if (iscost) {
} else {
return (DLADM_STATUS_BADVAL);
/*
* If the user is setting stp_mcheck non-zero, then (per the
* IEEE management standards and UNH testing) we need to check
* whether this link is part of a bridge that is running RSTP.
* If it's not, then setting the flag is an error. Note that
* errors are intentionally discarded here; it's the value
* that's the problem -- it's not a bad value, merely one that
* can't be used now.
*/
sizeof (bridge)) != DLADM_STATUS_OK ||
&brprot) != DLADM_STATUS_OK)
return (DLADM_STATUS_FAILED);
return (DLADM_STATUS_FAILED);
}
return (DLADM_STATUS_OK);
}
}
/* ARGSUSED */
static dladm_status_t
{
if (flags != 0)
return (DLADM_STATUS_NOTSUP);
*val_cnt = 1;
if (retv == DLADM_STATUS_NOTFOUND) {
return (DLADM_STATUS_OK);
}
if (retv == DLADM_STATUS_OK)
else
return (retv);
}
/* ARGSUSED */
static dladm_status_t
{
/* Tell the running daemon, if any */
}
/* ARGSUSED */
static dladm_status_t
{
if (flags != 0)
return (DLADM_STATUS_NOTSUP);
*val_cnt = 1;
0, &status);
return (status);
if (status == DLADM_STATUS_OK) {
} else {
}
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
0, &status);
return (status);
if (status != DLADM_STATUS_OK)
return (status);
/* Tell the running daemon, if any */
}
/* ARGSUSED */
static dladm_status_t
{
char *cp;
if (val_cnt != 1)
return (DLADM_STATUS_BADVALCNT);
} else {
errno = 0;
return (DLADM_STATUS_BADVAL);
}
}
/* ARGSUSED */
static dladm_status_t
{
return (status);
if (status != DLADM_STATUS_OK)
return (status);
/* Tell the running daemon, if any */
}
/* ARGSUSED */
static dladm_status_t
{
if (flags != 0)
return (DLADM_STATUS_NOTSUP);
*val_cnt = 1;
MAC_PROP_VLAN_ANNOUNCE, 0, &status);
return (status);
if (status == DLADM_STATUS_OK) {
sizeof (mac_vlan_announce_t));
} else {
}
return (status);
}
{
void *dp;
return (status);
}
return (DLADM_STATUS_BADARG);
if (!(flags & DLADM_OPT_ACTIVE))
return (DLADM_STATUS_TEMPONLY);
return (DLADM_STATUS_NOMEM);
if (set)
if (status == DLADM_STATUS_OK) {
if (!set)
}
return (status);
}
{
}
/*
* Retrieve the one link property from the database
*/
/*ARGSUSED*/
static int
{
/*
* it is fine to point to prop_name since prop_name points to the
* prop_table[n].pd_name.
*/
return (DLADM_WALK_CONTINUE);
}
/*
* Retrieve all link properties for a link from the database and
* return a property list.
*/
{
return (dladm_errno2status(errno));
return (status);
}
/*
* Retrieve the named property from a proplist, check the value and
* convert to a kernel structure.
*/
static dladm_status_t
{
int i, j;
/* Find named property in proplist */
break;
}
/* Property not in list */
return (DLADM_STATUS_OK);
for (i = 0; i < DLADM_MAX_PROPS; i++) {
return (DLADM_STATUS_NOMEM);
continue;
return (DLADM_STATUS_BADARG);
/* Check property value */
} else {
}
if (status != DLADM_STATUS_OK)
return (status);
for (j = 0; j < DLADM_MAX_RSRC_PROP; j++) {
continue;
/* Extract kernel structure */
} else {
}
break;
}
if (status != DLADM_STATUS_OK)
return (status);
break;
}
return (status);
}
/*
* Extract properties from a proplist and convert to mac_resource_props_t.
*/
{
int i;
for (i = 0; i < DLADM_MAX_RSRC_PROP; i++) {
if (status != DLADM_STATUS_OK)
return (status);
}
return (status);
}
static const char *
{
return (buf);
}
{
}
{
/* non-property attribute names */
const char *nonprop[] = {
/*
* dlmgmtd core attributes. These properties are written to
* datalink.conf and not the profile-specific file.
*/
"name",
"class",
"media",
/* other attributes for vlan, aggr, etc */
};
int i;
is_nonprop = B_TRUE;
break;
}
}
return (!is_nonprop);
}
{
int i;
bufsize = (sizeof (char *) + DLADM_PROP_VAL_MAX) *
return (DLADM_STATUS_NOMEM);
for (i = 0; i < valcnt; i++) {
sizeof (char *) * DLADM_MAX_PROP_VALCNT +
i * DLADM_PROP_VAL_MAX;
}
&valcnt) != DLADM_STATUS_OK) {
goto done;
}
/*
* valcnt is always set to 1 by get_pool(), hence we need to check
* for a non-null string to see if it is set. For protection and
* allowed-ips, we can check either the *propval or the valcnt.
*/
}
done:
return (status);
}
/* ARGSUSED */
static dladm_status_t
{
char *s;
uint32_t v;
perm_flags, &v, sizeof (v));
if (status != DLADM_STATUS_OK)
return (status);
switch (v) {
case DLADM_PART_CM_MODE:
s = "cm";
break;
case DLADM_PART_UD_MODE:
s = "ud";
break;
default:
s = "";
break;
}
*val_cnt = 1;
return (DLADM_STATUS_OK);
}
static prop_desc_t *
{
int i;
pdp = prop_table;
for (i = 0; i < DLADM_MAX_PROPS; i++, pdp++) {
return (pdp);
}
return (NULL);
}