10Sstevel@tonic-gate /* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 52343Sseb * Common Development and Distribution License (the "License"). 62343Sseb * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 210Sstevel@tonic-gate /* 225895Syz147064 * Copyright 2008 Sun Microsystems, Inc. All rights reserved. 230Sstevel@tonic-gate * Use is subject to license terms. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 260Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 270Sstevel@tonic-gate 280Sstevel@tonic-gate #include <sys/param.h> 290Sstevel@tonic-gate #include <sys/types.h> 300Sstevel@tonic-gate #include <sys/user.h> 310Sstevel@tonic-gate #include <sys/vfs.h> 320Sstevel@tonic-gate #include <sys/vnode.h> 330Sstevel@tonic-gate #include <sys/file.h> 340Sstevel@tonic-gate #include <sys/stream.h> 350Sstevel@tonic-gate #include <sys/stropts.h> 360Sstevel@tonic-gate #include <sys/strsubr.h> 370Sstevel@tonic-gate #include <sys/dlpi.h> 380Sstevel@tonic-gate #include <sys/vnode.h> 390Sstevel@tonic-gate #include <sys/socket.h> 400Sstevel@tonic-gate #include <sys/sockio.h> 410Sstevel@tonic-gate #include <net/if.h> 420Sstevel@tonic-gate 430Sstevel@tonic-gate #include <sys/cred.h> 440Sstevel@tonic-gate #include <sys/sysmacros.h> 450Sstevel@tonic-gate 460Sstevel@tonic-gate #include <sys/sad.h> 470Sstevel@tonic-gate #include <sys/kstr.h> 480Sstevel@tonic-gate #include <sys/bootconf.h> 490Sstevel@tonic-gate #include <sys/bootprops.h> 500Sstevel@tonic-gate 510Sstevel@tonic-gate #include <sys/errno.h> 520Sstevel@tonic-gate #include <sys/modctl.h> 530Sstevel@tonic-gate #include <sys/sunddi.h> 540Sstevel@tonic-gate #include <sys/sunldi.h> 550Sstevel@tonic-gate #include <sys/esunddi.h> 560Sstevel@tonic-gate #include <sys/promif.h> 570Sstevel@tonic-gate 580Sstevel@tonic-gate #include <netinet/in.h> 590Sstevel@tonic-gate #include <netinet/ip6.h> 600Sstevel@tonic-gate #include <netinet/icmp6.h> 610Sstevel@tonic-gate #include <netinet/sctp.h> 620Sstevel@tonic-gate #include <inet/common.h> 630Sstevel@tonic-gate #include <inet/ip.h> 640Sstevel@tonic-gate #include <inet/ip6.h> 650Sstevel@tonic-gate #include <inet/tcp.h> 660Sstevel@tonic-gate #include <inet/sctp_ip.h> 670Sstevel@tonic-gate 680Sstevel@tonic-gate #include <sys/strlog.h> 690Sstevel@tonic-gate #include <sys/log.h> 700Sstevel@tonic-gate #include <sys/ethernet.h> 710Sstevel@tonic-gate #include <sys/ddi_implfuncs.h> 720Sstevel@tonic-gate 730Sstevel@tonic-gate #include <sys/dld.h> 74*5903Ssowmini #include <sys/mac.h> 750Sstevel@tonic-gate 760Sstevel@tonic-gate /* 770Sstevel@tonic-gate * Debug Macros 780Sstevel@tonic-gate */ 790Sstevel@tonic-gate int strplumbdebug = 0; 800Sstevel@tonic-gate 810Sstevel@tonic-gate #define DBG0(_f) \ 820Sstevel@tonic-gate if (strplumbdebug != 0) \ 830Sstevel@tonic-gate printf("strplumb: " _f) 840Sstevel@tonic-gate 850Sstevel@tonic-gate #define DBG1(_f, _a) \ 860Sstevel@tonic-gate if (strplumbdebug != 0) \ 870Sstevel@tonic-gate printf("strplumb: " _f, (_a)) 880Sstevel@tonic-gate 890Sstevel@tonic-gate #define DBG2(_f, _a, _b) \ 900Sstevel@tonic-gate if (strplumbdebug != 0) \ 910Sstevel@tonic-gate printf("strplumb: " _f, (_a), (_b)) 920Sstevel@tonic-gate 930Sstevel@tonic-gate #define DBG3(_f, _a, _b, _c) \ 940Sstevel@tonic-gate if (strplumbdebug != 0) \ 950Sstevel@tonic-gate printf("strplumb: " _f, (_a), (_b), (_c)) 960Sstevel@tonic-gate 970Sstevel@tonic-gate /* 980Sstevel@tonic-gate * Module linkage information for the kernel. 990Sstevel@tonic-gate */ 1005648Ssetje #define STRPLUMB_IDENT "STREAMS Plumbing Module" 1010Sstevel@tonic-gate 1020Sstevel@tonic-gate static struct modlmisc modlmisc = { 1030Sstevel@tonic-gate &mod_miscops, 1040Sstevel@tonic-gate STRPLUMB_IDENT 1050Sstevel@tonic-gate }; 1060Sstevel@tonic-gate 1070Sstevel@tonic-gate static struct modlinkage modlinkage = { 1080Sstevel@tonic-gate MODREV_1, 1090Sstevel@tonic-gate &modlmisc, 1100Sstevel@tonic-gate NULL 1110Sstevel@tonic-gate }; 1120Sstevel@tonic-gate 1130Sstevel@tonic-gate int 1140Sstevel@tonic-gate _init(void) 1150Sstevel@tonic-gate { 1160Sstevel@tonic-gate return (mod_install(&modlinkage)); 1170Sstevel@tonic-gate } 1180Sstevel@tonic-gate 1190Sstevel@tonic-gate int 1200Sstevel@tonic-gate _fini(void) 1210Sstevel@tonic-gate { 1220Sstevel@tonic-gate return (mod_remove(&modlinkage)); 1230Sstevel@tonic-gate } 1240Sstevel@tonic-gate 1250Sstevel@tonic-gate int 1260Sstevel@tonic-gate _info(struct modinfo *modinfop) 1270Sstevel@tonic-gate { 1280Sstevel@tonic-gate return (mod_info(&modlinkage, modinfop)); 1290Sstevel@tonic-gate } 1300Sstevel@tonic-gate 1310Sstevel@tonic-gate #define ARP "arp" 1320Sstevel@tonic-gate #define TCP "tcp" 1330Sstevel@tonic-gate #define TCP6 "tcp6" 1340Sstevel@tonic-gate #define UDP "udp" 1350Sstevel@tonic-gate #define UDP6 "udp6" 1360Sstevel@tonic-gate #define SCTP "sctp" 1370Sstevel@tonic-gate #define SCTP6 "sctp6" 1380Sstevel@tonic-gate #define ICMP "icmp" 1390Sstevel@tonic-gate #define ICMP6 "icmp6" 1400Sstevel@tonic-gate #define IP "ip" 1410Sstevel@tonic-gate #define IP6 "ip6" 1420Sstevel@tonic-gate #define TIMOD "timod" 1430Sstevel@tonic-gate 1440Sstevel@tonic-gate #define UDPDEV "/devices/pseudo/udp@0:udp" 1450Sstevel@tonic-gate #define TCP6DEV "/devices/pseudo/tcp6@0:tcp6" 1460Sstevel@tonic-gate #define SCTP6DEV "/devices/pseudo/sctp6@0:sctp6" 1470Sstevel@tonic-gate #define IP6DEV "/devices/pseudo/ip6@0:ip6" 1480Sstevel@tonic-gate 1490Sstevel@tonic-gate typedef struct strplumb_modspec { 1500Sstevel@tonic-gate char *sm_type; 1510Sstevel@tonic-gate char *sm_name; 1520Sstevel@tonic-gate } strplumb_modspec_t; 1530Sstevel@tonic-gate 1540Sstevel@tonic-gate static strplumb_modspec_t strplumb_modlist[] = { 1550Sstevel@tonic-gate { "drv", DLD_DRIVER_NAME }, 1560Sstevel@tonic-gate { "drv", IP }, 1570Sstevel@tonic-gate { "drv", IP6 }, 1580Sstevel@tonic-gate { "drv", TCP }, 1590Sstevel@tonic-gate { "drv", TCP6 }, 1600Sstevel@tonic-gate { "drv", UDP }, 1610Sstevel@tonic-gate { "drv", UDP6 }, 1620Sstevel@tonic-gate { "drv", SCTP }, 1630Sstevel@tonic-gate { "drv", SCTP6 }, 1640Sstevel@tonic-gate { "drv", ICMP }, 1650Sstevel@tonic-gate { "drv", ICMP6 }, 1660Sstevel@tonic-gate { "drv", ARP }, 1670Sstevel@tonic-gate { "strmod", TIMOD } 1680Sstevel@tonic-gate }; 1690Sstevel@tonic-gate 1700Sstevel@tonic-gate /* 1710Sstevel@tonic-gate * Called from swapgeneric.c:loadrootmodules() in the network boot case. 1720Sstevel@tonic-gate */ 1730Sstevel@tonic-gate int 1740Sstevel@tonic-gate strplumb_load(void) 1750Sstevel@tonic-gate { 1760Sstevel@tonic-gate uint_t i; 1770Sstevel@tonic-gate strplumb_modspec_t *p; 1780Sstevel@tonic-gate 1790Sstevel@tonic-gate DBG0("loading modules\n"); 1800Sstevel@tonic-gate 1810Sstevel@tonic-gate for (i = 0, p = strplumb_modlist; 1820Sstevel@tonic-gate i < sizeof (strplumb_modlist) / sizeof (strplumb_modlist[0]); 1830Sstevel@tonic-gate i++, p++) { 1840Sstevel@tonic-gate if (modloadonly(p->sm_type, p->sm_name) < 0) { 1850Sstevel@tonic-gate printf("strplumb: failed to load %s/%s\n", 1860Sstevel@tonic-gate p->sm_type, p->sm_name); 1870Sstevel@tonic-gate return (EFAULT); 1880Sstevel@tonic-gate } 1890Sstevel@tonic-gate } 1900Sstevel@tonic-gate 1910Sstevel@tonic-gate return (0); 1920Sstevel@tonic-gate } 1930Sstevel@tonic-gate 1940Sstevel@tonic-gate static int 1950Sstevel@tonic-gate strplumb_init(void) 1960Sstevel@tonic-gate { 1970Sstevel@tonic-gate uint_t i; 1980Sstevel@tonic-gate strplumb_modspec_t *p; 1990Sstevel@tonic-gate int err; 2000Sstevel@tonic-gate 2010Sstevel@tonic-gate DBG0("initializing modules\n"); 2020Sstevel@tonic-gate 2030Sstevel@tonic-gate for (i = 0, p = strplumb_modlist; 2040Sstevel@tonic-gate i < sizeof (strplumb_modlist) / sizeof (strplumb_modlist[0]); 2050Sstevel@tonic-gate i++, p++) { 2060Sstevel@tonic-gate if (strcmp(p->sm_type, "drv") == 0) 2070Sstevel@tonic-gate err = (i_ddi_attach_pseudo_node(p->sm_name) != NULL) ? 2080Sstevel@tonic-gate 0 : EFAULT; 2090Sstevel@tonic-gate else 2100Sstevel@tonic-gate err = (modload(p->sm_type, p->sm_name) < 0) ? 2110Sstevel@tonic-gate EFAULT : 0; 2120Sstevel@tonic-gate 2130Sstevel@tonic-gate if (err != 0) { 2140Sstevel@tonic-gate printf("strplumb: failed to initialize %s/%s\n", 2150Sstevel@tonic-gate p->sm_type, p->sm_name); 2160Sstevel@tonic-gate return (err); 2170Sstevel@tonic-gate } 2180Sstevel@tonic-gate } 2190Sstevel@tonic-gate 2200Sstevel@tonic-gate return (0); 2210Sstevel@tonic-gate } 2220Sstevel@tonic-gate 2230Sstevel@tonic-gate static int 2240Sstevel@tonic-gate strplumb_autopush(void) 2250Sstevel@tonic-gate { 2260Sstevel@tonic-gate major_t maj; 2270Sstevel@tonic-gate minor_t min; 2280Sstevel@tonic-gate char *mods[5]; 2290Sstevel@tonic-gate uint_t anchor = 1; 2300Sstevel@tonic-gate int err; 2310Sstevel@tonic-gate 2320Sstevel@tonic-gate min = (minor_t)-1; 2330Sstevel@tonic-gate mods[1] = NULL; 2340Sstevel@tonic-gate 2350Sstevel@tonic-gate /* 2360Sstevel@tonic-gate * ARP 2370Sstevel@tonic-gate */ 2380Sstevel@tonic-gate DBG0("setting up arp autopush\n"); 2390Sstevel@tonic-gate 2400Sstevel@tonic-gate mods[0] = ARP; 2410Sstevel@tonic-gate 2420Sstevel@tonic-gate maj = ddi_name_to_major(ARP); 2430Sstevel@tonic-gate if ((err = kstr_autopush(SET_AUTOPUSH, &maj, &min, NULL, &anchor, 2440Sstevel@tonic-gate mods)) != 0) { 2450Sstevel@tonic-gate printf("strplumb: kstr_autopush(SET/ARP) failed: %d\n", err); 2460Sstevel@tonic-gate return (err); 2470Sstevel@tonic-gate } 2480Sstevel@tonic-gate 2490Sstevel@tonic-gate return (0); 2500Sstevel@tonic-gate } 2510Sstevel@tonic-gate 2520Sstevel@tonic-gate static int 2530Sstevel@tonic-gate strplumb_sctpq(ldi_ident_t li) 2540Sstevel@tonic-gate { 2550Sstevel@tonic-gate ldi_handle_t lh = NULL; 2560Sstevel@tonic-gate int err; 2570Sstevel@tonic-gate int rval; 2580Sstevel@tonic-gate 2590Sstevel@tonic-gate DBG0("configuring SCTP default queue\n"); 2600Sstevel@tonic-gate 2610Sstevel@tonic-gate if ((err = ldi_open_by_name(SCTP6DEV, FREAD|FWRITE, CRED(), &lh, 2620Sstevel@tonic-gate li)) != 0) { 2630Sstevel@tonic-gate printf("strplumb: open of SCTP6DEV failed: %d\n", err); 2640Sstevel@tonic-gate return (err); 2650Sstevel@tonic-gate } 2660Sstevel@tonic-gate 2670Sstevel@tonic-gate if ((err = ldi_ioctl(lh, SCTP_IOC_DEFAULT_Q, (intptr_t)0, FKIOCTL, 2680Sstevel@tonic-gate CRED(), &rval)) != 0) { 2690Sstevel@tonic-gate printf("strplumb: failed to set SCTP default queue: %d\n", 2700Sstevel@tonic-gate err); 2710Sstevel@tonic-gate (void) ldi_close(lh, FREAD|FWRITE, CRED()); 2720Sstevel@tonic-gate return (err); 2730Sstevel@tonic-gate } 2740Sstevel@tonic-gate 2750Sstevel@tonic-gate return (0); 2760Sstevel@tonic-gate } 2770Sstevel@tonic-gate 2780Sstevel@tonic-gate static int 2790Sstevel@tonic-gate strplumb_tcpq(ldi_ident_t li) 2800Sstevel@tonic-gate { 2810Sstevel@tonic-gate ldi_handle_t lh = NULL; 2820Sstevel@tonic-gate ldi_handle_t ip_lh = NULL; 2830Sstevel@tonic-gate int err; 2840Sstevel@tonic-gate int rval; 2850Sstevel@tonic-gate 2860Sstevel@tonic-gate DBG0("configuring TCP default queue\n"); 2870Sstevel@tonic-gate 2880Sstevel@tonic-gate /* 2890Sstevel@tonic-gate * We open IP6DEV here because we need to have it open to in 2900Sstevel@tonic-gate * order to open TCP6DEV successfully. 2910Sstevel@tonic-gate */ 2920Sstevel@tonic-gate if ((err = ldi_open_by_name(IP6DEV, FREAD|FWRITE, CRED(), &ip_lh, 2930Sstevel@tonic-gate li)) != 0) { 2940Sstevel@tonic-gate printf("strplumb: open of IP6DEV failed: %d\n", err); 2950Sstevel@tonic-gate return (err); 2960Sstevel@tonic-gate } 2970Sstevel@tonic-gate 2980Sstevel@tonic-gate /* 2990Sstevel@tonic-gate * We set the tcp default queue to IPv6 because IPv4 falls back to 3000Sstevel@tonic-gate * IPv6 when it can't find a client, but IPv6 does not fall back to 3010Sstevel@tonic-gate * IPv4. 3020Sstevel@tonic-gate */ 3030Sstevel@tonic-gate if ((err = ldi_open_by_name(TCP6DEV, FREAD|FWRITE, CRED(), &lh, 3040Sstevel@tonic-gate li)) != 0) { 3050Sstevel@tonic-gate printf("strplumb: open of TCP6DEV failed: %d\n", err); 3060Sstevel@tonic-gate goto done; 3070Sstevel@tonic-gate } 3080Sstevel@tonic-gate 3090Sstevel@tonic-gate if ((err = ldi_ioctl(lh, TCP_IOC_DEFAULT_Q, (intptr_t)0, FKIOCTL, 3100Sstevel@tonic-gate CRED(), &rval)) != 0) { 3110Sstevel@tonic-gate printf("strplumb: failed to set TCP default queue: %d\n", 3120Sstevel@tonic-gate err); 3130Sstevel@tonic-gate goto done; 3140Sstevel@tonic-gate } 3150Sstevel@tonic-gate 3160Sstevel@tonic-gate done: 3170Sstevel@tonic-gate (void) ldi_close(ip_lh, FREAD|FWRITE, CRED()); 3180Sstevel@tonic-gate return (err); 3190Sstevel@tonic-gate } 3200Sstevel@tonic-gate 3210Sstevel@tonic-gate /* 3220Sstevel@tonic-gate * Can be set in /etc/system in the case of local booting. See comment below. 3230Sstevel@tonic-gate */ 3240Sstevel@tonic-gate char *ndev_name = 0; 3250Sstevel@tonic-gate int ndev_unit = 0; 3260Sstevel@tonic-gate 3270Sstevel@tonic-gate /* 3280Sstevel@tonic-gate * If we booted diskless then strplumb() will have been called from 3290Sstevel@tonic-gate * swapgeneric.c:rootconf(). All we can do in that case is plumb the 3300Sstevel@tonic-gate * network device that we booted from. 3310Sstevel@tonic-gate * 3320Sstevel@tonic-gate * If we booted from a local disk, we will have been called from main(), 3330Sstevel@tonic-gate * and normally we defer the plumbing of interfaces until network/physical. 3340Sstevel@tonic-gate * This can be overridden by setting "ndev_name" in /etc/system. 3350Sstevel@tonic-gate */ 3360Sstevel@tonic-gate static int 337269Sericheng resolve_boot_path(void) 3380Sstevel@tonic-gate { 3395710Ssetje char *devpath; 3400Sstevel@tonic-gate dev_info_t *dip; 3410Sstevel@tonic-gate const char *driver; 3420Sstevel@tonic-gate int instance; 3435648Ssetje #ifdef _OBP 3445648Ssetje char stripped_path[OBP_MAXPATHLEN]; 3455648Ssetje #endif 3460Sstevel@tonic-gate 3470Sstevel@tonic-gate if (strncmp(rootfs.bo_fstype, "nfs", 3) == 0) 3480Sstevel@tonic-gate devpath = rootfs.bo_name; 3490Sstevel@tonic-gate else 3500Sstevel@tonic-gate devpath = strplumb_get_netdev_path(); 3510Sstevel@tonic-gate 3520Sstevel@tonic-gate if (devpath != NULL) { 3530Sstevel@tonic-gate DBG1("resolving boot-path: %s\n", devpath); 3545710Ssetje #ifdef _OBP 3555710Ssetje /* 3565710Ssetje * OBP passes options e.g, "net:dhcp" 3575710Ssetje * remove them here 3585710Ssetje */ 3595710Ssetje prom_strip_options(devpath, stripped_path); 3605710Ssetje devpath = stripped_path; 3615710Ssetje #endif 3620Sstevel@tonic-gate /* 3630Sstevel@tonic-gate * Hold the devi since this is the root device. 3640Sstevel@tonic-gate */ 3650Sstevel@tonic-gate if ((dip = e_ddi_hold_devi_by_path(devpath, 0)) == NULL) { 3660Sstevel@tonic-gate printf("strplumb: unable to hold root device: %s\n", 3670Sstevel@tonic-gate devpath); 3680Sstevel@tonic-gate return (ENXIO); 3690Sstevel@tonic-gate } 3700Sstevel@tonic-gate 3710Sstevel@tonic-gate driver = ddi_driver_name(dip); 3720Sstevel@tonic-gate instance = ddi_get_instance(dip); 3730Sstevel@tonic-gate } else { 3740Sstevel@tonic-gate if (ndev_name == NULL) 3750Sstevel@tonic-gate return (ENODEV); 3760Sstevel@tonic-gate 3770Sstevel@tonic-gate DBG2("using ndev_name (%s) ndev_unit (%d)\n", ndev_name, 3780Sstevel@tonic-gate ndev_unit); 3790Sstevel@tonic-gate 3800Sstevel@tonic-gate if (i_ddi_attach_hw_nodes(ndev_name) != DDI_SUCCESS) { 3810Sstevel@tonic-gate printf("strplumb: cannot load ndev_name '%s'\n", 3820Sstevel@tonic-gate ndev_name); 3830Sstevel@tonic-gate return (ENXIO); 3840Sstevel@tonic-gate } 3850Sstevel@tonic-gate 3860Sstevel@tonic-gate driver = ndev_name; 3870Sstevel@tonic-gate instance = ndev_unit; 3880Sstevel@tonic-gate } 3890Sstevel@tonic-gate 3900Sstevel@tonic-gate (void) snprintf(rootfs.bo_devname, BO_MAXOBJNAME, 391269Sericheng "/devices/pseudo/clone@0:%s", driver); 3920Sstevel@tonic-gate (void) snprintf(rootfs.bo_ifname, BO_MAXOBJNAME, "%s%d", 3930Sstevel@tonic-gate driver, instance); 3940Sstevel@tonic-gate rootfs.bo_ppa = instance; 395269Sericheng return (0); 3960Sstevel@tonic-gate } 3970Sstevel@tonic-gate 3980Sstevel@tonic-gate static int 3990Sstevel@tonic-gate getifflags(ldi_handle_t lh, struct lifreq *lifrp) 4000Sstevel@tonic-gate { 4010Sstevel@tonic-gate struct strioctl iocb; 4020Sstevel@tonic-gate int rval; 4030Sstevel@tonic-gate 4040Sstevel@tonic-gate iocb.ic_cmd = SIOCGLIFFLAGS; 4050Sstevel@tonic-gate iocb.ic_timout = 15; 4060Sstevel@tonic-gate iocb.ic_len = sizeof (struct lifreq); 4070Sstevel@tonic-gate iocb.ic_dp = (char *)lifrp; 4080Sstevel@tonic-gate 4090Sstevel@tonic-gate return (ldi_ioctl(lh, I_STR, (intptr_t)&iocb, FKIOCTL, CRED(), &rval)); 4100Sstevel@tonic-gate 4110Sstevel@tonic-gate } 4120Sstevel@tonic-gate 4130Sstevel@tonic-gate static int 4140Sstevel@tonic-gate setifname(ldi_handle_t lh, struct lifreq *lifrp) 4150Sstevel@tonic-gate { 4160Sstevel@tonic-gate struct strioctl iocb; 4170Sstevel@tonic-gate int rval; 4180Sstevel@tonic-gate 4190Sstevel@tonic-gate iocb.ic_cmd = SIOCSLIFNAME; 4200Sstevel@tonic-gate iocb.ic_timout = 15; 4210Sstevel@tonic-gate iocb.ic_len = sizeof (struct lifreq); 4220Sstevel@tonic-gate iocb.ic_dp = (char *)lifrp; 4230Sstevel@tonic-gate 4240Sstevel@tonic-gate return (ldi_ioctl(lh, I_STR, (intptr_t)&iocb, FKIOCTL, CRED(), &rval)); 4250Sstevel@tonic-gate } 4260Sstevel@tonic-gate 4270Sstevel@tonic-gate static int 4280Sstevel@tonic-gate strplumb_dev(ldi_ident_t li) 4290Sstevel@tonic-gate { 4300Sstevel@tonic-gate ldi_handle_t lh = NULL; 4310Sstevel@tonic-gate ldi_handle_t mux_lh = NULL; 4320Sstevel@tonic-gate int err; 4330Sstevel@tonic-gate struct lifreq lifr; 4340Sstevel@tonic-gate struct ifreq ifr; 4350Sstevel@tonic-gate int rval; 4360Sstevel@tonic-gate 4370Sstevel@tonic-gate bzero(&lifr, sizeof (struct lifreq)); 4380Sstevel@tonic-gate bzero(&ifr, sizeof (ifr)); 4390Sstevel@tonic-gate 4400Sstevel@tonic-gate /* 4410Sstevel@tonic-gate * Now set up the links. Ultimately, we should have two streams 4420Sstevel@tonic-gate * permanently linked underneath UDP (which is actually IP with UDP 4430Sstevel@tonic-gate * autopushed). One stream consists of the ARP-[ifname] combination, 4440Sstevel@tonic-gate * while the other consists of ARP-IP-[ifname]. The second combination 4450Sstevel@tonic-gate * seems a little weird, but is linked underneath UDP just to keep it 4460Sstevel@tonic-gate * around. 4470Sstevel@tonic-gate * 4480Sstevel@tonic-gate * We pin underneath UDP here to match what is done in ifconfig(1m); 4490Sstevel@tonic-gate * otherwise, ifconfig will be unable to unplumb the stream (the major 4500Sstevel@tonic-gate * number and mux id must both match for a successful I_PUNLINK). 4510Sstevel@tonic-gate * 4520Sstevel@tonic-gate * There are subtleties in the plumbing which make it essential to 4530Sstevel@tonic-gate * follow the logic used in ifconfig(1m) very closely. 4540Sstevel@tonic-gate */ 4550Sstevel@tonic-gate 4560Sstevel@tonic-gate /* 4570Sstevel@tonic-gate * Plumb UDP-ARP-IP-<dev> 4580Sstevel@tonic-gate */ 4590Sstevel@tonic-gate 4600Sstevel@tonic-gate if ((err = ldi_open_by_name(rootfs.bo_devname, FREAD|FWRITE, CRED(), 4610Sstevel@tonic-gate &lh, li)) != 0) { 4620Sstevel@tonic-gate printf("strplumb: open %s failed: %d\n", rootfs.bo_devname, 4630Sstevel@tonic-gate err); 4640Sstevel@tonic-gate goto done; 4650Sstevel@tonic-gate } 4660Sstevel@tonic-gate 4670Sstevel@tonic-gate 4680Sstevel@tonic-gate if ((err = ldi_ioctl(lh, I_PUSH, (intptr_t)IP, FKIOCTL, CRED(), 4690Sstevel@tonic-gate &rval)) != 0) { 4700Sstevel@tonic-gate printf("strplumb: push IP failed: %d\n", err); 4710Sstevel@tonic-gate goto done; 4720Sstevel@tonic-gate } 4730Sstevel@tonic-gate 4740Sstevel@tonic-gate if ((err = getifflags(lh, &lifr)) != 0) 4750Sstevel@tonic-gate goto done; 4760Sstevel@tonic-gate 4770Sstevel@tonic-gate lifr.lifr_flags |= IFF_IPV4; 4780Sstevel@tonic-gate lifr.lifr_flags &= ~IFF_IPV6; 4790Sstevel@tonic-gate 4800Sstevel@tonic-gate if ((err = ldi_ioctl(lh, I_PUSH, (intptr_t)ARP, FKIOCTL, CRED(), 4810Sstevel@tonic-gate &rval)) != 0) { 4820Sstevel@tonic-gate printf("strplumb: push ARP failed: %d\n", err); 4830Sstevel@tonic-gate goto done; 4840Sstevel@tonic-gate } 4850Sstevel@tonic-gate 4860Sstevel@tonic-gate (void) strlcpy(lifr.lifr_name, rootfs.bo_ifname, 4870Sstevel@tonic-gate sizeof (lifr.lifr_name)); 4880Sstevel@tonic-gate lifr.lifr_ppa = rootfs.bo_ppa; 4890Sstevel@tonic-gate 4900Sstevel@tonic-gate if ((err = setifname(lh, &lifr)) != 0) 4910Sstevel@tonic-gate goto done; 4920Sstevel@tonic-gate 4930Sstevel@tonic-gate /* Get the flags and check if ARP is needed */ 4940Sstevel@tonic-gate if ((err = getifflags(lh, &lifr)) != 0) { 4950Sstevel@tonic-gate printf("strplumb: getifflags %s IP failed, error %d\n", 4960Sstevel@tonic-gate lifr.lifr_name, err); 4970Sstevel@tonic-gate goto done; 4980Sstevel@tonic-gate } 4990Sstevel@tonic-gate 5000Sstevel@tonic-gate /* Pop out ARP if not needed */ 5010Sstevel@tonic-gate if (lifr.lifr_flags & IFF_NOARP) { 5020Sstevel@tonic-gate err = ldi_ioctl(lh, I_POP, (intptr_t)0, FKIOCTL, CRED(), 5030Sstevel@tonic-gate &rval); 5040Sstevel@tonic-gate if (err != 0) { 5050Sstevel@tonic-gate printf("strplumb: pop ARP failed, error %d\n", err); 5060Sstevel@tonic-gate goto done; 5070Sstevel@tonic-gate } 5080Sstevel@tonic-gate } 5090Sstevel@tonic-gate 5100Sstevel@tonic-gate if ((err = ldi_open_by_name(UDPDEV, FREAD|FWRITE, CRED(), &mux_lh, 5110Sstevel@tonic-gate li)) != 0) { 5120Sstevel@tonic-gate printf("strplumb: open of UDPDEV failed: %d\n", err); 5130Sstevel@tonic-gate goto done; 5140Sstevel@tonic-gate } 5150Sstevel@tonic-gate 5160Sstevel@tonic-gate if ((err = ldi_ioctl(mux_lh, I_PLINK, (intptr_t)lh, 5170Sstevel@tonic-gate FREAD|FWRITE|FNOCTTY|FKIOCTL, CRED(), 5180Sstevel@tonic-gate &(ifr.ifr_ip_muxid))) != 0) { 5190Sstevel@tonic-gate printf("strplumb: plink UDP-ARP-IP-%s failed: %d\n", 5200Sstevel@tonic-gate rootfs.bo_ifname, err); 5210Sstevel@tonic-gate goto done; 5220Sstevel@tonic-gate } 5230Sstevel@tonic-gate 5240Sstevel@tonic-gate DBG2("UDP-ARP-IP-%s muxid: %d\n", rootfs.bo_ifname, ifr.ifr_ip_muxid); 5250Sstevel@tonic-gate 5260Sstevel@tonic-gate (void) ldi_close(lh, FREAD|FWRITE, CRED()); 5270Sstevel@tonic-gate lh = NULL; 5280Sstevel@tonic-gate 5290Sstevel@tonic-gate /* 5300Sstevel@tonic-gate * Plumb UDP-ARP-<dev> 5310Sstevel@tonic-gate */ 5320Sstevel@tonic-gate 5330Sstevel@tonic-gate if ((err = ldi_open_by_name(rootfs.bo_devname, FREAD|FWRITE, CRED(), 5340Sstevel@tonic-gate &lh, li)) != 0) { 5350Sstevel@tonic-gate printf("strplumb: open %s failed: %d\n", rootfs.bo_devname, 5360Sstevel@tonic-gate err); 5370Sstevel@tonic-gate goto done; 5380Sstevel@tonic-gate } 5390Sstevel@tonic-gate 5400Sstevel@tonic-gate if ((err = ldi_ioctl(lh, I_PUSH, (intptr_t)ARP, FKIOCTL, CRED(), 5410Sstevel@tonic-gate &rval)) != 0) { 5420Sstevel@tonic-gate printf("strplumb: push ARP failed: %d\n", err); 5430Sstevel@tonic-gate goto done; 5440Sstevel@tonic-gate } 5450Sstevel@tonic-gate 5460Sstevel@tonic-gate if ((err = setifname(lh, &lifr)) != 0) 5470Sstevel@tonic-gate goto done; 5480Sstevel@tonic-gate 5490Sstevel@tonic-gate if ((err = ldi_ioctl(mux_lh, I_PLINK, (intptr_t)lh, 5500Sstevel@tonic-gate FREAD|FWRITE|FNOCTTY|FKIOCTL, CRED(), 5510Sstevel@tonic-gate &(ifr.ifr_arp_muxid))) != 0) { 5520Sstevel@tonic-gate printf("strplumb: plink UDP-ARP-%s failed: %d\n", 5530Sstevel@tonic-gate rootfs.bo_ifname, err); 5540Sstevel@tonic-gate goto done; 5550Sstevel@tonic-gate } 5560Sstevel@tonic-gate 5570Sstevel@tonic-gate DBG2("UDP-ARP-%s muxid: %d\n", rootfs.bo_ifname, ifr.ifr_arp_muxid); 5580Sstevel@tonic-gate 5590Sstevel@tonic-gate /* 5600Sstevel@tonic-gate * Cache the mux ids. 5610Sstevel@tonic-gate */ 5620Sstevel@tonic-gate (void) strlcpy(ifr.ifr_name, rootfs.bo_ifname, sizeof (ifr.ifr_name)); 5630Sstevel@tonic-gate 5640Sstevel@tonic-gate if ((err = ldi_ioctl(mux_lh, SIOCSIFMUXID, (intptr_t)&ifr, FKIOCTL, 5650Sstevel@tonic-gate CRED(), &rval)) != 0) { 5660Sstevel@tonic-gate printf("strplumb: SIOCSIFMUXID failed: %d\n", err); 5670Sstevel@tonic-gate goto done; 5680Sstevel@tonic-gate } 5690Sstevel@tonic-gate 5700Sstevel@tonic-gate done: 5710Sstevel@tonic-gate if (lh != NULL) 5720Sstevel@tonic-gate (void) ldi_close(lh, FREAD|FWRITE, CRED()); 5730Sstevel@tonic-gate 5740Sstevel@tonic-gate if (mux_lh != NULL) 5750Sstevel@tonic-gate (void) ldi_close(mux_lh, FREAD|FWRITE, CRED()); 5760Sstevel@tonic-gate 5770Sstevel@tonic-gate return (err); 5780Sstevel@tonic-gate } 5790Sstevel@tonic-gate 5800Sstevel@tonic-gate /* 5810Sstevel@tonic-gate * Do streams plumbing for internet protocols. 5820Sstevel@tonic-gate */ 5830Sstevel@tonic-gate int 5840Sstevel@tonic-gate strplumb(void) 5850Sstevel@tonic-gate { 5860Sstevel@tonic-gate ldi_ident_t li; 5870Sstevel@tonic-gate int err; 5880Sstevel@tonic-gate 5890Sstevel@tonic-gate if ((err = strplumb_init()) != 0) 5900Sstevel@tonic-gate return (err); 5910Sstevel@tonic-gate 5920Sstevel@tonic-gate if ((err = strplumb_autopush()) != 0) 5930Sstevel@tonic-gate return (err); 5940Sstevel@tonic-gate 5950Sstevel@tonic-gate if ((err = ldi_ident_from_mod(&modlinkage, &li)) != 0) 5960Sstevel@tonic-gate return (err); 5970Sstevel@tonic-gate 5983448Sdh155122 /* 5993448Sdh155122 * Setup the TCP and SCTP default queues for the global stack. 6003448Sdh155122 * tcp/sctp_stack_init will do this for additional stack instances. 6013448Sdh155122 */ 6020Sstevel@tonic-gate if ((err = strplumb_sctpq(li)) != 0) 6030Sstevel@tonic-gate goto done; 6040Sstevel@tonic-gate 6050Sstevel@tonic-gate if ((err = strplumb_tcpq(li)) != 0) 6060Sstevel@tonic-gate goto done; 6070Sstevel@tonic-gate 608269Sericheng if ((err = resolve_boot_path()) != 0) 6090Sstevel@tonic-gate goto done; 6100Sstevel@tonic-gate 6110Sstevel@tonic-gate DBG1("rootfs.bo_devname: %s\n", rootfs.bo_devname); 6120Sstevel@tonic-gate DBG1("rootfs.bo_ifname: %s\n", rootfs.bo_ifname); 6130Sstevel@tonic-gate DBG1("rootfs.bo_ppa: %d\n", rootfs.bo_ppa); 6140Sstevel@tonic-gate 6150Sstevel@tonic-gate if ((err = strplumb_dev(li)) != 0) 6160Sstevel@tonic-gate goto done; 6170Sstevel@tonic-gate 6180Sstevel@tonic-gate done: 6190Sstevel@tonic-gate ldi_ident_release(li); 6200Sstevel@tonic-gate 6210Sstevel@tonic-gate return (err); 6220Sstevel@tonic-gate } 6230Sstevel@tonic-gate 6240Sstevel@tonic-gate /* multiboot: diskless boot interface discovery */ 6250Sstevel@tonic-gate 6265648Ssetje #ifndef _OBP 6270Sstevel@tonic-gate 6280Sstevel@tonic-gate static uchar_t boot_macaddr[16]; 6290Sstevel@tonic-gate static int boot_maclen; 6305895Syz147064 static uchar_t *getmacaddr(dev_info_t *dip, size_t *maclenp); 6310Sstevel@tonic-gate static int matchmac(dev_info_t *dip, void *arg); 6320Sstevel@tonic-gate 6335648Ssetje #endif /* !_OBP */ 6344172Ssetje 6350Sstevel@tonic-gate char * 6360Sstevel@tonic-gate strplumb_get_netdev_path(void) 6370Sstevel@tonic-gate { 6385710Ssetje #ifdef _OBP 6395710Ssetje char fstype[OBP_MAXPROPNAME]; 6405710Ssetje 6415710Ssetje if (bop_getprop("fstype", fstype) == -1) 6425710Ssetje return (NULL); 6435710Ssetje 6445710Ssetje if (strncmp(fstype, "nfs", 3) == 0) 6455710Ssetje return (prom_bootpath()); 6465710Ssetje else 6475710Ssetje return (NULL); 6485710Ssetje #else 6495710Ssetje 6500Sstevel@tonic-gate char *macstr, *devpath = NULL; 6510Sstevel@tonic-gate uchar_t *bootp; 6525648Ssetje uint_t bootp_len; 6530Sstevel@tonic-gate 6540Sstevel@tonic-gate if (ddi_prop_lookup_string(DDI_DEV_T_ANY, ddi_root_node(), 6550Sstevel@tonic-gate DDI_PROP_DONTPASS, BP_BOOT_MAC, &macstr) == DDI_SUCCESS) { 6560Sstevel@tonic-gate /* 6570Sstevel@tonic-gate * hard coded ether mac len for booting floppy on 6580Sstevel@tonic-gate * machines with old cards 6590Sstevel@tonic-gate */ 6600Sstevel@tonic-gate boot_maclen = ether_aton(macstr, boot_macaddr); 6610Sstevel@tonic-gate if (boot_maclen != 6) { 6620Sstevel@tonic-gate cmn_err(CE_WARN, 6630Sstevel@tonic-gate "malformed boot_mac property, %d bytes", 6640Sstevel@tonic-gate boot_maclen); 6650Sstevel@tonic-gate } 6660Sstevel@tonic-gate ddi_prop_free(macstr); 6670Sstevel@tonic-gate } else if (ddi_prop_lookup_byte_array(DDI_DEV_T_ANY, ddi_root_node(), 6680Sstevel@tonic-gate DDI_PROP_DONTPASS, BP_BOOTP_RESPONSE, &bootp, &bootp_len) 6690Sstevel@tonic-gate == DDI_SUCCESS) { 6700Sstevel@tonic-gate 6710Sstevel@tonic-gate /* 6720Sstevel@tonic-gate * These offsets are defined by dhcp standard 6730Sstevel@tonic-gate * Should use structure offsets 6740Sstevel@tonic-gate */ 6750Sstevel@tonic-gate boot_maclen = *(bootp + 2); 6760Sstevel@tonic-gate ASSERT(boot_maclen <= 16); 6775648Ssetje bcopy(bootp + 28, boot_macaddr, boot_maclen); 6780Sstevel@tonic-gate 6795648Ssetje dhcack = kmem_alloc(bootp_len, KM_SLEEP); 6805648Ssetje bcopy(bootp, dhcack, bootp_len); 6815648Ssetje dhcacklen = bootp_len; 6825648Ssetje 6830Sstevel@tonic-gate ddi_prop_free(bootp); 6840Sstevel@tonic-gate } else 6850Sstevel@tonic-gate return (NULL); 6860Sstevel@tonic-gate 6870Sstevel@tonic-gate ddi_walk_devs(ddi_root_node(), matchmac, (void *)&devpath); 6880Sstevel@tonic-gate return (devpath); 6894172Ssetje 6905710Ssetje #endif /* _OBP */ 6910Sstevel@tonic-gate } 6920Sstevel@tonic-gate 6935648Ssetje #ifndef _OBP 6944172Ssetje 6950Sstevel@tonic-gate /* 6960Sstevel@tonic-gate * Get boot path from the boot_mac address 6970Sstevel@tonic-gate */ 6980Sstevel@tonic-gate /*ARGSUSED*/ 6990Sstevel@tonic-gate static int 7000Sstevel@tonic-gate matchmac(dev_info_t *dip, void *arg) 7010Sstevel@tonic-gate { 7020Sstevel@tonic-gate char **devpathp = (char **)arg; 7030Sstevel@tonic-gate char *model_str; 7040Sstevel@tonic-gate uchar_t *macaddr; 7055895Syz147064 size_t maclen; 7060Sstevel@tonic-gate 7070Sstevel@tonic-gate /* XXX Should use "device-type" per IEEE 1275 */ 7080Sstevel@tonic-gate if (ddi_prop_lookup_string(DDI_DEV_T_ANY, dip, 0, 7090Sstevel@tonic-gate "model", &model_str) != DDI_SUCCESS) 7100Sstevel@tonic-gate return (DDI_WALK_CONTINUE); 7110Sstevel@tonic-gate 7120Sstevel@tonic-gate if (strcmp(model_str, "Ethernet controller") != 0) { 7130Sstevel@tonic-gate ddi_prop_free(model_str); 7140Sstevel@tonic-gate return (DDI_WALK_CONTINUE); 7150Sstevel@tonic-gate } 7160Sstevel@tonic-gate ddi_prop_free(model_str); 7170Sstevel@tonic-gate 7180Sstevel@tonic-gate /* We have a network device now */ 7190Sstevel@tonic-gate if (i_ddi_attach_node_hierarchy(dip) != DDI_SUCCESS) { 7200Sstevel@tonic-gate return (DDI_WALK_CONTINUE); 7210Sstevel@tonic-gate } 7220Sstevel@tonic-gate 7230Sstevel@tonic-gate ASSERT(boot_maclen != 0); 7240Sstevel@tonic-gate macaddr = getmacaddr(dip, &maclen); 7250Sstevel@tonic-gate if (macaddr == NULL) 7260Sstevel@tonic-gate return (DDI_WALK_CONTINUE); 7270Sstevel@tonic-gate 7280Sstevel@tonic-gate if (maclen != boot_maclen || 7290Sstevel@tonic-gate bcmp(macaddr, boot_macaddr, maclen) != 0) { 7300Sstevel@tonic-gate kmem_free(macaddr, maclen); 7310Sstevel@tonic-gate return (DDI_WALK_CONTINUE); 7320Sstevel@tonic-gate } 7330Sstevel@tonic-gate 7340Sstevel@tonic-gate /* found hardware with the mac address */ 7350Sstevel@tonic-gate (void) localetheraddr((struct ether_addr *)macaddr, NULL); 7360Sstevel@tonic-gate kmem_free(macaddr, maclen); 7370Sstevel@tonic-gate 7380Sstevel@tonic-gate *devpathp = kmem_alloc(MAXPATHLEN, KM_SLEEP); 7390Sstevel@tonic-gate (void) ddi_pathname(dip, *devpathp); 7400Sstevel@tonic-gate 7415648Ssetje /* fill in dhcifname */ 7425648Ssetje if (dhcack) { 7435648Ssetje (void) snprintf(dhcifname, IFNAMSIZ, "%s%d", 7440Sstevel@tonic-gate ddi_driver_name(dip), i_ddi_devi_get_ppa(dip)); 7455648Ssetje } 7460Sstevel@tonic-gate return (DDI_WALK_TERMINATE); 7470Sstevel@tonic-gate } 7480Sstevel@tonic-gate 7490Sstevel@tonic-gate static uchar_t * 7505895Syz147064 getmacaddr(dev_info_t *dip, size_t *maclenp) 7510Sstevel@tonic-gate { 7520Sstevel@tonic-gate int rc, ppa; 7530Sstevel@tonic-gate ldi_ident_t li; 7540Sstevel@tonic-gate ldi_handle_t lh; 7555895Syz147064 const char *drv_name = ddi_driver_name(dip); 7560Sstevel@tonic-gate char *clonepath; 7570Sstevel@tonic-gate uchar_t *macaddr = NULL; 7580Sstevel@tonic-gate 7590Sstevel@tonic-gate if (rc = ldi_ident_from_mod(&modlinkage, &li)) { 7600Sstevel@tonic-gate cmn_err(CE_WARN, 7610Sstevel@tonic-gate "getmacaddr: ldi_ident_from_mod failed: %d\n", rc); 7620Sstevel@tonic-gate return (NULL); 7630Sstevel@tonic-gate } 7640Sstevel@tonic-gate 7650Sstevel@tonic-gate clonepath = kmem_alloc(MAXPATHLEN, KM_SLEEP); 7660Sstevel@tonic-gate (void) snprintf(clonepath, MAXPATHLEN, 7670Sstevel@tonic-gate "/devices/pseudo/clone@0:%s", drv_name); 7680Sstevel@tonic-gate 7690Sstevel@tonic-gate rc = ldi_open_by_name(clonepath, FREAD|FWRITE, CRED(), &lh, li); 7700Sstevel@tonic-gate ldi_ident_release(li); 7710Sstevel@tonic-gate if (rc) { 7720Sstevel@tonic-gate cmn_err(CE_WARN, 7730Sstevel@tonic-gate "getmacaddr: ldi_open_by_name(%s) failed: %d\n", 7740Sstevel@tonic-gate clonepath, rc); 7750Sstevel@tonic-gate kmem_free(clonepath, MAXPATHLEN); 7760Sstevel@tonic-gate return (NULL); 7770Sstevel@tonic-gate } 7780Sstevel@tonic-gate kmem_free(clonepath, MAXPATHLEN); 7790Sstevel@tonic-gate 7800Sstevel@tonic-gate ppa = i_ddi_devi_get_ppa(dip); 7815895Syz147064 if ((dl_attach(lh, ppa, NULL) != 0) || 7825895Syz147064 (dl_bind(lh, ETHERTYPE_IP, NULL) != 0)) { 7830Sstevel@tonic-gate (void) ldi_close(lh, FREAD|FWRITE, CRED()); 7840Sstevel@tonic-gate cmn_err(CE_WARN, 7850Sstevel@tonic-gate "getmacaddr: dl_attach/bind(%s%d) failed: %d\n", 7860Sstevel@tonic-gate drv_name, ppa, rc); 7870Sstevel@tonic-gate return (NULL); 7880Sstevel@tonic-gate } 7895895Syz147064 7905895Syz147064 *maclenp = ETHERADDRL; 7915895Syz147064 macaddr = kmem_alloc(ETHERADDRL, KM_SLEEP); 7925895Syz147064 if (dl_phys_addr(lh, macaddr, maclenp, NULL) != 0 || 7935895Syz147064 *maclenp != ETHERADDRL) { 7945895Syz147064 kmem_free(macaddr, ETHERADDRL); 7950Sstevel@tonic-gate macaddr = NULL; 7960Sstevel@tonic-gate *maclenp = 0; 7970Sstevel@tonic-gate cmn_err(CE_WARN, 7985895Syz147064 "getmacaddr: dl_phys_addr(%s%d) failed: %d\n", 7990Sstevel@tonic-gate drv_name, ppa, rc); 8000Sstevel@tonic-gate } 8010Sstevel@tonic-gate (void) ldi_close(lh, FREAD|FWRITE, CRED()); 8020Sstevel@tonic-gate return (macaddr); 8030Sstevel@tonic-gate } 8045648Ssetje #endif /* !_OBP */ 805