summaryrefslogtreecommitdiff
path: root/usr/src/lib/libmacadm/common/libmacadm.c
diff options
context:
space:
mode:
authorericheng <none@none>2005-08-29 18:49:03 -0700
committerericheng <none@none>2005-08-29 18:49:03 -0700
commitcd93090ec4fd8704271aee7cc8241a848bc78ffd (patch)
tree8866a859b0500824028a7b4e13d28ba415351201 /usr/src/lib/libmacadm/common/libmacadm.c
parenta14d39b7841e304340dbd4378ec3266bd6868156 (diff)
downloadillumos-gate-cd93090ec4fd8704271aee7cc8241a848bc78ffd.tar.gz
6252036 dladm show-link outputs nothing for regular users
6260551 aggr_grp_detach_port() can be called without AGGR_LACP_LOCK_HELD 6270678 The aggregation was unavailable after using dladm modify-aggr change mac address to zero 6283674 potential race condition between dls_rx_set and i_dls_link_ether_rx 6293292 dladm show-dev deceives when passed unknown device names 6309909 dld_open must call qassociate(9F) to inform the framework it is DDI-compliant 6311907 poll_tx, ill_tx and str_mdata_fastpath_put() comments are incorrect 6313057 dladm show-dev doesn't show legacy devices 6315019 sparc full kernel lint is missing many modules
Diffstat (limited to 'usr/src/lib/libmacadm/common/libmacadm.c')
-rw-r--r--usr/src/lib/libmacadm/common/libmacadm.c61
1 files changed, 40 insertions, 21 deletions
diff --git a/usr/src/lib/libmacadm/common/libmacadm.c b/usr/src/lib/libmacadm/common/libmacadm.c
index 053d1c5011..9e6061099d 100644
--- a/usr/src/lib/libmacadm/common/libmacadm.c
+++ b/usr/src/lib/libmacadm/common/libmacadm.c
@@ -30,11 +30,11 @@
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
#include <stropts.h>
#include <sys/dld.h>
#include <libdevinfo.h>
-#include <libdladm.h>
-#include <libdlpi.h>
#define _KERNEL
#include <sys/sysmacros.h>
@@ -48,9 +48,13 @@
*
*/
+typedef struct macadm_dev {
+ char md_name[MAXNAMELEN];
+ struct macadm_dev *md_next;
+} macadm_dev_t;
+
typedef struct macadm_walk {
- void *mw_arg;
- void (*mw_fn)(void *, const char *);
+ macadm_dev_t *mw_dev_list;
} macadm_walk_t;
/*
@@ -61,28 +65,36 @@ static int
i_macadm_apply(di_node_t node, di_minor_t minor, void *arg)
{
macadm_walk_t *mwp = arg;
+ macadm_dev_t *mdp = mwp->mw_dev_list;
+ macadm_dev_t **lastp = &mwp->mw_dev_list;
char dev[MAXNAMELEN];
- dladm_attr_t dlattr;
- int fd;
(void) snprintf(dev, MAXNAMELEN, "%s%d",
di_driver_name(node), di_instance(node));
/*
- * We need to be able to report devices that are
- * reported by the walker, but have not yet attached
- * to the system. Attempting to opening them will
- * cause them to temporarely attach and be known
- * by dld.
+ * Skip aggregations.
*/
- if ((fd = dlpi_open(dev)) == -1 && errno != EPERM)
+ if (strcmp("aggr", di_driver_name(node)) == 0)
+ return (DI_WALK_CONTINUE);
+
+ while (mdp) {
+ /*
+ * Skip duplicates.
+ */
+ if (strcmp(mdp->md_name, dev) == 0)
+ return (DI_WALK_CONTINUE);
+
+ lastp = &mdp->md_next;
+ mdp = mdp->md_next;
+ }
+
+ if ((mdp = malloc(sizeof (*mdp))) == NULL)
return (DI_WALK_CONTINUE);
- if (fd != 0)
- (void) dlpi_close(fd);
- /* invoke callback only for non-legacy devices */
- if (dladm_info(dev, &dlattr) == 0)
- mwp->mw_fn(mwp->mw_arg, dev);
+ (void) strlcpy(mdp->md_name, dev, MAXNAMELEN);
+ mdp->md_next = NULL;
+ *lastp = mdp;
return (DI_WALK_CONTINUE);
}
@@ -96,7 +108,8 @@ macadm_walk(void (*fn)(void *, const char *), void *arg,
{
di_node_t root;
macadm_walk_t mw;
- uint_t flags;
+ macadm_dev_t *mdp;
+ uint_t flags;
if (use_cache) {
flags = DINFOCACHE;
@@ -107,12 +120,18 @@ macadm_walk(void (*fn)(void *, const char *), void *arg,
if ((root = di_init("/", flags)) == DI_NODE_NIL) {
return (-1);
}
+ mw.mw_dev_list = NULL;
- mw.mw_fn = fn;
- mw.mw_arg = arg;
+ (void) di_walk_minor(root, DDI_NT_NET, DI_CHECK_ALIAS, &mw,
+ i_macadm_apply);
- (void) di_walk_minor(root, DDI_NT_NET, 0, &mw, i_macadm_apply);
di_fini(root);
+ mdp = mw.mw_dev_list;
+ while (mdp) {
+ (*fn)(arg, mdp->md_name);
+ mdp = mdp->md_next;
+ }
+
return (0);
}