From d62bc4badc1c1f1549c961cfb8b420e650e1272b Mon Sep 17 00:00:00 2001 From: yz147064 Date: Wed, 23 Jan 2008 18:09:15 -0800 Subject: PSARC/2006/499 Clearview Nemo unification and vanity naming PSARC/2007/527 Addendum for Clearview Vanity Naming and Nemo Unification PSARC/2008/002 Clearview UV Updates 6310766 vlan statistics get reset at unplumb time 6320515 dladm commands with "-R" option should not take effect immediately 6433732 Simplify the GLDv3 control path by making its processing asynchronous 6445912 dladm show-link fails to show a specific link in the debug version 6452413 dladm show-link doesn't show VLAN links for GLDv2 drivers 6504433 libwladm's use of wladm_wlresult2status() needs an overhaul 6504507 dladm set-linkprop failure message is unclear 6534289 DR should work with aggregations 6535719 dladm_aggr_port_attr_db_t`lp_devname should be MAXNAMELEN, not MAXNAMELEN + 1 6539634 GLDv3 should DL_ERROR_ACK a DL_UDQOS_REQ with DL_OUTSTATE when the stream is DL_UNATTACHED 6540246 libdladm should not guess zoneid from DLDIOCZIDGET ioctl errno 6544195 dladm show-dev assumes GLDv3 stats.. incompatible with GLDv2 6563295 dladm show-linkprop -P does not work properly for unavailable links 6577618 integrate network vanity naming and nemo unification 6600446 links assigned to a local zone are still aggregatable by global zone 6607572 "boot net - install" can trigger assertion failure in dld_str_attach() 6613956 "svccfg import -" does not work as bfu expects 6637596 invalid assertion in ip_soft_ring_assignment() 6642350 kernel DLPI processing routines are long overdue 6643338 GLDv3 PPA hack VLAN ID checks don't always work 6647203 bfu: smf_delete_manifest() does not work for non-global zones 6649885 DL_IB GLDv3 mactype plugin must fill in its mtr_nativetype 6650395 libuuid should be lint-clean and linted nightly --HG-- rename : usr/src/cmd/dladm/aggregation.conf => deleted_files/usr/src/cmd/dladm/aggregation.conf rename : usr/src/cmd/dladm/linkprop.conf => deleted_files/usr/src/cmd/dladm/linkprop.conf rename : usr/src/lib/libinetcfg/common/inetcfg_nic.c => deleted_files/usr/src/lib/libinetcfg/common/inetcfg_nic.c rename : usr/src/lib/libinetcfg/common/inetcfg_nic.h => deleted_files/usr/src/lib/libinetcfg/common/inetcfg_nic.h --- usr/src/Makefile.lint | 4 +- usr/src/Targetdirs | 15 +- usr/src/cmd/Makefile | 4 +- usr/src/cmd/cmd-inet/lib/nwamd/functions.h | 6 +- usr/src/cmd/cmd-inet/lib/nwamd/interface.c | 46 +- usr/src/cmd/cmd-inet/lib/nwamd/structures.h | 3 +- usr/src/cmd/cmd-inet/lib/nwamd/wireless.c | 117 +- usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c | 55 +- usr/src/cmd/cmd-inet/usr.lib/wpad/driver.h | 19 +- usr/src/cmd/cmd-inet/usr.lib/wpad/driver_wifi.c | 114 +- usr/src/cmd/cmd-inet/usr.lib/wpad/wpa.c | 77 +- usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_impl.h | 5 +- usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_supplicant.c | 136 +- usr/src/cmd/cmd-inet/usr.sbin/ifconfig/Makefile | 4 +- usr/src/cmd/cmd-inet/usr.sbin/ifconfig/defs.h | 4 +- usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c | 53 +- usr/src/cmd/cmd-inet/usr.sbin/in.routed/if.c | 9 +- usr/src/cmd/devfsadm/devfsadm.c | 4 +- usr/src/cmd/dladm/Makefile | 7 +- usr/src/cmd/dladm/aggregation.conf | 31 - usr/src/cmd/dladm/dladm.c | 3071 ++++++++++++++------ usr/src/cmd/dladm/dladm.xcl | 9 +- usr/src/cmd/dladm/linkprop.conf | 30 - usr/src/cmd/dlmgmtd/Makefile | 77 + usr/src/cmd/dlmgmtd/datalink.conf | 30 + usr/src/cmd/dlmgmtd/dlmgmt.xml | 90 + usr/src/cmd/dlmgmtd/dlmgmt_db.c | 949 ++++++ usr/src/cmd/dlmgmtd/dlmgmt_door.c | 1075 +++++++ usr/src/cmd/dlmgmtd/dlmgmt_impl.h | 134 + usr/src/cmd/dlmgmtd/dlmgmt_main.c | 345 +++ usr/src/cmd/dlmgmtd/dlmgmt_util.c | 748 +++++ usr/src/cmd/dlmgmtd/svc-dlmgmtd | 45 + usr/src/cmd/rcm_daemon/Makefile.com | 12 +- usr/src/cmd/rcm_daemon/common/aggr_rcm.c | 1455 ++++++++++ usr/src/cmd/rcm_daemon/common/ip_rcm.c | 585 +--- usr/src/cmd/rcm_daemon/common/network_rcm.c | 513 +++- usr/src/cmd/rcm_daemon/common/vlan_rcm.c | 1327 +++++++++ usr/src/cmd/rpcsvc/rstat_proc.c | 15 +- usr/src/cmd/svc/milestone/manifest-import | 19 +- usr/src/cmd/svc/milestone/net-nwam | 17 +- usr/src/cmd/svc/milestone/net-physical | 16 +- usr/src/cmd/svc/seed/Makefile | 3 +- usr/src/cmd/svc/seed/inc.flg | 3 +- usr/src/cmd/svc/shell/net_include.sh | 64 +- usr/src/cmd/truss/codes.c | 20 +- usr/src/cmd/vna/vna.c | 152 +- usr/src/cmd/zoneadmd/Makefile | 4 +- usr/src/cmd/zoneadmd/vplat.c | 150 +- usr/src/lib/Makefile | 8 +- usr/src/lib/brand/native/zone/platform.xml | 3 +- usr/src/lib/brand/sn1/zone/platform.xml | 3 +- usr/src/lib/cfgadm_plugins/sbd/common/ap_rcm.c | 11 +- usr/src/lib/cfgadm_plugins/sbd/sbd.xcl | 9 +- usr/src/lib/libdladm/Makefile | 8 +- usr/src/lib/libdladm/Makefile.com | 6 +- usr/src/lib/libdladm/common/libdladm.c | 194 +- usr/src/lib/libdladm/common/libdladm.h | 60 +- usr/src/lib/libdladm/common/libdladm_impl.h | 33 +- usr/src/lib/libdladm/common/libdlaggr.c | 1945 ++++++------- usr/src/lib/libdladm/common/libdlaggr.h | 54 +- usr/src/lib/libdladm/common/libdllink.c | 915 ++++-- usr/src/lib/libdladm/common/libdllink.h | 88 +- usr/src/lib/libdladm/common/libdlmgmt.c | 676 +++++ usr/src/lib/libdladm/common/libdlmgmt.h | 199 ++ usr/src/lib/libdladm/common/libdlvlan.c | 345 +++ usr/src/lib/libdladm/common/libdlvlan.h | 60 + usr/src/lib/libdladm/common/libdlvnic.c | 364 +-- usr/src/lib/libdladm/common/libdlvnic.h | 28 +- usr/src/lib/libdladm/common/libdlwlan.c | 1358 +++------ usr/src/lib/libdladm/common/libdlwlan.h | 46 +- usr/src/lib/libdladm/common/libdlwlan_impl.h | 15 +- usr/src/lib/libdladm/common/linkprop.c | 1837 ++++++------ usr/src/lib/libdladm/common/llib-ldladm | 4 +- usr/src/lib/libdladm/common/mapfile-vers | 52 +- usr/src/lib/libdladm/common/secobj.c | 16 +- usr/src/lib/libdlpi/Makefile.com | 4 +- usr/src/lib/libdlpi/common/libdlpi.c | 154 +- usr/src/lib/libdlpi/common/libdlpi.h | 56 +- usr/src/lib/libdlpi/common/mapfile-vers | 3 +- usr/src/lib/libinetcfg/Makefile.com | 7 +- usr/src/lib/libinetcfg/common/inetcfg.c | 85 +- usr/src/lib/libinetcfg/common/inetcfg_nic.c | 371 --- usr/src/lib/libinetcfg/common/inetcfg_nic.h | 44 - usr/src/lib/librcm/Makefile.com | 5 +- usr/src/lib/librcm/librcm.h | 7 +- usr/src/lib/libuuid/Makefile.com | 4 +- usr/src/lib/libuuid/common/etheraddr.c | 55 +- usr/src/lib/libuuid/common/uuid.c | 11 +- usr/src/pkgdefs/SUNWarc/prototype_com | 4 +- usr/src/pkgdefs/SUNWarc/prototype_i386 | 3 +- usr/src/pkgdefs/SUNWarc/prototype_sparc | 3 +- usr/src/pkgdefs/SUNWarcr/prototype_com | 4 +- usr/src/pkgdefs/SUNWarcr/prototype_i386 | 3 +- usr/src/pkgdefs/SUNWarcr/prototype_sparc | 3 +- usr/src/pkgdefs/SUNWckr/prototype_com | 3 +- usr/src/pkgdefs/SUNWckr/prototype_i386 | 5 + usr/src/pkgdefs/SUNWckr/prototype_sparc | 2 + usr/src/pkgdefs/SUNWcnetr/postinstall | 92 +- usr/src/pkgdefs/SUNWcnetr/prototype_com | 3 +- usr/src/pkgdefs/SUNWcsd/prototype_com | 3 +- usr/src/pkgdefs/SUNWcsl/prototype_com | 6 +- usr/src/pkgdefs/SUNWcsl/prototype_i386 | 6 +- usr/src/pkgdefs/SUNWcsl/prototype_sparc | 6 +- usr/src/pkgdefs/SUNWcslr/prototype_com | 4 +- usr/src/pkgdefs/SUNWcslr/prototype_i386 | 4 +- usr/src/pkgdefs/SUNWcslr/prototype_sparc | 4 +- usr/src/pkgdefs/SUNWcsr/Makefile | 3 +- usr/src/pkgdefs/SUNWcsr/pkginfo.tmpl | 4 +- usr/src/pkgdefs/SUNWcsr/prototype_com | 7 +- usr/src/pkgdefs/SUNWcsu/prototype_com | 4 +- usr/src/pkgdefs/common_files/i.minorperm_i386 | 3 +- usr/src/pkgdefs/common_files/i.minorperm_sparc | 3 +- usr/src/pkgdefs/common_files/i.seedmanifest | 68 + usr/src/pkgdefs/etc/exception_list_i386 | 18 +- usr/src/pkgdefs/etc/exception_list_sparc | 2 + usr/src/tools/abi/etc/ABI_i386.db | 226 +- usr/src/tools/abi/etc/ABI_sparc.db | 258 +- usr/src/tools/abi/etc/exceptions | 6 +- usr/src/tools/scripts/bfu.sh | 503 ++-- usr/src/uts/common/Makefile.files | 11 +- usr/src/uts/common/Makefile.rules | 7 + usr/src/uts/common/fs/dev/sdev_netops.c | 397 +++ usr/src/uts/common/fs/dev/sdev_subr.c | 72 +- usr/src/uts/common/fs/dev/sdev_vnops.c | 58 +- usr/src/uts/common/fs/nfs/nfs_dlinet.c | 76 +- usr/src/uts/common/inet/arp/arp.c | 4 +- usr/src/uts/common/inet/ip.h | 2 - usr/src/uts/common/inet/ip/ip.c | 86 +- usr/src/uts/common/inet/ip/ip_if.c | 10 +- usr/src/uts/common/inet/ip/ip_squeue.c | 4 +- usr/src/uts/common/inet/tcp/tcp.c | 7 +- usr/src/uts/common/io/afe/afe.c | 2 + usr/src/uts/common/io/aggr/aggr_ctl.c | 53 +- usr/src/uts/common/io/aggr/aggr_dev.c | 12 +- usr/src/uts/common/io/aggr/aggr_grp.c | 301 +- usr/src/uts/common/io/aggr/aggr_lacp.c | 200 +- usr/src/uts/common/io/aggr/aggr_port.c | 78 +- usr/src/uts/common/io/aggr/aggr_recv.c | 15 +- usr/src/uts/common/io/bge/bge_main2.c | 3 +- usr/src/uts/common/io/dld/dld_drv.c | 641 +++- usr/src/uts/common/io/dld/dld_proto.c | 559 ++-- usr/src/uts/common/io/dld/dld_str.c | 750 +++-- usr/src/uts/common/io/dls/dls.c | 219 +- usr/src/uts/common/io/dls/dls_link.c | 54 +- usr/src/uts/common/io/dls/dls_mgmt.c | 1562 ++++++++++ usr/src/uts/common/io/dls/dls_mod.c | 10 +- usr/src/uts/common/io/dls/dls_soft_ring.c | 29 +- usr/src/uts/common/io/dls/dls_stat.c | 111 +- usr/src/uts/common/io/dls/dls_vlan.c | 721 ++--- usr/src/uts/common/io/dmfe/dmfe_main.c | 3 +- usr/src/uts/common/io/e1000g/e1000g_main.c | 1 + usr/src/uts/common/io/gld.c | 29 +- usr/src/uts/common/io/ib/clients/rds/rds_ioctl.c | 58 +- usr/src/uts/common/io/igb/igb_main.c | 1 + usr/src/uts/common/io/mac/mac.c | 647 ++++- usr/src/uts/common/io/mac/mac_stat.c | 15 +- usr/src/uts/common/io/mac/plugins/mac_ib.c | 1 + usr/src/uts/common/io/mxfe/mxfe.c | 2 + usr/src/uts/common/io/net_dacf.c | 136 + usr/src/uts/common/io/nge/nge_main.c | 1 + usr/src/uts/common/io/nxge/nxge_main.c | 1 + usr/src/uts/common/io/rge/rge_main.c | 3 +- usr/src/uts/common/io/sfe/sfe_util.c | 1 + usr/src/uts/common/io/softmac/softmac.conf | 27 + usr/src/uts/common/io/softmac/softmac_capab.c | 756 +++++ usr/src/uts/common/io/softmac/softmac_ctl.c | 389 +++ usr/src/uts/common/io/softmac/softmac_dev.c | 417 +++ usr/src/uts/common/io/softmac/softmac_main.c | 1192 ++++++++ usr/src/uts/common/io/softmac/softmac_pkt.c | 320 ++ usr/src/uts/common/io/softmac/softmac_stat.c | 270 ++ usr/src/uts/common/io/strplumb.c | 275 +- usr/src/uts/common/io/sundlpi.c | 393 ++- usr/src/uts/common/io/vnic/vnic_ctl.c | 197 +- usr/src/uts/common/io/vnic/vnic_dev.c | 105 +- usr/src/uts/common/io/xge/drv/xgell.c | 3 +- usr/src/uts/common/os/dacf.c | 22 +- usr/src/uts/common/os/dacf_clnt.c | 14 +- usr/src/uts/common/os/devcfg.c | 16 +- usr/src/uts/common/os/streamio.c | 54 +- usr/src/uts/common/os/swapgeneric.c | 21 +- usr/src/uts/common/os/zone.c | 23 + usr/src/uts/common/sys/aggr.h | 45 +- usr/src/uts/common/sys/aggr_impl.h | 42 +- usr/src/uts/common/sys/dacf.h | 8 +- usr/src/uts/common/sys/ddi_implfuncs.h | 3 +- usr/src/uts/common/sys/dld.h | 127 +- usr/src/uts/common/sys/dld_impl.h | 115 +- usr/src/uts/common/sys/dlpi.h | 23 +- usr/src/uts/common/sys/dls.h | 234 +- usr/src/uts/common/sys/dls_impl.h | 101 +- usr/src/uts/common/sys/dls_soft_ring.h | 4 +- usr/src/uts/common/sys/fs/sdev_impl.h | 34 +- usr/src/uts/common/sys/gld.h | 4 +- usr/src/uts/common/sys/mac.h | 126 +- usr/src/uts/common/sys/mac_impl.h | 58 +- usr/src/uts/common/sys/param.h | 9 +- usr/src/uts/common/sys/softmac.h | 50 + usr/src/uts/common/sys/softmac_impl.h | 234 ++ usr/src/uts/common/sys/vnic.h | 30 +- usr/src/uts/common/sys/vnic_impl.h | 19 +- usr/src/uts/common/sys/zone.h | 1 + usr/src/uts/common/xen/io/xnbo.c | 10 +- usr/src/uts/common/xen/io/xnbu.c | 8 +- usr/src/uts/intel/Makefile.intel.shared | 6 + usr/src/uts/intel/aggr/Makefile | 4 +- usr/src/uts/intel/dev/Makefile | 4 +- usr/src/uts/intel/ia32/ml/modstubs.s | 33 +- usr/src/uts/intel/io/amd8111s/amd8111s_main.c | 4 +- usr/src/uts/intel/net_dacf/Makefile | 81 + usr/src/uts/intel/os/dacf.conf | 13 +- usr/src/uts/intel/os/device_policy | 3 +- usr/src/uts/intel/os/name_to_major | 1 + usr/src/uts/intel/softmac/Makefile | 92 + usr/src/uts/intel/strplumb/Makefile | 5 +- usr/src/uts/intel/vnic/Makefile | 4 +- usr/src/uts/sparc/Makefile.sparc.shared | 4 +- usr/src/uts/sparc/aggr/Makefile | 4 +- usr/src/uts/sparc/dev/Makefile | 4 +- usr/src/uts/sparc/ml/modstubs.s | 33 +- usr/src/uts/sparc/net_dacf/Makefile | 81 + usr/src/uts/sparc/os/dacf.conf | 13 +- usr/src/uts/sparc/os/device_policy | 3 +- usr/src/uts/sparc/os/name_to_major | 1 + usr/src/uts/sparc/softmac/Makefile | 92 + usr/src/uts/sparc/vnic/Makefile | 4 +- usr/src/uts/sun/io/eri.c | 4 +- usr/src/uts/sun/io/hme.c | 4 +- usr/src/uts/sun4v/io/vsw_phys.c | 17 +- 228 files changed, 25938 insertions(+), 9385 deletions(-) delete mode 100644 usr/src/cmd/dladm/aggregation.conf delete mode 100644 usr/src/cmd/dladm/linkprop.conf create mode 100644 usr/src/cmd/dlmgmtd/Makefile create mode 100644 usr/src/cmd/dlmgmtd/datalink.conf create mode 100644 usr/src/cmd/dlmgmtd/dlmgmt.xml create mode 100644 usr/src/cmd/dlmgmtd/dlmgmt_db.c create mode 100644 usr/src/cmd/dlmgmtd/dlmgmt_door.c create mode 100644 usr/src/cmd/dlmgmtd/dlmgmt_impl.h create mode 100644 usr/src/cmd/dlmgmtd/dlmgmt_main.c create mode 100644 usr/src/cmd/dlmgmtd/dlmgmt_util.c create mode 100644 usr/src/cmd/dlmgmtd/svc-dlmgmtd create mode 100644 usr/src/cmd/rcm_daemon/common/aggr_rcm.c create mode 100644 usr/src/cmd/rcm_daemon/common/vlan_rcm.c create mode 100644 usr/src/lib/libdladm/common/libdlmgmt.c create mode 100644 usr/src/lib/libdladm/common/libdlmgmt.h create mode 100644 usr/src/lib/libdladm/common/libdlvlan.c create mode 100644 usr/src/lib/libdladm/common/libdlvlan.h delete mode 100644 usr/src/lib/libinetcfg/common/inetcfg_nic.c delete mode 100644 usr/src/lib/libinetcfg/common/inetcfg_nic.h create mode 100644 usr/src/pkgdefs/common_files/i.seedmanifest create mode 100644 usr/src/uts/common/fs/dev/sdev_netops.c create mode 100644 usr/src/uts/common/io/dls/dls_mgmt.c create mode 100644 usr/src/uts/common/io/net_dacf.c create mode 100644 usr/src/uts/common/io/softmac/softmac.conf create mode 100644 usr/src/uts/common/io/softmac/softmac_capab.c create mode 100644 usr/src/uts/common/io/softmac/softmac_ctl.c create mode 100644 usr/src/uts/common/io/softmac/softmac_dev.c create mode 100644 usr/src/uts/common/io/softmac/softmac_main.c create mode 100644 usr/src/uts/common/io/softmac/softmac_pkt.c create mode 100644 usr/src/uts/common/io/softmac/softmac_stat.c create mode 100644 usr/src/uts/common/sys/softmac.h create mode 100644 usr/src/uts/common/sys/softmac_impl.h create mode 100644 usr/src/uts/intel/net_dacf/Makefile create mode 100644 usr/src/uts/intel/softmac/Makefile create mode 100644 usr/src/uts/sparc/net_dacf/Makefile create mode 100644 usr/src/uts/sparc/softmac/Makefile (limited to 'usr/src') diff --git a/usr/src/Makefile.lint b/usr/src/Makefile.lint index aebe1e341b..6ed5c8ab98 100644 --- a/usr/src/Makefile.lint +++ b/usr/src/Makefile.lint @@ -20,7 +20,7 @@ # # -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -170,6 +170,7 @@ COMMON_SUBDIRS = \ cmd/ldapcachemgr \ cmd/line \ cmd/link \ + cmd/dlmgmtd \ cmd/locator \ cmd/lockstat \ cmd/lofiadm \ @@ -382,6 +383,7 @@ COMMON_SUBDIRS = \ lib/libtsnet \ lib/libtsol \ lib/libumem \ + lib/libuuid \ lib/libuutil \ lib/libwanboot \ lib/libwanbootutil \ diff --git a/usr/src/Targetdirs b/usr/src/Targetdirs index eaddb51f2a..f3a4937c83 100644 --- a/usr/src/Targetdirs +++ b/usr/src/Targetdirs @@ -20,7 +20,7 @@ # # -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -67,6 +67,7 @@ ROOT.SYS= \ /dev \ /dev/dsk \ /dev/fd \ + /dev/net \ /dev/rdsk \ /dev/rmt \ /dev/pts \ @@ -919,10 +920,12 @@ $(ROOT)/usr/lib/libposix4.so:= REALPATH=../../lib/librt.so.1 $(ROOT)/usr/lib/libproc.so.1:= REALPATH=../../lib/libproc.so.1 $(ROOT)/usr/lib/libproc.so:= REALPATH=../../lib/libproc.so.1 $(ROOT)/usr/lib/libpthread.so.1:= REALPATH=../../lib/libpthread.so.1 +$(ROOT)/usr/lib/libpthread.so:= REALPATH=../../lib/libpthread.so.1 +$(ROOT)/usr/lib/librcm.so.1:= REALPATH=../../lib/librcm.so.1 +$(ROOT)/usr/lib/librcm.so:= REALPATH=../../lib/librcm.so.1 $(ROOT)/usr/lib/libresolv.so.1:= REALPATH=../../lib/libresolv.so.1 $(ROOT)/usr/lib/libresolv.so.2:= REALPATH=../../lib/libresolv.so.2 $(ROOT)/usr/lib/libresolv.so:= REALPATH=../../lib/libresolv.so.2 -$(ROOT)/usr/lib/libpthread.so:= REALPATH=../../lib/libpthread.so.1 $(ROOT)/usr/lib/librestart.so.1:= REALPATH=../../lib/librestart.so.1 $(ROOT)/usr/lib/librestart.so:= REALPATH=../../lib/librestart.so.1 $(ROOT)/usr/lib/librpcsvc.so.1:= REALPATH=../../lib/librpcsvc.so.1 @@ -1217,6 +1220,10 @@ $(ROOT)/usr/lib/$(MACH64)/libpthread.so.1:= \ REALPATH=../../../lib/$(MACH64)/libpthread.so.1 $(ROOT)/usr/lib/$(MACH64)/libpthread.so:= \ REALPATH=../../../lib/$(MACH64)/libpthread.so.1 +$(ROOT)/usr/lib/$(MACH64)/librcm.so.1:= \ + REALPATH=../../../lib/$(MACH64)/librcm.so.1 +$(ROOT)/usr/lib/$(MACH64)/librcm.so:= \ + REALPATH=../../../lib/$(MACH64)/librcm.so.1 $(ROOT)/usr/lib/$(MACH64)/libresolv.so.2:= \ REALPATH=../../../lib/$(MACH64)/libresolv.so.2 $(ROOT)/usr/lib/$(MACH64)/libresolv.so:= \ @@ -1504,6 +1511,8 @@ SYM.USRLIB= \ /usr/lib/libproc.so.1 \ /usr/lib/libpthread.so \ /usr/lib/libpthread.so.1 \ + /usr/lib/librcm.so \ + /usr/lib/librcm.so.1 \ /usr/lib/libresolv.so \ /usr/lib/libresolv.so.1 \ /usr/lib/libresolv.so.2 \ @@ -1736,6 +1745,8 @@ SYM.USRLIB64= \ /usr/lib/$(MACH64)/libproc.so.1 \ /usr/lib/$(MACH64)/libpthread.so \ /usr/lib/$(MACH64)/libpthread.so.1 \ + /usr/lib/$(MACH64)/librcm.so \ + /usr/lib/$(MACH64)/librcm.so.1 \ /usr/lib/$(MACH64)/libresolv.so \ /usr/lib/$(MACH64)/libresolv.so.2 \ /usr/lib/$(MACH64)/librestart.so \ diff --git a/usr/src/cmd/Makefile b/usr/src/cmd/Makefile index 01c00817c7..6402d952e2 100644 --- a/usr/src/cmd/Makefile +++ b/usr/src/cmd/Makefile @@ -21,7 +21,7 @@ # # -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -223,6 +223,7 @@ COMMON_SUBDIRS= \ lgrpinfo \ line \ link \ + dlmgmtd \ listen \ loadkeys \ locale \ @@ -800,6 +801,7 @@ MANIFEST_TOPDIRS= \ ipf \ keyserv \ ldapcachemgr \ + dlmgmtd \ nscd \ oplhpd \ power \ diff --git a/usr/src/cmd/cmd-inet/lib/nwamd/functions.h b/usr/src/cmd/cmd-inet/lib/nwamd/functions.h index 96f4c50a63..bb88f4d2d9 100644 --- a/usr/src/cmd/cmd-inet/lib/nwamd/functions.h +++ b/usr/src/cmd/cmd-inet/lib/nwamd/functions.h @@ -20,7 +20,7 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -62,9 +62,9 @@ extern int lookup_count_property(const char *, const char *, uint64_t *); /* wireless.c: wifi link handling */ extern void init_mutexes(void); -extern boolean_t connect_chosen_lan(struct wireless_lan *, const char *); +extern boolean_t connect_chosen_lan(struct wireless_lan *, struct interface *); extern struct wireless_lan *prompt_for_visited(void); -extern boolean_t handle_wireless_lan(const char *); +extern boolean_t handle_wireless_lan(struct interface *); extern boolean_t scan_wireless_nets(struct interface *); extern void create_known_wifi_nets_file(void); extern void update_known_wifi_nets_file(const char *, const char *); diff --git a/usr/src/cmd/cmd-inet/lib/nwamd/interface.c b/usr/src/cmd/cmd-inet/lib/nwamd/interface.c index b66dee45f5..304cb78467 100644 --- a/usr/src/cmd/cmd-inet/lib/nwamd/interface.c +++ b/usr/src/cmd/cmd-inet/lib/nwamd/interface.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -558,7 +558,7 @@ bringupinterface(const char *ifname, const char *host, const char *ipv6addr, } if (intf->if_type == IF_WIRELESS) { - if (!handle_wireless_lan(ifname)) { + if (!handle_wireless_lan(intf)) { syslog(LOG_INFO, "Could not connect to any WLAN, not " "bringing %s up", ifname); return (B_FALSE); @@ -631,8 +631,8 @@ takedowninterface(const char *ifname, boolean_t popup, boolean_t v6onlink) (void) start_child(IFCONFIG, ifname, "inet6", "unplumb", NULL); } - if (find_if_type(ifname) == IF_WIRELESS) - (void) dladm_wlan_disconnect(ifname); + if (ifp->if_type == IF_WIRELESS) + (void) dladm_wlan_disconnect(ifp->if_linkid); dprintf("takedown interface, free cached ip address"); if (ifp != NULL) { @@ -751,6 +751,7 @@ struct interface * add_interface(sa_family_t family, const char *name, uint64_t flags) { struct interface *i; + datalink_id_t linkid = DATALINK_INVALID_LINKID; enum interface_type iftype; if (name == NULL) @@ -801,6 +802,13 @@ add_interface(sa_family_t family, const char *name, uint64_t flags) i->if_lflags = 0; i->if_timer_expire = 0; + /* + * If linkid is DATALINK_INVALID_LINKID, it is an IP-layer only + * interface. + */ + (void) dladm_name2info(name, &linkid, NULL, NULL, NULL); + i->if_linkid = linkid; + dprintf("added interface %s of type %s af %d; is %savailable", i->if_name, if_type_str(i->if_type), i->if_family, ((i->if_type == IF_WIRELESS) || @@ -1077,7 +1085,7 @@ initialize_interfaces(void) wait_time = NWAM_IF_WAIT_DELTA_MAX; } - (void) dladm_init_linkprop(); + (void) dladm_init_linkprop(DATALINK_ALL_LINKID); (void) icfg_iterate_if(AF_INET, ICFG_PLUMBED, NULL, do_add_interface); @@ -1167,6 +1175,7 @@ check_interface_timer(struct interface *ifp, void *arg) enum interface_type find_if_type(const char *name) { + uint32_t media; enum interface_type type; if (name == NULL) { @@ -1174,20 +1183,19 @@ find_if_type(const char *name) return (IF_UNKNOWN); } - if (strncmp(name, "ip.tun", 6) == 0) { - /* - * We'll need to update our tunnel detection once - * clearview/uv and clearview/tun driver projects - * go back; tunnel names won't necessarily be ip.tunN - */ - type = IF_TUN; - } else { - /* - * We didn't recognize it. Try the libdladm function - * to decide if it is wireless or not; if not, assume - * that it's wired. - */ - type = dladm_wlan_is_valid(name) ? IF_WIRELESS : IF_WIRED; + type = IF_WIRED; + if (dladm_name2info(name, NULL, NULL, NULL, &media) != + DLADM_STATUS_OK) { + if (strncmp(name, "ip.tun", 6) == 0) { + /* + * We'll need to update our tunnel detection once + * clearview/uv and clearview/tun driver projects + * go back; tunnel names won't necessarily be ip.tunN + */ + type = IF_TUN; + } + } else if (media == DL_WIFI) { + type = IF_WIRELESS; } return (type); diff --git a/usr/src/cmd/cmd-inet/lib/nwamd/structures.h b/usr/src/cmd/cmd-inet/lib/nwamd/structures.h index 0f232cd70b..caf0815d32 100644 --- a/usr/src/cmd/cmd-inet/lib/nwamd/structures.h +++ b/usr/src/cmd/cmd-inet/lib/nwamd/structures.h @@ -20,7 +20,7 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -89,6 +89,7 @@ struct np_event { */ struct interface { char *if_name; + datalink_id_t if_linkid; sa_family_t if_family; uint64_t if_flags; uint32_t if_lflags; diff --git a/usr/src/cmd/cmd-inet/lib/nwamd/wireless.c b/usr/src/cmd/cmd-inet/lib/nwamd/wireless.c index 78cd0f4c74..f99d103dd3 100644 --- a/usr/src/cmd/cmd-inet/lib/nwamd/wireless.c +++ b/usr/src/cmd/cmd-inet/lib/nwamd/wireless.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -152,10 +152,10 @@ static dladm_wlan_key_t *retrieve_key(const char *, const char *, static boolean_t add_wlan_entry(struct interface *, char *, char *, char *, dladm_wlan_secmode_t); static boolean_t already_in_visited_wlan_list(const struct wireless_lan *); -static boolean_t check_wlan(const char *, const char *); -static boolean_t connect_or_autoconf(struct wireless_lan *, const char *); +static boolean_t check_wlan(struct interface *, const char *); +static boolean_t connect_or_autoconf(struct wireless_lan *, struct interface *); static return_vals_t connect_to_new_wlan(const struct wireless_lan *, int, - const char *); + struct interface *); static boolean_t find_wlan_entry(struct interface *, char *, char *); static void free_wireless_lan(struct wireless_lan *); static struct wireless_lan *get_specific_lan(void); @@ -167,7 +167,7 @@ static void free_argv(char **); static char **build_wlanlist_zargv(const struct wireless_lan *, int, const char *, int, const char **, int); static char *get_zenity_response(char *const *); -static boolean_t wlan_autoconf(const char *ifname); +static boolean_t wlan_autoconf(struct interface *); static int zenity_height(int); static boolean_t get_scan_results(void *, dladm_wlan_attr_t *); static boolean_t known_wifi_nets_lookup(const char *, const char *, char *); @@ -438,20 +438,21 @@ clear_lan_entries(void) * to disassociate with it and then return false. */ static boolean_t -check_wlan(const char *intf, const char *exp_essid) +check_wlan(struct interface *intf, const char *exp_essid) { dladm_wlan_linkattr_t attr; dladm_status_t status; char cur_essid[DLADM_STRSIZE]; char errmsg[DLADM_STRSIZE]; - status = dladm_wlan_get_linkattr(intf, &attr); + status = dladm_wlan_get_linkattr(intf->if_linkid, &attr); if (status != DLADM_STATUS_OK) { - dprintf("check_wlan: dladm_wlan_get_linkattr() failed: %s", + dprintf("check_wlan: dladm_wlan_get_linkattr() for %s " + "failed: %s", intf->if_name, dladm_status2str(status, errmsg)); return (B_FALSE); } - if (attr.la_status == DLADM_WLAN_LINKSTATUS_DISCONNECTED) + if (attr.la_status == DLADM_WLAN_LINK_DISCONNECTED) return (B_FALSE); if (exp_essid == NULL) return (B_TRUE); @@ -462,8 +463,10 @@ check_wlan(const char *intf, const char *exp_essid) return (B_TRUE); /* Tell the driver to disassociate with the current AP. */ - if (dladm_wlan_disconnect(intf) != DLADM_STATUS_OK) - dprintf("check_wlan: dladm_wlan_disconnect() fails"); + if (dladm_wlan_disconnect(intf->if_linkid) != DLADM_STATUS_OK) { + dprintf("check_wlan: dladm_wlan_disconnect() for %s fails", + intf->if_name); + } return (B_FALSE); } @@ -505,7 +508,7 @@ scan_wireless_nets(struct interface *intf) * a lock in checking wireless_lan_used. */ num_ap = wireless_lan_used; - status = dladm_wlan_scan(intf->if_name, intf, get_scan_results); + status = dladm_wlan_scan(intf->if_linkid, intf, get_scan_results); if (status != DLADM_STATUS_OK) syslog(LOG_NOTICE, "cannot scan link '%s'", intf->if_name); else @@ -570,6 +573,8 @@ get_scan_results(void *arg, dladm_wlan_attr_t *attrp) void * periodic_wireless_scan(void *arg) { + datalink_id_t linkid; + /* * No periodic scan if the "-i" option is used to change the * interval to 0. @@ -601,13 +606,18 @@ periodic_wireless_scan(void *arg) */ if (ret == 0) { if (cur_llp != NULL) { - if (cur_llp->llp_type != IF_WIRELESS || - dladm_wlan_get_linkattr(cur_llp->llp_lname, - &attr) != DLADM_STATUS_OK) { + if (cur_llp->llp_type != IF_WIRELESS) + continue; + + if (dladm_name2info(cur_llp->llp_lname, &linkid, + NULL, NULL, NULL) != DLADM_STATUS_OK || + dladm_wlan_get_linkattr(linkid, &attr) != + DLADM_STATUS_OK) { continue; } + if (attr.la_status == - DLADM_WLAN_LINKSTATUS_CONNECTED && + DLADM_WLAN_LINK_CONNECTED && attr.la_wlan_attr.wa_strength > wireless_scan_level) { continue; @@ -771,7 +781,7 @@ store_key(struct wireless_lan *wlan) status = dladm_set_secobj(obj_name, class, obj_val, obj_len, - DLADM_OPT_CREATE | DLADM_OPT_PERSIST | DLADM_OPT_TEMP); + DLADM_OPT_CREATE | DLADM_OPT_PERSIST | DLADM_OPT_ACTIVE); if (status != DLADM_STATUS_OK) { syslog(LOG_ERR, "store_key: could not create secure object " "'%s' for key: %s", obj_name, @@ -826,7 +836,7 @@ retrieve_key(const char *essid, const char *bssid, dladm_secobj_class_t req) /* Try the kernel first, then fall back to persistent storage. */ status = dladm_get_secobj(cooked_key->wk_name, &class, cooked_key->wk_val, &cooked_key->wk_len, - DLADM_OPT_TEMP); + DLADM_OPT_ACTIVE); if (status != DLADM_STATUS_OK) { dprintf("retrieve_key: dladm_get_secobj(TEMP) failed: %s", dladm_status2str(status, errmsg)); @@ -1007,7 +1017,7 @@ known_wifi_nets_lookup(const char *new_essid, const char *new_bssid, * reqlan->bssid is optional (i.e., may be NULL) */ boolean_t -connect_chosen_lan(struct wireless_lan *reqlan, const char *ifname) +connect_chosen_lan(struct wireless_lan *reqlan, struct interface *intf) { uint_t keycount; dladm_wlan_key_t *key; @@ -1022,17 +1032,17 @@ connect_chosen_lan(struct wireless_lan *reqlan, const char *ifname) if (reqlan->essid == NULL) return (B_FALSE); dprintf("connect_chosen_lan(%s, %s, %s)", reqlan->essid, - STRING(reqlan->bssid), ifname); + STRING(reqlan->bssid), intf->if_name); /* If it is already connected to the required AP, just return. */ - if (check_wlan(ifname, reqlan->essid)) + if (check_wlan(intf, reqlan->essid)) return (B_TRUE); if (dladm_wlan_str2essid(reqlan->essid, &attr.wa_essid) != DLADM_STATUS_OK) { syslog(LOG_ERR, "connect_chosen_lan: invalid ESSID '%s' for '%s'", - reqlan->essid, ifname); + reqlan->essid, intf->if_name); return (B_FALSE); } attr.wa_valid = DLADM_WLAN_ATTR_ESSID; @@ -1041,7 +1051,7 @@ connect_chosen_lan(struct wireless_lan *reqlan, const char *ifname) DLADM_STATUS_OK) { syslog(LOG_ERR, "connect_chosen_lan: invalid BSSID '%s' for '%s'", - reqlan->bssid, ifname); + reqlan->bssid, intf->if_name); return (B_FALSE); } attr.wa_valid |= DLADM_WLAN_ATTR_BSSID; @@ -1068,8 +1078,8 @@ connect_chosen_lan(struct wireless_lan *reqlan, const char *ifname) * try a second time with just the ESSID. */ - status = dladm_wlan_connect(ifname, &attr, timeout, key, keycount, - flags); + status = dladm_wlan_connect(intf->if_linkid, &attr, timeout, key, + keycount, flags); dprintf("connect_chosen_lan: dladm_wlan_connect returned %s", dladm_status2str(status, errmsg)); if (status == DLADM_STATUS_TIMEDOUT && reqlan->bssid != NULL) { @@ -1078,13 +1088,14 @@ connect_chosen_lan(struct wireless_lan *reqlan, const char *ifname) reqlan->essid, reqlan->bssid, reqlan->essid); attr.wa_valid &= ~DLADM_WLAN_ATTR_BSSID; flags = 0; - status = dladm_wlan_connect(ifname, &attr, timeout, key, - keycount, flags); + status = dladm_wlan_connect(intf->if_linkid, &attr, timeout, + key, keycount, flags); } if (status != DLADM_STATUS_OK) { syslog(LOG_ERR, "connect_chosen_lan: connect to '%s' failed on '%s': %s", - reqlan->essid, ifname, dladm_status2str(status, errmsg)); + reqlan->essid, intf->if_name, + dladm_status2str(status, errmsg)); return (B_FALSE); } return (B_TRUE); @@ -1095,13 +1106,13 @@ connect_chosen_lan(struct wireless_lan *reqlan, const char *ifname) * If that fails, attempt to connect using autoconf. */ static boolean_t -connect_or_autoconf(struct wireless_lan *reqlan, const char *ifname) +connect_or_autoconf(struct wireless_lan *reqlan, struct interface *intf) { - if (!connect_chosen_lan(reqlan, ifname)) { + if (!connect_chosen_lan(reqlan, intf)) { syslog(LOG_WARNING, "Could not connect to chosen WLAN %s, going to auto-conf", reqlan->essid); - return (wlan_autoconf(ifname)); + return (wlan_autoconf(intf)); } return (B_TRUE); } @@ -1198,9 +1209,8 @@ build_wlanlist_zargv(const struct wireless_lan *lanlist, int nlans, static return_vals_t connect_to_new_wlan(const struct wireless_lan *lanlist, int nlans, - const char *ifname) + struct interface *intf) { - struct interface *intf; int i, dlist_cnt; int rtn; char **zargv; @@ -1209,19 +1219,13 @@ connect_to_new_wlan(const struct wireless_lan *lanlist, int nlans, struct wireless_lan *dlist, *reqlan; boolean_t autoconf = B_FALSE; - dprintf("connect_to_new_wlan(..., %d, %s)", nlans, ifname); + dprintf("connect_to_new_wlan(..., %d, %s)", nlans, intf->if_name); if (nlans == 0) { display(gettext("No Wifi networks found; continuing in case " "you know of any which do not broadcast.")); } - if ((intf = get_interface(ifname)) == NULL) { - dprintf("connect_to_new_wlan: cannot find wireless interface: " - "%s", ifname); - return (FAILURE); - } - /* build list of wlans to be displayed */ if ((dlist = calloc(nlans, sizeof (struct wireless_lan))) == NULL) return (FAILURE); @@ -1236,10 +1240,10 @@ connect_to_new_wlan(const struct wireless_lan *lanlist, int nlans, /* * Only use the interface which finds the AP to connect to it. */ - if (strcmp(lanlist[i].wl_if_name, ifname) != 0) { + if (strcmp(lanlist[i].wl_if_name, intf->if_name) != 0) { dprintf("connect_to_new_wlan: wrong interface (%s) for " - "%s (should be %s)", ifname, lanlist[i].essid, - lanlist[i].wl_if_name); + "%s (should be %s)", intf->if_name, + lanlist[i].essid, lanlist[i].wl_if_name); continue; } @@ -1279,7 +1283,7 @@ connect_to_new_wlan(const struct wireless_lan *lanlist, int nlans, if ((reqlan == NULL) || (reqlan->essid == NULL)) { dprintf("did not get user preference; attempting autoconf"); - rtn = wlan_autoconf(ifname) ? SUCCESS : FAILURE; + rtn = wlan_autoconf(intf) ? SUCCESS : FAILURE; goto cleanup; } dprintf("get_user_preference() returned essid %s, bssid %s, encr %s", @@ -1295,7 +1299,7 @@ connect_to_new_wlan(const struct wireless_lan *lanlist, int nlans, * now attempt to connect to selection, backing * off to autoconf if the connect fails */ - if (connect_chosen_lan(reqlan, ifname)) { + if (connect_chosen_lan(reqlan, intf)) { /* * Succeeded, so add entry to known_essid_list_file; * but first make sure the reqlan->bssid isn't empty. @@ -1305,7 +1309,8 @@ connect_to_new_wlan(const struct wireless_lan *lanlist, int nlans, dladm_wlan_linkattr_t attr; char bssid[DLADM_STRSIZE]; - status = dladm_wlan_get_linkattr(ifname, &attr); + status = dladm_wlan_get_linkattr(intf->if_linkid, + &attr); if (status == DLADM_STATUS_OK) { (void) dladm_wlan_bssid2str( @@ -1326,7 +1331,7 @@ connect_to_new_wlan(const struct wireless_lan *lanlist, int nlans, free_wireless_lan(reqlan); if (autoconf) - rtn = wlan_autoconf(ifname) ? SUCCESS : FAILURE; + rtn = wlan_autoconf(intf) ? SUCCESS : FAILURE; else rtn = SUCCESS; @@ -1391,7 +1396,7 @@ prompt_for_visited(void) } static boolean_t -wlan_autoconf(const char *ifname) +wlan_autoconf(struct interface *intf) { dladm_status_t status; boolean_t autoconf; @@ -1402,7 +1407,7 @@ wlan_autoconf(const char *ifname) } /* If the NIC is already associated with something, just return. */ - if (check_wlan(ifname, NULL)) + if (check_wlan(intf, NULL)) return (B_TRUE); /* @@ -1410,14 +1415,14 @@ wlan_autoconf(const char *ifname) * to cycle through WLANs detected in priority order, attempting * to connect. */ - status = dladm_wlan_connect(ifname, NULL, + status = dladm_wlan_connect(intf->if_linkid, NULL, DLADM_WLAN_CONNECT_TIMEOUT_DEFAULT, NULL, 0, 0); if (status != DLADM_STATUS_OK) { char errmsg[DLADM_STRSIZE]; syslog(LOG_ERR, "wlan_autoconf: dladm_wlan_connect failed for '%s': %s", - ifname, dladm_status2str(status, errmsg)); + intf->if_name, dladm_status2str(status, errmsg)); return (B_FALSE); } return (B_TRUE); @@ -1720,7 +1725,7 @@ cleanup: * B_FALSE if we were unable to connect to anything */ boolean_t -handle_wireless_lan(const char *ifname) +handle_wireless_lan(struct interface *intf) { const struct wireless_lan *cur_wlans; int i, num_wlans; @@ -1839,7 +1844,7 @@ start_over: if (strength < strongest) goto connect_any; } - result = connect_or_autoconf(target, ifname); + result = connect_or_autoconf(target, intf); connect_result = result ? SUCCESS : FAILURE; } else if (visited_wlan_list->total > 1) { @@ -1848,21 +1853,21 @@ start_over: * prompt user for which one should we connect to */ if ((req_conf = prompt_for_visited()) != NULL) { - result = connect_or_autoconf(req_conf, ifname); + result = connect_or_autoconf(req_conf, intf); connect_result = result ? SUCCESS : FAILURE; } else { /* * The user didn't make a choice; offer the full list. */ connect_result = connect_to_new_wlan(cur_wlans, - num_wlans, ifname); + num_wlans, intf); result = (connect_result == SUCCESS); } } else { connect_any: /* last case, no previously visited wlan found */ connect_result = connect_to_new_wlan(cur_wlans, num_wlans, - ifname); + intf); result = (connect_result == SUCCESS); } diff --git a/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c b/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c index 1a964f0ce2..b9a02b54e7 100644 --- a/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c +++ b/usr/src/cmd/cmd-inet/usr.bin/netstat/netstat.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -2632,9 +2632,17 @@ if_report(mib_item_t *item, char *matchname, continue; /* 'for' loop 2a */ new_ifindex = if_nametoindex(logintname); + /* + * First lookup the "link" kstats in + * case the link is renamed. Then + * fallback to the legacy kstats for + * those non-GLDv3 links. + */ if (new_ifindex != ifindex_v4 && - (ksp = kstat_lookup(kc, NULL, -1, - ifname)) != NULL) { + (((ksp = kstat_lookup(kc, "link", 0, + ifname)) != NULL) || + ((ksp = kstat_lookup(kc, NULL, -1, + ifname)) != NULL))) { (void) safe_kstat_read(kc, ksp, NULL); stat.ipackets = @@ -2774,11 +2782,20 @@ if_report(mib_item_t *item, char *matchname, continue; } - ksp = kstat_lookup(kc, NULL, -1, buf); - if (ksp && - ksp->ks_type == KSTAT_TYPE_NAMED) + /* + * First lookup the "link" kstats in + * case the link is renamed. Then + * fallback to the legacy kstats for + * those non-GLDv3 links. + */ + if (((ksp = kstat_lookup(kc, "link", + 0, buf)) != NULL || + (ksp = kstat_lookup(kc, NULL, -1, + buf)) != NULL) && (ksp->ks_type == + KSTAT_TYPE_NAMED)) { (void) safe_kstat_read(kc, ksp, NULL); + } t.ipackets = kstat_named_value(ksp, "ipackets"); @@ -2926,9 +2943,18 @@ if_report(mib_item_t *item, char *matchname, continue; /* 'for' loop 2d */ new_ifindex = if_nametoindex(logintname); + + /* + * First lookup the "link" kstats in + * case the link is renamed. Then + * fallback to the legacy kstats for + * those non-GLDv3 links. + */ if (new_ifindex != ifindex_v6 && + ((ksp = kstat_lookup(kc, "link", 0, + ifname)) != NULL || (ksp = kstat_lookup(kc, NULL, -1, - ifname)) != NULL) { + ifname)) != NULL)) { (void) safe_kstat_read(kc, ksp, NULL); stat.ipackets = @@ -3071,11 +3097,20 @@ if_report(mib_item_t *item, char *matchname, continue; } - ksp = kstat_lookup(kc, NULL, -1, buf); - if (ksp && ksp->ks_type == - KSTAT_TYPE_NAMED) + /* + * First lookup the "link" kstats in + * case the link is renamed. Then + * fallback to the legacy kstats for + * those non-GLDv3 links. + */ + if (((ksp = kstat_lookup(kc, "link", + 0, buf)) != NULL || + (ksp = kstat_lookup(kc, NULL, -1, + buf)) != NULL) && (ksp->ks_type == + KSTAT_TYPE_NAMED)) { (void) safe_kstat_read(kc, ksp, NULL); + } t.ipackets = kstat_named_value(ksp, "ipackets"); diff --git a/usr/src/cmd/cmd-inet/usr.lib/wpad/driver.h b/usr/src/cmd/cmd-inet/usr.lib/wpad/driver.h index dc13c719ce..1169c82263 100644 --- a/usr/src/cmd/cmd-inet/usr.lib/wpad/driver.h +++ b/usr/src/cmd/cmd-inet/usr.lib/wpad/driver.h @@ -1,5 +1,5 @@ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -14,6 +14,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include +#include #ifdef __cplusplus extern "C" { @@ -25,15 +26,15 @@ typedef enum { CIPHER_NONE, CIPHER_WEP40, CIPHER_TKIP, CIPHER_CCMP, typedef enum { KEY_MGMT_802_1X, KEY_MGMT_PSK, KEY_MGMT_NONE } wpa_key_mgmt; struct wpa_driver_ops { - int (*get_bssid)(const char *, char *); - int (*get_ssid)(const char *ifname, char *); - int (*set_wpa)(const char *, boolean_t); - int (*set_key)(const char *, wpa_alg, uint8_t *, + int (*get_bssid)(datalink_id_t, char *); + int (*get_ssid)(datalink_id_t, char *); + int (*set_wpa)(datalink_id_t, boolean_t); + int (*set_key)(datalink_id_t, wpa_alg, uint8_t *, int, boolean_t, uint8_t *, uint32_t, uint8_t *, uint32_t); - int (*scan)(const char *); - int (*get_scan_results)(const char *, dladm_wlan_ess_t *, uint32_t); - int (*disassociate)(const char *, int); - int (*associate)(const char *, const char *, uint8_t *, uint32_t); + int (*scan)(datalink_id_t); + int (*get_scan_results)(datalink_id_t, dladm_wlan_ess_t *, uint32_t); + int (*disassociate)(datalink_id_t, int); + int (*associate)(datalink_id_t, const char *, uint8_t *, uint32_t); }; #ifdef __cplusplus diff --git a/usr/src/cmd/cmd-inet/usr.lib/wpad/driver_wifi.c b/usr/src/cmd/cmd-inet/usr.lib/wpad/driver_wifi.c index 4ab82a2669..01ca5cea5e 100644 --- a/usr/src/cmd/cmd-inet/usr.lib/wpad/driver_wifi.c +++ b/usr/src/cmd/cmd-inet/usr.lib/wpad/driver_wifi.c @@ -1,5 +1,5 @@ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -28,7 +28,7 @@ /* * get_bssid - get the current BSSID - * @ifname: interface name, e.g., wlan0 + * @linkid: linkid of the given interface * @bssid: buffer for BSSID (IEEE80211_ADDR_LEN = 6 bytes) * * Returns: 0 on success, -1 on failure @@ -38,14 +38,14 @@ * associated. */ int -wpa_driver_wifi_get_bssid(const char *ifname, char *bssid) +wpa_driver_wifi_get_bssid(datalink_id_t linkid, char *bssid) { - int ret; + dladm_status_t status; dladm_wlan_linkattr_t attr; dladm_wlan_attr_t *wl_attrp; - ret = dladm_wlan_get_linkattr(ifname, &attr); - if (ret != DLADM_STATUS_OK) + status = dladm_wlan_get_linkattr(linkid, &attr); + if (status != DLADM_STATUS_OK) return (-1); wl_attrp = &attr.la_wlan_attr; @@ -58,12 +58,12 @@ wpa_driver_wifi_get_bssid(const char *ifname, char *bssid) wpa_printf(MSG_DEBUG, "wpa_driver_wifi_get_bssid: " MACSTR, MAC2STR((unsigned char *)bssid)); - return (WPA_STATUS(ret)); + return (WPA_STATUS(status)); } /* * get_ssid - get the current SSID - * @ifname: interface name, e.g., wlan0 + * @linkid: linkid of the given interface * @ssid: buffer for SSID (at least 32 bytes) * * Returns: length of the SSID on success, -1 on failure @@ -72,14 +72,15 @@ wpa_driver_wifi_get_bssid(const char *ifname, char *bssid) * Returning zero is recommended if the STA is not associated. */ int -wpa_driver_wifi_get_ssid(const char *ifname, char *ssid) +wpa_driver_wifi_get_ssid(datalink_id_t linkid, char *ssid) { int ret; + dladm_status_t status; dladm_wlan_linkattr_t attr; dladm_wlan_attr_t *wl_attrp; - ret = dladm_wlan_get_linkattr(ifname, &attr); - if (ret != DLADM_STATUS_OK) + status = dladm_wlan_get_linkattr(linkid, &attr); + if (status != DLADM_STATUS_OK) return (-1); wl_attrp = &attr.la_wlan_attr; @@ -97,20 +98,20 @@ wpa_driver_wifi_get_ssid(const char *ifname, char *ssid) } static int -wpa_driver_wifi_set_wpa_ie(const char *ifname, - uint8_t *wpa_ie, uint32_t wpa_ie_len) +wpa_driver_wifi_set_wpa_ie(datalink_id_t linkid, uint8_t *wpa_ie, + uint32_t wpa_ie_len) { - int ret; + dladm_status_t status; wpa_printf(MSG_DEBUG, "%s", "wpa_driver_wifi_set_wpa_ie"); - ret = dladm_wlan_wpa_set_ie(ifname, wpa_ie, wpa_ie_len); + status = dladm_wlan_wpa_set_ie(linkid, wpa_ie, wpa_ie_len); - return (WPA_STATUS(ret)); + return (WPA_STATUS(status)); } /* * set_wpa - enable/disable WPA support - * @ifname: interface name, e.g., wlan0 + * @linkid: linkid of the given interface * @enabled: 1 = enable, 0 = disable * * Returns: 0 on success, -1 on failure @@ -122,38 +123,38 @@ wpa_driver_wifi_set_wpa_ie(const char *ifname, * allow wpa_supplicant to control roaming). */ static int -wpa_driver_wifi_set_wpa(const char *ifname, boolean_t enabled) +wpa_driver_wifi_set_wpa(datalink_id_t linkid, boolean_t enabled) { - int ret; + dladm_status_t status; wpa_printf(MSG_DEBUG, "wpa_driver_wifi_set_wpa: enable=%d", enabled); - if (!enabled && wpa_driver_wifi_set_wpa_ie(ifname, NULL, 0) < 0) + if (!enabled && wpa_driver_wifi_set_wpa_ie(linkid, NULL, 0) < 0) return (-1); - ret = dladm_wlan_wpa_set_wpa(ifname, enabled); + status = dladm_wlan_wpa_set_wpa(linkid, enabled); - return (WPA_STATUS(ret)); + return (WPA_STATUS(status)); } static int -wpa_driver_wifi_del_key(const char *ifname, int key_idx, unsigned char *addr) +wpa_driver_wifi_del_key(datalink_id_t linkid, int key_idx, unsigned char *addr) { - int ret; + dladm_status_t status; dladm_wlan_bssid_t bss; wpa_printf(MSG_DEBUG, "%s: id=%d", "wpa_driver_wifi_del_key", key_idx); (void) memcpy(bss.wb_bytes, addr, DLADM_WLAN_BSSID_LEN); - ret = dladm_wlan_wpa_del_key(ifname, key_idx, &bss); + status = dladm_wlan_wpa_del_key(linkid, key_idx, &bss); - return (WPA_STATUS(ret)); + return (WPA_STATUS(status)); } /* * set_key - configure encryption key - * @ifname: interface name, e.g., wlan0 + * @linkid: linkid of the given interface * @alg: encryption algorithm (%WPA_ALG_NONE, %WPA_ALG_WEP, * %WPA_ALG_TKIP, %WPA_ALG_CCMP); %WPA_ALG_NONE clears the key. * @addr: address of the peer STA or ff:ff:ff:ff:ff:ff for @@ -185,19 +186,18 @@ wpa_driver_wifi_del_key(const char *ifname, int key_idx, unsigned char *addr) * configuration. */ static int -wpa_driver_wifi_set_key(const char *ifname, wpa_alg alg, - unsigned char *addr, int key_idx, - boolean_t set_tx, uint8_t *seq, uint32_t seq_len, - uint8_t *key, uint32_t key_len) +wpa_driver_wifi_set_key(datalink_id_t linkid, wpa_alg alg, + unsigned char *addr, int key_idx, boolean_t set_tx, uint8_t *seq, + uint32_t seq_len, uint8_t *key, uint32_t key_len) { char *alg_name; dladm_wlan_cipher_t cipher; dladm_wlan_bssid_t bss; - int ret; + dladm_status_t status; wpa_printf(MSG_DEBUG, "%s", "wpa_driver_wifi_set_key"); if (alg == WPA_ALG_NONE) - return (wpa_driver_wifi_del_key(ifname, key_idx, addr)); + return (wpa_driver_wifi_del_key(linkid, key_idx, addr)); switch (alg) { case WPA_ALG_WEP: @@ -230,36 +230,36 @@ wpa_driver_wifi_set_key(const char *ifname, wpa_alg alg, } (void) memcpy(bss.wb_bytes, addr, DLADM_WLAN_BSSID_LEN); - ret = dladm_wlan_wpa_set_key(ifname, cipher, &bss, set_tx, + status = dladm_wlan_wpa_set_key(linkid, cipher, &bss, set_tx, *(uint64_t *)seq, key_idx, key, key_len); - return (WPA_STATUS(ret)); + return (WPA_STATUS(status)); } /* * disassociate - request driver to disassociate - * @ifname: interface name, e.g., wlan0 + * @linkid: linkid of the given interface * @reason_code: 16-bit reason code to be sent in the disassociation * frame * * Return: 0 on success, -1 on failure */ static int -wpa_driver_wifi_disassociate(const char *ifname, int reason_code) +wpa_driver_wifi_disassociate(datalink_id_t linkid, int reason_code) { - int ret; + dladm_status_t status; wpa_printf(MSG_DEBUG, "wpa_driver_wifi_disassociate"); - ret = dladm_wlan_wpa_set_mlme(ifname, DLADM_WLAN_MLME_DISASSOC, + status = dladm_wlan_wpa_set_mlme(linkid, DLADM_WLAN_MLME_DISASSOC, reason_code, NULL); - return (WPA_STATUS(ret)); + return (WPA_STATUS(status)); } /* * associate - request driver to associate - * @ifname: interface name, e.g., wlan0 + * @linkid: linkid of the given interface * @bssid: BSSID of the selected AP * @wpa_ie: WPA information element to be included in (Re)Association * Request (including information element id and length). Use of @@ -277,10 +277,10 @@ wpa_driver_wifi_disassociate(const char *ifname, int reason_code) * Return: 0 on success, -1 on failure */ static int -wpa_driver_wifi_associate(const char *ifname, const char *bssid, +wpa_driver_wifi_associate(datalink_id_t linkid, const char *bssid, uint8_t *wpa_ie, uint32_t wpa_ie_len) { - int ret; + dladm_status_t status; dladm_wlan_bssid_t bss; wpa_printf(MSG_DEBUG, "wpa_driver_wifi_associate : " @@ -291,19 +291,19 @@ wpa_driver_wifi_associate(const char *ifname, const char *bssid, * this is implied by the bssid which is used to locate * the scanned node state which holds it. */ - if (wpa_driver_wifi_set_wpa_ie(ifname, wpa_ie, wpa_ie_len) < 0) + if (wpa_driver_wifi_set_wpa_ie(linkid, wpa_ie, wpa_ie_len) < 0) return (-1); (void) memcpy(bss.wb_bytes, bssid, DLADM_WLAN_BSSID_LEN); - ret = dladm_wlan_wpa_set_mlme(ifname, DLADM_WLAN_MLME_ASSOC, + status = dladm_wlan_wpa_set_mlme(linkid, DLADM_WLAN_MLME_ASSOC, 0, &bss); - return (WPA_STATUS(ret)); + return (WPA_STATUS(status)); } /* * scan - request the driver to initiate scan - * @ifname: interface name, e.g., wlan0 + * @linkid: linkid of the given interface * * Return: 0 on success, -1 on failure * @@ -312,9 +312,9 @@ wpa_driver_wifi_associate(const char *ifname, const char *bssid, * results with wpa_driver_get_scan_results(). */ static int -wpa_driver_wifi_scan(const char *ifname) +wpa_driver_wifi_scan(datalink_id_t linkid) { - int ret; + dladm_status_t status; wpa_printf(MSG_DEBUG, "%s", "wpa_driver_wifi_scan"); /* @@ -322,18 +322,18 @@ wpa_driver_wifi_scan(const char *ifname) * to get ieee80211_begin_scan called. We really want to scan w/o * altering the current state but that's not possible right now. */ - (void) wpa_driver_wifi_disassociate(ifname, + (void) wpa_driver_wifi_disassociate(linkid, DLADM_WLAN_REASON_DISASSOC_LEAVING); - ret = dladm_wlan_scan(ifname, NULL, NULL); + status = dladm_wlan_scan(linkid, NULL, NULL); wpa_printf(MSG_DEBUG, "%s: return", "wpa_driver_wifi_scan"); - return (WPA_STATUS(ret)); + return (WPA_STATUS(status)); } /* * get_scan_results - fetch the latest scan results - * @ifname: interface name, e.g., wlan0 + * @linkid: linkid of the given interface * @results: pointer to buffer for scan results * @max_size: maximum number of entries (buffer size) * @@ -344,15 +344,15 @@ wpa_driver_wifi_scan(const char *ifname) * buffer. */ int -wpa_driver_wifi_get_scan_results(const char *ifname, +wpa_driver_wifi_get_scan_results(datalink_id_t linkid, dladm_wlan_ess_t *results, uint32_t max_size) { uint_t ret; - wpa_printf(MSG_DEBUG, "%s: interface name =%s max size=%d\n", - "wpa_driver_wifi_get_scan_results", ifname, max_size); + wpa_printf(MSG_DEBUG, "%s: max size=%d\n", + "wpa_driver_wifi_get_scan_results", max_size); - if (dladm_wlan_wpa_get_sr(ifname, results, max_size, &ret) + if (dladm_wlan_wpa_get_sr(linkid, results, max_size, &ret) != DLADM_STATUS_OK) { return (-1); } diff --git a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa.c b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa.c index 7a7fbed6a8..999e80cfb1 100644 --- a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa.c +++ b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa.c @@ -1,5 +1,5 @@ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -760,13 +760,13 @@ wpa_supplicant_get_ssid(struct wpa_supplicant *wpa_s) uint8_t bssid[IEEE80211_ADDR_LEN]; (void) memset(ssid, 0, MAX_ESSID_LENGTH); - ssid_len = wpa_s->driver->get_ssid(wpa_s->ifname, (char *)ssid); + ssid_len = wpa_s->driver->get_ssid(wpa_s->linkid, (char *)ssid); if (ssid_len < 0) { wpa_printf(MSG_WARNING, "Could not read SSID from driver."); return (NULL); } - if (wpa_s->driver->get_bssid(wpa_s->ifname, (char *)bssid) < 0) { + if (wpa_s->driver->get_bssid(wpa_s->linkid, (char *)bssid) < 0) { wpa_printf(MSG_WARNING, "Could not read BSSID from driver."); return (NULL); } @@ -814,7 +814,7 @@ wpa_supplicant_key_request(struct wpa_supplicant *wpa_s, else ver = WPA_KEY_INFO_TYPE_HMAC_MD5_RC4; - if (wpa_s->driver->get_bssid(wpa_s->ifname, (char *)bssid) < 0) { + if (wpa_s->driver->get_bssid(wpa_s->linkid, (char *)bssid) < 0) { wpa_printf(MSG_WARNING, "Failed to read BSSID for EAPOL-Key " "request"); return; @@ -838,7 +838,7 @@ wpa_supplicant_key_request(struct wpa_supplicant *wpa_s, reply = (struct wpa_eapol_key *)(hdr + 1); reply->type = wpa_s->proto == WPA_PROTO_RSN ? - EAPOL_KEY_TYPE_RSN : EAPOL_KEY_TYPE_WPA; + EAPOL_KEY_TYPE_RSN : EAPOL_KEY_TYPE_WPA; key_info = WPA_KEY_INFO_REQUEST | ver; if (wpa_s->ptk_set) key_info |= WPA_KEY_INFO_MIC; @@ -849,7 +849,7 @@ wpa_supplicant_key_request(struct wpa_supplicant *wpa_s, reply->key_info = BE_16(key_info); reply->key_length = 0; (void) memcpy(reply->replay_counter, wpa_s->request_counter, - WPA_REPLAY_COUNTER_LEN); + WPA_REPLAY_COUNTER_LEN); inc_byte_array(wpa_s->request_counter, WPA_REPLAY_COUNTER_LEN); reply->key_data_length = BE_16(0); @@ -908,10 +908,10 @@ wpa_supplicant_process_1_of_4(struct wpa_supplicant *wpa_s, break; } if (pos[0] == GENERIC_INFO_ELEM && - pos + 1 + RSN_SELECTOR_LEN < end && - pos[1] >= RSN_SELECTOR_LEN + PMKID_LEN && - memcmp(pos + 2, RSN_KEY_DATA_PMKID, - RSN_SELECTOR_LEN) == 0) { + pos + 1 + RSN_SELECTOR_LEN < end && + pos[1] >= RSN_SELECTOR_LEN + PMKID_LEN && + memcmp(pos + 2, RSN_KEY_DATA_PMKID, + RSN_SELECTOR_LEN) == 0) { pmkid = pos + 2 + RSN_SELECTOR_LEN; wpa_hexdump(MSG_DEBUG, "RSN: PMKID from " "Authenticator", pmkid, PMKID_LEN); @@ -949,12 +949,11 @@ wpa_supplicant_process_1_of_4(struct wpa_supplicant *wpa_s, reply = (struct wpa_eapol_key *)(hdr + 1); reply->type = wpa_s->proto == WPA_PROTO_RSN ? - EAPOL_KEY_TYPE_RSN : EAPOL_KEY_TYPE_WPA; - reply->key_info = BE_16(ver | WPA_KEY_INFO_KEY_TYPE | - WPA_KEY_INFO_MIC); + EAPOL_KEY_TYPE_RSN : EAPOL_KEY_TYPE_WPA; + reply->key_info = BE_16(ver | WPA_KEY_INFO_KEY_TYPE | WPA_KEY_INFO_MIC); reply->key_length = key->key_length; (void) memcpy(reply->replay_counter, key->replay_counter, - WPA_REPLAY_COUNTER_LEN); + WPA_REPLAY_COUNTER_LEN); reply->key_data_length = BE_16(wpa_ie_len); (void) memcpy(reply + 1, wpa_ie, wpa_ie_len); @@ -986,7 +985,7 @@ wpa_supplicant_process_1_of_4(struct wpa_supplicant *wpa_s, (void) memcpy(ptk->u.auth.rx_mic_key, buf, 8); wpa_s->tptk_set = 1; wpa_eapol_key_mic(wpa_s->tptk.mic_key, ver, (uint8_t *)hdr, - rlen - sizeof (*ethhdr), reply->key_mic); + rlen - sizeof (*ethhdr), reply->key_mic); wpa_hexdump(MSG_DEBUG, "WPA: EAPOL-Key MIC", reply->key_mic, 16); wpa_printf(MSG_DEBUG, "WPA: Sending EAPOL-Key 2/4"); @@ -1080,23 +1079,21 @@ wpa_supplicant_process_3_of_4_gtk(struct wpa_supplicant *wpa_s, (void) memcpy(gtk + 24, tmpbuf, 8); } if (wpa_s->pairwise_cipher == WPA_CIPHER_NONE) { - if (wpa_s->driver->set_key(wpa_s->ifname, alg, + if (wpa_s->driver->set_key(wpa_s->linkid, alg, (uint8_t *)"\xff\xff\xff\xff\xff\xff", keyidx, 1, key->key_rsc, key_rsc_len, gtk, gtk_len) < 0) wpa_printf(MSG_WARNING, "WPA: Failed to set " "GTK to the driver (Group only)."); - } else if (wpa_s->driver->set_key(wpa_s->ifname, alg, - (uint8_t *)"\xff\xff\xff\xff\xff\xff", - keyidx, tx, - key->key_rsc, key_rsc_len, - gtk, gtk_len) < 0) { + } else if (wpa_s->driver->set_key(wpa_s->linkid, alg, + (uint8_t *)"\xff\xff\xff\xff\xff\xff", keyidx, tx, + key->key_rsc, key_rsc_len, gtk, gtk_len) < 0) { wpa_printf(MSG_WARNING, "WPA: Failed to set GTK to " "the driver."); } wpa_printf(MSG_INFO, "WPA: Key negotiation completed with " - MACSTR, MAC2STR(src_addr)); + MACSTR, MAC2STR(src_addr)); eloop_cancel_timeout(wpa_supplicant_scan, wpa_s, NULL); wpa_supplicant_cancel_auth_timeout(wpa_s); wpa_s->wpa_state = WPA_COMPLETED; @@ -1136,10 +1133,10 @@ wpa_supplicant_process_3_of_4(struct wpa_supplicant *wpa_s, ie = pos; ie_len = pos[1] + 2; } else if (pos[0] == GENERIC_INFO_ELEM && - pos + 1 + RSN_SELECTOR_LEN < end && - pos[1] > RSN_SELECTOR_LEN + 2 && - memcmp(pos + 2, RSN_KEY_DATA_GROUPKEY, - RSN_SELECTOR_LEN) == 0) { + pos + 1 + RSN_SELECTOR_LEN < end && + pos[1] > RSN_SELECTOR_LEN + 2 && + memcmp(pos + 2, RSN_KEY_DATA_GROUPKEY, + RSN_SELECTOR_LEN) == 0) { if (!(key_info & WPA_KEY_INFO_ENCR_KEY_DATA)) { wpa_printf(MSG_WARNING, "WPA: GTK IE " "in unencrypted key data"); @@ -1165,7 +1162,7 @@ wpa_supplicant_process_3_of_4(struct wpa_supplicant *wpa_s, if (wpa_s->ap_wpa_ie && (wpa_s->ap_wpa_ie_len != ie_len || - memcmp(wpa_s->ap_wpa_ie, ie, ie_len) != 0)) { + memcmp(wpa_s->ap_wpa_ie, ie, ie_len) != 0)) { wpa_printf(MSG_WARNING, "WPA: WPA IE in 3/4 msg does not match" " with WPA IE in Beacon/ProbeResp (src=" MACSTR ")", MAC2STR(src_addr)); @@ -1222,13 +1219,12 @@ wpa_supplicant_process_3_of_4(struct wpa_supplicant *wpa_s, reply = (struct wpa_eapol_key *)(hdr + 1); reply->type = wpa_s->proto == WPA_PROTO_RSN ? - EAPOL_KEY_TYPE_RSN : EAPOL_KEY_TYPE_WPA; + EAPOL_KEY_TYPE_RSN : EAPOL_KEY_TYPE_WPA; reply->key_info = BE_16(ver | WPA_KEY_INFO_KEY_TYPE | - WPA_KEY_INFO_MIC | - (key_info & WPA_KEY_INFO_SECURE)); + WPA_KEY_INFO_MIC | (key_info & WPA_KEY_INFO_SECURE)); reply->key_length = key->key_length; (void) memcpy(reply->replay_counter, key->replay_counter, - WPA_REPLAY_COUNTER_LEN); + WPA_REPLAY_COUNTER_LEN); reply->key_data_length = BE_16(0); @@ -1279,7 +1275,7 @@ wpa_supplicant_process_3_of_4(struct wpa_supplicant *wpa_s, wpa_hexdump(MSG_DEBUG, "WPA: RSC", key_rsc, rsclen); } - if (wpa_s->driver->set_key(wpa_s->ifname, alg, src_addr, + if (wpa_s->driver->set_key(wpa_s->linkid, alg, src_addr, 0, 1, key_rsc, rsclen, (uint8_t *)&wpa_s->ptk.tk1, keylen) < 0) { wpa_printf(MSG_WARNING, "WPA: Failed to set PTK to the" @@ -1342,9 +1338,9 @@ wpa_supplicant_process_1_of_2(struct wpa_supplicant *wpa_s, gtk_ie = pos + 2 + RSN_SELECTOR_LEN; gtk_ie_len = pos[1] - RSN_SELECTOR_LEN; break; - } else if (pos[0] == GENERIC_INFO_ELEM && - pos[1] == 0) + } else if (pos[0] == GENERIC_INFO_ELEM && pos[1] == 0) { break; + } pos += 2 + pos[1]; } @@ -1423,7 +1419,7 @@ wpa_supplicant_process_1_of_2(struct wpa_supplicant *wpa_s, (void) memcpy(gtk, gtk_ie + 2, gtk_ie_len - 2); } else { keyidx = (key_info & WPA_KEY_INFO_KEY_INDEX_MASK) >> - WPA_KEY_INFO_KEY_INDEX_SHIFT; + WPA_KEY_INFO_KEY_INDEX_SHIFT; if (ver == WPA_KEY_INFO_TYPE_HMAC_MD5_RC4) { (void) memcpy(ek, key->key_iv, 16); (void) memcpy(ek + 16, wpa_s->ptk.encr_key, 16); @@ -1436,7 +1432,7 @@ wpa_supplicant_process_1_of_2(struct wpa_supplicant *wpa_s, return; } if (aes_unwrap(wpa_s->ptk.encr_key, maxkeylen / 8, - (uint8_t *)(key + 1), gtk)) { + (uint8_t *)(key + 1), gtk)) { wpa_printf(MSG_WARNING, "WPA: AES unwrap " "failed - could not decrypt GTK"); return; @@ -1470,13 +1466,13 @@ wpa_supplicant_process_1_of_2(struct wpa_supplicant *wpa_s, (void) memcpy(gtk + 24, tmpbuf, 8); } if (wpa_s->pairwise_cipher == WPA_CIPHER_NONE) { - if (wpa_s->driver->set_key(wpa_s->ifname, alg, + if (wpa_s->driver->set_key(wpa_s->linkid, alg, (uint8_t *)"\xff\xff\xff\xff\xff\xff", keyidx, 1, key->key_rsc, key_rsc_len, gtk, keylen) < 0) wpa_printf(MSG_WARNING, "WPA: Failed to set GTK to the" " driver (Group only)."); - } else if (wpa_s->driver->set_key(wpa_s->ifname, alg, + } else if (wpa_s->driver->set_key(wpa_s->linkid, alg, (uint8_t *)"\xff\xff\xff\xff\xff\xff", keyidx, tx, key->key_rsc, key_rsc_len, @@ -1730,9 +1726,10 @@ wpa_sm_rx_eapol(struct wpa_supplicant *wpa_s, } if ((key_info & WPA_KEY_INFO_MIC) && - wpa_supplicant_verify_eapol_key_mic(wpa_s, key, ver, buf, - data_len)) + wpa_supplicant_verify_eapol_key_mic(wpa_s, key, ver, buf, + data_len)) { return; + } extra_len = data_len - sizeof (*hdr) - sizeof (*key); diff --git a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_impl.h b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_impl.h index e5e6f8f808..7745ec1c7f 100644 --- a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_impl.h +++ b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_impl.h @@ -1,5 +1,5 @@ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -14,6 +14,7 @@ #pragma ident "%Z%%M% %I% %E% SMI" #include +#include #ifdef __cplusplus extern "C" { @@ -164,7 +165,7 @@ struct wpa_supplicant { struct l2_packet_data *l2; unsigned char own_addr[IEEE80211_ADDR_LEN]; - char ifname[WPA_STRSIZE]; + datalink_id_t linkid; char kname[WPA_STRSIZE]; uint8_t pmk[PMK_LEN]; diff --git a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_supplicant.c b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_supplicant.c index 270b9133ed..06663383f7 100644 --- a/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_supplicant.c +++ b/usr/src/cmd/cmd-inet/usr.lib/wpad/wpa_supplicant.c @@ -1,5 +1,5 @@ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -141,7 +141,7 @@ wpa_supplicant_scan(void *eloop_ctx, void *timeout_ctx) wpa_printf(MSG_DEBUG, "Scan SSID: %s", ssid->ssid); } - if (wpa_s->driver->scan(wpa_s->ifname)) { + if (wpa_s->driver->scan(wpa_s->linkid)) { wpa_printf(MSG_WARNING, "Failed to initiate AP scan."); } } @@ -213,16 +213,16 @@ wpa_supplicant_cleanup(struct wpa_supplicant *wpa_s) static void wpa_clear_keys(struct wpa_supplicant *wpa_s, uint8_t *addr) { - wpa_s->driver->set_key(wpa_s->ifname, WPA_ALG_NONE, + wpa_s->driver->set_key(wpa_s->linkid, WPA_ALG_NONE, (uint8_t *)"\xff\xff\xff\xff\xff\xff", 0, 0, NULL, 0, NULL, 0); - wpa_s->driver->set_key(wpa_s->ifname, WPA_ALG_NONE, + wpa_s->driver->set_key(wpa_s->linkid, WPA_ALG_NONE, (uint8_t *)"\xff\xff\xff\xff\xff\xff", 1, 0, NULL, 0, NULL, 0); - wpa_s->driver->set_key(wpa_s->ifname, WPA_ALG_NONE, + wpa_s->driver->set_key(wpa_s->linkid, WPA_ALG_NONE, (uint8_t *)"\xff\xff\xff\xff\xff\xff", 2, 0, NULL, 0, NULL, 0); - wpa_s->driver->set_key(wpa_s->ifname, WPA_ALG_NONE, + wpa_s->driver->set_key(wpa_s->linkid, WPA_ALG_NONE, (uint8_t *)"\xff\xff\xff\xff\xff\xff", 3, 0, NULL, 0, NULL, 0); if (addr) { - wpa_s->driver->set_key(wpa_s->ifname, WPA_ALG_NONE, addr, + wpa_s->driver->set_key(wpa_s->linkid, WPA_ALG_NONE, addr, 0, 0, NULL, 0, NULL, 0); } } @@ -357,7 +357,7 @@ static void wpa_supplicant_associate(struct wpa_supplicant *wpa_s, wpa_clear_keys(wpa_s, bss->we_bssid.wb_bytes); wpa_s->wpa_state = WPA_ASSOCIATING; - wpa_s->driver->associate(wpa_s->ifname, + wpa_s->driver->associate(wpa_s->linkid, (const char *)bss->we_bssid.wb_bytes, wpa_ie, wpa_ie_len); /* Timeout for IEEE 802.11 authentication and association */ @@ -371,7 +371,7 @@ wpa_supplicant_disassociate(struct wpa_supplicant *wpa_s, int reason_code) wpa_s->wpa_state = WPA_DISCONNECTED; if (memcmp(wpa_s->bssid, "\x00\x00\x00\x00\x00\x00", IEEE80211_ADDR_LEN) != 0) { - wpa_s->driver->disassociate(wpa_s->ifname, reason_code); + wpa_s->driver->disassociate(wpa_s->linkid, reason_code); addr = wpa_s->bssid; } wpa_clear_keys(wpa_s, addr); @@ -453,7 +453,7 @@ wpa_supplicant_scan_results(struct wpa_supplicant *wpa_s) struct wpa_ssid *ssid; (void) memset(results, 0, sizeof (dladm_wlan_ess_t) * MAX_SCANRESULTS); - num = wpa_s->driver->get_scan_results(wpa_s->ifname, results, + num = wpa_s->driver->get_scan_results(wpa_s->linkid, results, MAX_SCANRESULTS); wpa_printf(MSG_DEBUG, "Scan results: %d", num); if (num < 0) @@ -506,7 +506,7 @@ wpa_event_handler(void *cookie, wpa_event_type event) WPA_REPLAY_COUNTER_LEN); wpa_s->rx_replay_counter_set = 0; wpa_s->renew_snonce = 1; - if (wpa_s->driver->get_bssid(wpa_s->ifname, + if (wpa_s->driver->get_bssid(wpa_s->linkid, (char *)bssid) >= 0 && memcmp(bssid, wpa_s->bssid, IEEE80211_ADDR_LEN) != 0) { wpa_printf(MSG_DEBUG, "Associated to a new BSS: " @@ -550,9 +550,9 @@ wpa_supplicant_terminate(int sig, void *eloop_ctx, void *signal_ctx) } static int -wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s) +wpa_supplicant_driver_init(const char *link, struct wpa_supplicant *wpa_s) { - wpa_s->l2 = l2_packet_init(wpa_s->ifname, ETHERTYPE_EAPOL, + wpa_s->l2 = l2_packet_init(link, ETHERTYPE_EAPOL, wpa_supplicant_rx_eapol, wpa_s); if (wpa_s->l2 == NULL) return (-1); @@ -562,7 +562,7 @@ wpa_supplicant_driver_init(struct wpa_supplicant *wpa_s) return (-1); } - if (wpa_s->driver->set_wpa(wpa_s->ifname, 1) < 0) { + if (wpa_s->driver->set_wpa(wpa_s->linkid, 1) < 0) { wpa_printf(MSG_ERROR, "Failed to enable WPA in the driver."); return (-1); } @@ -641,6 +641,9 @@ wpa_supplicant_door_destroy(char *doorname) { wpa_printf(MSG_DEBUG, "wpa_supplicant_door_destroy(%s)\n", doorname); + if (door_id == -1) + return; + if (door_revoke(door_id) == -1) { wpa_printf(MSG_ERROR, "failed to door_revoke(%d) %s, exiting.", door_id, strerror(errno)); @@ -701,13 +704,13 @@ wpa_config_read_network(struct wpa_supplicant *wpa_s) ssid->key_mgmt = WPA_KEY_MGMT_PSK; /* | WPA_KEY_MGMT_IEEE8021X; */ (void) memset(buf, 0, MAX_ESSID_LENGTH + 1); - wpa_s->driver->get_ssid(wpa_s->ifname, (char *)buf); + wpa_s->driver->get_ssid(wpa_s->linkid, (char *)buf); (void) wpa_config_parse_ssid(ssid, 0, buf); key_len = sizeof (psk); (void) dladm_get_secobj((const char *)wpa_s->kname, &cl, psk, &key_len, - DLADM_OPT_TEMP); + DLADM_OPT_ACTIVE); psk[key_len] = '\0'; ssid->passphrase = strdup((const char *)psk); @@ -760,9 +763,11 @@ wpa_config_free(struct wpa_config *config) { struct wpa_ssid *ssid = config->ssid; - free(ssid->ssid); - free(ssid->passphrase); - free(ssid); + if (ssid != NULL) { + free(ssid->ssid); + free(ssid->passphrase); + free(ssid); + } free(config); } @@ -798,13 +803,12 @@ static void usage(void) { (void) printf("%s\n\n" - "usage:\n" - " wpa_supplicant [-hv] -i -k" - "\n" - "options:\n" - " -h = show this help text\n" - " -v = show version\n", - wpa_supplicant_version); + "usage:\n" + " wpa_supplicant [-hv] -i -k\n" + "options:\n" + " -h = show this help text\n" + " -v = show version\n", + wpa_supplicant_version); } int @@ -813,12 +817,13 @@ main(int argc, char *argv[]) struct wpa_supplicant wpa_s; char *link = NULL; char *key = NULL; + dlpi_handle_t dh = NULL; + datalink_id_t linkid; + dladm_phys_attr_t dpa; int c; int exitcode; char door_file[WPA_STRSIZE]; - (void) memset(&wpa_s, 0, sizeof (wpa_s)); - for (;;) { c = getopt(argc, argv, "Dk:hi:v"); if (c < 0) @@ -845,8 +850,6 @@ main(int argc, char *argv[]) } } - wpa_s.driver = &wpa_driver_wifi_ops; - eloop_init(&wpa_s); /* * key name is required to retrieve PSK value through libwdladm APIs. * key is saved by dladm command by keyname @@ -857,22 +860,48 @@ main(int argc, char *argv[]) return (-1); } - if ((strlen(link) >= sizeof (wpa_s.ifname)) || - (strlen(key) >= sizeof (wpa_s.kname))) { - wpa_printf(MSG_ERROR, "Too long link/key name '%s', '%s'.", - link, key); + if ((strlen(key) >= sizeof (wpa_s.kname))) { + wpa_printf(MSG_ERROR, "Too long key name '%s'.", key); return (-1); } - (void) strlcpy(wpa_s.ifname, link, sizeof (wpa_s.ifname)); - (void) strlcpy(wpa_s.kname, key, sizeof (wpa_s.kname)); + if (daemon(0, 0)) + return (-1); /* - * Setup door file to communicate with driver - * Since this is multiple instance service, different instance - * has different doors. + * Hold this link open to prevent a link renaming operation. */ - (void) snprintf(door_file, WPA_STRSIZE, "%s_%s", WPA_DOOR, link); + if (dlpi_open(link, &dh, 0) != DLPI_SUCCESS) { + wpa_printf(MSG_ERROR, "Failed to open link '%s'.", link); + return (-1); + } + + if (dladm_name2info(link, &linkid, NULL, NULL, NULL) != + DLADM_STATUS_OK) { + wpa_printf(MSG_ERROR, "Invalid link name '%s'.", link); + dlpi_close(dh); + return (-1); + } + + /* + * Get the device name of the link, which will be used as the door + * file name used to communicate with the driver. Note that different + * links use different doors. + */ + if (dladm_phys_info(linkid, &dpa, DLADM_OPT_ACTIVE) != + DLADM_STATUS_OK) { + wpa_printf(MSG_ERROR, + "Failed to get device name of link '%s'.", link); + dlpi_close(dh); + return (-1); + } + (void) snprintf(door_file, WPA_STRSIZE, "%s_%s", WPA_DOOR, dpa.dp_dev); + + (void) memset(&wpa_s, 0, sizeof (wpa_s)); + wpa_s.driver = &wpa_driver_wifi_ops; + wpa_s.linkid = linkid; + (void) strlcpy(wpa_s.kname, key, sizeof (wpa_s.kname)); + eloop_init(&wpa_s); /* * Setup default WPA/WPA2 configuration @@ -881,16 +910,15 @@ main(int argc, char *argv[]) wpa_s.conf = wpa_config_read(&wpa_s); if (wpa_s.conf == NULL || wpa_s.conf->ssid == NULL) { wpa_printf(MSG_ERROR, "\nNo networks (SSID) configured.\n"); - return (-1); - } - - exitcode = 0; - - if (daemon(0, 0)) { exitcode = -1; goto cleanup; } + exitcode = 0; + + /* + * Setup door file to communicate with driver + */ if (wpa_supplicant_door_setup(&wpa_s, door_file) != 0) { wpa_printf(MSG_ERROR, "Failed to setup door(%s)", door_file); exitcode = -1; @@ -898,11 +926,18 @@ main(int argc, char *argv[]) } wpa_s.renew_snonce = 1; - if (wpa_supplicant_driver_init(&wpa_s) < 0) { + if (wpa_supplicant_driver_init(link, &wpa_s) < 0) { exitcode = -1; goto cleanup; } + /* + * This link is hold again in wpa_supplicant_driver_init(), so that + * we release the first reference. + */ + dlpi_close(dh); + dh = NULL; + wpa_printf(MSG_DEBUG, "=> eloop_run"); (void) eloop_register_signal(SIGINT, wpa_supplicant_terminate, NULL); @@ -914,14 +949,17 @@ main(int argc, char *argv[]) wpa_printf(MSG_DEBUG, "<= eloop_run()"); wpa_supplicant_disassociate(&wpa_s, REASON_DEAUTH_LEAVING); -cleanup: - if (wpa_s.driver->set_wpa(wpa_s.ifname, 0) < 0) { + if (wpa_s.driver->set_wpa(wpa_s.linkid, 0) < 0) { wpa_printf(MSG_ERROR, "Failed to disable WPA in the driver.\n"); } +cleanup: wpa_supplicant_door_destroy(door_file); wpa_supplicant_cleanup(&wpa_s); eloop_destroy(); + if (dh != NULL) + dlpi_close(dh); + return (exitcode); } diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/Makefile index 3011207150..4924d2fe4e 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/Makefile +++ b/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/Makefile @@ -19,7 +19,7 @@ # CDDL HEADER END # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -39,7 +39,7 @@ COMMONSRCS= $(CMDINETCOMMONDIR)/$(COMMONOBJS:%.o=%.c) SRCS= $(LOCALSRCS) $(COMMONSRCS) CPPFLAGS += -I$(CMDINETCOMMONDIR) -I$(SRC)/common/net/dhcp -LDLIBS += -ldevinfo -ldhcpagent -linetcfg -ldlpi +LDLIBS += -ldhcpagent -linetcfg -ldlpi LINTFLAGS += -m ROOTUSRSBINLINKS = $(PROG:%=$(ROOTUSRSBIN)/%) diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/defs.h b/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/defs.h index c40dac4648..c993baeb02 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/defs.h +++ b/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/defs.h @@ -1,5 +1,5 @@ /* - * Copyright 2003 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* @@ -17,6 +17,7 @@ extern "C" { #endif +#include #include #include #include @@ -24,7 +25,6 @@ extern "C" { #include #include #include -#include #include #include diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c b/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c index ed8ab462f5..877d275947 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/ifconfig.c @@ -1,5 +1,5 @@ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* @@ -164,7 +164,7 @@ static void in6_configinfo(int force, uint64_t flags); /* * Misc support functions */ -static int devfs_entry(di_node_t node, di_minor_t minor, void *arg); +static boolean_t ni_entry(const char *, void *); static void foreachinterface(void (*func)(), int argc, char *argv[], int af, int64_t onflags, int64_t offflags, int64_t lifc_flags); @@ -490,7 +490,7 @@ foreachinterface(void (*func)(), int argc, char *argv[], int af, /* * Special case: * ifconfig -a plumb should find all network interfaces - * in the machine by traversing the devinfo tree for global zone. + * in the machine for the global zone. * For non-global zones, only find the assigned interfaces. * Also, there is no need to SIOCGLIF* ioctls, since * those interfaces have already been plumbed @@ -1755,8 +1755,7 @@ updownifs(iface_t *ifs, int up) * static int find_all_global_interfaces(struct lifconf *lifcp, char **buf, * int64_t lifc_flags) * - * It finds all interfaces for the global zone, that is all - * the physical interfaces, using the kernel's devinfo tree. + * It finds all data links for the global zone. * * It takes in input a pointer to struct lifconf to receive interfaces * informations, a **char to hold allocated buffer, and a lifc_flags. @@ -1771,23 +1770,10 @@ find_all_global_interfaces(struct lifconf *lifcp, char **buf, { unsigned bufsize; int n; - di_node_t root; ni_t *nip; struct lifreq *lifrp; - /* - * DINFOCACHE is equivalent to DINFOSUBTREE | DINFOMINOR | - * DINFOPROP | DINFOFORCE. - */ - if ((root = di_init("/", DINFOCACHE)) == DI_NODE_NIL) { - (void) fprintf(stderr, "ifconfig: di_init " - "failed; check the devinfo driver.\n"); - exit(1); - } - - (void) di_walk_minor(root, DDI_NT_NET, DI_CHECK_ALIAS, - NULL, devfs_entry); - di_fini(root); + (void) dlpi_walk(ni_entry, NULL, 0); /* * Now, translate the linked list into @@ -4516,7 +4502,7 @@ strioctl(int s, int cmd, char *buf, int buflen) } static void -add_ni(char *name) +add_ni(const char *name) { ni_t **pp; ni_t *p; @@ -4545,35 +4531,18 @@ add_ni(char *name) } /* ARGSUSED2 */ -static int -devfs_entry(di_node_t node, di_minor_t minor, void *arg) +static boolean_t +ni_entry(const char *linkname, void *arg) { - char *provider; - char linkname[DLPI_LINKNAME_MAX]; dlpi_handle_t dh; - provider = di_minor_name(minor); - if (debug > 2) - (void) fprintf(stderr, "provider = %s\n", provider); - - if (dlpi_makelink(linkname, provider, - di_instance(node)) != DLPI_SUCCESS) - return (DI_WALK_CONTINUE); - if (dlpi_open(linkname, &dh, 0) != DLPI_SUCCESS) - return (DI_WALK_CONTINUE); + return (_B_FALSE); - if (di_minor_type(minor) == DDM_ALIAS) { - if (debug > 2) - (void) fprintf(stderr, "alias node, using instance\n"); - add_ni(linkname); - } else { - if (debug > 2) - (void) fprintf(stderr, "non-alias node, ignoring\n"); - } + add_ni(linkname); dlpi_close(dh); - return (DI_WALK_CONTINUE); + return (_B_FALSE); } /* diff --git a/usr/src/cmd/cmd-inet/usr.sbin/in.routed/if.c b/usr/src/cmd/cmd-inet/usr.sbin/in.routed/if.c index 2913f44669..455b4102a4 100644 --- a/usr/src/cmd/cmd-inet/usr.sbin/in.routed/if.c +++ b/usr/src/cmd/cmd-inet/usr.sbin/in.routed/if.c @@ -1,5 +1,5 @@ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * * Copyright (c) 1983, 1993 @@ -1902,7 +1902,12 @@ get_if_kstats(struct interface *ifp, struct phyi_data *newdata) if ((kc = kstat_open()) == NULL) return (-1); - if ((ksp = kstat_lookup(kc, NULL, -1, phyi->phyi_name)) == NULL) { + /* + * First we try to query the "link" kstats in case the link is renamed. + * If that fails, fallback to legacy ktats for those non-GLDv3 links. + */ + if (((ksp = kstat_lookup(kc, "link", 0, phyi->phyi_name)) == NULL) && + ((ksp = kstat_lookup(kc, NULL, -1, phyi->phyi_name)) == NULL)) { (void) kstat_close(kc); return (-1); } diff --git a/usr/src/cmd/devfsadm/devfsadm.c b/usr/src/cmd/devfsadm/devfsadm.c index a5bfeb5fbf..e2dfed2871 100644 --- a/usr/src/cmd/devfsadm/devfsadm.c +++ b/usr/src/cmd/devfsadm/devfsadm.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -7822,7 +7822,7 @@ process_rcm_events(void *arg) static int rcm_init(void) { -#define LIBRCM_PATH "/usr/lib/librcm.so" +#define LIBRCM_PATH "/lib/librcm.so" rcm_handle_t *hdl = NULL; int err; diff --git a/usr/src/cmd/dladm/Makefile b/usr/src/cmd/dladm/Makefile index 881a839ebb..94e6842ff3 100644 --- a/usr/src/cmd/dladm/Makefile +++ b/usr/src/cmd/dladm/Makefile @@ -19,14 +19,14 @@ # CDDL HEADER END # # -# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Copyright 2008 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # #ident "%Z%%M% %I% %E% SMI" # PROG= dladm -CFGFILES= aggregation.conf linkprop.conf secobj.conf +CFGFILES= secobj.conf ROOTFS_PROG= $(PROG) ROOTCFGDIR= $(ROOTETC)/dladm @@ -35,12 +35,11 @@ ROOTCFGFILES= $(CFGFILES:%=$(ROOTCFGDIR)/%) include ../Makefile.cmd XGETFLAGS += -a -x $(PROG).xcl -LDLIBS += -ldladm -ldlpi -lkstat -lsecdb -lbsm -linetutil +LDLIBS += -ldladm -ldlpi -lkstat -lsecdb -lbsm -linetutil -ldevinfo $(ROOTCFGFILES) := OWNER= dladm $(ROOTCFGFILES) := GROUP= sys -$(ROOTCFGDIR)/aggregation.conf $(ROOTCFGDIR)/linkprop.conf := FILEMODE= 644 $(ROOTCFGDIR)/secobj.conf := FILEMODE= 600 .KEEP_STATE: diff --git a/usr/src/cmd/dladm/aggregation.conf b/usr/src/cmd/dladm/aggregation.conf deleted file mode 100644 index 5cb5189578..0000000000 --- a/usr/src/cmd/dladm/aggregation.conf +++ /dev/null @@ -1,31 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. -# Use is subject to license terms. -# -# ident "%Z%%M% %I% %E% SMI" -# -# DO NOT EDIT OR PARSE THIS FILE! -# -# Use the dladm(1m) command to change the contents of this file. - diff --git a/usr/src/cmd/dladm/dladm.c b/usr/src/cmd/dladm/dladm.c index 17a3d53e6a..22cc5c515e 100644 --- a/usr/src/cmd/dladm/dladm.c +++ b/usr/src/cmd/dladm/dladm.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2008 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -45,18 +46,24 @@ #include #include #include +#include #include #include #include #include +#include +#include #include #include #include -#define AGGR_DRV "aggr" -#define MAXPORT 256 -#define DUMP_LACP_FORMAT " %-9s %-8s %-7s %-12s " \ - "%-5s %-4s %-4s %-9s %-7s\n" +#define AGGR_DRV "aggr" +#define MAXPORT 256 +#define BUFLEN(lim, ptr) (((lim) > (ptr)) ? ((lim) - (ptr)) : 0) +#define MAXLINELEN 1024 +#define SMF_UPGRADE_FILE "/var/svc/profile/upgrade" +#define SMF_UPGRADEDATALINK_FILE "/var/svc/profile/upgrade_datalink" +#define SMF_DLADM_UPGRADE_MSG " # added by dladm(1M)" typedef struct pktsum_s { uint64_t ipackets; @@ -67,54 +74,56 @@ typedef struct pktsum_s { uint32_t oerrors; } pktsum_t; -typedef struct show_link_state { +typedef struct show_state { boolean_t ls_firstonly; boolean_t ls_donefirst; - boolean_t ls_stats; pktsum_t ls_prevstats; boolean_t ls_parseable; -} show_link_state_t; + uint32_t ls_flags; + dladm_status_t ls_status; +} show_state_t; typedef struct show_grp_state { - uint32_t gs_key; boolean_t gs_lacp; - boolean_t gs_found; + boolean_t gs_extended; boolean_t gs_stats; boolean_t gs_firstonly; + boolean_t gs_donefirst; pktsum_t gs_prevstats[MAXPORT]; boolean_t gs_parseable; + uint32_t gs_flags; + dladm_status_t gs_status; } show_grp_state_t; -typedef struct show_mac_state { - boolean_t ms_firstonly; - boolean_t ms_donefirst; - pktsum_t ms_prevstats; - boolean_t ms_parseable; -} show_mac_state_t; - -typedef void cmdfunc_t(int, char **); +typedef void cmdfunc_t(int, char **); -static cmdfunc_t do_show_link, do_show_dev, do_show_wifi; +static cmdfunc_t do_show_link, do_show_dev, do_show_wifi, do_show_phys; static cmdfunc_t do_create_aggr, do_delete_aggr, do_add_aggr, do_remove_aggr; -static cmdfunc_t do_modify_aggr, do_show_aggr, do_up_aggr, do_down_aggr; +static cmdfunc_t do_modify_aggr, do_show_aggr, do_up_aggr; static cmdfunc_t do_scan_wifi, do_connect_wifi, do_disconnect_wifi; static cmdfunc_t do_show_linkprop, do_set_linkprop, do_reset_linkprop; static cmdfunc_t do_create_secobj, do_delete_secobj, do_show_secobj; static cmdfunc_t do_init_linkprop, do_init_secobj; +static cmdfunc_t do_create_vlan, do_delete_vlan, do_up_vlan, do_show_vlan; +static cmdfunc_t do_rename_link, do_delete_phys, do_init_phys; +static cmdfunc_t do_show_linkmap; -static void show_linkprop_onelink(void *, const char *); +static void altroot_cmd(char *, int, char **); +static int show_linkprop_onelink(datalink_id_t, void *); -static void link_stats(const char *, uint_t); -static void aggr_stats(uint32_t, uint_t); +static void link_stats(datalink_id_t, uint_t); +static void aggr_stats(datalink_id_t, show_grp_state_t *, uint_t); static void dev_stats(const char *dev, uint32_t); +static int get_one_kstat(const char *, const char *, uint8_t, + void *, boolean_t); static void get_mac_stats(const char *, pktsum_t *); static void get_link_stats(const char *, pktsum_t *); -static uint64_t mac_ifspeed(const char *); +static uint64_t get_ifspeed(const char *, boolean_t); static void stats_total(pktsum_t *, pktsum_t *, pktsum_t *); static void stats_diff(pktsum_t *, pktsum_t *, pktsum_t *); -static const char *mac_link_state(const char *, char *); -static const char *mac_link_duplex(const char *, char *); +static const char *get_linkstate(const char *, boolean_t, char *); +static const char *get_linkduplex(const char *, boolean_t, char *); static boolean_t str2int(const char *, int *); static void die(const char *, ...); @@ -139,7 +148,6 @@ static cmd_t cmds[] = { { "modify-aggr", do_modify_aggr }, { "show-aggr", do_show_aggr }, { "up-aggr", do_up_aggr }, - { "down-aggr", do_down_aggr }, { "scan-wifi", do_scan_wifi }, { "connect-wifi", do_connect_wifi }, { "disconnect-wifi", do_disconnect_wifi }, @@ -151,50 +159,67 @@ static cmd_t cmds[] = { { "delete-secobj", do_delete_secobj }, { "show-secobj", do_show_secobj }, { "init-linkprop", do_init_linkprop }, - { "init-secobj", do_init_secobj } + { "init-secobj", do_init_secobj }, + { "create-vlan", do_create_vlan }, + { "delete-vlan", do_delete_vlan }, + { "show-vlan", do_show_vlan }, + { "up-vlan", do_up_vlan }, + { "rename-link", do_rename_link }, + { "delete-phys", do_delete_phys }, + { "show-phys", do_show_phys }, + { "init-phys", do_init_phys }, + { "show-linkmap", do_show_linkmap } +}; + +static const struct option lopts[] = { + {"vlan-id", required_argument, 0, 'v'}, + {"dev", required_argument, 0, 'd'}, + {"policy", required_argument, 0, 'P'}, + {"lacp-mode", required_argument, 0, 'L'}, + {"lacp-timer", required_argument, 0, 'T'}, + {"unicast", required_argument, 0, 'u'}, + {"temporary", no_argument, 0, 't'}, + {"root-dir", required_argument, 0, 'R'}, + {"link", required_argument, 0, 'l'}, + {"forcible", no_argument, 0, 'f'}, + { 0, 0, 0, 0 } }; -static const struct option longopts[] = { - {"vlan-id", required_argument, 0, 'v' }, - {"dev", required_argument, 0, 'd' }, - {"policy", required_argument, 0, 'P' }, - {"lacp-mode", required_argument, 0, 'l' }, - {"lacp-timer", required_argument, 0, 'T' }, - {"unicast", required_argument, 0, 'u' }, - {"statistics", no_argument, 0, 's' }, - {"interval", required_argument, 0, 'i' }, - {"lacp", no_argument, 0, 'L' }, - {"temporary", no_argument, 0, 't' }, - {"root-dir", required_argument, 0, 'r' }, - {"parseable", no_argument, 0, 'p' }, +static const struct option show_lopts[] = { + {"statistics", no_argument, 0, 's'}, + {"interval", required_argument, 0, 'i'}, + {"parseable", no_argument, 0, 'p'}, + {"extended", no_argument, 0, 'x'}, + {"persistent", no_argument, 0, 'P'}, + {"lacp", no_argument, 0, 'L'}, { 0, 0, 0, 0 } }; static const struct option prop_longopts[] = { - {"temporary", no_argument, 0, 't' }, - {"root-dir", required_argument, 0, 'R' }, - {"prop", required_argument, 0, 'p' }, - {"parseable", no_argument, 0, 'c' }, - {"persistent", no_argument, 0, 'P' }, + {"temporary", no_argument, 0, 't' }, + {"root-dir", required_argument, 0, 'R' }, + {"prop", required_argument, 0, 'p' }, + {"parseable", no_argument, 0, 'c' }, + {"persistent", no_argument, 0, 'P' }, { 0, 0, 0, 0 } }; static const struct option wifi_longopts[] = { - {"parseable", no_argument, 0, 'p' }, - {"output", required_argument, 0, 'o' }, - {"essid", required_argument, 0, 'e' }, - {"bsstype", required_argument, 0, 'b' }, - {"mode", required_argument, 0, 'm' }, - {"key", required_argument, 0, 'k' }, - {"sec", required_argument, 0, 's' }, - {"auth", required_argument, 0, 'a' }, - {"create-ibss", required_argument, 0, 'c' }, - {"timeout", required_argument, 0, 'T' }, - {"all-links", no_argument, 0, 'a' }, - {"temporary", no_argument, 0, 't' }, - {"root-dir", required_argument, 0, 'R' }, - {"persistent", no_argument, 0, 'P' }, - {"file", required_argument, 0, 'f' }, + {"parseable", no_argument, 0, 'p' }, + {"output", required_argument, 0, 'o' }, + {"essid", required_argument, 0, 'e' }, + {"bsstype", required_argument, 0, 'b' }, + {"mode", required_argument, 0, 'm' }, + {"key", required_argument, 0, 'k' }, + {"sec", required_argument, 0, 's' }, + {"auth", required_argument, 0, 'a' }, + {"create-ibss", required_argument, 0, 'c' }, + {"timeout", required_argument, 0, 'T' }, + {"all-links", no_argument, 0, 'a' }, + {"temporary", no_argument, 0, 't' }, + {"root-dir", required_argument, 0, 'R' }, + {"persistent", no_argument, 0, 'P' }, + {"file", required_argument, 0, 'f' }, { 0, 0, 0, 0 } }; @@ -205,25 +230,33 @@ static void usage(void) { (void) fprintf(stderr, gettext("usage: dladm ...\n" - "\tshow-link [-p] [-s [-i ]] []\n" - "\tshow-dev [-p] [-s [-i ]] []\n" + "\tshow-link [-pP] [-s [-i ]] []\n" + "\trename-link [-R ] \n" + "\n" + "\tdelete-phys \n" + "\tshow-phys [-pP] []\n" + "\tshow-dev [-p] [-s [-i ]] []\n" "\n" - "\tcreate-aggr [-t] [-R ] [-P ] [-l ]\n" - "\t [-T