dladm.c revision a4754370e3396d98214a2a2bbb89a23555b2cff2
/*
* 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 <stdio.h>
#include <ctype.h>
#include <dlfcn.h>
#include <locale.h>
#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <stropts.h>
#include <errno.h>
#include <kstat.h>
#include <strings.h>
#include <getopt.h>
#include <unistd.h>
#include <priv.h>
#include <limits.h>
#include <termios.h>
#include <pwd.h>
#include <auth_attr.h>
#include <auth_list.h>
#include <libintl.h>
#include <libdevinfo.h>
#include <libdlpi.h>
#include <libdladm.h>
#include <libdllink.h>
#include <libdlstat.h>
#include <libdlaggr.h>
#include <libdlwlan.h>
#include <libdlvlan.h>
#include <libdlvnic.h>
#include <libdlib.h>
#include <libdlether.h>
#include <libdliptun.h>
#include <libdlsim.h>
#include <libdlbridge.h>
#include <libinetutil.h>
#include <libvrrpadm.h>
#include <bsm/adt_event.h>
#include <libdlvnic.h>
#include <sys/processor.h>
#include <net/if_types.h>
#include <stddef.h>
#include <stp_in.h>
#include <ofmt.h>
#define MAXPORT 256
#define MAXVNIC 256
#define MAXLINELEN 1024
#define SMF_UPGRADE_FILE "/var/svc/profile/upgrade"
#define SMF_UPGRADEDATALINK_FILE "/var/svc/profile/upgrade_datalink"
#define SMF_DLADM_UPGRADE_MSG " # added by dladm(1M)"
#define DLADM_DEFAULT_COL 80
/*
* used by the wifi show-* commands to set up ofmt_field_t structures.
*/
#define WIFI_CMD_SCAN 0x00000001
#define WIFI_CMD_SHOW 0x00000002
/* No larger than pktsum_t */
typedef struct brsum_s {
} brsum_t;
/* No larger than pktsum_t */
typedef struct brlsum_s {
} brlsum_t;
typedef struct show_state {
} show_state_t;
typedef struct show_grp_state {
typedef struct show_vnic_state {
char vs_vnic[MAXLINKNAMELEN];
char vs_link[MAXLINKNAMELEN];
typedef struct show_part_state {
char ps_part[MAXLINKNAMELEN];
typedef struct show_ib_state {
char is_link[MAXLINKNAMELEN];
typedef struct show_usage_state_s {
/*
* callback functions for printing output and error diagnostics.
*/
typedef void cmdfunc_t(int, char **, const char *);
static cmdfunc_t do_show_linkmap;
static cmdfunc_t do_show_ether;
static cmdfunc_t do_up_vnic;
static cmdfunc_t do_up_part;
static cmdfunc_t do_show_usage;
static void do_up_vnic_common(int, char **, const char *, boolean_t);
static void altroot_cmd(char *, int, char **);
static int get_one_kstat(const char *, const char *, uint8_t,
void *, boolean_t);
static void get_mac_stats(const char *, pktsum_t *);
static void get_link_stats(const char *, pktsum_t *);
static const char *get_linkstate(const char *, boolean_t, char *);
static const char *get_linkduplex(const char *, boolean_t, char *);
static iptun_type_t iptun_gettypebyname(char *);
static const char *iptun_gettypebyvalue(iptun_type_t);
show_state_t *);
static void show_ether_xprop(void *, dladm_ether_info_t *);
static void die(const char *, ...);
static void die_optdup(int);
static void die_opterr(int, int, const char *);
static void die_dlerr(dladm_status_t, const char *, ...);
static void warn(const char *, ...);
static void warn_dlerr(dladm_status_t, const char *, ...);
typedef struct cmd {
char *c_name;
const char *c_usage;
} cmd_t;
{ "rename-link", do_rename_link,
" rename-link <oldlink> <newlink>" },
{ "show-link", do_show_link,
" show-link [-pP] [-o <field>,..] [-s [-i <interval>]] "
"[<link>]\n" },
{ "create-aggr", do_create_aggr,
" create-aggr [-t] [-P <policy>] [-L <mode>] [-T <time>] "
"[-u <address>]\n"
"\t\t -l <link> [-l <link>...] <link>" },
{ "delete-aggr", do_delete_aggr,
" delete-aggr [-t] <link>" },
{ "add-aggr", do_add_aggr,
" add-aggr [-t] -l <link> [-l <link>...] <link>" },
{ "remove-aggr", do_remove_aggr,
" remove-aggr [-t] -l <link> [-l <link>...] <link>" },
{ "modify-aggr", do_modify_aggr,
" modify-aggr [-t] [-P <policy>] [-L <mode>] [-T <time>] "
"[-u <address>]\n"
"\t\t <link>" },
{ "show-aggr", do_show_aggr,
" show-aggr [-pPLx] [-o <field>,..] [-s [-i <interval>]] "
"[<link>]\n" },
{ "scan-wifi", do_scan_wifi,
" scan-wifi [-p] [-o <field>,...] [<link>]" },
{ "connect-wifi", do_connect_wifi,
" connect-wifi [-e <essid>] [-i <bssid>] [-k <key>,...] "
"[-s wep|wpa]\n"
"\t\t [-a open|shared] [-b bss|ibss] [-c] [-m a|b|g] "
"[-T <time>]\n"
"\t\t [<link>]" },
{ "disconnect-wifi", do_disconnect_wifi,
" disconnect-wifi [-a] [<link>]" },
{ "show-wifi", do_show_wifi,
" show-wifi [-p] [-o <field>,...] [<link>]\n" },
{ "set-linkprop", do_set_linkprop,
" set-linkprop [-t] -p <prop>=<value>[,...] <name>" },
{ "reset-linkprop", do_reset_linkprop,
" reset-linkprop [-t] [-p <prop>,...] <name>" },
{ "show-linkprop", do_show_linkprop,
" show-linkprop [-cP] [-o <field>,...] [-p <prop>,...] "
"<name>\n" },
{ "show-ether", do_show_ether,
" show-ether [-px][-o <field>,...] <link>\n" },
{ "create-secobj", do_create_secobj,
" create-secobj [-t] [-f <file>] -c <class> <secobj>" },
{ "delete-secobj", do_delete_secobj,
" delete-secobj [-t] <secobj>[,...]" },
{ "show-secobj", do_show_secobj,
" show-secobj [-pP] [-o <field>,...] [<secobj>,...]\n" },
{ "create-vlan", do_create_vlan,
" create-vlan [-ft] -l <link> -v <vid> [link]" },
{ "delete-vlan", do_delete_vlan,
" delete-vlan [-t] <link>" },
{ "show-vlan", do_show_vlan,
" show-vlan [-pP] [-o <field>,..] [<link>]\n" },
{ "create-iptun", do_create_iptun,
" create-iptun [-t] -T <type> "
"[-a {local|remote}=<addr>,...] <link>]" },
{ "delete-iptun", do_delete_iptun,
" delete-iptun [-t] <link>" },
{ "modify-iptun", do_modify_iptun,
" modify-iptun [-t] -a {local|remote}=<addr>,... <link>" },
{ "show-iptun", do_show_iptun,
" show-iptun [-pP] [-o <field>,..] [<link>]\n" },
{ "delete-phys", do_delete_phys,
" delete-phys <link>" },
{ "show-phys", do_show_phys,
" show-phys [-m | -H | -P] [[-p] [-o <field>[,...]] "
"[<link>]\n" },
{ "create-vnic", do_create_vnic,
" create-vnic [-t] -l <link> [-m <value> | auto |\n"
"\t\t {factory [-n <slot-id>]} | {random [-r <prefix>]} |\n"
"\t\t {vrrp -V <vrid> -A {inet | inet6}} [-v <vid> [-f]]\n"
"\t\t [-p <prop>=<value>[,...]] <vnic-link>" },
{ "delete-vnic", do_delete_vnic,
" delete-vnic [-t] <vnic-link>" },
{ "show-vnic", do_show_vnic,
" show-vnic [-pP] [-l <link>] [-s [-i <interval>]] "
"[<link>]\n" },
{ "create-part", do_create_part,
" create-part [-t] [-f] -l <link> [-P <pkey>]\n"
"\t\t [-R <root-dir>] <part-link>" },
{ "delete-part", do_delete_part,
" delete-part [-t] [-R <root-dir>] <part-link>"},
{ "show-part", do_show_part,
" show-part [-pP] [-o <field>,...][-l <linkover>]\n"
"\t\t [<part-link>]" },
{ "show-ib", do_show_ib,
" show-ib [-p] [-o <field>,...] [<link>]\n" },
{ "create-etherstub", do_create_etherstub,
" create-etherstub [-t] <link>" },
{ "delete-etherstub", do_delete_etherstub,
" delete-etherstub [-t] <link>" },
{ "show-etherstub", do_show_etherstub,
" show-etherstub [-t] [<link>]\n" },
{ "create-bridge", do_create_bridge,
" create-bridge [-R <root-dir>] [-P <protect>] "
"[-p <priority>]\n"
"\t\t [-m <max-age>] [-h <hello-time>] [-d <forward-delay>]\n"
"\t\t [-f <force-protocol>] [-l <link>]... <bridge>" },
{ "modify-bridge", do_modify_bridge,
" modify-bridge [-R <root-dir>] [-P <protect>] "
"[-p <priority>]\n"
"\t\t [-m <max-age>] [-h <hello-time>] [-d <forward-delay>]\n"
"\t\t [-f <force-protocol>] <bridge>" },
{ "delete-bridge", do_delete_bridge,
" delete-bridge [-R <root-dir>] <bridge>" },
{ "add-bridge", do_add_bridge,
" add-bridge [-R <root-dir>] -l <link> [-l <link>]... "
"<bridge>" },
{ "remove-bridge", do_remove_bridge,
" remove-bridge [-R <root-dir>] -l <link> [-l <link>]... "
"<bridge>" },
{ "show-bridge", do_show_bridge,
" show-bridge [-p] [-o <field>,...] [-s [-i <interval>]] "
"[<bridge>]\n"
" show-bridge -l [-p] [-o <field>,...] [-s [-i <interval>]]"
" <bridge>\n"
" show-bridge -f [-p] [-o <field>,...] [-s [-i <interval>]]"
" <bridge>\n"
" show-bridge -t [-p] [-o <field>,...] [-s [-i <interval>]]"
" <bridge>\n" },
{ "show-usage", do_show_usage,
" show-usage [-a] [-d | -F <format>] "
};
{ 0, 0, 0, 0 }
};
static const struct option show_lopts[] = {
{ 0, 0, 0, 0 }
};
static const struct option iptun_lopts[] = {
{ 0, 0, 0, 0 }
};
static char * const iptun_addropts[] = {
#define IPTUN_LOCAL 0
"local",
#define IPTUN_REMOTE 1
"remote",
NULL};
static const struct {
const char *type_name;
} iptun_types[] = {
{"ipv4", IPTUN_TYPE_IPV4},
{"ipv6", IPTUN_TYPE_IPV6},
{"6to4", IPTUN_TYPE_6TO4},
{NULL, 0}
};
static const struct option prop_longopts[] = {
{ 0, 0, 0, 0 }
};
static const struct option wifi_longopts[] = {
{ 0, 0, 0, 0 }
};
static const struct option showeth_lopts[] = {
{ 0, 0, 0, 0 }
};
static const struct option vnic_lopts[] = {
{ 0, 0, 0, 0 }
};
static const struct option part_lopts[] = {
{ 0, 0, 0, 0 }
};
static const struct option show_part_lopts[] = {
{ 0, 0, 0, 0 }
};
static const struct option etherstub_lopts[] = {
{ 0, 0, 0, 0 }
};
static const struct option usage_opts[] = {
{ 0, 0, 0, 0 }
};
static const struct option simnet_lopts[] = {
{ 0, 0, 0, 0 }
};
static const struct option bridge_lopts[] = {
};
static const struct option bridge_show_lopts[] = {
{ 0, 0, 0, 0 }
};
/*
* structures for 'dladm show-ether'
*/
static const char *ptype[] = {LEI_ATTR_NAMES};
typedef struct ether_fields_buf_s
{
char eth_link[15];
char eth_ptype[8];
char eth_state[8];
char eth_autoneg[5];
char eth_spdx[31];
char eth_pause[6];
char eth_rem_fault[16];
static const ofmt_field_t ether_fields[] = {
/* name, field width, offset callback */
{ "LINK", 16,
{ "PTYPE", 9,
{ "STATE", 9,
{ "AUTO", 6,
{ "SPEED-DUPLEX", 32,
{ "PAUSE", 7,
{ "REM_FAULT", 17,
{NULL, 0,
0, NULL}}
;
typedef struct print_ether_state {
const char *es_link;
/*
* structures for 'dladm show-link -s' (print statistics)
*/
typedef enum {
static const ofmt_field_t link_s_fields[] = {
/* name, field width, index, callback */
;
typedef struct link_args_s {
char *link_s_link;
} link_args_t;
/*
* buffer used by print functions for show-{link,phys,vlan} commands.
*/
typedef struct link_fields_buf_s {
char link_name[MAXLINKNAMELEN];
char link_class[DLADM_STRSIZE];
char link_mtu[11];
char link_state[DLADM_STRSIZE];
char link_bridge[MAXLINKNAMELEN];
char link_over[MAXLINKNAMELEN];
char link_phys_state[DLADM_STRSIZE];
char link_phys_media[DLADM_STRSIZE];
char link_phys_speed[DLADM_STRSIZE];
char link_flags[6];
char link_vlan_vid[6];
/*
* structures for 'dladm show-link'
*/
static const ofmt_field_t link_fields[] = {
/* name, field width, index, callback */
{ "LINK", 12,
{ "CLASS", 10,
{ "MTU", 7,
{ "STATE", 9,
{ "BRIDGE", 11,
{ "OVER", DLPI_LINKNAME_MAX,
;
/*
* structures for 'dladm show-aggr'
*/
typedef struct laggr_fields_buf_s {
char laggr_name[DLPI_LINKNAME_MAX];
char laggr_policy[9];
char laggr_lacpactivity[14];
char laggr_lacptimer[DLADM_STRSIZE];
char laggr_flags[7];
typedef struct laggr_args_s {
int laggr_lport; /* -1 indicates the aggr itself */
const char *laggr_link;
} laggr_args_t;
static const ofmt_field_t laggr_fields[] = {
/* name, field width, offset, callback */
{ "LINK", 16,
{ "POLICY", 9,
{ "LACPACTIVITY", 14,
{ "LACPTIMER", 12,
{ "FLAGS", 8,
;
/*
* structures for 'dladm show-aggr -x'.
*/
typedef enum {
static const ofmt_field_t aggr_x_fields[] = {
/* name, field width, index callback */
;
/*
* structures for 'dladm show-aggr -s'.
*/
typedef enum {
static const ofmt_field_t aggr_s_fields[] = {
;
/*
* structures for 'dladm show-aggr -L'.
*/
typedef enum {
static const ofmt_field_t aggr_l_fields[] = {
/* name, field width, index */
;
/*
* structures for 'dladm show-phys'
*/
static const ofmt_field_t phys_fields[] = {
/* name, field width, offset */
{ "LINK", 13,
{ "MEDIA", 21,
{ "STATE", 11,
{ "SPEED", 7,
{ "DUPLEX", 10,
{ "DEVICE", 13,
{ "FLAGS", 7,
;
/*
* structures for 'dladm show-phys -m'
*/
typedef enum {
static const ofmt_field_t phys_m_fields[] = {
/* name, field width, offset */
;
/*
* structures for 'dladm show-phys -H'
*/
typedef enum {
#define RINGSTRLEN 21
static const ofmt_field_t phys_h_fields[] = {
;
/*
* structures for 'dladm show-vlan'
*/
static const ofmt_field_t vlan_fields[] = {
{ "LINK", 16,
{ "VID", 9,
{ "OVER", 13,
{ "FLAGS", 7,
;
/*
* structures common to 'dladm scan-wifi' and 'dladm show-wifi'
* callback will be determined in parse_wifi_fields.
*/
static ofmt_field_t wifi_common_fields[] = {
/*
* the 'show-wifi' command supports all the fields in wifi_common_fields
* plus the AUTH and STATUS fields.
*/
/* copy wifi_common_fields here */
};
static char *all_scan_wifi_fields =
"link,essid,bssid,sec,strength,mode,speed,bsstype";
static char *all_show_wifi_fields =
"link,status,essid,sec,strength,mode,speed,auth,bssid,bsstype";
static char *def_scan_wifi_fields =
"link,essid,bssid,sec,strength,mode,speed";
static char *def_show_wifi_fields =
"link,status,essid,sec,strength,mode,speed";
/*
* structures for 'dladm show-linkprop'
*/
typedef enum {
static const ofmt_field_t linkprop_fields[] = {
/* name, field width, index */
;
#define MAX_PROP_LINE 512
typedef struct show_linkprop_state {
char ls_link[MAXLINKNAMELEN];
char *ls_line;
char **ls_propvals;
typedef struct set_linkprop_state {
const char *ls_name;
typedef struct linkprop_args_s {
char *ls_propname;
/*
* structures for 'dladm show-secobj'
*/
typedef struct secobj_fields_buf_s {
char ss_obj_name[DLADM_SECOBJ_VAL_MAX];
char ss_class[20];
char ss_val[30];
static const ofmt_field_t secobj_fields[] = {
{ "OBJECT", 21,
{ "CLASS", 21,
{ "VALUE", 31,
;
/*
* structures for 'dladm show-vnic'
*/
typedef struct vnic_fields_buf_s
{
char vnic_link[DLPI_LINKNAME_MAX];
char vnic_over[DLPI_LINKNAME_MAX];
char vnic_speed[6];
char vnic_macaddr[18];
char vnic_macaddrtype[19];
char vnic_vid[6];
static const ofmt_field_t vnic_fields[] = {
{ "LINK", 13,
{ "OVER", 13,
{ "SPEED", 7,
{ "MACADDRESS", 18,
{ "MACADDRTYPE", 20,
{ "VID", 7,
;
/*
* structures for 'dladm show-ib'
*/
typedef struct ib_fields_buf_s
{
char ib_link[DLPI_LINKNAME_MAX];
char ib_hcaguid[17];
char ib_portguid[17];
char ib_portnum[4];
char ib_state[6];
char ib_pkeys[MAXPKEYSTRSZ];
static const ofmt_field_t ib_fields[] = {
{ "LINK", 13,
{ "HCAGUID", IBGUIDSTRLEN,
{ "PORTGUID", IBGUIDSTRLEN,
{ "PORT", IBPORTSTRLEN,
{ "STATE", 7,
{ "PKEYS", 18,
/*
* structures for 'dladm show-part'
*/
typedef struct part_fields_buf_s
{
char part_link[DLPI_LINKNAME_MAX];
char part_pkey[5];
char part_over[DLPI_LINKNAME_MAX];
char part_state[8];
char part_flags[5];
static const ofmt_field_t part_fields[] = {
{ "LINK", 13,
{ "PKEY", MAXPKEYLEN,
{ "OVER", 13,
{ "STATE", 9,
{ "FLAGS", 5,
/*
* structures for 'dladm show-simnet'
*/
typedef struct simnet_fields_buf_s
{
char simnet_name[DLPI_LINKNAME_MAX];
char simnet_media[DLADM_STRSIZE];
char simnet_macaddr[18];
static const ofmt_field_t simnet_fields[] = {
{ "LINK", 12,
{ "MEDIA", 20,
{ "MACADDRESS", 18,
{ "OTHERLINK", 12,
;
/*
* structures for 'dladm show-usage'
*/
typedef struct usage_fields_buf_s {
char usage_link[12];
char usage_duration[10];
char usage_ipackets[9];
char usage_rbytes[10];
char usage_opackets[9];
char usage_obytes[10];
char usage_bandwidth[14];
static const ofmt_field_t usage_fields[] = {
{ "LINK", 13,
{ "DURATION", 11,
{ "IPACKETS", 10,
{ "RBYTES", 11,
{ "OPACKETS", 10,
{ "OBYTES", 11,
{ "BANDWIDTH", 15,
;
/*
* structures for 'dladm show-usage link'
*/
typedef struct usage_l_fields_buf_s {
char usage_l_link[12];
char usage_l_stime[13];
char usage_l_etime[13];
char usage_l_rbytes[8];
char usage_l_obytes[8];
char usage_l_bandwidth[14];
static const ofmt_field_t usage_l_fields[] = {
/* name, field width, offset */
{ "LINK", 13,
{ "START", 14,
{ "END", 14,
{ "RBYTES", 9,
{ "OBYTES", 9,
{ "BANDWIDTH", 15,
;
/* IPTUN_*FLAG_INDEX values are indices into iptun_flags below. */
/*
* structures for 'dladm show-iptun'
*/
typedef struct iptun_fields_buf_s {
char iptun_name[MAXLINKNAMELEN];
char iptun_type[5];
char iptun_laddr[NI_MAXHOST];
char iptun_raddr[NI_MAXHOST];
static const ofmt_field_t iptun_fields[] = {
{ "LINK", 16,
{ "TYPE", 6,
{ "FLAGS", 7,
{ "LOCAL", 20,
{ "REMOTE", 20,
};
/*
* structures for 'dladm show-bridge'. These are based on sections 14.8.1.1.3
* and 14.8.1.2.2 of IEEE 802.1D-2004.
*/
typedef struct bridge_fields_buf_s {
static ofmt_field_t bridge_fields[] = {
/* name, field width, offset, callback */
{ "BRIDGE", 12,
{ "PROTECT", 8,
{ "ADDRESS", 19,
{ "PRIORITY", 9,
{ "BMAXAGE", 8,
{ "BHELLOTIME", 11,
{ "BFWDDELAY", 10,
{ "FORCEPROTO", 11,
{ "TCTIME", 10,
{ "TCCOUNT", 10,
{ "TCHANGE", 10,
{ "DESROOT", 23,
{ "ROOTCOST", 11,
{ "ROOTPORT", 11,
{ "MAXAGE", 8,
{ "HELLOTIME", 10,
{ "FWDDELAY", 9,
{ "HOLDTIME", 9,
/*
* structures for 'dladm show-bridge -l'. These are based on 14.4.1.2.3 and
* 14.8.2.1.3 of IEEE 802.1D-2004.
*/
typedef struct bridge_link_fields_buf_s {
char bridgel_link[MAXLINKNAMELEN];
static ofmt_field_t bridge_link_fields[] = {
/* name, field width, offset, callback */
{ "LINK", 12,
{ "INDEX", 8,
{ "STATE", 12,
{ "UPTIME", 8,
{ "OPERCOST", 9,
{ "OPERP2P", 8,
{ "OPEREDGE", 9,
{ "DESROOT", 22,
{ "DESCOST", 11,
{ "DESBRIDGE", 22,
{ "DESPORT", 8,
{ "TCACK", 6,
/*
* structures for 'dladm show-bridge -s'. These are not based on IEEE
* 802.1D-2004.
*/
typedef struct bridge_statfields_buf_s {
char bridges_name[MAXLINKNAMELEN];
char bridges_drops[UINT64_DIG];
char bridges_forwards[UINT64_DIG];
char bridges_mbcast[UINT64_DIG];
char bridges_unknown[UINT64_DIG];
char bridges_recv[UINT64_DIG];
char bridges_sent[UINT64_DIG];
static ofmt_field_t bridge_statfields[] = {
/* name, field width, offset, callback */
{ "BRIDGE", 12,
{ "DROPS", 12,
{ "FORWARDS", 12,
{ "MBCAST", 12,
{ "UNKNOWN", 12,
{ "RECV", 12,
{ "SENT", 12,
/*
* structures for 'dladm show-bridge -s -l'. These are based in part on
* section 14.6.1.1.3 of IEEE 802.1D-2004.
*/
typedef struct bridge_link_statfields_buf_s {
char bridgels_link[MAXLINKNAMELEN];
char bridgels_cfgbpdu[ULONG_DIG];
char bridgels_tcnbpdu[ULONG_DIG];
char bridgels_rstpbpdu[ULONG_DIG];
char bridgels_txbpdu[ULONG_DIG];
static ofmt_field_t bridge_link_statfields[] = {
/* name, field width, offset, callback */
{ "LINK", 12,
{ "CFGBPDU", 9,
{ "TCNBPDU", 9,
{ "RSTPBPDU", 9,
{ "TXBPDU", 9,
{ "DROPS", 9,
{ "RECV", 9,
{ "XMIT", 9,
/*
* structures for 'dladm show-bridge -f'. These are based in part on
* section 14.7.6.3.3 of IEEE 802.1D-2004.
*/
typedef struct bridge_fwd_fields_buf_s {
char bridgef_age[8];
char bridgef_flags[6];
static ofmt_field_t bridge_fwd_fields[] = {
/* name, field width, offset, callback */
{ "DEST", 17,
{ "AGE", 7,
{ "FLAGS", 6,
{ "OUTPUT", 12,
/*
* structures for 'dladm show-bridge -t'.
*/
typedef struct bridge_trill_fields_buf_s {
char bridget_nick[6];
char bridget_flags[6];
char bridget_link[MAXLINKNAMELEN];
char bridget_nexthop[18];
static ofmt_field_t bridge_trill_fields[] = {
/* name, field width, offset, callback */
{ "NICK", 5,
{ "FLAGS", 6,
{ "LINK", 12,
{ "NEXTHOP", 17,
static char *progname;
static sig_atomic_t signalled;
/*
* Handle to libdladm. Opened in main() before the sub-command
* specific function is called.
*/
#define DLADM_ETHERSTUB_NAME "etherstub"
static void
usage(void)
{
int i;
"\n"));
}
/* close dladm handle if it was opened */
}
int
{
int i;
#if !defined(TEXT_DOMAIN)
#define TEXT_DOMAIN "SYS_TEST"
#endif
(void) textdomain(TEXT_DOMAIN);
if (argc < 2)
usage();
/* Open the libdladm handle */
}
return (EXIT_SUCCESS);
}
}
usage();
return (EXIT_FAILURE);
}
/*ARGSUSED*/
static int
{
char timebuf[20];
/*
* Only show usage information for existing links unless '-a'
* is specified.
*/
if (!state->us_showall) {
return (status);
}
if ((flags & DLADM_OPT_ACTIVE) == 0)
return (DLADM_STATUS_LINKINVAL);
}
return (DLADM_STATUS_OK);
}
static int
{
char buf[DLADM_STRSIZE];
double bw;
/*
* Only show usage information for existing links unless '-a'
* is specified.
*/
if (!state->us_showall) {
return (status);
}
if ((flags & DLADM_OPT_ACTIVE) == 0)
return (DLADM_STATUS_LINKINVAL);
}
if (!state->us_printheader) {
(void) printf("# Time");
}
(void) printf("\n");
}
} else {
}
(void) printf("\n");
}
}
return (DLADM_STATUS_OK);
}
buf);
buf);
return (DLADM_STATUS_OK);
}
static int
{
char buf[DLADM_STRSIZE];
/*
* Only show usage information for existing links unless '-a'
* is specified.
*/
if (!state->us_showall) {
return (status);
}
if ((flags & DLADM_OPT_ACTIVE) == 0)
return (DLADM_STATUS_LINKINVAL);
}
return (DLADM_STATUS_OK);
}
static boolean_t
valid_formatspec(char *formatspec_str)
{
return (B_TRUE);
return (B_FALSE);
}
/*ARGSUSED*/
static void
{
int opt;
char *fields_str = NULL;
char *formatspec_str = NULL;
char *all_l_fields =
"link,start,end,rbytes,obytes,bandwidth";
switch (opt) {
case 'd':
break;
case 'a':
break;
case 'f':
break;
case 's':
break;
case 'e':
break;
case 'o':
fields_str = optarg;
break;
case 'F':
break;
default:
break;
}
}
die("show-usage requires a file");
if (!state.us_showall &&
((flags & DLADM_OPT_ACTIVE) == 0))) {
}
}
die("incompatible -d and -F options");
if (state.us_parsable)
&ofmt);
} else {
&ofmt);
}
if (d_arg) {
/* Print log dates */
!F_arg) {
/* Print summary */
/* Print log entries for named resource */
} else {
/* Print time and information for each link */
}
if (status != DLADM_STATUS_OK)
}
static void
{
int option;
int key = 0;
char name[MAXLINKNAMELEN];
char propstr[DLADM_STRSIZE];
int i;
switch (option) {
case 'd':
die("too many ports specified");
break;
case 'P':
if (P_arg)
break;
case 'u':
if (u_arg)
mac_addr))
break;
case 'l':
/*
* Ended with digit, possibly a link name.
*/
die("too many ports specified");
break;
}
/* FALLTHROUGH */
case 'L':
if (l_arg)
break;
case 'T':
if (T_arg)
break;
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'f':
flags |= DLADM_OPT_FORCE;
break;
case 'R':
break;
case 'p':
break;
default:
break;
}
}
usage();
/* get key value or the aggregation name (required last argument) */
usage();
}
if (!dladm_valid_linkname(name))
} else {
}
for (n = 0; n < ndev; n++) {
}
}
for (n = 0; n < nlink; n++) {
}
}
lacp_timer, flags);
if (status != DLADM_STATUS_OK)
goto done;
!= DLADM_STATUS_OK)
die("invalid aggregation property");
return;
if (status != DLADM_STATUS_OK)
goto done;
if (pstatus != DLADM_STATUS_OK) {
"aggr creation succeeded but "
}
}
done:
if (status != DLADM_STATUS_OK) {
if (status == DLADM_STATUS_NONOTIF) {
"use -f (see dladm(1M))");
} else {
}
}
}
/*
* arg is either the key or the aggr name. Validate it and convert it to
* the linkid if altroot is NULL.
*/
static dladm_status_t
{
int key = 0;
return (DLADM_STATUS_LINKINVAL);
return (DLADM_STATUS_OK);
NULL);
} else {
}
return (status);
}
static void
{
int option;
opterr = 0;
switch (option) {
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
default:
break;
}
}
/* get key value or the aggregation name (required last argument) */
usage();
if (status != DLADM_STATUS_OK)
goto done;
done:
if (status != DLADM_STATUS_OK)
}
static void
{
int option;
NULL)) != -1) {
switch (option) {
case 'd':
die("too many ports specified");
break;
case 'l':
die("too many ports specified");
break;
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'f':
flags |= DLADM_OPT_FORCE;
break;
case 'R':
break;
default:
break;
}
}
usage();
/* get key value or the aggregation name (required last argument) */
usage();
goto done;
}
for (n = 0; n < ndev; n++) {
}
}
for (n = 0; n < nlink; n++) {
}
}
done:
if (status != DLADM_STATUS_OK) {
/*
* checking DLADM_STATUS_NOTSUP is a temporary workaround
* and should be removed once 6399681 is fixed.
*/
if (status == DLADM_STATUS_NOTSUP) {
die("add operation failed: link capabilities don't "
"match");
} else if (status == DLADM_STATUS_NONOTIF) {
"use -f (see dladm(1M))");
} else {
}
}
}
static void
{
int option;
switch (option) {
case 'd':
die("too many ports specified");
break;
case 'l':
die("too many ports specified");
break;
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
default:
break;
}
}
usage();
/* get key value or the aggregation name (required last argument) */
usage();
if (status != DLADM_STATUS_OK)
goto done;
for (n = 0; n < ndev; n++) {
}
}
for (n = 0; n < nlink; n++) {
}
}
done:
if (status != DLADM_STATUS_OK)
}
static void
{
int option;
uint8_t modify_mask = 0;
opterr = 0;
NULL)) != -1) {
switch (option) {
case 'P':
break;
case 'u':
if (modify_mask & DLADM_AGGR_MODIFY_MAC)
mac_addr))
break;
case 'l':
case 'L':
break;
case 'T':
break;
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
default:
break;
}
}
if (modify_mask == 0)
die("at least one of the -PulT options must be specified");
/* get key value or the aggregation name (required last argument) */
usage();
if (status != DLADM_STATUS_OK)
goto done;
flags);
done:
if (status != DLADM_STATUS_OK)
}
/*ARGSUSED*/
static void
{
/*
* get the key or the name of the aggregation (optional last argument)
*/
if (argc == 2) {
goto done;
} else if (argc > 2) {
usage();
}
done:
if (status != DLADM_STATUS_OK) {
if (argc == 2) {
} else {
}
}
}
static void
{
char drv[DLPI_LINKNAME_MAX];
int vid = 0;
int option;
char vlan[MAXLINKNAMELEN];
char propstr[DLADM_STRSIZE];
opterr = 0;
switch (option) {
case 'v':
if (vid != 0)
break;
case 'l':
break;
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
case 'p':
break;
case 'f':
flags |= DLADM_OPT_FORCE;
break;
default:
break;
}
}
/* get vlan name if there is any */
usage();
}
} else {
(ppa >= 1000) ||
DLPI_SUCCESS)) {
}
}
}
!= DLADM_STATUS_OK)
die("invalid vlan property");
switch (status) {
case DLADM_STATUS_OK:
break;
case DLADM_STATUS_NOTSUP:
die("VLAN over '%s' may require lowered MTU; must use -f (see "
"dladm(1M))", link);
break;
case DLADM_STATUS_LINKBUSY:
die("VLAN over '%s' may not use default_tag ID "
"(see dladm(1M))", link);
break;
default:
}
}
static void
{
int option;
opterr = 0;
switch (option) {
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
default:
break;
}
}
/* get VLAN link name (required last argument) */
usage();
NULL);
if (status != DLADM_STATUS_OK)
goto done;
done:
if (status != DLADM_STATUS_OK)
}
/*ARGSUSED*/
static void
{
}
static void
{
int option;
opterr = 0;
switch (option) {
case 'R':
break;
default:
break;
}
}
/* get link1 and link2 name (required the last 2 arguments) */
usage();
}
/*ARGSUSED*/
static void
{
/* get link name (required the last argument) */
if (argc > 2)
usage();
if (argc == 2) {
}
if (argc == 2)
else
}
}
/*ARGSUSED*/
static int
{
char name[MAXLINKNAMELEN];
char mediabuf[DLADM_STRSIZE];
char classbuf[DLADM_STRSIZE];
MAXLINKNAMELEN) == DLADM_STATUS_OK) {
}
return (DLADM_WALK_CONTINUE);
}
/*ARGSUSED*/
static void
{
if (argc != 1)
die("invalid arguments");
"CLASS", "MEDIA", "FLAGS");
}
/*
* Delete inactive physical links.
*/
/*ARGSUSED*/
static int
{
!= DLADM_STATUS_OK) {
return (DLADM_WALK_CONTINUE);
}
return (DLADM_WALK_CONTINUE);
}
/*ARGSUSED*/
static void
{
if (argc > 1)
usage();
/*
* Force all the devices to attach, therefore all the network physical
* devices can be known to the dlmgmtd daemon.
*/
}
/*
* Print the active topology information.
*/
void
{
char tmpbuf[MAXLINKNAMELEN];
switch (class) {
case DATALINK_CLASS_AGGR:
case DATALINK_CLASS_PHYS:
case DATALINK_CLASS_ETHERSTUB:
sizeof (lbuf->link_bridge));
if (status != DLADM_STATUS_OK &&
break;
}
switch (class) {
case DATALINK_CLASS_VLAN: {
break;
}
break;
}
case DATALINK_CLASS_AGGR: {
int i;
break;
}
break;
}
}
}
break;
}
case DATALINK_CLASS_VNIC: {
break;
}
break;
}
case DATALINK_CLASS_PART: {
break;
}
break;
}
case DATALINK_CLASS_BRIDGE: {
break;
}
if (tmpbuf[0] != '\0')
break;
}
for (i = 0; i < nports; i++) {
break;
}
if (i != nports - 1) {
}
}
break;
}
case DATALINK_CLASS_SIMNET: {
break;
}
}
break;
}
}
}
static dladm_status_t
{
char link[MAXLINKNAMELEN];
goto done;
}
goto done;
}
if (class == DATALINK_CLASS_PHYS) {
DLADM_OPT_ACTIVE)) != DLADM_STATUS_OK) {
goto done;
}
if (!dpa.dp_novanity)
goto link_mtu;
/*
* This is a physical link that does not have
* vanity naming support.
*/
DLPI_SUCCESS) {
goto done;
}
dlpi_close(dh);
goto done;
}
dlpi_close(dh);
} else {
if (status != DLADM_STATUS_OK)
goto done;
}
}
"%s", link);
"%u", mtu);
}
done:
return (status);
}
/* ARGSUSED */
static int
{
/*
* first get all the link attributes into lbuf;
*/
return (DLADM_WALK_CONTINUE);
}
static boolean_t
{
case LINK_S_LINK:
break;
case LINK_S_IPKTS:
break;
case LINK_S_RBYTES:
break;
case LINK_S_IERRORS:
break;
case LINK_S_OPKTS:
break;
case LINK_S_OBYTES:
break;
case LINK_S_OERRORS:
break;
default:
die("invalid input");
break;
}
return (B_TRUE);
}
static int
{
char link[DLPI_LINKNAME_MAX];
if (state->ls_firstonly) {
if (state->ls_donefirst)
return (DLADM_WALK_CONTINUE);
} else {
}
DLPI_LINKNAME_MAX) != DLADM_STATUS_OK) {
return (DLADM_WALK_CONTINUE);
}
if (class == DATALINK_CLASS_PHYS) {
return (DLADM_WALK_CONTINUE);
}
if (dpa.dp_novanity)
else
} else {
}
return (DLADM_WALK_CONTINUE);
}
static dladm_status_t
{
"%s", link);
if (ginfop->lg_mac_fixed) {
} else {
}
return (DLADM_STATUS_OK);
}
static boolean_t
{
char tmpbuf[DLADM_STRSIZE];
const char *objname;
if (is_port) {
objname = "?";
else
} else {
objname = l->laggr_link;
}
case AGGR_X_LINK:
break;
case AGGR_X_PORT:
if (is_port) {
}
break;
case AGGR_X_SPEED:
break;
case AGGR_X_DUPLEX:
break;
case AGGR_X_STATE:
break;
case AGGR_X_ADDRESS:
(void) dladm_aggr_macaddr2str(
tmpbuf);
break;
case AGGR_X_PORTSTATE:
if (is_port) {
tmpbuf);
}
break;
}
err:
*(l->laggr_status) = DLADM_STATUS_OK;
return (B_TRUE);
}
static dladm_status_t
{
int i;
if (status != DLADM_STATUS_OK)
goto done;
largs.laggr_lport = i;
if (status != DLADM_STATUS_OK)
goto done;
}
done:
return (status);
}
static boolean_t
{
int portnum;
if (!is_port)
return (B_FALSE); /* cannot happen! */
portnum = l->laggr_lport;
case AGGR_L_LINK:
break;
case AGGR_L_PORT:
break;
case AGGR_L_AGGREGATABLE:
break;
case AGGR_L_SYNC:
break;
case AGGR_L_COLL:
break;
case AGGR_L_DIST:
break;
case AGGR_L_DEFAULTED:
break;
case AGGR_L_EXPIRED:
break;
}
*(l->laggr_status) = DLADM_STATUS_OK;
return (B_TRUE);
}
static dladm_status_t
{
int i;
largs.laggr_lport = i;
if (status != DLADM_STATUS_OK)
goto done;
}
done:
return (status);
}
static boolean_t
{
int portnum;
stat = l->laggr_status;
*stat = DLADM_STATUS_OK;
if (is_port) {
portnum = l->laggr_lport;
goto err;
}
diff_stats = l->laggr_diffstats;
}
case AGGR_S_LINK:
break;
case AGGR_S_PORT:
/*
* if (is_port), buf has port name. Otherwise we print
* STR_UNDEF_VAL
*/
break;
case AGGR_S_IPKTS:
if (is_port) {
} else {
l->laggr_pktsumtot->ipackets);
}
break;
case AGGR_S_RBYTES:
if (is_port) {
diff_stats->rbytes);
} else {
l->laggr_pktsumtot->rbytes);
}
break;
case AGGR_S_OPKTS:
if (is_port) {
} else {
l->laggr_pktsumtot->opackets);
}
break;
case AGGR_S_OBYTES:
if (is_port) {
diff_stats->obytes);
} else {
l->laggr_pktsumtot->obytes);
}
break;
case AGGR_S_IPKTDIST:
if (is_port) {
(double)diff_stats->ipackets/
}
break;
case AGGR_S_OPKTDIST:
if (is_port) {
(double)diff_stats->opackets/
}
break;
}
return (B_TRUE);
err:
return (B_TRUE);
}
static dladm_status_t
{
int i;
/* sum the ports statistics */
/* Allocate memory to keep stats of each port */
/* Bail out; no memory */
return (DLADM_STATUS_NOMEM);
}
DLADM_OPT_ACTIVE)) != DLADM_STATUS_OK) {
goto done;
}
/*
* Let's re-use gs_prevstats[] to store the difference of the
* counters since last use. We will store the new stats from
* port_stat[] once we have the stats displayed.
*/
&state->gs_prevstats[i]);
&state->gs_prevstats[i]);
}
if (status != DLADM_STATUS_OK)
goto done;
largs.laggr_lport = i;
if (status != DLADM_STATUS_OK)
goto done;
}
done:
return (status);
}
static dladm_status_t
{
char link[MAXLINKNAMELEN];
return (status);
}
return (DLADM_STATUS_NOTFOUND);
if (status != DLADM_STATUS_OK)
return (status);
else if (state->gs_extended)
else
done:
return (status);
}
/* ARGSUSED */
static int
{
return (DLADM_WALK_CONTINUE);
}
static void
{
int option;
char linkname[MAXLINKNAMELEN];
char *fields_str = NULL;
char *all_active_fields = "link,class,mtu,state,bridge,over";
char *all_inactive_fields = "link,class,bridge,over";
char *allstat_fields =
"link,ipackets,rbytes,ierrors,opackets,obytes,oerrors";
opterr = 0;
switch (option) {
case 'p':
if (p_arg)
break;
case 's':
if (s_arg)
break;
case 'P':
if (flags != DLADM_OPT_ACTIVE)
break;
case 'S':
if (S_arg)
break;
case 'o':
fields_str = optarg;
break;
case 'i':
if (i_arg)
break;
default:
break;
}
}
die("the option -i can be used only with -s or -S");
die("the -s option cannot be used with -S");
die("the option -P cannot be used with -s");
/* get link name (optional last argument) */
uint32_t f;
die("link name too long");
}
if (!(f & flags)) {
"a temporary link" : "temporarily removed");
}
usage();
}
die("-p requires -o");
if (S_arg) {
return;
}
die("\"-o all\" is invalid with -p");
if (s_arg)
else if (flags & DLADM_OPT_ACTIVE)
else
}
if (s_arg) {
return;
}
if (state.ls_parsable)
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
static void
{
int option;
int key;
char *fields_str = NULL;
char *all_fields =
"link,policy,addrpolicy,lacpactivity,lacptimer,flags";
char *all_lacp_fields =
"link,port,aggregatable,sync,coll,dist,defaulted,expired";
char *all_stats_fields =
"link,port,ipackets,rbytes,opackets,obytes,ipktdist,opktdist";
char *all_extended_fields =
"link,port,speed,duplex,state,address,portstate";
const ofmt_field_t *pf;
opterr = 0;
switch (option) {
case 'L':
if (L_arg)
break;
case 'p':
if (p_arg)
break;
case 'x':
if (x_arg)
break;
case 'P':
if (flags != DLADM_OPT_ACTIVE)
break;
case 's':
if (s_arg)
break;
case 'o':
fields_str = optarg;
break;
case 'i':
if (i_arg)
break;
default:
break;
}
}
die("-p requires -o");
die("\"-o all\" is invalid with -p");
die("the option -i can be used only with -s");
die("the option -%c cannot be used with -s",
}
die("the option -P cannot be used with -L");
/* get aggregation key or aggrname (optional last argument) */
} else {
}
if (status != DLADM_STATUS_OK)
usage();
}
else if (state.gs_extended)
else
}
pf = aggr_l_fields;
pf = aggr_s_fields;
} else if (state.gs_extended) {
pf = aggr_x_fields;
} else {
pf = laggr_fields;
}
if (state.gs_parsable)
if (s_arg) {
return;
}
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
static dladm_status_t
{
if (status != DLADM_STATUS_OK)
goto done;
if (!dpa.dp_novanity) {
} else {
/*
* This is a physical link that does not have
* vanity naming support.
*/
}
islink)) / 1000000ull));
} else {
"%s", link);
}
done:
return (status);
}
typedef struct {
char *ms_link;
/*
* callback for ofmt_print()
*/
static boolean_t
{
case PHYS_M_LINK:
break;
case PHYS_M_SLOT:
if (is_primary)
else
break;
case PHYS_M_ADDRESS:
break;
case PHYS_M_INUSE:
gettext("no"));
break;
case PHYS_M_CLIENT:
/*
* CR 6678526: resolve link id to actual link name if
* it is valid.
*/
break;
}
return (B_TRUE);
}
typedef struct {
char *hs_link;
static boolean_t
{
int i;
int start = -1;
int end = -1;
char ringstr[RINGSTRLEN];
char ringsubstr[RINGSTRLEN];
case PHYS_H_LINK:
break;
case PHYS_H_RINGTYPE:
break;
case PHYS_H_RINGS:
ringstr[0] = '\0';
for (i = 0; i < attr->hg_n_rings; i++) {
if (start == -1) {
} else {
if (first) {
(void) snprintf(
RINGSTRLEN, "%d",
start);
} else {
(void) snprintf(
RINGSTRLEN, ",%d",
start);
}
} else {
if (first) {
(void) snprintf(
"%d-%d",
} else {
(void) snprintf(
",%d-%d",
}
}
}
}
/* The last one */
if (start != -1) {
if (first) {
start);
} else {
}
} else {
",%d", start);
} else {
}
}
}
break;
case PHYS_H_CLIENTS:
} else {
}
break;
}
return (B_TRUE);
}
/*
* callback for dladm_walk_macaddr, invoked for each MAC address slot
*/
static boolean_t
{
return (B_TRUE);
}
/*
* invoked by show-phys -m for each physical data-link
*/
static dladm_status_t
{
}
/*
* callback for dladm_walk_hwgrp, invoked for each MAC hwgrp
*/
static boolean_t
{
return (B_TRUE);
}
/* invoked by show-phys -H for each physical data-link */
static dladm_status_t
{
}
/*
* Parse the "local=<laddr>,remote=<raddr>" sub-options for the -a option of
* *-iptun subcommands.
*/
static void
{
char *addrval;
while (*addrarg != '\0') {
case IPTUN_LOCAL:
sizeof (params->iptun_param_laddr)) >=
sizeof (params->iptun_param_laddr))
die("tunnel source address is too long");
break;
case IPTUN_REMOTE:
sizeof (params->iptun_param_raddr)) >=
sizeof (params->iptun_param_raddr))
die("tunnel destination address is too long");
break;
default:
break;
}
}
}
/*
* Convenience routine to process iptun-create/modify/delete subcommand
* arguments.
*/
static void
{
int option;
opterr = 0;
-1) {
switch (option) {
case 'a':
break;
case 'R':
break;
case 't':
*flags &= ~DLADM_OPT_PERSIST;
break;
case 'T':
break;
default:
break;
}
}
/* Get the required tunnel name argument. */
usage();
die("tunnel name is too long");
}
static void
{
char name[MAXLINKNAMELEN];
use);
if (status != DLADM_STATUS_OK)
}
static void
{
char name[MAXLINKNAMELEN];
if (status != DLADM_STATUS_OK)
if (status != DLADM_STATUS_OK)
}
static void
{
char name[MAXLINKNAMELEN];
if (status != DLADM_STATUS_OK)
}
static void
{
char option;
const char *fields_str = NULL;
opterr = 0;
switch (option) {
case 'o':
fields_str = optarg;
break;
case 'p':
break;
case 'P':
break;
default:
break;
}
}
/*
* Get the optional tunnel name argument. If there is one, it must
* be the last thing remaining on the command-line.
*/
flags);
} else {
NULL)) == DLADM_STATUS_OK)
}
if (status != DLADM_STATUS_OK)
}
/* ARGSUSED */
static void
{
/*
* Get the optional tunnel name argument. If there is one, it must
* be the last thing remaining on the command-line.
*/
usage();
}
if (status == DLADM_STATUS_OK)
if (status != DLADM_STATUS_OK)
}
/* ARGSUSED */
static void
{
/*
* Get the optional tunnel name argument. If there is one, it must
* be the last thing remaining on the command-line.
*/
usage();
}
if (status == DLADM_STATUS_OK)
if (status != DLADM_STATUS_OK)
}
static iptun_type_t
iptun_gettypebyname(char *typestr)
{
int i;
return (iptun_types[i].type_value);
}
}
return (IPTUN_TYPE_UNKNOWN);
}
static const char *
{
int i;
return (iptun_types[i].type_name);
}
return (NULL);
}
static dladm_status_t
{
const char *laddr;
const char *raddr;
if (status != DLADM_STATUS_OK)
return (status);
/* LINK */
if (status != DLADM_STATUS_OK)
return (status);
/* TYPE */
sizeof (lbuf.iptun_type));
/* FLAGS */
/* LOCAL */
else
/* REMOTE */
else
return (DLADM_STATUS_OK);
}
static int
{
return (DLADM_WALK_CONTINUE);
}
static dladm_status_t
{
char link[MAXLINKNAMELEN];
goto done;
}
if (class != DATALINK_CLASS_PHYS) {
goto done;
}
goto done;
}
else
done:
return (status);
}
/* ARGSUSED */
static int
{
return (DLADM_WALK_CONTINUE);
}
/*
* Print the active topology information.
*/
static dladm_status_t
{
goto done;
}
goto done;
}
goto done;
}
done:
return (status);
}
/* ARGSUSED */
static int
{
if (status != DLADM_STATUS_OK)
goto done;
done:
return (DLADM_WALK_CONTINUE);
}
static void
{
int option;
char *fields_str = NULL;
char *all_active_fields =
"link,media,state,speed,duplex,device";
char *all_inactive_fields = "link,device,media,flags";
char *all_mac_fields = "link,slot,address,inuse,client";
char *all_hwgrp_fields = "link,ringtype,rings,clients";
const ofmt_field_t *pf;
opterr = 0;
switch (option) {
case 'p':
if (p_arg)
break;
case 'P':
if (flags != DLADM_OPT_ACTIVE)
break;
case 'o':
fields_str = optarg;
break;
case 'm':
break;
case 'H':
break;
default:
break;
}
}
die("-p requires -o");
die("-m cannot combine with -H");
die("\"-o all\" is invalid with -p");
/* get link name (optional last argument) */
}
usage();
}
/*
* We can only display the factory MAC addresses of
* active data-links.
*/
die("-m not compatible with -P");
}
} else {
}
}
pf = phys_m_fields;
pf = phys_h_fields;
} else {
pf = phys_fields;
}
if (state.ls_parsable)
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
static void
{
int option;
char *fields_str = NULL;
opterr = 0;
switch (option) {
case 'p':
if (p_arg)
break;
case 'P':
if (flags != DLADM_OPT_ACTIVE)
break;
case 'o':
fields_str = optarg;
break;
default:
break;
}
}
/* get link name (optional last argument) */
}
usage();
}
fields_str = NULL;
if (state.ls_parsable)
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
static void
{
char devname[MAXLINKNAMELEN];
char name[MAXLINKNAMELEN];
int option;
int mac_slot = -1;
char propstr[DLADM_STRSIZE];
int vid = 0;
opterr = 0;
switch (option) {
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
case 'l':
die("link name too long");
break;
case 'm':
die("cannot specify -m option twice");
/*
* A fixed MAC address must be specified
* by its value, not by the keyword 'fixed'.
*/
die("'fixed' is not a valid MAC address");
}
&mac_addr_type) != DLADM_STATUS_OK) {
/* MAC address specified by value */
die("invalid MAC address");
else
die("out of memory");
}
}
break;
case 'n':
errno = 0;
die("invalid slot number");
break;
case 'p':
break;
case 'r':
die("invalid MAC address");
else
die("out of memory");
}
break;
case 'V':
}
break;
case 'A':
else
break;
case 'v':
if (vid != 0)
break;
case 'f':
flags |= DLADM_OPT_FORCE;
break;
default:
}
}
/*
* 'f' - force, flag can be specified only with 'v' - vlan.
*/
die("-f option can only be used with -v");
usage();
if (mac_addr_type == VNIC_MAC_ADDR_TYPE_VRID) {
mac_prefix_len != 0) {
usage();
}
usage();
}
/* check required options */
if (!l_arg)
usage();
usage();
/* the VNIC id is the required operand */
usage();
if (!dladm_valid_linkname(name))
!= DLADM_STATUS_OK)
die("invalid vnic property");
switch (status) {
case DLADM_STATUS_OK:
break;
case DLADM_STATUS_LINKBUSY:
die("VLAN over '%s' may not use default_tag ID "
"(see dladm(1M))", devname);
break;
default:
}
}
static void
{
/*
* Let the delete continue anyway.
*/
return;
}
if (is_etherstub != etherstub) {
}
}
static void
{
int option;
opterr = 0;
NULL)) != -1) {
switch (option) {
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
default:
}
}
/* get vnic name (required last argument) */
usage();
NULL);
if (status != DLADM_STATUS_OK)
if ((flags & DLADM_OPT_ACTIVE) != 0) {
}
if ((flags & DLADM_OPT_PERSIST) != 0) {
}
if (status != DLADM_STATUS_OK)
}
static void
{
}
/* ARGSUSED */
static void
{
char *type;
/*
*/
if (argc == 2) {
NULL);
if (status != DLADM_STATUS_OK)
goto done;
} else if (argc > 2) {
usage();
}
if (vlan)
else
done:
if (status != DLADM_STATUS_OK) {
if (argc == 2) {
} else {
}
}
}
static void
{
}
static void
dump_vnics_head(const char *dev)
{
(void) printf("\tipackets rbytes opackets obytes ");
(void) printf("%%ipkts %%opkts\n");
else
(void) printf("\n");
}
static void
{
if (tot_stats) {
(void) printf("\t-");
} else {
}
(void) printf("\t-");
} else {
}
}
(void) printf("\n");
*old_stats = *vnic_stats;
}
/*
* Called from the walker dladm_vnic_walk_sys() for each vnic to display
* vnic information or statistics.
*/
static dladm_status_t
{
char devname[MAXLINKNAMELEN];
char vnic_name[MAXLINKNAMELEN];
return (status);
/*
* Want all etherstub but it's not one, or want
* non-etherstub and it's one.
*/
return (DLADM_STATUS_OK);
}
return (DLADM_STATUS_OK);
}
return (DLADM_STATUS_BADARG);
if (!is_etherstub &&
/* print vnic statistics */
if (state->vs_firstonly) {
if (state->vs_donefirst)
return (0);
}
if (!state->vs_printstats) {
/*
* get vnic statistics and add to the sum for the
* named device.
*/
} else {
/* get and print vnic statistics */
&state->vs_totalstats);
}
return (DLADM_STATUS_OK);
} else {
"%s", vnic_name);
if (!is_etherstub) {
"%s", devname);
/ 1000000ull));
switch (vnic->va_mac_addr_type) {
case VNIC_MAC_ADDR_TYPE_FIXED:
sizeof (vbuf.vnic_macaddrtype),
gettext("fixed"));
break;
sizeof (vbuf.vnic_macaddrtype),
gettext("random"));
break;
sizeof (vbuf.vnic_macaddrtype),
gettext("factory, slot %d"),
vnic->va_mac_slot);
break;
case VNIC_MAC_ADDR_TYPE_VRID:
sizeof (vbuf.vnic_macaddrtype),
gettext("vrrp, %d/%s"),
"inet" : "inet6");
break;
}
mstr));
}
}
return (DLADM_STATUS_OK);
}
}
/* ARGSUSED */
static int
{
return (DLADM_WALK_CONTINUE);
}
static void
{
int option;
char *fields_str = NULL;
const ofmt_field_t *pf;
char *all_e_fields = "link";
opterr = 0;
NULL)) != -1) {
switch (option) {
case 'p':
break;
case 'P':
break;
case 'l':
if (etherstub)
die("option not supported for this command");
die("link name too long");
break;
case 's':
if (s_arg) {
die("the option -s cannot be specified "
"more than once");
}
break;
case 'i':
if (i_arg) {
die("the option -i cannot be specified "
"more than once");
}
break;
case 'o':
fields_str = optarg;
break;
default:
}
}
die("the option -i can be used only with -s");
/* get vnic ID (optional last argument) */
if (status != DLADM_STATUS_OK) {
}
usage();
}
if (l_arg) {
if (status != DLADM_STATUS_OK) {
}
}
if (etherstub)
}
pf = vnic_fields;
if (state.vs_parsable)
if (s_arg) {
/* Display vnic statistics */
return;
}
/* Display vnic information */
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
static void
{
}
static void
{
int option;
char name[MAXLINKNAMELEN];
name[0] = '\0';
opterr = 0;
switch (option) {
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
default:
}
}
/* the etherstub id is the required operand */
usage();
if (!dladm_valid_linkname(name))
if (status != DLADM_STATUS_OK)
}
static void
{
}
/* ARGSUSED */
static void
{
}
/* ARGSUSED */
static void
{
}
static void
{
int option;
char name[MAXLINKNAMELEN];
name[0] = '\0';
opterr = 0;
switch (option) {
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
case 'm':
break;
default:
}
}
/* the simnet id is the required operand */
usage();
if (!dladm_valid_linkname(name))
}
if (status != DLADM_STATUS_OK)
}
static void
{
int option;
opterr = 0;
NULL)) != -1) {
switch (option) {
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
default:
}
}
/* get simnet name (required last argument) */
usage();
NULL);
if (status != DLADM_STATUS_OK)
flags)) != DLADM_STATUS_OK)
if (status != DLADM_STATUS_OK)
}
static void
{
int option;
opterr = 0;
NULL)) != -1) {
switch (option) {
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
case 'p':
if (p_arg)
break;
default:
}
}
/* get simnet name (required last argument) */
usage();
/* Nothing to do if no peer link argument */
if (!p_arg)
return;
NULL);
if (status != DLADM_STATUS_OK)
if (status != DLADM_STATUS_OK)
}
static dladm_status_t
{
!= DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_NOTFOUND);
return (status);
sizeof (slbuf.simnet_otherlink))) !=
return (status);
return (DLADM_STATUS_BADVAL);
sizeof (slbuf.simnet_macaddr));
return (status);
}
/* ARGSUSED */
static int
{
return (DLADM_WALK_CONTINUE);
}
static void
{
int option;
char *all_fields = "link,media,macaddress,otherlink";
char *fields_str = all_fields;
opterr = 0;
switch (option) {
case 'p':
if (p_arg)
break;
case 'P':
if (flags != DLADM_OPT_ACTIVE)
break;
case 'o':
fields_str = optarg;
break;
default:
break;
}
}
die("-p requires -o");
if (p_arg)
die("\"-o all\" is invalid with -p");
}
/* get link name (optional last argument) */
}
usage();
}
if (state.ls_parsable)
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
static void
{
if (state->ls_parsable)
/*
* If an interval is specified, continuously show the stats
* only for the first MAC port.
*/
for (;;) {
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
if (interval == 0)
break;
}
}
static void
{
/*
* If an interval is specified, continuously show the stats
* only for the first group.
*/
for (;;) {
if (linkid == DATALINK_ALL_LINKID)
else
if (interval == 0)
break;
}
}
/* ARGSUSED */
static void
{
/* Display vnic statistics */
/*
* If an interval is specified, and a vnic ID is not specified,
* continuously show the stats only for the first vnic.
*/
for (;;) {
/* Get stats for each vnic */
if (!specific_link) {
} else {
}
}
/* Show totals */
(void) printf("Total");
(void) printf("\t%-10llu",
(void) printf("%-12llu",
(void) printf("%-10llu",
(void) printf("%-12llu\n",
}
/* Show stats for each vnic */
if (!specific_link) {
} else {
}
}
if (interval == 0)
break;
}
}
static void
{
char module[DLPI_LINKNAME_MAX];
return;
warn("kstat open operation failed");
return;
}
(void) kstat_close(kcp);
}
static void
{
warn("kstat_open operation failed");
return;
}
(void) kstat_close(kcp);
}
static int
{
warn("kstat open operation failed");
return (-1);
}
/*
* The kstat query could fail if the underlying MAC
* driver was already detached.
*/
goto bail;
}
warn("kstat read failed");
goto bail;
}
goto bail;
(void) kstat_close(kcp);
return (0);
bail:
(void) kstat_close(kcp);
return (-1);
}
static int
{
char module[DLPI_LINKNAME_MAX];
if (islink) {
} else {
return (-1);
}
}
static uint64_t
{
return (ifspeed);
}
static const char *
{
return (buf);
}
}
static const char *
{
&linkduplex, islink) != 0) {
return (buf);
}
}
static int
{
if (cmdtype == WIFI_CMD_SCAN) {
} else if (cmdtype == WIFI_CMD_SHOW) {
sizeof (wifi_common_fields));
} else {
return (-1);
}
}
0, ofmt);
return (0);
}
typedef struct print_wifi_state {
char *ws_link;
typedef struct wlan_scan_args_s {
void *ws_attr;
static boolean_t
{
char tmpbuf[DLADM_STRSIZE];
return (B_TRUE);
}
return (B_TRUE);
case DLADM_WLAN_ATTR_ESSID:
break;
case DLADM_WLAN_ATTR_BSSID:
break;
case DLADM_WLAN_ATTR_SECMODE:
break;
case DLADM_WLAN_ATTR_STRENGTH:
break;
case DLADM_WLAN_ATTR_MODE:
break;
case DLADM_WLAN_ATTR_SPEED:
break;
case DLADM_WLAN_ATTR_AUTH:
break;
case DLADM_WLAN_ATTR_BSSTYPE:
break;
}
return (B_TRUE);
}
static boolean_t
{
return (B_TRUE);
}
static int
{
char link[MAXLINKNAMELEN];
sizeof (link))) != DLADM_STATUS_OK) {
return (DLADM_WALK_CONTINUE);
}
if (status != DLADM_STATUS_OK)
return (DLADM_WALK_CONTINUE);
}
static boolean_t
{
static char tmpbuf[DLADM_STRSIZE];
}
return (B_TRUE);
}
static boolean_t
{
}
static int
{
char link[MAXLINKNAMELEN];
sizeof (link))) != DLADM_STATUS_OK) {
return (DLADM_WALK_CONTINUE);
}
/* dladm_wlan_get_linkattr() memsets attr with 0 */
if (status != DLADM_STATUS_OK)
return (DLADM_WALK_CONTINUE);
}
static void
{
int option;
char *fields_str = NULL;
if (cmd == WIFI_CMD_SCAN)
else if (cmd == WIFI_CMD_SHOW)
else
return;
opterr = 0;
switch (option) {
case 'o':
fields_str = optarg;
break;
case 'p':
break;
default:
}
}
die("-p requires -o");
die("\"-o all\" is invalid with -p");
}
usage();
}
state.ws_parsable) < 0)
die("invalid field(s) specified");
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
static void
{
}
static void
{
}
typedef struct wlan_count_attr {
/* ARGSUSED */
static int
{
return (DLADM_WALK_CONTINUE);
}
static int
{
uint_t i;
int nfields = 1;
if (c == ',')
nfields++;
}
return (-1);
goto fail;
for (i = 0; i < nfields; i++) {
char *s;
goto fail;
*s = '\0';
}
if (status != DLADM_STATUS_OK) {
if (status == DLADM_STATUS_NOTFOUND) {
}
if (status != DLADM_STATUS_OK)
goto fail;
}
}
*key_countp = i;
return (0);
fail:
return (-1);
}
static void
{
int option;
char buf[DLADM_STRSIZE];
opterr = 0;
switch (option) {
case 'e':
if (status != DLADM_STATUS_OK)
/*
* Try to connect without doing a scan.
*/
break;
case 'i':
if (status != DLADM_STATUS_OK)
break;
case 'a':
if (status != DLADM_STATUS_OK)
break;
case 'm':
if (status != DLADM_STATUS_OK)
break;
case 'b':
}
break;
case 's':
}
break;
case 'k':
else
break;
case 'T':
timeout = -1;
break;
}
break;
case 'c':
break;
default:
break;
}
}
if (keysecmode == DLADM_WLAN_SECMODE_NONE) {
die("key required for security mode '%s'",
}
} else {
die("incompatible -s and -k options");
}
}
usage();
}
if (linkid == DATALINK_ALL_LINKID) {
die("no wifi links are available");
die("link name is required when more than one wifi "
"link is available");
}
}
if ((flags & DLADM_WLAN_CONNECT_NOSCAN) != 0) {
/*
* Try again with scanning and filtering.
*/
goto again;
}
if (status == DLADM_STATUS_NOTFOUND) {
die("no wifi networks are available");
} else {
die("no wifi networks with the specified "
"criteria are available");
}
}
}
}
/* ARGSUSED */
static int
{
if (status != DLADM_STATUS_OK)
return (DLADM_WALK_CONTINUE);
}
static void
{
int option;
opterr = 0;
switch (option) {
case 'a':
break;
default:
break;
}
}
}
usage();
}
if (linkid == DATALINK_ALL_LINKID) {
if (!all_links) {
&wcattr,
die("no wifi links are available");
die("link name is required when more than "
"one wifi link is available");
}
} else {
return;
}
}
if (status != DLADM_STATUS_OK)
}
static void
char **pptr)
{
int i;
char buf[DLADM_STRSIZE];
&valcnt);
if (status != DLADM_STATUS_OK) {
if (status == DLADM_STATUS_TEMPONLY) {
if (type == DLADM_PROP_VAL_MODIFIABLE &&
statep->ls_persist) {
valcnt = 1;
} else {
return;
}
} else if (status == DLADM_STATUS_NOTSUP ||
statep->ls_persist) {
valcnt = 1;
if (type == DLADM_PROP_VAL_CURRENT ||
else
} else if (status == DLADM_STATUS_NOTDEFINED) {
} else {
if (statep->ls_proplist &&
"cannot get link property '%s' for %s",
}
return;
}
}
buf[0] = '\0';
for (i = 0; i < valcnt; i++) {
else
break;
}
if (valcnt > 0)
if (statep->ls_parsable) {
"%s", buf);
} else {
}
}
static boolean_t
{
case LINKPROP_LINK:
break;
case LINKPROP_PROPERTY:
break;
case LINKPROP_VALUE:
/*
* If we failed to query the link property, for example, query
* the persistent value of a non-persistable link property,
* simply skip the output.
*/
/*
* Ignore the temponly error when we skip printing
* link properties to avoid returning failure on exit.
*/
goto skip;
}
break;
case LINKPROP_PERM:
goto skip;
break;
case LINKPROP_DEFAULT:
goto skip;
break;
case LINKPROP_POSSIBLE:
goto skip;
break;
default:
die("invalid input");
break;
}
return (B_TRUE);
skip:
}
static boolean_t
{
/* if used with -p flag, always print output */
return (B_TRUE);
if (status == DLADM_STATUS_OK)
return (B_TRUE);
/*
* A system wide default value is not available for the
* property. Check if current value can be retrieved.
*/
return (status == DLADM_STATUS_OK);
}
/* ARGSUSED */
static int
void *arg)
{
/*
* This will need to be fixed when kernel interfaces are added
* to enable walking of all known private properties. For now,
* we are limited to walking persistent private properties only.
*/
return (DLADM_WALK_CONTINUE);
if (!statep->ls_parsable &&
return (DLADM_WALK_CONTINUE);
return (DLADM_WALK_CONTINUE);
}
static void
{
int option;
char propstr[DLADM_STRSIZE];
char *fields_str = NULL;
opterr = 0;
switch (option) {
case 'p':
break;
case 'c':
break;
case 'P':
break;
case 'o':
fields_str = optarg;
break;
default:
break;
}
}
}
usage();
}
!= DLADM_STATUS_OK)
die("invalid link properties specified");
if (state.ls_parsable)
else
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
static int
{
int i;
char *buf;
return (DLADM_WALK_CONTINUE);
}
return (DLADM_WALK_CONTINUE);
}
/*
* When some WiFi links are opened for the first time, their hardware
* automatically scans for APs and does other slow operations. Thus,
* if there are no open links, the retrieval of link properties
* (below) will proceed slowly unless we hold the link open.
*
* Note that failure of dlpi_open() does not necessarily mean invalid
* link properties, because dlpi_open() may fail because of incorrect
* autopush configuration. Therefore, we ingore the return value of
* dlpi_open().
*/
if (!statep->ls_persist)
die("insufficient memory");
for (i = 0; i < DLADM_MAX_PROP_VALCNT; i++) {
sizeof (char *) * DLADM_MAX_PROP_VALCNT +
i * DLADM_PROP_VAL_MAX;
}
(sizeof (char *) + DLADM_PROP_VAL_MAX) * DLADM_MAX_PROP_VALCNT;
}
} else {
}
dlpi_close(dh);
return (DLADM_WALK_CONTINUE);
}
static int
{
if (status != DLADM_STATUS_OK &&
status != DLADM_STATUS_NOTSUP) {
}
return (DLADM_WALK_CONTINUE);
}
static void
{
int i, option;
char errmsg[DLADM_STRSIZE];
char propstr[DLADM_STRSIZE];
opterr = 0;
switch (option) {
case 'p':
break;
case 't':
break;
case 'R':
break;
default:
}
}
/* get link name (required last argument) */
usage();
die("invalid link properties specified");
die("link property must be specified");
}
NULL);
if (status != DLADM_STATUS_OK)
goto done;
}
char **val;
if (reset) {
count = 0;
} else {
if (count == 0) {
warn("no value specified for '%s'",
continue;
}
}
switch (status) {
case DLADM_STATUS_OK:
break;
case DLADM_STATUS_NOTFOUND:
break;
case DLADM_STATUS_BADVAL: {
int j;
die("insufficient memory");
for (j = 0; j < DLADM_MAX_PROP_VALCNT; j++) {
j * DLADM_PROP_VAL_MAX;
}
&valcnt);
if (s != DLADM_STATUS_OK) {
break;
}
*ptr = '\0';
for (j = 0; j < valcnt; j++) {
propvals[j]);
break;
}
warn("link property '%s' must be one of: %s",
} else
break;
}
default:
if (reset) {
} else {
}
break;
}
}
done:
if (status != DLADM_STATUS_OK) {
}
}
static void
{
}
static void
{
}
static int
{
int error = 0;
if (class == DLADM_SECOBJ_CLASS_WPA) {
return (EINVAL);
return (error);
}
if (class == DLADM_SECOBJ_CLASS_WEP) {
switch (len) {
case 5: /* ASCII key sizes */
case 13:
break;
case 10: /* Hex key sizes, not preceded by 0x */
case 26:
break;
case 12: /* Hex key sizes, preceded by 0x */
case 28:
return (EINVAL);
break;
default:
return (EINVAL);
}
return (error);
}
return (ENOENT);
}
static void
{
}
static int
{
int c;
void (*sigfunc)(int);
/*
* Turn off echo -- but before we do so, defer SIGINT handling
* so that a ^C doesn't leave the terminal corrupted.
*/
if (try == 1)
else
while (signalled == 0) {
c = getchar();
if (c == '\n' || c == '\r') {
if (len != 0)
break;
(void) putchar('\n');
goto again;
}
break;
(void) putchar('*');
}
(void) putchar('\n');
/*
* Restore terminal setting and handle deferred signals.
*/
if (signalled != 0)
return (len);
}
static int
{
int rval;
if (rval == 0) {
}
return (rval);
} else {
for (;;) {
break;
continue;
len--;
}
break;
}
}
}
static boolean_t
check_auth(const char *auth)
{
return (B_FALSE);
}
static void
{
char *errstr;
if (create) {
errstr = "ADT_dladm_create_secobj";
} else {
errstr = "ADT_dladm_delete_secobj";
}
/* fill in audit info */
if (create) {
} else {
}
if (success) {
}
} else {
ADT_FAIL_VALUE_AUTH) != 0) {
}
}
(void) adt_end_session(ah);
}
static void
{
char *class_name = NULL;
opterr = 0;
switch (option) {
case 'f':
}
break;
case 'c':
class_name = optarg;
if (status != DLADM_STATUS_OK) {
die("invalid secure object class '%s', "
"valid values are: wep, wpa", optarg);
}
break;
case 't':
break;
case 'R':
if (status != DLADM_STATUS_OK) {
"specified");
}
break;
default:
break;
}
}
usage();
if (class == -1)
die("secure object class required");
die("secure object name required");
if (!dladm_valid_secobj_name(obj_name))
if (!success)
if (rval != 0) {
switch (rval) {
case ENOENT:
die("invalid secure object class");
break;
case EINVAL:
die("invalid secure object value");
break;
case ENOTSUP:
die("verification failed");
break;
default:
break;
}
}
if (status != DLADM_STATUS_OK) {
obj_name);
}
if (temp)
return;
if (status != DLADM_STATUS_OK) {
"object '%s'", obj_name);
}
}
static void
{
int i, option;
int nfields = 1;
opterr = 0;
switch (option) {
case 't':
break;
case 'R':
if (status != DLADM_STATUS_OK) {
"specified");
}
break;
default:
break;
}
}
die("secure object name required");
if (c == ',')
nfields++;
}
die("no memory");
if (!success)
for (i = 0; i < nfields; i++) {
if (!temp) {
} else {
}
if (status != DLADM_STATUS_OK) {
"'%s'", field);
}
if (pstatus != DLADM_STATUS_OK) {
"secure object '%s'", field);
}
}
}
}
typedef struct show_secobj_state {
static boolean_t
{
char buf[DLADM_STRSIZE];
if (statep->ss_persist)
flags);
if (status != DLADM_STATUS_OK)
obj_name);
if (getuid() == 0) {
}
return (B_TRUE);
}
static void
{
int option;
uint_t i;
char *fields_str = NULL;
char *def_fields = "object,class";
char *all_fields = "object,class,value";
opterr = 0;
switch (option) {
case 'p':
break;
case 'P':
break;
case 'o':
else
fields_str = optarg;
break;
default:
break;
}
}
die("option -c requires -o");
die("\"-o all\" is invalid with -p");
if (state.ss_parsable)
die("secure object name required");
if (c == ',')
obj_fields++;
}
die("no memory");
for (i = 0; i < obj_fields; i++) {
break;
}
return;
usage();
if (status != DLADM_STATUS_OK)
}
/*ARGSUSED*/
static int
{
return (DLADM_WALK_CONTINUE);
}
/*ARGSUSED*/
void
{
int option;
opterr = 0;
switch (option) {
case 'w':
break;
default:
/*
* Because init-linkprop is not a public command,
* print the usage instead.
*/
usage();
break;
}
}
usage();
}
if (linkid == DATALINK_ALL_LINKID) {
/*
* linkprops of links of other classes have been initialized as
* part of the dladm up-xxx operation.
*/
} else {
}
}
static void
{
int option;
char *fields_str = NULL;
switch (option) {
case 'x':
break;
case 'p':
break;
case 'o':
fields_str = optarg;
break;
default:
break;
}
}
if (state.es_parsable)
} else {
die("invalid link specified");
}
}
static int
{
return (DLADM_WALK_CONTINUE);
}
if (status != DLADM_STATUS_OK)
goto cleanup;
sizeof (ebuf.eth_rem_fault));
if (statep->es_extended)
return (DLADM_WALK_CONTINUE);
}
/* ARGSUSED */
static void
{
if (status != DLADM_STATUS_OK)
}
enum bridge_func {
};
static void
enum bridge_func func)
{
int option;
const char *bridge;
/* Set up the default configuration values */
cfg.field_mask = 0;
switch (option) {
case 'P':
if (status != DLADM_STATUS_OK)
break;
case 'R':
break;
case 'd':
die("forwarding delay set more than once");
die("incorrect forwarding delay");
break;
case 'f':
die("force protocol set more than once");
cfg.force_version < 0)
die("incorrect force protocol");
break;
case 'h':
die("hello time set more than once");
die("incorrect hello time");
break;
case 'l':
die("too many links specified");
break;
case 'm':
die("max age set more than once");
die("incorrect max age");
break;
case 'p':
die("priority set more than once");
die("incorrect priority");
break;
default:
break;
}
}
/* get the bridge name (required last argument) */
usage();
if (!dladm_valid_bridgename(bridge))
/*
* Get the current properties, if any, and merge in with changes. This
* is necessary (even with the field_mask feature) so that the
* value-checking macros will produce the right results with proposed
* changes to existing configuration. We only need it for those
* parameters, though.
*/
if (brprot == DLADM_BRIDGE_PROT_UNKNOWN)
brprot = brprot_old;
if (!CHECK_BRIDGE_CONFIG(cfg)) {
warn("illegal forward delay / max age / hello time "
"combination");
die("no max age possible: need forward delay >= %d or "
} else if (SMALL_MAXAGE(cfg)) {
if (CAPPED_MAXAGE(cfg))
die("max age too small: need age >= %d and "
"<= %d or hello time <= %d",
MAX_HELLOTIME(cfg));
else
die("max age too small: need age >= %d or "
"hello time <= %d",
} else if (FLOORED_MAXAGE(cfg)) {
die("max age too large: need age >= %d and <= %d or "
"forward delay >= %d",
MIN_FWDELAY(cfg));
} else {
die("max age too large: need age <= %d or forward "
"delay >= %d",
}
}
for (n = 0; n < nlink; n++) {
char pointless[DLADM_STRSIZE];
&media) != DLADM_STATUS_OK)
die("%s %s cannot be bridged",
die("%s interface %s cannot be bridged",
}
flags);
if (status != DLADM_STATUS_OK)
}
for (n = 0; n < nlink; n++) {
if (status != DLADM_STATUS_OK)
break;
}
if (n >= nlink) {
/*
* We were successful. If we're creating a new bridge, then
* there's just one more step: enabling. If we're modifying or
* just adding links, then we're done.
*/
return;
}
/* clean up the partial configuration */
for (i = 0; i < n; i++)
/* if failure for brCreate, then delete the bridge */
if (n < nlink)
else
}
static void
{
}
static void
{
}
static void
{
}
static void
{
char option;
opterr = 0;
-1) {
switch (option) {
case 'R':
break;
default:
break;
}
}
/* get the bridge name (required last argument) */
usage();
if (status != DLADM_STATUS_OK)
}
static void
{
char option;
NULL)) != -1) {
switch (option) {
case 'R':
break;
case 'l':
die("too many links specified");
break;
default:
break;
}
}
if (nlink == 0)
usage();
/* get the bridge name (required last argument) */
usage();
for (n = 0; n < nlink; n++) {
char bridge[MAXLINKNAMELEN];
NULL) != DLADM_STATUS_OK)
sizeof (bridge));
if (status != DLADM_STATUS_OK &&
status != DLADM_STATUS_NOTFOUND) {
links[n]);
}
if (status == DLADM_STATUS_NOTFOUND ||
}
for (n = 0; n < nlink; n++) {
if (status == DLADM_STATUS_OK) {
} else {
"cannot remove link %s from bridge %s",
}
}
if (!removed_one)
}
static void
{
}
static void
{
}
static dladm_status_t
{
char link[MAXLINKNAMELEN];
return (status);
return (DLADM_STATUS_NOTFOUND);
/* Convert observability node name back to bridge name */
if (!dladm_observe_to_bridge(link))
return (DLADM_STATUS_NOTFOUND);
/*
* If the running value differs from the one in SMF, and parsable
* output is not requested, then we show the running value with an
* asterisk.
*/
&smfprot);
&runprot);
}
return (DLADM_STATUS_OK);
}
static dladm_status_t
{
char link[MAXLINKNAMELEN];
#ifndef lint
/* This is a compile-time assertion; optimizer normally fixes this */
extern void brsum_t_is_too_large(void);
#endif
if (state->ls_firstonly) {
if (state->ls_donefirst)
return (DLADM_WALK_CONTINUE);
} else {
}
return (status);
return (DLADM_STATUS_NOTFOUND);
warn("kstat open operation failed");
return (DLADM_STATUS_OK);
}
}
}
}
}
}
}
}
(void) kstat_close(kcp);
/* Convert observability node name back to bridge name */
if (!dladm_observe_to_bridge(link))
return (DLADM_STATUS_NOTFOUND);
return (DLADM_STATUS_OK);
}
/*
* This structure carries around extra state information for the show-bridge
* command and allows us to use common support functions.
*/
typedef struct {
const char *bridge;
/* ARGSUSED */
static int
{
void *buf;
if (brstate->show_stats) {
} else {
&bbuf);
}
return (DLADM_WALK_CONTINUE);
}
static void
{
}
static dladm_status_t
{
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_NOTFOUND);
sizeof (bbuf->bridgel_state));
} else {
}
sizeof (bbuf->bridgel_desbridge),
}
return (DLADM_STATUS_OK);
}
static dladm_status_t
{
char bridge[MAXLINKNAMELEN];
#ifndef lint
/* This is a compile-time assertion; optimizer normally fixes this */
extern void brlsum_t_is_too_large(void);
#endif
if (state->ls_firstonly) {
if (state->ls_donefirst)
return (DLADM_WALK_CONTINUE);
} else {
}
if (status != DLADM_STATUS_OK)
return (status);
return (DLADM_STATUS_NOTFOUND);
}
sizeof (bridge))) != DLADM_STATUS_OK)
goto bls_out;
warn("kstat open operation failed");
goto bls_out;
}
}
}
}
}
(void) kstat_close(kcp);
return (status);
}
static void
{
void *buf;
if (brstate->show_stats) {
} else {
}
}
/* ARGSUSED */
static int
{
char bridge[MAXLINKNAMELEN];
}
return (DLADM_WALK_CONTINUE);
}
static void
{
if (blf->blf_is_local) {
sizeof (bbuf.bridgef_flags));
} else {
if (blf->blf_trill_nick != 0) {
}
}
blf->blf_trill_nick == 0) {
sizeof (bbuf.bridgef_output));
}
}
static void
{
sizeof (bbuf.bridget_flags));
} else {
sizeof (bbuf.bridget_link));
}
}
static void
{
int option;
enum {
} op_mode = bridgeMode;
int interval = 0;
char *fields_str = NULL;
/* default: bridge-related data */
char *all_fields = "bridge,protect,address,priority,bmaxage,"
"bhellotime,bfwddelay,forceproto,tctime,tccount,tchange,"
"desroot,rootcost,rootport,maxage,hellotime,fwddelay,holdtime";
char *default_fields = "bridge,protect,address,priority,"
"desroot";
char *all_statfields = "bridge,drops,forwards,mbcast,"
"unknown,recv,sent";
char *default_statfields = "bridge,drops,forwards,mbcast,"
"unknown";
/* -l: link-related data */
char *all_link_fields = "link,index,state,uptime,opercost,"
"operp2p,operedge,desroot,descost,desbridge,desport,tcack";
char *default_link_fields = "link,state,uptime,desroot";
char *all_link_statfields = "link,cfgbpdu,tcnbpdu,rstpbpdu,"
"txbpdu,drops,recv,xmit";
char *default_link_statfields = "link,drops,recv,xmit";
/* -f: bridge forwarding table related data */
char *default_fwd_fields = "dest,age,flags,output";
/* -t: TRILL nickname table related data */
char *default_trill_fields = "nick,flags,link,nexthop";
char *default_str;
char *all_str;
opterr = 0;
switch (option) {
case 'f':
die("-f is incompatible with -l or -t");
break;
case 'i':
if (interval != 0)
break;
case 'l':
die("-l is incompatible with -f or -t");
break;
case 'o':
fields_str = optarg;
break;
case 'p':
if (parsable)
break;
case 's':
if (brstate.show_stats)
break;
case 't':
die("-t is incompatible with -f or -l");
break;
default:
break;
}
}
die("the -i option can be used only with -s");
die("the -f/-t and -s options cannot be used together");
/* get the bridge name (optional last argument) */
char lname[MAXLINKNAMELEN];
}
if (class != DATALINK_CLASS_BRIDGE)
}
usage();
} else if (op_mode != bridgeMode) {
die("bridge name required for -l, -f, or -t");
return;
}
switch (op_mode) {
case bridgeMode:
if (brstate.show_stats) {
} else {
}
break;
case linkMode:
if (brstate.show_stats) {
} else {
}
break;
case fwdMode:
break;
case trillMode:
break;
}
if (fields_str == NULL)
if (parsable)
for (;;) {
switch (op_mode) {
case bridgeMode:
if (linkid == DATALINK_ALL_LINKID) {
(void) dladm_walk_datalink_id(show_bridge,
} else {
"failed to show bridge %s",
}
}
break;
case linkMode: {
&nlinks);
for (i = 0; i < nlinks; i++)
/* bridge not running; iterate on libdladm */
(void) dladm_walk_datalink_id(
} else {
die("unable to get port list for bridge %s: %s",
}
break;
}
case fwdMode: {
&nfwd);
die("unable to get forwarding entries for "
} else {
for (i = 0; i < nfwd; i++)
}
break;
}
case trillMode: {
&nnick);
die("bridge %s is not running TRILL",
else
die("unable to get TRILL nickname "
"entries for bridge %s",
} else {
for (i = 0; i < nnick; i++)
show_bridge_trillnick(tln + i,
}
break;
}
}
if (interval == 0)
break;
}
}
/*
* "-R" option support. It is used for live upgrading. Append dladm commands
* to a upgrade script which will be run when the alternative root boots up:
*
* - If the /etc/dladm/datalink.conf file exists on the alternative root,
* append dladm commands to the <altroot>/var/svc/profile/upgrade_datalink
* plumbs various interfaces.
*
* - If the /etc/dladm/datalink.conf file does not exist on the alternative
* which will be run in the manifest-import service.
*
* Note that the SMF team is considering to move the manifest-import service
* to be run at the very begining of boot. Once that is done, the need for
* the /var/svc/profile/upgrade_datalink script will not exist any more.
*/
static void
{
char path[MAXPATHLEN];
int i;
/*
* Check for the existence of the /etc/dladm/datalink.conf
* configuration file, and determine the name of script file.
*/
altroot);
} else {
}
for (i = 0; i < argc; i++) {
/*
* Directly write to the file if it is not the "-R <altroot>"
* option. In which case, skip it.
*/
else
i ++;
}
}
/*
* Convert the string to an integer. Note that the string must not have any
* trailing non-integer characters.
*/
static boolean_t
{
int val;
errno = 0;
return (B_FALSE);
return (B_TRUE);
}
/* PRINTFLIKE1 */
static void
{
}
/* PRINTFLIKE2 */
static void
{
char errmsg[DLADM_STRSIZE];
}
/*
* Also closes the dladm handle if it is not NULL.
*/
/* PRINTFLIKE2 */
static void
{
char errmsg[DLADM_STRSIZE];
/* close dladm handle if it was opened */
}
/* PRINTFLIKE1 */
static void
{
/* close dladm handle if it was opened */
}
static void
die_optdup(int opt)
{
}
static void
{
switch (opterr) {
case ':':
break;
case '?':
default:
break;
}
}
static void
{
int i;
sizeof (ebuf.eth_rem_fault));
}
}
static boolean_t
{
return (B_TRUE);
}
return (B_FALSE);
}
/*
* default output callback function that, when invoked,
* prints string which is offset by ofmt_arg->ofmt_id within buf.
*/
static boolean_t
{
char *value;
return (B_TRUE);
}
static void
{
char buf[OFMT_BUFSIZE];
if (oferr == OFMT_SUCCESS)
return;
/*
* All errors are considered fatal in parsable mode.
* NOMEM errors are always fatal, regardless of mode.
* For other errors, we print diagnostics in human-readable
* mode and processs what we can.
*/
} else {
}
}
/*
* Called from the walker dladm_walk_datalink_id() for each IB partition to
* display IB partition specific information.
*/
static dladm_status_t
{
char part_over[MAXLINKNAMELEN];
char part_name[MAXLINKNAMELEN];
/*
* Get the information about the IB partition from the partition
* datlink ID 'linkid'.
*/
!= DLADM_STATUS_OK)
return (status);
/*
* If an IB Phys link name was provided on the command line we have
* the Phys link's datalink ID in the ps_over_id field of the state
* structure. Proceed only if the IB partition represented by 'linkid'
* was created over Phys link denoted by ps_over_id. The
* 'dia_physlinkid' field of dladm_part_attr_t represents the IB Phys
* link over which the partition was created.
*/
return (DLADM_STATUS_OK);
/*
* The linkid argument passed to this function is the datalink ID
* of the IB Partition. Get the partitions name from this linkid.
*/
return (DLADM_STATUS_BADARG);
/*
* The 'dia_physlinkid' field contains the datalink ID of the IB Phys
* link over which the partition was created. Use this linkid to get the
* linkover field.
*/
/*
* Read the FFORCE field from this datalink's persistent configuration
* database line to determine if this datalink was created forcibly.
* If this datalink is a temporary datalink, then it will not have an
* entry in the persistent configuration, so check if force create flag
* is set in the partition attributes.
*
* We need this two level check since persistent partitions brought up
* by up-part during boot will have force create flag always set, since
* we want up-part to always succeed even if the port is currently down
* or P_Key is not yet available in the subnet.
*/
&force_in_conf, sizeof (boolean_t));
} else if (status == DLADM_STATUS_NOTFOUND) {
/*
* for a temp link the force create flag will determine
* whether it was created with force flag.
*/
!= 0);
}
"%s", part_name);
"%s", part_over);
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static int
{
return (DLADM_WALK_CONTINUE);
}
/*
* Show the information about the IB partition objects.
*/
static void
{
int option;
char over_link[MAXLINKNAMELEN];
char *fields_str = NULL;
opterr = 0;
NULL)) != -1) {
switch (option) {
case 'p':
break;
case 'P':
break;
case 'l':
/*
* The data link ID of the IB Phys link. When this
* argument is provided we list only the partition
* objects created over this IB Phys link.
*/
die("link name too long");
break;
case 'o':
fields_str = optarg;
break;
default:
}
}
/*
* Get the partition ID (optional last argument).
*/
if (status != DLADM_STATUS_OK) {
}
usage();
}
die("-p requires -o");
/*
* If an IB Phys link name was provided as an argument, then get its
* datalink ID.
*/
if (l_arg) {
if (status != DLADM_STATUS_OK) {
}
}
if (state.ps_parsable)
/*
* If a specific IB partition name was not provided as an argument,
* walk all the datalinks and display the information for all
* IB partitions. If IB Phys link was provided limit it to only
* IB partitions created over that IB Phys link.
*/
if (linkid == DATALINK_ALL_LINKID) {
} else {
}
}
}
/*
* Called from the walker dladm_walk_datalink_id() for each IB Phys link to
* display IB specific information for these Phys links.
*/
static dladm_status_t
{
char linkname[MAXLINKNAMELEN];
char pkeystr[MAXPKEYLEN];
int i;
/*
* Get the attributes of the IB Phys link from active/Persistent config
* based on the flag passed.
*/
return (status);
!= attr.dia_physlinkid)) {
return (DLADM_STATUS_OK);
}
/*
* Get the data link name for the phys_linkid. If we are doing show-ib
* for all IB Phys links, we have only the datalink IDs not the
* datalink name.
*/
return (status);
"%s", linkname);
/*
* Create a comma separated list of pkeys from the pkey table returned
* by the IP over IB driver instance.
*/
for (i = 0; i < attr.dia_port_pkey_tbl_sz; i++) {
if (i == 0)
attr.dia_port_pkeys[i]);
else
attr.dia_port_pkeys[i]);
}
}
return (DLADM_STATUS_OK);
}
/* ARGSUSED */
static int
{
return (DLADM_WALK_CONTINUE);
}
/*
* show-phys command since this will display IB specific information about the
* Phys link like, HCA GUID, PORT GUID, PKEYS active for this port etc.
*/
static void
{
int option;
char *fields_str = NULL;
opterr = 0;
NULL)) != -1) {
switch (option) {
case 'p':
break;
case 'o':
fields_str = optarg;
break;
default:
}
}
/* get IB Phys link ID (optional last argument) */
if (status != DLADM_STATUS_OK) {
}
usage();
}
die("-p requires -o");
/*
* linkid is the data link ID of the IB Phys link. By default it will
* be DATALINK_ALL_LINKID.
*/
if (state.is_parsable)
/*
* If we are going to display the information for all IB Phys links
* then we'll walk through all the datalinks for datalinks of Phys
* class and media type IB.
*/
if (linkid == DATALINK_ALL_LINKID) {
} else {
/*
* We need to display the information only for the IB phys link
* linkid. Call show_ib for this link.
*/
}
}
}
/*
* Create an IP over Infiniband partition object over an IB Phys link. The IB
* Phys link is associated with an Infiniband HCA port. The IB partition object
* is created over a port, pkey combination. This partition object represents
* an instance of IP over IB interface.
*/
/* ARGSUSED */
static void
{
char *pname;
datalink_id_t physlinkid = 0;
datalink_id_t partlinkid = 0;
unsigned long opt_pkey;
char propstr[DLADM_STRSIZE];
propstr[0] = '\0';
switch (option) {
case 't':
/*
* Create a temporary IB partition object. This
* instance is not entered into the persistent database
* so it will not be recreated automatically on a
* reboot.
*/
flags &= ~DLADM_OPT_PERSIST;
break;
case 'l':
/*
* The IB phys link over which the partition object will
* be created.
*/
break;
case 'R':
break;
case 'p':
break;
case 'P':
/*
* The P_Key for the port, pkey tuple of the partition
* object. This P_Key should exist in the IB subnet.
* The partition creation for a non-existent P_Key will
* fail unless the -f option is used.
*
* The P_Key is expected to be a hexadecimal number.
*/
*endp != '\0')
die("Invalid pkey");
break;
case 'f':
flags |= DLADM_OPT_FORCE;
break;
default:
break;
}
}
/* check required options */
if (!l_arg)
usage();
/* the partition name is a required operand */
usage();
/*
* Verify that the partition object's name is in the valid link name
* format.
*/
if (!dladm_valid_linkname(pname))
/* pkey is a mandatory argument */
if (pkey == 0)
usage();
/*
* Get the data link id of the IB Phys link over which we will be
* creating partition object.
*/
/*
* parse the property list provided with -p option.
*/
!= DLADM_STATUS_OK)
die("invalid IB partition property");
/*
* Call the library routine to create the partition object.
*/
&partlinkid, proplist);
if (status != DLADM_STATUS_OK)
}
/*
* Delete an IP over Infiniband partition object. The partition object should
* be unplumbed before attempting the delete.
*/
static void
{
int status;
opterr = 0;
NULL)) != -1) {
switch (option) {
case 't':
flags &= ~DLADM_OPT_PERSIST;
break;
case 'R':
break;
default:
}
}
/* get partition name (required last argument) */
usage();
/*
* Get the data link id of the partition object given the partition
* name.
*/
NULL);
if (status != DLADM_STATUS_OK)
/*
* Call the library routine to delete the IB partition. This will
* result in the IB partition object and all its resources getting
* deleted.
*/
if (status != DLADM_STATUS_OK)
}
/*
* Bring up all or one IB partition already present in the persistent database
* but not active yet.
*
* This sub-command is used during the system boot up to bring up all IB
* partitions present in the persistent database. This is similar to a
* create partition except that, the partitions are always created even if the
* HCA port is down or P_Key is not present in the IB subnet. This is similar
* to using the 'force' option while creating the partition except that the 'f'
* flag will be set in the flags field only if the create-part for this command
* was called with '-f' option.
*/
/* ARGSUSED */
static void
{
/*
* If a partition name was passed as an argument, get its data link
* id. By default we'll attempt to bring up all IB partition data
* links.
*/
if (argc == 2) {
if (status != DLADM_STATUS_OK)
return;
} else if (argc > 2) {
usage();
}
}