From e7801d59e8ceda0cde8ebdfdddd7582ee2ea96ef Mon Sep 17 00:00:00 2001 From: sowmini Date: Thu, 24 Jan 2008 14:49:21 -0800 Subject: PSARC 2007/429 Brussels - enhanced network driver configuration via dladm 6565373 driver ndd parameter behavior does not match the ieee802.3(5) man page. 6598690 need support for 'dladm show-ether' subcommand. 6619126 ndd abuse in network (Layer 2) drivers 6621285 bge_setup_params_kstat is dead code --- usr/src/cmd/dladm/dladm.c | 2692 +++++++++++++++++++++--------- usr/src/cmd/dladm/dladm.xcl | 48 + usr/src/lib/libdladm/Makefile.com | 3 +- usr/src/lib/libdladm/common/libdladm.c | 2 + usr/src/lib/libdladm/common/libdllink.c | 98 ++ usr/src/lib/libdladm/common/libdllink.h | 10 + usr/src/lib/libdladm/common/libdlwlan.c | 30 +- usr/src/lib/libdladm/common/linkprop.c | 793 ++++++++- usr/src/lib/libdladm/common/mapfile-vers | 4 +- usr/src/lib/libdlpi/common/libdlpi.c | 12 +- usr/src/uts/common/io/aggr/aggr_grp.c | 13 +- usr/src/uts/common/io/bge/bge_chip2.c | 29 +- usr/src/uts/common/io/bge/bge_impl.h | 22 +- usr/src/uts/common/io/bge/bge_kstats.c | 27 +- usr/src/uts/common/io/bge/bge_main2.c | 516 +++++- usr/src/uts/common/io/bge/bge_ndd.c | 73 +- usr/src/uts/common/io/bge/bge_recv2.c | 8 +- usr/src/uts/common/io/dld/dld_drv.c | 74 +- usr/src/uts/common/io/dld/dld_proto.c | 12 +- usr/src/uts/common/io/dld/dld_str.c | 41 +- usr/src/uts/common/io/gld.c | 42 +- usr/src/uts/common/io/ipw/ipw2100.c | 1 + usr/src/uts/common/io/ipw/ipw2100_impl.h | 7 +- usr/src/uts/common/io/mac/mac.c | 72 +- usr/src/uts/common/io/nge/nge_kstats.c | 25 - usr/src/uts/common/io/strplumb.c | 1 + usr/src/uts/common/io/vnic/vnic_dev.c | 5 +- usr/src/uts/common/sys/dld.h | 64 +- usr/src/uts/common/sys/mac.h | 31 +- usr/src/uts/common/sys/mac_impl.h | 2 + usr/src/uts/common/xen/io/xnbo.c | 9 +- usr/src/uts/intel/mac/Makefile | 8 +- usr/src/uts/sparc/mac/Makefile | 8 +- usr/src/uts/sun/io/hme.c | 4 +- 34 files changed, 3754 insertions(+), 1032 deletions(-) (limited to 'usr/src') diff --git a/usr/src/cmd/dladm/dladm.c b/usr/src/cmd/dladm/dladm.c index 22cc5c515e..0de78dfd63 100644 --- a/usr/src/cmd/dladm/dladm.c +++ b/usr/src/cmd/dladm/dladm.c @@ -56,8 +56,10 @@ #include #include #include +#include #define AGGR_DRV "aggr" +#define STR_UNDEF_VAL "--" #define MAXPORT 256 #define BUFLEN(lim, ptr) (((lim) > (ptr)) ? ((lim) - (ptr)) : 0) #define MAXLINELEN 1024 @@ -65,6 +67,132 @@ #define SMF_UPGRADEDATALINK_FILE "/var/svc/profile/upgrade_datalink" #define SMF_DLADM_UPGRADE_MSG " # added by dladm(1M)" +#define CMD_TYPE_ANY 0xffffffff +#define WIFI_CMD_SCAN 0x00000001 +#define WIFI_CMD_SHOW 0x00000002 +#define WIFI_CMD_ALL (WIFI_CMD_SCAN | WIFI_CMD_SHOW) + +/* + * data structures and routines for printing output. + * All non-parseable output is assumed to be in a columnar format. + * Parseable output will be printed as ="" + * + * Each sub-command is associated with a global array of pointers, + * print_field_t *fields[], where the print_field_t contains information + * about the format in which the output is to be printed. + * + * Sub-commands may be implemented in one of two ways: + * (i) the implementation could get all field values into a character + * buffer, with pf_offset containing the offset (for pf_name) within + * the buffer. The sub-command would make the needed system calls + * to obtain all possible column values and then invoke the + * dladm_print_field() function to print the specific fields + * requested in the command line. See the comments for dladm_print_field + * for further details. + * (ii) Alternatively, each fields[i] entry could store a pf_index value + * that uniquely identifies the column to be printed. The implementation + * of the sub-command would then invoke dladm_print_output() with a + * callback function whose semantics are described below (see comments + * for dladm_print_output()) + * + * Thus, an implementation of a sub-command must provide the following: + * + * static print_field_t sub_command_fields[] = { + * {,
,, , cmdtype}, + * : + * {,
,, , cmdtype} + * }; + * + * #define SUB_COMMAND_MAX_FIELDS sizeof \ + * (sub_comand_fields) / sizeof (print_field_t)) + * + * print_state_t sub_command_print_state; + * + * The function that parses command line arguments (typically + * do_sub_command()) should then contain an invocation like: + * + * fields = parse_output_fields(fields_str, sub_command_fields, + * SUB_COMMAND_MAX_FIELDS, CMD_TYPE_ANY, &nfields); + * + * and store the resulting fields and nfields value in a print_state_t + * structure tracked for the command. + * + * sub_command_print_state.ps_fields = fields; + * sub_command_print_state.ps_nfields = nfields; + * + * To print the column header for the output, the print_header() + * function must then be invoked by do_sub_command(). + * + * Then if method (i) is used for the sub_command, the do_sub_command() + * function should make the necessary system calls to fill up the buffer + * and then invoke dladm_print_field(). An example of this method is + * the implementation of do_show_link() and show_link(); + * + * If method (ii) is used, do_sub_command should invoke dladm_print_output() + * with a callback function that will be called for each field to be printed. + * The callback function will be passed a pointer to the print_field_t + * for the field, and the pf_index may then be used to identify the + * system call required to find the value to be printed. An example of + * this implementation may be found in the do_show_dev() and print_dev() + * invocation. + */ + +typedef struct print_field_s { + const char *pf_name; /* name of column to be printed */ + const char *pf_header; /* header for this column */ + uint_t pf_width; + union { + uint_t _pf_index; /* private index for sub-command */ + size_t _pf_offset; + }_pf_un; +#define pf_index _pf_un._pf_index +#define pf_offset _pf_un._pf_offset; + uint_t pf_cmdtype; +} print_field_t; + +/* + * The state of the output is tracked in a print_state_t structure. + * Each ps_fields[i] entry points at the global print_field_t array for + * the sub-command, where ps_nfields is the number of requested fields. + */ +typedef struct print_state_s { + print_field_t **ps_fields; + uint_t ps_nfields; + boolean_t ps_lastfield; + uint_t ps_overflow; +} print_state_t; + +typedef char *(*print_callback_t)(print_field_t *, void *); +static print_field_t **parse_output_fields(char *, print_field_t *, int, + uint_t, uint_t *); +/* + * print the header for the output + */ +static void print_header(print_state_t *); +static void print_field(print_state_t *, print_field_t *, const char *, + boolean_t); + +/* + * to print output values, call dladm_print_output with a callback + * function (*func)() that should parse the args and return an + * unformatted character buffer with the value to be printed. + * + * dladm_print_output() prints the character buffer using the formatting + * information provided in the print_field_t for that column. + */ +static void dladm_print_output(print_state_t *, boolean_t, + print_callback_t, void *); + +/* + * helper function that, when invoked as dladm_print_field(pf, buf) + * prints string which is offset by pf->pf_offset within buf + */ +static char *dladm_print_field(print_field_t *, void *); + + +#define MAX_FIELD_LEN 32 + + typedef struct pktsum_s { uint64_t ipackets; uint64_t opackets; @@ -78,21 +206,25 @@ typedef struct show_state { boolean_t ls_firstonly; boolean_t ls_donefirst; pktsum_t ls_prevstats; - boolean_t ls_parseable; uint32_t ls_flags; dladm_status_t ls_status; + print_state_t ls_print; + boolean_t ls_parseable; + boolean_t ls_printheader; } show_state_t; typedef struct show_grp_state { + pktsum_t gs_prevstats[MAXPORT]; + uint32_t gs_flags; + dladm_status_t gs_status; + boolean_t gs_parseable; boolean_t gs_lacp; boolean_t gs_extended; boolean_t gs_stats; boolean_t gs_firstonly; boolean_t gs_donefirst; - pktsum_t gs_prevstats[MAXPORT]; - boolean_t gs_parseable; - uint32_t gs_flags; - dladm_status_t gs_status; + boolean_t gs_printheader; + print_state_t gs_print; } show_grp_state_t; typedef void cmdfunc_t(int, char **); @@ -107,13 +239,14 @@ static cmdfunc_t do_init_linkprop, do_init_secobj; static cmdfunc_t do_create_vlan, do_delete_vlan, do_up_vlan, do_show_vlan; static cmdfunc_t do_rename_link, do_delete_phys, do_init_phys; static cmdfunc_t do_show_linkmap; +static cmdfunc_t do_show_ether; static void altroot_cmd(char *, int, char **); static int show_linkprop_onelink(datalink_id_t, void *); static void link_stats(datalink_id_t, uint_t); static void aggr_stats(datalink_id_t, show_grp_state_t *, uint_t); -static void dev_stats(const char *dev, uint32_t); +static void dev_stats(const char *dev, uint32_t, char *, show_state_t *); static int get_one_kstat(const char *, const char *, uint8_t, void *, boolean_t); @@ -125,6 +258,16 @@ static void stats_diff(pktsum_t *, pktsum_t *, pktsum_t *); static const char *get_linkstate(const char *, boolean_t, char *); static const char *get_linkduplex(const char *, boolean_t, char *); +static int show_etherprop(datalink_id_t, void *); +static void show_ether_xprop(datalink_id_t, void *); +static boolean_t get_speed_duplex(datalink_id_t, const char *, char *, + char *, boolean_t); +static char *pause_str(int, int); +static boolean_t link_is_ether(const char *, datalink_id_t *); + +#define IS_FDX 0x10 +#define IS_HDX 0x01 + static boolean_t str2int(const char *, int *); static void die(const char *, ...); static void die_optdup(int); @@ -155,6 +298,7 @@ static cmd_t cmds[] = { { "show-linkprop", do_show_linkprop }, { "set-linkprop", do_set_linkprop }, { "reset-linkprop", do_reset_linkprop }, + { "show-ether", do_show_ether }, { "create-secobj", do_create_secobj }, { "delete-secobj", do_delete_secobj }, { "show-secobj", do_show_secobj }, @@ -173,6 +317,7 @@ static cmd_t cmds[] = { static const struct option lopts[] = { {"vlan-id", required_argument, 0, 'v'}, + {"output", required_argument, 0, 'o'}, {"dev", required_argument, 0, 'd'}, {"policy", required_argument, 0, 'P'}, {"lacp-mode", required_argument, 0, 'L'}, @@ -190,6 +335,7 @@ static const struct option show_lopts[] = { {"interval", required_argument, 0, 'i'}, {"parseable", no_argument, 0, 'p'}, {"extended", no_argument, 0, 'x'}, + {"output", required_argument, 0, 'o'}, {"persistent", no_argument, 0, 'P'}, {"lacp", no_argument, 0, 'L'}, { 0, 0, 0, 0 } @@ -197,6 +343,7 @@ static const struct option show_lopts[] = { static const struct option prop_longopts[] = { {"temporary", no_argument, 0, 't' }, + {"output", required_argument, 0, 'o' }, {"root-dir", required_argument, 0, 'R' }, {"prop", required_argument, 0, 'p' }, {"parseable", no_argument, 0, 'c' }, @@ -222,6 +369,418 @@ static const struct option wifi_longopts[] = { {"file", required_argument, 0, 'f' }, { 0, 0, 0, 0 } }; +static const struct option showeth_lopts[] = { + {"parseable", no_argument, 0, 'p' }, + {"extended", no_argument, 0, 'x' }, + {"output", required_argument, 0, 'o' }, + { 0, 0, 0, 0 } +}; + +/* + * structures for 'dladm show-ether' + */ +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]; +} ether_fields_buf_t; + +static print_field_t ether_fields[] = { +/* name, header, field width, offset, cmdtype */ +{ "link", "LINK", 15, + offsetof(ether_fields_buf_t, eth_link), CMD_TYPE_ANY}, +{ "ptype", "PTYPE", 8, + offsetof(ether_fields_buf_t, eth_ptype), CMD_TYPE_ANY}, +{ "state", "STATE", 8, + offsetof(ether_fields_buf_t, eth_state), CMD_TYPE_ANY}, +{ "auto", "AUTO", 5, + offsetof(ether_fields_buf_t, eth_autoneg), CMD_TYPE_ANY}, +{ "speed-duplex", "SPEED-DUPLEX", 31, + offsetof(ether_fields_buf_t, eth_spdx), CMD_TYPE_ANY}, +{ "pause", "PAUSE", 6, + offsetof(ether_fields_buf_t, eth_pause), CMD_TYPE_ANY}, +{ "rem_fault", "REM_FAULT", 16, + offsetof(ether_fields_buf_t, eth_rem_fault), CMD_TYPE_ANY}} +; +#define ETHER_MAX_FIELDS (sizeof (ether_fields) / sizeof (print_field_t)) + +typedef struct print_ether_state { + const char *es_link; + boolean_t es_parseable; + boolean_t es_header; + boolean_t es_extended; + print_state_t es_print; +} print_ether_state_t; + +/* + * structures for 'dladm show-dev'. + */ +typedef enum { + DEV_LINK, + DEV_STATE, + DEV_SPEED, + DEV_DUPLEX +} dev_field_index_t; + +static print_field_t dev_fields[] = { +/* name, header, field width, index, cmdtype */ +{ "link", "LINK", 15, DEV_LINK, CMD_TYPE_ANY}, +{ "state", "STATE", 6, DEV_STATE, CMD_TYPE_ANY}, +{ "speed", "SPEED", 8, DEV_SPEED, CMD_TYPE_ANY}, +{ "duplex", "DUPLEX", 8, DEV_DUPLEX, CMD_TYPE_ANY}} +; +#define DEV_MAX_FIELDS (sizeof (dev_fields) / sizeof (print_field_t)) + +/* + * structures for 'dladm show-dev -s' (print statistics) + */ +typedef enum { + DEVS_LINK, + DEVS_IPKTS, + DEVS_RBYTES, + DEVS_IERRORS, + DEVS_OPKTS, + DEVS_OBYTES, + DEVS_OERRORS +} devs_field_index_t; + +static print_field_t devs_fields[] = { +/* name, header, field width, index, cmdtype */ +{ "link", "LINK", 15, DEVS_LINK, CMD_TYPE_ANY}, +{ "ipackets", "IPACKETS", 10, DEVS_IPKTS, CMD_TYPE_ANY}, +{ "rbytes", "RBYTES", 8, DEVS_RBYTES, CMD_TYPE_ANY}, +{ "ierrors", "IERRORS", 10, DEVS_IERRORS, CMD_TYPE_ANY}, +{ "opackets", "OPACKETS", 12, DEVS_OPKTS, CMD_TYPE_ANY}, +{ "obytes", "OBYTES", 12, DEVS_OBYTES, CMD_TYPE_ANY}, +{ "oerrors", "OERRORS", 8, DEVS_OERRORS, CMD_TYPE_ANY}} +; +#define DEVS_MAX_FIELDS (sizeof (devs_fields) / sizeof (print_field_t)) +typedef struct dev_args_s { + char *devs_link; + pktsum_t *devs_psum; +} dev_args_t; +static char *print_dev_stats(print_field_t *, void *); +static char *print_dev(print_field_t *, void *); + +/* + * 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[6]; + char link_state[DLADM_STRSIZE]; + char link_over[MAXLINKNAMELEN]; + char link_phys_state[6]; + char link_phys_media[DLADM_STRSIZE]; + char link_phys_speed[DLADM_STRSIZE]; + char link_phys_duplex[DLPI_LINKNAME_MAX]; + char link_phys_device[DLPI_LINKNAME_MAX]; + char link_flags[6]; + char link_vlan_vid[6]; +} link_fields_buf_t; + +/* + * structures for 'dladm show-link' + */ +static print_field_t link_fields[] = { +/* name, header, field width, offset, cmdtype */ +{ "link", "LINK", 11, + offsetof(link_fields_buf_t, link_name), CMD_TYPE_ANY}, +{ "class", "CLASS", 8, + offsetof(link_fields_buf_t, link_class), CMD_TYPE_ANY}, +{ "mtu", "MTU", 6, + offsetof(link_fields_buf_t, link_mtu), CMD_TYPE_ANY}, +{ "state", "STATE", 8, + offsetof(link_fields_buf_t, link_state), CMD_TYPE_ANY}, +{ "over", "OVER", DLPI_LINKNAME_MAX, + offsetof(link_fields_buf_t, link_over), CMD_TYPE_ANY}} +; +#define DEV_LINK_FIELDS (sizeof (link_fields) / sizeof (print_field_t)) + +/* + * structures for 'dladm show-aggr' + */ +typedef struct laggr_fields_buf_s { + char laggr_name[DLPI_LINKNAME_MAX]; + char laggr_policy[9]; + char laggr_addrpolicy[ETHERADDRL * 3 + 3]; + char laggr_lacpactivity[14]; + char laggr_lacptimer[DLADM_STRSIZE]; + char laggr_flags[7]; +} laggr_fields_buf_t; + +typedef struct laggr_args_s { + int laggr_lport; /* -1 indicates the aggr itself */ + const char *laggr_link; + dladm_aggr_grp_attr_t *laggr_ginfop; + dladm_status_t *laggr_status; + pktsum_t *laggr_pktsumtot; /* -s only */ + pktsum_t *laggr_prevstats; /* -s only */ + boolean_t laggr_parseable; +} laggr_args_t; + +static print_field_t laggr_fields[] = { +/* name, header, field width, offset, cmdtype */ +{ "link", "LINK", 15, + offsetof(laggr_fields_buf_t, laggr_name), CMD_TYPE_ANY}, +{ "policy", "POLICY", 8, + offsetof(laggr_fields_buf_t, laggr_policy), CMD_TYPE_ANY}, +{ "addrpolicy", "ADDRPOLICY", ETHERADDRL * 3 + 2, + offsetof(laggr_fields_buf_t, laggr_addrpolicy), CMD_TYPE_ANY}, +{ "lacpactivity", "LACPACTIVITY", 13, + offsetof(laggr_fields_buf_t, laggr_lacpactivity), CMD_TYPE_ANY}, +{ "lacptimer", "LACPTIMER", 11, + offsetof(laggr_fields_buf_t, laggr_lacptimer), CMD_TYPE_ANY}, +{ "flags", "FLAGS", 7, + offsetof(laggr_fields_buf_t, laggr_flags), CMD_TYPE_ANY}} +; +#define LAGGR_MAX_FIELDS (sizeof (laggr_fields) / sizeof (print_field_t)) + +/* + * structures for 'dladm show-aggr -x'. + */ +typedef enum { + AGGR_X_LINK, + AGGR_X_PORT, + AGGR_X_SPEED, + AGGR_X_DUPLEX, + AGGR_X_STATE, + AGGR_X_ADDRESS, + AGGR_X_PORTSTATE +} aggr_x_field_index_t; + +static print_field_t aggr_x_fields[] = { +/* name, header, field width, index, cmdtype */ +{ "link", "LINK", 11, AGGR_X_LINK, CMD_TYPE_ANY}, +{ "port", "PORT", 14, AGGR_X_PORT, CMD_TYPE_ANY}, +{ "speed", "SPEED", 4, AGGR_X_SPEED, CMD_TYPE_ANY}, +{ "duplex", "DUPLEX", 9, AGGR_X_DUPLEX, CMD_TYPE_ANY}, +{ "state", "STATE", 9, AGGR_X_STATE, CMD_TYPE_ANY}, +{ "address", "ADDRESS", 18, AGGR_X_ADDRESS, CMD_TYPE_ANY}, +{ "portstate", "PORTSTATE", 15, AGGR_X_PORTSTATE, CMD_TYPE_ANY}} +; +#define AGGR_X_MAX_FIELDS \ + (sizeof (aggr_x_fields) / sizeof (print_field_t)) + +/* + * structures for 'dladm show-aggr -s'. + */ +typedef enum { + AGGR_S_LINK, + AGGR_S_PORT, + AGGR_S_IPKTS, + AGGR_S_RBYTES, + AGGR_S_OPKTS, + AGGR_S_OBYTES, + AGGR_S_IPKTDIST, + AGGR_S_OPKTDIST +} aggr_s_field_index_t; + +static print_field_t aggr_s_fields[] = { +/* name, header, field width, index, cmdtype */ +{ "link", "LINK", 11, AGGR_S_LINK, + CMD_TYPE_ANY}, +{ "port", "PORT", 9, AGGR_S_PORT, + CMD_TYPE_ANY}, +{ "ipackets", "IPACKETS", 7, AGGR_S_IPKTS, + CMD_TYPE_ANY}, +{ "rbytes", "RBYTES", 7, AGGR_S_RBYTES, + CMD_TYPE_ANY}, +{ "opackets", "OPACKETS", 7, AGGR_S_OPKTS, + CMD_TYPE_ANY}, +{ "obytes", "OBYTES", 7, AGGR_S_OBYTES, + CMD_TYPE_ANY}, +{ "ipktdist", "IPKTDIST", 8, AGGR_S_IPKTDIST, + CMD_TYPE_ANY}, +{ "opktdist", "OPKTDIST", 14, AGGR_S_OPKTDIST, + CMD_TYPE_ANY}} +; +#define AGGR_S_MAX_FIELDS \ + (sizeof (aggr_l_fields) / sizeof (print_field_t)) + +/* + * structures for 'dladm show-dev -L'. + */ +typedef enum { + AGGR_L_LINK, + AGGR_L_PORT, + AGGR_L_AGGREGATABLE, + AGGR_L_SYNC, + AGGR_L_COLL, + AGGR_L_DIST, + AGGR_L_DEFAULTED, + AGGR_L_EXPIRED +} aggr_l_field_index_t; + +static print_field_t aggr_l_fields[] = { +/* name, header, field width, index, cmdtype */ +{ "link", "LINK", 11, AGGR_L_LINK, + CMD_TYPE_ANY}, +{ "port", "PORT", 12, AGGR_L_PORT, + CMD_TYPE_ANY}, +{ "aggregatable", "AGGREGATABLE", 12, AGGR_L_AGGREGATABLE, + CMD_TYPE_ANY}, +{ "sync", "SYNC", 4, AGGR_L_SYNC, + CMD_TYPE_ANY}, +{ "coll", "COLL", 4, AGGR_L_COLL, + CMD_TYPE_ANY}, +{ "dist", "DIST", 4, AGGR_L_DIST, + CMD_TYPE_ANY}, +{ "defaulted", "DEFAULTED", 9, AGGR_L_DEFAULTED, + CMD_TYPE_ANY}, +{ "expired", "EXPIRED", 14, AGGR_L_EXPIRED, + CMD_TYPE_ANY}} +; +#define AGGR_L_MAX_FIELDS \ + (sizeof (aggr_l_fields) / sizeof (print_field_t)) + +/* + * structures for 'dladm show-phys' + */ + +static print_field_t phys_fields[] = { +/* name, header, field width, offset, cmdtype */ +{ "link", "LINK", 12, + offsetof(link_fields_buf_t, link_name), CMD_TYPE_ANY}, +{ "media", "MEDIA", 20, + offsetof(link_fields_buf_t, link_phys_media), CMD_TYPE_ANY}, +{ "state", "STATE", 10, + offsetof(link_fields_buf_t, link_phys_state), CMD_TYPE_ANY}, +{ "speed", "SPEED", 4, + offsetof(link_fields_buf_t, link_phys_speed), CMD_TYPE_ANY}, +{ "duplex", "DUPLEX", 9, + offsetof(link_fields_buf_t, link_phys_duplex), CMD_TYPE_ANY}, +{ "device", "DEVICE", 12, + offsetof(link_fields_buf_t, link_phys_device), CMD_TYPE_ANY}, +{ "flags", "FLAGS", 6, + offsetof(link_fields_buf_t, link_flags), CMD_TYPE_ANY}} +; +#define PHYS_MAX_FIELDS (sizeof (phys_fields) / sizeof (print_field_t)) + +/* + * structures for 'dladm show-vlan' + */ +static print_field_t vlan_fields[] = { +/* name, header, field width, offset, cmdtype */ +{ "link", "LINK", 15, + offsetof(link_fields_buf_t, link_name), CMD_TYPE_ANY}, +{ "vid", "VID", 8, + offsetof(link_fields_buf_t, link_vlan_vid), CMD_TYPE_ANY}, +{ "over", "OVER", 12, + offsetof(link_fields_buf_t, link_over), CMD_TYPE_ANY}, +{ "flags", "FLAGS", 6, + offsetof(link_fields_buf_t, link_flags), CMD_TYPE_ANY}} +; +#define VLAN_MAX_FIELDS (sizeof (vlan_fields) / sizeof (print_field_t)) + +/* + * structures for 'dladm show-wifi' + */ +static print_field_t wifi_fields[] = { +{ "link", "LINK", 10, 0, WIFI_CMD_ALL}, +{ "essid", "ESSID", 19, DLADM_WLAN_ATTR_ESSID, WIFI_CMD_ALL}, +{ "bssid", "BSSID/IBSSID", 17, DLADM_WLAN_ATTR_BSSID, WIFI_CMD_ALL}, +{ "ibssid", "BSSID/IBSSID", 17, DLADM_WLAN_ATTR_BSSID, WIFI_CMD_ALL}, +{ "mode", "MODE", 6, DLADM_WLAN_ATTR_MODE, WIFI_CMD_ALL}, +{ "speed", "SPEED", 6, DLADM_WLAN_ATTR_SPEED, WIFI_CMD_ALL}, +{ "auth", "AUTH", 8, DLADM_WLAN_ATTR_AUTH, WIFI_CMD_SHOW}, +{ "bsstype", "BSSTYPE", 8, DLADM_WLAN_ATTR_BSSTYPE, WIFI_CMD_ALL}, +{ "sec", "SEC", 6, DLADM_WLAN_ATTR_SECMODE, WIFI_CMD_ALL}, +{ "status", "STATUS", 17, DLADM_WLAN_LINKATTR_STATUS, WIFI_CMD_SHOW}, +{ "strength", "STRENGTH", 10, DLADM_WLAN_ATTR_STRENGTH, WIFI_CMD_ALL}} +; + +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"; + +#define WIFI_MAX_FIELDS (sizeof (wifi_fields) / sizeof (print_field_t)) + +/* + * structures for 'dladm show-linkprop' + */ +typedef enum { + LINKPROP_LINK, + LINKPROP_PROPERTY, + LINKPROP_VALUE, + LINKPROP_DEFAULT, + LINKPROP_POSSIBLE +} linkprop_field_index_t; + +static print_field_t linkprop_fields[] = { +/* name, header, field width, index, cmdtype */ +{ "link", "LINK", 12, LINKPROP_LINK, CMD_TYPE_ANY}, +{ "property", "PROPERTY", 15, LINKPROP_PROPERTY, CMD_TYPE_ANY}, +{ "value", "VALUE", 14, LINKPROP_VALUE, CMD_TYPE_ANY}, +{ "default", "DEFAULT", 14, LINKPROP_DEFAULT, CMD_TYPE_ANY}, +{ "possible", "POSSIBLE", 20, LINKPROP_POSSIBLE, CMD_TYPE_ANY}} +; +#define LINKPROP_MAX_FIELDS \ + (sizeof (linkprop_fields) / sizeof (print_field_t)) + +#define MAX_PROPS 32 +#define MAX_PROP_LINE 512 + +typedef struct prop_info { + char *pi_name; + char *pi_val[DLADM_MAX_PROP_VALCNT]; + uint_t pi_count; +} prop_info_t; + +typedef struct prop_list { + prop_info_t pl_info[MAX_PROPS]; + uint_t pl_count; + char *pl_buf; +} prop_list_t; + +typedef struct show_linkprop_state { + char ls_link[MAXLINKNAMELEN]; + char *ls_line; + char **ls_propvals; + prop_list_t *ls_proplist; + boolean_t ls_parseable; + boolean_t ls_persist; + boolean_t ls_header; + dladm_status_t ls_status; + dladm_status_t ls_retstatus; + print_state_t ls_print; +} show_linkprop_state_t; + +typedef struct linkprop_args_s { + show_linkprop_state_t *ls_state; + char *ls_propname; + datalink_id_t ls_linkid; +} linkprop_args_t; + +/* + * 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]; +} secobj_fields_buf_t; +static print_field_t secobj_fields[] = { +/* name, header, field width, offset, cmdtype */ +{ "object", "OBJECT", 20, + offsetof(secobj_fields_buf_t, ss_obj_name), CMD_TYPE_ANY}, +{ "class", "CLASS", 20, + offsetof(secobj_fields_buf_t, ss_class), CMD_TYPE_ANY}, +{ "value", "VALUE", 30, + offsetof(secobj_fields_buf_t, ss_val), CMD_TYPE_ANY}} +; +#define DEV_SOBJ_FIELDS (sizeof (secobj_fields) / sizeof (print_field_t)) static char *progname; static sig_atomic_t signalled; @@ -230,25 +789,28 @@ static void usage(void) { (void) fprintf(stderr, gettext("usage: dladm ...\n" - "\tshow-link [-pP] [-s [-i ]] []\n" + "\tshow-link [-pP] [-o ,..] [-s [-i ]] " + "[]\n" "\trename-link [-R ] \n" "\n" "\tdelete-phys \n" - "\tshow-phys [-pP] []\n" - "\tshow-dev [-p] [-s [-i ]] []\n" + "\tshow-phys [-pP] [-o ,..] []\n" + "\tshow-dev [-p] [-o ,..] [-s [-i ]] " + "[]\n" "\n" "\tcreate-aggr [-t] [-R ] [-P ] [-L ]\n" "\t [-T