diff options
author | nh145002 <none@none> | 2007-01-15 11:53:51 -0800 |
---|---|---|
committer | nh145002 <none@none> | 2007-01-15 11:53:51 -0800 |
commit | 74e20cfe817b82802b16fac8690dadcda76f54f5 (patch) | |
tree | a454cd2ee9787b54e0a0be3a50bdf481a8c30e4d /usr/src | |
parent | 6e8a7b447bf994515a78a52e5b06ed1eec552e9e (diff) | |
download | illumos-joyent-74e20cfe817b82802b16fac8690dadcda76f54f5.tar.gz |
PSARC 2003/064 SDP: Sockets Direct Protocol
5068505 Integration of PSARC 2003/064 SDP into solaris
6503394 TX introduced an incorrect assert: ASSERT(!connp->conn_mac_exempt);
Diffstat (limited to 'usr/src')
56 files changed, 4377 insertions, 25 deletions
diff --git a/usr/src/Makefile.lint b/usr/src/Makefile.lint index 5944ecd55c..9198b7d694 100644 --- a/usr/src/Makefile.lint +++ b/usr/src/Makefile.lint @@ -20,7 +20,7 @@ # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -238,6 +238,7 @@ COMMON_SUBDIRS = \ cmd/rpcgen \ cmd/rpcsvc/rpc.bootparamd \ cmd/runat \ + cmd/sdpadm \ cmd/setpgrp \ cmd/smbios \ cmd/smserverd \ diff --git a/usr/src/cmd/Makefile b/usr/src/cmd/Makefile index 8acbd7ea75..eaa45cda4b 100644 --- a/usr/src/cmd/Makefile +++ b/usr/src/cmd/Makefile @@ -333,6 +333,7 @@ COMMON_SUBDIRS= \ savecore \ script \ sdiff \ + sdpadm \ sendmail \ setfacl \ setmnt \ @@ -635,6 +636,7 @@ MSGSUBDIRS= \ scadm \ script \ sdiff \ + sdpadm \ sgs \ sh \ sleep \ diff --git a/usr/src/cmd/cmd-inet/etc/default/inetinit.dfl b/usr/src/cmd/cmd-inet/etc/default/inetinit.dfl index 71b1e1af3f..6154dac9c2 100644 --- a/usr/src/cmd/cmd-inet/etc/default/inetinit.dfl +++ b/usr/src/cmd/cmd-inet/etc/default/inetinit.dfl @@ -1,13 +1,12 @@ # -# Copyright 2005 Sun Microsystems, Inc. All rights reserved. +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # 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. +# Common Development and Distribution License (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. @@ -53,3 +52,15 @@ TCP_STRONG_ISS=1 # ACCEPT6TO4RELAY=NO RELAY6TO4ADDR="192.88.99.1" + +# Set the SDP system Policy. This needs to happen after basic +# networking is up but before any networking services that might +# want to use SDP are enabled +if [ -f /usr/sbin/sdpadm ] ; then + if [ -f /etc/sdp.conf ] ; then + . /etc/sdp.conf + if [ "$sysenable" = "1" ]; then + /usr/sbin/sdpadm enable + fi + fi +fi diff --git a/usr/src/cmd/devfsadm/misc_link.c b/usr/src/cmd/devfsadm/misc_link.c index 933295ed58..525313a117 100644 --- a/usr/src/cmd/devfsadm/misc_link.c +++ b/usr/src/cmd/devfsadm/misc_link.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -106,7 +106,7 @@ static devfsadm_create_t misc_cbt[] = { "(^ip$)|(^tcp$)|(^udp$)|(^icmp$)|(^sctp$)|" "(^ip6$)|(^tcp6$)|(^udp6$)|(^icmp6$)|(^sctp6$)|" "(^rts$)|(^arp$)|(^ipsecah$)|(^ipsecesp$)|(^keysock$)|(^spdsock$)|" - "(^nca$)|(^rds$)", + "(^nca$)|(^rds$)|(^sdp$)", TYPE_EXACT | DRV_RE, ILEVEL_1, minor_name }, { "pseudo", "ddi_pseudo", diff --git a/usr/src/cmd/sdpadm/Makefile b/usr/src/cmd/sdpadm/Makefile new file mode 100755 index 0000000000..c5542f910d --- /dev/null +++ b/usr/src/cmd/sdpadm/Makefile @@ -0,0 +1,75 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" + +PROG = sdpadm + +OBJS = sdpadm.o +SRCS = $(OBJS:.o=.c) +MSGFILES = $(SRCS:%.c=%.i) +ETCFILES = sdp.conf +ROOTETC = $(ROOT)/etc + +LINTFLAGS += -mx + +include ../Makefile.cmd + +CFLAGS += $(CCVERBOSE) +POFILE = sdpadm_msg.po +XGETFLAGS = -a +FILEMODE = 0555 +OWNER = root +GROUP = bin + +ROOTETCFILES= $(ETCFILES:%=$(ROOTETC)/%) +$(ROOTETCFILES) := FILEMODE= 644 + +LINT_OBJS = $(OBJS:%.o=%.ln) + +.KEEP_STATE: + +all: $(PROG) $(ETCFILES) + +$(PROG): $(OBJS) + $(LINK.c) -o $@ $(OBJS) + $(POST_PROCESS) + +install: all $(ROOTUSRSBINPROG) $(ROOTETCFILES) + +$(POFILE): $(MSGFILES) + $(BUILDPO.msgfiles) + +_msg: $(MSGDOMAINPOFILE) + +clean: + $(RM) $(OBJS) + +clobber: clean + $(RM) $(PROG) $(MSGFILES) $(POFILE) + +lint: $(LINT_OBJS) + $(LINT.c) $(LINTFLAGS) $(LINT_OBJS) + +include $(SRC)/Makefile.msg.targ diff --git a/usr/src/cmd/sdpadm/sdp.conf b/usr/src/cmd/sdpadm/sdp.conf new file mode 100644 index 0000000000..7509ddbe2b --- /dev/null +++ b/usr/src/cmd/sdpadm/sdp.conf @@ -0,0 +1,29 @@ +#!/bin/sh +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 +# +# +# ident "%Z%%M% %I% %E% SMI" +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +sysenable=0 diff --git a/usr/src/cmd/sdpadm/sdpadm.c b/usr/src/cmd/sdpadm/sdpadm.c new file mode 100755 index 0000000000..ccae39be90 --- /dev/null +++ b/usr/src/cmd/sdpadm/sdpadm.c @@ -0,0 +1,153 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <stdio.h> +#include <libintl.h> +#include <stdlib.h> +#include <errno.h> +#include <locale.h> +#include <unistd.h> +#include <strings.h> +#include <fcntl.h> +#include <stropts.h> + +#include <sys/types.h> +#include <sys/socket.h> +#include <sys/sockio.h> + +#define E_SUCCESS 0 /* Exit status for success */ +#define E_ERROR 1 /* Exit status for error */ +#define E_USAGE 2 /* Exit status for usage error */ + +static const char USAGE[] = "Usage:\tsdpadm\tstatus\n\t\tenable\n\t\tdisable\n"; +static const char OPTS[] = "?"; + +static const char FILEENTRY[] = "sysenable=%d\n"; +static const char FILENAME[] = "/etc/sdp.conf"; +static const char dcname[] = "/dev/sdp"; + +static char conf_header[] = +"#\n" +"# CDDL HEADER START\n" +"#\n" +"# The contents of this file are subject to the terms of the\n" +"# Common Development and Distribution License (the \"License\").\n" +"# You may not use this file except in compliance with the License.\n" +"#\n" +"# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE\n" +"# or http://www.opensolaris.org/os/licensing.\n" +"# See the License for the specific language governing permissions\n" +"# and limitations under the License.\n" +"#\n" +"# When distributing Covered Code, include this CDDL HEADER in each\n" +"# file and include the License file at usr/src/OPENSOLARIS.LICENSE.\n" +"# If applicable, add the following below this CDDL HEADER, with the\n" +"# fields enclosed by brackets \"[]\" replaced with your own identifying\n" +"# information: Portions Copyright [yyyy] [name of copyright owner]\n" +"#\n" +"# CDDL HEADER END\n" +"#\n" +"#\n" +"# ident \"@(#)sdp.conf 1.1 07/01/03 SMI\"\n" +"#\n" +"# Copyright 2007 Sun Microsystems, Inc. All rights reserved.\n" +"# Use is subject to license terms.\n" +"#\n\n"; + +static void +usage() +{ + (void) fprintf(stderr, gettext(USAGE)); + exit(E_USAGE); +} + +int +main(int argc, char *argv[]) +{ + int c, enable, ret = E_SUCCESS; + int fd; + FILE *fConf; + struct strioctl stri; + + (void) setlocale(LC_ALL, ""); + (void) textdomain(TEXT_DOMAIN); + + while ((c = getopt(argc, argv, OPTS)) != EOF) { + switch (c) { + case '?': + usage(); + } + } + + if (argc != 2) { + usage(); + } + + fd = open(dcname, O_RDONLY); + if (fd < 0) { + (void) fprintf(stderr, gettext("opening %s failed errno %d\n"), + dcname, errno); + exit(0); + } + + if (argc == 2) { + /* Parse the on|off from the user */ + if (strncasecmp(argv[1], "enable", 7) == 0) { + enable = 1; + } else if (strncasecmp(argv[1], "disable", 8) == 0) { + enable = 0; + } else if (strncasecmp(argv[1], "status", 7) == 0) + enable = -1; + else { + usage(); + } + } + + stri.ic_cmd = SIOSYSENABLESDP; + stri.ic_timout = 0; + stri.ic_len = sizeof (int); + stri.ic_dp = (char *)&enable; + + if (ioctl(fd, I_STR, &stri) >= 0) { + (void) fprintf(stdout, gettext("SDP is %s\n"), + enable ? "Enabled" : "Disabled"); + fConf = fopen(FILENAME, "w"); + if (NULL != fConf) { + (void) fprintf(fConf, conf_header); + if (enable == 0) { + (void) fprintf(fConf, FILEENTRY, 0); + } else { + (void) fprintf(fConf, FILEENTRY, 1); + } + (void) fclose(fConf); + } + } else { + perror("ioctl failed"); + ret = E_ERROR; + } + return (ret); +} diff --git a/usr/src/pkgdefs/Makefile b/usr/src/pkgdefs/Makefile index d405b58100..6a8a27e0e9 100644 --- a/usr/src/pkgdefs/Makefile +++ b/usr/src/pkgdefs/Makefile @@ -20,7 +20,7 @@ # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -211,6 +211,8 @@ COMMON_SUBDIRS= \ SUNWhwdata \ SUNWib \ SUNWibhca \ + SUNWibsdpu \ + SUNWibsdp \ SUNWiotu \ SUNWioth \ SUNWipc \ @@ -394,6 +396,7 @@ COMMON_XMODS= \ SUNWcryr \ SUNWcryptoint \ SUNWintgige \ + SUNWibsdpib \ SUNWkdcr \ SUNWkdcu \ SUNWopenssl-man \ diff --git a/usr/src/pkgdefs/SUNWibsdp/Makefile b/usr/src/pkgdefs/SUNWibsdp/Makefile new file mode 100644 index 0000000000..495b19a051 --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdp/Makefile @@ -0,0 +1,37 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +include ../Makefile.com + +DATAFILES += i.sdpconf + +.KEEP_STATE: + +all: $(FILES) depend preinstall postinstall preremove +install: all pkg + +include ../Makefile.targ diff --git a/usr/src/pkgdefs/SUNWibsdp/depend b/usr/src/pkgdefs/SUNWibsdp/depend new file mode 100644 index 0000000000..428b2c6665 --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdp/depend @@ -0,0 +1,53 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# This package information file defines software dependencies associated +# with the pkg. You can define three types of pkg dependencies with this file: +# P indicates a prerequisite for installation +# I indicates an incompatible package +# R indicates a reverse dependency +# <pkg.abbr> see pkginfo(4), PKG parameter +# <name> see pkginfo(4), NAME parameter +# <version> see pkginfo(4), VERSION parameter +# <arch> see pkginfo(4), ARCH parameter +# <type> <pkg.abbr> <name> +# (<arch>)<version> +# (<arch>)<version> +# ... +# <type> <pkg.abbr> <name> +# ... + +P SUNWcar Core Architecture, (Root) +P SUNWcakr Core Solaris Kernel Architecture (Root) +P SUNWkvm Core Architecture, (Kvm) +P SUNWcsr Core Solaris, (Root) +P SUNWckr Core Solaris Kernel (Root) +P SUNWcnetr Core Solaris Network Infrastructure (Root) +P SUNWcsu Core Solaris, (Usr) +P SUNWcsd Core Solaris Devices +P SUNWcsl Core Solaris Libraries +P SUNWib Sun Infiniband Framework +P SUNWipoib Sun IP over Infiniband diff --git a/usr/src/pkgdefs/SUNWibsdp/pkginfo.tmpl b/usr/src/pkgdefs/SUNWibsdp/pkginfo.tmpl new file mode 100644 index 0000000000..ad3515c9f6 --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdp/pkginfo.tmpl @@ -0,0 +1,50 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# This required package information file describes characteristics of the +# package, such as package abbreviation, full package name, package version, +# and package architecture. +# + +PKG="SUNWibsdp" +NAME="Sun InfiniBand layered Sockets Direct Protocol" +ARCH="ISA" +VERSION="ONVERS,REV=0.0.0" +SUNW_PRODNAME="SunOS" +SUNW_PRODVERS="RELEASE/VERSION" +SUNW_PKGTYPE="root" +MAXINST="1000" +CATEGORY="system" +DESC="Sun InfiniBand layered Sockets Direct Protocol" +VENDOR="Sun Microsystems, Inc." +HOTLINE="Please contact your local service provider" +EMAIL="" +CLASSES="none" +BASEDIR=/ +SUNW_PKGVERS="1.0" +SUNW_PKG_ALLZONES="true" +SUNW_PKG_HOLLOW="true" +SUNW_PKG_THISZONE="false" diff --git a/usr/src/pkgdefs/SUNWibsdp/postinstall b/usr/src/pkgdefs/SUNWibsdp/postinstall new file mode 100644 index 0000000000..e320b55507 --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdp/postinstall @@ -0,0 +1,72 @@ +#!/bin/sh +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 +# +# +# ident "%Z%%M% %I% %E% SMI" +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +PATH="/usr/bin:/usr/sbin:${PATH}" +export PATH + +SDP4_SOCK_ENTRY=" 2 2 257 /dev/sdp" +SDP6_SOCK_ENTRY=" 26 2 257 /dev/sdp" + +if [ "${BASEDIR:=/}" != "/" ] +then + BASEDIR_OPT="-b $BASEDIR" +fi + +not_installed() { + driver=$1 + grep "^${driver} " $BASEDIR/etc/name_to_major > /dev/null 2>&1 + return $? +} + +EXIT=0 + +not_installed sdp || add_drv ${BASEDIR_OPT} -m '* 0644 root sys' sdp || EXIT=1 + +# Check sdp4 entry exists in sock2path +egrep "$SDP4_SOCK_ENTRY" $BASEDIR/etc/sock2path > /dev/null 2>&1 +if [ $? -ne 0 ] +then + echo "$SDP4_SOCK_ENTRY" >> $BASEDIR/etc/sock2path + if [ "${BASEDIR:=/}" = "/" ] + then + soconfig $SDP4_SOCK_ENTRY || EXIT=1 + fi +fi + +# Check sdp6 entry exists in sock2path +egrep "$SDP6_SOCK_ENTRY" $BASEDIR/etc/sock2path > /dev/null 2>&1 +if [ $? -ne 0 ] +then + echo "$SDP6_SOCK_ENTRY" >> $BASEDIR/etc/sock2path + if [ "${BASEDIR:=/}" = "/" ] + then + soconfig $SDP6_SOCK_ENTRY || EXIT=1 + fi +fi + +exit $EXIT diff --git a/usr/src/pkgdefs/SUNWibsdp/preinstall b/usr/src/pkgdefs/SUNWibsdp/preinstall new file mode 100644 index 0000000000..95f1f0c3d5 --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdp/preinstall @@ -0,0 +1,34 @@ +#!/bin/sh +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 +# +# +# ident "%Z%%M% %I% %E% SMI" +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +if [ -f $BASEDIR/etc/sdp.conf ] ; then + cp $BASEDIR/etc/sdp.conf $BASEDIR/etc/sdp.conf.temp +fi + +exit 0 + diff --git a/usr/src/pkgdefs/SUNWibsdp/preremove b/usr/src/pkgdefs/SUNWibsdp/preremove new file mode 100644 index 0000000000..d0f143d2cf --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdp/preremove @@ -0,0 +1,54 @@ +#!/bin/sh +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 +# +# +# ident "%Z%%M% %I% %E% SMI" +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +PATH="/usr/bin:/usr/sbin:${PATH}" +export PATH + +SDP4_SOCK_ENTRY=" 2 2 257 /dev/sdp" +SDP6_SOCK_ENTRY=" 26 2 257 /dev/sdp" + +EXIT=0 + +if [ "${BASEDIR:=/}" = "/" ] +then + soconfig 2 2 257 || EXIT=1 + soconfig 26 2 257 || EXIT=1 +else + BASEDIR_OPT="-b $BASEDIR" +fi + +# Remove Drivers +rem_drv ${BASEDIR_OPT} sdp || EXIT=1 + +# Remove sdp4 and sdp6 entry in sock2path +egrep -v "$SDP4_SOCK_ENTRY" $BASEDIR/etc/sock2path > /tmp/sock2path$$ +mv /tmp/sock2path$$ $BASEDIR/etc/sock2path +egrep -v "$SDP6_SOCK_ENTRY" $BASEDIR/etc/sock2path > /tmp/sock2path$$ +mv /tmp/sock2path$$ $BASEDIR/etc/sock2path + +exit $EXIT diff --git a/usr/src/pkgdefs/SUNWibsdp/prototype_com b/usr/src/pkgdefs/SUNWibsdp/prototype_com new file mode 100644 index 0000000000..633d13f483 --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdp/prototype_com @@ -0,0 +1,56 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# This required package information file contains a list of package contents. +# The 'pkgmk' command uses this file to identify the contents of a package +# and their location on the development machine when building the package. +# Can be created via a text editor or through use of the 'pkgproto' command. + +#!search <pathname pathname ...> # where to find pkg objects +#!include <filename> # include another 'prototype' file +#!default <mode> <owner> <group> # default used if not specified on entry +#!<param>=<value> # puts parameter in pkg environment + +# packaging files +i pkginfo +i copyright +i depend +i i.sdpconf + +# installation scripts +i preinstall +i postinstall +i preremove + +# source locations relative to the prototype file +# +# SUNWibsdp +# +d none kernel 0755 root sys +d none kernel/drv 0755 root sys +f none kernel/drv/sdp.conf 0644 root sys +d none etc 0755 root sys +e sdpconf etc/sdp.conf 0644 root sys diff --git a/usr/src/pkgdefs/SUNWibsdp/prototype_i386 b/usr/src/pkgdefs/SUNWibsdp/prototype_i386 new file mode 100644 index 0000000000..2c01d15098 --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdp/prototype_i386 @@ -0,0 +1,49 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# This required package information file contains a list of package contents. +# The 'pkgmk' command uses this file to identify the contents of a package +# and their location on the development machine when building the package. +# Can be created via a text editor or through use of the 'pkgproto' command. + +#!search <pathname pathname ...> # where to find pkg objects +#!include <filename> # include another 'prototype' file +#!default <mode> <owner> <group> # default used if not specified on entry +#!<param>=<value> # puts parameter in pkg environment +# +# Include ISA independent files (prototype_com) +# +!include prototype_com +# +# +# +# List files which are i386 specific here +# +# source locations relative to the prototype file +# +f none kernel/drv/sdp 0755 root sys +d none kernel/drv/amd64 0755 root sys +f none kernel/drv/amd64/sdp 0755 root sys diff --git a/usr/src/pkgdefs/SUNWibsdp/prototype_sparc b/usr/src/pkgdefs/SUNWibsdp/prototype_sparc new file mode 100644 index 0000000000..891011aba8 --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdp/prototype_sparc @@ -0,0 +1,51 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# This required package information file contains a list of package contents. +# The 'pkgmk' command uses this file to identify the contents of a package +# and their location on the development machine when building the package. +# Can be created via a text editor or through use of the 'pkgproto' command. + +#!search <pathname pathname ...> # where to find pkg objects +#!include <filename> # include another 'prototype' file +#!default <mode> <owner> <group> # default used if not specified on entry +#!<param>=<value> # puts parameter in pkg environment +# +# Include ISA independent files (prototype_com) +# +!include prototype_com +# +# +# +# List files which are SPARC specific here +# +# source locations relative to the prototype file +# +# +# SUNWibsdp +# +d none kernel/drv/sparcv9 0755 root sys +f none kernel/drv/sparcv9/sdp 0755 root sys diff --git a/usr/src/pkgdefs/SUNWibsdpib/Makefile b/usr/src/pkgdefs/SUNWibsdpib/Makefile new file mode 100644 index 0000000000..379e2284dc --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdpib/Makefile @@ -0,0 +1,15 @@ +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +include ../Makefile.com + +.KEEP_STATE: + +all: $(FILES) depend postinstall preremove +install: all pkg + +include ../Makefile.targ diff --git a/usr/src/pkgdefs/SUNWibsdpib/depend b/usr/src/pkgdefs/SUNWibsdpib/depend new file mode 100644 index 0000000000..623c13a178 --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdpib/depend @@ -0,0 +1,34 @@ +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# This package information file defines software dependencies associated +# with the pkg. You can define three types of pkg dependencies with this file: +# P indicates a prerequisite for installation +# I indicates an incompatible package +# R indicates a reverse dependency +# <pkg.abbr> see pkginfo(4), PKG parameter +# <name> see pkginfo(4), NAME parameter +# <version> see pkginfo(4), VERSION parameter +# <arch> see pkginfo(4), ARCH parameter +# <type> <pkg.abbr> <name> +# (<arch>)<version> +# (<arch>)<version> +# ... +# <type> <pkg.abbr> <name> +# ... + +P SUNWcar Core Architecture, (Root) +P SUNWcakr Core Solaris Kernel Architecture (Root) +P SUNWkvm Core Architecture, (Kvm) +P SUNWcsr Core Solaris, (Root) +P SUNWckr Core Solaris Kernel (Root) +P SUNWcnetr Core Solaris Network Infrastructure (Root) +P SUNWcsu Core Solaris, (Usr) +P SUNWcsd Core Solaris Devices +P SUNWcsl Core Solaris Libraries +P SUNWib Sun Infiniband Framework +P SUNWipoib Sun IP over Infiniband +P SUNWibsdp Sun Infiniband pseudo Sockets Direct Protocol diff --git a/usr/src/pkgdefs/SUNWibsdpib/pkginfo.tmpl b/usr/src/pkgdefs/SUNWibsdpib/pkginfo.tmpl new file mode 100644 index 0000000000..e8bcfd849f --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdpib/pkginfo.tmpl @@ -0,0 +1,30 @@ +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# This required package information file describes characteristics of the +# package, such as package abbreviation, full package name, package version, +# and package architecture. +# + +PKG="SUNWibsdpib" +NAME="Sun InfiniBand Sockets Direct Protocol" +ARCH="ISA" +VERSION="ONVERS,REV=0.0.0" +SUNW_PRODNAME="SunOS" +SUNW_PRODVERS="RELEASE/VERSION" +SUNW_PKGTYPE="root" +MAXINST="1000" +CATEGORY="system" +DESC="Sun InfiniBand Sockets Direct Protocol" +VENDOR="Sun Microsystems, Inc." +HOTLINE="Please contact your local service provider" +EMAIL="" +CLASSES="none" +BASEDIR=/ +SUNW_PKGVERS="1.0" +SUNW_PKG_ALLZONES="true" +SUNW_PKG_HOLLOW="true" +SUNW_PKG_THISZONE="false" diff --git a/usr/src/pkgdefs/SUNWibsdpib/postinstall b/usr/src/pkgdefs/SUNWibsdpib/postinstall new file mode 100755 index 0000000000..d31b10ccb0 --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdpib/postinstall @@ -0,0 +1,27 @@ +#!/bin/sh +# +# ident "%Z%%M% %I% %E% SMI" +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +PATH="/usr/bin:/usr/sbin:${PATH}" +export PATH + +if [ "${BASEDIR:=/}" != "/" ] +then + BASEDIR_OPT="-b $BASEDIR" +fi + +not_installed() { + driver=$1 + grep "^${driver} " $BASEDIR/etc/name_to_major > /dev/null 2>&1 + return $? +} + +EXIT=0 + +not_installed sdpib || add_drv -b ${BASEDIR} -m '* 0644 root sys' sdpib || EXIT=1 + +exit $EXIT diff --git a/usr/src/pkgdefs/SUNWibsdpib/preremove b/usr/src/pkgdefs/SUNWibsdpib/preremove new file mode 100755 index 0000000000..b516a39bb7 --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdpib/preremove @@ -0,0 +1,20 @@ +#!/bin/sh +# +# ident "%Z%%M% %I% %E% SMI" +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# + +PATH="/usr/bin:/usr/sbin:${PATH}" +export PATH + +if [ "${BASEDIR:=/}" != "/" ] +then + BASEDIR_OPT="-b $BASEDIR" +fi + +# Remove Drivers +rem_drv ${BASEDIR} sdpib + +exit 0 diff --git a/usr/src/pkgdefs/SUNWibsdpib/prototype_com b/usr/src/pkgdefs/SUNWibsdpib/prototype_com new file mode 100755 index 0000000000..51ffbe9aae --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdpib/prototype_com @@ -0,0 +1,33 @@ +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# This required package information file contains a list of package contents. +# The 'pkgmk' command uses this file to identify the contents of a package +# and their location on the development machine when building the package. +# Can be created via a text editor or through use of the 'pkgproto' command. + +#!search <pathname pathname ...> # where to find pkg objects +#!include <filename> # include another 'prototype' file +#!default <mode> <owner> <group> # default used if not specified on entry +#!<param>=<value> # puts parameter in pkg environment + +# packaging files +i pkginfo +i copyright +i depend + +# installation scripts +i postinstall +i preremove + +# source locations relative to the prototype file +# +# SUNWibsdpib +# +d none kernel 0755 root sys +d none kernel/drv 0755 root sys +f none kernel/drv/sdpib.conf 0644 root sys +d none kernel/strmod 0755 root sys diff --git a/usr/src/pkgdefs/SUNWibsdpib/prototype_i386 b/usr/src/pkgdefs/SUNWibsdpib/prototype_i386 new file mode 100755 index 0000000000..cb8fa9ca7c --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdpib/prototype_i386 @@ -0,0 +1,32 @@ +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# This required package information file contains a list of package contents. +# The 'pkgmk' command uses this file to identify the contents of a package +# and their location on the development machine when building the package. +# Can be created via a text editor or through use of the 'pkgproto' command. + +#!search <pathname pathname ...> # where to find pkg objects +#!include <filename> # include another 'prototype' file +#!default <mode> <owner> <group> # default used if not specified on entry +#!<param>=<value> # puts parameter in pkg environment +# +# Include ISA independent files (prototype_com) +# +!include prototype_com +# +# +# +# List files which are i386 specific here +# +# source locations relative to the prototype file +# +f none kernel/drv/sdpib 0755 root sys +l none kernel/strmod/sdpib=../../kernel/drv/sdpib +d none kernel/drv/amd64 0755 root sys +d none kernel/strmod/amd64 0755 root sys +f none kernel/drv/amd64/sdpib 0755 root sys +l none kernel/strmod/amd64/sdpib=../../../kernel/drv/amd64/sdpib diff --git a/usr/src/pkgdefs/SUNWibsdpib/prototype_sparc b/usr/src/pkgdefs/SUNWibsdpib/prototype_sparc new file mode 100755 index 0000000000..824e61c07b --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdpib/prototype_sparc @@ -0,0 +1,33 @@ +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# This required package information file contains a list of package contents. +# The 'pkgmk' command uses this file to identify the contents of a package +# and their location on the development machine when building the package. +# Can be created via a text editor or through use of the 'pkgproto' command. + +#!search <pathname pathname ...> # where to find pkg objects +#!include <filename> # include another 'prototype' file +#!default <mode> <owner> <group> # default used if not specified on entry +#!<param>=<value> # puts parameter in pkg environment +# +# Include ISA independent files (prototype_com) +# +!include prototype_com +# +# +# +# List files which are SPARC specific here +# +# source locations relative to the prototype file +# +# +# SUNWibsdpib +# +d none kernel/drv/sparcv9 0755 root sys +f none kernel/drv/sparcv9/sdpib 0755 root sys +d none kernel/strmod/sparcv9 0755 root sys +l none kernel/strmod/sparcv9/sdpib=../../../kernel/drv/sparcv9/sdpib diff --git a/usr/src/pkgdefs/SUNWibsdpu/Makefile b/usr/src/pkgdefs/SUNWibsdpu/Makefile new file mode 100644 index 0000000000..834d3ce6da --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdpu/Makefile @@ -0,0 +1,35 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# + +include ../Makefile.com + +.KEEP_STATE: + +all: $(FILES) depend +install: all pkg + +include ../Makefile.targ diff --git a/usr/src/pkgdefs/SUNWibsdpu/depend b/usr/src/pkgdefs/SUNWibsdpu/depend new file mode 100644 index 0000000000..a7b02255d8 --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdpu/depend @@ -0,0 +1,52 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# This package information file defines software dependencies associated +# with the pkg. You can define three types of pkg dependencies with this file: +# P indicates a prerequisite for installation +# I indicates an incompatible package +# R indicates a reverse dependency +# <pkg.abbr> see pkginfo(4), PKG parameter +# <name> see pkginfo(4), NAME parameter +# <version> see pkginfo(4), VERSION parameter +# <arch> see pkginfo(4), ARCH parameter +# <type> <pkg.abbr> <name> +# (<arch>)<version> +# (<arch>)<version> +# ... +# <type> <pkg.abbr> <name> +# ... + +P SUNWcar Core Architecture, (Root) +P SUNWcakr Core Solaris Kernel Architecture (Root) +P SUNWkvm Core Architecture, (Kvm) +P SUNWcsr Core Solaris, (Root) +P SUNWckr Core Solaris Kernel (Root) +P SUNWcnetr Core Solaris Network Infrastructure (Root) +P SUNWcsu Core Solaris, (Usr) +P SUNWcsd Core Solaris Devices +P SUNWcsl Core Solaris Libraries +P SUNWibsdp Sun Infiniband Layered Sockets Direct Protocol diff --git a/usr/src/pkgdefs/SUNWibsdpu/pkginfo.tmpl b/usr/src/pkgdefs/SUNWibsdpu/pkginfo.tmpl new file mode 100644 index 0000000000..988d8c0577 --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdpu/pkginfo.tmpl @@ -0,0 +1,50 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# This required package information file describes characteristics of the +# package, such as package abbreviation, full package name, package version, +# and package architecture. +# + +PKG="SUNWibsdpu" +NAME="Sun InfiniBand pseudo Sockets Direct Protocol Admin" +ARCH="ISA" +VERSION="ONVERS,REV=0.0.0" +SUNW_PRODNAME="SunOS" +SUNW_PRODVERS="RELEASE/VERSION" +SUNW_PKGTYPE="usr" +MAXINST="1000" +CATEGORY="system" +DESC="Sun InfiniBand Sockets Direct Protocol Admin" +VENDOR="Sun Microsystems, Inc." +HOTLINE="Please contact your local service provider" +EMAIL="" +CLASSES="none sdpconf" +BASEDIR=/ +SUNW_PKGVERS="1.0" +SUNW_PKG_ALLZONES="true" +SUNW_PKG_HOLLOW="true" +SUNW_PKG_THISZONE="false" diff --git a/usr/src/pkgdefs/SUNWibsdpu/prototype_com b/usr/src/pkgdefs/SUNWibsdpu/prototype_com new file mode 100644 index 0000000000..d6134ea23b --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdpu/prototype_com @@ -0,0 +1,48 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# This required package information file contains a list of package contents. +# The 'pkgmk' command uses this file to identify the contents of a package +# and their location on the development machine when building the package. +# Can be created via a text editor or through use of the 'pkgproto' command. + +#!search <pathname pathname ...> # where to find pkg objects +#!include <filename> # include another 'prototype' file +#!default <mode> <owner> <group> # default used if not specified on entry +#!<param>=<value> # puts parameter in pkg environment + +# packaging files +i pkginfo +i copyright +i depend + +# source locations relative to the prototype file +# +# SUNWibsdpu +# +d none usr 0755 root sys +d none usr/sbin 0755 root bin +f none usr/sbin/sdpadm 0555 root bin diff --git a/usr/src/pkgdefs/SUNWibsdpu/prototype_i386 b/usr/src/pkgdefs/SUNWibsdpu/prototype_i386 new file mode 100644 index 0000000000..f4962dc3ca --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdpu/prototype_i386 @@ -0,0 +1,49 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# This required package information file contains a list of package contents. +# The 'pkgmk' command uses this file to identify the contents of a package +# and their location on the development machine when building the package. +# Can be created via a text editor or through use of the 'pkgproto' command. + +#!search <pathname pathname ...> # where to find pkg objects +#!include <filename> # include another 'prototype' file +#!default <mode> <owner> <group> # default used if not specified on entry +#!<param>=<value> # puts parameter in pkg environment +# +# Include ISA independent files (prototype_com) +# +!include prototype_com +# +# +# +# List files which are SPARC specific here +# +# source locations relative to the prototype file +# +# +# SUNWibsdpu +# diff --git a/usr/src/pkgdefs/SUNWibsdpu/prototype_sparc b/usr/src/pkgdefs/SUNWibsdpu/prototype_sparc new file mode 100644 index 0000000000..f4962dc3ca --- /dev/null +++ b/usr/src/pkgdefs/SUNWibsdpu/prototype_sparc @@ -0,0 +1,49 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# This required package information file contains a list of package contents. +# The 'pkgmk' command uses this file to identify the contents of a package +# and their location on the development machine when building the package. +# Can be created via a text editor or through use of the 'pkgproto' command. + +#!search <pathname pathname ...> # where to find pkg objects +#!include <filename> # include another 'prototype' file +#!default <mode> <owner> <group> # default used if not specified on entry +#!<param>=<value> # puts parameter in pkg environment +# +# Include ISA independent files (prototype_com) +# +!include prototype_com +# +# +# +# List files which are SPARC specific here +# +# source locations relative to the prototype file +# +# +# SUNWibsdpu +# diff --git a/usr/src/pkgdefs/common_files/i.sdpconf b/usr/src/pkgdefs/common_files/i.sdpconf new file mode 100755 index 0000000000..347e9d7688 --- /dev/null +++ b/usr/src/pkgdefs/common_files/i.sdpconf @@ -0,0 +1,42 @@ +#!/bin/sh +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 +# +# ident "%Z%%M% %I% %E% SMI" +# +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. + +PATH="/usr/bin:/usr/sbin:${PATH}" +export PATH + +while read src dest +do + if [ ! -f $dest ] ; then + cp $src $dest + else + if [ -f $BASEDIR/etc/sdp.conf.temp ] ; then + cp $BASEDIR/etc/sdp.conf.temp $dest + rm -f $BASEDIR/etc/sdp.conf.temp + fi + fi +done + +exit 0 diff --git a/usr/src/uts/common/Makefile.files b/usr/src/uts/common/Makefile.files index 413ad69d02..d16d18b02d 100644 --- a/usr/src/uts/common/Makefile.files +++ b/usr/src/uts/common/Makefile.files @@ -20,7 +20,7 @@ # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -849,6 +849,7 @@ SPEC_OBJS += specsubr.o specvfsops.o specvnops.o SOCK_OBJS += socksubr.o sockvfsops.o sockvnops.o \ socksyscalls.o socktpi.o sockstr.o \ socksctp.o socksctpsubr.o socksctpvnops.o sockssl.o \ + socksdp.o socksdpsubr.o socksdpvnops.o \ nl7c.o nl7curi.o nl7chttp.o nl7clogd.o \ nl7cnca.o @@ -1272,6 +1273,8 @@ IPF_OBJS += ip_fil_solaris.o fil.o solaris.o ip_state.o ip_frag.o ip_nat.o \ IBD_OBJS += ibd.o +SDP_OBJS += sdpddi.o + VNI_OBJS += vni.o CTF_OBJS += ctf_create.o ctf_decl.o ctf_error.o ctf_hash.o ctf_labels.o \ diff --git a/usr/src/uts/common/Makefile.rules b/usr/src/uts/common/Makefile.rules index b256e5bb82..416692cadd 100644 --- a/usr/src/uts/common/Makefile.rules +++ b/usr/src/uts/common/Makefile.rules @@ -20,7 +20,7 @@ # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -511,6 +511,10 @@ $(OBJS_DIR)/%.o: $(UTSBASE)/common/io/ib/clients/ibd/%.c $(COMPILE.c) -o $@ $< $(CTFCONVERT_O) +$(OBJS_DIR)/%.o: $(UTSBASE)/common/io/ib/clients/sdp/%.c + $(COMPILE.c) -o $@ $< + $(CTFCONVERT_O) + $(OBJS_DIR)/%.o: $(UTSBASE)/common/io/ib/mgt/ibcm/%.c $(COMPILE.c) -o $@ $< $(CTFCONVERT_O) @@ -1267,6 +1271,9 @@ $(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/ib/clients/rds/%.c $(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/ib/clients/ibd/%.c @($(LHEAD) $(LINT.c) $< $(LTAIL)) +$(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/ib/clients/sdp/%.c + @($(LHEAD) $(LINT.c) $< $(LTAIL)) + $(LINTS_DIR)/%.ln: $(UTSBASE)/common/io/ib/mgt/ibcm/%.c @($(LHEAD) $(LINT.c) $< $(LTAIL)) diff --git a/usr/src/uts/common/fs/sockfs/socksdp.c b/usr/src/uts/common/fs/sockfs/socksdp.c new file mode 100755 index 0000000000..faaa4f3504 --- /dev/null +++ b/usr/src/uts/common/fs/sockfs/socksdp.c @@ -0,0 +1,1489 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <sys/types.h> +#include <sys/t_lock.h> +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/buf.h> +#include <sys/vfs.h> +#include <sys/vnode.h> +#include <sys/debug.h> +#include <sys/errno.h> +#include <sys/stropts.h> +#include <sys/cmn_err.h> +#include <sys/sysmacros.h> + +#include <sys/project.h> +#include <sys/tihdr.h> +#include <sys/strsubr.h> + +#include <sys/socket.h> +#include <sys/socketvar.h> +#include <sys/strsun.h> + +#include <sys/tsol/label.h> + +#include <inet/sdp_itf.h> +#include "socksdp.h" + +/* + * SDP sockfs sonode operations + */ +static int sosdp_accept(struct sonode *, int, struct sonode **); +static int sosdp_listen(struct sonode *, int); +static int sosdp_connect(struct sonode *, const struct sockaddr *, socklen_t, + int, int); +static int sosdp_sendmsg(struct sonode *, struct nmsghdr *, struct uio *); +static int sosdp_getpeername(struct sonode *); +static int sosdp_getsockname(struct sonode *); +static int sosdp_shutdown(struct sonode *, int); +static int sosdp_getsockopt(struct sonode *, int, int, void *, socklen_t *, + int); +static int sosdp_setsockopt(struct sonode *, int, int, const void *, + socklen_t); + + +/* + * Socket upcalls + */ +static void *sdp_sock_newconn(void *parenthandle, void *connind); +static void sdp_sock_connected(void *handle); +static void sdp_sock_disconnected(void *handle, int error); +static void sdp_sock_connfail(void *handle, int error); +static int sdp_sock_recv(void *handle, mblk_t *mp, int flags); +static void sdp_sock_xmitted(void *handle, int txqueued); +static void sdp_sock_urgdata(void *handle); +static void sdp_sock_ordrel(void *handle); + +static kmem_cache_t *sosdp_sockcache; + +sonodeops_t sosdp_sonodeops = { + sosdp_accept, /* sop_accept */ + sosdp_bind, /* sop_bind */ + sosdp_listen, /* sop_listen */ + sosdp_connect, /* sop_connect */ + sosdp_recvmsg, /* sop_recvmsg */ + sosdp_sendmsg, /* sop_sendmsg */ + sosdp_getpeername, /* sop_getpeername */ + sosdp_getsockname, /* sop_getsockname */ + sosdp_shutdown, /* sop_shutdown */ + sosdp_getsockopt, /* sop_getsockopt */ + sosdp_setsockopt /* sop_setsockopt */ +}; + +sdp_upcalls_t sosdp_sock_upcalls = { + sdp_sock_newconn, + sdp_sock_connected, + sdp_sock_disconnected, + sdp_sock_connfail, + sdp_sock_recv, + sdp_sock_xmitted, + sdp_sock_urgdata, + sdp_sock_ordrel, +}; + + +/*ARGSUSED*/ +static int +sosdp_sock_constructor(void *buf, void *cdrarg, int kmflags) +{ + struct sdp_sonode *ss = buf; + struct sonode *so = &ss->ss_so; + struct vnode *vp; + + ss->ss_type = SOSDP_SOCKET; + so->so_oobmsg = NULL; + so->so_ack_mp = NULL; + so->so_conn_ind_head = NULL; + so->so_conn_ind_tail = NULL; + so->so_discon_ind_mp = NULL; + so->so_ux_bound_vp = NULL; + so->so_unbind_mp = NULL; + so->so_accessvp = NULL; + so->so_priv = NULL; + + so->so_nl7c_flags = 0; + so->so_nl7c_uri = NULL; + so->so_nl7c_rcv_mp = NULL; + + vp = vn_alloc(kmflags); + if (vp == NULL) { + return (-1); + } + so->so_vnode = vp; + + vn_setops(vp, socksdp_vnodeops); + vp->v_data = (caddr_t)so; + + mutex_init(&so->so_lock, NULL, MUTEX_DEFAULT, NULL); + mutex_init(&so->so_plumb_lock, NULL, MUTEX_DEFAULT, NULL); + cv_init(&so->so_state_cv, NULL, CV_DEFAULT, NULL); + cv_init(&so->so_ack_cv, NULL, CV_DEFAULT, NULL); + cv_init(&so->so_connind_cv, NULL, CV_DEFAULT, NULL); + cv_init(&so->so_want_cv, NULL, CV_DEFAULT, NULL); + return (0); +} + +/*ARGSUSED*/ +static void +sosdp_sock_destructor(void *buf, void *cdrarg) +{ + struct sdp_sonode *ss = buf; + struct sonode *so = &ss->ss_so; + struct vnode *vp = SOTOV(so); + + ASSERT(so->so_nl7c_flags == 0); + ASSERT(so->so_nl7c_uri == NULL); + ASSERT(so->so_nl7c_rcv_mp == NULL); + + ASSERT(so->so_oobmsg == NULL); + ASSERT(so->so_ack_mp == NULL); + ASSERT(so->so_conn_ind_head == NULL); + ASSERT(so->so_conn_ind_tail == NULL); + ASSERT(so->so_discon_ind_mp == NULL); + ASSERT(so->so_ux_bound_vp == NULL); + ASSERT(so->so_unbind_mp == NULL); + ASSERT(so->so_ops == &sosdp_sonodeops); + + ASSERT(vn_matchops(vp, socksdp_vnodeops)); + ASSERT(vp->v_data == (caddr_t)so); + + vn_free(vp); + + mutex_destroy(&so->so_lock); + mutex_destroy(&so->so_plumb_lock); + cv_destroy(&so->so_state_cv); + cv_destroy(&so->so_ack_cv); + cv_destroy(&so->so_connind_cv); + cv_destroy(&so->so_want_cv); +} + + +int +sosdp_init(void) +{ + int error; + + error = vn_make_ops("socksdp", socksdp_vnodeops_template, + &socksdp_vnodeops); + if (error != 0) { + cmn_err(CE_WARN, "sosdp_init: bad vnode ops template"); + return (error); + } + + sosdp_sockcache = kmem_cache_create("sdpsock", + sizeof (struct sdp_sonode), 0, sosdp_sock_constructor, + sosdp_sock_destructor, NULL, NULL, NULL, 0); + return (0); +} + +static struct vnode * +sosdp_makevp(struct vnode *accessvp, int domain, int type, int protocol, + int kmflags) +{ + struct sdp_sonode *ss; + struct sonode *so; + struct vnode *vp; + time_t now; + + ss = kmem_cache_alloc(sosdp_sockcache, kmflags); + if (ss == NULL) { + return (NULL); + } + so = &ss->ss_so; + so->so_cache = sosdp_sockcache; + so->so_obj = ss; + vp = SOTOV(so); + now = gethrestime_sec(); + + so->so_flag = 0; + so->so_accessvp = accessvp; + so->so_dev = accessvp->v_rdev; + + so->so_state = 0; + so->so_mode = 0; + + so->so_fsid = sockdev; + so->so_atime = now; + so->so_mtime = now; + so->so_ctime = now; + so->so_count = 0; + + so->so_family = domain; + so->so_type = type; + so->so_protocol = protocol; + so->so_pushcnt = 0; + + so->so_options = 0; + so->so_linger.l_onoff = 0; + so->so_linger.l_linger = 0; + so->so_sndbuf = 0; + so->so_rcvbuf = 0; + so->so_error = 0; + so->so_delayed_error = 0; + + ASSERT(so->so_oobmsg == NULL); + so->so_oobcnt = 0; + so->so_oobsigcnt = 0; + so->so_pgrp = 0; + so->so_provinfo = NULL; + + so->so_laddr_sa = (struct sockaddr *)&ss->ss_laddr; + so->so_faddr_sa = (struct sockaddr *)&ss->ss_faddr; + so->so_laddr_maxlen = so->so_faddr_maxlen = sizeof (ss->ss_laddr); + so->so_laddr_len = so->so_faddr_len = 0; + so->so_eaddr_mp = NULL; + so->so_delayed_error = 0; + + so->so_peercred = NULL; + + ASSERT(so->so_ack_mp == NULL); + ASSERT(so->so_conn_ind_head == NULL); + ASSERT(so->so_conn_ind_tail == NULL); + ASSERT(so->so_ux_bound_vp == NULL); + ASSERT(so->so_unbind_mp == NULL); + + vn_reinit(vp); + vp->v_vfsp = rootvfs; + vp->v_type = VSOCK; + vp->v_rdev = so->so_dev; + + so->so_ops = &sosdp_sonodeops; + + ss->ss_rxqueued = 0; + bzero(&ss->ss_poll_list, sizeof (ss->ss_poll_list)); + + vn_exists(vp); + return (vp); +} + +/* + * Creates a sdp socket data structure. + * tso is non-NULL if it's passive open. + */ +struct sonode * +sosdp_create(vnode_t *accessvp, int domain, int type, int protocol, + int version, struct sonode *tso, int *errorp) +{ + struct sonode *so; + vnode_t *vp; + int error; + int soflags; + + + dprint(4, ("Inside sosdp_create: domain:%d proto:%d type:%d", + domain, protocol, type)); + + if (is_system_labeled()) { + *errorp = EOPNOTSUPP; + return (NULL); + } + + if (version == SOV_STREAM) { + *errorp = EINVAL; + return (NULL); + } + ASSERT(accessvp != NULL); + + /* + * We only support one type of SDP socket. Let sotpi_create() + * handle all other cases, such as raw socket. + */ + if (!(domain == AF_INET || domain == AF_INET6) || + !(type == SOCK_STREAM)) { + return (sotpi_create(accessvp, domain, type, protocol, version, + NULL, errorp)); + } + + if (tso == NULL) { + vp = sosdp_makevp(accessvp, domain, type, protocol, KM_SLEEP); + ASSERT(vp != NULL); + + soflags = FREAD | FWRITE; + } else { + vp = sosdp_makevp(accessvp, domain, type, protocol, + KM_NOSLEEP); + if (vp == NULL) { + /* + * sosdp_makevp() only fails when there is no memory. + */ + *errorp = ENOMEM; + return (NULL); + } + soflags = FREAD | FWRITE | SO_ACCEPTOR; + } + if ((error = VOP_OPEN(&vp, soflags, CRED())) != 0) { + VN_RELE(vp); + *errorp = error; + return (NULL); + } + so = VTOSO(vp); + + dprint(2, ("sosdp_create: %p domain %d type %d\n", so, domain, type)); + + if (version == SOV_DEFAULT) { + version = so_default_version; + } + so->so_version = (short)version; + + return (so); +} + +/* + * Free SDP socket data structure. + * Closes incoming connections which were never accepted, frees + * resources. + */ +void +sosdp_free(struct sonode *so) +{ + struct sonode *nso; + mblk_t *mp; + + dprint(3, ("sosdp_free: so:%p priv:%p", (void *)so, so->so_priv)); + + mutex_enter(&so->so_lock); + + /* + * Need to clear these out so that sockfree() doesn't think that + * there's memory in need of free'ing. + */ + so->so_laddr_sa = so->so_faddr_sa = NULL; + so->so_laddr_len = so->so_laddr_maxlen = 0; + so->so_faddr_len = so->so_faddr_maxlen = 0; + + while ((mp = so->so_conn_ind_head) != NULL) { + so->so_conn_ind_head = mp->b_next; + mutex_exit(&so->so_lock); + mp->b_next = NULL; + nso = *(struct sonode **)mp->b_rptr; + + (void) VOP_CLOSE(SOTOV(nso), 0, 1, 0, CRED()); + vn_invalid(SOTOV(nso)); + VN_RELE(SOTOV(nso)); + + freeb(mp); + mutex_enter(&so->so_lock); + } + so->so_conn_ind_tail = NULL; + so->so_state &= ~SS_HASCONNIND; + mutex_exit(&so->so_lock); + + sockfree(so); +} + +/* + * Accept incoming connection. + */ +static int +sosdp_accept(struct sonode *lso, int fflag, struct sonode **nsop) +{ + int error = 0; + mblk_t *mp; + struct sonode *nso; + + dprint(3, ("sosdp_accept: so:%p priv:%p", (void *)lso, + lso->so_priv)); + + if (!(lso->so_state & SS_ACCEPTCONN)) { + /* + * Not a listen socket. + */ + eprintsoline(lso, EINVAL); + return (EINVAL); + } + + /* + * Returns right away if socket is nonblocking. + */ + error = sowaitconnind(lso, fflag, &mp); + if (error != 0) { + eprintsoline(lso, error); + dprint(4, ("sosdp_accept: failed <%d>:lso:%p prv:%p", + error, (void *)lso, lso->so_priv)); + return (error); + } + nso = *(struct sonode **)mp->b_rptr; + freeb(mp); + + mutex_enter(&lso->so_lock); + ASSERT(SOTOSDO(lso)->ss_rxqueued > 0); + --SOTOSDO(lso)->ss_rxqueued; + mutex_exit(&lso->so_lock); + + + /* + * accept() needs remote address right away. + */ + (void) sosdp_getpeername(nso); + + dprint(2, ("sosdp_accept: new %p\n", nso)); + + *nsop = nso; + return (0); +} + +/* + * Bind local endpoint. + */ +int +sosdp_bind(struct sonode *so, struct sockaddr *name, socklen_t namelen, + int flags) +{ + int error = 0; + + if (!(flags & _SOBIND_LOCK_HELD)) { + mutex_enter(&so->so_lock); + so_lock_single(so); /* Set SOLOCKED */ + /* LINTED - statement has no conseq */ + } else { + ASSERT(MUTEX_HELD(&so->so_lock)); + ASSERT(so->so_flag & SOLOCKED); + } + + if ((so->so_state & SS_ISBOUND) || name == NULL || namelen == 0) { + /* + * Multiple binds not allowed for any SDP socket. + * Also binding with null address is not supported. + */ + error = EINVAL; + eprintsoline(so, error); + goto done; + } + /* + * X/Open requires this check + */ + if (so->so_state & SS_CANTSENDMORE) { + error = EINVAL; + goto done; + } + + /* + * Protocol module does address family checks. + */ + mutex_exit(&so->so_lock); + + error = sdp_bind(so->so_priv, name, namelen); + + mutex_enter(&so->so_lock); + if (error == 0) { + so->so_state |= SS_ISBOUND; + /* LINTED - statement has no conseq */ + } else { + eprintsoline(so, error); + } +done: + if (!(flags & _SOBIND_LOCK_HELD)) { + so_unlock_single(so, SOLOCKED); + mutex_exit(&so->so_lock); + /* LINTED - statement has no conseq */ + } else { + /* If the caller held the lock don't release it here */ + ASSERT(MUTEX_HELD(&so->so_lock)); + ASSERT(so->so_flag & SOLOCKED); + } + return (error); +} + +/* + * Turn socket into a listen socket. + */ +static int +sosdp_listen(struct sonode *so, int backlog) +{ + int error = 0; + + + mutex_enter(&so->so_lock); + so_lock_single(so); + + /* + * If this socket is trying to do connect, or if it has + * been connected, disallow. + */ + if (so->so_state & (SS_ISCONNECTING | SS_ISCONNECTED | + SS_ISDISCONNECTING | SS_CANTRCVMORE | SS_CANTSENDMORE)) { + error = EINVAL; + eprintsoline(so, error); + goto done; + } + + if (backlog < 0) { + backlog = 0; + } + + /* + * Use the same qlimit as in BSD. BSD checks the qlimit + * before queuing the next connection implying that a + * listen(sock, 0) allows one connection to be queued. + * BSD also uses 1.5 times the requested backlog. + * + * XNS Issue 4 required a strict interpretation of the backlog. + * This has been waived subsequently for Issue 4 and the change + * incorporated in XNS Issue 5. So we aren't required to do + * anything special for XPG apps. + */ + if (backlog >= (INT_MAX - 1) / 3) + backlog = INT_MAX; + else + backlog = backlog * 3 / 2 + 1; + + /* + * If listen() is only called to change backlog, we don't + * need to notify protocol module. + */ + if (so->so_state & SS_ACCEPTCONN) { + so->so_backlog = backlog; + goto done; + } + + mutex_exit(&so->so_lock); + + error = sdp_listen(so->so_priv, backlog); + + mutex_enter(&so->so_lock); + if (error == 0) { + so->so_state |= (SS_ACCEPTCONN|SS_ISBOUND); + so->so_backlog = backlog; + /* LINTED - statement has no conseq */ + } else { + eprintsoline(so, error); + } +done: + so_unlock_single(so, SOLOCKED); + mutex_exit(&so->so_lock); + + return (error); +} + +/* + * Active open. + */ +/*ARGSUSED*/ +static int +sosdp_connect(struct sonode *so, const struct sockaddr *name, + socklen_t namelen, int fflag, int flags) +{ + int error; + + ASSERT(so->so_type == SOCK_STREAM); + dprint(3, ("sosdp_connect: so:%p priv:%p", (void *)so, + so->so_priv)); + + mutex_enter(&so->so_lock); + so_lock_single(so); + + /* + * Can't connect() after listen(), or if the socket is already + * connected. + */ + if (so->so_state & (SS_ACCEPTCONN|SS_ISCONNECTED|SS_ISCONNECTING)) { + if (so->so_state & SS_ISCONNECTED) { + error = EISCONN; + } else if (so->so_state & SS_ISCONNECTING) { + error = EALREADY; + } else { + error = EOPNOTSUPP; + } + eprintsoline(so, error); + goto done; + } + + /* + * Check for failure of an earlier call + */ + if (so->so_error != 0) { + error = sogeterr(so); + eprintsoline(so, error); + goto done; + } + + /* + * Connection is closing, or closed, don't allow reconnect. + * TCP allows this to proceed, but the socket remains unwriteable. + * BSD returns EINVAL. + */ + if (so->so_state & (SS_ISDISCONNECTING|SS_CANTRCVMORE| + SS_CANTSENDMORE)) { + error = EINVAL; + eprintsoline(so, error); + goto done; + } + if (name == NULL || namelen == 0) { + error = EINVAL; + eprintsoline(so, error); + goto done; + } + soisconnecting(so); + + mutex_exit(&so->so_lock); + + error = sdp_connect(so->so_priv, name, namelen); + mutex_enter(&so->so_lock); + if (error == 0) { + /* + * Allow other threads to access the socket + */ + error = sosdp_waitconnected(so, fflag); + dprint(4, ("sosdp_connect: wait on so:%p priv:%p failed:%d", + (void *)so, so->so_priv, error)); + } + switch (error) { + case 0: + case EINPROGRESS: + case EALREADY: + case EINTR: + /* Non-fatal errors */ + so->so_state |= SS_ISBOUND; + break; + default: + /* clear SS_ISCONNECTING in case it was set */ + so->so_state &= ~SS_ISCONNECTING; + break; + } +done: + so_unlock_single(so, SOLOCKED); + mutex_exit(&so->so_lock); + return (error); +} + + +/* + * Receive data. + */ +int +sosdp_recvmsg(struct sonode *so, struct nmsghdr *msg, struct uio *uiop) +{ + int flags, error = 0; + int size; + + flags = msg->msg_flags; + msg->msg_flags = 0; + + + if (!(so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING| + SS_CANTRCVMORE))) { + return (ENOTCONN); + } + + /* + * flag possibilities: + * + * MSG_PEEK Don't consume data + * MSG_WAITALL Wait for full quantity of data (ignored if MSG_PEEK) + * MSG_DONTWAIT Non-blocking (same as FNDELAY | FNONBLOCK) + * + * MSG_WAITALL can return less than the full buffer if either + * + * 1. we would block and we are non-blocking + * 2. a full message cannot be delivered + * + */ + + mutex_enter(&so->so_lock); + + /* + * Allow just one reader at a time. + */ + error = so_lock_read_intr(so, uiop->uio_fmode); + if (error != 0) { + mutex_exit(&so->so_lock); + return (error); + } + size = uiop->uio_resid; + mutex_exit(&so->so_lock); + + if (!(so->so_state & SS_CANTRCVMORE)) { + if (uiop->uio_fmode & (FNDELAY|FNONBLOCK)) { + flags |= MSG_DONTWAIT; + } + error = sdp_recv(so->so_priv, msg, size, flags, uiop); + } else { + msg->msg_controllen = 0; + msg->msg_namelen = 0; + } +done: + mutex_enter(&so->so_lock); + so_unlock_read(so); + mutex_exit(&so->so_lock); + return (error); +} + +/* + * Send message. + */ +static int +sosdp_sendmsg(struct sonode *so, struct nmsghdr *msg, struct uio *uiop) +{ + int flags; + ssize_t count; + int error; + + ASSERT(so->so_type == SOCK_STREAM); + + dprint(4, ("sosdp_sendmsg: so:%p priv:%p", + (void *)so, so->so_priv)); + + flags = msg->msg_flags; + + if (msg->msg_controllen != 0) { + return (EOPNOTSUPP); + } + + mutex_enter(&so->so_lock); + if (so->so_state & SS_CANTSENDMORE) { + mutex_exit(&so->so_lock); + tsignal(curthread, SIGPIPE); + return (EPIPE); + } + + if (so->so_error != 0) { + error = sogeterr(so); + mutex_exit(&so->so_lock); + return (error); + } + + if (uiop->uio_fmode & (FNDELAY|FNONBLOCK)) + flags |= MSG_DONTWAIT; + + count = uiop->uio_resid; + + if (!(so->so_state & (SS_ISCONNECTING | SS_ISCONNECTED))) { + dprint(4, ("sosdp_sendmsg: invalid state: <%x>", + so->so_state)); + mutex_exit(&so->so_lock); + return (ENOTCONN); + } + + mutex_exit(&so->so_lock); + error = sdp_send(so->so_priv, msg, count, flags, uiop); + if (error == 0) + return (0); + + mutex_enter(&so->so_lock); + if ((error == EPIPE) && (so->so_state & SS_CANTSENDMORE)) { + /* + * We received shutdown between the time lock was + * lifted and call to sdp_sendmsg(). + */ + mutex_exit(&so->so_lock); + tsignal(curthread, SIGPIPE); + return (EPIPE); + } + mutex_exit(&so->so_lock); + return (error); +} + + +/* + * Get address of remote node. + */ +static int +sosdp_getpeername(struct sonode *so) +{ + int error; + + + if (!(so->so_state & SS_ISCONNECTED)) { + error = ENOTCONN; + } else { + error = sdp_getpeername(so->so_priv, so->so_faddr_sa, + &so->so_faddr_len); + } + return (error); +} + +/* + * Get local address. + */ +static int +sosdp_getsockname(struct sonode *so) +{ + int error; + + mutex_enter(&so->so_lock); + if (!(so->so_state & SS_ISBOUND)) { + /* + * Zero address, except for address family + */ + bzero(so->so_laddr_sa, so->so_laddr_maxlen); + + so->so_laddr_len = (so->so_family == AF_INET6) ? + sizeof (struct sockaddr_in6) : sizeof (struct sockaddr_in); + so->so_laddr_sa->sa_family = so->so_family; + error = 0; + mutex_exit(&so->so_lock); + } else { + mutex_exit(&so->so_lock); + + error = sdp_getsockname(so->so_priv, so->so_laddr_sa, + &so->so_laddr_len); + } + + return (error); +} + +/* + * Called from shutdown(). + */ +static int +sosdp_shutdown(struct sonode *so, int how) +{ + struct sdp_sonode *ss = SOTOSDO(so); + uint_t state_change; + int error = 0; + short wakesig = 0; + + mutex_enter(&so->so_lock); + so_lock_single(so); + + /* + * Record the current state and then perform any state changes. + * Then use the difference between the old and new states to + * determine which needs to be done. + */ + state_change = so->so_state; + + switch (how) { + case SHUT_RD: + socantrcvmore(so); + break; + case SHUT_WR: + socantsendmore(so); + break; + case SHUT_RDWR: + socantsendmore(so); + socantrcvmore(so); + break; + default: + error = EINVAL; + goto done; + } + + state_change = so->so_state & ~state_change; + + if (state_change & SS_CANTRCVMORE) { + wakesig = POLLIN|POLLRDNORM; + sosdp_sendsig(ss, SDPSIG_READ); + } + if (state_change & SS_CANTSENDMORE) { + wakesig |= POLLOUT; + so->so_state |= SS_ISDISCONNECTING; + } + mutex_exit(&so->so_lock); + + pollwakeup(&ss->ss_poll_list, wakesig); + + if (state_change & SS_CANTSENDMORE) { + error = sdp_shutdown(so->so_priv, how); + } + mutex_enter(&so->so_lock); +done: + so_unlock_single(so, SOLOCKED); + mutex_exit(&so->so_lock); + + /* + * HACK: sdp_disconnect() may return EWOULDBLOCK. But this error is + * not documented in standard socket API. Catch it here. + */ + if (error == EWOULDBLOCK) + error = 0; + return (error); +} + +/* + * Get socket options. + */ +/*ARGSUSED*/ +static int +sosdp_getsockopt(struct sonode *so, int level, int option_name, + void *optval, socklen_t *optlenp, int flags) +{ + int error = 0; + void *option = NULL; + socklen_t maxlen = *optlenp, len, optlen; + uint32_t value; + uint8_t buffer[4]; + void *optbuf = &buffer; + + + mutex_enter(&so->so_lock); + + if (level == SOL_SOCKET) { + switch (option_name) { + case SO_TYPE: + case SO_ERROR: + case SO_DEBUG: + case SO_ACCEPTCONN: + case SO_REUSEADDR: + case SO_KEEPALIVE: + case SO_DONTROUTE: + case SO_BROADCAST: + case SO_USELOOPBACK: + case SO_OOBINLINE: + case SO_SNDBUF: + case SO_RCVBUF: + case SO_SNDLOWAT: + case SO_RCVLOWAT: + case SO_DGRAM_ERRIND: + if (maxlen < (t_uscalar_t)sizeof (int32_t)) { + error = EINVAL; + eprintsoline(so, error); + goto done; + } + break; + case SO_LINGER: + if (maxlen < (t_uscalar_t)sizeof (struct linger)) { + error = EINVAL; + eprintsoline(so, error); + goto done; + } + break; + } + len = (t_uscalar_t)sizeof (uint32_t); /* Default */ + option = &value; + + switch (option_name) { + case SO_TYPE: + value = so->so_type; + goto copyout; + + case SO_ERROR: + value = sogeterr(so); + goto copyout; + + case SO_ACCEPTCONN: + value = (so->so_state & SS_ACCEPTCONN) ? + SO_ACCEPTCONN : 0; + goto copyout; + + case SO_DEBUG: + case SO_REUSEADDR: + case SO_KEEPALIVE: + case SO_DONTROUTE: + case SO_BROADCAST: + case SO_USELOOPBACK: + case SO_OOBINLINE: + case SO_DGRAM_ERRIND: + value = (so->so_options & option_name); + goto copyout; + + /* + * The following options are only returned by sockfs + * when sdp_get_opt() fails. + */ + + case SO_LINGER: + option = &so->so_linger; + len = (t_uscalar_t)sizeof (struct linger); + break; + case SO_SNDBUF: + value = so->so_sndbuf; + len = (t_uscalar_t)sizeof (int); + goto copyout; + + case SO_RCVBUF: + value = so->so_rcvbuf; + len = (t_uscalar_t)sizeof (int); + goto copyout; + + case SO_SNDLOWAT: + value = so->so_sndlowat; + len = (t_uscalar_t)sizeof (int); + goto copyout; + + case SO_RCVLOWAT: + value = so->so_rcvlowat; + len = (t_uscalar_t)sizeof (int); + goto copyout; + + default: + option = NULL; + break; + } + } + if (maxlen > sizeof (buffer)) { + optbuf = kmem_alloc(maxlen, KM_SLEEP); + } + optlen = maxlen; + mutex_exit(&so->so_lock); + error = sdp_get_opt(so->so_priv, level, option_name, optbuf, &optlen); + mutex_enter(&so->so_lock); + ASSERT(optlen <= maxlen); + if (error != 0) { + if (option == NULL) { + /* We have no fallback value */ + eprintsoline(so, error); + goto free; + } + error = 0; + goto copyout; + } + + option = optbuf; + len = optlen; + +copyout: + len = MIN(len, maxlen); + bcopy(option, optval, len); + *optlenp = len; + +free: + if (optbuf != &buffer) { + kmem_free(optbuf, maxlen); + } +done: + mutex_exit(&so->so_lock); + return (error); +} + +/* + * Set socket options + */ +static int +sosdp_setsockopt(struct sonode *so, int level, int option_name, + const void *optval, t_uscalar_t optlen) +{ + int error; + void *conn = NULL; + + + /* X/Open requires this check */ + if (so->so_state & SS_CANTSENDMORE) { + return (EINVAL); + } + + /* Caller allocates aligned optval, or passes null */ + ASSERT(((uintptr_t)optval & (sizeof (t_scalar_t) - 1)) == 0); + + /* No SDP options should be zero-length */ + if (optlen == 0) { + error = EINVAL; + eprintsoline(so, error); + return (error); + } + + mutex_enter(&so->so_lock); + so_lock_single(so); + + if (so->so_type == SOCK_STREAM) { + conn = so->so_priv; + } + + dprint(2, ("sosdp_setsockopt (%d) - conn %p %d %d \n", + so->so_type, conn, level, option_name)); + if (conn != NULL) { + mutex_exit(&so->so_lock); + error = sdp_set_opt(conn, level, option_name, optval, optlen); + mutex_enter(&so->so_lock); + } + /* + * Check for SOL_SOCKET options and record their values. + * If we know about a SOL_SOCKET parameter and the transport + * failed it with TBADOPT or TOUTSTATE (i.e. ENOPROTOOPT or + * EPROTO) we let the setsockopt succeed. + */ + if (level == SOL_SOCKET) { + boolean_t handled = B_FALSE; + + /* Check parameters */ + switch (option_name) { + case SO_DEBUG: + case SO_REUSEADDR: + case SO_KEEPALIVE: + case SO_DONTROUTE: + case SO_BROADCAST: + case SO_USELOOPBACK: + case SO_OOBINLINE: + case SO_SNDBUF: + case SO_RCVBUF: + case SO_SNDLOWAT: + case SO_RCVLOWAT: + case SO_DGRAM_ERRIND: + if (optlen != (t_uscalar_t)sizeof (int32_t)) { + error = EINVAL; + eprintsoline(so, error); + goto done; + } + ASSERT(optval); + handled = B_TRUE; + break; + case SO_LINGER: + if (optlen != (t_uscalar_t)sizeof (struct linger)) { + error = EINVAL; + eprintsoline(so, error); + goto done; + } + ASSERT(optval); + handled = B_TRUE; + break; + } + +#define intvalue (*(int32_t *)optval) + + switch (option_name) { + case SO_TYPE: + case SO_ERROR: + case SO_ACCEPTCONN: + /* Can't be set */ + error = ENOPROTOOPT; + goto done; + case SO_LINGER: { + struct linger *l = (struct linger *)optval; + + so->so_linger.l_linger = l->l_linger; + if (l->l_onoff) { + so->so_linger.l_onoff = SO_LINGER; + so->so_options |= SO_LINGER; + } else { + so->so_linger.l_onoff = 0; + so->so_options &= ~SO_LINGER; + } + break; + } + + case SO_DEBUG: + case SO_REUSEADDR: + case SO_KEEPALIVE: + case SO_DONTROUTE: + case SO_BROADCAST: + case SO_USELOOPBACK: + case SO_OOBINLINE: + case SO_DGRAM_ERRIND: + if (intvalue != 0) { + dprintso(so, 1, + ("sosdp_setsockopt: setting 0x%x\n", + option_name)); + so->so_options |= option_name; + } else { + dprintso(so, 1, + ("sosdp_setsockopt: clearing 0x%x\n", + option_name)); + so->so_options &= ~option_name; + } + break; + + case SO_SNDBUF: + so->so_sndbuf = intvalue; + if (so->so_sndlowat > so->so_sndbuf) { + so->so_sndlowat = so->so_sndbuf; + } + break; + case SO_RCVBUF: + so->so_rcvbuf = intvalue; + if (so->so_rcvlowat > so->so_rcvbuf) { + so->so_rcvlowat = so->so_rcvbuf; + } + break; + case SO_SNDLOWAT: + if (so->so_sndlowat > so->so_sndbuf) { + so->so_sndlowat = so->so_sndbuf; + } + break; + case SO_RCVLOWAT: + if (so->so_rcvlowat > so->so_rcvbuf) { + so->so_rcvlowat = so->so_rcvbuf; + } + break; + } +#undef intvalue + + if (error != 0) { + if ((error == ENOPROTOOPT || error == EPROTO || + error == EINVAL) && handled) { + dprintso(so, 1, + ("sosdp_setsockopt: ignoring error %d " + "for 0x%x\n", error, option_name)); + error = 0; + } + } + } + +done: + so_unlock_single(so, SOLOCKED); + mutex_exit(&so->so_lock); + + return (error); +} + +/* + * Upcalls from SDP + */ + +/* + * Incoming connection on listen socket. + */ +static void * +sdp_sock_newconn(void *parenthandle, void *connind) +{ + struct sdp_sonode *lss = parenthandle; + struct sonode *lso = &lss->ss_so; + struct sonode *nso; + struct sdp_sonode *nss; + mblk_t *mp; + int error; + + ASSERT(lso->so_state & SS_ACCEPTCONN); + ASSERT(lso->so_priv != NULL); /* closed conn */ + ASSERT(lso->so_type == SOCK_STREAM); + + dprint(3, ("sosdp_newconn A: so:%p priv:%p", (void *)lso, + lso->so_priv)); + + /* + * Check current # of queued conns against backlog + */ + if (lss->ss_rxqueued >= lso->so_backlog) { + return (NULL); + } + + /* + * Need to create a new socket. + */ + mp = allocb(sizeof (connind), BPRI_MED); + if (mp == NULL) { + eprintsoline(lso, ENOMEM); + return (NULL); + } + DB_TYPE(mp) = M_PROTO; + + VN_HOLD(lso->so_accessvp); + nso = sosdp_create(lso->so_accessvp, lso->so_family, lso->so_type, + lso->so_protocol, lso->so_version, lso, &error); + if (nso == NULL) { + VN_RELE(lso->so_accessvp); + freeb(mp); + eprintsoline(lso, error); + return (NULL); + } + + dprint(2, ("sdp_stream_newconn: new %p\n", nso)); + nss = SOTOSDO(nso); + + /* + * Inherit socket properties + */ + mutex_enter(&lso->so_lock); + mutex_enter(&nso->so_lock); + + nso->so_state |= (SS_ISBOUND | SS_ISCONNECTED | + (lso->so_state & SS_ASYNC)); + sosdp_so_inherit(lss, nss); + nso->so_priv = connind; + + mutex_exit(&nso->so_lock); + + ++lss->ss_rxqueued; + mutex_exit(&lso->so_lock); + + /* + * Copy pointer to new socket to connind queue message + */ + *(struct sonode **)mp->b_wptr = nso; + mp->b_wptr += sizeof (nso); + + /* + * Wake people who're waiting incoming conns. Note that + * soqueueconnind gets so_lock. + */ + soqueueconnind(lso, mp); + pollwakeup(&lss->ss_poll_list, POLLIN|POLLRDNORM); + + mutex_enter(&lso->so_lock); + sosdp_sendsig(lss, SDPSIG_READ); + mutex_exit(&lso->so_lock); + return (nss); +} + +/* + * For outgoing connections, the connection has been established. + */ +static void +sdp_sock_connected(void *handle) +{ + struct sdp_sonode *ss = handle; + struct sonode *so = &ss->ss_so; + + ASSERT(so->so_type == SOCK_STREAM); + dprint(3, ("sosdp_connected C: so:%p priv:%p", (void *)so, + so->so_priv)); + + mutex_enter(&so->so_lock); + ASSERT(so->so_priv); /* closed conn */ + + ASSERT(!(so->so_state & SS_ACCEPTCONN)); + soisconnected(so); + + sosdp_sendsig(ss, SDPSIG_WRITE); + mutex_exit(&so->so_lock); + + /* + * Wake ones who're waiting for conn to become established. + */ + pollwakeup(&ss->ss_poll_list, POLLOUT); +} + +/* + * Connection got disconnected. Either with an error, or through + * normal handshake. + */ +static void +sdp_sock_disconnected(void *handle, int error) +{ + int event = 0; + struct sdp_sonode *ss = handle; + struct sonode *so = &ss->ss_so; + + ASSERT(so->so_type == SOCK_STREAM); + dprint(2, ("sosdp_disconnected C: so:%p priv:%p error:%d", + (void *)so, so->so_priv, error)); + + mutex_enter(&so->so_lock); + ASSERT(so->so_priv != NULL); /* closed conn */ + + /* + * If socket is already disconnected/disconnecting, + * don't (re)send signal. + */ + if (!(so->so_state & SS_CANTRCVMORE)) + event |= SDPSIG_READ; + if (!(so->so_state & SS_CANTSENDMORE)) + event |= SDPSIG_WRITE; + if (event != 0) + sosdp_sendsig(ss, event); + + soisdisconnected(so, error); + mutex_exit(&so->so_lock); + + pollwakeup(&ss->ss_poll_list, POLLIN|POLLRDNORM|POLLOUT); +} + +/* + * Incoming data. + */ +/*ARGSUSED*/ +static int +sdp_sock_recv(void *handle, mblk_t *mp, int flags) +{ + struct sdp_sonode *ss = handle; + struct sonode *so = &ss->ss_so; + + ASSERT(so->so_type == SOCK_STREAM); + + mutex_enter(&so->so_lock); + sosdp_sendsig(ss, SDPSIG_READ); + mutex_exit(&so->so_lock); + pollwakeup(&ss->ss_poll_list, POLLIN|POLLRDNORM); + + return (so->so_rcvbuf); +} + +/* + * TX queued data got acknowledged. + */ +static void +sdp_sock_xmitted(void *handle, int writeable) +{ + struct sdp_sonode *ss = handle; + struct sonode *so = &ss->ss_so; + + dprint(4, ("sosdp_sock_xmitted: so:%p priv:%p txq:%d", + (void *)so, so->so_priv, writeable)); + mutex_enter(&so->so_lock); + ASSERT(so->so_priv != NULL); /* closed conn */ + + + /* + * Only do pollwakeup if the amount of queued data is less than + * watermark. + */ + if (!writeable) { + sosdp_sendsig(ss, SDPSIG_WRITE); + mutex_exit(&so->so_lock); + pollwakeup(&ss->ss_poll_list, POLLOUT); + } else { + mutex_exit(&so->so_lock); + } +} + + +/* + * SDP notifies socket for presence of urgent data. + */ +static void +sdp_sock_urgdata(void *handle) +{ + struct sdp_sonode *ss = handle; + + ASSERT(ss->ss_so.so_type == SOCK_STREAM); + + mutex_enter(&ss->ss_so.so_lock); + + ASSERT(ss->ss_so.so_priv != NULL); /* closed conn */ + sosdp_sendsig(ss, SDPSIG_URG); + + mutex_exit(&ss->ss_so.so_lock); +} + +/* + * SDP notifies socket about receiving of conn close request from peer side. + */ +static void +sdp_sock_ordrel(void *handle) +{ + struct sdp_sonode *ss = handle; + /* LINTED */ + struct sonode *so = &ss->ss_so; + + ASSERT(ss->ss_so.so_type == SOCK_STREAM); + + dprint(4, ("sdp_sock_ordrel : so:%p, priv:%p", + (void *)so, so->so_priv)); + mutex_enter(&ss->ss_so.so_lock); + socantrcvmore(&ss->ss_so); + mutex_exit(&ss->ss_so.so_lock); + pollwakeup(&ss->ss_poll_list, POLLIN|POLLRDNORM); +} + +static void +sdp_sock_connfail(void *handle, int error) +{ + + struct sdp_sonode *ss = handle; + struct sonode *so = &ss->ss_so; + + dprint(3, ("sosdp_conn Failed: so:%p priv:%p", (void *)so, + so->so_priv)); + mutex_enter(&so->so_lock); + ASSERT(so->so_priv != NULL); /* closed conn */ + so->so_state &= ~(SS_ISCONNECTING|SS_ISCONNECTED|SS_ISDISCONNECTING); + so->so_error = (ushort_t)error; + mutex_exit(&so->so_lock); + cv_broadcast(&so->so_state_cv); +} diff --git a/usr/src/uts/common/fs/sockfs/socksdp.h b/usr/src/uts/common/fs/sockfs/socksdp.h new file mode 100755 index 0000000000..68231bb0e5 --- /dev/null +++ b/usr/src/uts/common/fs/sockfs/socksdp.h @@ -0,0 +1,85 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _SOCKSDP_H_ +#define _SOCKSDP_H_ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * SDP socket structure. + * + * The opaque pointer passed in upcalls is a pointer to sdp_sonode. + */ +struct sdp_sonode { + int ss_type; /* sonode or soassoc */ + struct sonode ss_so; + struct sockaddr_in6 ss_laddr; /* can fit both v4 & v6 */ + struct sockaddr_in6 ss_faddr; + int ss_rxqueued; /* queued # of conn */ + struct pollhead ss_poll_list; +}; + +extern sdp_upcalls_t sosdp_sock_upcalls; +extern struct vnodeops *socksdp_vnodeops; +extern const fs_operation_def_t socksdp_vnodeops_template[]; + +extern void sosdp_free(struct sonode *so); +extern int sosdp_chgpgrp(struct sdp_sonode *ss, pid_t pid); +extern void sosdp_sendsig(struct sdp_sonode *ss, int event); + +extern int sosdp_bind(struct sonode *so, struct sockaddr *name, + socklen_t namelen, int flags); +extern int sosdp_recvmsg(struct sonode *, struct nmsghdr *, struct uio *); + +extern int sosdp_waitconnected(struct sonode *so, int fmode); + +extern void sosdp_so_inherit(struct sdp_sonode *lss, struct sdp_sonode *nss); + +/* + * Data structure types. + */ +#define SOSDP_SOCKET 0x1 + +#define SOTOSDO(so) ((struct sdp_sonode *)(((char *)so) - \ + offsetof(struct sdp_sonode, ss_so))) + +/* + * Event flags to sosdp_sendsig(). + */ +#define SDPSIG_WRITE 0x1 +#define SDPSIG_READ 0x2 +#define SDPSIG_URG 0x4 + +#ifdef __cplusplus +} +#endif + +#endif /* _SOCKSDP_H_ */ diff --git a/usr/src/uts/common/fs/sockfs/socksdpsubr.c b/usr/src/uts/common/fs/sockfs/socksdpsubr.c new file mode 100755 index 0000000000..6ae3c4d03d --- /dev/null +++ b/usr/src/uts/common/fs/sockfs/socksdpsubr.c @@ -0,0 +1,213 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <sys/types.h> +#include <sys/t_lock.h> +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/debug.h> +#include <sys/errno.h> +#include <sys/strsubr.h> +#include <sys/cmn_err.h> +#include <sys/sysmacros.h> + +#include <sys/vfs.h> + +#include <sys/socket.h> +#include <sys/socketvar.h> +#include <sys/strsun.h> +#include <sys/signal.h> + +#include <inet/sdp_itf.h> +#include "socksdp.h" + + +/* + * Wait until the socket is connected or there is an error. + * fmode should contain any nonblocking flags. + */ +int +sosdp_waitconnected(struct sonode *so, int fmode) +{ + int error; + + ASSERT(MUTEX_HELD(&so->so_lock)); + ASSERT((so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING)) || + so->so_error != 0); + + while ((so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING)) == + SS_ISCONNECTING && so->so_error == 0) { + + dprint(3, ("waiting for SS_ISCONNECTED on %p\n", so)); + if (fmode & (FNDELAY|FNONBLOCK)) + return (EINPROGRESS); + + if (!cv_wait_sig_swap(&so->so_state_cv, &so->so_lock)) { + /* + * Return EINTR and let the application use + * nonblocking techniques for detecting when + * the connection has been established. + */ + error = EINTR; + break; + } + dprint(3, ("awoken on %p\n", so)); + } + + if (so->so_error != 0) { + error = sogeterr(so); + ASSERT(error != 0); + dprint(3, ("sosdp_waitconnected: error %d\n", error)); + } else if (so->so_state & SS_ISCONNECTED) { + error = 0; + } + return (error); +} + + +/* + * Change the process/process group to which SIGIO is sent. + */ +int +sosdp_chgpgrp(struct sdp_sonode *ss, pid_t pid) +{ + int error; + + ASSERT(MUTEX_HELD(&ss->ss_so.so_lock)); + if (pid != 0) { + /* + * Permissions check by sending signal 0. + * Note that when kill fails it does a + * set_errno causing the system call to fail. + */ + error = kill(pid, 0); + if (error != 0) { + return (error); + } + } + ss->ss_so.so_pgrp = pid; + return (0); +} + + +/* + * Generate a SIGIO, for 'writable' events include siginfo structure, + * for read events just send the signal. + */ +/*ARGSUSED*/ +static void +sosdp_sigproc(proc_t *proc, int event) +{ + k_siginfo_t info; + + if (event & SDPSIG_WRITE) { + info.si_signo = SIGPOLL; + info.si_code = POLL_OUT; + info.si_errno = 0; + info.si_fd = 0; + info.si_band = 0; + sigaddq(proc, NULL, &info, KM_NOSLEEP); + } + if (event & SDPSIG_READ) { + sigtoproc(proc, NULL, SIGPOLL); + } + if (event & SDPSIG_URG) { + sigtoproc(proc, NULL, SIGURG); + } +} + +void +sosdp_sendsig(struct sdp_sonode *ss, int event) +{ + proc_t *proc; + struct sonode *so = &ss->ss_so; + + ASSERT(MUTEX_HELD(&ss->ss_so.so_lock)); + + if (so->so_pgrp == 0 || (!(so->so_state & SS_ASYNC) && + event != SDPSIG_URG)) { + return; + } + + dprint(3, ("sending sig %d to %d\n", event, so->so_pgrp)); + + if (so->so_pgrp > 0) { + /* + * XXX This unfortunately still generates + * a signal when a fd is closed but + * the proc is active. + */ + mutex_enter(&pidlock); + proc = prfind(so->so_pgrp); + if (proc == NULL) { + mutex_exit(&pidlock); + return; + } + mutex_enter(&proc->p_lock); + mutex_exit(&pidlock); + sosdp_sigproc(proc, event); + mutex_exit(&proc->p_lock); + } else { + /* + * Send to process group. Hold pidlock across + * calls to sosdp_sigproc(). + */ + pid_t pgrp = -so->so_pgrp; + + mutex_enter(&pidlock); + proc = pgfind(pgrp); + while (proc != NULL) { + mutex_enter(&proc->p_lock); + sosdp_sigproc(proc, event); + mutex_exit(&proc->p_lock); + proc = proc->p_pglink; + } + mutex_exit(&pidlock); + } +} + + +/* + * Inherit socket properties + */ +void +sosdp_so_inherit(struct sdp_sonode *lss, struct sdp_sonode *nss) +{ + struct sonode *nso = &nss->ss_so; + struct sonode *lso = &lss->ss_so; + + nso->so_options = lso->so_options & (SO_DEBUG|SO_REUSEADDR| + SO_KEEPALIVE|SO_DONTROUTE|SO_BROADCAST|SO_USELOOPBACK| + SO_OOBINLINE|SO_DGRAM_ERRIND|SO_LINGER); + nso->so_sndbuf = lso->so_sndbuf; + nso->so_rcvbuf = lso->so_rcvbuf; + nso->so_pgrp = lso->so_pgrp; + + nso->so_rcvlowat = lso->so_rcvlowat; + nso->so_sndlowat = lso->so_sndlowat; +} diff --git a/usr/src/uts/common/fs/sockfs/socksdpvnops.c b/usr/src/uts/common/fs/sockfs/socksdpvnops.c new file mode 100755 index 0000000000..ada23d844d --- /dev/null +++ b/usr/src/uts/common/fs/sockfs/socksdpvnops.c @@ -0,0 +1,520 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <sys/types.h> +#include <sys/t_lock.h> +#include <sys/param.h> +#include <sys/systm.h> +#include <sys/buf.h> +#include <sys/debug.h> +#include <sys/errno.h> +#include <sys/uio.h> +#include <sys/vfs.h> +#include <sys/vnode.h> +#include <sys/stropts.h> +#include <sys/cmn_err.h> +#include <sys/sysmacros.h> +#include <sys/stream.h> +#include <sys/strsun.h> + +#include <sys/socket.h> +#include <sys/socketvar.h> + +#include <sys/project.h> +#include <sys/strsubr.h> + +#include <fs/fs_subr.h> + +#include <sys/esunddi.h> +#include <sys/ddi.h> + +#include <sys/filio.h> +#include <sys/sockio.h> + +#include <inet/sdp_itf.h> +#include "socksdp.h" + +/* + * SDP sockfs vnode operations + */ +static int socksdpv_open(struct vnode **, int, struct cred *); +static int socksdpv_close(struct vnode *, int, int, offset_t, + struct cred *); +static int socksdpv_read(struct vnode *vp, struct uio *uiop, int ioflag, + struct cred *cr, struct caller_context *ct); +static int socksdpv_write(struct vnode *, struct uio *, int, struct cred *); +static int socksdpv_ioctl(struct vnode *, int, intptr_t, int, + struct cred *, int32_t *); +static int socksdp_setfl(vnode_t *vp, int oflags, int nflags, cred_t *cr); +static void socksdpv_inactive(struct vnode *, struct cred *); +static int socksdpv_poll(struct vnode *, short, int, short *, + struct pollhead **); + +const fs_operation_def_t socksdp_vnodeops_template[] = { + VOPNAME_OPEN, socksdpv_open, + VOPNAME_CLOSE, socksdpv_close, + VOPNAME_READ, socksdpv_read, + VOPNAME_WRITE, socksdpv_write, + VOPNAME_IOCTL, socksdpv_ioctl, + VOPNAME_SETFL, socksdp_setfl, + VOPNAME_GETATTR, socktpi_getattr, + VOPNAME_SETATTR, socktpi_setattr, + VOPNAME_ACCESS, socktpi_access, + VOPNAME_FSYNC, socktpi_fsync, + VOPNAME_INACTIVE, (fs_generic_func_p) socksdpv_inactive, + VOPNAME_FID, socktpi_fid, + VOPNAME_SEEK, socktpi_seek, + VOPNAME_POLL, (fs_generic_func_p) socksdpv_poll, + VOPNAME_DISPOSE, fs_error, + NULL, NULL +}; +struct vnodeops *socksdp_vnodeops; + +static int +socksdpv_open(struct vnode **vpp, int flag, struct cred *cr) +{ + struct sonode *so; + struct sdp_sonode *ss; + struct vnode *vp = *vpp; + int error = 0; + sdp_sockbuf_limits_t sbl; + sdp_upcalls_t *upcalls; + + flag &= ~FCREAT; /* paranoia */ + + so = VTOSO(vp); + ss = SOTOSDO(so); + + mutex_enter(&so->so_lock); + so->so_count++; /* one more open reference */ + ASSERT(so->so_count != 0); /* wraparound */ + mutex_exit(&so->so_lock); + + ASSERT(vp->v_type == VSOCK); + + if (flag & SO_ACCEPTOR) { + ASSERT(so->so_type == SOCK_STREAM); + return (0); + } + + /* + * Active open. + */ + upcalls = &sosdp_sock_upcalls; + + so->so_priv = sdp_create(ss, NULL, so->so_family, SDP_CAN_BLOCK, + upcalls, &sbl, cr, &error); + if (so->so_priv == NULL) { + mutex_enter(&so->so_lock); + ASSERT(so->so_count > 0); + so->so_count--; /* one less open reference */ + mutex_exit(&so->so_lock); + return (error); + } + so->so_rcvbuf = sbl.sbl_rxbuf; + so->so_rcvlowat = sbl.sbl_rxlowat; + so->so_sndbuf = sbl.sbl_txbuf; + so->so_sndlowat = sbl.sbl_txlowat; + + return (error); +} + +/*ARGSUSED*/ +static int +socksdpv_close(struct vnode *vp, int flag, int count, offset_t offset, + struct cred *cr) +{ + int sendsig = 0; + int error = 0; + struct sonode *so; + struct sdp_sonode *ss; + + so = VTOSO(vp); + ss = SOTOSDO(so); + + cleanlocks(vp, ttoproc(curthread)->p_pid, 0); + cleanshares(vp, ttoproc(curthread)->p_pid); + + ASSERT(vp->v_stream == NULL); + if (count > 1) { + dprint(2, ("socksdpv_close: count %d\n", count)); + return (0); + } + + mutex_enter(&so->so_lock); + so_lock_single(so); /* Set SOLOCKED */ + ASSERT(so->so_count > 0); + so->so_count--; /* one fewer open reference */ + + dprint(2, ("socksdpv_close: %p so_count %d\n", so, so->so_count)); + + if (so->so_count == 0) { + /* + * Need to set flags as there might be ops in progress on + * this socket. + * + * If socket already disconnected/disconnecting, + * don't send signal (again). + */ + if (!(so->so_state & SS_CANTRCVMORE)) + sendsig |= SDPSIG_READ; + if (!(so->so_state & SS_CANTSENDMORE)) + sendsig |= SDPSIG_WRITE; + soisdisconnected(so, 0); + mutex_exit(&so->so_lock); + + /* + * Initiate connection shutdown. + */ + error = sdp_disconnect(so->so_priv, flag); + + mutex_enter(&so->so_lock); + if (sendsig != 0) + sosdp_sendsig(ss, sendsig); + mutex_exit(&so->so_lock); + + pollwakeup(&ss->ss_poll_list, POLLIN|POLLRDNORM|POLLOUT); + } + mutex_enter(&so->so_lock); + so_unlock_single(so, SOLOCKED); + mutex_exit(&so->so_lock); + + return (error); +} + +/*ARGSUSED2*/ +static int +socksdpv_read(struct vnode *vp, struct uio *uiop, int ioflag, struct cred *cr, + struct caller_context *ct) +{ + struct sonode *so = VTOSO(vp); + struct nmsghdr lmsg; + + if (so->so_type != SOCK_STREAM) { + return (EOPNOTSUPP); + } + + ASSERT(vp->v_type == VSOCK); + so_update_attrs(so, SOACC); + lmsg.msg_namelen = 0; + lmsg.msg_controllen = 0; + lmsg.msg_flags = 0; + return (sosdp_recvmsg(so, &lmsg, uiop)); +} + +/* + * Send data, see sosdp_sendmsg() + */ +/*ARGSUSED2*/ +static int +socksdpv_write(struct vnode *vp, struct uio *uiop, int ioflag, struct cred *cr) +{ + struct sonode *so; + ssize_t count; + int error; + int flags = 0; + + so = VTOSO(vp); + + mutex_enter(&so->so_lock); + if (so->so_state & SS_CANTSENDMORE) { + mutex_exit(&so->so_lock); + tsignal(curthread, SIGPIPE); + return (EPIPE); + } + + if (so->so_error != 0) { + error = sogeterr(so); + if (error != 0) { + mutex_exit(&so->so_lock); + return (error); + } + } + + if (uiop->uio_fmode & (FNDELAY|FNONBLOCK)) + flags |= MSG_DONTWAIT; + + if (!(so->so_state & (SS_ISCONNECTING | SS_ISCONNECTED))) { + mutex_exit(&so->so_lock); + return (ENOTCONN); + } + count = uiop->uio_resid; + mutex_exit(&so->so_lock); + + if (count == 0) { + return (0); + } + so_update_attrs(so, SOMOD); + + error = sdp_send(so->so_priv, NULL, count, flags, uiop); + return (error); +} + +/*ARGSUSED4*/ +static int +socksdpv_ioctl(struct vnode *vp, int cmd, intptr_t arg, int mode, + struct cred *cr, int32_t *rvalp) +{ + struct sonode *so; + struct sdp_sonode *ss; + int32_t value; + int error, intval; + pid_t pid; + + so = VTOSO(vp); + ss = SOTOSDO(so); + + /* handle socket specific ioctls */ + switch (cmd) { + case FIONBIO: + if (so_copyin((void *)arg, &value, sizeof (int32_t), + (mode & (int)FKIOCTL))) { + return (EFAULT); + } + mutex_enter(&so->so_lock); + if (value != 0) { + so->so_state |= SS_NDELAY; + } else { + so->so_state &= ~SS_NDELAY; + } + mutex_exit(&so->so_lock); + return (0); + + case FIOASYNC: + if (so_copyin((void *)arg, &value, sizeof (int32_t), + (mode & (int)FKIOCTL))) { + return (EFAULT); + } + mutex_enter(&so->so_lock); + + if (value) { + /* Turn on SIGIO */ + so->so_state |= SS_ASYNC; + } else { + /* Turn off SIGIO */ + so->so_state &= ~SS_ASYNC; + } + mutex_exit(&so->so_lock); + return (0); + + case SIOCSPGRP: + case FIOSETOWN: + if (so_copyin((void *)arg, &pid, sizeof (pid_t), + (mode & (int)FKIOCTL))) { + return (EFAULT); + } + mutex_enter(&so->so_lock); + + error = (pid != so->so_pgrp) ? sosdp_chgpgrp(ss, pid) : 0; + mutex_exit(&so->so_lock); + return (error); + + case SIOCGPGRP: + case FIOGETOWN: + if (so_copyout(&so->so_pgrp, (void *)arg, + sizeof (pid_t), (mode & (int)FKIOCTL))) + return (EFAULT); + return (0); + + case SIOCATMARK: + intval = 0; + error = sdp_ioctl(so->so_priv, cmd, &intval, cr); + if (so_copyout(&intval, (void *)arg, sizeof (int), + (mode & (int)FKIOCTL))) + return (EFAULT); + return (0); + + + case SIOSYSENABLESDP: { + int32_t enable; + + /* + * System wide enable SDP + */ + + if (so_copyin((void *)arg, &enable, sizeof (int32_t), + mode & (int)FKIOCTL)) + return (EFAULT); + + error = sdp_ioctl(so->so_priv, cmd, &enable, cr); + if (so_copyout(&enable, (void *)arg, + sizeof (int32_t), (mode & (int)FKIOCTL))) + return (EFAULT); + return (0); + } + /* from strioctl */ + case FIONREAD: + /* + * Return number of bytes of data in all data messages + * in queue in "arg". + * For stream socket, amount of available data. + */ + if (so->so_state & SS_ACCEPTCONN) { + intval = 0; + } else { + mutex_enter(&so->so_lock); + intval = sdp_polldata(so->so_priv, SDP_READ); + mutex_exit(&so->so_lock); + } + if (so_copyout(&intval, (void *)arg, sizeof (intval), + (mode & (int)FKIOCTL))) + return (EFAULT); + return (0); + default: + return (EINVAL); + } + +} + +/* + * Allow any flags. Record FNDELAY and FNONBLOCK so that they can be inherited + * from listener to acceptor. + */ +/* ARGSUSED */ +static int +socksdp_setfl(vnode_t *vp, int oflags, int nflags, cred_t *cr) +{ + struct sonode *so; + + so = VTOSO(vp); + + mutex_enter(&so->so_lock); + if (nflags & FNDELAY) + so->so_state |= SS_NDELAY; + else + so->so_state &= ~SS_NDELAY; + if (nflags & FNONBLOCK) + so->so_state |= SS_NONBLOCK; + else + so->so_state &= ~SS_NONBLOCK; + mutex_exit(&so->so_lock); + return (0); +} + +/*ARGSUSED*/ +static void +socksdpv_inactive(struct vnode *vp, struct cred *cr) +{ + struct sonode *so; + + so = VTOSO(vp); + + mutex_enter(&vp->v_lock); + /* + * If no one has reclaimed the vnode, remove from the + * cache now. + */ + if (vp->v_count < 1) + cmn_err(CE_PANIC, "socksdpv_inactive: Bad v_count"); + + /* + * Drop the temporary hold by vn_rele now + */ + if (--vp->v_count != 0) { + mutex_exit(&vp->v_lock); + return; + } + mutex_exit(&vp->v_lock); + + /* We are the sole owner of so now */ + + ASSERT(!vn_has_cached_data(vp)); + if (so->so_priv) { + sdp_close(so->so_priv); + } + so->so_priv = NULL; + sosdp_free(so); +} + +/* + * Check socktpi_poll() on why so_lock is not held in this function. + */ +static int +socksdpv_poll(struct vnode *vp, short events, int anyyet, short *reventsp, + struct pollhead **phpp) +{ + struct sonode *so; + struct sdp_sonode *ss; + short origevents = events; + int so_state; + + so = VTOSO(vp); + ss = SOTOSDO(so); + so_state = so->so_state; + + + ASSERT(vp->v_type == VSOCK); + ASSERT(vp->v_stream == NULL); + ASSERT(so->so_version != SOV_STREAM); + + if (!(so_state & SS_ISCONNECTED) && (so->so_type == SOCK_STREAM)) { + /* + * Not connected yet - turn off write side events + */ + events &= ~(POLLOUT|POLLWRBAND); + } + + /* + * Check for errors + */ + if (so->so_error != 0 && + ((POLLIN|POLLRDNORM|POLLOUT) & origevents) != 0) { + *reventsp = (POLLIN|POLLRDNORM|POLLOUT) & origevents; + return (0); + } + + *reventsp = 0; + + /* + * Don't mark socket as writable until TX queued data is + * below watermark. + */ + if (so->so_type == SOCK_STREAM) { + if (sdp_polldata(so->so_priv, SDP_XMIT)) { + *reventsp |= POLLOUT & events; + } + } else { + *reventsp = 0; + goto done; + } + + if (sdp_polldata(so->so_priv, SDP_READ)) { + *reventsp |= (POLLIN|POLLRDNORM) & events; + } + + if ((so_state & (SS_HASCONNIND|SS_CANTRCVMORE)) != 0) { + *reventsp |= (POLLIN|POLLRDNORM) & events; + } + +done: + if (!*reventsp && !anyyet) { + *phpp = &ss->ss_poll_list; + } + + return (0); +} diff --git a/usr/src/uts/common/fs/sockfs/socksubr.c b/usr/src/uts/common/fs/sockfs/socksubr.c index 7c4d885901..f9f5eed188 100644 --- a/usr/src/uts/common/fs/sockfs/socksubr.c +++ b/usr/src/uts/common/fs/sockfs/socksubr.c @@ -20,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -706,6 +706,12 @@ sockinit(int fstype, char *name) goto failure; } + error = sosdp_init(); + if (error != 0) { + err_str = NULL; + goto failure; + } + /* * Create sonode caches. We create a special one for AF_UNIX so * that we can track them for netstat(1m). diff --git a/usr/src/uts/common/fs/sockfs/socksyscalls.c b/usr/src/uts/common/fs/sockfs/socksyscalls.c index f489b273ff..791a584ebd 100644 --- a/usr/src/uts/common/fs/sockfs/socksyscalls.c +++ b/usr/src/uts/common/fs/sockfs/socksyscalls.c @@ -161,6 +161,9 @@ so_socket(int domain, int type, int protocol, char *devpath, int version) if (protocol == IPPROTO_SCTP) { so = sosctp_create(accessvp, domain, type, protocol, version, NULL, &error); + } else if (protocol == PROTO_SDP) { + so = sosdp_create(accessvp, domain, type, protocol, version, + NULL, &error); } else { so = sotpi_create(accessvp, domain, type, protocol, version, NULL, &error); diff --git a/usr/src/uts/common/inet/ip/ipclassifier.c b/usr/src/uts/common/inet/ip/ipclassifier.c index f90b7a844c..7465e3a4ed 100644 --- a/usr/src/uts/common/inet/ip/ipclassifier.c +++ b/usr/src/uts/common/inet/ip/ipclassifier.c @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -801,7 +801,6 @@ ipcl_hash_remove_locked(conn_t *connp, connf_t *connfp) void ipcl_hash_insert_wildcard(connf_t *connfp, conn_t *connp) { - ASSERT(!connp->conn_mac_exempt); IPCL_HASH_INSERT_WILDCARD(connfp, connp); } diff --git a/usr/src/uts/common/inet/sdp_itf.h b/usr/src/uts/common/inet/sdp_itf.h new file mode 100755 index 0000000000..fb2d0a3f23 --- /dev/null +++ b/usr/src/uts/common/inet/sdp_itf.h @@ -0,0 +1,130 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#ifndef _INET_SDP_ITF_H +#define _INET_SDP_ITF_H + +#pragma ident "%Z%%M% %I% %E% SMI" + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Kernel SDP programming interface. Note that this interface + * is private to Sun and can be changed without notice. + */ + +#ifdef _KERNEL + +/* + * The version number of the SDP kernel interface. Use it with + * sdp_itf_ver() to verify if the kernel supports the correct + * version of the interface. + * + * NOTE: do not assume backward compatibility of the interface. + * If the return value of sdp_itf_ver() is different from what + * is expected, do not call any of the routines. + */ +#define SDP_ITF_VER 1 + +/* + * This struct holds all the upcalls the SDP kernel module will + * invoke for different events. When calling sdp_create() to create + * a SDP handle, the caller must provide this information. + */ +typedef struct sdp_upcalls_s { + void * (*su_newconn)(void *parenthandle, void *connind); + void (*su_connected)(void *handle); + void (*su_disconnected)(void *handle, int error); + void (*su_connfailed)(void *handle, int error); + int (*su_recv)(void *handle, mblk_t *mp, int flags); + void (*su_xmitted)(void *handle, int writeable); + void (*su_urgdata)(void *handle); + void (*su_ordrel)(void *handle); +} sdp_upcalls_t; + + +/* + * This struct holds various flow control limits the caller of + * sdp_create() should observe when interacting with SDP. + */ +typedef struct sdp_sockbuf_limits_s { + int sbl_rxbuf; + int sbl_rxlowat; + int sbl_txbuf; + int sbl_txlowat; +} sdp_sockbuf_limits_t; + +struct sdp_conn_struct_t; + +/* + * The list of routines the SDP kernel module provides. + */ +extern int sdp_bind(struct sdp_conn_struct_t *conn, struct sockaddr *addr, + socklen_t addrlen); +extern void sdp_close(struct sdp_conn_struct_t *conn); +extern int sdp_connect(struct sdp_conn_struct_t *conn, + const struct sockaddr *dst, socklen_t addrlen); +extern struct sdp_conn_struct_t *sdp_create(void *newhandle, + struct sdp_conn_struct_t *parent, int family, int flags, + const sdp_upcalls_t *su, sdp_sockbuf_limits_t *sbl, cred_t *cr, + int *error); +extern int sdp_disconnect(struct sdp_conn_struct_t *conn, int flags); +extern int sdp_shutdown(struct sdp_conn_struct_t *conn, int flag); +extern int sdp_polldata(struct sdp_conn_struct_t *conn, int flag); +extern int sdp_get_opt(struct sdp_conn_struct_t *conn, int level, int opt, + void *opts, socklen_t *optlen); +extern int sdp_getpeername(struct sdp_conn_struct_t *conn, + struct sockaddr *addr, socklen_t *addrlen); +extern int sdp_getsockname(struct sdp_conn_struct_t *conn, + struct sockaddr *addr, socklen_t *addrlen); +extern int sdp_itf_ver(int); +extern int sdp_listen(struct sdp_conn_struct_t *conn, int backlog); +extern int sdp_send(struct sdp_conn_struct_t *conn, struct msghdr *msg, + size_t size, int flags, struct uio *uiop); +extern int sdp_recv(struct sdp_conn_struct_t *conn, struct msghdr *msg, + size_t size, int flags, struct uio *uiop); +extern int sdp_set_opt(struct sdp_conn_struct_t *conn, int level, int opt, + const void *opts, socklen_t optlen); +extern int sdp_ioctl(struct sdp_conn_struct_t *conn, int cmd, int32_t *value, + struct cred *cr); + + +/* Flags for sdp_create() */ +#define SDP_CAN_BLOCK 0x01 + +#define SDP_READ 0x01 +#define SDP_XMIT 0x02 + +#endif /* _KERNEL */ + +#define SDP_NODELAY 0x01 + +#ifdef __cplusplus +} +#endif + +#endif /* _INET_SDP_ITF_H */ diff --git a/usr/src/uts/common/io/ib/clients/sdp/sdp.conf b/usr/src/uts/common/io/ib/clients/sdp/sdp.conf new file mode 100644 index 0000000000..0f9f8ea1be --- /dev/null +++ b/usr/src/uts/common/io/ib/clients/sdp/sdp.conf @@ -0,0 +1,27 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +name="sdp" parent="pseudo" instance=0; diff --git a/usr/src/uts/common/io/ib/clients/sdp/sdpddi.c b/usr/src/uts/common/io/ib/clients/sdp/sdpddi.c new file mode 100755 index 0000000000..e39550608d --- /dev/null +++ b/usr/src/uts/common/io/ib/clients/sdp/sdpddi.c @@ -0,0 +1,371 @@ +/* + * CDDL HEADER START + * + * The contents of this file are subject to the terms of the + * Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. + * Use is subject to license terms. + */ + +#pragma ident "%Z%%M% %I% %E% SMI" + +#include <sys/types.h> +#include <sys/conf.h> +#include <sys/modctl.h> +#include <sys/stat.h> +#include <sys/stream.h> +#include <sys/strsun.h> +#include <sys/ddi.h> +#include <sys/sunddi.h> +#include <sys/sunldi.h> +#include <sys/file.h> +#include <sys/priv_names.h> +#include <inet/common.h> + +#define _SUN_TPI_VERSION 2 +#include <sys/tihdr.h> +#include <sys/timod.h> +#include <sys/tiuser.h> +#include <sys/suntpi.h> +#include <sys/socket.h> +#include <sys/sockio.h> +#include <inet/common.h> +#include <inet/ip.h> +#include <inet/mi.h> +#include <sys/policy.h> +#include "sys/random.h" +#include <inet/sdp_itf.h> +#include <sys/ib/ibtl/ibti.h> + + +/* + * This is a pseudo driver which creates an entry for /dev/sdp in the device + * tree. A regular installation will end up modifying sock2path file announcing + * support for sdp using AF_INET/SOCK_STREAM/PROTO_SDP parameters in socket + * call. On a non IB hardware, following are the constraints within which + * the sdp project operates. The sdpib driver which is the real driver + * (in terms of moving data) should not be loaded since it has dependency on + * ibcm and ibtl modules which will be loaded in the memory. This will consume + * precious memory and needs to be avoided. As a result the sdpib driver + * should fail its init() call to disallow loading on other modules. Due to + * this we do not get a chance to create a /dev/sdp entry in the device tree + * in the regular sdpib driver. During the boottime, this will cause a warning + * message when soconfig processes the entry for sdp in sock2path file . In + * order to avoid this a pseudo driver is introduced which creates an entry + * for /dev/sdp regardless of the hardware. When a socket call is made on the + * sdp subsystem, the call will end up in this driver, which then forwards + * this call to the real sdp driver. On a non-ib hardware system the call + * will fail + */ + +#define SDP_NAME "sdp" +#define SDP_DEVDESC "SDP STREAMS driver %I%" +#define SDP_DEVMINOR 0 + +static dev_info_t *sdp_dev_info; + +ldi_ident_t sdp_li; +krwlock_t sdp_transport_lock; +ldi_handle_t sdp_transport_handle = NULL; + +static int +sdp_gen_attach(dev_info_t *devi, ddi_attach_cmd_t cmd) +{ + int ret; + + if (cmd != DDI_ATTACH) + return (DDI_FAILURE); + + sdp_dev_info = devi; + + ret = ddi_create_minor_node(devi, SDP_NAME, S_IFCHR, + SDP_DEVMINOR, DDI_PSEUDO, 0); + if (ret != DDI_SUCCESS) { + return (ret); + } + return (DDI_SUCCESS); +} + +static int +sdp_gen_detach(dev_info_t *devi, ddi_detach_cmd_t cmd) +{ + if (cmd != DDI_DETACH) + return (DDI_FAILURE); + + ASSERT(devi == sdp_dev_info); + + ddi_remove_minor_node(devi, NULL); + + return (DDI_SUCCESS); +} + +/* open routine. */ +/*ARGSUSED*/ +static int +sdp_gen_open(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp) +{ + qprocson(q); + qenable(q); + return (0); +} + +/* open routine. */ +/*ARGSUSED*/ +static int +sdp_gen_close(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp) +{ + qprocsoff(q); + return (0); +} + +static int +sdp_open_sdpib_driver() +{ + int ret = 0; + + rw_enter(&sdp_transport_lock, RW_WRITER); + if (sdp_transport_handle != 0) { + /* + * Someone beat us to it. + */ + goto done; + } + + if (ibt_hw_is_present() == 0) { + ret = ENODEV; + goto done; + } + + if (sdp_li == NULL) { + ret = EPROTONOSUPPORT; + goto done; + } + + ret = ldi_open_by_name("/devices/ib/sdpib@0:sdpib", + FREAD | FWRITE, kcred, &sdp_transport_handle, sdp_li); + if (ret != 0) { + ret = EPROTONOSUPPORT; + sdp_transport_handle = NULL; + goto done; + } + +done: + rw_exit(&sdp_transport_lock); + return (ret); +} + + +static void +sdp_gen_ioctl(queue_t *q, mblk_t *mp) +{ + struct iocblk *iocp; + int32_t enable = 0; + int ret; + boolean_t priv = B_TRUE; + + /* LINTED */ + iocp = (struct iocblk *)mp->b_rptr; + switch (iocp->ioc_cmd) { + case SIOSYSENABLESDP: + bcopy(mp->b_cont->b_rptr, &enable, sizeof (int)); + + /* + * Check for root privs. + * if not net config privs - return state of system SDP + */ + if (secpolicy_net_config(CRED(), B_FALSE) != 0) { + priv = B_FALSE; + } + + + /* + * The sdpib driver is loaded if root enables sdp the + * first time (sdp_transport_handle is NULL). It is + * unloaded during the following first disable. At all + * other times for root as well as non-root users, the + * action of enabling/disabling sdp is simply acked. + */ + rw_enter(&sdp_transport_lock, RW_READER); + if ((enable == 1) && (sdp_transport_handle == NULL) && + (priv == B_TRUE)) { + /* Initialize sdpib transport driver */ + rw_exit(&sdp_transport_lock); + ret = sdp_open_sdpib_driver(); + rw_enter(&sdp_transport_lock, + RW_READER); + if (ret != 0) { + /* Transport failed to load */ + rw_exit(&sdp_transport_lock); + enable = 0; + goto done; + } + (void) sdp_ioctl(NULL, iocp->ioc_cmd, &enable, + CRED()); + } else if ((enable == 0) && + (sdp_transport_handle != NULL) && + (priv == B_TRUE)) { + (void) sdp_ioctl(NULL, iocp->ioc_cmd, &enable, + CRED()); + (void) ldi_close(sdp_transport_handle, + FNDELAY, kcred); + sdp_transport_handle = NULL; + } else { + ret = sdp_ioctl(NULL, iocp->ioc_cmd, &enable, + CRED()); + if (ret == EINVAL) + enable = 0; + } + rw_exit(&sdp_transport_lock); + +done: + bcopy(&enable, mp->b_cont->b_rptr, sizeof (int)); + + /* ACK the ioctl */ + mp->b_datap->db_type = M_IOCACK; + iocp->ioc_count = sizeof (int); + qreply(q, mp); + break; + default: + miocnak(q, mp, 0, ENOTSUP); + } +} + +/* + * Received a put from sockfs. We only support ndd get/set + */ +static void +sdp_gen_wput(queue_t *q, mblk_t *mp) +{ + switch (mp->b_datap->db_type) { + case M_IOCTL: + sdp_gen_ioctl(q, mp); + break; + default: + return; + } +} + +static struct module_info info = { + 0, "sdp", 1, INFPSZ, 65536, 1024 +}; + +static struct qinit rinit = { + NULL, (pfi_t)NULL, (pfi_t)sdp_gen_open, (pfi_t)sdp_gen_close, NULL, + &info, NULL, NULL, NULL, STRUIOT_NONE +}; + +static struct qinit winit = { + (pfi_t)sdp_gen_wput, NULL, (pfi_t)sdp_gen_open, (pfi_t)sdp_gen_close, + NULL, &info, NULL, NULL, NULL, STRUIOT_NONE +}; + +struct streamtab sdpinfo = { + &rinit, &winit, NULL, NULL +}; + +/* Stream operations */ +static struct streamtab sdp_streamtab = { + &rinit, /* read queue */ + &winit, /* write queue */ +}; + +/* Character/block operations */ +static struct cb_ops sdp_cb_ops = { + nodev, /* open */ + nodev, /* close */ + nodev, /* strategy */ + nodev, /* print */ + nodev, /* dump */ + nodev, /* read */ + nodev, /* write */ + nodev, /* ioctl */ + nodev, /* devmap */ + nodev, /* mmap */ + nodev, /* segmap */ + nochpoll, /* chpoll */ + ddi_prop_op, /* prop_op (sun DDI-specific) */ + &sdp_streamtab, /* streams */ + D_MP, + CB_REV +}; + +/* Driver operations */ +static struct dev_ops sdp_devops = { + DEVO_REV, /* struct rev */ + 0, /* refcnt */ + nodev, /* getinfo */ + nulldev, /* identify */ + nulldev, /* probe */ + sdp_gen_attach, /* attach */ + sdp_gen_detach, /* detach */ + nodev, /* reset */ + &sdp_cb_ops, /* cb_ops */ + NULL, /* bus_ops */ + nodev /* power */ +}; + +/* + * Module linkage information for the kernel. + */ +static struct modldrv modldrv = { + &mod_driverops, + SDP_DEVDESC, + &sdp_devops +}; + +static struct modlinkage modlinkage = { + MODREV_1, + &modldrv, + NULL +}; + +int +_init(void) +{ + int ret; + + ret = mod_install(&modlinkage); + if (ret != 0) + goto done; + ret = ldi_ident_from_mod(&modlinkage, &sdp_li); + if (ret != 0) + sdp_li = NULL; +done: + return (ret); +} + +int +_fini(void) +{ + int ret; + + ret = mod_remove(&modlinkage); + if (ret != 0) { + return (ret); + } + + ldi_ident_release(sdp_li); + return (0); +} + +int +_info(struct modinfo *modinfop) +{ + return (mod_info(&modlinkage, modinfop)); +} diff --git a/usr/src/uts/common/netinet/in.h b/usr/src/uts/common/netinet/in.h index 45d0d70aed..d1920bd004 100644 --- a/usr/src/uts/common/netinet/in.h +++ b/usr/src/uts/common/netinet/in.h @@ -1,5 +1,5 @@ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* @@ -174,6 +174,8 @@ typedef uint16_t sa_family_t; #define IPPROTO_RAW 255 /* raw IP packet */ #define IPPROTO_MAX 256 +#define PROTO_SDP 257 /* Sockets Direct Protocol */ + /* * Port/socket numbers: network standard functions */ diff --git a/usr/src/uts/common/sys/socketvar.h b/usr/src/uts/common/sys/socketvar.h index 39112e6c97..b7da38240c 100644 --- a/usr/src/uts/common/sys/socketvar.h +++ b/usr/src/uts/common/sys/socketvar.h @@ -20,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -834,6 +834,11 @@ extern struct sonode *sosctp_create(vnode_t *, int, int, int, int, struct sonode *, int *); extern int sosctp_init(void); +/* SDP sockfs */ +extern struct sonode *sosdp_create(vnode_t *, int, int, int, int, + struct sonode *, int *); +extern int sosdp_init(void); + #endif /* diff --git a/usr/src/uts/common/sys/sockio.h b/usr/src/uts/common/sys/sockio.h index c9e57359ef..5c542e939e 100644 --- a/usr/src/uts/common/sys/sockio.h +++ b/usr/src/uts/common/sys/sockio.h @@ -2,9 +2,8 @@ * 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. + * Common Development and Distribution License (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. @@ -20,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2005 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -317,6 +316,8 @@ extern "C" { #define SIOCSIPMPFAILBACK _IOW('i', 182, int) /* enable/disable */ /* FAILBACK */ +#define SIOSYSENABLESDP _IOWR('i', 183, int) /* Enable SDP */ + #ifdef __cplusplus } #endif diff --git a/usr/src/uts/intel/Makefile.intel.shared b/usr/src/uts/intel/Makefile.intel.shared index f02a017c55..853410e89a 100644 --- a/usr/src/uts/intel/Makefile.intel.shared +++ b/usr/src/uts/intel/Makefile.intel.shared @@ -20,7 +20,7 @@ # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -400,7 +400,7 @@ DRV_KMODS += dcam1394 # # InfiniBand pseudo drivers # -DRV_KMODS += ib ibd rdsib +DRV_KMODS += ib ibd rdsib sdp # # LVM modules @@ -579,6 +579,7 @@ $(CLOSED_BUILD)CLOSED_XMODS = \ e1000g \ lsimega \ nge \ + sdpib \ tavor diff --git a/usr/src/uts/intel/ia32/ml/modstubs.s b/usr/src/uts/intel/ia32/ml/modstubs.s index 500b0622bd..ce3ee34877 100644 --- a/usr/src/uts/intel/ia32/ml/modstubs.s +++ b/usr/src/uts/intel/ia32/ml/modstubs.s @@ -20,7 +20,7 @@ */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -1200,6 +1200,30 @@ fcnname/**/_info: \ #endif /* + * Stubs for SDP-IB driver. + */ +#ifndef SDPIB_MODULE + MODULE(sdpib,drv); + STUB(sdpib, sdp_create, nomod_zero); + STUB(sdpib, sdp_bind, nomod_einval); + STUB(sdpib, sdp_listen, nomod_einval); + STUB(sdpib, sdp_connect, nomod_einval); + STUB(sdpib, sdp_recv, nomod_einval); + STUB(sdpib, sdp_send, nomod_einval); + STUB(sdpib, sdp_getpeername, nomod_einval); + STUB(sdpib, sdp_getsockname, nomod_einval); + STUB(sdpib, sdp_disconnect, nomod_einval); + STUB(sdpib, sdp_shutdown, nomod_einval); + STUB(sdpib, sdp_get_opt, nomod_einval); + STUB(sdpib, sdp_set_opt, nomod_einval); + STUB(sdpib, sdp_close, nomod_void); + STUB(sdpib, sdp_polldata, nomod_zero); + STUB(sdpib, sdp_ioctl, nomod_einval); + END_MODULE(sdpib); +#endif + + +/* * Stubs for kssl, the kernel SSL proxy */ #ifndef KSSL_MODULE diff --git a/usr/src/uts/intel/os/minor_perm b/usr/src/uts/intel/os/minor_perm index 8d53f40b5e..9506e5595c 100644 --- a/usr/src/uts/intel/os/minor_perm +++ b/usr/src/uts/intel/os/minor_perm @@ -140,3 +140,4 @@ pcn:* 0666 root sys rtls:* 0666 root sys ath:* 0666 root sys physmem:* 0600 root sys +sdp:sdp 0666 root sys diff --git a/usr/src/uts/intel/sdp/Makefile b/usr/src/uts/intel/sdp/Makefile new file mode 100755 index 0000000000..472c7eeaf8 --- /dev/null +++ b/usr/src/uts/intel/sdp/Makefile @@ -0,0 +1,80 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# + +# +# Path to the base of the uts directory tree (usually /usr/src/uts). +# +UTSBASE = ../.. + +# +# Define the module and object file sets. +# +MODULE = sdp +OBJECTS = $(SDP_OBJS:%=$(OBJS_DIR)/%) +LINTS = $(SDP_OBJS:%.o=$(LINTS_DIR)/%.ln) +ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) +LDFLAGS += -dy +CONF_SRCDIR = $(UTSBASE)/common/io/ib/clients/sdp +# +# Include common rules. +# +include $(UTSBASE)/intel/Makefile.intel + +# +# Define targets +# +ALL_TARGET = $(BINARY) $(SRC_CONFILE) +LINT_TARGET = $(MODULE).lint +INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE) + +# +# Default build targets. +# +.KEEP_STATE: + +def: $(DEF_DEPS) + +all: $(ALL_DEPS) + +clean: $(CLEAN_DEPS) + +clobber: $(CLOBBER_DEPS) + +lint: $(LINT_DEPS) + +modlintlib: $(MODLINTLIB_DEPS) + +clean.lint: $(CLEAN_LINT_DEPS) + +install: $(INSTALL_DEPS) + +# +# Include common targets. +# +include $(UTSBASE)/intel/Makefile.targ + diff --git a/usr/src/uts/sparc/Makefile.sparc.shared b/usr/src/uts/sparc/Makefile.sparc.shared index 97c3f7789d..a055072202 100644 --- a/usr/src/uts/sparc/Makefile.sparc.shared +++ b/usr/src/uts/sparc/Makefile.sparc.shared @@ -20,7 +20,7 @@ # # -# Copyright 2006 Sun Microsystems, Inc. All rights reserved. +# Copyright 2007 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # # ident "%Z%%M% %I% %E% SMI" @@ -274,7 +274,7 @@ DRV_KMODS += usbskel DRV_KMODS += usbvc DRV_KMODS += hci1394 av1394 scsa1394 dcam1394 DRV_KMODS += sbp2 -DRV_KMODS += ib ibd rdsib +DRV_KMODS += ib ibd rdsib sdp DRV_KMODS += pci_pci px_pci pxb_plx pxb_bcm pcie DRV_KMODS += i8042 kb8042 mouse8042 DRV_KMODS += fcode @@ -434,6 +434,7 @@ XMODS += $(CLOSED_BUILD)CLOSED_XMODS = \ daplt \ e1000g \ + sdpib \ tavor \ wsdrv diff --git a/usr/src/uts/sparc/ml/modstubs.s b/usr/src/uts/sparc/ml/modstubs.s index ad7748d294..f90032f9e9 100644 --- a/usr/src/uts/sparc/ml/modstubs.s +++ b/usr/src/uts/sparc/ml/modstubs.s @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2006 Sun Microsystems, Inc. All rights reserved. + * Copyright 2007 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -1165,6 +1165,27 @@ stubs_base: END_MODULE(dld); #endif +#ifndef SDPIB_MODULE + MODULE(sdpib,drv); + STUB(sdpib, sdp_create, nomod_zero); + STUB(sdpib, sdp_bind, nomod_einval); + STUB(sdpib, sdp_listen, nomod_einval); + STUB(sdpib, sdp_connect, nomod_einval); + STUB(sdpib, sdp_recv, nomod_einval); + STUB(sdpib, sdp_send, nomod_einval); + STUB(sdpib, sdp_getpeername, nomod_einval); + STUB(sdpib, sdp_getsockname, nomod_einval); + STUB(sdpib, sdp_disconnect, nomod_einval); + STUB(sdpib, sdp_shutdown, nomod_einval); + STUB(sdpib, sdp_get_opt, nomod_einval); + STUB(sdpib, sdp_set_opt, nomod_einval); + STUB(sdpib, sdp_close, nomod_void); + STUB(sdpib, sdp_polldata, nomod_zero); + STUB(sdpib, sdp_ioctl, nomod_einval); + END_MODULE(sdpib); +#endif + + /* * Stubs for kssl, the kernel SSL proxy */ diff --git a/usr/src/uts/sparc/os/minor_perm b/usr/src/uts/sparc/os/minor_perm index 1ff87599fe..494961198f 100644 --- a/usr/src/uts/sparc/os/minor_perm +++ b/usr/src/uts/sparc/os/minor_perm @@ -167,3 +167,4 @@ chxge:* 0666 root sys vsw:* 0666 root sys vnet:* 0666 root sys physmem:* 0600 root sys +sdp:sdp 0666 root sys diff --git a/usr/src/uts/sparc/sdp/Makefile b/usr/src/uts/sparc/sdp/Makefile new file mode 100644 index 0000000000..c9b216840d --- /dev/null +++ b/usr/src/uts/sparc/sdp/Makefile @@ -0,0 +1,79 @@ +# +# CDDL HEADER START +# +# The contents of this file are subject to the terms of the +# Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved. +# Use is subject to license terms. +# +# ident "%Z%%M% %I% %E% SMI" +# +# + +# +# Path to the base of the uts directory tree (usually /usr/src/uts). +# +UTSBASE = ../.. + +# +# Define the module and object file sets. +# +MODULE = sdp +OBJECTS = $(SDP_OBJS:%=$(OBJS_DIR)/%) +LINTS = $(SDP_OBJS:%.o=$(LINTS_DIR)/%.ln) +ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE) +LDFLAGS += -dy +CONF_SRCDIR = $(UTSBASE)/common/io/ib/clients/sdp +# +# Include common rules. +# +include $(UTSBASE)/sparc/Makefile.sparc + +# +# Define targets +# +ALL_TARGET = $(BINARY) $(SRC_CONFILE) +LINT_TARGET = $(MODULE).lint +INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOT_CONFFILE) + +# +# Default build targets. +# +.KEEP_STATE: + +def: $(DEF_DEPS) + +all: $(ALL_DEPS) + +clean: $(CLEAN_DEPS) + +clobber: $(CLOBBER_DEPS) + +lint: $(LINT_DEPS) + +modlintlib: $(MODLINTLIB_DEPS) + +clean.lint: $(CLEAN_LINT_DEPS) + +install: $(INSTALL_DEPS) + +# +# Include common targets. +# +include $(UTSBASE)/sparc/Makefile.targ diff --git a/usr/src/xmod/xmod_files b/usr/src/xmod/xmod_files index 2b1c57989f..613a6e60a9 100644 --- a/usr/src/xmod/xmod_files +++ b/usr/src/xmod/xmod_files @@ -67,6 +67,10 @@ cmd/cmd-inet/usr.sbin/bootconfchk ../closed/uts/intel/daplt ../closed/uts/common/io/ib/clients/daplt ../closed/uts/common/sys/ib/clients/daplt +../closed/uts/sparc/sdpib +../closed/uts/intel/sdpib +../closed/uts/common/io/ib/clients/sdpib +../closed/uts/common/sys/ib/clients/sdpib common/openssl lib/libresolv2/cylink lib/libresolv2/dnssafe |