xref: /titanic_52/usr/src/uts/common/syscall/systeminfo.c (revision 986fd29a0dc13f7608ef7f508f6e700bd7bc2720)
17c478bd9Sstevel@tonic-gate /*
27c478bd9Sstevel@tonic-gate  * CDDL HEADER START
37c478bd9Sstevel@tonic-gate  *
47c478bd9Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
5abddd56eScb117521  * Common Development and Distribution License (the "License").
6abddd56eScb117521  * You may not use this file except in compliance with the License.
77c478bd9Sstevel@tonic-gate  *
87c478bd9Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97c478bd9Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
107c478bd9Sstevel@tonic-gate  * See the License for the specific language governing permissions
117c478bd9Sstevel@tonic-gate  * and limitations under the License.
127c478bd9Sstevel@tonic-gate  *
137c478bd9Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
147c478bd9Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157c478bd9Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
167c478bd9Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
177c478bd9Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
187c478bd9Sstevel@tonic-gate  *
197c478bd9Sstevel@tonic-gate  * CDDL HEADER END
207c478bd9Sstevel@tonic-gate  */
217c478bd9Sstevel@tonic-gate /*
22a9ddc71cSsetje  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
237c478bd9Sstevel@tonic-gate  * Use is subject to license terms.
247c478bd9Sstevel@tonic-gate  */
257c478bd9Sstevel@tonic-gate 
267c478bd9Sstevel@tonic-gate /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
277c478bd9Sstevel@tonic-gate /*	  All rights reserved.	*/
287c478bd9Sstevel@tonic-gate 
297c478bd9Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
307c478bd9Sstevel@tonic-gate 
317c478bd9Sstevel@tonic-gate #include <sys/param.h>
327c478bd9Sstevel@tonic-gate #include <sys/types.h>
337c478bd9Sstevel@tonic-gate #include <sys/sysmacros.h>
347c478bd9Sstevel@tonic-gate #include <sys/systm.h>
357c478bd9Sstevel@tonic-gate #include <sys/tuneable.h>
367c478bd9Sstevel@tonic-gate #include <sys/errno.h>
377c478bd9Sstevel@tonic-gate #include <sys/cred.h>
387c478bd9Sstevel@tonic-gate #include <sys/utsname.h>
397c478bd9Sstevel@tonic-gate #include <sys/systeminfo.h>
407c478bd9Sstevel@tonic-gate #include <sys/unistd.h>
417c478bd9Sstevel@tonic-gate #include <sys/debug.h>
427c478bd9Sstevel@tonic-gate #include <sys/bootconf.h>
437c478bd9Sstevel@tonic-gate #include <sys/socket.h>
447c478bd9Sstevel@tonic-gate #include <sys/policy.h>
457c478bd9Sstevel@tonic-gate #include <net/if.h>
467c478bd9Sstevel@tonic-gate #include <sys/sunddi.h>
477c478bd9Sstevel@tonic-gate #include <sys/promif.h>
487c478bd9Sstevel@tonic-gate #include <sys/zone.h>
497c478bd9Sstevel@tonic-gate #include <sys/model.h>
50*986fd29aSsetje #include <netinet/inetutil.h>
517c478bd9Sstevel@tonic-gate 
527c478bd9Sstevel@tonic-gate static void get_netif_name(char *, char *);
537c478bd9Sstevel@tonic-gate 
547c478bd9Sstevel@tonic-gate long
557c478bd9Sstevel@tonic-gate systeminfo(int command, char *buf, long count)
567c478bd9Sstevel@tonic-gate {
577c478bd9Sstevel@tonic-gate 	int error = 0;
587c478bd9Sstevel@tonic-gate 	long strcnt, getcnt;
597c478bd9Sstevel@tonic-gate 	char *kstr;
607c478bd9Sstevel@tonic-gate 
617c478bd9Sstevel@tonic-gate 	if (count < 0 && command != SI_SET_HOSTNAME &&
627c478bd9Sstevel@tonic-gate 	    command != SI_SET_SRPC_DOMAIN)
637c478bd9Sstevel@tonic-gate 		return (set_errno(EINVAL));
647c478bd9Sstevel@tonic-gate 
657c478bd9Sstevel@tonic-gate 	/*
667c478bd9Sstevel@tonic-gate 	 * Deal with the common "get a string" case first.
677c478bd9Sstevel@tonic-gate 	 */
687c478bd9Sstevel@tonic-gate 	switch (command) {
697c478bd9Sstevel@tonic-gate 	case SI_SYSNAME:
707c478bd9Sstevel@tonic-gate 		kstr = utsname.sysname;
717c478bd9Sstevel@tonic-gate 		break;
727c478bd9Sstevel@tonic-gate 	case SI_HOSTNAME:
737c478bd9Sstevel@tonic-gate 		kstr = uts_nodename();
747c478bd9Sstevel@tonic-gate 		break;
757c478bd9Sstevel@tonic-gate 	case SI_RELEASE:
767c478bd9Sstevel@tonic-gate 		kstr = utsname.release;
777c478bd9Sstevel@tonic-gate 		break;
787c478bd9Sstevel@tonic-gate 	case SI_VERSION:
797c478bd9Sstevel@tonic-gate 		kstr = utsname.version;
807c478bd9Sstevel@tonic-gate 		break;
817c478bd9Sstevel@tonic-gate 	case SI_MACHINE:
827c478bd9Sstevel@tonic-gate 		kstr = utsname.machine;
837c478bd9Sstevel@tonic-gate 		break;
847c478bd9Sstevel@tonic-gate #ifdef _LP64
857c478bd9Sstevel@tonic-gate 	case SI_ARCHITECTURE_64:
867c478bd9Sstevel@tonic-gate 	case SI_ARCHITECTURE_K:
877c478bd9Sstevel@tonic-gate 		kstr = architecture;
887c478bd9Sstevel@tonic-gate 		break;
897c478bd9Sstevel@tonic-gate 	case SI_ARCHITECTURE_32:
907c478bd9Sstevel@tonic-gate 	case SI_ARCHITECTURE:
917c478bd9Sstevel@tonic-gate 		kstr = architecture_32;
927c478bd9Sstevel@tonic-gate 		break;
937c478bd9Sstevel@tonic-gate 	case SI_ARCHITECTURE_NATIVE:
947c478bd9Sstevel@tonic-gate 		kstr = get_udatamodel() == DATAMODEL_NATIVE ?
957c478bd9Sstevel@tonic-gate 		    architecture : architecture_32;
967c478bd9Sstevel@tonic-gate 		break;
977c478bd9Sstevel@tonic-gate #else
987c478bd9Sstevel@tonic-gate 	case SI_ARCHITECTURE_K:
997c478bd9Sstevel@tonic-gate 	case SI_ARCHITECTURE_32:
1007c478bd9Sstevel@tonic-gate 	case SI_ARCHITECTURE:
1017c478bd9Sstevel@tonic-gate 	case SI_ARCHITECTURE_NATIVE:
1027c478bd9Sstevel@tonic-gate 		kstr = architecture;
1037c478bd9Sstevel@tonic-gate 		break;
1047c478bd9Sstevel@tonic-gate #endif
1057c478bd9Sstevel@tonic-gate 	case SI_HW_SERIAL:
1067c478bd9Sstevel@tonic-gate 		kstr = hw_serial;
1077c478bd9Sstevel@tonic-gate 		break;
1087c478bd9Sstevel@tonic-gate 	case SI_HW_PROVIDER:
1097c478bd9Sstevel@tonic-gate 		kstr = hw_provider;
1107c478bd9Sstevel@tonic-gate 		break;
1117c478bd9Sstevel@tonic-gate 	case SI_SRPC_DOMAIN:
1127c478bd9Sstevel@tonic-gate 		kstr = curproc->p_zone->zone_domain;
1137c478bd9Sstevel@tonic-gate 		break;
1147c478bd9Sstevel@tonic-gate 	case SI_PLATFORM:
1157c478bd9Sstevel@tonic-gate 		kstr = platform;
1167c478bd9Sstevel@tonic-gate 		break;
1177c478bd9Sstevel@tonic-gate 	case SI_ISALIST:
1187c478bd9Sstevel@tonic-gate 		kstr = isa_list;
1197c478bd9Sstevel@tonic-gate 		break;
1207c478bd9Sstevel@tonic-gate 	default:
1217c478bd9Sstevel@tonic-gate 		kstr = NULL;
1227c478bd9Sstevel@tonic-gate 		break;
1237c478bd9Sstevel@tonic-gate 	}
1247c478bd9Sstevel@tonic-gate 
1257c478bd9Sstevel@tonic-gate 	if (kstr != NULL) {
126abddd56eScb117521 		strcnt = strlen(kstr);
127abddd56eScb117521 		if (count > 0) {
128abddd56eScb117521 			if (count <= strcnt) {
1297c478bd9Sstevel@tonic-gate 				getcnt = count - 1;
130abddd56eScb117521 				if (subyte(buf + getcnt, 0) < 0)
1317c478bd9Sstevel@tonic-gate 					return (set_errno(EFAULT));
132abddd56eScb117521 			} else {
1337c478bd9Sstevel@tonic-gate 				getcnt = strcnt + 1;
134abddd56eScb117521 			}
1357c478bd9Sstevel@tonic-gate 			if (copyout(kstr, buf, getcnt))
1367c478bd9Sstevel@tonic-gate 				return (set_errno(EFAULT));
137abddd56eScb117521 		}
1387c478bd9Sstevel@tonic-gate 		return (strcnt + 1);
1397c478bd9Sstevel@tonic-gate 	}
1407c478bd9Sstevel@tonic-gate 
1417c478bd9Sstevel@tonic-gate 	switch (command) {
1427c478bd9Sstevel@tonic-gate 	case SI_DHCP_CACHE:
1437c478bd9Sstevel@tonic-gate 	{
1447c478bd9Sstevel@tonic-gate 		char	*tmp;
145*986fd29aSsetje 		unsigned int tlen, octlen;
1467c478bd9Sstevel@tonic-gate 
1477c478bd9Sstevel@tonic-gate 		if (dhcack == NULL) {
1487c478bd9Sstevel@tonic-gate 			tmp = "";
1497c478bd9Sstevel@tonic-gate 			strcnt = 0;
1507c478bd9Sstevel@tonic-gate 		} else {
1517c478bd9Sstevel@tonic-gate 			/*
152a9ddc71cSsetje 			 * If the interface didn't have a name (bindable
153a9ddc71cSsetje 			 * driver) to begin with, it might have one now.
154a9ddc71cSsetje 			 * So, re-run strplumb_get_netdev_path() to see
155a9ddc71cSsetje 			 * if one can be established at this time.
156a9ddc71cSsetje 			 */
157a9ddc71cSsetje 			if (netdev_path == NULL || netdev_path[0] == '\0') {
158a9ddc71cSsetje 				netdev_path = strplumb_get_netdev_path();
159a9ddc71cSsetje 			}
160a9ddc71cSsetje 			/*
1617c478bd9Sstevel@tonic-gate 			 * If the interface name has not yet been resolved
162*986fd29aSsetje 			 * and a validnetdev_path[] was stashed by
163*986fd29aSsetje 			 * loadrootmodules in swapgeneric.c, or established
164*986fd29aSsetje 			 * above, resolve the interface name now.
1657c478bd9Sstevel@tonic-gate 			 */
166*986fd29aSsetje 			if (dhcifname[0] == '\0' &&
1677c478bd9Sstevel@tonic-gate 			    netdev_path != NULL && netdev_path[0] != '\0') {
168*986fd29aSsetje 				get_netif_name(netdev_path, dhcifname);
1697c478bd9Sstevel@tonic-gate 			}
1707c478bd9Sstevel@tonic-gate 
171*986fd29aSsetje 			/*
172*986fd29aSsetje 			 * Form reply:
173*986fd29aSsetje 			 *  IFNAMESIZ array of dhcp i/f
174*986fd29aSsetje 			 *  hexascii representation of dhcp reply
175*986fd29aSsetje 			 */
176*986fd29aSsetje 			octlen = dhcacklen * 2 + 1;
177*986fd29aSsetje 			tlen = octlen + IFNAMSIZ;
178*986fd29aSsetje 			tmp = kmem_alloc(tlen, KM_SLEEP);
179*986fd29aSsetje 			(void) strncpy(tmp, dhcifname, IFNAMSIZ);
180*986fd29aSsetje 			if (octet_to_hexascii(dhcack, dhcacklen,
181*986fd29aSsetje 			    &tmp[IFNAMSIZ], &octlen) != 0) {
182*986fd29aSsetje 				kmem_free(tmp, tlen);
183*986fd29aSsetje 				error = EINVAL;
184*986fd29aSsetje 				break;
185*986fd29aSsetje 			} else {
186*986fd29aSsetje 				strcnt = IFNAMSIZ + octlen;
187*986fd29aSsetje 			}
1887c478bd9Sstevel@tonic-gate 		}
1897c478bd9Sstevel@tonic-gate 
190abddd56eScb117521 		if (count > 0) {
191abddd56eScb117521 			if (count <= strcnt) {
192abddd56eScb117521 				getcnt = count - 1;
193*986fd29aSsetje 				if (subyte((buf + getcnt), 0) < 0)
194*986fd29aSsetje 					goto fail;
195abddd56eScb117521 			} else {
196abddd56eScb117521 				getcnt = strcnt + 1;
197abddd56eScb117521 			}
198*986fd29aSsetje 			if (copyout(tmp, buf, getcnt))
199*986fd29aSsetje 				goto fail;
200*986fd29aSsetje 		}
201*986fd29aSsetje 		if (strcnt != 0)
202*986fd29aSsetje 			kmem_free(tmp, tlen);
203*986fd29aSsetje 		return (strcnt + 1);
204*986fd29aSsetje fail:
205*986fd29aSsetje 		if (strcnt != 0)
206*986fd29aSsetje 			kmem_free(tmp, tlen);
2077c478bd9Sstevel@tonic-gate 		error = EFAULT;
2087c478bd9Sstevel@tonic-gate 		break;
2097c478bd9Sstevel@tonic-gate 	}
2107c478bd9Sstevel@tonic-gate 
2117c478bd9Sstevel@tonic-gate 	case SI_SET_HOSTNAME:
2127c478bd9Sstevel@tonic-gate 	{
2137c478bd9Sstevel@tonic-gate 		size_t		len;
2147c478bd9Sstevel@tonic-gate 		char		name[SYS_NMLN];
2157c478bd9Sstevel@tonic-gate 		char		*name_to_use;
2167c478bd9Sstevel@tonic-gate 
2177c478bd9Sstevel@tonic-gate 		if ((error = secpolicy_systeminfo(CRED())) != 0)
2187c478bd9Sstevel@tonic-gate 			break;
2197c478bd9Sstevel@tonic-gate 
2207c478bd9Sstevel@tonic-gate 		name_to_use = uts_nodename();
2217c478bd9Sstevel@tonic-gate 		if ((error = copyinstr(buf, name, SYS_NMLN, &len)) != 0)
2227c478bd9Sstevel@tonic-gate 			break;
2237c478bd9Sstevel@tonic-gate 
2247c478bd9Sstevel@tonic-gate 		/*
2257c478bd9Sstevel@tonic-gate 		 * Must be non-NULL string and string
2267c478bd9Sstevel@tonic-gate 		 * must be less than SYS_NMLN chars.
2277c478bd9Sstevel@tonic-gate 		 */
2287c478bd9Sstevel@tonic-gate 		if (len < 2 || (len == SYS_NMLN && name[SYS_NMLN-1] != '\0')) {
2297c478bd9Sstevel@tonic-gate 			error = EINVAL;
2307c478bd9Sstevel@tonic-gate 			break;
2317c478bd9Sstevel@tonic-gate 		}
2327c478bd9Sstevel@tonic-gate 
2337c478bd9Sstevel@tonic-gate 		/*
2347c478bd9Sstevel@tonic-gate 		 * Copy the name into the relevant zone's nodename.
2357c478bd9Sstevel@tonic-gate 		 */
2367c478bd9Sstevel@tonic-gate 		(void) strcpy(name_to_use, name);
2377c478bd9Sstevel@tonic-gate 
2387c478bd9Sstevel@tonic-gate 		/*
2397c478bd9Sstevel@tonic-gate 		 * Notify other interested parties that the nodename was set
2407c478bd9Sstevel@tonic-gate 		 */
2417c478bd9Sstevel@tonic-gate 		if (name_to_use == utsname.nodename) /* global zone nodename */
2427c478bd9Sstevel@tonic-gate 			nodename_set();
2437c478bd9Sstevel@tonic-gate 
2447c478bd9Sstevel@tonic-gate 		return (len);
2457c478bd9Sstevel@tonic-gate 	}
2467c478bd9Sstevel@tonic-gate 
2477c478bd9Sstevel@tonic-gate 	case SI_SET_SRPC_DOMAIN:
2487c478bd9Sstevel@tonic-gate 	{
2497c478bd9Sstevel@tonic-gate 		char name[SYS_NMLN];
2507c478bd9Sstevel@tonic-gate 		size_t len;
2517c478bd9Sstevel@tonic-gate 
2527c478bd9Sstevel@tonic-gate 		if ((error = secpolicy_systeminfo(CRED())) != 0)
2537c478bd9Sstevel@tonic-gate 			break;
2547c478bd9Sstevel@tonic-gate 		if ((error = copyinstr(buf, name, SYS_NMLN, &len)) != 0)
2557c478bd9Sstevel@tonic-gate 			break;
2567c478bd9Sstevel@tonic-gate 		/*
2577c478bd9Sstevel@tonic-gate 		 * If string passed in is longer than length
2587c478bd9Sstevel@tonic-gate 		 * allowed for domain name, fail.
2597c478bd9Sstevel@tonic-gate 		 */
2607c478bd9Sstevel@tonic-gate 		if (len == SYS_NMLN && name[SYS_NMLN-1] != '\0') {
2617c478bd9Sstevel@tonic-gate 			error = EINVAL;
2627c478bd9Sstevel@tonic-gate 			break;
2637c478bd9Sstevel@tonic-gate 		}
2647c478bd9Sstevel@tonic-gate 
2657c478bd9Sstevel@tonic-gate 		(void) strcpy(curproc->p_zone->zone_domain, name);
2667c478bd9Sstevel@tonic-gate 		return (len);
2677c478bd9Sstevel@tonic-gate 	}
2687c478bd9Sstevel@tonic-gate 
2697c478bd9Sstevel@tonic-gate 	default:
2707c478bd9Sstevel@tonic-gate 		error = EINVAL;
2717c478bd9Sstevel@tonic-gate 		break;
2727c478bd9Sstevel@tonic-gate 	}
2737c478bd9Sstevel@tonic-gate 
2747c478bd9Sstevel@tonic-gate 	return (set_errno(error));
2757c478bd9Sstevel@tonic-gate }
2767c478bd9Sstevel@tonic-gate 
2777c478bd9Sstevel@tonic-gate /*
2787c478bd9Sstevel@tonic-gate  * i_path_find_node: Internal routine used by path_to_devinfo
2797c478bd9Sstevel@tonic-gate  * to locate a given nodeid in the device tree.
2807c478bd9Sstevel@tonic-gate  */
2817c478bd9Sstevel@tonic-gate struct i_path_findnode {
282fa9e4066Sahrens 	pnode_t nodeid;
2837c478bd9Sstevel@tonic-gate 	dev_info_t *dip;
2847c478bd9Sstevel@tonic-gate };
2857c478bd9Sstevel@tonic-gate 
2867c478bd9Sstevel@tonic-gate static int
2877c478bd9Sstevel@tonic-gate i_path_find_node(dev_info_t *dev, void *arg)
2887c478bd9Sstevel@tonic-gate {
2897c478bd9Sstevel@tonic-gate 	struct i_path_findnode *f = (struct i_path_findnode *)arg;
2907c478bd9Sstevel@tonic-gate 
2917c478bd9Sstevel@tonic-gate 
2927c478bd9Sstevel@tonic-gate 	if (ddi_get_nodeid(dev) == (int)f->nodeid) {
2937c478bd9Sstevel@tonic-gate 		f->dip = dev;
2947c478bd9Sstevel@tonic-gate 		return (DDI_WALK_TERMINATE);
2957c478bd9Sstevel@tonic-gate 	}
2967c478bd9Sstevel@tonic-gate 	return (DDI_WALK_CONTINUE);
2977c478bd9Sstevel@tonic-gate }
2987c478bd9Sstevel@tonic-gate 
2997c478bd9Sstevel@tonic-gate /*
3007c478bd9Sstevel@tonic-gate  * Return the devinfo node to a boot device
3017c478bd9Sstevel@tonic-gate  */
3027c478bd9Sstevel@tonic-gate static dev_info_t *
3037c478bd9Sstevel@tonic-gate path_to_devinfo(char *path)
3047c478bd9Sstevel@tonic-gate {
3057c478bd9Sstevel@tonic-gate 	struct i_path_findnode fn;
3067c478bd9Sstevel@tonic-gate 	extern dev_info_t *top_devinfo;
3077c478bd9Sstevel@tonic-gate 
3087c478bd9Sstevel@tonic-gate 	/*
3097c478bd9Sstevel@tonic-gate 	 * Get the nodeid of the given pathname, if such a mapping exists.
3107c478bd9Sstevel@tonic-gate 	 */
3117c478bd9Sstevel@tonic-gate 	fn.dip = NULL;
3127c478bd9Sstevel@tonic-gate 	fn.nodeid = prom_finddevice(path);
3137c478bd9Sstevel@tonic-gate 	if (fn.nodeid != OBP_BADNODE) {
3147c478bd9Sstevel@tonic-gate 		/*
3157c478bd9Sstevel@tonic-gate 		 * Find the nodeid in our copy of the device tree and return
3167c478bd9Sstevel@tonic-gate 		 * whatever name we used to bind this node to a driver.
3177c478bd9Sstevel@tonic-gate 		 */
3187c478bd9Sstevel@tonic-gate 		ddi_walk_devs(top_devinfo, i_path_find_node, (void *)(&fn));
3197c478bd9Sstevel@tonic-gate 	}
3207c478bd9Sstevel@tonic-gate 
3217c478bd9Sstevel@tonic-gate 	return (fn.dip);
3227c478bd9Sstevel@tonic-gate }
3237c478bd9Sstevel@tonic-gate 
3247c478bd9Sstevel@tonic-gate /*
3257c478bd9Sstevel@tonic-gate  * Determine the network interface name from the device path argument.
3267c478bd9Sstevel@tonic-gate  */
3277c478bd9Sstevel@tonic-gate static void
3287c478bd9Sstevel@tonic-gate get_netif_name(char *devname, char *ifname)
3297c478bd9Sstevel@tonic-gate {
3307c478bd9Sstevel@tonic-gate 	dev_info_t	*dip;
3317c478bd9Sstevel@tonic-gate 	major_t		ndev;
3327c478bd9Sstevel@tonic-gate 	char		*name;
3337c478bd9Sstevel@tonic-gate 	int		unit;
3347c478bd9Sstevel@tonic-gate 
3357c478bd9Sstevel@tonic-gate 	dip = path_to_devinfo(devname);
3367c478bd9Sstevel@tonic-gate 	if (dip == NULL) {
3377c478bd9Sstevel@tonic-gate 		cmn_err(CE_WARN, "get_netif_name: "
3387c478bd9Sstevel@tonic-gate 		    "can't bind driver for '%s'\n", devname);
3397c478bd9Sstevel@tonic-gate 		return;
3407c478bd9Sstevel@tonic-gate 	}
3417c478bd9Sstevel@tonic-gate 
3427c478bd9Sstevel@tonic-gate 	ndev = ddi_driver_major(dip);
3437c478bd9Sstevel@tonic-gate 	if (ndev == -1) {
3447c478bd9Sstevel@tonic-gate 		cmn_err(CE_WARN, "get_netif_name: "
3457c478bd9Sstevel@tonic-gate 		    "no driver bound to '%s'\n", devname);
3467c478bd9Sstevel@tonic-gate 		return;
3477c478bd9Sstevel@tonic-gate 	}
3487c478bd9Sstevel@tonic-gate 
3497c478bd9Sstevel@tonic-gate 	name = ddi_major_to_name(ndev);
3507c478bd9Sstevel@tonic-gate 	if (name == NULL) {
3517c478bd9Sstevel@tonic-gate 		cmn_err(CE_WARN, "get_netif_name: "
3527c478bd9Sstevel@tonic-gate 		    "no name for major number %d\n", ndev);
3537c478bd9Sstevel@tonic-gate 		return;
3547c478bd9Sstevel@tonic-gate 	}
3557c478bd9Sstevel@tonic-gate 
3567c478bd9Sstevel@tonic-gate 	unit = i_ddi_devi_get_ppa(dip);
3577c478bd9Sstevel@tonic-gate 	if (unit < 0) {
3587c478bd9Sstevel@tonic-gate 		cmn_err(CE_WARN, "get_netif_name: "
3597c478bd9Sstevel@tonic-gate 		    "illegal unit number %d\n", unit);
3607c478bd9Sstevel@tonic-gate 		return;
3617c478bd9Sstevel@tonic-gate 	}
3627c478bd9Sstevel@tonic-gate 
3637c478bd9Sstevel@tonic-gate 	(void) snprintf(ifname, IFNAMSIZ, "%s%d", name, unit);
3647c478bd9Sstevel@tonic-gate }
365