diff options
| author | Artem Kachitchkine <Artem.Kachitchkin@Sun.COM> | 2008-12-26 16:52:57 -0800 |
|---|---|---|
| committer | Artem Kachitchkine <Artem.Kachitchkin@Sun.COM> | 2008-12-26 16:52:57 -0800 |
| commit | 62ee1d25bffb3d6d74798efe1199f7e86a29a14e (patch) | |
| tree | f49f1a15b5832247208e7b448efb94910c0e0951 /usr/src/cmd/dlmgmtd | |
| parent | 5c066ec28ea93f3a7c93082611a61747f255290a (diff) | |
| download | illumos-joyent-62ee1d25bffb3d6d74798efe1199f7e86a29a14e.tar.gz | |
6688428 dladm init-linkprop ignores private properties
Diffstat (limited to 'usr/src/cmd/dlmgmtd')
| -rw-r--r-- | usr/src/cmd/dlmgmtd/dlmgmt_door.c | 58 | ||||
| -rw-r--r-- | usr/src/cmd/dlmgmtd/dlmgmt_impl.h | 3 | ||||
| -rw-r--r-- | usr/src/cmd/dlmgmtd/dlmgmt_util.c | 30 |
3 files changed, 87 insertions, 4 deletions
diff --git a/usr/src/cmd/dlmgmtd/dlmgmt_door.c b/usr/src/cmd/dlmgmtd/dlmgmt_door.c index 532260ac4f..90c923920d 100644 --- a/usr/src/cmd/dlmgmtd/dlmgmt_door.c +++ b/usr/src/cmd/dlmgmtd/dlmgmt_door.c @@ -446,6 +446,7 @@ dlmgmt_upcall_getattr(void *argp, void *retp) dlmgmt_upcall_arg_getattr_t *getattr = argp; dlmgmt_getattr_retval_t *retvalp = retp; dlmgmt_link_t *linkp; + int err = 0; /* * Hold the reader lock to access the link @@ -455,7 +456,7 @@ dlmgmt_upcall_getattr(void *argp, void *retp) /* * The link does not exist. */ - retvalp->lr_err = ENOENT; + err = ENOENT; goto done; } @@ -463,6 +464,7 @@ dlmgmt_upcall_getattr(void *argp, void *retp) done: dlmgmt_table_unlock(); + retvalp->lr_err = err; } static void @@ -955,6 +957,54 @@ dlmgmt_upcall_linkprop_init(void *argp, void *retp) lip->ld_linkid, B_TRUE); } +/* + * Get the link property that follows ld_last_attr. + * If ld_last_attr is empty, return the first property. + */ +static void +dlmgmt_linkprop_getnext(void *argp, void *retp) +{ + dlmgmt_door_linkprop_getnext_t *getnext = argp; + dlmgmt_linkprop_getnext_retval_t *retvalp = retp; + dlmgmt_dlconf_t dlconf, *dlconfp; + char *attr; + void *attrval; + size_t attrsz; + dladm_datatype_t attrtype; + int err = 0; + + /* + * Hold the read lock to access the dlconf table. + */ + dlmgmt_dlconf_table_lock(B_FALSE); + + dlconf.ld_id = (int)getnext->ld_conf; + dlconfp = avl_find(&dlmgmt_dlconf_avl, &dlconf, NULL); + if (dlconfp == NULL) { + err = ENOENT; + goto done; + } + + err = linkprop_getnext(&dlconfp->ld_head, getnext->ld_last_attr, + &attr, &attrval, &attrsz, &attrtype); + if (err != 0) + goto done; + + if (attrsz > MAXLINKATTRVALLEN) { + err = EINVAL; + goto done; + } + + (void) strlcpy(retvalp->lr_attr, attr, MAXLINKATTRLEN); + retvalp->lr_type = attrtype; + retvalp->lr_attrsz = attrsz; + bcopy(attrval, retvalp->lr_attrval, attrsz); + +done: + dlmgmt_dlconf_table_unlock(); + retvalp->lr_err = err; +} + static dlmgmt_door_info_t i_dlmgmt_door_info_tbl[] = { { DLMGMT_CMD_DLS_CREATE, B_TRUE, sizeof (dlmgmt_upcall_arg_create_t), sizeof (dlmgmt_create_retval_t), dlmgmt_upcall_create }, @@ -997,7 +1047,11 @@ static dlmgmt_door_info_t i_dlmgmt_door_info_tbl[] = { { DLMGMT_CMD_LINKPROP_INIT, B_TRUE, sizeof (dlmgmt_door_linkprop_init_t), sizeof (dlmgmt_linkprop_init_retval_t), - dlmgmt_upcall_linkprop_init } + dlmgmt_upcall_linkprop_init }, + { DLMGMT_CMD_LINKPROP_GETNEXT, B_FALSE, + sizeof (dlmgmt_door_linkprop_getnext_t), + sizeof (dlmgmt_linkprop_getnext_retval_t), + dlmgmt_linkprop_getnext } }; #define DLMGMT_INFO_TABLE_SIZE (sizeof (i_dlmgmt_door_info_tbl) / \ diff --git a/usr/src/cmd/dlmgmtd/dlmgmt_impl.h b/usr/src/cmd/dlmgmtd/dlmgmt_impl.h index 09dcf2b1b4..4bd8f2d2cb 100644 --- a/usr/src/cmd/dlmgmtd/dlmgmt_impl.h +++ b/usr/src/cmd/dlmgmtd/dlmgmt_impl.h @@ -48,6 +48,7 @@ typedef struct dlmgmt_linkattr_s { void *lp_val; dladm_datatype_t lp_type; uint_t lp_sz; + boolean_t lp_linkprop; } dlmgmt_linkattr_t; /* @@ -94,6 +95,8 @@ int linkattr_set(dlmgmt_linkattr_t **, const char *, void *, size_t, dladm_datatype_t); int linkattr_get(dlmgmt_linkattr_t **, const char *, void **, size_t *, dladm_datatype_t *); +int linkprop_getnext(dlmgmt_linkattr_t **, const char *, + char **, void **, size_t *, dladm_datatype_t *); void link_destroy(dlmgmt_link_t *); dlmgmt_link_t *link_by_id(datalink_id_t); diff --git a/usr/src/cmd/dlmgmtd/dlmgmt_util.c b/usr/src/cmd/dlmgmtd/dlmgmt_util.c index ce41103dc4..ef1d3f7219 100644 --- a/usr/src/cmd/dlmgmtd/dlmgmt_util.c +++ b/usr/src/cmd/dlmgmtd/dlmgmt_util.c @@ -24,8 +24,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * Utility functions used by the dlmgmtd daemon. */ @@ -248,6 +246,7 @@ linkattr_set(dlmgmt_linkattr_t **headp, const char *attr, void *attrval, bcopy(attrval, attrp->lp_val, attrsz); attrp->lp_sz = attrsz; attrp->lp_type = type; + attrp->lp_linkprop = dladm_attr_is_linkprop(attr); return (0); } @@ -308,6 +307,33 @@ linkattr_get(dlmgmt_linkattr_t **headp, const char *attr, void **attrvalp, return (0); } +int +linkprop_getnext(dlmgmt_linkattr_t **headp, const char *lastattr, + char **attrnamep, void **attrvalp, size_t *attrszp, dladm_datatype_t *typep) +{ + dlmgmt_linkattr_t *attrp; + + /* skip to entry following lastattr or pick first if none specified */ + for (attrp = *headp; attrp != NULL; attrp = attrp->lp_next) { + if (!attrp->lp_linkprop) + continue; + if (lastattr[0] == '\0') + break; + if (strcmp(attrp->lp_name, lastattr) == 0) { + attrp = attrp->lp_next; + break; + } + } + if (attrp == NULL) + return (ENOENT); + + *attrnamep = attrp->lp_name; + *attrvalp = attrp->lp_val; + *attrszp = attrp->lp_sz; + *typep = attrp->lp_type; + return (0); +} + boolean_t linkattr_equal(dlmgmt_linkattr_t **headp, const char *attr, void *attrval, size_t attrsz) |
