diff options
| author | Garrett D'Amore <gdamore@opensolaris.org> | 2009-10-07 07:12:17 -0700 |
|---|---|---|
| committer | Garrett D'Amore <gdamore@opensolaris.org> | 2009-10-07 07:12:17 -0700 |
| commit | 3ade6e843b7f9e2656892a172ecd9e302b0dee09 (patch) | |
| tree | 7296fba64bde85af1992472e199810062f913c6f /usr | |
| parent | ab412e7222cc32794594e5ad31919652d757c81f (diff) | |
| download | illumos-joyent-3ade6e843b7f9e2656892a172ecd9e302b0dee09.tar.gz | |
6888680 GLDv3 PPA nits
6888202 vnic not available in early boot
6888700 potential fencepost errors involving MAX_PPA and MAX_MINOR
Diffstat (limited to 'usr')
| -rw-r--r-- | usr/src/uts/common/io/dld/dld_str.c | 8 | ||||
| -rw-r--r-- | usr/src/uts/common/io/dls/dls_mgmt.c | 2 | ||||
| -rw-r--r-- | usr/src/uts/common/io/mac/mac_provider.c | 2 | ||||
| -rw-r--r-- | usr/src/uts/common/io/softmac/softmac_main.c | 23 |
4 files changed, 20 insertions, 15 deletions
diff --git a/usr/src/uts/common/io/dld/dld_str.c b/usr/src/uts/common/io/dld/dld_str.c index 41e188f321..50443b2a06 100644 --- a/usr/src/uts/common/io/dld/dld_str.c +++ b/usr/src/uts/common/io/dld/dld_str.c @@ -155,7 +155,7 @@ i_dld_str_walker(mod_hash_key_t key, mod_hash_val_t *val, void *arg) */ if (mh != NULL) { statep->ds_dip = mac_devinfo_get(mh); - statep->ds_instance = mac_minor(mh) - 1; + statep->ds_instance = DLS_MINOR2INST(mac_minor(mh)); } return (MH_WALK_TERMINATE); } @@ -202,8 +202,8 @@ dld_devt_to_instance(dev_t dev) return (-1); /* - * Check for style 2 unassociated node, this is quick and - * easy. Note that this doesn't *necessarily* work for legacy + * Check for unopened style 1 node. + * Note that this doesn't *necessarily* work for legacy * devices, but this code is only called within the * getinfo(9e) implementation for true GLDv3 devices, so it * doesn't matter. @@ -228,7 +228,7 @@ dld_devt_to_instance(dev_t dev) * instances are attached. Hence, if a particular provider needs a * special mapping (the mac instance != ddi_get_instance()), then it * may need to provide its own implmentation using the - * MAC_MINOR_TO_INSTANCE() function, and translating the returned mac + * mac_devt_to_instance() function, and translating the returned mac * instance to a devinfo instance. For dev_t's where the minor number * is too large (i.e. > MAC_MAX_MINOR), the provider can call this * function indirectly via the mac_getinfo() function. diff --git a/usr/src/uts/common/io/dls/dls_mgmt.c b/usr/src/uts/common/io/dls/dls_mgmt.c index b4bac61ea0..f94ca1abaa 100644 --- a/usr/src/uts/common/io/dls/dls_mgmt.c +++ b/usr/src/uts/common/io/dls/dls_mgmt.c @@ -1068,7 +1068,7 @@ dls_devnet_hold_by_dev(dev_t dev, dls_dl_handle_t *ddhp) * Hold this link to prevent it being detached in case of a * GLDv3 physical link. */ - if (DLS_MINOR2INST(getminor(dev)) < DLS_MAX_MINOR) + if (DLS_MINOR2INST(getminor(dev)) <= DLS_MAX_PPA) (void) softmac_hold_device(dev, &ddh); rw_enter(&i_dls_devnet_lock, RW_WRITER); diff --git a/usr/src/uts/common/io/mac/mac_provider.c b/usr/src/uts/common/io/mac/mac_provider.c index 3192314e51..090de162b5 100644 --- a/usr/src/uts/common/io/mac/mac_provider.c +++ b/usr/src/uts/common/io/mac/mac_provider.c @@ -403,7 +403,7 @@ mac_register(mac_register_t *mregp, mac_handle_t *mhp) dnp->dn_flags |= (DN_GLDV3_DRIVER | DN_NETWORK_DRIVER); UNLOCK_DEV_OPS(&dnp->dn_lock); - if (mip->mi_minor < MAC_MAX_MINOR + 1) { + if (mip->mi_minor <= MAC_MAX_MINOR) { /* Create a style-2 DLPI device */ if (ddi_create_minor_node(mip->mi_dip, driver, S_IFCHR, 0, DDI_NT_NET, CLONE_DEV) != DDI_SUCCESS) diff --git a/usr/src/uts/common/io/softmac/softmac_main.c b/usr/src/uts/common/io/softmac/softmac_main.c index 01068e1538..cd4b7ee9f2 100644 --- a/usr/src/uts/common/io/softmac/softmac_main.c +++ b/usr/src/uts/common/io/softmac/softmac_main.c @@ -1509,21 +1509,13 @@ softmac_hold_device(dev_t dev, dls_dev_handle_t *ddhp) drvname = ddi_major_to_name(getmajor(dev)); /* - * Exclude non-physical network device instances, for example, aggr0. - */ - if (!NETWORK_DRV(getmajor(dev)) || (strcmp(drvname, "aggr") == 0) || - (strcmp(drvname, "vnic") == 0)) { - return (ENOENT); - } - - /* * We have to lookup the device instance using getinfo(9e). */ inst = dev_to_instance(dev); if (inst < 0) return (ENOENT); - if ((ppa = getminor(dev) - 1) > 1000) + if ((ppa = getminor(dev) - 1) > DLS_MAX_PPA) return (ENOENT); /* @@ -1534,6 +1526,19 @@ softmac_hold_device(dev_t dev, dls_dev_handle_t *ddhp) return (ENOENT); /* + * Exclude non-physical network device instances, for example, aggr0. + * Note: this check *must* occur after the dip is held, or else + * NETWORK_DRV might return false incorrectly. (Essentially, the + * driver needs to be loaded to populate the dev_ops structure + * that NETWORK_DRV checks.) + */ + if (!NETWORK_DRV(getmajor(dev)) || (strcmp(drvname, "aggr") == 0) || + (strcmp(drvname, "vnic") == 0)) { + ddi_release_devi(dip); + return (ENOENT); + } + + /* * This is a network device; wait for its softmac to be registered. */ (void) snprintf(devname, MAXNAMELEN, "%s%d", drvname, ppa); |
