summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGarrett D'Amore <garrett@damore.org>2022-07-03 19:05:50 -0700
committerGarrett D'Amore <garrett@damore.org>2022-07-11 18:59:59 -0400
commit15f90b02bdacbf0ae47fa105944f15b6596f9748 (patch)
tree998c2fb60e1c6a117e55985b8d94631e5cc95ea8
parent174513368dec739adb93c76e5d47aed84797d1ad (diff)
downloadillumos-joyent-15f90b02bdacbf0ae47fa105944f15b6596f9748.tar.gz
14768 retire nca
Reviewed by: Peter Tribble <peter.tribble@gmail.com> Reviewed by: Andy Fiddaman <andy@omnios.org> Reviewed by: Hans Rosenfeld <rosenfeld@grumpf.hope-2000.org> Approved by: Robert Mustacchi <rm@fingolfin.org>
-rw-r--r--exception_lists/packaging4
-rw-r--r--usr/src/cmd/cmd-inet/etc/Makefile7
-rw-r--r--usr/src/cmd/cmd-inet/etc/init.d/Makefile27
-rw-r--r--usr/src/cmd/cmd-inet/etc/init.d/ncakmod121
-rw-r--r--usr/src/cmd/cmd-inet/etc/init.d/ncalogd140
-rw-r--r--usr/src/cmd/cmd-inet/etc/nca/Makefile52
-rw-r--r--usr/src/cmd/cmd-inet/etc/nca/nca.if29
-rw-r--r--usr/src/cmd/cmd-inet/etc/nca/ncakmod.conf33
-rw-r--r--usr/src/cmd/cmd-inet/etc/nca/ncalogd.conf33
-rw-r--r--usr/src/cmd/cmd-inet/etc/nca/ncaport.conf38
-rw-r--r--usr/src/cmd/cmd-inet/etc/sock2path.d/Makefile4
-rw-r--r--usr/src/cmd/cmd-inet/etc/sock2path.d/system%2Fnetwork%2Fhttp%2Fcache%2Faccelerator26
-rw-r--r--usr/src/cmd/cmd-inet/usr.bin/Makefile7
-rw-r--r--usr/src/cmd/cmd-inet/usr.bin/nca/Makefile83
-rw-r--r--usr/src/cmd/cmd-inet/usr.bin/nca/ncab2clf.c904
-rw-r--r--usr/src/cmd/cmd-inet/usr.lib/Makefile8
-rw-r--r--usr/src/cmd/cmd-inet/usr.lib/ncaconfd/Makefile50
-rw-r--r--usr/src/cmd/cmd-inet/usr.lib/ncaconfd/ncaconfd.c1424
-rw-r--r--usr/src/cmd/devfsadm/misc_link.c2
-rw-r--r--usr/src/cmd/mdb/Makefile.common2
-rw-r--r--usr/src/cmd/mdb/common/modules/nca/nca.c1237
-rw-r--r--usr/src/cmd/mdb/intel/amd64/nca/Makefile36
-rw-r--r--usr/src/cmd/mdb/sparc/v9/nca/Makefile36
-rw-r--r--usr/src/cmd/truss/print.c14
-rw-r--r--usr/src/lib/Makefile3
-rw-r--r--usr/src/lib/README.Makefiles2
-rw-r--r--usr/src/lib/ncad_addr/Makefile43
-rw-r--r--usr/src/lib/ncad_addr/Makefile.com42
-rw-r--r--usr/src/lib/ncad_addr/amd64/Makefile32
-rw-r--r--usr/src/lib/ncad_addr/common/mapfile-vers103
-rw-r--r--usr/src/lib/ncad_addr/common/ncad_addr.c252
-rw-r--r--usr/src/lib/ncad_addr/i386/Makefile31
-rw-r--r--usr/src/lib/ncad_addr/sparc/Makefile31
-rw-r--r--usr/src/lib/ncad_addr/sparcv9/Makefile32
-rw-r--r--usr/src/man/man1/Makefile8
-rw-r--r--usr/src/man/man1/digest.111
-rw-r--r--usr/src/man/man1/nca.1176
-rw-r--r--usr/src/man/man1/ncab2clf.1212
-rw-r--r--usr/src/man/man1/ncakmod.1119
-rw-r--r--usr/src/man/man3ext/sendfilev.3ext16
-rw-r--r--usr/src/man/man3socket/socket.3socket27
-rw-r--r--usr/src/man/man5/Makefile6
-rw-r--r--usr/src/man/man5/nca.if.5142
-rw-r--r--usr/src/man/man5/ncad_addr.576
-rw-r--r--usr/src/man/man5/ncakmod.conf.5110
-rw-r--r--usr/src/man/man5/ncalogd.conf.5118
-rw-r--r--usr/src/man/man5/ncaport.conf.569
-rw-r--r--usr/src/man/man8/Makefile3
-rw-r--r--usr/src/man/man8/ncaconfd.884
-rw-r--r--usr/src/pkg/manifests/developer-debug-mdb.p5m3
-rw-r--r--usr/src/pkg/manifests/system-network-http-cache-accelerator.p5m81
-rw-r--r--usr/src/uts/Makefile2
-rw-r--r--usr/src/uts/common/Makefile.files5
-rw-r--r--usr/src/uts/common/Makefile.rules4
-rw-r--r--usr/src/uts/common/fs/sockfs/nl7c.c1047
-rw-r--r--usr/src/uts/common/fs/sockfs/nl7c.h89
-rw-r--r--usr/src/uts/common/fs/sockfs/nl7chttp.c1948
-rw-r--r--usr/src/uts/common/fs/sockfs/nl7clogd.c754
-rw-r--r--usr/src/uts/common/fs/sockfs/nl7cnca.c452
-rwxr-xr-xusr/src/uts/common/fs/sockfs/nl7ctokgen79
-rw-r--r--usr/src/uts/common/fs/sockfs/nl7ctokreq.txt44
-rw-r--r--usr/src/uts/common/fs/sockfs/nl7ctokres.txt43
-rw-r--r--usr/src/uts/common/fs/sockfs/nl7curi.c2145
-rw-r--r--usr/src/uts/common/fs/sockfs/nl7curi.h197
-rw-r--r--usr/src/uts/common/fs/sockfs/sockcommon.c2
-rw-r--r--usr/src/uts/common/fs/sockfs/sockcommon_sops.c29
-rw-r--r--usr/src/uts/common/fs/sockfs/socksubr.c10
-rw-r--r--usr/src/uts/common/fs/sockfs/socksyscalls.c44
-rw-r--r--usr/src/uts/common/fs/sockfs/socktpi.c242
-rw-r--r--usr/src/uts/common/fs/sockfs/socktpi.h27
-rw-r--r--usr/src/uts/common/inet/nca/ncaddi.c173
-rw-r--r--usr/src/uts/common/io/ksocket/ksocket.c4
-rw-r--r--usr/src/uts/common/sys/socket.h8
-rw-r--r--usr/src/uts/common/syscall/sendfile.c12
-rw-r--r--usr/src/uts/intel/Makefile.intel1
-rw-r--r--usr/src/uts/intel/ml/modstubs.s1
-rw-r--r--usr/src/uts/intel/nca/Makefile83
-rw-r--r--usr/src/uts/intel/sockrds/Makefile3
-rw-r--r--usr/src/uts/intel/socksctp/Makefile3
-rw-r--r--usr/src/uts/intel/socksdp/Makefile3
-rw-r--r--usr/src/uts/sparc/Makefile.sparc2
-rw-r--r--usr/src/uts/sparc/ml/modstubs.s1
-rw-r--r--usr/src/uts/sparc/nca/Makefile83
-rw-r--r--usr/src/uts/sparc/sockpfp/Makefile3
-rw-r--r--usr/src/uts/sparc/sockrds/Makefile3
-rw-r--r--usr/src/uts/sparc/socksctp/Makefile3
-rw-r--r--usr/src/uts/sparc/socksdp/Makefile3
87 files changed, 70 insertions, 13631 deletions
diff --git a/exception_lists/packaging b/exception_lists/packaging
index a0a16df034..9654bf67ef 100644
--- a/exception_lists/packaging
+++ b/exception_lists/packaging
@@ -265,10 +265,6 @@ usr/include/librcm_impl.h
usr/lib/mdb/proc/mdb_test.so
usr/lib/mdb/proc/sparcv9/mdb_test.so sparc
#
-# SNCA project exception list
-#
-usr/include/inet/nca
-#
# these are "removed" from the source product build because the only
# packages that currently deliver them are removed.
# they really should't be in here.
diff --git a/usr/src/cmd/cmd-inet/etc/Makefile b/usr/src/cmd/cmd-inet/etc/Makefile
index c9d3824663..22ff2dd23f 100644
--- a/usr/src/cmd/cmd-inet/etc/Makefile
+++ b/usr/src/cmd/cmd-inet/etc/Makefile
@@ -19,6 +19,7 @@
# CDDL HEADER END
#
# Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2022 Garrett D'Amore
SYMPROG= hosts inetd.conf networks protocols services netmasks
@@ -27,7 +28,7 @@ EDITPROG= ipaddrsel.conf ipsecalgs
PROG= datemsk.ndpd ipsecinit.sample ipqosconf.1.sample ipqosconf.2.sample \
ipqosconf.3.sample
ETCPROG= $(SYMPROG) $(EDITPROG) $(PROG)
-SUBDIRS= default dhcp init.d ike nca ppp secret sock2path.d
+SUBDIRS= default dhcp init.d ike ppp secret sock2path.d
include ../../Makefile.cmd
@@ -37,8 +38,8 @@ install:= TARGET= install
ROOTVAR= $(ROOT)/var
INETETCDIR= $(ROOTETC)/inet
INETVARDIR= $(ROOTVAR)/inet
-DIRS= $(INETETCDIR) $(INETVARDIR)
-SYMDIR= inet
+DIRS= $(INETETCDIR) $(INETVARDIR)
+SYMDIR= inet
ETCINETPROG= $(ETCPROG:%=$(INETETCDIR)/%)
EDITFILES= $(SYMPROG:%=$(INETETCDIR)/%) $(EDITPROG:%=$(INETETCDIR)/%)
# Only old /etc/inet files get symlinks in /etc.
diff --git a/usr/src/cmd/cmd-inet/etc/init.d/Makefile b/usr/src/cmd/cmd-inet/etc/init.d/Makefile
index 46f744cd3b..377ebd0821 100644
--- a/usr/src/cmd/cmd-inet/etc/init.d/Makefile
+++ b/usr/src/cmd/cmd-inet/etc/init.d/Makefile
@@ -21,18 +21,15 @@
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
+# Copyright 2022 Garrett D'Amore
+#
# cmd/cmd-inet/etc/init.d/Makefile
-PROG4= ncalogd
-PROG5= ncakmod
PPPD= pppd
-PROG= $(PROG4) $(PROG5) $(PPPD)
+PROG= $(PPPD)
include ../../../Makefile.cmd
-STARTINET3= $(ROOTETC)/rc2.d/S94ncalogd
-STARTINET4= $(ROOTETC)/rc2.d/S42ncakmod
-
PPPDK= K50pppd
PPPDS= S47pppd
@@ -53,18 +50,12 @@ $(INITD)/% : % $(INITD)
$(INS.file)
ln_PROG : $(ETCINITPROG)
- @for dir in rc0.d rcS.d rc1.d; do \
- echo $(LN) $(INITD)/$(PROG4) $(ROOTETC)/$$dir/K34ncalogd; \
- $(RM) $(ROOTETC)/$$dir/K34ncalogd; \
- $(LN) $(INITD)/$(PROG4) $(ROOTETC)/$$dir/K34ncalogd; \
- echo $(LN) $(INITD)/$(PPPD) $(ROOTETC)/$$dir/$(PPPDK); \
- $(RM) $(ROOTETC)/$$dir/$(PPPDK); \
- $(LN) $(INITD)/$(PPPD) $(ROOTETC)/$$dir/$(PPPDK); \
- done
- -$(RM) $(STARTINET3)
- $(LN) $(INITD)/$(PROG4) $(STARTINET3)
- -$(RM) $(STARTINET4)
- $(LN) $(INITD)/$(PROG5) $(STARTINET4)
+ -$(RM) $(ROOTETC)/rc0.d/$(PPPDK)
+ $(LN) $(INITD)/$(PPPD) $(ROOTETC)/rc0.d/$(PPPDK)
+ -$(RM) $(ROOTETC)/rc1.d/$(PPPDK)
+ $(LN) $(INITD)/$(PPPD) $(ROOTETC)/rc1.d/$(PPPDK)
+ -$(RM) $(ROOTETC)/rcS.d/$(PPPDK)
+ $(LN) $(INITD)/$(PPPD) $(ROOTETC)/rcS.d/$(PPPDK)
-$(RM) $(ROOTETC)/rc2.d/$(PPPDS)
$(LN) $(INITD)/$(PPPD) $(ROOTETC)/rc2.d/$(PPPDS)
diff --git a/usr/src/cmd/cmd-inet/etc/init.d/ncakmod b/usr/src/cmd/cmd-inet/etc/init.d/ncakmod
deleted file mode 100644
index e29d31453d..0000000000
--- a/usr/src/cmd/cmd-inet/etc/init.d/ncakmod
+++ /dev/null
@@ -1,121 +0,0 @@
-#!/sbin/sh
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 1999-2002 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-#ident "%Z%%M% %I% %E% SMI"
-
-# Default config values used by script
-nca=drv/nca
-ncakmodconf=/etc/nca/ncakmod.conf
-ncaifconf=/etc/nca/nca.if
-tempdir=/tmp
-default_miss_door=/var/run/nca_httpd_1.door
-
-# Function used to parse the interface names from /etc/hostname.* entries
-readifconf()
-{
- while read i; do
- case "$i" in
- '#'* | '') # Ignore comments, empty lines
- continue ;;
- '*') configinterfaces="`echo /etc/hostname.*[0-9] \
- 2>/dev/null`"
- checkforvirt=false
- break ;;
- esac
- configinterfaces="$configinterfaces $i"
- done
-}
-
-case "$1" in
-'start')
-
- if [ ! -f $ncakmodconf ]; then
- # If configuration file is missing, just exit
- exit 0
- fi
-
- . $ncakmodconf
-
- # Default is "disabled" so we want to exit
- [ "x$status" != "xenabled" ] && exit 0
-
- if [ -f "$ncaifconf" ]; then
- readifconf < $ncaifconf
- configinterfaces="`echo $configinterfaces | \
- /bin/sed 's/.etc.hostname.//g'`"
- for i in $configinterfaces; do
- findinterface="`echo $i | /bin/grep '[0-9][0-9]*'`"
- if [ $? -ne 0 ]; then
- # Need to expand interface (ie. iprb)
- interface="`echo /etc/hostname.$i*[0-9] \
- 2>/dev/null | /bin/sed \
- 's/.etc.hostname.//g'`"
- interfaces="$interfaces $interface"
- else
- interfaces="$interfaces $i"
- fi
- done
-
- # If we don't have any interfaces configured, exit
- [ -z "$interfaces" ] && exit 0
-
- # Prevent multiple instances of ncaconfd
- if /bin/pgrep ncaconfd > /dev/null 2>&1; then
- echo "$0: ncaconfd is already running"
- exit 1
- fi
-
- /usr/sbin/modload -p $nca
-
- # Insert NCA into the stream of all the interfaces configured.
- interfaces="`echo $interfaces | /bin/tr ' ' '\012' | \
- /bin/grep -v :`"
- if [ "x$nca_active" != xenabled ]; then
- /usr/lib/inet/ncaconfd -l $interfaces
- else
- /usr/lib/inet/ncaconfd -al $interfaces
- fi
-
- if [ "$httpd_door_path" != "$default_miss_door" ]; then
- # Set the default HTTPD door in NCA via ndd
- /usr/sbin/ndd -set /dev/nca httpd_door_path \
- $httpd_door_path
- fi
- fi
- ;;
-
-'stop')
- # Need to reboot the system to stop
- echo "System reset is required to stop NCA functionality"
- ;;
-
-*)
-
- echo "Usage: $0 { start | stop }"
- exit 1
- ;;
-esac
-exit 0
diff --git a/usr/src/cmd/cmd-inet/etc/init.d/ncalogd b/usr/src/cmd/cmd-inet/etc/init.d/ncalogd
deleted file mode 100644
index 7a435579b5..0000000000
--- a/usr/src/cmd/cmd-inet/etc/init.d/ncalogd
+++ /dev/null
@@ -1,140 +0,0 @@
-#!/sbin/sh
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright (c) 1998-2001 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-#ident "%Z%%M% %I% %E% SMI"
-
-# Default location for script
-ncalogd=/etc/init.d/ncalogd
-success=1
-
-# Default config values used by script
-ncalogdconf=/etc/nca/ncalogd.conf
-ncakmodconf=/etc/nca/ncakmod.conf
-
-isValidFile() {
- # Check if file exists
- if [ ! -f $1 ]
- then
- # Create subdirectories
- logd_dir=`/usr/bin/dirname $1`
- if [ ! -d "$logd_dir" ]; then
- /usr/bin/mkdir -m 0755 -p $logd_dir > /dev/null 2>&1
- if [ $? != 0 ]; then
- echo "Error: $ncalogd: unable to" \
- "create directory $logd_dir"
- return 1
- fi
- fi
- # Create the log file
- touch $1
- if [ $? != 0 ]; then
- echo "Error: ${ncalogd}: unable to create file $1"
- return 1
- fi
- fi
-
- # test if valid local file
- df -l $1 > /dev/null 2>&1
- if [ $? != 0 ]; then
- echo "Error: $ncalogd: $1 is not a local file system"
- return 1
- fi
- return 0
-}
-
-isValidDev() {
- # Check if device is valid
- fsck -m $1 > /dev/null 2>&1
- case $? in
- 36 | 39 )
- return 0
- ;;
- 0 | 32 | 33 | 40 )
- echo "Error: $ncalogd: refusing to overwrite filesystem on $1"
- return 1
- ;;
- * )
- echo "Error: $ncalogd: $1 is an invalid device"
- return 1
- ;;
- esac
-}
-
-case "$1" in
-'start')
- if [ ! -f $ncalogdconf ]; then
- # If configuration file is missing, just exit
- exit 0
- fi
-
- . $ncalogdconf
-
- # Default is "disabled" so we want to exit
- [ "x$status" != "xenabled" ] && exit 0
-
- . $ncakmodconf
-
- # Default is "disabled" so we want to exit
- [ "x$status" != "xenabled" ] && exit 0
-
- for i in $logd_path_name; do
- # make sure that specified logfile is not a directory
- if [ -d $i ]; then
- echo "Error: $ncalogd: $i is a directory"
- continue
- elif [ -b $i -o -c $i ]; then
- # Check if file is a device
- isValidDev $i || continue
- else
- isValidFile $i || continue
- fi
-
- # Finally, set the specified file as a NCA log file
- /usr/sbin/ndd -set /dev/nca nca_log_file $i
- success=0
- done
-
- if [ $success = 0 ]; then
- [ "x$logd_file_size" != "x" ] && \
- /usr/sbin/ndd -set /dev/nca nca_log_size $logd_file_size
- /usr/sbin/ndd -set /dev/nca nca_logging_on 1
- fi
- ;;
-
-'stop')
- . $ncakmodconf
-
- if [ "x$status" = "xenabled" ]; then
- /usr/sbin/ndd -set /dev/nca nca_logging_on 0
- fi
- ;;
-
-*)
- echo "Usage: $0 { start | stop }"
- exit 1
- ;;
-esac
-exit 0
diff --git a/usr/src/cmd/cmd-inet/etc/nca/Makefile b/usr/src/cmd/cmd-inet/etc/nca/Makefile
deleted file mode 100644
index 5ca89052ef..0000000000
--- a/usr/src/cmd/cmd-inet/etc/nca/Makefile
+++ /dev/null
@@ -1,52 +0,0 @@
-#
-# 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 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# cmd/cmd-inet/etc/nca/Makefile
-#
-
-NCADIR= nca
-ETCPROG= nca.if ncakmod.conf ncalogd.conf ncaport.conf
-
-include ../../../Makefile.cmd
-
-ETCNCADIR= $(ROOTETC)/$(NCADIR)
-ETCNCAPROG= $(ETCPROG:%=$(ETCNCADIR)/%)
-
-FILEMODE= 0644
-
-.KEEP_STATE:
-
-all: $(ETCPROG)
-
-install: all $(ETCNCADIR) $(ETCNCAPROG)
-
-$(ETCNCADIR)/% : %
- $(INS.file)
-
-$(ETCNCADIR):
- $(INS.dir)
-
-FRC:
-
-clean clobber lint:
diff --git a/usr/src/cmd/cmd-inet/etc/nca/nca.if b/usr/src/cmd/cmd-inet/etc/nca/nca.if
deleted file mode 100644
index 3866e3fc93..0000000000
--- a/usr/src/cmd/cmd-inet/etc/nca/nca.if
+++ /dev/null
@@ -1,29 +0,0 @@
-#
-# Copyright 2005 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.
-#
-# 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"
-#
-# NCA feature interface configuration file
-#
-# Use this file to tell the NCA feature which interfaces to listen on
diff --git a/usr/src/cmd/cmd-inet/etc/nca/ncakmod.conf b/usr/src/cmd/cmd-inet/etc/nca/ncakmod.conf
deleted file mode 100644
index 66387cc724..0000000000
--- a/usr/src/cmd/cmd-inet/etc/nca/ncakmod.conf
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright (c) 1998-2001 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-#ident "%Z%%M% %I% %E% SMI"
-#
-# NCA Kernel Module Configuration File
-#
-
-status=disabled
-httpd_door_path=/var/run/nca_httpd_1.door
-nca_active=disabled
diff --git a/usr/src/cmd/cmd-inet/etc/nca/ncalogd.conf b/usr/src/cmd/cmd-inet/etc/nca/ncalogd.conf
deleted file mode 100644
index ce2ccf9e2b..0000000000
--- a/usr/src/cmd/cmd-inet/etc/nca/ncalogd.conf
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright (c) 1998-1999 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-#ident "%Z%%M% %I% %E% SMI"
-#
-# NCA Logging Configuration File
-#
-
-status=disabled
-logd_path_name="/var/nca/log"
-logd_file_size=1000000
diff --git a/usr/src/cmd/cmd-inet/etc/nca/ncaport.conf b/usr/src/cmd/cmd-inet/etc/nca/ncaport.conf
deleted file mode 100644
index 74b110dfa7..0000000000
--- a/usr/src/cmd/cmd-inet/etc/nca/ncaport.conf
+++ /dev/null
@@ -1,38 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2002 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-#
-#
-# NCA Kernel Module Port Configuration File
-#
-# Use this file to tell NCA socket utility library /usr/lib/ncad_addr.so to
-# convert an AF_INET socket to an AF_NCA socket. Each line consists of two
-# fields - a key and a value - in the format ncaport=ipaddress/port. See
-# man page ncaport(5) for the format and contents of this file.
-#
-# Example configuration file:
-#
-# ncaport=*/80
-# ncaport=192.168.84.71/8888
diff --git a/usr/src/cmd/cmd-inet/etc/sock2path.d/Makefile b/usr/src/cmd/cmd-inet/etc/sock2path.d/Makefile
index 383071bbc6..42b3dacb1c 100644
--- a/usr/src/cmd/cmd-inet/etc/sock2path.d/Makefile
+++ b/usr/src/cmd/cmd-inet/etc/sock2path.d/Makefile
@@ -19,6 +19,7 @@
# CDDL HEADER END
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2022 Garrett D'Amore
#
# cmd/cmd-inet/etc/sock2path.d/Makefile
#
@@ -28,8 +29,7 @@ SOCK2PATHFILES= \
driver%2Fnetwork%2Frds \
driver%2Fnetwork%2Frdsv3 \
driver%2Fnetwork%2Fsdp \
- system%2Fkernel \
- system%2Fnetwork%2Fhttp%2Fcache%2Faccelerator
+ system%2Fkernel
include ../../../Makefile.cmd
diff --git a/usr/src/cmd/cmd-inet/etc/sock2path.d/system%2Fnetwork%2Fhttp%2Fcache%2Faccelerator b/usr/src/cmd/cmd-inet/etc/sock2path.d/system%2Fnetwork%2Fhttp%2Fcache%2Faccelerator
deleted file mode 100644
index 1a551d6500..0000000000
--- a/usr/src/cmd/cmd-inet/etc/sock2path.d/system%2Fnetwork%2Fhttp%2Fcache%2Faccelerator
+++ /dev/null
@@ -1,26 +0,0 @@
-# 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 (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
-#
-# socket configuration information
-#
-# Family Type Protocol Dev|Module
-
- 28 2 0 /dev/nca
diff --git a/usr/src/cmd/cmd-inet/usr.bin/Makefile b/usr/src/cmd/cmd-inet/usr.bin/Makefile
index 8e3a8b16a5..c1af28dd03 100644
--- a/usr/src/cmd/cmd-inet/usr.bin/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.bin/Makefile
@@ -25,6 +25,7 @@
# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
# Copyright 2016 Toomas Soome <tsoome@me.com>
# Copyright (c) 2018, Joyent, Inc.
+# Copyright 2022 Garrett D'Amore
#
PROG= finger rdate ruptime rwho whois
@@ -33,10 +34,10 @@ ALL= $(PROG) $(SUIDPROG)
SRCS= $(ALL:%=%.c)
KCMDPROGS= rcp rlogin rsh
-SUBDIRS= chat dns-sd ftp nc nca netstat \
+SUBDIRS= chat dns-sd ftp nc netstat \
pppd pppdump pppstats rdist talk telnet tftp
SUBDIR1= talk
-MSGSUBDIRS= nca talk
+MSGSUBDIRS= talk
# As programs get lint-clean, add them here. Eventually.
# This hack should go away, and all in PROG should be lint-clean.
@@ -46,7 +47,7 @@ LINTCLEAN= rlogin.c rsh.c rcp.c rdate.c rwho.c whois.c
# they're all clean, replace the dependency of the lint target
# with SUBDIRS. Also (sigh) deal with the commented-out build lines
# for the lint rule.
-LINTSUBDIRS= nca netstat pppd pppstats tftp
+LINTSUBDIRS= netstat pppd pppstats tftp
include ../../Makefile.cmd
include ../Makefile.cmd-inet
diff --git a/usr/src/cmd/cmd-inet/usr.bin/nca/Makefile b/usr/src/cmd/cmd-inet/usr.bin/nca/Makefile
deleted file mode 100644
index 88bae6de1c..0000000000
--- a/usr/src/cmd/cmd-inet/usr.bin/nca/Makefile
+++ /dev/null
@@ -1,83 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# Copyright 2015 RackTop Systems.
-#
-
-PROG= ncab2clf
-OBJS= ncab2clf.o
-SRCS= $(OBJS:%.o=%.c)
-
-include ../../../Makefile.cmd
-
-#
-# Message catalog
-#
-POFILE= ncab2clf.po
-#
-
-# these #defines are required to use UNIX 98 interfaces
-_EXTN= -D_REENTRANT
-
-$(OBJS) := CPPFLAGS += $(_EXTN)
-
-LINTFLAGS += $(_EXTN)
-
-INC_PATH += ../../../../uts/common/inet/nca -I.
-CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-parentheses
-CPPFLAGS += -I$(INC_PATH)
-
-.KEEP_STATE:
-
-.PARALLEL: $(OBJS)
-
-all: $(PROG)
-
-$(PROG): $(OBJS)
- $(LINK.c) $(OBJS) -o $@ $(LDLIBS)
- $(POST_PROCESS)
-
-#
-# Message catalog
-#
-_msg: $(POFILE)
-
-$(POFILE): $(SRCS)
- $(RM) ncab2clf.po
- $(COMPILE.cpp) $(SRCS) > $(POFILE).i
- $(XGETTEXT) $(XGETFLAGS) $(POFILE).i
- sed "/^domain/d" messages.po > $@
- $(RM) messages.po $(POFILE).i
-
-#
-install: all $(ROOTPROG)
-
-clean:
- $(RM) $(OBJS)
-
-lint: lint_SRCS
-
-include ../../../Makefile.targ
diff --git a/usr/src/cmd/cmd-inet/usr.bin/nca/ncab2clf.c b/usr/src/cmd/cmd-inet/usr.bin/nca/ncab2clf.c
deleted file mode 100644
index d0d78c4df7..0000000000
--- a/usr/src/cmd/cmd-inet/usr.bin/nca/ncab2clf.c
+++ /dev/null
@@ -1,904 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- *
- * Converts binary log files to CLF (Common Log Format).
- *
- */
-
-#include <stdlib.h>
-#include <unistd.h>
-#include <strings.h>
-#include <sys/types.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <locale.h>
-#include <errno.h>
-#include <time.h>
-#include <synch.h>
-#include <syslog.h>
-
-#ifndef TRUE
-#define TRUE 1
-#endif /* TRUE */
-
-#ifndef FALSE
-#define FALSE 0
-#endif /* FALSE */
-
-#include "ncadoorhdr.h"
-#include "ncalogd.h"
-
-extern char *gettext();
-
-typedef enum { /* Boolean type */
- false = 0,
- true = 1
-} bool;
-
-static const char *const
-g_method_strings[8] = {
- "UNKNOWN",
- "OPTIONS",
- "GET",
- "HEAD",
- "POST",
- "PUT",
- "DELETE",
- "TRACE"
-};
-
-/* Short month strings */
-static const char * const sMonthStr [12] = {
- "Jan",
- "Feb",
- "Mar",
- "Apr",
- "May",
- "Jun",
- "Jul",
- "Aug",
- "Sep",
- "Oct",
- "Nov",
- "Dec",
-};
-
-#define SEC_PER_MIN (60)
-#define SEC_PER_HOUR (60*60)
-#define SEC_PER_DAY (24*60*60)
-#define SEC_PER_YEAR (365*24*60*60)
-#define LEAP_TO_70 (70/4)
-
-#define KILO_BYTE (1024)
-#define MEGA_BYTE (KILO_BYTE * KILO_BYTE)
-#define GIGA_BYTE (KILO_BYTE * MEGA_BYTE)
-
-#define CLF_DATE_BUF_LENGTH (128)
-#define OUTFILE_BUF_SIZE (256 * KILO_BYTE)
-
-static bool g_enable_directio = true;
-static ssize_t g_invalid_count = 0;
-static ssize_t g_skip_count = 0;
-static char *g_start_time_str = NULL;
-
-/* init value must match logd & NCA kmod */
-static ssize_t g_n_log_upcall = 0;
-
-/* input binary file was written in 64k chunks by default */
-static ssize_t g_infile_blk_size = NCA_DEFAULT_LOG_BUF_SIZE;
-
-/* num of output records, by default infinite */
-static ssize_t g_out_records = -1;
-
-/* start time for log output, default none (i.e. output all) */
-static struct tm g_start_time;
-
-/*
- * http_version(version)
- *
- * Returns out the string of a given http version
- */
-
-static char *
-http_version(int http_ver)
-{
- char *ver_num;
-
- switch (http_ver) {
- case HTTP_0_9:
- case HTTP_0_0:
- ver_num = "HTTP/0.9";
- break;
- case HTTP_ERR:
- case HTTP_1_0:
- ver_num = "HTTP/1.0";
- break;
- case HTTP_1_1:
- ver_num = "HTTP/1.1";
- break;
- default:
- ver_num = "HTTP/unknown";
- }
-
- return (ver_num);
-}
-
-static bool
-valid_version(int http_ver)
-{
- switch (http_ver) {
- case HTTP_0_9:
- case HTTP_0_0:
- case HTTP_1_0:
- case HTTP_1_1:
- return (true);
- default:
- break;
- }
-
- return (false);
-}
-
-static bool
-valid_method(int method)
-{
- switch (method) {
- case NCA_OPTIONS:
- case NCA_GET:
- case NCA_HEAD:
- case NCA_POST:
- case NCA_PUT:
- case NCA_DELETE:
- case NCA_TRACE:
- return (true);
- default:
- break;
- }
-
- return (false);
-}
-
-/*
- * http_method
- *
- * Returns the method string for the given method.
- */
-
-static char *
-http_method(int method)
-{
- if (method < sizeof (g_method_strings) / sizeof (g_method_strings[0]))
- return ((char *)(g_method_strings[method]));
- else
- return ((char *)(g_method_strings[0]));
-}
-
-/* sMonth: Return short month string */
-
-static const char *
-sMonth(int index)
-{
- return (sMonthStr[index]);
-}
-
-/*
- * Debug formatting routine. Returns a character string representation of the
- * addr in buf, of the form xxx.xxx.xxx.xxx. This routine takes the address
- * as a pointer. The "xxx" parts including left zero padding so the final
- * string will fit easily in tables. It would be nice to take a padding
- * length argument instead.
- */
-
-static char *
-ip_dot_saddr(uchar_t *addr, char *buf)
-{
- (void) sprintf(buf, "%03d.%03d.%03d.%03d",
- addr[0] & 0xFF, addr[1] & 0xFF, addr[2] & 0xFF, addr[3] & 0xFF);
- return (buf);
-}
-
-/*
- * Debug formatting routine. Returns a character string representation of the
- * addr in buf, of the form xxx.xxx.xxx.xxx. This routine takes the address
- * in the form of a ipaddr_t and calls ip_dot_saddr with a pointer.
- */
-
-static char *
-ip_dot_addr(ipaddr_t addr, char *buf)
-{
- return (ip_dot_saddr((uchar_t *)&addr, buf));
-}
-
-static int
-http_clf_date(char *buf, int bufsize, time_t t)
-{
- struct tm local_time;
- long time_zone_info;
- char sign;
-
- if (localtime_r(&t, &local_time) == NULL)
- return (0);
-
- if (g_start_time.tm_year > 0 &&
- (local_time.tm_year < g_start_time.tm_year ||
- (local_time.tm_year == g_start_time.tm_year &&
- local_time.tm_mon < g_start_time.tm_mon ||
- (local_time.tm_mon == g_start_time.tm_mon &&
- local_time.tm_mday < g_start_time.tm_mday ||
- (local_time.tm_mday == g_start_time.tm_mday &&
- local_time.tm_hour < g_start_time.tm_hour ||
- (local_time.tm_hour == g_start_time.tm_hour &&
- local_time.tm_min < g_start_time.tm_min ||
- (local_time.tm_min == g_start_time.tm_min &&
- local_time.tm_sec < g_start_time.tm_sec))))))) {
- /* clf record before the specified start time */
- return (1);
- }
-
- if (local_time.tm_isdst)
- time_zone_info = -timezone + SEC_PER_HOUR;
- else
- time_zone_info = -timezone;
-
- if (time_zone_info < 0) {
- sign = '-';
- time_zone_info = -time_zone_info;
- } else {
- sign = '+';
- }
-
- (void) snprintf(buf, bufsize,
- "[%02d/%s/%04d:%02d:%02d:%02d %c%02ld%02ld]",
- local_time.tm_mday, sMonth(local_time.tm_mon),
- 1900 + local_time.tm_year, local_time.tm_hour,
- local_time.tm_min, local_time.tm_sec,
- sign, time_zone_info / SEC_PER_HOUR,
- time_zone_info % SEC_PER_HOUR);
-
- return (0);
-}
-
-/*
- * xmalloc(size)
- * Abort if malloc fails
- */
-
-static void *
-xmalloc(size_t size)
-{
- void *p;
-
- if (! size)
- size = 1;
-
- if ((p = malloc(size)) == NULL) {
- syslog(LOG_ERR, gettext("Error: ncab2clf: Out of memory\n"));
- abort();
- }
-
- return (p);
-}
-
-/*
- * xstrdup(string)
- * duplicate string
- */
-
-static char *
-xstrdup(const char *string)
-{
- char *new_string;
-
- if (string) {
- new_string = xmalloc(strlen(string) + 1);
- (void) strcpy(new_string, string);
-
- return (new_string);
- }
-
- return (NULL);
-}
-
-static void
-usage(void)
-{
- (void) fprintf(stderr, gettext(
- "\nncab2clf [-Dhv] [-b <block-size>] [-i <binary-log-file>] "
- "[-n <n>]\n"
- " [-o <output-file>] [-s <date/time>]\n"
- "\tconverts a NCA binary log file to HTTP CLF"
- " (Common Log Format)\n\n"
- "\t-b <block-size>\n"
- "\t\tinput file blocking size in KB\n"
- "\t\t- default is 64K bytes\n"
- "\t-D\tdisable directio on <output-file-name>\n"
- "\t-h\tthis usage message\n"
- "\t-i <binary-log-file>\n"
- "\t\tspecify input file\n"
- "\t-n <n>\n"
- "\t\toutput <n> CLF records\n"
- "\t-o <output-file>\n"
- "\t\tspecify output file\n"
- "\t-s <date/time>\n"
- "\t\tskip any records before <date/time>\n"
- "\t\t- <date/time> may be in CLF format\n"
- "\t\t- <date/time> may be in time format as specified "
- "by touch(1)\n"
- "\t-v\tverbose output\n"
- "\tNote: if no <output-file> - output goes to standard output\n"
- "\tNote: if no <binary-log-file> - input is taken from standard "
- "input\n"));
-
- exit(3);
-}
-
-/*
- * atoi_for2(p, value)
- * - stores the numerical value of the two digit string p into value
- * - return TRUE upon success and FALSE upon failure
- */
-
-static int
-atoi_for2(char *p, int *value)
-{
-
- *value = (*p - '0') * 10 + *(p+1) - '0';
- if ((*value < 0) || (*value > 99))
- return (FALSE);
- return (TRUE);
-}
-
-/*
- * parse_time(t, tm)
- * - parses the string t to retrieve the UNIX time format as specified by
- * touch(1).
- * - return TRUE upon success and FALSE upon failure
- */
-
-static int
-parse_time(char *t, struct tm *tm)
-{
- int century = 0;
- int seconds = 0;
- time_t when;
- char *p;
-
- /*
- * time in the following format (defined by the touch(1) spec):
- * [[CC]YY]MMDDhhmm[.SS]
- */
- if ((p = strchr(t, '.')) != NULL) {
- if (strchr(p+1, '.') != NULL)
- return (FALSE);
- if (!atoi_for2(p+1, &seconds))
- return (FALSE);
- *p = '\0';
- }
-
- when = time(0);
- bzero(tm, sizeof (struct tm));
- tm->tm_year = localtime(&when)->tm_year;
-
- switch (strlen(t)) {
- case 12: /* CCYYMMDDhhmm */
- if (!atoi_for2(t, &century))
- return (FALSE);
- t += 2;
- /* FALLTHROUGH */
- case 10: /* YYMMDDhhmm */
- if (!atoi_for2(t, &tm->tm_year))
- return (FALSE);
- t += 2;
- if (century == 0) {
- if (tm->tm_year < 69)
- tm->tm_year += 100;
- } else
- tm->tm_year += (century - 19) * 100;
- /* FALLTHROUGH */
- case 8: /* MMDDhhmm */
- if (!atoi_for2(t, &tm->tm_mon))
- return (FALSE);
- tm->tm_mon--;
- t += 2;
-
- if (!atoi_for2(t, &tm->tm_mday))
- return (FALSE);
- t += 2;
-
- if (!atoi_for2(t, &tm->tm_hour))
- return (FALSE);
- t += 2;
-
- if (!atoi_for2(t, &tm->tm_min))
- return (FALSE);
-
- tm->tm_sec = seconds;
- break;
- default:
- return (FALSE);
- }
-
- return (TRUE);
-}
-
-static void
-close_files(int ifd, int ofd)
-{
- if (ifd != STDIN_FILENO)
- (void) close(ifd);
-
- if (ofd != STDOUT_FILENO)
- (void) close(ofd);
-}
-
-/*
- * Read the requested number of bytes from the given file descriptor
- */
-
-static ssize_t
-read_n_bytes(int fd, char *buf, ssize_t bufsize)
-{
- ssize_t num_to_read = bufsize;
- ssize_t num_already_read = 0;
- ssize_t i;
-
- while (num_to_read > 0) {
-
- i = read(fd, &(buf[num_already_read]), num_to_read);
- if (i < 0) {
- if (errno == EINTR)
- continue;
- else
- (void) fprintf(stderr, gettext(
- "Error: ncab2clf: "
- "reading input file: %s\n"),
- strerror(errno));
- return (-1); /* some wierd interrupt */
- }
-
- if (i == 0)
- break;
-
- num_already_read += i;
- num_to_read -= i;
- }
-
- return (num_already_read);
-}
-
-/*
- * Write the requested number of bytes to the given file descriptor
- */
-
-static ssize_t
-write_n_bytes(int fd, char *buf, ssize_t bufsize)
-{
- ssize_t num_to_write = bufsize;
- ssize_t num_written = 0;
- ssize_t i;
-
- while (num_to_write > 0) {
-
- i = write(fd, &(buf[num_written]), num_to_write);
- if (i < 0) {
- if (errno == EINTR)
- continue;
- else
- (void) fprintf(stderr, gettext(
- "Error: ncab2clf: "
- "writing output file: %s\n"),
- strerror(errno));
- return (-1); /* some wierd interrupt */
- }
-
- num_written += i;
- num_to_write -= i;
- }
-
- return (num_written);
-}
-
-/* do constraint checks and determine if it's a valid header */
-
-static bool
-is_valid_header(void *ibuf)
-{
- nca_log_buf_hdr_t *h;
- nca_log_stat_t *s;
-
- h = (nca_log_buf_hdr_t *)ibuf;
-
- /* Do some validity checks on ibuf */
-
- if (((h->nca_loghdr).nca_version != NCA_LOG_VERSION1) ||
- ((h->nca_loghdr).nca_op != log_op)) {
- return (false);
- }
-
- s = &(h->nca_logstats);
-
- if (g_n_log_upcall == 0) {
- g_n_log_upcall = s->n_log_upcall;
- } else {
- if ((++g_n_log_upcall) != (ssize_t)s->n_log_upcall) {
- (void) fprintf(stderr, gettext(
- "Warning: ncab2clf:"
- " expected record number (%d) is"
- " different from the one seen (%d)\n."
- " Resetting the expected record"
- " number.\n"), g_n_log_upcall, s->n_log_upcall);
-
- g_n_log_upcall = s->n_log_upcall;
- }
- }
-
- return (true);
-}
-
-/* convert input binary buffer into CLF */
-
-static int
-b2clf_buf(
- void *ibuf,
- char *obuf,
- ssize_t isize,
- ssize_t osize,
- ssize_t *out_size)
-{
- nca_log_buf_hdr_t *h;
- nca_log_stat_t *s;
- nca_request_log_t *r;
-
- char *br;
- void *er;
- char ip_buf[64];
- ssize_t max_input_size, num_bytes_read;
- int n_recs;
- bool error_seen;
-
- ssize_t count;
- char clf_timebuf[CLF_DATE_BUF_LENGTH];
- char *method;
- char *http_version_string;
- char *ruser;
- char *req_url;
- char *remote_ip;
-
- h = (nca_log_buf_hdr_t *)ibuf;
- s = &(h->nca_logstats);
- r = (nca_request_log_t *)(&(h[1]));
-
- /* OK, it's a valid buffer which we can use, go ahead and convert it */
-
- max_input_size = (ssize_t)isize - sizeof (nca_log_buf_hdr_t);
-
- *out_size = 0;
- error_seen = false;
- num_bytes_read = 0;
- for (n_recs = 0; n_recs < s->n_log_recs; n_recs++) {
-
- /* Make sure there is enough space in the output buffer */
-
- if ((*out_size >= osize) ||
- (num_bytes_read >= max_input_size)) {
- error_seen = true;
- break;
- }
-
- if (http_clf_date(clf_timebuf, sizeof (clf_timebuf),
- ((time_t)r->start_process_time))) {
- /* A start time was speced and we're not there yet */
- ++g_skip_count;
- goto skip;
- }
-
- /* Only logs valid HTTP ops */
-
- if ((! valid_method((int)r->method)) ||
- (! valid_version((int)r->version))) {
- ++g_invalid_count;
- goto skip;
- }
-
- method = http_method((int)r->method);
- http_version_string = http_version((int)r->version);
-
- remote_ip = ip_dot_addr(r->remote_host, (char *)&ip_buf);
- if (r->remote_user_len) {
- ruser = NCA_REQLOG_RDATA(r, remote_user);
- } else {
- ruser = "-";
- }
-
- if (r->request_url_len) {
- req_url = NCA_REQLOG_RDATA(r, request_url);
- } else {
- req_url = "UNKNOWN";
- }
-
- count = (ssize_t)snprintf(&(obuf[*out_size]), osize - *out_size,
- "%s %s %s %s \"%s %s %s\" %d %d\n",
- ((remote_ip) ? remote_ip : "-"),
- /* should be remote_log_name */
- "-",
- ruser,
- clf_timebuf,
- method,
- req_url,
- http_version_string,
- r->response_status,
- r->response_len);
-
- *out_size += count;
- skip:
- br = (char *)r;
- er = ((char *)r) + NCA_LOG_REC_SIZE(r);
-
- /*LINTED*/
- r = (nca_request_log_t *)NCA_LOG_ALIGN(er);
- num_bytes_read += (ssize_t)(((char *)r) - br);
- if (g_out_records > 0 && --g_out_records == 0)
- break;
- }
-
- if (error_seen) {
- (void) fprintf(stderr, gettext(
- "Error: ncab2clf: Input buffer not fully converted.\n"));
-
- if (n_recs != s->n_log_recs)
- (void) fprintf(stderr, gettext(
- "Warning: ncab2clf: "
- "Converted only %d of %d records\n"),
- n_recs, s->n_log_recs);
- }
-
- return (0);
-}
-
-static int
-b2clf(int ifd, int ofd)
-{
- char *ibuf;
- char *obuf;
- bool error_seen;
- bool eof_seen;
- ssize_t num_iterations, ni, nh, no, olen;
-
- nca_log_buf_hdr_t *h;
- nca_log_stat_t *s;
-
- ibuf = xmalloc(g_infile_blk_size);
- obuf = xmalloc(OUTFILE_BUF_SIZE);
- error_seen = false;
-
- eof_seen = false;
- num_iterations = 0;
- while (! eof_seen && g_out_records != 0) {
- ++num_iterations;
-
- nh = ni = no = 0;
-
- /* read the binary header first */
- nh = read_n_bytes(ifd, ibuf, sizeof (nca_log_buf_hdr_t));
- if (nh != sizeof (nca_log_buf_hdr_t)) {
- eof_seen = true;
- break;
- }
-
- if (! is_valid_header(ibuf)) {
- (void) fprintf(stderr, gettext(
- "Error: ncab2clf: "
- "Can't convert the input data to CLF\n"));
- continue;
- }
-
- /* read the data to be converted */
- /* LINTED */
- h = (nca_log_buf_hdr_t *)ibuf;
- s = &(h->nca_logstats);
-
- if (s->n_log_size == 0)
- continue;
-
- ni = read_n_bytes(ifd, &(ibuf[nh]), (ssize_t)s->n_log_size);
- if (ni < 0) {
- error_seen = true;
- break;
- } else if (ni < (ssize_t)s->n_log_size) {
- eof_seen = true;
- }
-
- if (ni == 0)
- break;
-
- /* convert binary input into text output */
-
- if (b2clf_buf(ibuf, obuf, ni + nh, OUTFILE_BUF_SIZE, &olen)) {
- (void) fprintf(stderr, gettext(
- "Error: ncab2clf: "
- "Can't convert the input data to CLF\n"));
- error_seen = true;
- break;
- }
-
- /* write out the text data */
- no = write_n_bytes(ofd, obuf, olen);
- if (no != olen) {
- error_seen = true;
- break;
- }
-
- bzero(ibuf, nh + ni);
- bzero(obuf, no);
- }
-
- free(ibuf);
- free(obuf);
-
- if (error_seen)
- return (-1);
-
- return (0);
-}
-
-
-int
-main(int argc, char **argv)
-{
- int c;
- int ifd; /* input fd - binary log file */
- int ofd;
- struct tm t;
-
- char *infile = NULL; /* input file name */
- char *outfile = NULL; /* output file name */
-
- char monstr[64];
-
- (void) setlocale(LC_ALL, "");
-
-#if !defined(TEXT_DOMAIN) /* Should be defined by cc -D */
-#define TEXT_DOMAIN "SYS_TEST"
-#endif
-
- (void) textdomain(TEXT_DOMAIN);
-
- /* parse any arguments */
- while ((c = getopt(argc, argv, "hvDi:o:b:n:s:")) != EOF) {
- switch (c) {
- case 'h':
- usage();
- break;
- case 'i':
- infile = xstrdup(optarg);
- break;
- case 'D':
- g_enable_directio = false;
- break;
- case 'o':
- outfile = xstrdup(optarg);
- break;
- case 'b':
- g_infile_blk_size = (KILO_BYTE * atoi(optarg));
- break;
- case 'n':
- g_out_records = atoi(optarg);
- break;
- case 's':
- g_start_time_str = strdup(optarg);
- bzero(&t, sizeof (t));
- if (sscanf(optarg, "%d/%3s/%d:%d:%d:%d", &t.tm_mday,
- &monstr[0], &t.tm_year, &t.tm_hour, &t.tm_min,
- &t.tm_sec) == 6) {
- /* Valid CLF time (e.g. 06/Apr/2001:09:14:14) */
- t.tm_mon = 0;
- do {
- if (strcasecmp(monstr,
- sMonthStr[t.tm_mon]) == 0)
- break;
- } while (t.tm_mon++ < 12);
- t.tm_year -= 1900;
- g_start_time = t;
- } else if (parse_time(optarg, &t)) {
- g_start_time = t;
- } else {
- (void) fprintf(stderr,
- gettext("Error: ncab2clf:"
- " %s: unrecognized date/time.\n"),
- optarg);
- }
- break;
- case 'v':
- (void) fprintf(stderr, gettext("Error: ncab2clf: "
- "verbose functionality not yet supported\n"));
- exit(3);
- break;
- case '?':
- usage();
- break;
- }
- }
-
- /* set up the input stream */
-
- if (infile) {
-
- if ((ifd = open(infile, O_RDONLY)) < 0) {
- (void) fprintf(stderr,
- gettext("Error: ncab2clf: "
- "Failure to open binary log file %s: %s\n"),
- infile, strerror(errno));
- exit(1);
- }
-
- } else {
- ifd = STDIN_FILENO;
- }
-
- /* set up the output stream */
-
- if (outfile) {
-
- if ((ofd = open(outfile, O_WRONLY|O_CREAT, 0644)) < 0) {
- (void) fprintf(stderr, gettext(
- "Error: ncab2clf: "
- "Failure to open output file %s: %s\n"),
- outfile, strerror(errno));
- exit(1);
- }
-
- /* Enable directio on output stream if specified */
-
- if (g_enable_directio)
- (void) directio(ofd, DIRECTIO_ON);
-
- } else {
- ofd = STDOUT_FILENO;
- }
-
- if ((b2clf(ifd, ofd) != 0)) {
- close_files(ifd, ofd);
- exit(2);
- }
-
- close_files(ifd, ofd);
-
- if (g_invalid_count) {
- (void) fprintf(stderr, gettext("Warning: ncab2clf: %d"
- " number of invalid log records encountered in binary input"
- " file were skipped\n"), g_invalid_count);
- }
- if (g_skip_count) {
- (void) fprintf(stderr, gettext("Warning: ncab2clf:"
- " %d log records in binary input file before %s"
- " were skipped\n"),
- g_skip_count, g_start_time_str);
- }
-
- return (0);
-}
diff --git a/usr/src/cmd/cmd-inet/usr.lib/Makefile b/usr/src/cmd/cmd-inet/usr.lib/Makefile
index b2d674bcf1..67186f1e27 100644
--- a/usr/src/cmd/cmd-inet/usr.lib/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.lib/Makefile
@@ -21,20 +21,20 @@
#
# Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+# Copyright 2022 Garrett D'Amore
#
SUBDIRS= bridged ilbd in.chargend in.daytimed \
in.discardd in.echod in.mpathd in.ndpd \
- in.ripngd in.timed inetd mdnsd ncaconfd pppoe \
+ in.ripngd in.timed inetd mdnsd pppoe \
slpd vrrpd wpad
-MSGSUBDIRS= ilbd inetd ncaconfd vrrpd
+MSGSUBDIRS= ilbd inetd vrrpd
include ../../Makefile.cmd
include ./Makefile.lib
-POFILES= inetd/inetd.po ncaconfd/ncaconfd.po vrrpd/vrrpd.po
+POFILES= inetd/inetd.po vrrpd/vrrpd.po
POFILE= usr.lib.po
all:= TARGET= all
diff --git a/usr/src/cmd/cmd-inet/usr.lib/ncaconfd/Makefile b/usr/src/cmd/cmd-inet/usr.lib/ncaconfd/Makefile
deleted file mode 100644
index 1a447f1888..0000000000
--- a/usr/src/cmd/cmd-inet/usr.lib/ncaconfd/Makefile
+++ /dev/null
@@ -1,50 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright (c) 2000 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-
-PROG = ncaconfd
-
-.KEEP_STATE:
-
-all: $(PROG)
-
-include ../../../Makefile.cmd
-include ../Makefile.lib
-
-LDLIBS += -lsocket -lnsl
-CPPFLAGS += -I$(SRC)/uts/common/inet/nca
-
-CERRWARN += $(CNOWARN_UNINIT)
-
-POFILE = ${PROG}.po
-
-install: all $(ROOTLIBINETPROG)
-
-clean:
- $(RM) $(PROG)
-
-include ../../../Makefile.targ
-
-lint: lint_PROG
diff --git a/usr/src/cmd/cmd-inet/usr.lib/ncaconfd/ncaconfd.c b/usr/src/cmd/cmd-inet/usr.lib/ncaconfd/ncaconfd.c
deleted file mode 100644
index 8115784a3a..0000000000
--- a/usr/src/cmd/cmd-inet/usr.lib/ncaconfd/ncaconfd.c
+++ /dev/null
@@ -1,1424 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (the "License"). You may not use this file except in compliance
- * with the License.
- *
- * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
- * or http://www.opensolaris.org/os/licensing.
- * See the License for the specific language governing permissions
- * and limitations under the License.
- *
- * When distributing Covered Code, include this CDDL HEADER in each
- * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
- * If applicable, add the following below this CDDL HEADER, with the
- * fields enclosed by brackets "[]" replaced with your own identifying
- * information: Portions Copyright [yyyy] [name of copyright owner]
- *
- * CDDL HEADER END
- */
-/*
- * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <sys/tihdr.h>
-#include <stropts.h>
-#include <fcntl.h>
-#include <syslog.h>
-#include <string.h>
-#include <strings.h>
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <libintl.h>
-#include <locale.h>
-#include <unistd.h>
-#include <sys/varargs.h>
-
-#include <netinet/in.h>
-#include <sys/ethernet.h>
-#include <sys/socket.h>
-#include <sys/sockio.h>
-#include <sys/sysmacros.h>
-#include <net/if.h>
-#include <inet/mib2.h>
-#include <inet/ip.h>
-#include <net/route.h>
-#include <arpa/inet.h>
-#include "ncaconf.h"
-
-/* NCA does not support IPv6... */
-#ifndef NCA_MOD_NAME
-#define NCA_MOD_NAME "nca"
-#endif
-
-#ifndef ARP_MOD_NAME
-#define ARP_MOD_NAME "arp"
-#endif
-
-#define IF_SEPARATOR ':'
-
-#define ping_prog "/usr/sbin/ping"
-
-/* Structure to hold info about each network interface. */
-typedef struct nif_s {
- char name[LIFNAMSIZ+1];
- struct in_addr local_addr;
- struct in_addr router_addr;
- uchar_t router_ether_addr[ETHERADDRL];
-} nif_t;
-
-typedef struct mib_item_s {
- struct mib_item_s *next_item;
- int group;
- int mib_id;
- int length;
- char *valp;
-} mib_item_t;
-
-/* The network interface array. */
-static nif_t *nif_list;
-/* Number of network interface to process. */
-static int num_nif;
-
-/* Interface request to IP. */
-static struct lifreq lifr;
-
-/* True if syslog is to be used. */
-static boolean_t logging;
-/* True if additional debugging messages are printed. */
-static boolean_t debug;
-
-/* File descriptor to the routing socket. */
-static int rt_fd;
-
-static void logperror(char *);
-static void logwarn(char *, ...);
-static void logdebug(char *, ...);
-static int ip_domux2fd(int *, int *);
-static void ip_plink(int, int);
-static int find_nca_pos(int);
-static int nca_set_nif(int, struct in_addr, uchar_t *);
-static void nca_setup(boolean_t *);
-static int get_if_ip_addr(void);
-static mib_item_t *mibget(int);
-static int ire_process(mib2_ipRouteEntry_t *, size_t, boolean_t *);
-static int arp_process(mib2_ipNetToMediaEntry_t *, size_t, boolean_t *);
-static int get_router_ip_addr(mib_item_t *, boolean_t *);
-static int get_router_ether_addr(mib_item_t *, boolean_t *);
-static int get_if_info(boolean_t *);
-static void daemon_init(void);
-static void daemon_work(void);
-static void ping_them(void);
-
-/*
- * Print out system error messages, either to syslog or stderr. Note that
- * syslog() should print out system error messages in the correct language
- * used. There is no need to use gettext().
- */
-static void
-logperror(char *str)
-{
- if (logging) {
- syslog(LOG_ERR, "%s: %m\n", str);
- } else {
- (void) fprintf(stderr, "ncaconfd: %s: %s\n", str,
- strerror(errno));
- }
-}
-
-/*
- * Print out warning messages. The caller should use gettext() to have
- * the message printed out in the correct language.
- */
-/*PRINTFLIKE1*/
-static void
-logwarn(char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- if (logging) {
- vsyslog(LOG_WARNING, fmt, ap);
- } else {
- (void) fprintf(stderr, "ncaconfd: ");
- (void) vfprintf(stderr, fmt, ap);
- }
- va_end(ap);
-}
-
-/*
- * Print out debugging info. Note that syslogd(8) should be configured to
- * take ordinary debug info for it to get this kind of info.
- */
-/*PRINTFLIKE1*/
-static void
-logdebug(char *fmt, ...)
-{
- va_list ap;
-
- va_start(ap, fmt);
- if (logging) {
- vsyslog(LOG_WARNING, fmt, ap);
- } else {
- (void) fprintf(stderr, "ncaconfd: ");
- (void) vfprintf(stderr, fmt, ap);
- }
- va_end(ap);
-}
-
-/*
- * Helper function for nca_setup(). It gets a fd to the lower IP
- * stream and I_PUNLINK's the lower stream. It also initializes the
- * global variable lifr.
- *
- * Param:
- * int *udp_fd: (referenced) fd to /dev/udp (upper IP stream).
- * int *fd: (referenced) fd to the lower IP stream.
- *
- * Return:
- * -1 if operation fails, 0 otherwise.
- */
-static int
-ip_domux2fd(int *udp_fd, int *fd)
-{
- int ip_fd;
-
- if ((ip_fd = open(IP_DEV_NAME, O_RDWR)) < 0) {
- logperror("Cannot open IP");
- return (-1);
- }
- if ((*udp_fd = open(UDP_DEV_NAME, O_RDWR)) < 0) {
- logperror("Cannot open UDP");
- (void) close(ip_fd);
- return (-1);
- }
- if (ioctl(ip_fd, SIOCGLIFMUXID, (caddr_t)&lifr) < 0) {
- logperror("ioctl(SIOCGLIFMUXID) failed");
- (void) close(ip_fd);
- return (-1);
- }
- if (debug) {
- logdebug("ARP_muxid %d IP_muxid %d\n", lifr.lifr_arp_muxid,
- lifr.lifr_ip_muxid);
- }
- if ((*fd = ioctl(*udp_fd, _I_MUXID2FD, lifr.lifr_ip_muxid)) < 0) {
- logperror("ioctl(_I_MUXID2FD) failed");
- (void) close(ip_fd);
- (void) close(*udp_fd);
- return (-1);
- }
- (void) close(ip_fd);
- return (0);
-}
-
-/*
- * Helper function for nca_setup(). It I_PLINK's back the upper and
- * lower IP streams. Note that this function must be called after
- * ip_domux2fd(). In ip_domux2fd(), the global variable lifr is initialized
- * and ip_plink() needs information in lifr. So ip_domux2fd() and ip_plink()
- * must be called in pairs.
- *
- * Param:
- * int udp_fd: fd to /dev/udp (upper IP stream).
- * int fd: fd to the lower IP stream.
- */
-static void
-ip_plink(int udp_fd, int fd)
-{
- int mux_id;
-
- if ((mux_id = ioctl(udp_fd, I_PLINK, fd)) < 0) {
- logperror("ioctl(I_PLINK) failed");
- return;
- }
- if (debug > 0) {
- logdebug("New IP_muxid %d\n", mux_id);
- }
- lifr.lifr_ip_muxid = mux_id;
- if (ioctl(udp_fd, SIOCSLIFMUXID, (caddr_t)&lifr) < 0) {
- logperror("ioctl(SIOCSLIFMUXID) failed");
- }
-}
-
-#define FOUND_NCA -1
-#define FOUND_NONE -2
-/*
- * Find the proper position to insert NCA, which is just below IP.
- *
- * Param:
- * int fd: fd to the lower IP stream.
- *
- * Return:
- * If positive, it is the position to insert NCA.
- * FOUND_NCA: found NCA! So skip this one for plumbing. But we
- * still keep it in the interface list.
- * FOUND_NONE: could not find IP or encounter other errors. Remove
- * this interface from the list.
- */
-static int
-find_nca_pos(int fd)
-{
- int num_mods;
- int i, pos;
- struct str_list strlist;
- boolean_t found_ip = B_FALSE;
- boolean_t found_nca = B_FALSE;
-
- if ((num_mods = ioctl(fd, I_LIST, NULL)) < 0) {
- logperror("ioctl(I_LIST) failed");
- return (FOUND_NONE);
- } else {
- strlist.sl_nmods = num_mods;
- strlist.sl_modlist = calloc(num_mods,
- sizeof (struct str_mlist));
- if (strlist.sl_modlist == NULL) {
- logperror("cannot malloc");
- return (FOUND_NONE);
- } else {
- if (ioctl(fd, I_LIST, (caddr_t)&strlist) < 0) {
- logperror("ioctl(I_LIST) failed");
- } else {
- for (i = 0; i < strlist.sl_nmods; i++) {
- if (strcmp(IP_MOD_NAME,
- strlist.sl_modlist[i].l_name)
- == 0) {
- found_ip = B_TRUE;
- /*
- * NCA should be just below
- * IP.
- */
- pos = i + 1;
- } else if (strncmp(NCA_MOD_NAME,
- strlist.sl_modlist[i].l_name,
- strlen(NCA_MOD_NAME)) == 0) {
- found_nca = B_TRUE;
- }
- }
- }
- free(strlist.sl_modlist);
- }
- }
- if (found_nca) {
- return (FOUND_NCA);
- } else if (found_ip) {
- if (debug) {
- logdebug("NCA is at position %d in the stream.\n", pos);
- }
- return (pos);
- } else {
- if (debug) {
- logdebug("Cannot find IP??\n");
- }
- return (FOUND_NONE);
- }
-}
-
-/*
- * To set the local IP address and default router ethernet address.
- *
- * Param:
- * int fd: the fd to the lower IP stream.
- * struct in_addr local_addr: the IP address for this interface.
- * uchar_t *ether_addr: the ethernet address of the default router for
- * for this interface.
- *
- * Return:
- * -1 if the system does not support this NCA ioctl(), 0 otherwise.
- */
-static int
-nca_set_nif(int fd, struct in_addr local_addr, uchar_t *ether_addr)
-{
- struct nca_set_ioctl nca_ioctl;
- struct strioctl strioc;
- int len;
- uchar_t *dst;
-
- strioc.ic_cmd = NCA_SET_IF;
- strioc.ic_timout = INFTIM;
- strioc.ic_len = sizeof (nca_ioctl);
- strioc.ic_dp = (char *)&nca_ioctl;
-
- nca_ioctl.local_addr = local_addr.s_addr;
- dst = nca_ioctl.router_ether_addr;
- for (len = ETHERADDRL; len > 0; len--)
- *dst++ = *ether_addr++;
- nca_ioctl.action = ADD_DEF_ROUTE;
-
- if (ioctl(fd, I_STR, &strioc) < 0) {
- logperror("ioctl(NCA_SET_IF) failed");
- if (errno == EINVAL)
- return (-1);
- }
- return (0);
-}
-
-/*
- * To setup the NCA stream. First insert NCA into the proper position.
- * Then tell NCA the local IP address and default router by using the
- * NCA_SET_IF ioctl.
- *
- * Param:
- * boolean_t *active: (referenced) B_TRUE if NCA is setup to do active
- * connection. If NCA does not support active connection,
- * in return, active will be set to B_FALSE.
- */
-static void
-nca_setup(boolean_t *active)
-{
- int i;
- int udp_fd;
- int fd;
- struct strmodconf mod;
- /* 128 is enough because interface name can only be LIFNAMSIZ long. */
- char err_buf[128];
-
- mod.mod_name = NCA_MOD_NAME;
- lifr.lifr_addr.ss_family = AF_INET;
- for (i = 0; i < num_nif; i++) {
- if (debug) {
- logdebug("Plumbing NCA for %s\n", nif_list[i].name);
- }
- /* This interface does not exist according to IP. */
- if (nif_list[i].local_addr.s_addr == 0) {
- continue;
- }
- (void) strlcpy(lifr.lifr_name, nif_list[i].name,
- sizeof (lifr.lifr_name));
-
- if (ip_domux2fd(&udp_fd, &fd) < 0) {
- continue;
- }
- if (ioctl(udp_fd, I_PUNLINK, lifr.lifr_ip_muxid) < 0) {
- (void) snprintf(err_buf, sizeof (err_buf),
- "ioctl(I_PUNLINK) for %s failed", nif_list[i].name);
- logperror(err_buf);
- (void) close(udp_fd);
- (void) close(fd);
- continue;
- }
- if ((mod.pos = find_nca_pos(fd)) < 0) {
- if (mod.pos == FOUND_NCA) {
- if (debug) {
- logdebug("Find NCA in the %s"
- " stream\n", nif_list[i].name);
- }
- /* Just skip plumbing NCA. */
- goto set_nif;
- }
- if (debug) {
- logdebug("Cannot find pos for %s\n",
- nif_list[i].name);
- }
- goto clean_up;
- }
- if (ioctl(fd, _I_INSERT, (caddr_t)&mod) < 0) {
- (void) snprintf(err_buf, sizeof (err_buf),
- "ioctl(_I_INSERT) for %s failed", nif_list[i].name);
- logperror(err_buf);
- goto clean_up;
- }
-
- /*
- * Only do the following if NCA is also used to make
- * outgoing connections, and all necessary info is
- * there.
- */
-set_nif:
- if (*active && nif_list[i].router_addr.s_addr != 0) {
- if (nca_set_nif(fd, nif_list[i].local_addr,
- nif_list[i].router_ether_addr) < 0) {
- /*
- * The system does not support this ioctl()!
- * Skip all active stack processing but
- * continue to plumb NCA.
- */
- logwarn("NCA does not support active stack!");
- *active = B_FALSE;
- }
- }
-clean_up:
- ip_plink(udp_fd, fd);
- (void) close(udp_fd);
- (void) close(fd);
- }
-}
-
-/*
- * To get IP address of network interface from IP.
- */
-static int
-get_if_ip_addr(void)
-{
- int sock;
- struct lifnum lifn;
- struct lifconf lifc;
- struct lifreq *lifr;
- struct sockaddr_in *sin;
- char *buf;
- int num_lifr;
- int i, j;
-
- /* NCA only supports IPv4... */
- if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
- logperror(gettext("Cannot open socket"));
- return (-1);
- }
- lifn.lifn_family = AF_UNSPEC;
- lifn.lifn_flags = 0;
- if (ioctl(sock, SIOCGLIFNUM, (char *)&lifn) < 0) {
- logperror(gettext("ioctl(SIOCGLIFNUM) failed"));
- (void) close(sock);
- return (-1);
- }
- buf = (char *)calloc(lifn.lifn_count, sizeof (struct lifreq));
- if (buf == NULL) {
- logperror(gettext("calloc() failed"));
- (void) close(sock);
- return (-1);
- }
-
- lifc.lifc_family = AF_UNSPEC;
- lifc.lifc_flags = 0;
- lifc.lifc_len = lifn.lifn_count * sizeof (struct lifreq);
- lifc.lifc_buf = buf;
-
- if (ioctl(sock, SIOCGLIFCONF, (char *)&lifc) < 0) {
- /*
- * NCA is set up after all the interfaces have been
- * plumbed. So normally we should not get any error.
- * Just abort if we encounter an error.
- */
- logperror(gettext("ioctl(SIOCGLIFCONF) failed"));
- free(buf);
- (void) close(sock);
- return (-1);
- }
- num_lifr = lifc.lifc_len / sizeof (struct lifreq);
- /* Find the interface and copy the local IP address. */
- for (i = 0; i < num_nif; i++) {
- lifr = (struct lifreq *)lifc.lifc_req;
- for (j = num_lifr; j > 0; j--, lifr++) {
- /* Again, NCA only supports IPv4. */
- if (lifr->lifr_addr.ss_family != AF_INET)
- continue;
- if (strncmp(nif_list[i].name, lifr->lifr_name,
- strlen(nif_list[i].name)) == 0) {
- sin = (struct sockaddr_in *)&lifr->lifr_addr;
- nif_list[i].local_addr = sin->sin_addr;
- if (debug) {
- logdebug("IP address of %s: %s\n",
- nif_list[i].name,
- inet_ntoa(sin->sin_addr));
- }
- break;
- }
- }
- if (j == 0) {
- /*
- * The interface does not exist according to IP!
- * Log a warning and go on.
- */
- logwarn(gettext("Network interface %s"
- " does not exist!\n"), nif_list[i].name);
- /*
- * Set local_addr to 0 so that nca_setup() will
- * not do anything for this interface.
- */
- nif_list[i].local_addr.s_addr = 0;
- }
- }
- free(buf);
- (void) close(sock);
- return (0);
-}
-
-/*
- * Get MIB2 info from IP.
- *
- * Param:
- * int sd: descriptor to IP to send down mib request.
- */
-static mib_item_t *
-mibget(int sd)
-{
- char buf[1024];
- int flags;
- int i, j, getcode;
- struct strbuf ctlbuf, databuf;
- /* LINTED */
- struct T_optmgmt_req *tor = (struct T_optmgmt_req *)buf;
- /* LINTED */
- struct T_optmgmt_ack *toa = (struct T_optmgmt_ack *)buf;
- /* LINTED */
- struct T_error_ack *tea = (struct T_error_ack *)buf;
- struct opthdr *req;
- mib_item_t *first_item = (mib_item_t *)0;
- mib_item_t *last_item = (mib_item_t *)0;
- mib_item_t *temp;
-
- tor->PRIM_type = T_SVR4_OPTMGMT_REQ;
- tor->OPT_offset = sizeof (struct T_optmgmt_req);
- tor->OPT_length = sizeof (struct opthdr);
- tor->MGMT_flags = T_CURRENT;
- req = (struct opthdr *)&tor[1];
- req->level = MIB2_IP; /* any MIB2_xxx value ok here */
- req->name = 0;
- req->len = 0;
-
- ctlbuf.buf = buf;
- ctlbuf.len = tor->OPT_length + tor->OPT_offset;
- flags = 0;
- if (putmsg(sd, &ctlbuf, (struct strbuf *)0, flags) == -1) {
- logperror("mibget: putmsg(ctl) failed");
- goto error_exit;
- }
-
- /*
- * Each reply consists of a ctl part for one fixed structure
- * or table, as defined in mib2.h. The format is a T_OPTMGMT_ACK,
- * containing an opthdr structure. level/name identify the entry,
- * len is the size of the data part of the message.
- */
- req = (struct opthdr *)&toa[1];
- ctlbuf.maxlen = sizeof (buf);
- j = 1;
- for (;;) {
- flags = 0;
- getcode = getmsg(sd, &ctlbuf, (struct strbuf *)0, &flags);
- if (getcode == -1) {
- logperror("mibget getmsg(ctl) failed");
- if (debug) {
- logdebug("# level name len\n");
- i = 0;
- for (last_item = first_item; last_item;
- last_item = last_item->next_item)
- (void) printf("%d %4d %5d %d\n",
- ++i,
- last_item->group,
- last_item->mib_id,
- last_item->length);
- }
- goto error_exit;
- }
- if (getcode == 0 &&
- ctlbuf.len >= sizeof (struct T_optmgmt_ack) &&
- toa->PRIM_type == T_OPTMGMT_ACK &&
- toa->MGMT_flags == T_SUCCESS &&
- req->len == 0) {
- if (debug) {
- logdebug("mibget getmsg() %d returned "
- "EOD (level %ld, name %ld)\n",
- j, req->level, req->name);
- }
- return (first_item); /* this is EOD msg */
- }
-
- if (ctlbuf.len >= sizeof (struct T_error_ack) &&
- tea->PRIM_type == T_ERROR_ACK) {
- logwarn("mibget %d gives T_ERROR_ACK: TLI_error ="
- " 0x%lx, UNIX_error = 0x%lx\n",
- j, tea->TLI_error, tea->UNIX_error);
- errno = (tea->TLI_error == TSYSERR) ?
- tea->UNIX_error : EPROTO;
- goto error_exit;
- }
-
- if (getcode != MOREDATA ||
- ctlbuf.len < sizeof (struct T_optmgmt_ack) ||
- toa->PRIM_type != T_OPTMGMT_ACK ||
- toa->MGMT_flags != T_SUCCESS) {
- logwarn("mibget getmsg(ctl) %d returned %d, "
- "ctlbuf.len = %d, PRIM_type = %ld\n",
- j, getcode, ctlbuf.len, toa->PRIM_type);
- if (toa->PRIM_type == T_OPTMGMT_ACK) {
- logwarn("T_OPTMGMT_ACK: "
- "MGMT_flags = 0x%lx, req->len = %ld\n",
- toa->MGMT_flags, req->len);
- }
- errno = ENOMSG;
- goto error_exit;
- }
-
- temp = (mib_item_t *)malloc(sizeof (mib_item_t));
- if (!temp) {
- logperror("mibget malloc failed");
- goto error_exit;
- }
- if (last_item)
- last_item->next_item = temp;
- else
- first_item = temp;
- last_item = temp;
- last_item->next_item = (mib_item_t *)0;
- last_item->group = req->level;
- last_item->mib_id = req->name;
- last_item->length = req->len;
- last_item->valp = malloc((int)req->len);
-
- databuf.maxlen = last_item->length;
- databuf.buf = last_item->valp;
- databuf.len = 0;
- flags = 0;
- getcode = getmsg(sd, (struct strbuf *)0, &databuf, &flags);
- if (getcode == -1) {
- logperror("mibget getmsg(data) failed");
- goto error_exit;
- } else if (getcode != 0) {
- logwarn("mibget getmsg(data) returned %d, "
- "databuf.maxlen = %d, databuf.len = %d\n",
- getcode, databuf.maxlen, databuf.len);
- goto error_exit;
- }
- j++;
- }
-
-error_exit:;
- while (first_item) {
- last_item = first_item;
- first_item = first_item->next_item;
- free(last_item);
- }
- return (first_item);
-}
-
-/*
- * Examine the IPv4 routing table for default routers. For each interface,
- * find its default router.
- *
- * Param:
- * mib2_ipRouteEntry_t *buf: the mib info buffer.
- * size_t len: length of buffer.
- * boolean_t *changed (referenced): set to B_TRUE if there is a change
- * in router info.
- *
- * Return:
- * number of default router found.
- */
-static int
-ire_process(mib2_ipRouteEntry_t *buf, size_t len, boolean_t *changed)
-{
- mib2_ipRouteEntry_t *rp;
- mib2_ipRouteEntry_t *rp1;
- mib2_ipRouteEntry_t *rp2;
- struct in_addr nexthop_v4;
- mib2_ipRouteEntry_t *endp;
- char ifname[LIFNAMSIZ + 1];
- char *cp;
- int i;
- int ifname_len;
- boolean_t found;
- int num_found = 0;
-
- if (len == 0)
- return (0);
- endp = buf + (len / sizeof (mib2_ipRouteEntry_t));
-
- for (i = 0; i < num_nif; i++) {
- /*
- * Loop thru the routing table entries. Process any
- * IRE_DEFAULT ire. Ignore the others. For each such
- * ire, get the nexthop gateway address.
- */
- found = B_FALSE;
- for (rp = buf; rp < endp; rp++) {
- /*
- * NCA is only interested in default routes associated
- * with an interface.
- */
- if (!(rp->ipRouteInfo.re_ire_type & IRE_DEFAULT)) {
- continue;
- }
- /* Get the nexthop address. */
- nexthop_v4.s_addr = rp->ipRouteNextHop;
-
- /*
- * Right now, not all IREs have the interface name
- * it is associated with.
- */
- if (rp->ipRouteIfIndex.o_length == 0) {
- /*
- * We don't have the outgoing interface in
- * this case. Get the nexthop address. Then
- * determine the outgoing interface, by
- * examining all interface IREs, and
- * picking the match.
- */
- for (rp1 = buf; rp1 < endp; rp1++) {
-
- if (!(rp1->ipRouteInfo.re_ire_type &
- IRE_INTERFACE)) {
- continue;
- }
-
- /*
- * Determine the interface IRE that
- * matches the nexthop. i.e.
- * (IRE addr & IRE mask) ==
- * (nexthop & IRE mask)
- */
- if ((rp1->ipRouteDest & rp1->ipRouteMask) ==
- (nexthop_v4.s_addr & rp1->ipRouteMask)) {
- /*
- * We found the interface to go to
- * the default router. Check the
- * interface name.
- */
- /* Can this be possible?? */
- if (rp1->ipRouteIfIndex.o_length == 0)
- continue;
- rp2 = rp1;
- break;
- }
-
- } /* End inner for loop. */
- } else {
- rp2 = rp;
- }
-
- ifname_len = MIN(rp2->ipRouteIfIndex.o_length,
- sizeof (ifname) - 1);
- (void) memcpy(ifname, rp2->ipRouteIfIndex.o_bytes,
- ifname_len);
- ifname[ifname_len] = '\0';
- if (ifname[0] == '\0')
- continue;
- cp = strchr(ifname, IF_SEPARATOR);
- if (cp != NULL)
- *cp = '\0';
-
- /* We are sure both are NULL terminated. */
- if (strcmp(nif_list[i].name, ifname) == 0) {
- /* No change, do not do anything. */
- if (nexthop_v4.s_addr ==
- nif_list[i].router_addr.s_addr) {
- found = B_TRUE;
- break;
- }
- nif_list[i].router_addr.s_addr =
- nexthop_v4.s_addr;
- if (debug) {
- logdebug("Get default"
- " router for %s: %s\n", ifname,
- inet_ntoa(nexthop_v4));
- }
- found = B_TRUE;
- *changed = B_TRUE;
- break;
- }
-
- }
- if (!found) {
- /*
- * The interface does not have a default router.
- * Log a warning and go on.
- */
- logwarn(gettext("Network interface %s"
- " does not have a default router.\n"),
- nif_list[i].name);
- /*
- * Set router_addr to 0 so that we will
- * not do anything for this interface.
- */
- nif_list[i].router_addr.s_addr = 0;
- } else {
- num_found++;
- }
- }
- return (num_found);
-}
-
-/*
- * Examine the ARP table to find ethernet address for default routers.
- *
- * Param:
- * mib2_ipNetToMdeiaEntry_t *buf: the mib info buffer.
- * size_t len: length of buffer.
- * boolean_t *changed (referenced): set to B_TRUE if there is any change
- * in ethernet address for any default router.
- *
- * Return:
- * number of ethernet address found.
- */
-static int
-arp_process(mib2_ipNetToMediaEntry_t *buf, size_t len, boolean_t *changed)
-{
- mib2_ipNetToMediaEntry_t *rp;
- mib2_ipNetToMediaEntry_t *endp;
- int i;
- boolean_t found;
- int num_found = 0;
- uchar_t *src, *dst;
-
- if (len == 0)
- return (0);
- endp = buf + (len / sizeof (mib2_ipNetToMediaEntry_t));
-
- for (i = 0; i < num_nif; i++) {
- /*
- * Loop thru the arp table entries and find the ethernet
- * address of those default routers.
- */
- if (nif_list[i].router_addr.s_addr == 0)
- continue;
- found = B_FALSE;
- for (rp = buf; rp < endp; rp++) {
- if (rp->ipNetToMediaNetAddress ==
- nif_list[i].router_addr.s_addr) {
- /*
- * Sanity check. Make sure that this
- * default router is only reachable thru this
- * interface.
- */
- if (rp->ipNetToMediaIfIndex.o_length !=
- strlen(nif_list[i].name) ||
- strncmp(rp->ipNetToMediaIfIndex.o_bytes,
- nif_list[i].name,
- rp->ipNetToMediaIfIndex.o_length) !=
- 0) {
- break;
- }
- /* No change, do not do anything. */
- if (bcmp(nif_list[i].router_ether_addr,
- rp->ipNetToMediaPhysAddress.o_bytes,
- ETHERADDRL) == 0) {
- found = B_TRUE;
- continue;
- }
- dst = nif_list[i].router_ether_addr;
- src = (uchar_t *)
- rp->ipNetToMediaPhysAddress.o_bytes;
- for (len = ETHERADDRL; len > 0; len--)
- *dst++ = *src++;
- if (debug) {
- int j;
- uchar_t *cp;
- char err_buf[128];
-
- (void) snprintf(err_buf,
- sizeof (err_buf),
- "Get address for %s: ",
- inet_ntoa(nif_list[i].router_addr));
- cp = (uchar_t *)
- nif_list[i].router_ether_addr;
- for (j = 0; j < ETHERADDRL; j++) {
- (void) sprintf(err_buf +
- strlen(err_buf),
- "%02x:", 0xff & cp[j]);
- }
- (void) sprintf(err_buf +
- strlen(err_buf) - 1, "\n");
- logdebug(err_buf);
- }
- found = B_TRUE;
- *changed = B_TRUE;
- }
- }
- if (!found) {
- logwarn("Cannot reach %s using %s\n",
- inet_ntoa(nif_list[i].router_addr),
- nif_list[i].name);
- /* Clear this default router. */
- nif_list[i].router_addr.s_addr = 0;
- } else {
- num_found++;
- }
- }
- return (num_found);
-}
-
-/*
- * Get IP address of default routers for each interface.
- *
- * Param:
- * mib_item_t *item: the mib info buffer.
- * boolean_t *changed (referenced): set to B_TRUE if there is any change
- * in router info.
- *
- * Return:
- * -1 if there is no router found, 0 otherwise.
- */
-static int
-get_router_ip_addr(mib_item_t *item, boolean_t *changed)
-{
- int found = 0;
-
- for (; item != NULL; item = item->next_item) {
- /* NCA does not support IPv6... */
- if (!(item->group == MIB2_IP && item->mib_id == MIB2_IP_ROUTE))
- continue;
- /* LINTED */
- found += ire_process((mib2_ipRouteEntry_t *)item->valp,
- item->length, changed);
- }
- if (found == 0)
- return (-1);
- else
- return (0);
-}
-
-/*
- * Get Ethernet address for each default router from ARP.
- *
- * Param:
- * mib_item_t *item: the mib info buffer.
- * boolean_t *changed (referenced): set to B_TRUE if there is any change
- * in ethernet address of router.
- *
- * Return:
- * -1 if there is no ethernet address found, 0 otherwise.
- */
-static int
-get_router_ether_addr(mib_item_t *item, boolean_t *changed)
-{
- int found = 0;
-
- for (; item != NULL; item = item->next_item) {
- /* NCA does not support IPv6... */
- if (!(item->group == MIB2_IP && item->mib_id == MIB2_IP_MEDIA))
- continue;
- /* LINTED */
- found += arp_process((mib2_ipNetToMediaEntry_t *)item->valp,
- item->length, changed);
- }
- if (found == 0)
- return (-1);
- else
- return (0);
-}
-
-/*
- * Ping all default routers. It just uses system(3F) to call
- * ping(8) to do the job...
- */
-static void
-ping_them(void)
-{
- int i;
- char ping_cmd[128];
-
- for (i = 0; i < num_nif; i++) {
- if (nif_list[i].router_addr.s_addr != 0) {
- (void) snprintf(ping_cmd, sizeof (ping_cmd),
- "%s %s > /dev/null 2>&1",
- ping_prog,
- inet_ntoa(nif_list[i].router_addr));
- (void) system(ping_cmd);
- }
- }
-}
-
-/*
- * To get default router info (both IP address and ethernet address) for
- * each configured interface from IP.
- *
- * Param:
- * boolean_t *changed (referenced): set to B_TRUE if there is any change
- * of info.
- *
- * Return:
- * -1 if there is any error, 0 if everything is fine.
- */
-static int
-get_if_info(boolean_t *changed)
-{
- int mib_fd;
- mib_item_t *item;
- boolean_t ip_changed = B_FALSE;
- boolean_t ether_changed = B_FALSE;
-
- if ((mib_fd = open(IP_DEV_NAME, O_RDWR)) < 0) {
- logperror("cannot open ip to get router info");
- return (-1);
- }
- if (ioctl(mib_fd, I_PUSH, ARP_MOD_NAME) == -1) {
- logperror("cannot push arp");
- goto err;
- }
-
- if ((item = mibget(mib_fd)) == NULL) {
- goto err;
- }
-
- if (get_router_ip_addr(item, &ip_changed) < 0) {
- goto err;
- }
- /*
- * Ping every routers to make sure that ARP has all their ethernet
- * addresses.
- */
- ping_them();
- /*
- * If the router IP address is not changed, its ethernet address
- * should not be changed. But just in case there is some IP
- * failover going on...
- */
- if (get_router_ether_addr(item, &ether_changed) < 0) {
- goto err;
- }
- (void) close(mib_fd);
- *changed = ip_changed || ether_changed;
- return (0);
-err:
- (void) close(mib_fd);
- return (-1);
-}
-
-/*
- * To remove the default router from an interface.
- *
- * Param:
- * struct in_addr gw_addr: the IP address of the default router to be
- * removed.
- */
-static void
-nca_del_nif(struct in_addr gw_addr)
-{
- struct nca_set_ioctl nca_ioctl;
- struct strioctl strioc;
- int i;
- int udp_fd, fd;
-
- /* Search for the interface for this router. */
- for (i = 0; i < num_nif; i++) {
- if (nif_list[i].router_addr.s_addr == gw_addr.s_addr)
- break;
- }
- if (i == num_nif)
- return;
-
- if (ip_domux2fd(&udp_fd, &fd) < 0) {
- logwarn(gettext("Removing interface %s from the"
- " configuration list.\n"), nif_list[i].name);
- nif_list[i].name[0] = 0;
- return;
- }
- if (ioctl(udp_fd, I_PUNLINK, lifr.lifr_ip_muxid) < 0) {
- logwarn(gettext("Removing interface %s from the"
- " configuration list.\n"), nif_list[i].name);
- nif_list[i].name[0] = 0;
- (void) close(udp_fd);
- (void) close(fd);
- return;
- }
-
- strioc.ic_cmd = NCA_SET_IF;
- strioc.ic_timout = INFTIM;
- strioc.ic_len = sizeof (nca_ioctl);
- strioc.ic_dp = (char *)&nca_ioctl;
-
- nca_ioctl.local_addr = 0;
- (void) memset(nca_ioctl.router_ether_addr, 0, ETHERADDRL);
- nca_ioctl.action = DEL_DEF_ROUTE;
-
- if (ioctl(fd, I_STR, &strioc) < 0) {
- logperror("ioctl(NCA_SET_IF) failed");
- }
- ip_plink(udp_fd, fd);
- (void) close(udp_fd);
- (void) close(fd);
-
- /* Clear the fields for this interface. */
- nif_list[i].router_addr.s_addr = 0;
- (void) memset(nif_list[i].router_ether_addr, 0, ETHERADDRL);
-}
-
-/*
- * Wait for any changes in the routing table. If there are changes to
- * IP address or router ethernet address, send down the info to NCA.
- */
-static void
-daemon_work(void)
-{
- int n;
- int i;
- int udp_fd;
- int fd;
- int64_t msg[2048/8];
- struct rt_msghdr *rtm;
- boolean_t changed;
- struct sockaddr_in *sin;
- struct in_addr gw_addr;
- uchar_t *cp;
-
- /* Loop forever waiting for any routing changes. */
- for (;;) {
- if (debug) {
- logdebug("Waiting to read routing info...\n");
- }
- n = read(rt_fd, msg, sizeof (msg));
- /* Don't die... Reinitialize socket and listen again. */
- if (n <= 0) {
- if (debug) {
- logdebug("Routing socket read error.\n");
- }
- (void) close(rt_fd);
- rt_fd = socket(PF_ROUTE, SOCK_RAW, AF_INET);
- i = 0;
- while (rt_fd < 0) {
- if (i++ == 0) {
- logperror(gettext("cannot reinitialize"
- " routing socket"));
- } else if (i > 5) {
- logwarn(gettext("Give up on trying to"
- " reinitializing routing"
- " socket\n"));
- exit(1);
- }
- /* May be a transient error... */
- (void) sleep(10);
- rt_fd = socket(PF_ROUTE, SOCK_RAW, AF_INET);
- }
- } else {
- rtm = (struct rt_msghdr *)msg;
- if (rtm->rtm_version != RTM_VERSION) {
- logwarn(gettext("Do non understand routing"
- " socket info.\n"));
- continue;
- }
- if (debug) {
- logdebug("Get routing info.\n");
- }
- switch (rtm->rtm_type) {
- case RTM_DELETE:
- case RTM_OLDDEL:
- sin = (struct sockaddr_in *)(rtm + 1);
- cp = (uchar_t *)sin;
- /* Only handle default route deletion. */
- if ((rtm->rtm_addrs & RTA_DST) &&
- (sin->sin_addr.s_addr == 0)) {
- if (!(rtm->rtm_addrs & RTA_GATEWAY)) {
- break;
- }
- cp += sizeof (struct sockaddr_in);
- /* LINTED */
- sin = (struct sockaddr_in *)cp;
- gw_addr = sin->sin_addr;
- if (debug) {
- logdebug("Get default route "
- "removal notice: gw %s\n",
- inet_ntoa(gw_addr));
- }
- nca_del_nif(gw_addr);
- }
- break;
- case RTM_ADD:
- case RTM_OLDADD:
- case RTM_CHANGE:
- changed = B_FALSE;
- if (get_if_info(&changed) < 0) {
- /* May be a transient error... */
- (void) sleep(10);
- break;
- }
- /* Nothing is changed, do nothing. */
- if (!changed) {
- if (debug) {
- logdebug("Get route change "
- "notice, but nothing is "
- "changed for us!");
- }
- break;
- }
- lifr.lifr_addr.ss_family = AF_INET;
- for (i = 0; i < num_nif; i++) {
- int ret;
-
- /*
- * If name is NULL, it means that
- * we have encontered some problems
- * when configurating the interface.
- * So we remove it from the list.
- */
- if (nif_list[i].name[0] == 0 ||
- nif_list[i].local_addr.s_addr == 0)
- continue;
- (void) strlcpy(lifr.lifr_name,
- nif_list[i].name,
- sizeof (lifr.lifr_name));
- if (ip_domux2fd(&udp_fd, &fd) < 0) {
- logwarn(gettext("Removing"
- " interface %s from the"
- " configuration list.\n"),
- nif_list[i].name);
- nif_list[i].name[0] = 0;
- continue;
- }
- if (ioctl(udp_fd, I_PUNLINK,
- lifr.lifr_ip_muxid) < 0) {
- logwarn(gettext("Removing"
- " interface %s from the"
- " configuration list.\n"),
- nif_list[i].name);
- nif_list[i].name[0] = 0;
- (void) close(udp_fd);
- (void) close(fd);
- continue;
- }
- if (debug) {
- logdebug("Configuring"
- " %s\n", nif_list[i].name);
- }
- ret = nca_set_nif(fd,
- nif_list[i].local_addr,
- nif_list[i].router_ether_addr);
- ip_plink(udp_fd, fd);
- if (ret < 0) {
- /*
- * This should not be possible
- * since if NCA does not
- * support the ioctl, the
- * active flag should be
- * cleared already and this
- * function should not have
- * been called at all!
- */
- logwarn("Daemon dies\n");
- exit(1);
- }
- (void) close(udp_fd);
- (void) close(fd);
- }
- break;
- default:
- continue;
- }
- }
- }
-}
-
-/*
- * Make us a daemon.
- */
-static void
-daemon_init(void)
-{
- pid_t pid;
-
- if ((pid = fork()) == -1) {
- /* Write directly to terminal, instead of syslog. */
- (void) fprintf(stderr, gettext("ncaconfd: cannot fork: %s\n"),
- strerror(errno));
- exit(1);
- }
- if (pid != 0)
- exit(0);
- (void) setsid();
- /* Fork again so that we will never get a controlling terminal. */
- if ((pid = fork()) == -1) {
- /* Write directly to terminal, instead of syslog. */
- (void) fprintf(stderr, gettext("ncaconfd: cannot fork: %s\n"),
- strerror(errno));
- exit(1);
- }
- if (pid != 0)
- exit(0);
- (void) chdir("/");
- (void) umask(0);
- (void) fclose(stdin);
- (void) fclose(stdout);
- (void) fclose(stderr);
-}
-
-int
-main(int argc, char **argv)
-{
- int i, j;
- int c;
- boolean_t active = B_FALSE;
- boolean_t as_daemon = B_TRUE;
-
- if (argc == 1) {
- (void) fprintf(stderr, gettext("Usage: %s [-al]"
- " [interface1 interface2 ...]\n"), argv[0]);
- return (1);
- }
-
- (void) setlocale(LC_ALL, "");
-#if !defined(TEXT_DOMAIN)
-#define TEXT_DOMAIN "SYS_TEST"
-#endif
- (void) textdomain(TEXT_DOMAIN);
-
- while ((c = getopt(argc, argv, "adcl")) != EOF) {
- switch (c) {
- case 'a':
- active = B_TRUE;
- break;
- case 'd':
- debug = B_TRUE;
- break;
- case 'c':
- /* Don't run as daemon. */
- as_daemon = B_FALSE;
- break;
- case 'l':
- logging = B_TRUE;
- break;
- default:
- /* -d and -c are "undocumented" options. */
- (void) fprintf(stderr, gettext("Usage: %s [-al]"
- " [interface1 interface2 ...]\n"), argv[0]);
- return (1);
- }
- }
- num_nif = argc - optind;
- if (num_nif == 0) {
- /* No network interface to proces... */
- (void) fprintf(stderr, gettext("Usage: %s [-al]"
- " [interface1 interface2 ...]\n"), argv[0]);
- return (0);
- }
- nif_list = calloc(num_nif, sizeof (nif_t));
- if (nif_list == NULL) {
- (void) fprintf(stderr, gettext("ncaconfd: Cannot malloc: %s\n"),
- strerror(errno));
- return (1);
- }
- for (i = 0, j = optind; i < num_nif; i++, j++) {
- (void) strlcpy(nif_list[i].name, argv[j], LIFNAMSIZ+1);
- }
-
- /* Get IP address info for all the intefaces. */
- if (get_if_ip_addr() < 0) {
- if (debug) {
- (void) fprintf(stderr, "ncaconfd: Cannot get IP"
- " addresses for interfaces.\n");
- }
- return (1);
- }
- if (logging)
- openlog("ncaconfd", LOG_PID, LOG_DAEMON);
- /* No need to run as daemon if NCA is not making active connections. */
- if (active && as_daemon)
- daemon_init();
- if (active) {
- boolean_t changed;
-
- /* NCA does not support IPv6... */
- if ((rt_fd = socket(PF_ROUTE, SOCK_RAW, AF_INET)) < 0) {
- logperror("Cannot open routing socket");
- return (1);
- }
- /*
- * At boot up time, the default router may not have been
- * found. So ignore the error and check later.
- */
- if (get_if_info(&changed) < 0) {
- if (debug) {
- (void) logwarn("Cannot get"
- " information from network interface.\n");
- }
- }
- }
- /* Do the set up as daemon (if we are) to save time at boot up... */
- nca_setup(&active);
- if (active)
- daemon_work();
- return (0);
-}
diff --git a/usr/src/cmd/devfsadm/misc_link.c b/usr/src/cmd/devfsadm/misc_link.c
index 33c57f573a..9172238f7e 100644
--- a/usr/src/cmd/devfsadm/misc_link.c
+++ b/usr/src/cmd/devfsadm/misc_link.c
@@ -112,7 +112,7 @@ static devfsadm_create_t misc_cbt[] = {
"(^ip$)|(^tcp$)|(^udp$)|(^icmp$)|"
"(^ip6$)|(^tcp6$)|(^udp6$)|(^icmp6$)|"
"(^rts$)|(^arp$)|(^ipsecah$)|(^ipsecesp$)|(^keysock$)|(^spdsock$)|"
- "(^nca$)|(^rds$)|(^sdp$)|(^ipnet$)|(^dlpistub$)|(^bpf$)",
+ "(^rds$)|(^sdp$)|(^ipnet$)|(^dlpistub$)|(^bpf$)",
TYPE_EXACT | DRV_RE, ILEVEL_1, minor_name
},
{ "pseudo", "ddi_pseudo", "ipd",
diff --git a/usr/src/cmd/mdb/Makefile.common b/usr/src/cmd/mdb/Makefile.common
index 5616038726..77a103c554 100644
--- a/usr/src/cmd/mdb/Makefile.common
+++ b/usr/src/cmd/mdb/Makefile.common
@@ -23,6 +23,7 @@
# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2016 Joyent, Inc.
# Copyright 2018 Nexenta Systems, Inc.
+# Copyright 2022 Garrett D'Amore
#
#
@@ -83,7 +84,6 @@ COMMON_MODULES_KVM = \
mm \
mpt_sas \
mr_sas \
- nca \
nsmb \
pmcs \
ptm \
diff --git a/usr/src/cmd/mdb/common/modules/nca/nca.c b/usr/src/cmd/mdb/common/modules/nca/nca.c
deleted file mode 100644
index e10a42e0aa..0000000000
--- a/usr/src/cmd/mdb/common/modules/nca/nca.c
+++ /dev/null
@@ -1,1237 +0,0 @@
-/*
- * 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 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * NCA mdb module. Provides a collection of dcmds and walkers that
- * operate on core NCA data structures. Dependencies on NCA internals
- * are described in $SRC/uts/common/inet/nca/nca.h.
- */
-
-#include <mdb/mdb_modapi.h>
-#include <mdb/mdb_ks.h>
-
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/sunddi.h>
-#include <sys/processor.h>
-#include <netinet/in.h>
-#include <netinet/ip6.h> /* must come before common.h */
-#include <inet/common.h> /* must come before led.h */
-#include <inet/led.h> /* must come before ip.h */
-#include <inet/ip.h> /* must come before tcp.h */
-#include <inet/tcp.h> /* must come before nca/nca.h */
-#include <inet/nca/nca.h>
-#include <inet/nca/ncadoorhdr.h>
-
-#define NCA_WALK_PLRU (void *)1
-#define NCA_WALK_VLRU (void *)2
-#define NCA_ADDR_WIDTH 11 /* kernel addresses *shouldn't* be wider */
-#define YESNO(bool) ((bool) ? 'Y' : 'n')
-
-/*
- * Structure for assigning a name to a region of memory.
- */
-typedef struct {
- const char *nm_name; /* name of region */
- int nm_len; /* length to region */
- uintptr_t nm_addr; /* starting address of region */
-} namedmem_t;
-
-/*
- * Structure for giving a name to a constant.
- */
-typedef struct {
- const char *const_name; /* name of constant */
- int const_value; /* constant itself */
-} constname_t;
-
-/*
- * Structure for mapping a bit to a name and a description. Instances
- * of this datatype should always be arrays which decode bits in a
- * number, and the index into the array should contain the description
- * of a bit at position "index" in the number being decoded. The list
- * must be terminated by an entry with a NULL `bit_name'.
- */
-typedef struct {
- const char *bit_name; /* name of bit */
- const char *bit_descr; /* description of bit's purpose */
-} bitname_t;
-
-/*
- * Note: These should be defined in upside down order to their
- * definitions in nca.h
- * (Assumes that current ordering convention in nca.h will
- * prevail for future additions)
- */
-static const bitname_t node_refs[] = {
- { "REF_UNUSED", "0x00000001" },
- { "REF_UNUSED", "0x00000002" },
- { "REF_UNUSED", "0x00000004" },
- { "REF_UNUSED", "0x00000008" },
- { "REF_UNUSED", "0x00000010" },
- { "REF_UNUSED", "0x00000020" },
- { "REF_UNUSED", "0x00000040" },
- { "REF_UNUSED", "0x00000080" },
- { "REF_UNUSED", "0x00000100" },
- { "REF_UNUSED", "0x00000200" },
- { "REF_UNUSED", "0x00000400" },
- { "REF_SEGMAP", "segmapped (PHYS|VIRT)" },
- { "REF_NCAFS", "NCAfs required" },
- { "REF_VNODE", "vnode hashed" },
- { "REF_ERROR", "errored" },
- { "REF_OWNED", "owned (won't be freed)" },
- { "REF_UPCALL", "upcall not completed yet" },
- { "REF_CTAG", "CTAG hashed" },
- { "REF_PREEMPT", "processing preempted" },
- { "REF_ONVLRU", "on virtual memory LRU list" },
- { "REF_ONPLRU", "on physical memory LRU list" },
- { "REF_MISS", "in miss processing" },
- { "REF_NOLRU", "not safe for LRU reclaim" },
- { "REF_RESP", "done parsing response header" },
- { "REF_FILE", "reachable through filename hash" },
- { "REF_SAFED", "not safe for use" },
- { "REF_DONE", "done with miss processing" },
- { "REF_KMEM", "content-backed via kmem_alloc()" },
- { "REF_CKSUM", "checksum mapping in-use" },
- { "REF_VIRT", "virtually mapped (data valid)" },
- { "REF_PHYS", "physically mapped (pp valid)" },
- { "REF_URI", "reachable through URI hash" },
- { NULL }
-};
-
-static const bitname_t advise_types[] = {
- { "ADVISE", "" },
- { "ADVISE_REPLACE", "replace cached object with provided object" },
- { "ADVISE_FLUSH", "flush cached object" },
- { "ADVISE_TEMP", "return this object; keep cached object" },
- { NULL }
-};
-
-/*
- * Print `len' bytes of buffer `buf'. Handle nonprintable characters
- * specially.
- */
-static void
-printbuf(uint8_t *buf, size_t len)
-{
- size_t i;
-
- /*
- * TODO: display octal form of unprintable characters in dim mode
- * once mdb pager bug is fixed.
- */
- for (i = 0; i < len; i++)
- mdb_printf(isgraph(buf[i]) ? "%c" : "\\%#o", buf[i]);
-
- mdb_printf("\n");
-}
-
-/*
- * Convert HTTP method operation `method' to a name.
- */
-static const char *
-method2name(unsigned int method)
-{
- unsigned int i;
- static constname_t http_methods[] = {
- { "NCA_UNKNOWN", NCA_UNKNOWN },
- { "NCA_OPTIONS", NCA_OPTIONS },
- { "NCA_GET", NCA_GET },
- { "NCA_HEAD", NCA_HEAD },
- { "NCA_POST", NCA_POST },
- { "NCA_PUT", NCA_PUT },
- { "NCA_DELETE", NCA_DELETE },
- { "NCA_TRACE", NCA_TRACE },
- { "NCA_RAW", NCA_RAW },
- { NULL }
- };
-
- for (i = 0; http_methods[i].const_name != NULL; i++) {
- if (method == http_methods[i].const_value)
- return (http_methods[i].const_name);
- }
-
- return ("<unknown>");
-}
-
-/*
- * Convert TCP state `state' to a name.
- */
-static const char *
-state2name(int state)
-{
- unsigned int i;
- static constname_t tcp_states[] = {
- { "CLOSED", TCPS_CLOSED },
- { "IDLE", TCPS_IDLE },
- { "BOUND", TCPS_BOUND },
- { "LISTEN", TCPS_LISTEN },
- { "SYN_SENT", TCPS_SYN_SENT },
- { "SYN_RCVD", TCPS_SYN_RCVD },
- { "ESTABLISHED", TCPS_ESTABLISHED },
- { "CLOSE_WAIT", TCPS_CLOSE_WAIT },
- { "FIN_WAIT1", TCPS_FIN_WAIT_1 },
- { "FIN_WAIT2", TCPS_FIN_WAIT_2 },
- { "CLOSING", TCPS_CLOSING },
- { "LAST_ACK", TCPS_LAST_ACK },
- { "TIME_WAIT", TCPS_TIME_WAIT },
- { NULL }
- };
-
- for (i = 0; tcp_states[i].const_name != NULL; i++) {
- if (state == tcp_states[i].const_value)
- return (tcp_states[i].const_name);
- }
-
- return ("<unknown>");
-}
-
-/*
- * Convert an nca_io2_t direct_type into a name.
- */
-static const char *
-direct2name(unsigned int type)
-{
- unsigned int i;
- static const constname_t direct_types[] = {
- { "DIRECT_NONE", NCA_IO_DIRECT_NONE },
- { "DIRECT_FILENAME", NCA_IO_DIRECT_FILENAME },
- { "DIRECT_SHMSEG", NCA_IO_DIRECT_SHMSEG },
- { "DIRECT_FILEDESC", NCA_IO_DIRECT_FILEDESC },
- { "DIRECT_CTAG", NCA_IO_DIRECT_CTAG },
- { "DIRECT_SPLICE", NCA_IO_DIRECT_SPLICE },
- { "DIRECT_TEE", NCA_IO_DIRECT_TEE },
- { "DIRECT_FILE_FD", NCA_IO_DIRECT_FILE_FD },
- { NULL, 0 }
- };
-
- for (i = 0; direct_types[i].const_name != NULL; i++) {
- if (type == direct_types[i].const_value)
- return (direct_types[i].const_name);
- }
-
- return ("<unknown>");
-}
-
-/*
- * Convert an nca_io2_t operation into a name.
- */
-static const char *
-op2name(nca_op_t op)
-{
- unsigned int i;
- static const constname_t op_types[] = {
- { "http", http_op },
- { "error", error_op },
- { "error_retry", error_retry_op },
- { "resource", resource_op },
- { "timeout", timeout_op },
- { "door_attach", door_attach_op },
-
- { "log", log_op },
- { "log_ok", log_ok_op },
- { "log_error", log_error_op },
- { "log_op_fiov", log_op_fiov },
-
- { NULL, 0 }
- };
-
- for (i = 0; op_types[i].const_name != NULL; i++) {
- if (op == op_types[i].const_value)
- return (op_types[i].const_name);
- }
-
- return ("<unknown>");
-}
-
-/*
- * Convert from ticks to milliseconds.
- */
-static uint64_t
-tick2msec(uint64_t tick)
-{
- static int tick_per_msec;
- static int msec_per_tick;
- static int once;
-
- if (once == 0) {
- if (mdb_readvar(&tick_per_msec, "tick_per_msec") == -1) {
- mdb_warn("cannot read symbol tick_per_msec");
- return (0);
- }
- if (mdb_readvar(&msec_per_tick, "msec_per_tick") == -1) {
- mdb_warn("cannot read symbol msec_per_tick");
- return (0);
- }
- once++;
- }
-
- return (tick_per_msec ? tick / tick_per_msec : tick * msec_per_tick);
-}
-
-/*
- * Print the core fields in an nca_io2_t. With the "-v" argument,
- * provide more verbose output. With the "-p" argument, print payload
- * information.
- */
-static int
-nca_io2(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
-{
- unsigned int i;
- unsigned int payload_len;
- uint64_t payload_output_max = 0;
- unsigned int verbose = FALSE;
- const int IO2_ADVDELT = NCA_ADDR_WIDTH + 1;
- boolean_t arm;
- nca_io2_t io2;
- uint8_t *buf;
- namedmem_t area[3];
-
- if (!(flags & DCMD_ADDRSPEC))
- return (DCMD_USAGE);
-
- if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose,
- 'p', MDB_OPT_UINT64, &payload_output_max, NULL) != argc)
- return (DCMD_USAGE);
-
- if (!DCMD_HDRSPEC(flags) && verbose)
- mdb_printf("\n\n");
-
- if (DCMD_HDRSPEC(flags) || verbose) {
- mdb_printf("%<u>%-*s %2s %4s %8s %*s %8s %16s %-12s%</u>\n",
- NCA_ADDR_WIDTH, "ADDR", "AV", "MFNP", "TID",
- NCA_ADDR_WIDTH, "CONN", "CONN_TAG", "CACHE_TAG",
- "OPERATION");
- }
-
- if (mdb_vread(&io2, sizeof (nca_io2_t), addr) == -1) {
- mdb_warn("cannot read nca_io2_t at %p", addr);
- return (DCMD_ERR);
- }
-
- if (io2.version != NCA_HTTP_VERSION2)
- mdb_warn("nca_io2_t at %p has incorrect version `%u'\n", addr,
- io2.version);
-
- mdb_printf("%0*p %02x %c%c%c%c %08x %0*llx %08x %016llx %s\n",
- NCA_ADDR_WIDTH, addr, io2.advisory, YESNO(io2.more),
- YESNO(io2.first), YESNO(io2.nocache), YESNO(io2.preempt),
- (uint32_t)io2.tid, NCA_ADDR_WIDTH, io2.cid, io2.tag, io2.ctag,
- op2name(io2.op));
-
- if (verbose) {
- arm = B_TRUE;
- for (i = 0; advise_types[i].bit_name != NULL; i++) {
- if ((io2.advisory & (1 << i)) == 0)
- continue;
-
- if (arm) {
- mdb_printf("%*s|\n", IO2_ADVDELT, "");
- mdb_printf("%*s+--> ", IO2_ADVDELT, "");
- arm = B_FALSE;
- } else
- mdb_printf("%*s ", IO2_ADVDELT, "");
-
- mdb_printf("%-15s %s\n", advise_types[i].bit_name,
- advise_types[i].bit_descr);
- }
- }
-
- payload_len = io2.data_len + io2.direct_len + io2.trailer_len;
-
- if (payload_output_max == 0 || payload_len == 0)
- return (DCMD_OK);
-
- mdb_inc_indent(4);
- mdb_printf("\n%u byte payload consists of:\n", payload_len);
- mdb_inc_indent(4);
-
- buf = mdb_alloc(payload_output_max, UM_SLEEP);
-
- area[0].nm_name = "data";
- area[0].nm_addr = addr + io2.data;
- area[0].nm_len = io2.data_len;
-
- area[1].nm_name = direct2name(io2.direct_type);
- area[1].nm_addr = addr + io2.direct;
- area[1].nm_len = io2.direct_len;
-
- area[2].nm_name = "trailer";
- area[2].nm_addr = addr + io2.trailer;
- area[2].nm_len = io2.trailer_len;
-
- for (i = 0; i < sizeof (area) / sizeof (area[0]); i++) {
- if (area[i].nm_len <= 0)
- continue;
-
- mdb_printf("%d byte %s area at %p (", area[i].nm_len,
- area[i].nm_name, area[i].nm_addr);
-
- if (area[i].nm_len > payload_output_max) {
- mdb_printf("first");
- area[i].nm_len = (int)payload_output_max;
- } else
- mdb_printf("all");
-
- mdb_printf(" %u bytes follow):\n", area[i].nm_len);
- if (mdb_vread(buf, area[i].nm_len, area[i].nm_addr) == -1)
- mdb_warn("cannot read %s area at %p", area[i].nm_name,
- area[i].nm_addr);
- else {
- mdb_inc_indent(4);
- printbuf(buf, area[i].nm_len);
- mdb_dec_indent(4);
- }
- }
- mdb_dec_indent(4);
- mdb_dec_indent(4);
-
- mdb_free(buf, payload_output_max);
-
- return (DCMD_OK);
-}
-
-static void
-nca_io2_help(void)
-{
- mdb_printf("Print the core information for a given NCA nca_io2_t.\n");
- mdb_printf("Options:\n");
- mdb_printf("\t-p N\tshow up to N bytes of payload information from\n");
- mdb_printf("\t\teach payload area\n");
- mdb_printf("\t\t(reminder: default radix is %<b>hex%</b>)\n");
- mdb_printf("\t-v\tbe verbose (more descriptive)\n");
-}
-
-/*
- * Print the core fields for one or all NCA timers. If no address is
- * specified, all NCA timers are printed; otherwise the specified timer
- * list is printed. With the "-e" argument, the "encapsulated" pointer
- * for each te_t in a given tb_t is shown in parentheses.
- */
-static int
-nca_timer(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
-{
- unsigned int show_encap = FALSE;
- void *tb_addr, *te_addr;
- clock_t lbolt, first_exec = 0;
- ti_t ti;
- tb_t tb;
- te_t te;
-
- if (!(flags & DCMD_ADDRSPEC)) {
- if (mdb_walk_dcmd("nca_timer", "nca_timer", argc, argv) == -1) {
- mdb_warn("cannot walk timer list");
- return (DCMD_ERR);
- }
- return (DCMD_OK);
- }
-
- if (mdb_getopts(argc, argv, 'e', MDB_OPT_SETBITS, TRUE, &show_encap,
- NULL) != argc)
- return (DCMD_USAGE);
-
- if (DCMD_HDRSPEC(flags)) {
- mdb_printf("%<u>%-*s %-*s %-55s%</u>\n", NCA_ADDR_WIDTH, "TI",
- NCA_ADDR_WIDTH, "SQUEUE", "FIRELIST +MSEC");
- }
-
- if (mdb_vread(&ti, sizeof (ti_t), addr) == -1) {
- mdb_warn("cannot read ti_t at %p", addr);
- return (DCMD_ERR);
- }
-
- if ((lbolt = (clock_t)mdb_get_lbolt()) == -1)
- return (DCMD_ERR);
-
- mdb_printf("%0*p %0*p", NCA_ADDR_WIDTH, addr, NCA_ADDR_WIDTH, ti.ep);
- mdb_inc_indent(24);
- for (tb_addr = ti.head; tb_addr != NULL; tb_addr = tb.next) {
- if (mdb_vread(&tb, sizeof (tb_t), (uintptr_t)tb_addr) == -1) {
- mdb_warn("cannot read tb_t at %p", tb_addr);
- return (DCMD_ERR);
- }
- if (first_exec == 0) {
- mdb_printf(" %ld", tick2msec(tb.exec - lbolt));
- first_exec = tb.exec;
- } else
- mdb_printf(" %+lld", tick2msec(tb.exec - first_exec));
-
- if (!show_encap || tb.head == NULL)
- continue;
-
- mdb_printf("(");
- for (te_addr = tb.head; te_addr != NULL; te_addr = te.next) {
- if (mdb_vread(&te, sizeof (te_t), (uintptr_t)te_addr)
- == -1) {
- mdb_warn("cannot read te_t at %p", te_addr);
- return (DCMD_ERR);
- }
- mdb_printf("%0p%s", te.ep, te.next == NULL ? "" : " ");
- }
- mdb_printf(")");
- }
- mdb_printf("\n");
- mdb_dec_indent(24);
-
- return (DCMD_OK);
-}
-
-static void
-nca_timer_help(void)
-{
- mdb_printf("Print the core information for one or all NCA timer\n");
- mdb_printf("lists. If no timer list is given, then all timer lists\n");
- mdb_printf("are shown. For each timer list, the list of timers to\n");
- mdb_printf("fire on that list are shown, the first in absolute\n");
- mdb_printf("ticks and the rest in ticks relative to the first.\n\n");
- mdb_printf("Options:\n");
- mdb_printf("\t-e\tshow the encapsulating pointer for each event ");
- mdb_printf("at each fire time\n");
-}
-
-/*
- * Print the core fields in an NCA node_t. With the "-r" argument,
- * provide additional information about the request; with "-v",
- * provide more verbose output.
- */
-static int
-nca_node(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
-{
- unsigned int i, max;
- unsigned int verbose = FALSE;
- unsigned int request = FALSE;
- const int NODE_REFDELT = NCA_ADDR_WIDTH + 4 + 2;
- boolean_t arm;
- node_t node;
- char *buf;
- namedmem_t hdr[4];
-
- if (!(flags & DCMD_ADDRSPEC))
- return (DCMD_USAGE);
-
- if (mdb_getopts(argc, argv, 'v', MDB_OPT_SETBITS, TRUE, &verbose,
- 'r', MDB_OPT_SETBITS, TRUE, &request, 'p', NULL) != argc)
- return (DCMD_USAGE);
-
- if (!DCMD_HDRSPEC(flags) && verbose)
- mdb_printf("\n\n");
-
- if (DCMD_HDRSPEC(flags) || verbose) {
- mdb_printf("%<u>%-*s %4s %5s %8s %-*s %-*s %-*s %-*s%</u>\n",
- NCA_ADDR_WIDTH, "ADDR", "REF", "STATE", "DATASIZE",
- NCA_ADDR_WIDTH, "SQUEUE", NCA_ADDR_WIDTH, "REQUEST",
- NCA_ADDR_WIDTH, "PLRUN", NCA_ADDR_WIDTH, "VLRUN");
- }
-
- if (mdb_vread(&node, sizeof (node_t), addr) == -1) {
- mdb_warn("cannot read node_t at %p", addr);
- return (DCMD_ERR);
- }
-
- mdb_printf("%0*p %4d %05x %8d %0*p %0*p %0*p %0*p\n",
- NCA_ADDR_WIDTH, addr, node.cnt, node.ref,
- node.datasz, NCA_ADDR_WIDTH, node.sqp, NCA_ADDR_WIDTH,
- node.req, NCA_ADDR_WIDTH, node.plrunn, NCA_ADDR_WIDTH, node.vlrunn);
-
- if (verbose) {
- arm = B_TRUE;
- for (i = 0; node_refs[i].bit_name != NULL; i++) {
- if ((node.ref & (1 << i)) == 0)
- continue;
-
- if (arm) {
- mdb_printf("%*s|\n", NODE_REFDELT, "");
- mdb_printf("%*s+--> ", NODE_REFDELT, "");
- arm = B_FALSE;
- } else
- mdb_printf("%*s ", NODE_REFDELT, "");
-
- mdb_printf("%-12s %s\n", node_refs[i].bit_name,
- node_refs[i].bit_descr);
- }
- }
-
- if (!request || node.req == NULL)
- return (DCMD_OK);
-
- mdb_inc_indent(4);
- mdb_printf("\n%u byte HTTP/%u.%u %s request (%u bytes in header, "
- "%u in content)\n", node.reqsz, node.version >> 16,
- node.version & 0xff, method2name(node.method), node.reqhdrsz,
- node.reqcontl);
-
- hdr[0].nm_name = "URI";
- hdr[0].nm_addr = (uintptr_t)node.path;
- hdr[0].nm_len = node.pathsz;
-
- hdr[1].nm_name = "Accept";
- hdr[1].nm_addr = (uintptr_t)node.reqaccept;
- hdr[1].nm_len = node.reqacceptsz;
-
- hdr[2].nm_name = "Accept-Language";
- hdr[2].nm_addr = (uintptr_t)node.reqacceptl;
- hdr[2].nm_len = node.reqacceptlsz;
-
- hdr[3].nm_name = "Host";
- hdr[3].nm_addr = (uintptr_t)node.reqhost;
- hdr[3].nm_len = node.reqhostsz;
-
- /*
- * A little optimization. Allocate all of the necessary memory here,
- * so we don't have to allocate on each loop iteration.
- */
-
- max = node.reqhdrsz;
- for (i = 0; i < 4; i++)
- max = MAX(max, hdr[i].nm_len);
- max++;
-
- buf = mdb_alloc(max, UM_SLEEP);
-
- mdb_inc_indent(4);
- for (i = 0; i < sizeof (hdr) / sizeof (hdr[0]); i++) {
- if (hdr[i].nm_len <= 0)
- continue;
-
- if (mdb_vread(buf, hdr[i].nm_len, hdr[i].nm_addr) == -1) {
- mdb_warn("cannot read \"%s\" header field at %p",
- hdr[i].nm_name, hdr[i].nm_addr);
- continue;
- }
- buf[hdr[i].nm_len] = '\0';
-
- mdb_printf("%s: ", hdr[i].nm_name);
- mdb_inc_indent(4);
- mdb_printf("%s\n", buf);
- mdb_dec_indent(4);
- }
-
- if (node.reqhdrsz > 0 && verbose) {
- if (mdb_vread(buf, node.reqhdrsz, (uintptr_t)node.reqhdr) == -1)
- mdb_warn("cannot read header at %p", node.reqhdr);
- else {
- mdb_printf("Raw header: ");
- mdb_inc_indent(4);
- printbuf((uint8_t *)buf, node.reqhdrsz);
- mdb_dec_indent(4);
- }
- }
- mdb_dec_indent(4);
- mdb_dec_indent(4);
-
- mdb_free(buf, max);
-
- return (DCMD_OK);
-}
-
-static void
-nca_node_help(void)
-{
- mdb_printf("Print the core information for a given NCA node_t.\n\n");
- mdb_printf("Options:\n");
- mdb_printf("\t-r\tdisplay HTTP request information\n");
- mdb_printf("\t-v\tbe verbose (more descriptive)\n");
-}
-
-/*
- * Print the core fields in an NCA nca_conn_t. With the "-t" argument, skip
- * all nca_conn_t's that are in the TIME_WAIT state. With the "-x" argument,
- * show the xmit data.
- */
-static int
-nca_conn(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
-{
- unsigned int i;
- nca_conn_t conn;
- unsigned int show_timewait = TRUE;
- unsigned int show_xmit = FALSE;
-
- if (!(flags & DCMD_ADDRSPEC))
- return (DCMD_USAGE);
-
- if (mdb_getopts(argc, argv, 'x', MDB_OPT_SETBITS, TRUE, &show_xmit,
- 't', MDB_OPT_CLRBITS, TRUE, &show_timewait, NULL) != argc)
- return (DCMD_USAGE);
-
- if (DCMD_HDRSPEC(flags)) {
- mdb_printf("%<u>%-*s %3s %8s %15s %15s %-*s %-10s%</u>\n",
- NCA_ADDR_WIDTH, "ADDR", "REF", "CREATE", "LOCAL_ADDR",
- "REMOTE_ADDR", NCA_ADDR_WIDTH, "NODE", "STATE");
- }
-
- if (mdb_vread(&conn, sizeof (nca_conn_t), addr) == -1) {
- mdb_warn("cannot read nca_conn_t at %p", addr);
- return (DCMD_ERR);
- }
-
- if (!show_timewait && conn.tcp_state == TCPS_TIME_WAIT)
- return (DCMD_OK);
-
- mdb_printf("%0*p %3d %8lx %15I %15I %0*p %s\n", NCA_ADDR_WIDTH, addr,
- conn.ref, conn.create, conn.laddr, conn.faddr, NCA_ADDR_WIDTH,
- conn.req_np, state2name(conn.tcp_state));
-
- if (show_xmit) {
- mdb_inc_indent(4);
-
- for (i = 0; i < TCP_XMIT_MAX_IX; i++) {
- mdb_printf("xmit[%d]\n", i);
- mdb_printf("\tref pointer\t\t%p\n", conn.xmit[i].np);
- mdb_printf("\tdata pointer\t\t%p\n", conn.xmit[i].dp);
- mdb_printf("\tcksum array\t\t%p\n", conn.xmit[i].cp);
- mdb_printf("\tremaining xmit data\t%d\n",
- conn.xmit[i].sz);
- mdb_printf("\tref to node_t\t\t%p\n",
- conn.xmit[i].refed);
- mdb_printf("\tremaining segment data\t%d\n",
- conn.xmit[i].dsz);
- mdb_printf("\tvirtual pointer\t\t%p\n",
- conn.xmit[i].dvp);
- }
-
- mdb_dec_indent(4);
- }
-
- return (DCMD_OK);
-}
-
-static void
-nca_conn_help(void)
-{
- mdb_printf("Print the core information for a given NCA "
- "nca_conn_t.\n\n");
- mdb_printf("Options:\n");
- mdb_printf("\t-t\tskip connections in the TIME_WAIT state\n");
- mdb_printf("\t-x\tshow TCP XMIT information\n");
-}
-
-/*
- * Print the core TCP-related fields in an NCA nca_conn_t. With the "-t"
- * argument, skips all nca_conn_t's that are in the TIME_WAIT state.
- */
-static int
-nca_tcpconn(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
-{
- nca_conn_t conn;
- unsigned int show_timewait = TRUE;
-
- if (!(flags & DCMD_ADDRSPEC))
- return (DCMD_USAGE);
-
- if (mdb_getopts(argc, argv, 't', MDB_OPT_CLRBITS, TRUE, &show_timewait,
- NULL) != argc)
- return (DCMD_USAGE);
-
- if (DCMD_HDRSPEC(flags)) {
- mdb_printf("%<u>%-*s %21s %5s %8s %5s %8s %5s %-9s%</u>\n",
- NCA_ADDR_WIDTH, "ADDR", "REMOTE_ADDR", "SWIND", "SUNASEQ",
- "SNSEQ", "RACKSEQ", "RNSEQ", "STATE");
- }
-
- if (mdb_vread(&conn, sizeof (nca_conn_t), addr) == -1) {
- mdb_warn("cannot read nca_conn_t at %p", addr);
- return (DCMD_ERR);
- }
-
- if (!show_timewait && conn.tcp_state == TCPS_TIME_WAIT)
- return (DCMD_OK);
-
- mdb_nhconvert(&conn.conn_fport, &conn.conn_fport, sizeof (in_port_t));
-
- mdb_printf("%0*p %15I:%05hu %5u %08x %+5d %08x %+5d %-9s\n",
- NCA_ADDR_WIDTH, addr, conn.faddr, conn.conn_fport, conn.tcp_swnd,
- conn.tcp_suna, conn.tcp_snxt - conn.tcp_suna, conn.tcp_rack,
- conn.tcp_rnxt - conn.tcp_rack, state2name(conn.tcp_state));
-
- return (DCMD_OK);
-}
-
-static void
-nca_tcpconn_help(void)
-{
- mdb_printf("Print the core TCP-related information for a given ");
- mdb_printf("NCA nca_conn_t.\n\n");
- mdb_printf("Options:\n");
- mdb_printf("\t-t\tskip connections in the TIME_WAIT state\n");
-}
-
-/*
- * Initialize a walk for the NCA connection fanout table. Note that
- * local walks are not supported since they're more trouble than
- * they're worth.
- */
-static int
-nca_connf_walk_init(mdb_walk_state_t *wsp)
-{
- int fanout_size;
-
- if (wsp->walk_addr != 0) {
- mdb_warn("nca_connf_walk does not support local walks\n");
- return (WALK_DONE);
- }
-
- if (mdb_readvar(&wsp->walk_addr, "nca_conn_fanout") == -1) {
- mdb_warn("cannot read symbol nca_conn_fanout");
- return (WALK_ERR);
- }
-
- if (mdb_readvar(&fanout_size, "nca_conn_fanout_size") == -1) {
- mdb_warn("cannot read symbol nca_conn_fanout_size");
- return (WALK_ERR);
- }
-
- wsp->walk_data = (void *)(uintptr_t)fanout_size;
-
- return (WALK_NEXT);
-}
-
-/*
- * Walk the NCA connection fanout table; `wsp->walk_data' is used to keep
- * track of the number of indicies that are left to walk so we know when
- * to stop.
- */
-static int
-nca_connf_walk_step(mdb_walk_state_t *wsp)
-{
- connf_t connf;
- nca_conn_t conn;
- int status;
- intptr_t i = (intptr_t)wsp->walk_data;
-
- if (i-- <= 0)
- return (WALK_DONE);
-
- if (mdb_vread(&connf, sizeof (connf_t), wsp->walk_addr) == -1) {
- mdb_warn("cannot read connf_t at %p", wsp->walk_addr);
- return (WALK_ERR);
- }
-
- /*
- * No point in walking the fanout if there are no
- * connections in it.
- */
- if (connf.head != NULL) {
- /*
- * Point to the nca_conn_t instead of the connf_t so that output
- * can be piped to ::nca_conn dcmd.
- */
- if (mdb_vread(&conn, sizeof (nca_conn_t),
- (uintptr_t)connf.head) == -1) {
- mdb_warn("cannot read nca_conn_t at %p", connf.head);
- return (WALK_ERR);
- }
- status = wsp->walk_callback((uintptr_t)connf.head, &conn,
- wsp->walk_cbdata);
- } else {
- status = WALK_NEXT;
- }
-
- wsp->walk_data = (void *)i;
- wsp->walk_addr += sizeof (connf_t);
-
- return (status);
-}
-
-/*
- * Initialize a walk for the NCA node fanout tables. Note that local
- * walks are not supported since they're more trouble than they're
- * worth.
- */
-static int
-nca_nodef_walk_init(mdb_walk_state_t *wsp)
-{
- char varname[256];
- uint32_t size;
-
- if (wsp->walk_addr != 0) {
- mdb_warn("nca_nodef_walk does not support local walks\n");
- return (WALK_DONE);
- }
-
- if (mdb_readvar(&wsp->walk_addr, wsp->walk_arg) == -1) {
- mdb_warn("cannot read symbol %s", wsp->walk_arg);
- return (WALK_ERR);
- }
-
- mdb_snprintf(varname, sizeof (varname), "%s_sz", wsp->walk_arg);
-
- if (mdb_readvar(&size, varname) == -1) {
- mdb_warn("cannot read symbol %s", varname);
- return (WALK_ERR);
- }
-
- wsp->walk_data = (void *)(uintptr_t)size;
-
- return (WALK_NEXT);
-}
-
-/*
- * Walk the NCA node fanout table; `wsp->walk_data' is used to keep
- * track of the number of indicies that are left to walk so we know
- * when to stop.
- */
-static int
-nca_nodef_walk_step(mdb_walk_state_t *wsp)
-{
- nodef_t nodef;
- node_t node;
- int status;
- intptr_t i = (intptr_t)wsp->walk_data;
-
- if (i-- <= 0)
- return (WALK_DONE);
-
- if (mdb_vread(&nodef, sizeof (nodef_t), wsp->walk_addr) == -1) {
- mdb_warn("cannot read nodef_t at %p", wsp->walk_addr);
- return (WALK_ERR);
- }
-
- status = wsp->walk_callback(wsp->walk_addr, &nodef, wsp->walk_cbdata);
-
- wsp->walk_data = (void *)i;
- wsp->walk_addr += sizeof (nodef_t);
-
- if (nodef.head != NULL) {
- /*
- * Point to the node_t instead of the nodef_t so that output
- * can be piped to ::nca_node dcmd.
- */
- if (mdb_vread(&node, sizeof (node),
- (uintptr_t)nodef.head) == -1) {
- mdb_warn("cannot read node_t at %p", nodef.head);
- return (WALK_ERR);
- }
-
- status = wsp->walk_callback((uintptr_t)nodef.head,
- &node, wsp->walk_cbdata);
- } else {
- status = WALK_NEXT;
- }
-
- return (status);
-}
-
-/*
- * Initialize a walk for the NCA CPU table. Note that local walks
- * are not supported since they're more trouble than they're worth.
- */
-static int
-nca_cpu_walk_init(mdb_walk_state_t *wsp)
-{
- int ncpus;
-
- if (wsp->walk_addr != 0) {
- mdb_warn("nca_cpu_walk does not support local walks\n");
- return (WALK_DONE);
- }
-
- if (mdb_readvar(&wsp->walk_addr, "nca_gv") == -1) {
- mdb_warn("cannot read symbol nca_gv");
- return (WALK_ERR);
- }
-
- if (mdb_readvar(&ncpus, "ncpus") == -1) {
- mdb_warn("cannot read symbol ncpus");
- return (WALK_ERR);
- }
- wsp->walk_data = (void *)(uintptr_t)ncpus;
-
- return (WALK_NEXT);
-}
-
-/*
- * Walk the NCA CPU table; `wsp->walk_data' is used to keep track of the
- * number of CPUs that are left to walk so we know when to stop.
- */
-static int
-nca_cpu_walk_step(mdb_walk_state_t *wsp)
-{
- nca_cpu_t cpu;
- int status;
- intptr_t curcpu = (intptr_t)wsp->walk_data;
-
- if (curcpu-- <= 0)
- return (WALK_DONE);
-
- if (mdb_vread(&cpu, sizeof (nca_cpu_t), wsp->walk_addr) == -1) {
- mdb_warn("cannot read nca_cpu_t at %p", wsp->walk_addr);
- return (WALK_ERR);
- }
-
- status = wsp->walk_callback(wsp->walk_addr, &cpu, wsp->walk_cbdata);
-
- wsp->walk_data = (void *)curcpu;
- wsp->walk_addr += sizeof (nca_cpu_t);
-
- return (status);
-}
-
-/*
- * Initialize a walk for the NCA timer list. Note that local walks
- * are not supported since this walk is layered on top of "nca_cpu"
- * which doesn't support them (and they're not too useful here anyway).
- */
-static int
-nca_timer_walk_init(mdb_walk_state_t *wsp)
-{
- if (wsp->walk_addr != 0) {
- mdb_warn("nca_timer_walk does not support local walks\n");
- return (WALK_DONE);
- }
-
- if (mdb_layered_walk("nca_cpu", wsp) == -1) {
- mdb_warn("cannot walk nca_cpu");
- return (WALK_ERR);
- }
-
- return (WALK_NEXT);
-}
-
-/*
- * Walk the NCA timer list; done as a layered walk on top of "nca_cpu".
- */
-static int
-nca_timer_walk_step(mdb_walk_state_t *wsp)
-{
- const nca_cpu_t *nca_cpu = wsp->walk_layer;
- ti_t ti;
-
- /*
- * Just skip CPUs that don't have any timers running.
- */
- if (nca_cpu->tcp_ti == NULL)
- return (WALK_NEXT);
-
- if (mdb_vread(&ti, sizeof (ti_t), (uintptr_t)nca_cpu->tcp_ti) == -1) {
- mdb_warn("cannot read ti_t at %p", nca_cpu->tcp_ti);
- return (WALK_ERR);
- }
-
- return (wsp->walk_callback((uintptr_t)nca_cpu->tcp_ti, &ti,
- wsp->walk_cbdata));
-}
-
-/*
- * Initialize a walk for NCA node LRUs; the type of LRU to walk should
- * be specified through `wsp->walk_arg'. If no starting location for
- * the walk is given, `wsp->walk_addr' is set to the head of the
- * appropriate LRU.
- */
-static int
-nca_node_lru_walk_init(mdb_walk_state_t *wsp)
-{
- GElf_Sym sym;
- lru_t lru;
-
- if (wsp->walk_addr != 0)
- return (WALK_NEXT);
-
- /*
- * We do this instead of mdb_readvar() so that we catch changes
- * in the size of the lru_t structure.
- */
- if (mdb_lookup_by_name("nca_lru", &sym) == -1) {
- mdb_warn("cannot lookup symbol nca_lru");
- return (WALK_ERR);
- }
-
- if (sym.st_size != sizeof (lru)) {
- mdb_warn("nca_lru object size mismatch\n");
- return (WALK_ERR);
- }
-
- if (mdb_vread(&lru, sym.st_size, (uintptr_t)sym.st_value) == -1) {
- mdb_warn("cannot read nca_lru at %p", sym.st_value);
- return (WALK_ERR);
- }
-
- if (wsp->walk_arg == NCA_WALK_PLRU)
- wsp->walk_addr = (uintptr_t)lru.phead;
- else
- wsp->walk_addr = (uintptr_t)lru.vhead;
-
- return (WALK_NEXT);
-}
-
-/*
- * Walk the NCA node LRUs; the type of LRU to walk should be specified
- * through `wsp->walk_arg'.
- */
-static int
-nca_node_lru_walk_step(mdb_walk_state_t *wsp)
-{
- node_t node;
- int status;
-
- if (wsp->walk_addr == 0)
- return (WALK_DONE);
-
- if (mdb_vread(&node, sizeof (node_t), wsp->walk_addr) == -1) {
- mdb_warn("cannot read node_t at %p", wsp->walk_addr);
- return (WALK_ERR);
- }
-
- status = wsp->walk_callback(wsp->walk_addr, &node, wsp->walk_cbdata);
-
- if (wsp->walk_arg == NCA_WALK_PLRU)
- wsp->walk_addr = (uintptr_t)node.plrunn;
- else
- wsp->walk_addr = (uintptr_t)node.vlrunn;
-
- return (status);
-}
-
-/*
- * Walk the NCA node structures; follows node_t next pointers from a
- * given offset, specified through `wsp->walk_arg'.
- */
-static int
-nca_node_walk_step(mdb_walk_state_t *wsp)
-{
- node_t node;
- int status;
-
- if (wsp->walk_addr == 0) {
- mdb_warn("nca_node_walk does not support global walks\n");
- return (WALK_DONE);
- }
-
- if (mdb_vread(&node, sizeof (node_t), wsp->walk_addr) == -1) {
- mdb_warn("cannot read node_t at %p", wsp->walk_addr);
- return (WALK_ERR);
- }
-
- status = wsp->walk_callback(wsp->walk_addr, &node, wsp->walk_cbdata);
- if (status != WALK_NEXT)
- return (status);
-
- /* LINTED */
- wsp->walk_addr = *(uintptr_t *)((caddr_t)&node +
- (uint_t)(uintptr_t)wsp->walk_arg);
-
- if (wsp->walk_addr == 0)
- return (WALK_DONE);
-
- return (WALK_NEXT);
-}
-
-/*
- * Walk the NCA connection structures; follows nca_conn_t next pointers
- * from a given offset, specified through `wsp->walk_arg'.
- */
-static int
-nca_conn_walk_step(mdb_walk_state_t *wsp)
-{
- nca_conn_t conn;
- int status;
-
- if (wsp->walk_addr == 0) {
- mdb_warn("nca_conn_walk does not support global walks\n");
- return (WALK_DONE);
- }
-
- if (mdb_vread(&conn, sizeof (nca_conn_t), wsp->walk_addr) == -1) {
- mdb_warn("cannot read nca_conn_t at %p", wsp->walk_addr);
- return (WALK_ERR);
- }
-
- status = wsp->walk_callback(wsp->walk_addr, &conn, wsp->walk_cbdata);
- if (status != WALK_NEXT)
- return (status);
-
- /* LINTED */
- wsp->walk_addr = *(uintptr_t *)((caddr_t)&conn +
- (uint_t)(uintptr_t)wsp->walk_arg);
-
- if (wsp->walk_addr == 0)
- return (WALK_DONE);
-
- return (WALK_NEXT);
-}
-
-static const mdb_dcmd_t dcmds[] = {
- { "nca_conn", ":[-tx]", "print core NCA nca_conn_t info", nca_conn,
- nca_conn_help },
- { "nca_tcpconn", ":[-t]", "print TCP NCA nca_conn_t info",
- nca_tcpconn, nca_tcpconn_help },
- { "nca_io2", ":[-pv]", "print core NCA io2_t info", nca_io2,
- nca_io2_help },
- { "nca_node", ":[-rv]", "print core NCA node_t info", nca_node,
- nca_node_help },
- { "nca_timer", "?[-e]", "print core NCA timer info", nca_timer,
- nca_timer_help },
- { NULL }
-};
-
-static const mdb_walker_t walkers[] = {
- { "nca_conn_hash", "walk the NCA connection hash chain", 0,
- nca_conn_walk_step, 0, (void *)OFFSETOF(nca_conn_t, hashnext) },
- { "nca_conn_bind", "walk the NCA connection bind chain", 0,
- nca_conn_walk_step, 0, (void *)OFFSETOF(nca_conn_t, bindnext) },
- { "nca_conn_miss", "walk the NCA connection miss chain", 0,
- nca_conn_walk_step, 0, (void *)OFFSETOF(nca_conn_t, nodenext) },
- { "nca_conn_tw", "walk the NCA connection TIME_WAIT chain", 0,
- nca_conn_walk_step, 0, (void *)OFFSETOF(nca_conn_t, twnext) },
-
- { "nca_node_file", "walk the NCA node file chain", 0,
- nca_node_walk_step, 0, (void *)OFFSETOF(node_t, filenext) },
- { "nca_node_hash", "walk the NCA node hash chain", 0,
- nca_node_walk_step, 0, (void *)OFFSETOF(node_t, hashnext) },
- { "nca_node_chunk", "walk the NCA node chunk chain", 0,
- nca_node_walk_step, 0, (void *)OFFSETOF(node_t, next) },
- { "nca_node_ctag", "walk the NCA node ctag chain", 0,
- nca_node_walk_step, 0, (void *)OFFSETOF(node_t, ctagnext) },
-
- { "nca_node_plru", "walk the NCA node physical LRU chain",
- nca_node_lru_walk_init, nca_node_lru_walk_step, 0, NCA_WALK_PLRU },
- { "nca_node_vlru", "walk the NCA node virtual LRU chain",
- nca_node_lru_walk_init, nca_node_lru_walk_step, 0, NCA_WALK_VLRU },
-
- { "nca_uri_hash", "walk the NCA URI node hash table",
- nca_nodef_walk_init, nca_nodef_walk_step, 0, "ncaurihash" },
- { "nca_file_hash", "walk the NCA file node hash table",
- nca_nodef_walk_init, nca_nodef_walk_step, 0, "ncafilehash" },
- { "nca_ctag_hash", "walk the NCA ctag node hash table",
- nca_nodef_walk_init, nca_nodef_walk_step, 0, "ncactaghash" },
- { "nca_vnode_hash", "walk the NCA vnode node hash table",
- nca_nodef_walk_init, nca_nodef_walk_step, 0, "ncavnodehash" },
-
- { "nca_cpu", "walk the NCA CPU table",
- nca_cpu_walk_init, nca_cpu_walk_step },
- { "nca_timer", "walk the NCA timer table",
- nca_timer_walk_init, nca_timer_walk_step },
- { "nca_connf", "walk the NCA connection fanout",
- nca_connf_walk_init, nca_connf_walk_step },
-
- { NULL }
-};
-
-static const mdb_modinfo_t modinfo = { MDB_API_VERSION, dcmds, walkers };
-
-const mdb_modinfo_t *
-_mdb_init(void)
-{
- return (&modinfo);
-}
diff --git a/usr/src/cmd/mdb/intel/amd64/nca/Makefile b/usr/src/cmd/mdb/intel/amd64/nca/Makefile
deleted file mode 100644
index 4c7e428c18..0000000000
--- a/usr/src/cmd/mdb/intel/amd64/nca/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-#ident "%Z%%M% %I% %E% SMI"
-
-MODULE = nca.so
-MDBTGT = kvm
-
-MODSRCS = nca.c
-
-include ../../../../Makefile.cmd
-include ../../../../Makefile.cmd.64
-include ../../Makefile.amd64
-include ../../../Makefile.module
diff --git a/usr/src/cmd/mdb/sparc/v9/nca/Makefile b/usr/src/cmd/mdb/sparc/v9/nca/Makefile
deleted file mode 100644
index 432e62605e..0000000000
--- a/usr/src/cmd/mdb/sparc/v9/nca/Makefile
+++ /dev/null
@@ -1,36 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright (c) 2000 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-#ident "%Z%%M% %I% %E% SMI"
-
-MODULE = nca.so
-MDBTGT = kvm
-
-MODSRCS = nca.c
-
-include ../../../../Makefile.cmd
-include ../../../../Makefile.cmd.64
-include ../../Makefile.sparcv9
-include ../../../Makefile.module
diff --git a/usr/src/cmd/truss/print.c b/usr/src/cmd/truss/print.c
index f7241f26fc..b977a5d14e 100644
--- a/usr/src/cmd/truss/print.c
+++ b/usr/src/cmd/truss/print.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2020 Joyent, Inc.
+ * Copyright 2022 Garrett D'Amore
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
@@ -1858,13 +1859,14 @@ prt_skp(private_t *pri, int raw, long val)
switch (pri->sys_args[0]) {
case PF_INET6:
case PF_INET:
- case PF_NCA: if ((s = ipprotos((int)val)) != NULL) {
- outstring(pri, s);
- break;
- }
- /* FALLTHROUGH */
- default: prt_dec(pri, 0, val);
+ if ((s = ipprotos((int)val)) != NULL) {
+ outstring(pri, s);
break;
+ }
+ /* FALLTHROUGH */
+ default:
+ prt_dec(pri, 0, val);
+ break;
}
}
diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile
index d1a33d262d..5d7b9fb816 100644
--- a/usr/src/lib/Makefile
+++ b/usr/src/lib/Makefile
@@ -24,8 +24,8 @@
# Copyright (c) 2012 by Delphix. All rights reserved.
# Copyright 2020 Joyent, Inc.
# Copyright (c) 2013 Gary Mills
-# Copyright 2014 Garrett D'Amore <garrett@damore.org>
# Copyright (c) 2015 Gary Mills
+# Copyright 2022 Garrett D'Amore
# Copyright 2016 Toomas Soome <tsoome@me.com>
# Copyright 2018 Nexenta Systems, Inc.
# Copyright (c) 2016, Chris Fraire <cfraire@me.com>.
@@ -252,7 +252,6 @@ SUBDIRS += \
mpapi \
mpss \
nametoaddr \
- ncad_addr \
nsswitch \
pam_modules \
passwdutil \
diff --git a/usr/src/lib/README.Makefiles b/usr/src/lib/README.Makefiles
index 6db4c7ef6e..531adc6784 100644
--- a/usr/src/lib/README.Makefiles
+++ b/usr/src/lib/README.Makefiles
@@ -592,7 +592,7 @@ outlined in this document:
Example of a simple 32/64-bit library that obtains its sources
from multiple directories.
- lib/ncad_addr
+ lib/nametoaddr/straddr
Example of a simple loadable module.
diff --git a/usr/src/lib/ncad_addr/Makefile b/usr/src/lib/ncad_addr/Makefile
deleted file mode 100644
index a9ce76dd8a..0000000000
--- a/usr/src/lib/ncad_addr/Makefile
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-# 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 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-include ../Makefile.lib
-
-SUBDIRS= $(MACH)
-$(BUILD64)SUBDIRS += $(MACH64)
-
-all := TARGET= all
-install := TARGET= install
-clean := TARGET= clean
-clobber := TARGET= clobber
-
-.KEEP_STATE:
-
-all install clean clobber: $(SUBDIRS)
-
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
diff --git a/usr/src/lib/ncad_addr/Makefile.com b/usr/src/lib/ncad_addr/Makefile.com
deleted file mode 100644
index 446ed16a3f..0000000000
--- a/usr/src/lib/ncad_addr/Makefile.com
+++ /dev/null
@@ -1,42 +0,0 @@
-#
-# 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 (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
-#
-
-LIBRARY = ncad_addr.a
-VERS = .1
-OBJECTS = ncad_addr.o
-
-include ../../Makefile.lib
-
-SRCDIR = ../common
-
-LIBS = $(DYNLIB)
-LDLIBS += -lc
-CFLAGS += $(CCVERBOSE)
-
-.KEEP_STATE:
-
-all: $(LIBS)
-
-
-include ../../Makefile.targ
diff --git a/usr/src/lib/ncad_addr/amd64/Makefile b/usr/src/lib/ncad_addr/amd64/Makefile
deleted file mode 100644
index cb39a2beff..0000000000
--- a/usr/src/lib/ncad_addr/amd64/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright 2004 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-include ../../Makefile.lib.64
-
-install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/ncad_addr/common/mapfile-vers b/usr/src/lib/ncad_addr/common/mapfile-vers
deleted file mode 100644
index 66479635e0..0000000000
--- a/usr/src/lib/ncad_addr/common/mapfile-vers
+++ /dev/null
@@ -1,103 +0,0 @@
-#
-# 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 (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
-#
-
-#
-# MAPFILE HEADER START
-#
-# WARNING: STOP NOW. DO NOT MODIFY THIS FILE.
-# Object versioning must comply with the rules detailed in
-#
-# usr/src/lib/README.mapfiles
-#
-# You should not be making modifications here until you've read the most current
-# copy of that file. If you need help, contact a gatekeeper for guidance.
-#
-# MAPFILE HEADER END
-#
-
-$mapfile_version 2
-
-# The following version madness was mistakenly inherited from
-# libsocket in Solaris 9, when this library was created.
-# See the isa-specific mapfiles for the contents of SUNW_0.7
-
-SYMBOL_VERSION SUNW_1.4 { # SunOS 5.9 (Solaris 9)
- global:
- SUNW_1.4;
-} SUNW_1.3;
-
-SYMBOL_VERSION SUNW_1.3 {
- global:
- SUNW_1.3;
-} SUNW_1.2;
-
-SYMBOL_VERSION SUNW_1.2 {
- global:
- SUNW_1.2;
-} SUNW_1.1;
-
-SYMBOL_VERSION SUNW_1.1 {
- global:
- SUNW_1.1;
-} SUNW_0.7;
-
-#
-# For most platforms, SUNW_0.7 contains bind. For ABI reasons, 32-bit sparc
-# puts it in SISCD_2.3 instead, and SUNW_0.7 exists solely so that 1.1 can
-# inherit from it on all platforms.
-#
-SYMBOL_VERSION SUNW_0.7 {
- global:
-$if _sparc && _ELF32
- SUNW_0.7;
-} SISCD_2.3;
-
-SYMBOL_VERSION SISCD_2.3 {
- global:
-$endif
- # Bind is intended to interpose on the real system call. However,
- # we want debuggers to see its real name (nca_bind), so use NODYNSORT
- # to prevent "bind" from going into the ELF .SUNW_dynsymsort section
- bind { FLAGS = NODYNSORT };
-};
-
-# There really should be only one SUNWprivate version.
-# Don't add any more. Add new private symbols to SUNWprivate_1.3
-
-SYMBOL_VERSION SUNWprivate_1.3 {
- global:
- SUNWprivate_1.3;
-} SUNWprivate_1.2;
-
-SYMBOL_VERSION SUNWprivate_1.2 {
- global:
- SUNWprivate_1.2;
-} SUNWprivate_1.1;
-
-SYMBOL_VERSION SUNWprivate_1.1 {
- global:
- SUNWprivate_1.1;
- local:
- *;
-};
diff --git a/usr/src/lib/ncad_addr/common/ncad_addr.c b/usr/src/lib/ncad_addr/common/ncad_addr.c
deleted file mode 100644
index 40367e9f03..0000000000
--- a/usr/src/lib/ncad_addr/common/ncad_addr.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * 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 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Shim library which should be LD_PRELOADed before running applications
- * that interact with NCA but do not explicitly use the AF_NCA family.
- * This library overloads AF_INET's version of bind(3SOCKET) with AF_NCA's
- * version. The new version of bind checks to see if that the port is one
- * NCA is listening on, closes the socket(3SOCKET), and opens a new one
- * the family AF_NCA. Afterwards, the real bind(3SOCKET) is called
- * descriptors, etc. *
- *
- * Compile: cc -Kpic -G -o ncad_addr.so ncad_addr.c -lsocket -lnsl
- * Use: LD_PRELOAD=/path/to/ncad_addr.so my_program
- */
-
-#include <stdio.h>
-#include <assert.h>
-#include <dlfcn.h>
-#include <door.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <inet/nd.h>
-#include <unistd.h>
-#include <stropts.h>
-#include <sys/stat.h>
-#include <string.h>
-#include <stdlib.h>
-#include <sys/mman.h>
-#include <netdb.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <arpa/inet.h>
-
-#pragma weak bind = nca_bind
-#pragma init(ncad_init)
-#pragma fini(ncad_fini)
-
-#define SEPARATOR '/'
-
-typedef int sfunc1_t(int, int, int);
-typedef int sfunc2_t(int, const struct sockaddr *, socklen_t);
-
-static sfunc1_t *real_socket;
-static sfunc2_t *real_bind;
-
-/*
- * It is used to represent an address NCA is willing to handle.
- */
-typedef struct nca_address_s {
- uint16_t port; /* port, in network byte order */
- ipaddr_t ipaddr; /* IP address, in network byte order */
-} nca_address_t;
-
-static uint32_t addrcount; /* current address count */
-static uint32_t addrcapacity; /* capacity of ncaaddrs */
-static nca_address_t *ncaaddrs; /* array for all addresses */
-
-/*
- * It loads all NCA addresses from a configuration file. A NCA address
- * entry is: ncaport=IPaddress:port. The line above can be repeatly for other
- * addresses. If IPaddress is '*', then it is translated into INADDR_ANY.
- */
-static void
-ncad_init(void)
-{
- uint16_t port;
- ipaddr_t addr;
- FILE *fp;
- char *s, *p, *q;
- char buffer[1024];
- const char *filename = "/etc/nca/ncaport.conf";
-
- real_socket = (sfunc1_t *)dlsym(RTLD_NEXT, "socket");
- real_bind = (sfunc2_t *)dlsym(RTLD_NEXT, "bind");
-
- if ((fp = fopen(filename, "rF")) == NULL) {
- (void) fprintf(stderr, "Failed to open file %s for reading in "
- " ncad_addr.so. Error = %s\n",
- filename,
- (p = strerror(errno)) ? p : "unknown error");
- return;
- }
-
- while (fgets(buffer, sizeof (buffer), fp) != NULL) {
- s = buffer;
-
- /* remove '\n' at the end from fgets() */
- p = strchr(s, '\n');
- if (p != NULL)
- *p = '\0';
-
- /* remove spaces from the front */
- while (*s != '\0' && isspace(*s))
- s++;
-
- if (*s == '\0' || *s == '#')
- continue;
-
- /* it should start with ncaport= */
- p = strchr(s, '=');
- if (p == NULL || strncasecmp(s, "ncaport", 7) != 0)
- continue;
-
- p++;
- while (*p != '\0' && isspace(*p))
- p++;
-
- q = strchr(p, SEPARATOR);
- if (q == NULL)
- continue;
- *q++ = '\0';
- if (strcmp(p, "*") == 0) {
- addr = INADDR_ANY;
- } else {
- if (inet_pton(AF_INET, p, &addr) != 1) {
- struct in6_addr addr6;
-
- if (inet_pton(AF_INET6, p, &addr6) == 1) {
- (void) fprintf(stderr,
- "NCA does not support IPv6\n");
- } else {
- (void) fprintf(stderr,
- "Invalid IP address: %s\n", p);
- }
- continue;
- }
- }
- port = atoi(q);
-
- /* array is full, expand it */
- if (addrcount == addrcapacity) {
- if (addrcapacity == 0)
- addrcapacity = 64;
- else
- addrcapacity *= 2;
- ncaaddrs = realloc(ncaaddrs,
- addrcapacity * sizeof (nca_address_t));
- if (ncaaddrs == NULL) {
- (void) fprintf(stderr, "out of memory");
- break;
- }
- }
-
- ncaaddrs[addrcount].ipaddr = addr;
- ncaaddrs[addrcount].port = htons(port);
- addrcount++;
- }
-
- (void) fclose(fp);
-}
-
-/*
- * It destroys memory at the end of program.
- */
-static void
-ncad_fini(void)
-{
- if (ncaaddrs != NULL) {
- free(ncaaddrs);
- ncaaddrs = NULL;
- }
-}
-
-/*
- * If the bind is happening on a port NCA is listening on, close
- * the socket and open a new one with family AF_NCA.
- */
-static int
-nca_bind(int sock, const struct sockaddr *name, socklen_t namelen)
-{
- struct sockaddr_in sin;
- int new_sock;
- int i;
-
- if (sock < 0) {
- errno = EBADF;
- return (-1);
- }
-
- if (real_socket == NULL) {
- if ((real_socket = (sfunc1_t *)dlsym(RTLD_NEXT, "socket"))
- == NULL) {
- errno = EAGAIN;
- exit(-1);
- }
- }
-
- if (real_bind == NULL) {
- if ((real_bind = (sfunc2_t *)dlsym(RTLD_NEXT, "bind"))
- == NULL) {
- errno = EAGAIN;
- exit(-1);
- }
- }
-
- if (name == NULL ||
- ncaaddrs == NULL ||
- name->sa_family != AF_INET ||
- namelen != sizeof (sin)) {
- return (real_bind(sock, name, namelen));
- }
-
- (void) memcpy(&sin, name, sizeof (sin));
-
- /*
- * If it is one of the addresses NCA is handling, convert it
- * to NCA socket.
- */
- for (i = 0; i < addrcount; i++) {
- if (sin.sin_port == ncaaddrs[i].port &&
- (sin.sin_addr.s_addr == ncaaddrs[i].ipaddr ||
- ncaaddrs[i].ipaddr == INADDR_ANY)) {
- /* convert to NCA socket */
- new_sock = real_socket(AF_NCA, SOCK_STREAM, 0);
- if (new_sock >= 0) {
- (void) dup2(new_sock, sock);
- (void) close(new_sock);
- sin.sin_family = AF_NCA;
- }
- break;
- }
- }
-
- return (real_bind(sock, (struct sockaddr *)&sin, namelen));
-}
diff --git a/usr/src/lib/ncad_addr/i386/Makefile b/usr/src/lib/ncad_addr/i386/Makefile
deleted file mode 100644
index 6134c1e850..0000000000
--- a/usr/src/lib/ncad_addr/i386/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright (c) 1999-2001 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-
-install: all $(ROOTLIBS) $(ROOTLINKS)
diff --git a/usr/src/lib/ncad_addr/sparc/Makefile b/usr/src/lib/ncad_addr/sparc/Makefile
deleted file mode 100644
index 6134c1e850..0000000000
--- a/usr/src/lib/ncad_addr/sparc/Makefile
+++ /dev/null
@@ -1,31 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright (c) 1999-2001 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-
-install: all $(ROOTLIBS) $(ROOTLINKS)
diff --git a/usr/src/lib/ncad_addr/sparcv9/Makefile b/usr/src/lib/ncad_addr/sparcv9/Makefile
deleted file mode 100644
index a8dcf1ef21..0000000000
--- a/usr/src/lib/ncad_addr/sparcv9/Makefile
+++ /dev/null
@@ -1,32 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-#
-# Copyright (c) 1999-2001 by Sun Microsystems, Inc.
-# All rights reserved.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-include ../Makefile.com
-include ../../Makefile.lib.64
-
-install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/man/man1/Makefile b/usr/src/man/man1/Makefile
index 60cc6a6ecf..e98c187773 100644
--- a/usr/src/man/man1/Makefile
+++ b/usr/src/man/man1/Makefile
@@ -12,7 +12,7 @@
#
# Copyright 2011, Richard Lowe
# Copyright 2018 Nexenta Systems, Inc.
-# Copyright 2014 Garrett D'Amore <garrett@damore.org>
+# Copyright 2022 Garrett D'Amore
# Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
# Copyright 2020 Joyent, Inc.
#
@@ -248,9 +248,6 @@ MANFILES= acctcom.1 \
mt.1 \
mv.1 \
nc.1 \
- nca.1 \
- ncab2clf.1 \
- ncakmod.1 \
newform.1 \
newgrp.1 \
news.1 \
@@ -519,7 +516,6 @@ MANLINKS= batch.1 \
setenv.1 \
settime.1 \
sh.1 \
- snca.1 \
source.1 \
spellin.1 \
stop.1 \
@@ -666,8 +662,6 @@ rmail.1 := LINKSRC = mail.1
page.1 := LINKSRC = more.1
-snca.1 := LINKSRC = nca.1
-
pcat.1 := LINKSRC = pack.1
unpack.1 := LINKSRC = pack.1
diff --git a/usr/src/man/man1/digest.1 b/usr/src/man/man1/digest.1
index 82a9566df2..dc4cb0c3d8 100644
--- a/usr/src/man/man1/digest.1
+++ b/usr/src/man/man1/digest.1
@@ -4,22 +4,19 @@
.\" 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]
-.TH DIGEST 1 "Feb 07, 2018"
+.TH DIGEST 1 "July 3, 2022"
.SH NAME
digest \- calculate a message digest
.SH SYNOPSIS
-.LP
.nf
\fB/usr/bin/digest\fR \fB-l\fR | [\fB-v\fR] \fB-a\fR \fIalgorithm\fR [\fIfile\fR]...
.fi
.SH DESCRIPTION
-.LP
The \fBdigest\fR utility calculates the message digest of the given files or
\fBstdin\fR using the algorithm specified. If more than one file is given, each
line of output is the digest of a single file.
.SH OPTIONS
-.LP
The following options are supported:
.sp
.ne 2
@@ -52,7 +49,6 @@ Verbose output. Includes the algorithm name and filename in the output.
.SH USAGE
.SS "Algorithms"
-.LP
These algorithms are provided by the Cryptographic Framework. Each algorithm
supported by the command is an alias of the PKCS #11 mechanism for easier
access. For example, \fBsha1\fR is an alias to \fBCKM_SHA_1\fR.
@@ -60,7 +56,6 @@ access. For example, \fBsha1\fR is an alias to \fBCKM_SHA_1\fR.
.LP
These aliases are used with the \fB-a\fR option and are case-sensitive.
.SH EXAMPLES
-.LP
\fBExample 1 \fRSimulating Output
.sp
.LP
@@ -111,7 +106,6 @@ sha1 (/usr/lib/inet/in.iked) = be6061fad725d37256e773dc85f8bd5248649463
sha1 (/usr/lib/inet/in.mpathd) = 5bd6bf0340fd5c4cc0c53f2df158302a0e85f9d0
sha1 (/usr/lib/inet/in.ndpd) = fdb768aebe7e5eb4465e1c1bb5e679b496f5c5c6
sha1 (/usr/lib/inet/in.ripngd) = 4f56a0df2d4a252f581a73c2e84143b920d0b66b
-sha1 (/usr/lib/inet/ncaconfd) = 7219542b5585a8d1104d7ce4a2ced07d8a260ea3
sha1 (/usr/lib/inet/ppp) = c96ee458549871a6ffdf2674a888b01d0c9e9740
sha1 (/usr/lib/inet/pppoec) = 5f022498d79dacacd947cddadc64f171822e3dee
sha1 (/usr/lib/inet/pppoed) = 252bd2f0863dbc1b05fffae72821a2a95609b8ad
@@ -141,7 +135,6 @@ sha512
.sp
.SH EXIT STATUS
-.LP
The following exit values are returned:
.sp
.ne 2
@@ -162,7 +155,6 @@ An error occurred.
.RE
.SH ATTRIBUTES
-.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp
@@ -177,7 +169,6 @@ Interface Stability Committed
.TE
.SH SEE ALSO
-.LP
.BR cksum (1),
.BR encrypt (1),
.BR mac (1),
diff --git a/usr/src/man/man1/nca.1 b/usr/src/man/man1/nca.1
deleted file mode 100644
index 4760571da2..0000000000
--- a/usr/src/man/man1/nca.1
+++ /dev/null
@@ -1,176 +0,0 @@
-'\" te
-.\" Copyright (C) 2005, Sun Microsystems, Inc. All Rights Reserved
-.\" 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]
-.TH NCA 1 "Feb 22, 2005"
-.SH NAME
-nca, snca \- the Solaris Network Cache and Accelerator (NCA)
-.SH DESCRIPTION
-.sp
-.LP
-The Solaris Network Cache and Accelerator ("\fBNCA\fR") is a kernel module
-designed to provide improved web server performance. The kernel module,
-\fBncakmod\fR, services \fBHTTP\fR requests. To improve the performance of
-servicing \fBHTTP\fR requests, the \fBNCA\fR kernel module maintains an
-in-kernel cache of web pages. If the \fBNCA\fR kernel module cannot service the
-request itself, it passes the request to the \fBhttp\fR daemon (\fBhttpd\fR).
-It uses either a sockets interface, with family type designated \fBPF_NCA\fR,
-or a private Solaris doors interface that is based on the Solaris doors RPC
-mechanism, to pass the request.
-.sp
-.LP
-To use the sockets interface, the web server must open a socket of family type
-\fBPF_NCA\fR. The \fBPF_NCA\fR family supports only \fBSOCK_STREAM\fR and
-protocol 0, otherwise an error occurs.
-.sp
-.LP
-The following features are not presently supported:
-.RS +4
-.TP
-.ie t \(bu
-.el o
-You cannot initiate a connection from a \fBPF_NCA\fR type socket. The
-\fBconnect\fR(3SOCKET) interface on \fBPF_NCA\fR fails.
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-System calls that are associated with type \fBSO_DGRAM\fR, such as
-\fBsend()\fR, \fBsendto()\fR, \fBsendmsg()\fR, \fBrecv()\fR, \fBrecvfrom()\fR,
-and \fBrecvmsg()\fR, fails.
-.RE
-.RS +4
-.TP
-.ie t \(bu
-.el o
-You cannot set TCP or IP options on a \fBPF_NCA\fR type socket through
-\fBsetsockopt\fR(3SOCKET).
-.RE
-.sp
-.LP
-The \fBNCA\fR cache consistency is maintained by honoring \fBHTTP\fR headers
-that deal with a given content type and expiration date, much the same way as a
-proxy cache.
-.sp
-.LP
-For configuration information, see \fISystem Administration Guide: IP
-Services\fR
-.sp
-.LP
-When native \fBPF_NCA\fR socket support does not exist in the web server, the
-\fBncad_addr\fR(5) interface must be used to provide NCA support in that web
-server.
-.sp
-.LP
-\fBNCA\fR is intended to be run on a dedicated web server. Running other large
-processes while running \fBNCA\fR might cause undesirable behavior.
-.sp
-.LP
-\fBNCA\fR supports the logging of in-kernel cache hits. See
-\fBncalogd.conf\fR(5). \fBNCA\fR stores logs in a binary format. Use the
-\fBncab2clf\fR(1) utility to convert the log from a binary format to the Common
-Log File format.
-.SH FILES
-.sp
-.ne 2
-.na
-\fB\fB/etc/nca/ncakmod.conf\fR\fR
-.ad
-.RS 25n
-Lists configuration parameters for \fBNCA\fR.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/etc/nca/ncalogd.conf\fR\fR
-.ad
-.RS 25n
-Lists configuration parameters for \fBNCA\fR logging.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/etc/nca/nca.if\fR\fR
-.ad
-.RS 25n
-Lists the physical interfaces on which \fBNCA\fR runs.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/etc/nca/ncaport.conf\fR\fR
-.ad
-.RS 25n
-\fBncaport\fR configuration file
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/etc/hostname.{}{0-9}\fR\fR
-.ad
-.RS 25n
-Lists all physical interfaces configured on the server.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/etc/hosts\fR\fR
-.ad
-.RS 25n
-Lists all host names associated with the server. Entries in this file must
-match with entries in \fB/etc/hostname.{}{0-9}\fR for \fBNCA\fR to function.
-.RE
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(7) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Interface Stability Committed
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-.BR ncab2clf (1),
-.BR ncakmod (1),
-.BR close (2),
-.BR read (2),
-.BR write (2),
-.BR door_bind (3C),
-.BR door_call (3C),
-.BR door_create (3C),
-.BR sendfilev (3EXT),
-.BR socket.h (3HEAD),
-.BR accept (3SOCKET),
-.BR bind (3SOCKET),
-.BR connect (3SOCKET),
-.BR getsockopt (3SOCKET),
-.BR listen (3SOCKET),
-.BR setsockopt (3SOCKET),
-.BR shutdown (3SOCKET),
-.BR socket (3SOCKET),
-.BR nca.if (5),
-.BR ncad_addr (5),
-.BR ncakmod.conf (5),
-.BR ncalogd.conf (5),
-.BR ncaport.conf (5),
-.BR attributes (7)
-.sp
-.LP
-\fISystem Administration Guide: IP Services\fR
diff --git a/usr/src/man/man1/ncab2clf.1 b/usr/src/man/man1/ncab2clf.1
deleted file mode 100644
index 6e4fcd2855..0000000000
--- a/usr/src/man/man1/ncab2clf.1
+++ /dev/null
@@ -1,212 +0,0 @@
-'\" te
-.\" Copyright (C) 2001, Sun Microsystems, Inc. All Rights Reserved
-.\" 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]
-.TH NCAB2CLF 1 "Sep 28, 2001"
-.SH NAME
-ncab2clf \- convert binary log file to Common Log File format
-.SH SYNOPSIS
-.LP
-.nf
-\fB/usr/bin/ncab2clf\fR [\fB-Dhv\fR] [\fB-i\fR \fIinput-file\fR] [\fB-o\fR \fIoutput-file\fR]
- [\fB-b\fR \fIsize\fR] [\fB-n\fR \fInumber\fR] [\fB-s\fR \fIdatetime\fR]
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-The \fBncab2clf\fR command is used to convert the log file generated by the
-Solaris Network Cache and Accelerator ("\fBNCA\fR") from binary format, to
-Common Log File ("\fBCLF\fR") format. If no \fIinput-file\fR is specified,
-\fBncab2clf\fR uses \fBstdin\fR. If no \fIoutput-file\fR is specified, the
-output goes to \fBstdout\fR.
-.SH OPTIONS
-.sp
-.ne 2
-.na
-\fB\fB-b\fR\fR
-.ad
-.RS 18n
-Specifies the binary-log-file blocking in kilobytes; the default is 64 Kbyte.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-D\fR\fR
-.ad
-.RS 18n
-Specifies that direct \fBI/O\fR be disabled.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-h\fR\fR
-.ad
-.RS 18n
-Prints usage message.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-i\fR \fIinput-file\fR\fR
-.ad
-.RS 18n
-Specifies the input file.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-n\fR \fInumber\fR\fR
-.ad
-.RS 18n
-Output \fInumber\fR CLF records.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-o\fR \fIoutput-file\fR\fR
-.ad
-.RS 18n
-Specifies the output file.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-s\fR \fIdatetime\fR\fR
-.ad
-.RS 18n
-Skip any records before the date and time specified in \fIdatetime\fR. You can
-specify the date and time in CLF format or in the format specified by the
-\fBtouch\fR(1) utility. CLF format is the dominant format, so \fBncab2clf\fR
-first analyzes \fIdatetime\fR assuming CLF.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-v\fR\fR
-.ad
-.RS 18n
-Provides verbose output.
-.RE
-
-.SH EXAMPLES
-.LP
-\fBExample 1 \fRConverting a Binary File to a Common Log File Format
-.sp
-.LP
-The following example converts the binary file \fB/var/nca/logs/nca.blf\fR to a
-file \fB/var/nca/logs/nca.clf\fR, which is in Common Log File format.
-
-.sp
-.in +2
-.nf
-example% \fBncab2clf -D -i /var/nca/logs/nca.blf -o /var/nca/logs/nca.clf\fR
-.fi
-.in -2
-.sp
-
-.LP
-\fBExample 2 \fRConverting Multiple Log Files
-.sp
-.LP
-The following script may be used to convert multiple log files. The directory
-designated by "\fB*\fR" must only contain log files.
-
-.sp
-.in +2
-.nf
-!/bin/ksh
-for filename in *
-do
- ncab2clf -D < $filename > $filename.clf
-done
-.fi
-.in -2
-
-.LP
-\fBExample 3 \fRUsing \fB-s\fR and \fB-n\fR on a Raw Device
-.sp
-.LP
-The following example shows how \fBncab2clf\fR can be used on a raw device. If
-not using the \fB-n\fR option, the default is to convert all records from the
-starting location to the end of the file. The date and time specified with
-\fB-s\fR, below, is in CLF format.
-
-.sp
-.in +2
-.nf
-example% ncab2clf -s '10/Apr/2001:09:23:13' -n 100 < /dev/dsk/c2t1d0s6
-.fi
-.in -2
-.sp
-
-.SH EXIT STATUS
-.sp
-.LP
-The following exit values are returned:
-.sp
-.ne 2
-.na
-\fB\fB0\fR \fR
-.ad
-.RS 6n
-The file converted successfully
-.RE
-
-.sp
-.ne 2
-.na
-\fB>\fB0\fR\fR
-.ad
-.RS 6n
-An error occurred.
-.RE
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(7) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Interface Stability Evolving
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-.BR nca (1),
-.BR ncakmod (1),
-.BR nca.if (5),
-.BR ncakmod.conf (5),
-.BR ncalogd.conf (5),
-.BR attributes (7)
-.sp
-.LP
-\fISystem Administration Guide: IP Services\fR
-.SH NOTES
-.sp
-.LP
-The binary log files generated by \fBNCA\fR can become very large. When
-converting these large binary files, use the \fB-b\fR option to the
-\fBncab2clf\fR command to help performance.
-.sp
-.LP
-Direct \fBI/O\fR is a benefit to the user if the data being written does not
-come in as large chunks. However, if the user wishes to convert the log file in
-large chunks using the \fB-b\fR option, then direct \fBI/O\fR should be
-disabled by using the \fB-D\fR option.
diff --git a/usr/src/man/man1/ncakmod.1 b/usr/src/man/man1/ncakmod.1
deleted file mode 100644
index bf36c1977e..0000000000
--- a/usr/src/man/man1/ncakmod.1
+++ /dev/null
@@ -1,119 +0,0 @@
-'\" te
-.\" Copyright (C) 2001, Sun Microsystems, Inc. All Rights Reserved
-.\" 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]
-.TH NCAKMOD 1 "Sep 28, 2001"
-.SH NAME
-ncakmod \- start or stop the NCA kernel module
-.SH SYNOPSIS
-.LP
-.nf
-\fB/etc/init.d/ncakmod\fR \fBstart\fR | \fBstop\fR
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-\fBncakmod\fR is used to start or stop the Solaris Network Cache and
-Accelerator ("NCA") kernel module.
-.sp
-.LP
-When the \fBstart\fR option is specified at the command-line, the \fBNCA\fR
-kernel module will be activated for all physical interfaces listed in the
-\fBnca.if\fR file. When the \fBncakmod\fR command is invoked with the
-\fBstop\fR option, the NCA kernel module will print the following message:
-.sp
-.in +2
-.nf
-To stop NCA, please set the status configuration parameter
-to disable in ncakmod.conf and then reboot your system. See
-the ncakmod.conf(5) manual page for more information.
-.fi
-.in -2
-.sp
-
-.sp
-.LP
-Note that in order to properly stop \fBNCA\fR on your system, you must first
-edit the \fBncakmod.conf\fR(5) file and set the status field to "disable," then
-reboot your system.
-.SH OPTIONS
-.sp
-.ne 2
-.na
-\fB\fBstart\fR\fR
-.ad
-.RS 9n
-Starts the \fBNCA\fR kernel module.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBstop\fR\fR
-.ad
-.RS 9n
-Describes the current method for stopping the \fBNCA\fR feature.
-.RE
-
-.SH EXAMPLES
-.LP
-\fBExample 1 \fRStarting and Stopping the NCA Feature
-.sp
-.LP
-The following command is used to start the NCA feature:
-
-.sp
-.in +2
-.nf
-example% \fB/etc/init.d/ncakmod start\fR
-.fi
-.in -2
-.sp
-
-.SH FILES
-.sp
-.ne 2
-.na
-\fB\fB/etc/init.d/ncakmod\fR\fR
-.ad
-.RS 25n
-The NCA kernel module startup script.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/etc/nca/ncakmod.conf\fR\fR
-.ad
-.RS 25n
-Specifies configuration options for the NCA kernel module.
-.RE
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(7) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Interface Stability Evolving
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-.BR nca (1),
-.BR ncab2clf (1),
-.BR nca.if (5),
-.BR ncad_addr (5),
-.BR ncakmod.conf (5),
-.BR ncalogd.conf (5),
-.BR attributes (7)
diff --git a/usr/src/man/man3ext/sendfilev.3ext b/usr/src/man/man3ext/sendfilev.3ext
index 6679356d05..568fe10d33 100644
--- a/usr/src/man/man3ext/sendfilev.3ext
+++ b/usr/src/man/man3ext/sendfilev.3ext
@@ -3,11 +3,11 @@
.\" 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]
-.TH SENDFILEV 3EXT "Nov 26, 2017"
+.\" Copyright 2022 Garrett D'Amore
+.TH SENDFILEV 3EXT "July 3, 2022"
.SH NAME
sendfilev \- send a file
.SH SYNOPSIS
-.LP
.nf
\fBcc\fR [ \fIflag\fR\&.\|.\|. ] \fIfile\fR\&.\|.\|. \fB-lsendfile\fR [ \fIlibrary\fR... ]
#include <sys/sendfile.h>
@@ -17,7 +17,6 @@ sendfilev \- send a file
.fi
.SH PARAMETERS
-.LP
The \fBsendfilev()\fR function supports the following parameters:
.sp
.ne 2
@@ -25,9 +24,8 @@ The \fBsendfilev()\fR function supports the following parameters:
\fB\fIfildes\fR\fR
.ad
.RS 11n
-A file descriptor to a regular file or to a \fBAF_NCA\fR, \fBAF_INET\fR, or
+A file descriptor to a regular file or to a \fBAF_INET\fR or
\fBAF_INET6\fR family type \fBSOCK_STREAM\fR socket that is open for writing.
-For \fBAF_NCA\fR, the protocol type should be zero.
.RE
.sp
@@ -59,11 +57,10 @@ The total number of bytes written to \fBout_fd\fR.
.RE
.SH DESCRIPTION
-.LP
The \fBsendfilev()\fR function attempts to write data from the \fIsfvcnt\fR
buffers specified by the members of \fIvec\fR array: \fBvec[0], vec[1], ... ,
vec[sfvcnt-1]\fR. The \fIfildes\fR argument is a file descriptor to a regular
-file or to an \fBAF_NCA\fR, \fBAF_INET\fR, or \fBAF_INET6\fR family type
+file or to an \fBAF_INET\fR or \fBAF_INET6\fR family type
\fBSOCK_STREAM\fR socket that is open for writing.
.sp
.LP
@@ -108,7 +105,6 @@ To send data directly from the address space of the process, set \fBsfv_fd\fR
to \fBSFV_FD_SELF\fR. \fBsfv_off\fR should point to the data, with
\fBsfv_len\fR containing the length of the buffer.
.SH RETURN VALUES
-.LP
Upon successful completion, the \fBsendfilev()\fR function returns total number
of bytes written to \fBout_fd\fR. Otherwise, it returns \fB-1\fR, and
\fBerrno\fR is set to indicate the error. The \fIxferred\fR argument contains
@@ -220,11 +216,9 @@ The socket type is not supported.
.RE
.SH USAGE
-.LP
The \fBsendfilev()\fR function has a transitional interface for 64-bit file
offsets. See \fBlf64\fR(7).
.SH EXAMPLES
-.LP
The following example sends 2 vectors, one of HEADER data and a file of length
100 over \fBsockfd\fR. \fBsockfd\fR is in a connected state, that is,
\fBsocket()\fR, \fBaccept()\fR, and \fBbind()\fR operation are complete.
@@ -262,7 +256,6 @@ main (int argc, char *argv[]){
.in -2
.SH ATTRIBUTES
-.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp
@@ -279,7 +272,6 @@ MT-Level MT-Safe
.TE
.SH SEE ALSO
-.LP
.BR open (2),
.BR writev (2),
.BR sendfile (3EXT),
diff --git a/usr/src/man/man3socket/socket.3socket b/usr/src/man/man3socket/socket.3socket
index 1ceceb1098..cfb72c2646 100644
--- a/usr/src/man/man3socket/socket.3socket
+++ b/usr/src/man/man3socket/socket.3socket
@@ -5,11 +5,11 @@
.\" 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]
-.TH SOCKET 3SOCKET "Jan 28, 2009"
+.\" Copyright 2022 Garrett D'Amore
+.TH SOCKET 3SOCKET "July 6, 2022"
.SH NAME
socket \- create an endpoint for communication
.SH SYNOPSIS
-.LP
.nf
\fBcc\fR [ \fIflag\fR ... ] \fIfile\fR ... \fB-lsocket\fR \fB -lnsl \fR [ \fIlibrary\fR ... ]
#include <sys/types.h>
@@ -19,11 +19,8 @@ socket \- create an endpoint for communication
.fi
.SH DESCRIPTION
-.sp
-.LP
The \fBsocket()\fR function creates an endpoint for communication and returns a
descriptor.
-.sp
.LP
The \fIdomain\fR argument specifies the protocol family within which
communication takes place. The protocol family is generally the same as the
@@ -60,15 +57,6 @@ Internet Protocol Version 6 (IPv6)
.RE
.sp
-.ne 2
-.na
-\fB\fBPF_NCA\fR\fR
-.ad
-.RS 12n
-Network Cache and Accelerator (NCA) protocols
-.RE
-
-.sp
.LP
The socket has the indicated \fItype\fR, which specifies the communication
semantics. Currently defined types are:
@@ -197,13 +185,9 @@ The operation of sockets is controlled by socket level \fIoptions\fR. These
options are defined in the file <\fBsys/socket.h\fR>. \fBsetsockopt\fR(3SOCKET)
and \fBgetsockopt\fR(3SOCKET) are used to set and get options, respectively.
.SH RETURN VALUES
-.sp
-.LP
Upon successful completion, a descriptor referencing the socket is returned.
Otherwise, -1 is returned and \fBerrno\fR is set to indicate the error.
.SH ERRORS
-.sp
-.LP
The \fBsocket()\fR function will fail if:
.sp
.ne 2
@@ -296,8 +280,6 @@ One or more of the specified flags is not supported.
.RE
.SH ATTRIBUTES
-.sp
-.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp
@@ -312,9 +294,6 @@ MT-Level Safe
.TE
.SH SEE ALSO
-.sp
-.LP
-.BR nca (1),
.BR close (2),
.BR exec (2),
.BR fcntl (2),
@@ -337,7 +316,5 @@ MT-Level Safe
.BR socketpair (3SOCKET),
.BR attributes (7)
.SH NOTES
-.sp
-.LP
Historically, \fBAF_\fR* was commonly used in places where \fBPF_\fR* was
meant. New code should be careful to use \fBPF_\fR* as necessary.
diff --git a/usr/src/man/man5/Makefile b/usr/src/man/man5/Makefile
index d7718eedec..ead3d03a48 100644
--- a/usr/src/man/man5/Makefile
+++ b/usr/src/man/man5/Makefile
@@ -15,6 +15,7 @@
# Copyright 2018 Nexenta Systems, Inc.
# Copyright 2018 Gary Mills
# Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
+# Copyright 2022 Garrett D'Amore <garrett@dmaore.org>
#
include $(SRC)/Makefile.master
@@ -109,11 +110,6 @@ _MANFILES= Intro.5 \
mech.5 \
mnttab.5 \
mpapi.conf.5 \
- nca.if.5 \
- ncad_addr.5 \
- ncakmod.conf.5 \
- ncalogd.conf.5 \
- ncaport.conf.5 \
ndmp.5 \
ndpd.conf.5 \
netconfig.5 \
diff --git a/usr/src/man/man5/nca.if.5 b/usr/src/man/man5/nca.if.5
deleted file mode 100644
index 2ce8956464..0000000000
--- a/usr/src/man/man5/nca.if.5
+++ /dev/null
@@ -1,142 +0,0 @@
-'\" te
-.\" Copyright (C) 2003, Sun Microsystems, Inc. All Rights Reserved
-.\" 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]
-.TH NCA.IF 5 "Feb 18, 2003"
-.SH NAME
-nca.if \- the NCA configuration file that specifies physical interfaces
-.SH SYNOPSIS
-.LP
-.nf
-\fB/etc/nca/nca.if\fR
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-Specify the physical interfaces for which the Solaris Network Cache and
-Accelerator ("\fBNCA\fR") feature will be configured in the \fBnca.if\fR
-configuration file. List the physical interfaces in the file, one per line. To
-configure \fBNCA\fR to listen on all physical interfaces present on the system
-backed by a \fBhostname.{interface_name}\fR, then list only an asterik
-("\fB*\fR") in \fBnca.if\fR.
-.sp
-.LP
-When the \fBncakmod\fR(1) initialization script is invoked during system boot,
-it will attempt to configure each physical interface specified in the
-\fBnca.if\fR file by using \fBncaconfd\fR(8). Note that there must be an
-accompanying \fBhostname.{interface_name}\fR file and an entry in
-\fB/etc/hosts\fR for the contents of \fBhostname.{interface_name}\fR.
-.sp
-.LP
-You must reboot in order to implement changes to the \fBnca.if\fR file.
-.SH EXAMPLES
-.SS "x86"
-.LP
-\fBExample 1 \fR\fBnca.if\fR on x86
-.sp
-.LP
-The following is an example of an \fBnca.if\fR file that would be used on an
-x86 system:
-
-.sp
-.in +2
-.nf
-iprb1
-iprb6
-iprb8
-.fi
-.in -2
-
-.SS "SPARC"
-.LP
-\fBExample 2 \fR\fBnca.if\fR on SPARC
-.sp
-.LP
-The following is an example of an \fBnca.if\fR file that would be used on a
-SPARC system:
-
-.sp
-.in +2
-.nf
-hme2
-hme3
-hme4
-.fi
-.in -2
-
-.SS "All Platforms"
-.LP
-\fBExample 3 \fRConfiguring NCA to Listen on All Physical Interfaces
-.sp
-.LP
-The following example shows the contents of an \fBnca.if\fR file that would be
-used to configure either platform to listen on all physical interfaces present
-on the system:
-
-.sp
-.in +2
-.nf
-*
-.fi
-.in -2
-
-.SH FILES
-.sp
-.ne 2
-.na
-\fB\fB/etc/nca/nca.if\fR\fR
-.ad
-.RS 25n
-Lists the physical interfaces on which \fBNCA\fR will run.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/etc/hostname.{}{0-9}\fR\fR
-.ad
-.RS 25n
-Lists all physical interfaces configured on the server.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB/etc/hosts\fR\fR
-.ad
-.RS 25n
-Lists all host names associated with the server. Entries in this file must
-match with entries in \fB/etc/hostname.{}{0-9}\fR for \fBNCA\fR to function.
-.RE
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(7) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Interface Stability Evolving
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-.BR nca (1),
-.BR ncab2clf (1),
-.BR ncakmod (1),
-.BR ncakmod.conf (5),
-.BR ncalogd.conf (5),
-.BR attributes (7),
-.BR ifconfig (8)
-.sp
-.LP
-\fISystem Administration Guide: IP Services\fR
diff --git a/usr/src/man/man5/ncad_addr.5 b/usr/src/man/man5/ncad_addr.5
deleted file mode 100644
index f7d356a886..0000000000
--- a/usr/src/man/man5/ncad_addr.5
+++ /dev/null
@@ -1,76 +0,0 @@
-'\" te
-.\" Copyright (C) 2003, Sun Microsystems, Inc. All Rights Reserved
-.\" 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]
-.TH NCAD_ADDR 5 "April 9, 2016"
-.SH NAME
-ncad_addr \- name of the Solaris Network Cache and Accelerator (NCA) socket
-utility library
-.SH SYNOPSIS
-.LP
-.nf
-\fB/usr/lib/ncad_addr.so\fR
-.fi
-
-.SH DESCRIPTION
-.LP
-\fBncad_addr.so\fR is the Solaris Network Cache and Accelerator (\fBNCA\fR)
-socket utility library. Use this library with a web server to avoid support for
-the \fBPF_NCA\fR family type socket. The web server can take advantage of NCA
-functionality.
-.sp
-.LP
-Interpose the \fBncad_addr\fR interfaces before the interfaces in
-\fBlibsocket\fR by setting the environment variable \fBLD_PRELOAD\fR to
-\fBncad_addr.so\fR so that it is preloaded before \fBlibsocket.so.1\fR. The
-\fBncad_addr.so\fR interfaces will be interposed only if NCA is enabled. See
-\fBncakmod\fR(1).
-.SH EXAMPLES
-.LP
-\fBExample 1 \fRInterposing \fBncad_addr\fR
-.sp
-.LP
-Using Bourne shell syntax as an example, set \fBLD_PRELOAD\fR as shown below to
-interpose the \fBncad_addr\fR socket utility library:
-
-.sp
-.in +2
-.nf
-LD_PRELOAD=/usr/lib/ncad_addr.so /usr/bin/httpd
-.fi
-.in -2
-
-.SH FILES
-.ne 2
-.na
-\fB\fB/usr/lib/ncad_addr.so\fR\fR
-.ad
-.RS 25n
-\fBncad_addr\fR socket utility library shared object
-.RE
-
-.SH ATTRIBUTES
-.LP
-See \fBattributes\fR(7) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Interface Stability Unstable
-.TE
-
-.SH SEE ALSO
-.LP
-\fBnca\fR(1), \fBncab2clf\fR(1), \fBncakmod\fR(1), \fBsocket\fR(3SOCKET),
-\fBnca.if\fR(5), \fBncakmod.conf\fR(5),
-.BR attributes (7)
-.SH NOTES
-.LP
-Only applications that use the \fBNCA\fR feature, for example, web servers,
-should interpose this library.
diff --git a/usr/src/man/man5/ncakmod.conf.5 b/usr/src/man/man5/ncakmod.conf.5
deleted file mode 100644
index ab8f74af2c..0000000000
--- a/usr/src/man/man5/ncakmod.conf.5
+++ /dev/null
@@ -1,110 +0,0 @@
-'\" te
-.\" Copyright (C) 2001, Sun Microsystems, Inc. All Rights Reserved
-.\" 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]
-.TH NCAKMOD.CONF 5 "Sep 28, 2001"
-.SH NAME
-ncakmod.conf \- ncakmod configuration file
-.SH SYNOPSIS
-.LP
-.nf
-\fB/etc/nca/ncakmod.conf\fR
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-The \fBncakmod.conf\fR file is used to configure the Solaris Network Cache and
-Accelerator ("\fBNCA\fR") kernel module. The file contains two fields,
-\fBkey\fR and \fBvalue\fR.
-.sp
-.LP
-The \fBstatus\fR key is used to indicate if the user wants to have \fBNCA\fR
-turned on as a feature. If the value of \fBstatus\fR key is \fBenabled\fR,
-then the \fBNCA\fR kernel module will be pushed on to the specified interfaces.
-If the value of the \fBstatus\fR key is \fBdisabled\fR, then the \fBNCA\fR
-kernel module will not be pushed on to any interfaces . The default is
-\fBdisabled\fR.
-.sp
-.LP
-The \fBhttpd_door_path\fR key specifies the path name of the Solaris Door
-\fBRPC\fR mechanism that will be used to communicate with the \fBhttp\fR
-daemon. The default value is \fB/var/run/nca_httpd_1.door\fR.
-.sp
-.LP
-Use the \fBnca_active\fR key to indicate whether to allow NCA to actively open
-outgoing TCP connections. The default value for \fBnca_active\fR is
-\fBdisabled\fR. If set to \fBenabled\fR, \fBncaconfd\fR sets up NCA for each
-interface and then operates as a daemon, allowing NCA to make outgoing TCP
-connections. This functionality is possible only by using the doors interface
-to NCA. A web server that uses the sockets interface with \fBPF_NCA\fR or
-\fBncad_addr.so\fR cannot connect by means of \fBnca_active\fR.
-.sp
-.LP
-NCA supports the logging of in-kernel cache hits. See \fBncalogd.conf\fR(5).
-NCA stores logs in a binary format. Use the \fBncab2clf\fR(1) utility to
-convert the log from a binary format to the Common Log File format.
-.sp
-.LP
-In order to implement changes to the \fBncakmod.conf\fR file, you will need to
-reboot.
-.SH EXAMPLES
-.LP
-\fBExample 1 \fRA Sample \fBncakmod.conf\fR File
-.sp
-.LP
-The following is a sample \fBncakmod.conf\fR file:
-
-.sp
-.in +2
-.nf
-#
-# NCA Kernel Module Configuration File
-#
-status=disabled
-httpd_door_path=/var/run/nca_httpd_1.door
-nca_active=disabled
-.fi
-.in -2
-
-.SH FILES
-.sp
-.ne 2
-.na
-\fB\fB/etc/nca/ncakmod.conf\fR\fR
-.ad
-.RS 25n
-The NCA kernel module configuration file.
-.RE
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(7) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Interface Stability Evolving
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-.BR nca (1),
-.BR ncab2clf (1),
-.BR ncakmod (1),
-.BR door_create (3C),
-.BR nca.if (5),
-.BR ncad_addr (5),
-.BR ncalogd.conf (5),
-.BR attributes (7)
-.sp
-.LP
-\fISystem Administration Guide: IP Services\fR
diff --git a/usr/src/man/man5/ncalogd.conf.5 b/usr/src/man/man5/ncalogd.conf.5
deleted file mode 100644
index 8ef091eaa2..0000000000
--- a/usr/src/man/man5/ncalogd.conf.5
+++ /dev/null
@@ -1,118 +0,0 @@
-'\" te
-.\" Copyright (C) 2002, Sun Microsystems, Inc. All Rights Reserved
-.\" 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]
-.TH NCALOGD.CONF 5 "Jan 22, 2002"
-.SH NAME
-ncalogd.conf \- NCA logging configuration file
-.SH SYNOPSIS
-.LP
-.nf
-\fB/etc/nca/ncalogd.conf\fR
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-The \fBncalogd.conf\fR is used to configure Solaris Network Cache and
-Accelerator ("\fBNCA\fR") logging. The file contains two fields, \fBkey\fR and
-\fBvalue\fR.
-.sp
-.LP
-The \fBstatus\fR key is used to indicate if the user wants to have \fBNCA\fR
-logging turned on. If the value of \fBstatus\fR key is \fBenabled\fR, then
-\fBNCA\fR logging will be turned on. If the value of the \fBstatus\fR key is
-\fBdisabled\fR, then \fBNCA\fR logging will not be invoked. The default value
-is \fBdisabled\fR.
-.sp
-.LP
-The \fBlogd_path_name\fR key specifies the absolute pathname of the log file.
-The log file must be a raw device without a filesystem or a file on a local
-file system. The default value is \fB/var/nca/log\fR. \fBlogd_path_name\fR can
-also contain a whitespace-delimited list of values for multiple log files to a
-maximum of 16. If you specify multiple log files, you must enclose the list in
-quotation marks ("). With multiple files, \fBNCA\fR logging moves to the next
-file on the list once the file size specified by \fBlogd_file_size\fR has been
-reached. When the last file is full, \fBNCA\fR logging rotates back to the
-first file in the list. A pointer to the current log file is stored in
-\fB/var/nca/current\fR.
-.sp
-.LP
-The \fBlogd_file_size\fR key specifies the value of the file size, in bytes,
-allowed for each log file specified in by the \fBlogd_path_name\fR key. The
-default value is 1000000 bytes.
-.sp
-.LP
-In order to implement changes to the \fBncalogd.conf\fR file, you will need to
-stop and start NCA logging or reboot.
-.sp
-.LP
-NCA stores logs in a binary format. Use the \fBncab2clf\fR(1) utility to
-convert the log from a binary format to the Common Log File format.
-.SH EXAMPLES
-.LP
-\fBExample 1 \fRA Sample \fBncalogd.conf\fR File
-.sp
-.LP
-The following is a sample \fBncalogd.conf\fR file that specifies three log
-files:
-
-.sp
-.in +2
-.nf
-#
-# NCA Log Daemon Configuration File
-#
-
-status=enabled
-logd_path_name="/var/nca/log1 /var/nca/log2 /var/nca/log3"
-logd_file_size=1000000
-.fi
-.in -2
-
-.sp
-.LP
-Note that there is no NCA logging daemon. Logging is performed as one of the
-functions of the NCA software.
-
-.SH FILES
-.sp
-.ne 2
-.na
-\fB\fB/etc/nca/ncalogd.conf\fR\fR
-.ad
-.RS 25n
-Lists configuration parameters for \fBNCA\fRlogging.
-.RE
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(7) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Interface Stability Evolving
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-.BR nca (1),
-.BR ncab2clf (1),
-.BR ncakmod (1),
-.BR door_create (3C),
-.BR nca.if (5),
-.BR ncakmod.conf (5),
-.BR attributes (7),
-.BR dd (8)
-.sp
-.LP
-\fISystem Administration Guide: IP Services\fR
diff --git a/usr/src/man/man5/ncaport.conf.5 b/usr/src/man/man5/ncaport.conf.5
deleted file mode 100644
index 7c3f50804e..0000000000
--- a/usr/src/man/man5/ncaport.conf.5
+++ /dev/null
@@ -1,69 +0,0 @@
-'\" te
-.\" Copyright (c) 2001, Sun Microsystems, Inc. All Rights Reserved.
-.\" 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]
-.TH NCAPORT.CONF 5 "Jul 30, 2001"
-.SH NAME
-ncaport.conf \- ncaport configuration file
-.SH SYNOPSIS
-.LP
-.nf
-\fB/etc/nca/ncaport.conf\fR
-.fi
-
-.SH DESCRIPTION
-.LP
-The \fBncaport.conf\fR file is used to configure the IP addresses and ports
-that the Solaris Network Cache and Acceleration (NCA) kernel module services.
-The file contains two fields, key and value, in the format of
-\fBncaport=\fIipaddress\fR/\fIport\fR\fR. IPv4 addresses must be in the dot
-notation \fId\fR.\fId\fR.\fId\fR.\fId\fR. IPv6 addresses must be in one of the
-three conventional forms (see \fBinet_pton\fR(3C)). If an asterisk
-(\fB*\fR) is used for an IP address, it is interpreted as \fBINADDR_ANY\fR,
-which matches any IP address.
-.sp
-.LP
-A web server uses the environment variable \fBLD_PRELOAD\fR and the
-\fBncaport.conf\fR configuration file to convert an \fBAF_INET\fR socket to an
-\fBAF_NCA\fR socket. \fBLD_PRELOAD\fR enables the NCA socket utility library to
-be loaded before \fBlibsocket.so.1\fR. See the \fBncad_addr\fR(5) for details.
-When a web server issues the \fBbind\fR(3SOCKET) system call, it is intercepted
-by the interposition library \fBncad_addr.so\fR. If the bind address is in the
-\fBncaport.conf\fR file, the \fBAF_INET\fR socket is converted to a
-\fBAF_NCA\fR socket.
-.SH EXAMPLES
-.LP
-\fBExample 1 \fRSample \fBncaport.conf\fR File
-.sp
-.LP
-The following is a sample \fBncaport.conf\fR file:
-
-.sp
-.in +2
-.nf
-#
-# NCA Kernel Module Port Configuration File
-#
-ncaport=1080:0:0:0:8:800:200C:417A/100
-ncaport=192.168.84.71/80
-ncaport=*/9000
-.fi
-.in -2
-.sp
-
-.SH SEE ALSO
-.LP
-.BR nca (1),
-.BR inet_pton (3C),
-.BR bind (3SOCKET),
-.BR ncad_addr (5),
-.BR attributes (7)
-.SH NOTES
-.LP
-For those web servers that use \fBAF_NCA\fR sockets, the NCA port configuration
-described here has no effect.
-.sp
-.LP
-NCA does not currently support IPv6. Any IPv6 addresses in the file
-\fBncaport.conf\fR are ignored.
diff --git a/usr/src/man/man8/Makefile b/usr/src/man/man8/Makefile
index ab33d3c4c8..e978668679 100644
--- a/usr/src/man/man8/Makefile
+++ b/usr/src/man/man8/Makefile
@@ -19,7 +19,7 @@
# Copyright 2020 Joyent, Inc.
# Copyright 2020 Peter Tribble
# Copyright 2021 OmniOS Community Edition (OmniOSce) Association.
-# Copryight 2022 Garrett D'Amore <garrett@damore.org>
+# Copyright 2022 Garrett D'Amore
#
include $(SRC)/Makefile.master
@@ -312,7 +312,6 @@ _MANFILES= 6to4relay.8 \
mpstat.8 \
msgid.8 \
mvdir.8 \
- ncaconfd.8 \
ncheck.8 \
ncheck_ufs.8 \
ndd.8 \
diff --git a/usr/src/man/man8/ncaconfd.8 b/usr/src/man/man8/ncaconfd.8
deleted file mode 100644
index bf2bdf6872..0000000000
--- a/usr/src/man/man8/ncaconfd.8
+++ /dev/null
@@ -1,84 +0,0 @@
-'\" te
-.\" Copyright (C) 2001, Sun Microsystems, Inc.
-.\" All Rights Reserved
-.\" 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]
-.TH NCACONFD 8 "Oct 12, 2004"
-.SH NAME
-ncaconfd \- Solaris Network Cache and Accelerator (NCA) configuration daemon
-.SH SYNOPSIS
-.LP
-.nf
-\fB/usr/lib/inet/ncaconfd\fR [\fB-al\fR ] \fIinterface1 \fR [\fIinterface2 ...\fR]
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-Use the \fBncaconfd\fR utility to set up NCA on a system. At boot time, the
-\fBncakmod\fR initialization script reads in \fBnca.if\fR(5) to determine on
-which interface(s) NCA should run. \fBncaconfd\fR then sets up the interface.
-.sp
-.LP
-\fBncaconfd\fR also operates as a daemon if the \fBnca_active\fR key is set to
-enabled in \fBncakmod.conf\fR(5) file. In this case, \fBncaconfd\fR will
-continue as a daemon after all the NCA interfaces have been set up, listening
-for routing changes. The changes are then passed to NCA to control which
-interface NCA should use to make active outgoing TCP connnections.
-.SH OPTIONS
-.sp
-.LP
-The following options are supported:
-.sp
-.ne 2
-.na
-\fB\fB-a\fR\fR
-.ad
-.RS 6n
-Enable active connections.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-l\fR\fR
-.ad
-.RS 6n
-Enable logging.
-.RE
-
-.SH FILES
-.sp
-.ne 2
-.na
-\fB\fB/etc/nca/ncakmod.conf\fR\fR
-.ad
-.RS 25n
-
-.RE
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(7) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Interface Stability Evolving
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-.BR nca (1),
-.BR ncakmod (1),
-.BR nca.if (5),
-.BR ncakmod.conf (5),
-.BR attributes (7)
diff --git a/usr/src/pkg/manifests/developer-debug-mdb.p5m b/usr/src/pkg/manifests/developer-debug-mdb.p5m
index ed3f01ef70..5b58449cda 100644
--- a/usr/src/pkg/manifests/developer-debug-mdb.p5m
+++ b/usr/src/pkg/manifests/developer-debug-mdb.p5m
@@ -22,6 +22,7 @@
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2019, Joyent, Inc.
+# Copyright 2022 Garrett D'Amore
#
set name=pkg.fmri value=pkg:/developer/debug/mdb@$(PKGVERS)
@@ -55,7 +56,6 @@ file path=kernel/kmdb/$(ARCH64)/mm group=sys mode=0555
file path=kernel/kmdb/$(ARCH64)/mpt group=sys mode=0555
file path=kernel/kmdb/$(ARCH64)/mpt_sas group=sys mode=0555
file path=kernel/kmdb/$(ARCH64)/mr_sas group=sys mode=0555
-file path=kernel/kmdb/$(ARCH64)/nca group=sys mode=0555
file path=kernel/kmdb/$(ARCH64)/neti group=sys mode=0555
file path=kernel/kmdb/$(ARCH64)/nfs group=sys mode=0555
$(sparc_ONLY)link path=kernel/kmdb/$(ARCH64)/niumx target=intr
@@ -170,7 +170,6 @@ file path=usr/lib/mdb/kvm/$(ARCH64)/mm.so group=sys mode=0555
file path=usr/lib/mdb/kvm/$(ARCH64)/mpt.so group=sys mode=0555
file path=usr/lib/mdb/kvm/$(ARCH64)/mpt_sas.so group=sys mode=0555
file path=usr/lib/mdb/kvm/$(ARCH64)/mr_sas.so group=sys mode=0555
-file path=usr/lib/mdb/kvm/$(ARCH64)/nca.so group=sys mode=0555
file path=usr/lib/mdb/kvm/$(ARCH64)/neti.so group=sys mode=0555
file path=usr/lib/mdb/kvm/$(ARCH64)/nfs.so group=sys mode=0555
$(sparc_ONLY)link path=usr/lib/mdb/kvm/$(ARCH64)/niumx.so target=intr.so
diff --git a/usr/src/pkg/manifests/system-network-http-cache-accelerator.p5m b/usr/src/pkg/manifests/system-network-http-cache-accelerator.p5m
index d91d4af8f3..da10a28935 100644
--- a/usr/src/pkg/manifests/system-network-http-cache-accelerator.p5m
+++ b/usr/src/pkg/manifests/system-network-http-cache-accelerator.p5m
@@ -22,87 +22,10 @@
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+# Copyright 2022 Garrett D'Amore
#
-#
-# The default for payload-bearing actions in this package is to appear in the
-# global zone only. See the include file for greater detail, as well as
-# information about overriding the defaults.
-#
<include global_zone_only_component>
set name=pkg.fmri value=pkg:/system/network/http-cache-accelerator@$(PKGVERS)
-set name=pkg.summary value="Solaris Network Cache and Accelerator"
-set name=pkg.description \
- value="components to enable the network cache and accelerator"
-set name=info.classification value=org.opensolaris.category.2008:System/Core
+set name=pkg.obsolete value=true
set name=variant.arch value=$(ARCH)
-dir path=etc group=sys
-dir path=etc/init.d group=sys
-file path=etc/init.d/ncakmod group=sys mode=0744 \
- original_name=SUNWnca:etc/init.d/ncakmod preserve=true
-file path=etc/init.d/ncalogd group=sys mode=0744 \
- original_name=SUNWnca:etc/init.d/ncalogd preserve=true
-dir path=etc/nca group=sys
-file path=etc/nca/nca.if group=sys original_name=SUNWnca:etc/nca/nca.if \
- preserve=true
-file path=etc/nca/ncakmod.conf group=sys \
- original_name=SUNWnca:etc/nca/ncakmod.conf preserve=true
-file path=etc/nca/ncalogd.conf group=sys \
- original_name=SUNWnca:etc/nca/ncalogd.conf preserve=true
-file path=etc/nca/ncaport.conf group=sys \
- original_name=SUNWnca:etc/nca/ncaport.conf preserve=true
-dir path=etc/rc0.d group=sys
-hardlink path=etc/rc0.d/K34ncalogd target=../../etc/init.d/ncalogd
-dir path=etc/rc1.d group=sys
-hardlink path=etc/rc1.d/K34ncalogd target=../../etc/init.d/ncalogd
-dir path=etc/rc2.d group=sys
-hardlink path=etc/rc2.d/S42ncakmod target=../../etc/init.d/ncakmod
-hardlink path=etc/rc2.d/S94ncalogd target=../../etc/init.d/ncalogd
-dir path=etc/rcS.d group=sys
-hardlink path=etc/rcS.d/K34ncalogd target=../../etc/init.d/ncalogd
-dir path=etc/sock2path.d group=sys
-file path=etc/sock2path.d/system%2Fnetwork%2Fhttp%2Fcache%2Faccelerator \
- group=sys
-dir path=kernel group=sys
-dir path=kernel/drv group=sys
-dir path=kernel/drv/$(ARCH64) group=sys
-file path=kernel/drv/$(ARCH64)/nca group=sys
-file path=kernel/drv/nca.conf group=sys
-dir path=kernel/strmod group=sys
-dir path=kernel/strmod/$(ARCH64) group=sys
-hardlink path=kernel/strmod/$(ARCH64)/nca \
- target=../../../kernel/drv/$(ARCH64)/nca
-dir path=usr group=sys
-dir path=usr/bin
-file path=usr/bin/ncab2clf mode=0555
-dir path=usr/lib
-dir path=usr/lib/$(ARCH64)
-link path=usr/lib/$(ARCH64)/ncad_addr.so target=./ncad_addr.so.1
-file path=usr/lib/$(ARCH64)/ncad_addr.so.1
-dir path=usr/lib/inet
-file path=usr/lib/inet/ncaconfd mode=0555
-link path=usr/lib/ncad_addr.so target=./ncad_addr.so.1
-file path=usr/lib/ncad_addr.so.1
-dir path=usr/share/man
-dir path=usr/share/man/man1
-file path=usr/share/man/man1/nca.1
-file path=usr/share/man/man1/ncab2clf.1
-file path=usr/share/man/man1/ncakmod.1
-link path=usr/share/man/man1/snca.1 target=nca.1
-dir path=usr/share/man/man5
-file path=usr/share/man/man5/nca.if.5
-file path=usr/share/man/man5/ncad_addr.5
-file path=usr/share/man/man5/ncakmod.conf.5
-file path=usr/share/man/man5/ncalogd.conf.5
-file path=usr/share/man/man5/ncaport.conf.5
-dir path=usr/share/man/man8
-file path=usr/share/man/man8/ncaconfd.8
-driver name=nca
-legacy pkg=SUNWncar \
- desc="core components to enable the network cache and accelerator" \
- name="Solaris Network Cache and Accelerator (Root)"
-legacy pkg=SUNWncau \
- desc="components to enable the network cache and accelerator" \
- name="Solaris Network Cache and Accelerator (Usr)"
-license cr_Sun license=cr_Sun
-license lic_CDDL license=lic_CDDL
diff --git a/usr/src/uts/Makefile b/usr/src/uts/Makefile
index b21c920fce..2cc0dce6f0 100644
--- a/usr/src/uts/Makefile
+++ b/usr/src/uts/Makefile
@@ -22,6 +22,7 @@
#
# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2018 Nexenta Systems, Inc.
+# Copyright 2022 Garrett D'Amore
#
include ../Makefile.master
@@ -138,7 +139,6 @@ COMMON_HDRDIRS= common/c2 \
common/klm \
common/inet \
common/inet/ipf/netinet \
- common/inet/nca \
common/inet/sockmods/netpacket \
common/io/bpf/net \
common/io/fibre-channel/fca/qlc \
diff --git a/usr/src/uts/common/Makefile.files b/usr/src/uts/common/Makefile.files
index 8e7d5f0e06..1e9d9774b7 100644
--- a/usr/src/uts/common/Makefile.files
+++ b/usr/src/uts/common/Makefile.files
@@ -621,8 +621,6 @@ TCP_OBJS += tcpddi.o
TCP6_OBJS += tcp6ddi.o
-NCA_OBJS += ncaddi.o
-
SDP_SOCK_MOD_OBJS += sockmod_sdp.o socksdp.o socksdpsubr.o
SCTP_SOCK_MOD_OBJS += sockmod_sctp.o socksctp.o socksctpsubr.o
@@ -1282,8 +1280,7 @@ SOCK_OBJS += socksubr.o sockvfsops.o sockparams.o \
sockcommon_vnops.o sockcommon_subr.o \
sockcommon_sops.o sockcommon.o \
sock_notsupp.o socknotify.o \
- nl7c.o nl7curi.o nl7chttp.o nl7clogd.o \
- nl7cnca.o sodirect.o sockfilter.o
+ sodirect.o sockfilter.o
TMPFS_OBJS += tmp_dir.o tmp_subr.o tmp_tnode.o tmp_vfsops.o \
tmp_vnops.o
diff --git a/usr/src/uts/common/Makefile.rules b/usr/src/uts/common/Makefile.rules
index df000b61cb..ba70c5d688 100644
--- a/usr/src/uts/common/Makefile.rules
+++ b/usr/src/uts/common/Makefile.rules
@@ -530,10 +530,6 @@ $(OBJS_DIR)/%.o: $(UTSBASE)/common/inet/udp/%.c
$(COMPILE.c) -o $@ $<
$(CTFCONVERT_O)
-$(OBJS_DIR)/%.o: $(UTSBASE)/common/inet/nca/%.c
- $(COMPILE.c) -o $@ $<
- $(CTFCONVERT_O)
-
$(OBJS_DIR)/%.o: $(UTSBASE)/common/inet/sockmods/%.c
$(COMPILE.c) -o $@ $<
$(CTFCONVERT_O)
diff --git a/usr/src/uts/common/fs/sockfs/nl7c.c b/usr/src/uts/common/fs/sockfs/nl7c.c
deleted file mode 100644
index a71572cbd4..0000000000
--- a/usr/src/uts/common/fs/sockfs/nl7c.c
+++ /dev/null
@@ -1,1047 +0,0 @@
-/*
- * 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 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
- */
-
-/*
- * NL7C (Network Layer 7 Cache) as part of SOCKFS provides an in-kernel
- * gateway cache for the request/response message based L7 protocol HTTP
- * (Hypertext Transfer Protocol, see HTTP/1.1 RFC2616) in a semantically
- * transparent manner.
- *
- * Neither the requesting user agent (client, e.g. web browser) nor the
- * origin server (e.g. webserver) that provided the response cached by
- * NL7C are impacted in any way.
- *
- * Note, currently NL7C only processes HTTP messages via the embedded
- * URI of scheme http (not https nor any other), additional scheme are
- * intended to be supported as is practical such that much of the NL7C
- * framework may appear more general purpose then would be needed just
- * for an HTTP gateway cache.
- *
- * NL7C replaces NCA (Network Cache and Accelerator) and in the future
- * NCAS (NCA/SSL).
- *
- * Further, NL7C uses all NCA configuration files, see "/etc/nca/", the
- * NCA socket API, "AF_NCA", and "ndd /dev/nca" for backwards compatibility.
- */
-
-#include <sys/systm.h>
-#include <sys/strsun.h>
-#include <sys/strsubr.h>
-#include <sys/ddi.h>
-#include <sys/sunddi.h>
-#include <inet/common.h>
-#include <inet/ip.h>
-#include <inet/led.h>
-#include <inet/mi.h>
-#include <netinet/in.h>
-#include <fs/sockfs/nl7c.h>
-#include <fs/sockfs/nl7curi.h>
-#include <fs/sockfs/socktpi.h>
-
-#include <inet/nca/ncadoorhdr.h>
-#include <inet/nca/ncalogd.h>
-#include <inet/nca/ncandd.h>
-
-#include <sys/promif.h>
-
-/*
- * NL7C, NCA, NL7C logger enabled:
- */
-
-boolean_t nl7c_enabled = B_FALSE;
-
-boolean_t nl7c_logd_enabled = B_FALSE;
-boolean_t nl7c_logd_started = B_FALSE;
-boolean_t nl7c_logd_cycle = B_TRUE;
-
-/*
- * Some externs:
- */
-extern void nl7c_uri_init(void);
-extern boolean_t nl7c_logd_init(int, caddr_t *);
-extern void nl7c_nca_init(void);
-
-/*
- * nl7c_addr_t - a singly linked grounded list, pointed to by *nl7caddrs,
- * constructed at init time by parsing "/etc/nca/ncaport.conf".
- *
- * This list is searched at bind(3SOCKET) time when an application doesn't
- * explicitly set AF_NCA but instead uses AF_INET, if a match is found then
- * the underlying socket is marked sti_nl7c_flags NL7C_ENABLED.
- */
-
-typedef struct nl7c_addr_s {
- struct nl7c_addr_s *next; /* next entry */
- sa_family_t family; /* addr type, only INET and INET6 */
- uint16_t port; /* port */
- union {
- ipaddr_t v4; /* IPv4 address */
- in6_addr_t v6; /* IPv6 address */
- void *align; /* foce alignment */
- } addr; /* address */
-
- struct sonode *listener; /* listen()er's sonode */
- boolean_t temp; /* temporary addr via add_addr() ? */
-} nl7c_addr_t;
-
-nl7c_addr_t *nl7caddrs = NULL;
-
-/*
- * Called for an NL7C_ENABLED listen()er socket for the nl7c_addr_t
- * previously returned by nl7c_lookup_addr().
- */
-
-void
-nl7c_listener_addr(void *arg, struct sonode *so)
-{
- nl7c_addr_t *p = (nl7c_addr_t *)arg;
-
- if (p->listener == NULL)
- p->listener = so;
- SOTOTPI(so)->sti_nl7c_addr = arg;
-}
-
-struct sonode *
-nl7c_addr2portso(void *arg)
-{
- nl7c_addr_t *p = (nl7c_addr_t *)arg;
-
- return (p->listener);
-}
-
-void *
-nl7c_lookup_addr(void *addr, t_uscalar_t addrlen)
-{
- struct sockaddr *sap = addr;
- struct sockaddr_in *v4p = addr;
- nl7c_addr_t *p = nl7caddrs;
-
- if (sap->sa_family != AF_INET || addrlen != sizeof (*v4p)) {
- /* Only support IPv4 */
- return (B_FALSE);
- }
- while (p) {
- if (sap->sa_family == p->family &&
- v4p->sin_port == p->port &&
- (v4p->sin_addr.s_addr == p->addr.v4 ||
- p->addr.v4 == INADDR_ANY)) {
- /* Match */
- return (p);
- }
- p = p->next;
- }
- return (NULL);
-}
-
-void *
-nl7c_add_addr(void *addr, t_uscalar_t addrlen)
-{
- struct sockaddr *sap = addr;
- struct sockaddr_in *v4p = addr;
- nl7c_addr_t *new = NULL;
- nl7c_addr_t *old;
- nl7c_addr_t *p;
- boolean_t alloced;
-
- if (sap->sa_family != AF_INET || addrlen != sizeof (*v4p)) {
- /* Only support IPv4 */
- return (NULL);
- }
-again:
- p = nl7caddrs;
- while (p) {
- if (new == NULL && p->port == 0)
- new = p;
- if (sap->sa_family == p->family &&
- v4p->sin_port == p->port &&
- (v4p->sin_addr.s_addr == p->addr.v4 ||
- p->addr.v4 == INADDR_ANY)) {
- /* Match */
- return (p);
- }
- p = p->next;
- }
- if (new == NULL) {
- new = kmem_zalloc(sizeof (*new), KM_SLEEP);
- alloced = B_TRUE;
- } else
- alloced = B_FALSE;
-
- new->family = sap->sa_family;
- new->port = v4p->sin_port;
- new->addr.v4 = v4p->sin_addr.s_addr;
- new->temp = B_TRUE;
-
- if (alloced) {
- old = nl7caddrs;
- new->next = old;
- if (atomic_cas_ptr(&nl7caddrs, old, new) != old) {
- kmem_free(new, sizeof (*new));
- goto again;
- }
- }
-
- return (new);
-}
-
-boolean_t
-nl7c_close_addr(struct sonode *so)
-{
- nl7c_addr_t *p = nl7caddrs;
-
- while (p) {
- if (p->listener == so) {
- if (p->temp)
- p->port = (uint16_t)-1;
- p->listener = NULL;
- return (B_TRUE);
- }
- p = p->next;
- }
- return (B_FALSE);
-}
-
-static void
-nl7c_addr_add(nl7c_addr_t *p)
-{
- p->next = nl7caddrs;
- nl7caddrs = p;
-}
-
-void
-nl7c_mi_report_addr(mblk_t *mp)
-{
- ipaddr_t ip;
- uint16_t port;
- nl7c_addr_t *p = nl7caddrs;
- struct sonode *so;
- char addr[32];
-
- (void) mi_mpprintf(mp, "Door Up-Call-Queue IPaddr:TCPport Listenning");
- while (p) {
- if (p->port != (uint16_t)-1) {
- /* Don't report freed slots */
- ip = ntohl(p->addr.v4);
- port = ntohs(p->port);
-
- if (ip == INADDR_ANY) {
- (void) strcpy(addr, "*");
- } else {
- int a1 = (ip >> 24) & 0xFF;
- int a2 = (ip >> 16) & 0xFF;
- int a3 = (ip >> 8) & 0xFF;
- int a4 = ip & 0xFF;
-
- (void) mi_sprintf(addr, "%d.%d.%d.%d",
- a1, a2, a3, a4);
- }
- so = p->listener;
- (void) mi_mpprintf(mp, "%p %s:%d %d",
- so ? (void *)strvp2wq(SOTOV(so)) : NULL,
- addr, port, p->listener ? 1 : 0);
- }
- p = p->next;
- }
-}
-
-/*
- * Inet ASCII to binary.
- *
- * Note, it's assumed that *s is a valid zero byte terminated string, and
- * that *p is a zero initialized struct (this is important as the value of
- * INADDR_ANY and IN6ADDR_ANY is zero).
- */
-
-static int
-inet_atob(char *s, nl7c_addr_t *p)
-{
- if (strcmp(s, "*") == 0) {
- /* INADDR_ANY */
- p->family = AF_INET;
- return (0);
- }
- if (strcmp(s, "::") == 0) {
- /* IN6ADDR_ANY */
- p->family = AF_INET6;
- return (0);
- }
- /* IPv4 address ? */
- if (inet_pton(AF_INET, s, &p->addr.v4) != 1) {
- /* Nop, IPv6 address ? */
- if (inet_pton(AF_INET6, s, &p->addr.v6) != 1) {
- /* Nop, return error */
- return (1);
- }
- p->family = AF_INET6;
- } else {
- p->family = AF_INET;
- }
- return (0);
-}
-
-/*
- * Open and read each line from "/etc/nca/ncaport.conf", the syntax of a
- * ncaport.conf file line is:
- *
- * ncaport=IPaddr/Port[/Proxy]
- *
- * Where:
- *
- * ncaport - the only token recognized.
- *
- * IPaddr - an IPv4 numeric dot address (e.g. 192.168.84.71) or '*' for
- * INADDR_ANY, or an IPv6 numeric address or "::" for IN6ADDR_ANY.
- *
- * / - IPaddr/Port separator.
- *
- * Port - a TCP decimal port number.
- *
- * Note, all other lines will be ignored.
- */
-
-static void
-ncaportconf_read(void)
-{
- int ret;
- struct vnode *vp;
- char c;
- ssize_t resid;
- char buf[1024];
- char *ebp = &buf[sizeof (buf)];
- char *bp = ebp;
- offset_t off = 0;
- enum parse_e {START, TOK, ADDR, PORT, EOL} parse = START;
- nl7c_addr_t *addrp = NULL;
- char *ncaport = "ncaport";
- char string[] = "XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX:XXXX";
- char *stringp;
- char *tok;
- char *portconf = "/etc/nca/ncaport.conf";
-
- ret = vn_open(portconf, UIO_SYSSPACE, FREAD, 0, &vp, 0, 0);
- if (ret == ENOENT) {
- /* No portconf file, nothing to do */
- return;
- }
- if (ret != 0) {
- /* Error of some sort, tell'm about it */
- cmn_err(CE_WARN, "%s: open error %d", portconf, ret);
- return;
- }
- /*
- * Read portconf one buf[] at a time, parse one char at a time.
- */
- for (;;) {
- if (bp == ebp) {
- /* Nothing left in buf[], read another */
- ret = vn_rdwr(UIO_READ, vp, buf, sizeof (buf), off,
- UIO_SYSSPACE, 0, (rlim64_t)0, CRED(), &resid);
- if (ret != 0) {
- /* Error of some sort, tell'm about it */
- cmn_err(CE_WARN, "%s: read error %d",
- portconf, ret);
- break;
- }
- if (resid == sizeof (buf)) {
- /* EOF, done */
- break;
- }
- /* Initilize per buf[] state */
- bp = buf;
- ebp = &buf[sizeof (buf) - resid];
- off += sizeof (buf) - resid;
- }
- c = *bp++;
- switch (parse) {
- case START:
- /* Initilize all per file line state */
- if (addrp == NULL) {
- addrp = kmem_zalloc(sizeof (*addrp),
- KM_NOSLEEP);
- }
- tok = ncaport;
- stringp = string;
- parse = TOK;
- /*FALLTHROUGH*/
- case TOK:
- if (c == '#') {
- /* Comment through end of line */
- parse = EOL;
- break;
- }
- if (isalpha(c)) {
- if (c != *tok++) {
- /* Only know one token, skip */
- parse = EOL;
- }
- } else if (c == '=') {
- if (*tok != '\0') {
- /* Only know one token, skip */
- parse = EOL;
- break;
- }
- parse = ADDR;
- } else if (c == '\n') {
- /* Found EOL, empty line, next line */
- parse = START;
- } else {
- /* Unexpected char, skip */
- parse = EOL;
- }
- break;
-
- case ADDR:
- if (c == '/') {
- /* addr/port separator, end of addr */
- *stringp = 0;
- if (inet_atob(string, addrp)) {
- /* Bad addr, skip */
- parse = EOL;
- } else {
- stringp = string;
- parse = PORT;
- }
- } else {
- /* Save char to string */
- if (stringp ==
- &string[sizeof (string) - 1]) {
- /* Would overflow, skip */
- parse = EOL;
- } else {
- /* Copy IP addr char */
- *stringp++ = c;
- }
- }
- break;
-
- case PORT:
- if (isdigit(c)) {
- /* Save char to string */
- if (stringp ==
- &string[sizeof (string) - 1]) {
- /* Would overflow, skip */
- parse = EOL;
- } else {
- /* Copy port digit char */
- *stringp++ = c;
- }
- break;
- } else if (c == '#' || isspace(c)) {
- unsigned long result = 0;
-
- /* End of port number, convert */
- *stringp = '\0';
- if (ddi_strtoul(string, NULL, 10, &result)
- != 0) {
- parse = EOL;
- break;
- }
- addrp->port = ntohs(result);
-
- /* End of parse, add entry */
- nl7c_addr_add(addrp);
- addrp = NULL;
- parse = EOL;
- } else {
- /* Unrecognized char, skip */
- parse = EOL;
- break;
- }
- if (c == '\n') {
- /* Found EOL, start on next line */
- parse = START;
- }
- break;
-
- case EOL:
- if (c == '\n') {
- /* Found EOL, start on next line */
- parse = START;
- }
- break;
- }
-
- }
- if (addrp != NULL) {
- kmem_free(addrp, sizeof (*addrp));
- }
- (void) VOP_CLOSE(vp, FREAD, 1, (offset_t)0, CRED(), NULL);
- VN_RELE(vp);
-}
-
-/*
- * Open and read each line from "/etc/nca/ncakmod.conf" and parse looking
- * for the NCA enabled, the syntax is: status=enabled, all other lines will
- * be ignored.
- */
-
-static void
-ncakmodconf_read(void)
-{
- int ret;
- struct vnode *vp;
- char c;
- ssize_t resid;
- char buf[1024];
- char *ebp = &buf[sizeof (buf)];
- char *bp = ebp;
- offset_t off = 0;
- enum parse_e {START, TOK, EOL} parse = START;
- char *status = "status=enabled";
- char *tok;
- char *ncakmod = "/etc/nca/ncakmod.conf";
-
- ret = vn_open(ncakmod, UIO_SYSSPACE, FREAD, 0, &vp, 0, 0);
- if (ret == ENOENT) {
- /* No ncakmod file, nothing to do */
- return;
- }
- if (ret != 0) {
- /* Error of some sort, tell'm about it */
- cmn_err(CE_WARN, "%s: open error %d", status, ret);
- return;
- }
- /*
- * Read ncakmod one buf[] at a time, parse one char at a time.
- */
- for (;;) {
- if (bp == ebp) {
- /* Nothing left in buf[], read another */
- ret = vn_rdwr(UIO_READ, vp, buf, sizeof (buf), off,
- UIO_SYSSPACE, 0, (rlim64_t)0, CRED(), &resid);
- if (ret != 0) {
- /* Error of some sort, tell'm about it */
- cmn_err(CE_WARN, "%s: read error %d",
- status, ret);
- break;
- }
- if (resid == sizeof (buf)) {
- /* EOF, done */
- break;
- }
- /* Initilize per buf[] state */
- bp = buf;
- ebp = &buf[sizeof (buf) - resid];
- off += sizeof (buf) - resid;
- }
- c = *bp++;
- switch (parse) {
- case START:
- /* Initilize all per file line state */
- tok = status;
- parse = TOK;
- /*FALLTHROUGH*/
- case TOK:
- if (c == '#') {
- /* Comment through end of line */
- parse = EOL;
- break;
- }
- if (isalpha(c) || c == '=') {
- if (c != *tok++) {
- /* Only know one token, skip */
- parse = EOL;
- }
- } else if (c == '\n') {
- /*
- * Found EOL, if tok found done,
- * else start on next-line.
- */
- if (*tok == '\0') {
- nl7c_enabled = B_TRUE;
- goto done;
- }
- parse = START;
- } else {
- /* Unexpected char, skip */
- parse = EOL;
- }
- break;
-
- case EOL:
- if (c == '\n') {
- /* Found EOL, start on next line */
- parse = START;
- }
- break;
- }
-
- }
-done:
- (void) VOP_CLOSE(vp, FREAD, 1, (offset_t)0, CRED(), NULL);
- VN_RELE(vp);
-}
-
-/*
- * Open and read each line from "/etc/nca/ncalogd.conf" and parse for
- * the tokens and token text (i.e. key and value ncalogd.conf(5)):
- *
- * status=enabled
- *
- * logd_file_size=[0-9]+
- *
- * logd_file_name=["]filename( filename)*["]
- */
-
-static int file_size = 1000000;
-static caddr_t fnv[NCA_FIOV_SZ];
-
-static void
-ncalogdconf_read(void)
-{
- int ret;
- struct vnode *vp;
- char c;
- int sz;
- ssize_t resid;
- char buf[1024];
- char *ebp = &buf[sizeof (buf)];
- char *bp = ebp;
- offset_t off = 0;
- enum parse_e {START, TOK, TEXT, EOL} parse = START;
- char *tokstatus = "status\0enabled";
- char *toksize = "logd_file_size";
- char *tokfile = "logd_path_name";
- char *tokstatusp;
- char *toksizep;
- char *tokfilep;
- char *tok;
- int tokdelim = 0;
- char *ncalogd = "/etc/nca/ncalogd.conf";
- char *ncadeflog = "/var/nca/log";
- char file[TYPICALMAXPATHLEN] = {0};
- char *fp = file;
- caddr_t *fnvp = fnv;
-
- ret = vn_open(ncalogd, UIO_SYSSPACE, FREAD, 0, &vp, 0, 0);
- if (ret == ENOENT) {
- /* No ncalogd file, nothing to do */
- return;
- }
- if (ret != 0) {
- /* Error of some sort, tell'm about it */
- cmn_err(CE_WARN, "ncalogdconf_read: %s: open error(%d).",
- ncalogd, ret);
- return;
- }
- /*
- * Read ncalogd.conf one buf[] at a time, parse one char at a time.
- */
- for (;;) {
- if (bp == ebp) {
- /* Nothing left in buf[], read another */
- ret = vn_rdwr(UIO_READ, vp, buf, sizeof (buf), off,
- UIO_SYSSPACE, 0, (rlim64_t)0, CRED(), &resid);
- if (ret != 0) {
- /* Error of some sort, tell'm about it */
- cmn_err(CE_WARN, "%s: read error %d",
- ncalogd, ret);
- break;
- }
- if (resid == sizeof (buf)) {
- /* EOF, done */
- break;
- }
- /* Initilize per buf[] state */
- bp = buf;
- ebp = &buf[sizeof (buf) - resid];
- off += sizeof (buf) - resid;
- }
- c = *bp++;
- switch (parse) {
- case START:
- /* Initilize all per file line state */
- tokstatusp = tokstatus;
- toksizep = toksize;
- tokfilep = tokfile;
- tok = NULL;
- parse = TOK;
- sz = 0;
- /*FALLTHROUGH*/
- case TOK:
- if (isalpha(c) || c == '_') {
- /*
- * Found a valid tok char, if matches
- * any of the tokens continue else NULL
- * then string pointer.
- */
- if (tokstatusp != NULL && c != *tokstatusp++)
- tokstatusp = NULL;
- if (toksizep != NULL && c != *toksizep++)
- toksizep = NULL;
- if (tokfilep != NULL && c != *tokfilep++)
- tokfilep = NULL;
-
- if (tokstatusp == NULL &&
- toksizep == NULL &&
- tokfilep == NULL) {
- /*
- * All tok string pointers are NULL
- * so skip rest of line.
- */
- parse = EOL;
- }
- } else if (c == '=') {
- /*
- * Found tok separator, if tok found get
- * tok text, else skip rest of line.
- */
- if (tokstatusp != NULL && *tokstatusp == '\0')
- tok = tokstatus;
- else if (toksizep != NULL && *toksizep == '\0')
- tok = toksize;
- else if (tokfilep != NULL && *tokfilep == '\0')
- tok = tokfile;
- if (tok != NULL)
- parse = TEXT;
- else
- parse = EOL;
- } else if (c == '\n') {
- /* Found EOL, start on next line */
- parse = START;
- } else {
- /* Comment or unknown char, skip rest of line */
- parse = EOL;
- }
- break;
- case TEXT:
- if (c == '\n') {
- /*
- * Found EOL, finish up tok text processing
- * (if any) and start on next line.
- */
- if (tok == tokstatus) {
- if (*++tokstatusp == '\0')
- nl7c_logd_enabled = B_TRUE;
- } else if (tok == toksize) {
- file_size = sz;
- } else if (tok == tokfile) {
- if (tokdelim == 0) {
- /* Non delimited path name */
- *fnvp++ = strdup(file);
- } else if (fp != file) {
- /* No closing delimiter */
- /*EMPTY*/;
- }
- }
- parse = START;
- } else if (tok == tokstatus) {
- if (! isalpha(c) || *++tokstatusp == '\0' ||
- c != *tokstatusp) {
- /* Not enabled, skip line */
- parse = EOL;
- }
- } else if (tok == toksize) {
- if (isdigit(c)) {
- sz *= 10;
- sz += c - '0';
- } else {
- /* Not a decimal digit, skip line */
- parse = EOL;
- }
- } else {
- /* File name */
- if (c == '"' && tokdelim++ == 0) {
- /* Opening delimiter, skip */
- /*EMPTY*/;
- } else if (c == '"' || c == ' ') {
- /* List delim or filename separator */
- *fnvp++ = strdup(file);
- fp = file;
- } else if (fp < &file[sizeof (file) - 1]) {
- /* Filename char */
- *fp++ = c;
- } else {
- /* Filename to long, skip line */
- parse = EOL;
- }
- }
- break;
-
- case EOL:
- if (c == '\n') {
- /* Found EOL, start on next line */
- parse = START;
- }
- break;
- }
-
- }
-done:
- (void) VOP_CLOSE(vp, FREAD, 1, (offset_t)0, CRED(), NULL);
- VN_RELE(vp);
-
- if (nl7c_logd_enabled) {
- if (fnvp == fnv) {
- /*
- * No logfile was specified and found so
- * so use defualt NCA log file path.
- */
- *fnvp++ = strdup(ncadeflog);
- }
- if (fnvp < &fnv[NCA_FIOV_SZ]) {
- /* NULL terminate list */
- *fnvp = NULL;
- }
- }
-}
-
-void
-nl7clogd_startup(void)
-{
- static kmutex_t startup;
-
- /*
- * Called on the first log() attempt, have to wait until then to
- * initialize logd as at logdconf_read() the root fs is read-only.
- */
- mutex_enter(&startup);
- if (nl7c_logd_started) {
- /* Lost the race, nothing todo */
- mutex_exit(&startup);
- return;
- }
- nl7c_logd_started = B_TRUE;
- if (! nl7c_logd_init(file_size, fnv)) {
- /* Failure, disable logging */
- nl7c_logd_enabled = B_FALSE;
- cmn_err(CE_WARN, "nl7clogd_startup: failed, disabling loggin");
- mutex_exit(&startup);
- return;
- }
- mutex_exit(&startup);
-}
-
-
-void
-nl7c_startup()
-{
- /*
- * Open, read, and parse the NCA logd configuration file,
- * then initialize URI processing and NCA compat.
- */
- ncalogdconf_read();
- nl7c_uri_init();
- nl7c_nca_init();
-}
-
-void
-nl7c_init()
-{
- /* Open, read, and parse the NCA kmod configuration file */
- ncakmodconf_read();
-
- if (nl7c_enabled) {
- /*
- * NL7C is enabled so open, read, and parse
- * the NCA address/port configuration file
- * and call startup() to finish config/init.
- */
- ncaportconf_read();
- nl7c_startup();
- }
-}
-
-/*
- * The main processing function called by accept() on a newly created
- * socket prior to returning it to the caller of accept().
- *
- * Here data is read from the socket until a completed L7 request parse
- * is completed. Data will be read in the context of the user thread
- * which called accept(), when parse has been completed either B_TRUE
- * or B_FALSE will be returned.
- *
- * If NL7C successfully process the L7 protocol request, i.e. generates
- * a response, B_TRUE will be returned.
- *
- * Else, B_FALSE will be returned if NL7C can't process the request:
- *
- * 1) Couldn't locate a URI within the request.
- *
- * 2) URI scheme not reqcognized.
- *
- * 3) A request which can't be processed.
- *
- * 4) A request which could be processed but NL7C dosen't currently have
- * the response data. In which case NL7C will parse the returned response
- * from the application for possible caching for subsequent request(s).
- */
-
-volatile uint64_t nl7c_proc_cnt = 0;
-volatile uint64_t nl7c_proc_error = 0;
-volatile uint64_t nl7c_proc_ETIME = 0;
-volatile uint64_t nl7c_proc_again = 0;
-volatile uint64_t nl7c_proc_next = 0;
-volatile uint64_t nl7c_proc_rcv = 0;
-volatile uint64_t nl7c_proc_noLRI = 0;
-volatile uint64_t nl7c_proc_nodata = 0;
-volatile uint64_t nl7c_proc_parse = 0;
-
-boolean_t
-nl7c_process(struct sonode *so, boolean_t nonblocking)
-{
- vnode_t *vp = SOTOV(so);
- sotpi_info_t *sti = SOTOTPI(so);
- mblk_t *rmp = sti->sti_nl7c_rcv_mp;
- clock_t timout;
- rval_t rval;
- uchar_t pri;
- int pflag;
- int error;
- boolean_t more;
- boolean_t ret = B_FALSE;
- boolean_t first = B_TRUE;
- boolean_t pollin = (sti->sti_nl7c_flags & NL7C_POLLIN);
-
- nl7c_proc_cnt++;
-
- /* Caller has so_lock enter()ed */
- error = so_lock_read_intr(so, nonblocking ? FNDELAY|FNONBLOCK : 0);
- if (error) {
- /* Couldn't read lock, pass on this socket */
- sti->sti_nl7c_flags = 0;
- nl7c_proc_noLRI++;
- return (B_FALSE);
- }
- /* Exit so_lock for now, will be reenter()ed prior to return */
- mutex_exit(&so->so_lock);
-
- if (pollin)
- sti->sti_nl7c_flags &= ~NL7C_POLLIN;
-
- /* Initialize some kstrgetmsg() constants */
- pflag = MSG_ANY | MSG_DELAYERROR;
- pri = 0;
- if (nonblocking) {
- /* Non blocking so don't block */
- timout = 0;
- } else if (sti->sti_nl7c_flags & NL7C_SOPERSIST) {
- /* 2nd or more time(s) here so use keep-alive value */
- timout = nca_http_keep_alive_timeout;
- } else {
- /* 1st time here so use connection value */
- timout = nca_http_timeout;
- }
-
- rval.r_vals = 0;
- do {
- /*
- * First time through, if no data left over from a previous
- * kstrgetmsg() then try to get some, else just process it.
- *
- * Thereafter, rmp = NULL after the successful kstrgetmsg()
- * so try to get some new data and append to list (i.e. until
- * enough fragments are collected for a successful parse).
- */
- if (rmp == NULL) {
-
- error = kstrgetmsg(vp, &rmp, NULL, &pri, &pflag,
- timout, &rval);
- if (error) {
- if (error == ETIME) {
- /* Timeout */
- nl7c_proc_ETIME++;
- } else if (error != EWOULDBLOCK) {
- /* Error of some sort */
- nl7c_proc_error++;
- rval.r_v.r_v2 = error;
- sti->sti_nl7c_flags = 0;
- break;
- }
- error = 0;
- }
- if (rmp != NULL) {
- mblk_t *mp = sti->sti_nl7c_rcv_mp;
-
-
- if (mp == NULL) {
- /* Just new data, common case */
- sti->sti_nl7c_rcv_mp = rmp;
- } else {
- /* Add new data to tail */
- while (mp->b_cont != NULL)
- mp = mp->b_cont;
- mp->b_cont = rmp;
- }
- }
- if (sti->sti_nl7c_rcv_mp == NULL) {
- /* No data */
- nl7c_proc_nodata++;
- if (timout > 0 || (first && pollin)) {
- /* Expected data so EOF */
- ret = B_TRUE;
- } else if (sti->sti_nl7c_flags &
- NL7C_SOPERSIST) {
- /* Persistent so just checking */
- ret = B_FALSE;
- }
- break;
- }
- rmp = NULL;
- }
- first = B_FALSE;
- again:
- nl7c_proc_parse++;
-
- more = nl7c_parse(so, nonblocking, &ret);
-
- if (ret == B_TRUE && (sti->sti_nl7c_flags & NL7C_SOPERSIST)) {
- /*
- * Parse complete, cache hit, response on its way,
- * socket is persistent so try to process the next
- * request.
- */
- if (nonblocking) {
- ret = B_FALSE;
- break;
- }
- if (sti->sti_nl7c_rcv_mp) {
- /* More recv-side data, pipelined */
- nl7c_proc_again++;
- goto again;
- }
- nl7c_proc_next++;
- if (nonblocking)
- timout = 0;
- else
- timout = nca_http_keep_alive_timeout;
-
- more = B_TRUE;
- }
-
- } while (more);
-
- if (sti->sti_nl7c_rcv_mp) {
- nl7c_proc_rcv++;
- }
- sti->sti_nl7c_rcv_rval = rval.r_vals;
- /* Renter so_lock, caller called with it enter()ed */
- mutex_enter(&so->so_lock);
- so_unlock_read(so);
-
- return (ret);
-}
diff --git a/usr/src/uts/common/fs/sockfs/nl7c.h b/usr/src/uts/common/fs/sockfs/nl7c.h
deleted file mode 100644
index 6cd27c5efd..0000000000
--- a/usr/src/uts/common/fs/sockfs/nl7c.h
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * 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 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _SYS_SOCKFS_NL7C_H
-#define _SYS_SOCKFS_NL7C_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/types.h>
-#include <sys/atomic.h>
-#include <sys/cmn_err.h>
-#include <sys/stropts.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-
-
-/*
- * NCA_DEV NCA device
- *
- * NCA_INET_DEV TPI device for the INET based transport that NCA will use.
- */
-#define NCA_DEV "/dev/nca"
-#define NCA_INET_DEV "/dev/tcp"
-
-/*
- * NL7C (uint64_t)(sotpi_info_t).sti_nl7c_flags:
- */
-
-#define NL7C_ENABLED 0x00000001 /* NL7C enabled socket */
-#define NL7C_SOPERSIST 0x00000002 /* NL7C socket is persistent */
-#define NL7C_WAITWRITE 0x00000004 /* NL7C waiting first write */
-#define NL7C_AF_NCA 0x00000008 /* NL7C enabled socket via AF_NCA */
-#define NL7C_POLLIN 0x00000010 /* poll() POLLIN prior to read */
-#define NL7C_CLOSE 0x00000020 /* NL7C close needed */
-
-#define NL7C_SCHEMEPRIV 0xFFFF0000 /* NL7C scheme private state */
-
-#define NL7C_UNUSED 0xFFFFFFFF00000000 /* Unused bits */
-
-/*
- * Globals ...
- */
-
-extern boolean_t nl7c_enabled;
-extern clock_t nl7c_uri_ttl;
-
-/*
- * Function prototypes ...
- */
-
-boolean_t nl7c_process(struct sonode *, boolean_t);
-int nl7c_data(struct sonode *, uio_t *);
-void nl7c_urifree(struct sonode *);
-void nl7c_close(struct sonode *);
-boolean_t nl7c_parse(struct sonode *, boolean_t, boolean_t *);
-
-extern void *nl7c_lookup_addr(void *, t_uscalar_t);
-extern void *nl7c_add_addr(void *, t_uscalar_t);
-extern void nl7c_listener_addr(void *, struct sonode *);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _SYS_SOCKFS_NL7C_H */
diff --git a/usr/src/uts/common/fs/sockfs/nl7chttp.c b/usr/src/uts/common/fs/sockfs/nl7chttp.c
deleted file mode 100644
index e22c9d300c..0000000000
--- a/usr/src/uts/common/fs/sockfs/nl7chttp.c
+++ /dev/null
@@ -1,1948 +0,0 @@
-/*
- * 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 2009 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <sys/sysmacros.h>
-#include <sys/strsubr.h>
-#include <fs/sockfs/nl7c.h>
-#include <fs/sockfs/nl7curi.h>
-#include <fs/sockfs/socktpi.h>
-
-#include <inet/nca/ncadoorhdr.h>
-#include <inet/nca/ncalogd.h>
-
-
-volatile uint64_t nl7c_http_response_chunked = 0;
-volatile uint64_t nl7c_http_response_chunkparse = 0;
-
-volatile uint64_t nl7c_http_response_pass1 = 0;
-volatile uint64_t nl7c_http_response_pass2 = 0;
-volatile uint64_t nl7c_http_response_304 = 0;
-volatile uint64_t nl7c_http_response_307 = 0;
-volatile uint64_t nl7c_http_response_400 = 0;
-
-volatile uint64_t nl7c_http_cond_304 = 0;
-volatile uint64_t nl7c_http_cond_412 = 0;
-
-/*
- * Some externs:
- */
-
-extern uint64_t nl7c_uri_bytes;
-extern kmem_cache_t *nl7c_uri_kmc;
-extern kmem_cache_t *nl7c_uri_rd_kmc;
-extern void nl7c_uri_inactive(uri_desc_t *);
-extern uint32_t nca_major_version;
-extern uint32_t nca_minor_version;
-
-/*
- * HTTP connection persistent headers, mblk_t's, and state values stored in
- * (struct sonode *).so_nl7c_flags & NL7C_SCHEMEPRIV.
- */
-
-char Shttp_conn_cl[] = "Connection: close\r\n";
-char Shttp_conn_ka[] = "Connection: Keep-Alive\r\n";
-
-mblk_t *http_conn_cl;
-mblk_t *http_conn_ka;
-
-#define HTTP_CONN_CL 0x00010000
-#define HTTP_CONN_KA 0x00020000
-
-/*
- * Hex ascii Digit to Integer accumulate, if (char)c is a valid ascii
- * hex digit then the contents of (int32_t)n will be left shifted and
- * the new digit added in, else n will be set to -1.
- */
-
-#define hd2i(c, n) { \
- (n) *= 16; \
- if (isdigit(c)) \
- (n) += (c) - '0'; \
- else if ((c) >= 'a' && (c) <= 'f') \
- (n) += (c) - 'W'; \
- else if ((c) >= 'A' && (c) <= 'F') \
- (n) += (c) - '7'; \
- else \
- (n) = -1; \
-}
-
-/*
- * HTTP parser action values:
- */
-
-typedef enum act_e {
- REQUEST = 0x0001,
- NUMERIC = 0x0002,
- QUALIFIER = 0x0004,
- PASS = 0x0008,
- FILTER = 0x0010,
- NOCACHE = 0x0020,
- HASH = 0x0040,
- DATE = 0x0080,
- ETAG = 0x0100,
- RESPONSE = 0x0200,
- URIABS = 0x0400,
- URIREL = 0x0800,
- HEX = 0x1000
-} act_t;
-
-#define UNDEF PASS
-
-/*
- * HTTP parser token:
- */
-
-typedef struct token_s {
- int tokid; /* Token ident */
- char *text; /* Token text */
- act_t act; /* Action to take */
-} token_t;
-
-/*
- * The ttree_t (or token tree) is an ascending ordered binary tree
- * built by ttree_build() from an array of tokens and subsequently
- * used by ttree_line_parse() to parse multiline text data.
- */
-typedef struct ttree_s {
- token_t *tok; /* Token */
- struct ttree_s *lt, *gt; /* < and > next node */
-} ttree_t;
-
-/*
- * Note: req_tree[] and res_tree[] must be in ascending case insensitive
- * order of the char[] strings used to initialize each element.
- *
- * See "nl7ctokreq.txt" and "nl7ctokres.txt" which are processed by
- * "nl7ctokgen" to produce "nl7ctokgen.h" and included here.
- */
-
-#define INIT(s, t) {s, S##s, t}
-
-#include "nl7ctokgen.h"
-static ttree_t *req_tree;
-static ttree_t *res_tree;
-
-/*
- * HTTP scheme private state:
- */
-
-typedef struct http_s {
- boolean_t parsed; /* Response parsed */
- uint32_t major, minor; /* HTTP/major.minor */
- uint32_t headlen; /* HTTP header length */
- clock_t date; /* Response Date: */
- clock_t expire; /* Response Expire: */
- clock_t moddate; /* Request *Modified-Since date */
- enum tokid_e modtokid; /* Request *Modified-Since tokid */
- time_t lastmod; /* Response Last-Modified: */
- str_t accept; /* Request Accept: */
- str_t acceptchar; /* Request Accept-Charset: */
- str_t acceptenco; /* Request Accept-Encoding: */
- str_t acceptlang; /* Request Accept-Language: */
- str_t etag; /* Request/Response ETag: */
- str_t uagent; /* Request User-Agent: */
-} http_t;
-
-static kmem_cache_t *http_kmc;
-
-/*
- * HTTP date routines, dow[] for day of the week, Dow[] for day of the
- * week for the Unix epoch (i.e. day 0 is a Thu), months[] for the months
- * of the year, and dom[] for day number of the year for the first day
- * of each month (non leap year).
- */
-
-static char *dow[] = {"sunday", "monday", "tuesday", "wednesday", "thursday",
- "friday", "saturday", 0};
-
-static char *Dow[] = {"Thu", "Fri", "Sat", "Sun", "Mon", "Tue", "Wed", 0};
-
-static char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul",
- "Aug", "Sep", "Oct", "Nov", "Dec", 0};
-
-static int dom[] = {0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334};
-
-/*
- * http_date2time_t(const char *) - returns the time(2) value (i.e.
- * the value 0 is Thu, 01 Jan 1970 00:00:00 GMT) for the following
- * time formats used by HTTP request and response headers:
- *
- * 1) Sun, 07 Dec 1998 14:49:37 GMT ; RFC 822, updated by RFC 1123
- * 2) Sunday, 07-Dec-98 14:49:37 GMT ; RFC 850, obsoleted by RFC 1036
- * 3) Sun Nov 7 14:49:37 1998 ; ANSI C's asctime() format
- * 4) 60 ; Time delta of N seconds
- *
- * On error a time_t value of -1 is returned.
- *
- * All dates are GMT (must be part of the date string for types
- * 1 and 2 and not for type 1).
- *
- * Note, the given mstr_t pointed to by *sp will be modified.
- */
-
-static time_t
-http_date2time_t(char *cp, char *ep)
-{
- char *scp = cp;
- time_t secs;
- char **tpp;
- char *tp;
- char c, sc;
- ssize_t n;
-
- ssize_t zeroleap = 1970 / 4 - 1970 / 100 + 1970 / 400;
- ssize_t leap;
- ssize_t year;
- ssize_t month;
- ssize_t day;
- ssize_t hour;
- ssize_t min;
- ssize_t sec;
-
- /* Parse and skip day-of-week (we don't use it) */
- tpp = dow;
- tp = *tpp;
- n = 0;
- while (cp < ep) {
- c = *cp++;
- if (c == ',' || c == ' ')
- break;
- c = tolower(c);
- if (*tp == 0 || *tp != c) {
- cp = scp;
- if ((tp = *++tpp) == NULL)
- break;
- continue;
- }
- tp++;
- }
- if (cp == NULL) {
- /* Not case 1-3, try 4 */
- while (cp < ep) {
- c = *cp;
- if (isdigit(c)) {
- cp++;
- n *= 10;
- n += c - '0';
- continue;
- }
- /* An invalid date sytax */
- return (-1);
- }
- /* Case 4, delta from current time */
- return (gethrestime_sec() + n);
- }
- if (c == ',') {
- /* Case 1 or 2, skip <SP> */
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (c != ' ')
- return (-1);
- /* Get day of the month */
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n = c - '0';
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n *= 10;
- n += c - '0';
- day = n;
- /* Get day/month/year seperator */
- if (cp == ep)
- return (-1);
- sc = *cp++;
- if (sc != ' ' && sc != '-')
- return (-1);
- /* Parse month */
- tpp = months;
- tp = *tpp++;
- scp = cp;
- n = 0;
- while (cp < ep) {
- c = *cp;
- if (c == sc) {
- cp++;
- break;
- }
- c = tolower(c);
- if (*tp == 0 || tolower(*tp) != c) {
- if ((tp = *tpp++) == NULL)
- break;
- cp = scp;
- n++;
- continue;
- }
- cp++;
- tp++;
- }
- if (cp == NULL)
- return (-1);
- month = n;
- /* Get year */
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n = c - '0';
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n *= 10;
- n += c - '0';
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (sc == ' ') {
- /* Case 1, get 2 more year digits */
- if (! isdigit(c))
- return (-1);
- n *= 10;
- n += c - '0';
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n *= 10;
- n += c - '0';
- /* Get seperator char */
- if (cp == ep)
- return (-1);
- c = *cp;
- if (c != ' ')
- return (-1);
- cp++;
- } else {
- /*
- * Case 2, 2 digit year and as this is a so-called
- * Unix date format and the begining of time was
- * 1970 so we can extend this obsoleted date syntax
- * past the year 1999 into the year 2038 for 32 bit
- * machines and through 2069 for 64 bit machines.
- */
- if (n > 69)
- n += 1900;
- else
- n += 2000;
- }
- year = n;
- /* Get GMT time */
- if (c != ' ')
- return (-1);
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n = c - '0';
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n *= 10;
- n += c - '0';
- hour = n;
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (c != ':')
- return (-1);
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n = c - '0';
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n *= 10;
- n += c - '0';
- min = n;
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (c != ':')
- return (-1);
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n = c - '0';
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n *= 10;
- n += c - '0';
- sec = n;
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (c != ' ')
- return (-1);
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (c != 'G')
- return (-1);
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (c != 'M')
- return (-1);
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (c != 'T')
- return (-1);
- } else {
- /* case 3, parse month */
- sc = c;
- tpp = months;
- tp = *tpp++;
- scp = cp;
- n = 0;
- while (cp < ep) {
- c = *cp;
- if (c == sc) {
- cp++;
- break;
- }
- c = tolower(c);
- if (*tp == 0 || tolower(*tp) != c) {
- if ((tp = *tpp++) == NULL)
- break;
- cp = scp;
- n++;
- continue;
- }
- cp++;
- tp++;
- }
- if (cp == NULL)
- return (-1);
- month = n;
- /* Get day of the month */
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n = c - '0';
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n *= 10;
- n += c - '0';
- day = n;
- /* Skip <SP> */
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (c != ' ')
- return (-1);
- /* Get time */
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n = c - '0';
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n *= 10;
- n += c - '0';
- hour = n;
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (c != ':')
- return (-1);
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n = c - '0';
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n *= 10;
- n += c - '0';
- min = n;
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (c != ':')
- return (-1);
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n = c - '0';
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n *= 10;
- n += c - '0';
- sec = n;
- /* Skip <SP> */
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (c != ' ')
- return (-1);
- /* Get year */
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n = c - '0';
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n *= 10;
- n += c - '0';
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n *= 10;
- n += c - '0';
- if (cp == ep)
- return (-1);
- c = *cp++;
- if (! isdigit(c))
- return (-1);
- n *= 10;
- n += c - '0';
- year = n;
- }
-
- /* Last, caclulate seconds since Unix day zero */
- leap = year;
- if (month < 2)
- leap--;
- leap = leap / 4 - leap / 100 + leap / 400 - zeroleap;
- secs = ((((year - 1970) * 365 + dom[month] + day - 1 + leap) * 24
- + hour) * 60 + min) * 60 + sec;
-
- return (secs);
-}
-
-/*
- * http_today(char *) - returns in the given char* pointer the current
- * date in ascii with a format of (char [29]):
- *
- * Sun, 07 Dec 1998 14:49:37 GMT ; RFC 822, updated by RFC 1123
- */
-
-static void
-http_today(char *cp)
-{
- ssize_t i;
- char *fp;
-
- ssize_t leap;
- ssize_t year;
- ssize_t month;
- ssize_t dow;
- ssize_t day;
- ssize_t hour;
- ssize_t min;
- ssize_t sec;
-
- /* Secs since Thu, 01 Jan 1970 00:00:00 GMT */
- time_t now = gethrestime_sec();
-
- sec = now % 60;
- now /= 60;
- min = now % 60;
- now /= 60;
- hour = now % 24;
- now /= 24;
- dow = now % 7;
-
- year = 1970;
- for (;;) {
- if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
- day = 366;
- else
- day = 365;
- if (now < day)
- break;
- now -= day;
- year++;
- }
-
- now++;
- if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
- leap = 1;
- else
- leap = 0;
- month = 11;
- for (i = 11; i; i--) {
- if (i < 2)
- leap = 0;
- if (now > dom[i] + leap)
- break;
- month--;
- }
- day = now - dom[i] - leap;
-
- fp = Dow[dow];
- *cp++ = *fp++;
- *cp++ = *fp++;
- *cp++ = *fp++;
- *cp++ = ',';
- *cp++ = ' ';
-
- i = day / 10;
- *cp++ = '0' + i;
- *cp++ = '0' + (day - i * 10);
- *cp++ = ' ';
-
- fp = months[month];
- *cp++ = *fp++;
- *cp++ = *fp++;
- *cp++ = *fp++;
- *cp++ = ' ';
-
- i = year / 1000;
- *cp++ = '0' + i;
- year -= i * 1000;
- i = year / 100;
- *cp++ = '0' + i;
- year -= i * 100;
- i = year / 10;
- *cp++ = '0' + i;
- year -= i * 10;
- *cp++ = '0' + year;
- *cp++ = ' ';
-
- i = hour / 10;
- *cp++ = '0' + i;
- *cp++ = '0' + (hour - i * 10);
- *cp++ = ':';
-
- i = min / 10;
- *cp++ = '0' + i;
- *cp++ = '0' + (min - i * 10);
- *cp++ = ':';
-
- i = sec / 10;
- *cp++ = '0' + i;
- *cp++ = '0' + (sec - i * 10);
- *cp++ = ' ';
-
- *cp++ = 'G';
- *cp++ = 'M';
- *cp = 'T';
-}
-
-/*
- * Given the ttree_t pointer "*t", parse the char buffer pointed to
- * by "**cpp" of multiline text data up to the pointer "**epp", the
- * pointer "*hash" points to the current text hash.
- *
- * If a match is found a pointer to the ttree_t token will be returned,
- * "**cpp" will point to the next line, "**epp" will point to the first
- * EOL char, "**hpp" will point to remainder of the parse data (if none,
- * **hpp == **epp), and "*hash" will be updated.
- *
- * If no match, as above except "**hpp" points to the begining of the
- * line and "*hash" wont be updated.
- *
- * If no EOL is found NULL is returned, "**epp" is set to NULL, no further
- * calls can be made until additional data is ready and all arguments are
- * reset.
- *
- * If EOH (i.e. an empty line) NULL is returned, "**hpp" is set to NULL,
- * *cpp points to past EOH, no further calls can be made.
- */
-
-static token_t *
-ttree_line_parse(ttree_t *t, char **cpp, char **epp, char **hpp, uint32_t *hash)
-{
- char ca, cb; /* current line <=> parse node */
-
- char *cp = *cpp;
- char *ep = *epp;
-
- char *tp = t->tok->text; /* current parse text */
- char *sp = cp; /* saved *cp */
-
- int parse; /* parse state */
-
- uint32_t hv; /* hash value */
-
- if (hash != NULL)
- hv = *hash;
-
- /* Special case, check for EOH (i.e. empty line) */
- if (cp < ep) {
- ca = *cp;
- if (ca == '\n') {
- /* End of header */
- *cpp = ++cp;
- *hpp = NULL;
- return (NULL);
- } else if (ca == '\r') {
- cp++;
- if (cp < ep) {
- ca = *cp;
- if (ca == '\n') {
- /* End of header */
- *cpp = ++cp;
- *hpp = NULL;
- return (NULL);
- }
- }
- cp = *cpp;
- }
- }
- while (cp < ep) {
- /* Get next parse text char */
- cb = *tp;
- if (cb != 0) {
- /* Get next current line char */
- ca = *cp++;
- /* Case insensitive */
- cb = tolower(cb);
- ca = tolower(ca);
- if (ca == cb) {
- /*
- * Char match, next char.
- *
- * Note, parse text can contain EOL chars.
- */
- tp++;
- continue;
- }
- if (ca == '\r' || ca == '\n') {
- /* EOL, always go less than */
- t = t->lt;
- } else if (ca < cb) {
- /* Go less than */
- t = t->lt;
- } else {
- /* Go greater than */
- t = t->gt;
- }
- while (t != NULL && t->tok == NULL) {
- /* Null node, so descend to < node */
- t = t->lt;
- }
- if (t != NULL) {
- /* Initialize for next node compare */
- tp = t->tok->text;
- cp = sp;
- continue;
- }
- /*
- * End of tree walk, no match, return pointer
- * to the start of line then below find EOL.
- */
- *hpp = *cpp;
- } else {
- /*
- * End of token text, match, return pointer to
- * the rest of header text then below find EOL.
- */
- *hpp = cp;
- }
- /*
- * Find end of line. Note, the HTTP line syntax supports
- * implicit multi-line if the next line starts with a <SP>
- * or <HT>.
- */
- parse = 0;
- while (cp < ep) {
- ca = *cp;
- if (parse == 0 && ca == '\r') {
- *epp = cp;
- parse = 1;
- } else if (parse == 0 && ca == '\n') {
- *epp = cp;
- parse = 2;
- } else if (parse == 1 && ca == '\n') {
- parse = 2;
- } else if (parse >= 2 && (ca == ' ' || ca == '\t')) {
- parse++;
- } else if (parse > 2) {
- parse = 0;
- } else if (parse == 2) {
- break;
- } else if (t != NULL && (t->tok->act & HASH) &&
- hash != NULL) {
- CHASH(hv, ca);
- }
- cp++;
- }
- if (parse < 2) {
- /* No EOL, not enough data */
- *epp = NULL;
- return (t != NULL ? t->tok : NULL);
- }
- /*
- * Return updated hash value (if any), update parse current
- * pointer for next call (i.e. begin of next line), and last
- * return pointer to the matching token_t.
- */
- if (t != NULL && (t->tok->act & HASH) && hash != NULL)
- *hash = hv;
- *cpp = cp;
- return (t != NULL ? t->tok : NULL);
- }
- /*
- * End of parse text, ...
- */
- *epp = NULL;
- return (NULL);
-}
-
-/*
- * Given a NULL terminated array of token_t(s) ordered in ascending
- * case insensitive order a binary tree is allocated and populated with
- * pointers into the array and a pointer to the root node is returned.
- *
- * Todo, for maximum ttree parse efficiency needs to be path compressed,
- * the function ttree_line_parse() handles the empty nodes correctly.
- */
-static ttree_t *
-ttree_build(token_t *list, int sz)
-{
- ttree_t *treev;
- int max, lvl, inc, ix;
-
- /* calc the size of the tree */
- for (max = 1; max < sz; max <<= 1)
- ;
- /* allocate the tree */
- treev = kmem_alloc(sizeof (*treev) * (max - 1), KM_SLEEP);
-
- /* walk the tree and populate from list vector */
- lvl = max;
- while (lvl >>= 1) {
- inc = lvl >> 1;
- for (ix = lvl; ix < max; ix += lvl << 1) {
- if (ix <= sz) {
- treev[ix - 1].tok = &list[ix - 1];
- } else {
- treev[ix - 1].tok = 0;
- }
- if (inc) {
- treev[ix - 1].lt = &treev[ix - inc - 1];
- treev[ix - 1].gt = &treev[ix + inc - 1];
- } else {
- treev[ix - 1].lt = 0;
- treev[ix - 1].gt = 0;
- }
- }
- }
-
- return (&treev[(max >> 1) - 1]);
-}
-
-void
-nl7c_http_init(void)
-{
- int n;
-
- http_kmc = kmem_cache_create("NL7C_http_kmc",
- sizeof (http_t), 0, NULL, NULL, NULL, NULL, NULL, 0);
-
- req_tree = ttree_build(tokreq, tokreq_cnt - 1);
- res_tree = ttree_build(tokres, tokres_cnt - 1);
-
- n = sizeof (Shttp_conn_cl) - 1;
- http_conn_cl = allocb_wait(n, BPRI_HI, STR_NOSIG, NULL);
- bcopy(Shttp_conn_cl, http_conn_cl->b_rptr, n);
- http_conn_cl->b_wptr += n;
-
- n = sizeof (Shttp_conn_ka) - 1;
- http_conn_ka = allocb_wait(n, BPRI_HI, STR_NOSIG, NULL);
- bcopy(Shttp_conn_ka, http_conn_ka->b_rptr, n);
- http_conn_ka->b_wptr += n;
-}
-
-void
-nl7c_http_free(void *arg)
-{
- http_t *http = arg;
-
- kmem_cache_free(http_kmc, http);
-}
-
-#define STR_T_NOTCMP_OPT(a, b, m) ( \
- a->m.cp && b->m.cp && \
- ((a->m.ep - a->m.cp) != (b->m.ep - b->m.cp) || \
- strncmp(a->m.cp, b->m.cp, (b->m.ep - b->m.cp))))
-
-#define STR_T_NOTCMP(a, b, m) ( \
- a->m.cp && ! b->m.cp || \
- b->m.cp && ! a->m.cp || \
- STR_T_NOTCMP_OPT(a, b, m))
-
-boolean_t
-nl7c_http_cmp(void *arg1, void *arg2)
-{
- http_t *httpa = arg1; /* Response */
- http_t *httpb = arg2; /* Request */
-
- if (httpa->major != httpb->major ||
- httpa->minor != httpb->minor ||
- STR_T_NOTCMP(httpa, httpb, accept) ||
- STR_T_NOTCMP(httpa, httpb, acceptchar) ||
- STR_T_NOTCMP(httpa, httpb, acceptenco) ||
- STR_T_NOTCMP(httpa, httpb, acceptlang) ||
- STR_T_NOTCMP_OPT(httpa, httpb, etag))
- return (B_FALSE);
- return (B_TRUE);
-}
-
-/*
- * In-line HTTP responses:
- */
-
-static char http_resp_304[] =
- "HTTP/#.# 304 Not Modified\r\n"
- "Date: #############################\r\n"
- "Server: NCA/#.# (Solaris)\r\n";
-
-static char http_resp_412[] =
- "HTTP/#.# 412 Precondition Failed\r\n"
- "Date: #############################\r\n"
- "Server: NCA/#.# (Solaris)\r\n";
-
-static uri_desc_t *
-http_mkresponse(uri_desc_t *req, uri_desc_t *res, char *proto, int sz)
-{
- http_t *qhttp = req->scheme;
- http_t *shttp = res->scheme;
- uri_desc_t *uri = kmem_cache_alloc(nl7c_uri_kmc, KM_SLEEP);
- char *alloc;
- char *cp;
- char *ep = &proto[sz];
- uri_rd_t *rdp;
- int cnt;
-
- char hdr_etag[] = "ETag: ";
-
- /* Any optional header(s) */
- if (shttp->etag.cp != NULL) {
- /* Response has an ETag:, count it */
- sz += sizeof (hdr_etag) - 1 +
- (shttp->etag.ep - shttp->etag.cp) + 2;
- }
- sz += 2;
- alloc = kmem_alloc(sz, KM_SLEEP);
-
- /* Minimum temp uri initialization as needed by uri_response() */
- REF_INIT(uri, 1, nl7c_uri_inactive, nl7c_uri_kmc);
- uri->hash = URI_TEMP;
- uri->tail = NULL;
- uri->scheme = NULL;
- uri->reqmp = NULL;
- uri->count = 0;
- cv_init(&uri->waiting, NULL, CV_DEFAULT, NULL);
- mutex_init(&uri->proclock, NULL, MUTEX_DEFAULT, NULL);
-
- URI_RD_ADD(uri, rdp, sz, -1);
- rdp->data.kmem = alloc;
- atomic_add_64(&nl7c_uri_bytes, sz);
-
- cp = alloc;
- if (qhttp->major == 1) {
- /*
- * Full response format.
- *
- * Copy to first sub char '#'.
- */
- while (proto < ep) {
- if (*proto == '#')
- break;
- *cp++ = *proto++;
- }
-
- /* Process the HTTP version substitutions */
- if (*proto != '#') goto bad;
- *cp++ = '0' + qhttp->major;
- proto++;
- while (proto < ep) {
- if (*proto == '#')
- break;
- *cp++ = *proto++;
- }
- if (*proto != '#') goto bad;
- *cp++ = '0' + qhttp->minor;
- proto++;
-
- /* Copy to the next sub char '#' */
- while (proto < ep) {
- if (*proto == '#')
- break;
- *cp++ = *proto++;
- }
-
- /* Process the "Date: " substitution */
- if (*proto != '#') goto bad;
- http_today(cp);
-
- /* Skip to the next nonsub char '#' */
- while (proto < ep) {
- if (*proto != '#')
- break;
- cp++;
- proto++;
- }
-
- /* Copy to the next sub char '#' */
- while (proto < ep) {
- if (*proto == '#')
- break;
- *cp++ = *proto++;
- }
-
- /* Process the NCA version substitutions */
- if (*proto != '#') goto bad;
- *cp++ = '0' + nca_major_version;
- proto++;
- while (proto < ep) {
- if (*proto == '#')
- break;
- *cp++ = *proto++;
- }
- if (*proto != '#') goto bad;
- *cp++ = '0' + nca_minor_version;
- proto++;
-
- /* Copy remainder of HTTP header */
- while (proto < ep) {
- *cp++ = *proto++;
- }
- } else {
- goto bad;
- }
- /* Any optional header(s) */
- if (shttp->etag.cp != NULL) {
- /* Response has an ETag:, add it */
- cnt = sizeof (hdr_etag) - 1;
- bcopy(hdr_etag, cp, cnt);
- cp += cnt;
- cnt = (shttp->etag.ep - shttp->etag.cp);
- bcopy(shttp->etag.cp, cp, cnt);
- cp += cnt;
- *cp++ = '\r';
- *cp++ = '\n';
- }
- /* Last, add empty line */
- uri->eoh = cp;
- *cp++ = '\r';
- *cp = '\n';
-
- return (uri);
-
-bad:
- /*
- * Free any resources allocated here, note that while we could
- * use the uri_inactive() to free the uri by doing a REF_RELE()
- * we instead free it here as the URI may be in less then a fully
- * initialized state.
- */
- kmem_free(alloc, sz);
- kmem_cache_free(nl7c_uri_kmc, uri);
- return (NULL);
-}
-
-uri_desc_t *
-nl7c_http_cond(uri_desc_t *req, uri_desc_t *res)
-{
- http_t *qhttp = req->scheme;
- time_t qdate = qhttp->moddate;
- http_t *shttp = res->scheme;
- time_t sdate = shttp->lastmod == -1 ? shttp->date : shttp->lastmod;
- uri_desc_t *uri;
-
- if (qhttp->modtokid == Qhdr_If_Modified_Since &&
- sdate != -1 && qdate != -1 && sdate <= qdate) {
- /*
- * Request is If-Modified-Since: and both response
- * and request dates are valid and response is the
- * same age as request so return a 304 response uri
- * instead of the cached response.
- */
- nl7c_http_cond_304++;
- uri = http_mkresponse(req, res, http_resp_304,
- sizeof (http_resp_304) - 1);
- if (uri != NULL) {
- /* New response uri */
- REF_RELE(res);
- return (uri);
- }
- return (res);
- } else if (qhttp->modtokid == Qhdr_If_Unmodified_Since &&
- sdate != -1 && qdate != -1 && sdate >= qdate) {
- /*
- * Request is If-Unmodified-Since: and both response
- * and request dates are valid and response is not the
- * same age as the request so return a 412 response
- * uri instead of the cached response.
- */
- nl7c_http_cond_412++;
- uri = http_mkresponse(req, res, http_resp_412,
- sizeof (http_resp_412) - 1);
- if (uri != NULL) {
- /* New response uri */
- REF_RELE(res);
- return (uri);
- }
- return (res);
- }
- /*
- * No conditional response meet or unknown type or no
- * valid dates so just return the original uri response.
- */
- return (res);
-}
-
-/*
- * Return the appropriate HTTP connection persist header
- * based on the request HTTP persistent header state.
- */
-
-mblk_t *
-nl7c_http_persist(struct sonode *so)
-{
- uint64_t flags = SOTOTPI(so)->sti_nl7c_flags & NL7C_SCHEMEPRIV;
- mblk_t *mp;
-
- if (flags & HTTP_CONN_CL)
- mp = dupb(http_conn_cl);
- else if (flags & HTTP_CONN_KA)
- mp = dupb(http_conn_ka);
- else
- mp = NULL;
- return (mp);
-}
-
-/*
- * Parse the buffer *p of size len and update the uri_desc_t *uri and our
- * http_t *http with the results.
- */
-
-boolean_t
-nl7c_http_request(char **cpp, char *ep, uri_desc_t *uri, struct sonode *so)
-{
- sotpi_info_t *sti = SOTOTPI(so);
- http_t *http = kmem_cache_alloc(http_kmc, KM_SLEEP);
- char *cp = *cpp;
- char *hp;
- char *scp, *sep;
- char *HTTP = "HTTP/";
- token_t *match;
- boolean_t persist = B_FALSE;
-
- ASSERT(cp <= ep);
-
- if (cp == ep) {
- goto bad;
- }
- /*
- * Initialize any uri_desc_t and/or http_t members.
- */
- uri->scheme = (void *)http;
- uri->auth.cp = NULL;
- uri->auth.ep = NULL;
- uri->resplen = URI_LEN_NOVALUE;
- uri->respclen = URI_LEN_NOVALUE;
- uri->eoh = NULL;
- uri->nocache = B_FALSE;
- uri->conditional = B_FALSE;
- http->parsed = B_FALSE;
- http->accept.cp = NULL;
- http->acceptchar.cp = NULL;
- http->acceptenco.cp = NULL;
- http->acceptlang.cp = NULL;
- http->etag.cp = NULL;
- http->uagent.cp = NULL;
- http->date = -1;
- http->expire = -1;
- http->lastmod = -1;
- if (*cp == '\r') {
- /*
- * Special case for a Request-Line without an HTTP version,
- * assume it's an old style, i.e. HTTP version 0.9 request.
- */
- http->major = 0;
- http->minor = 9;
- goto got_version;
- }
- /*
- * Skip URI path delimiter, must be a <SP>.
- */
- if (*cp++ != ' ')
- /* Unkown or bad Request-Line format, just punt */
- goto bad;
- /*
- * The URI parser has parsed through the URI and the <SP>
- * delimiter, parse the HTTP/N.N version
- */
- while (cp < ep && *HTTP == *cp) {
- HTTP++;
- cp++;
- }
- if (*HTTP != 0) {
- if (cp == ep)
- goto more;
- goto bad;
- }
- if (cp == ep)
- goto more;
- if (*cp < '0' || *cp > '9')
- goto bad;
- http->major = *cp++ - '0';
- if (cp == ep)
- goto more;
- if (*cp++ != '.')
- goto bad;
- if (cp == ep)
- goto more;
- if (*cp < '0' || *cp > '9')
- goto bad;
- http->minor = *cp++ - '0';
- if (cp == ep)
- goto more;
-
-got_version:
-
- if (*cp++ != '\r')
- goto bad;
- if (cp == ep)
- goto more;
- if (*cp++ != '\n')
- goto bad;
- /*
- * Initialize persistent state based on HTTP version.
- */
- if (http->major == 1) {
- if (http->minor >= 1) {
- /* 1.1 persistent by default */
- persist = B_TRUE;
- } else {
- /* 1.0 isn't persistent by default */
- persist = B_FALSE;
- }
- } else if (http->major == 0) {
- /* Before 1.0 no persistent connections */
- persist = B_FALSE;
- } else {
- /* >= 2.0 not supported (yet) */
- goto bad;
- }
- /*
- * Parse HTTP headers through the EOH
- * (End Of Header, i.e. an empty line).
- */
- for (sep = ep; cp < ep; ep = sep) {
- /* Get the next line */
- scp = cp;
- match = ttree_line_parse(req_tree, &cp, &ep, &hp, &uri->hvalue);
- if (match != NULL) {
- if (match->act & QUALIFIER) {
- /*
- * Header field text is used to qualify this
- * request/response, based on qualifier type
- * optionally convert and store *http.
- */
- char c;
- int n = 0;
- time_t secs;
-
- ASSERT(hp != NULL && ep != NULL);
-
- if (match->act & NUMERIC) {
- while (hp < ep) {
- c = *hp++;
- if (! isdigit(c))
- goto bad;
- n *= 10;
- n += c - '0';
- }
- } else if (match->act & DATE) {
- secs = http_date2time_t(hp, ep);
- }
- switch (match->tokid) {
-
- case Qhdr_Accept_Charset:
- http->acceptchar.cp = hp;
- http->acceptchar.ep = ep;
- break;
-
- case Qhdr_Accept_Encoding:
- http->acceptenco.cp = hp;
- http->acceptenco.ep = ep;
- break;
-
- case Qhdr_Accept_Language:
- http->acceptlang.cp = hp;
- http->acceptlang.ep = ep;
- break;
-
- case Qhdr_Accept:
- http->accept.cp = hp;
- http->accept.ep = ep;
- break;
-
- case Qhdr_Authorization:
- goto pass;
-
- case Qhdr_Connection_close:
- persist = B_FALSE;
- break;
-
- case Qhdr_Connection_Keep_Alive:
- persist = B_TRUE;
- break;
-
- case Qhdr_Date:
- http->date = secs;
- break;
-
- case Qhdr_ETag:
- http->etag.cp = hp;
- http->etag.ep = ep;
- break;
-
- case Qhdr_Host:
- uri->auth.cp = hp;
- uri->auth.ep = ep;
- break;
-
- case Qhdr_If_Modified_Since:
- case Qhdr_If_Unmodified_Since:
- http->moddate = secs;
- http->modtokid = match->tokid;
- uri->conditional = B_TRUE;
- break;
-
- case Qhdr_Keep_Alive:
- persist = B_TRUE;
- break;
-
- case Qhdr_User_Agent:
- http->uagent.cp = hp;
- http->uagent.ep = ep;
- break;
-
- default:
- break;
-
- };
- }
- if (match->act & FILTER) {
- /*
- * Filter header, do a copyover the header
- * text, guarenteed to be at least 1 byte.
- */
- char *cop = scp;
- int n = (ep - cop) - 1;
- char filter[] = "NL7C-Filtered";
-
- n = MIN(n, sizeof (filter) - 1);
- if (n > 0)
- bcopy(filter, cop, n);
- cop += n;
- ASSERT(cop < ep);
- *cop++ = ':';
- while (cop < ep)
- *cop++ = ' ';
- }
- if (match->act & NOCACHE) {
- uri->nocache = B_TRUE;
- }
- } else if (hp == NULL) {
- goto done;
- } else if (ep == NULL) {
- goto more;
- }
- }
- /* No EOH found */
- goto more;
-
-done:
- /*
- * Initialize socket persist state and response persist type
- * flag based on the persist state of the request headers.
- *
- */
- if (persist)
- sti->sti_nl7c_flags |= NL7C_SOPERSIST;
- else
- sti->sti_nl7c_flags &= ~NL7C_SOPERSIST;
-
- if (http->major == 1) {
- sti->sti_nl7c_flags &= ~NL7C_SCHEMEPRIV;
- if (http->minor >= 1) {
- if (! persist)
- sti->sti_nl7c_flags |= HTTP_CONN_CL;
- } else {
- if (persist)
- sti->sti_nl7c_flags |= HTTP_CONN_KA;
- else
- sti->sti_nl7c_flags |= HTTP_CONN_CL;
- }
- }
- /*
- * Last, update parse consumed text pointer.
- */
- *cpp = cp;
- return (B_TRUE);
-
-pass:
- *cpp = NULL;
- return (B_TRUE);
-
-bad:
- *cpp = NULL;
-more:
- return (B_FALSE);
-}
-
-boolean_t
-nl7c_http_response(char **cpp, char *ep, uri_desc_t *uri, struct sonode *so)
-{
- sotpi_info_t *sti = SOTOTPI(so);
- http_t *http = uri->scheme;
- char *cp = *cpp;
- char *hp;
- char *scp, *sep;
- char *HTTP = "HTTP/";
- int status = 0;
- token_t *match;
-#ifdef NOT_YET
- uint32_t major, minor;
-#endif
- boolean_t nocache = B_FALSE;
- boolean_t persist = B_FALSE;
-
- ASSERT(http != NULL);
-
- if (http->parsed) {
- if (uri->respclen != URI_LEN_NOVALUE) {
- /* Chunked response */
- sep = ep;
- goto chunked;
- }
- /* Already parsed, nothing todo */
- return (B_TRUE);
- }
-
- /*
- * Parse the HTTP/N.N version. Note, there's currently no use
- * for the actual response major nor minor values as only the
- * request values are used.
- */
- while (cp < ep && *HTTP == *cp) {
- HTTP++;
- cp++;
- }
- if (*HTTP != 0) {
- if (cp == ep)
- goto more;
- goto bad;
- }
- if (cp == ep)
- goto more;
-
- if (*cp < '0' || *cp > '9')
- goto bad;
-#ifdef NOT_YET
- major = *cp++ - '0';
-#else
- cp++;
-#endif
-
- if (cp == ep)
- goto more;
- if (*cp++ != '.')
- goto bad;
- if (cp == ep)
- goto more;
- if (*cp < '0' || *cp > '9')
- goto bad;
-#ifdef NOT_YET
- minor = *cp++ - '0';
-#else
- cp++;
-#endif
-
- if (cp == ep)
- goto more;
-
-got_version:
-
- /*
- * Get the response code.
- */
- if (*cp++ != ' ')
- goto bad;
- if (cp == ep)
- goto more;
-
- do {
- if (*cp == ' ')
- break;
- if (*cp < '0' || *cp > '9')
- goto bad;
- if (status)
- status *= 10;
- status += *cp++ - '0';
- } while (cp < ep);
-
- switch (status) {
- case 200:
- /*
- * The only response status we continue to process.
- */
- break;
- case 304:
- nl7c_http_response_304++;
- nocache = B_TRUE;
- uri->resplen = 0;
- goto pass;
- case 307:
- nl7c_http_response_307++;
- nocache = B_TRUE;
- uri->resplen = 0;
- goto pass;
- case 400:
- nl7c_http_response_400++;
- /*
- * Special case some response status codes, just mark
- * as nocache and no response length and pass on the
- * request/connection.
- */
- nocache = B_TRUE;
- uri->resplen = 0;
- goto pass;
- default:
- /*
- * All other response codes result in a parse failure.
- */
- goto bad;
- }
-
- /*
- * Initialize persistent state based on request HTTP version.
- */
- if (http->major == 1) {
- if (http->minor >= 1) {
- /* 1.1 persistent by default */
- persist = B_TRUE;
- } else {
- /* 1.0 isn't persistent by default */
- persist = B_FALSE;
- }
- } else if (http->major == 0) {
- /* Before 1.0 no persistent connections */
- persist = B_FALSE;
- } else {
- /* >= 2.0 not supported (yet) */
- goto bad;
- }
-
- /*
- * Parse HTTP headers through the EOH
- * (End Of Header, i.e. an empty line).
- */
- for (sep = ep; cp < ep; ep = sep) {
- /* Get the next line */
- scp = cp;
- match = ttree_line_parse(res_tree, &cp, &ep, &hp, NULL);
- if (match != NULL) {
- if (match->act & QUALIFIER) {
- /*
- * Header field text is used to qualify this
- * request/response, based on qualifier type
- * optionally convert and store *http.
- */
- char c;
- int n = 0;
- time_t secs;
-
- ASSERT(hp != NULL && ep != NULL);
-
- if (match->act & NUMERIC) {
- while (hp < ep) {
- c = *hp++;
- if (match->act & HEX) {
- hd2i(c, n);
- if (n == -1)
- goto bad;
- } else {
- if (! isdigit(c))
- goto bad;
- n *= 10;
- n += c - '0';
- }
- }
- } else if (match->act & DATE) {
- secs = http_date2time_t(hp, ep);
- }
- switch (match->tokid) {
-
- case Shdr_Cache_Control_Max_Age:
- break;
-
- case Shdr_Cache_Control_No_Cache:
- nocache = B_TRUE;
- break;
-
- case Shdr_Cache_Control_No_Store:
- nocache = B_TRUE;
- break;
-
- case Shdr_Connection_close:
- persist = B_FALSE;
- break;
-
- case Shdr_Connection_Keep_Alive:
- persist = B_TRUE;
- break;
-
- case Shdr_Chunked:
- uri->respclen = 0;
- uri->resplen = 0;
- nl7c_http_response_chunked++;
- break;
-
- case Shdr_Content_Length:
- if (uri->respclen == URI_LEN_NOVALUE)
- uri->resplen = n;
- break;
-
- case Shdr_Date:
- http->date = secs;
- break;
-
- case Shdr_ETag:
- http->etag.cp = hp;
- http->etag.ep = ep;
- break;
-
- case Shdr_Expires:
- http->expire = secs;
- break;
-
- case Shdr_Keep_Alive:
- persist = B_TRUE;
- break;
-
- case Shdr_Last_Modified:
- http->lastmod = secs;
- break;
-
- case Shdr_Set_Cookie:
- nocache = B_TRUE;
- break;
-
- case Shdr_Server:
- break;
-
- default:
- nocache = B_TRUE;
- break;
- };
- }
- if (match->act & FILTER) {
- /*
- * Filter header, do a copyover the header
- * text, guarenteed to be at least 1 byte.
- */
- char *cop = scp;
- int n = (ep - cop) - 1;
- char filter[] = "NL7C-Filtered";
-
- n = MIN(n, sizeof (filter) - 1);
- if (n > 0)
- bcopy(filter, cop, n);
- cop += n;
- ASSERT(cop < ep);
- *cop++ = ':';
- while (cop < ep)
- *cop++ = ' ';
- }
- if (match->act & NOCACHE) {
- nocache = B_TRUE;
- }
- } else if (hp == NULL) {
- uri->eoh = scp;
- goto done;
- } else if (ep == NULL) {
- goto more;
- }
- }
- /* No EOH found */
- goto more;
-
-done:
- /* Parse completed */
- http->parsed = B_TRUE;
- /* Save the HTTP header length */
- http->headlen = (cp - *cpp);
- if (uri->respclen == URI_LEN_NOVALUE) {
- if (uri->resplen == URI_LEN_NOVALUE) {
- nl7c_http_response_pass1++;
- goto pass;
- }
- }
- /* Add header length to URI response length */
- uri->resplen += http->headlen;
-
- /* Set socket persist state */
- if (persist)
- sti->sti_nl7c_flags |= NL7C_SOPERSIST;
- else
- sti->sti_nl7c_flags &= ~NL7C_SOPERSIST;
-
- if (http->major == 1) {
- sti->sti_nl7c_flags &= ~NL7C_SCHEMEPRIV;
- if (http->minor >= 1) {
- if (! persist)
- sti->sti_nl7c_flags |= HTTP_CONN_CL;
- } else {
- if (persist)
- sti->sti_nl7c_flags |= HTTP_CONN_KA;
- else
- sti->sti_nl7c_flags |= HTTP_CONN_CL;
- }
- }
-
- if (nocache) {
- /*
- * Response not to be cached, only post response
- * processing code common to both non and cached
- * cases above here and code for the cached case
- * below.
- *
- * Note, chunked transfer processing is the last
- * to be done.
- */
- uri->nocache = B_TRUE;
- if (uri->respclen != URI_LEN_NOVALUE) {
- /* Chunked response */
- goto chunked;
- }
- /* Nothing more todo */
- goto parsed;
- }
-
- if (http->expire != -1 && http->date != -1) {
- if (http->expire <= http->date) {
- /* ??? just pass */
- nl7c_http_response_pass2++;
- goto pass;
- }
- /* Have a valid expire and date so calc an lbolt expire */
- uri->expire = ddi_get_lbolt() + SEC_TO_TICK(http->expire -
- http->date);
- } else if (nl7c_uri_ttl != -1) {
- /* No valid expire speced and we have a TTL */
- uri->expire = ddi_get_lbolt() + SEC_TO_TICK(nl7c_uri_ttl);
- }
-
-chunked:
- /*
- * Chunk transfer parser and processing, a very simple parser
- * is implemented here for the common case were one, or more,
- * complete chunk(s) are passed in (i.e. length header + body).
- *
- * All other cases are passed.
- */
- scp = cp;
- while (uri->respclen != URI_LEN_NOVALUE && cp < sep) {
- if (uri->respclen == URI_LEN_CONSUMED) {
- /* Skip trailing "\r\n" */
- if (cp == sep)
- goto more;
- if (*cp++ != '\r')
- goto bad;
- if (cp == sep)
- goto more;
- if (*cp++ != '\n')
- goto bad;
- uri->respclen = 0;
- }
- if (uri->respclen == 0) {
- /* Parse a chunklen "[0-9A-Fa-f]+" */
- char c;
- int n = 0;
-
- if (cp == sep)
- goto more;
- nl7c_http_response_chunkparse++;
- while (cp < sep && (c = *cp++) != '\r') {
- hd2i(c, n);
- if (n == -1)
- goto bad;
- }
- if (cp == sep)
- goto more;
- if (*cp++ != '\n')
- goto bad;
- uri->respclen = n;
- if (n == 0) {
- /* Last chunk, skip trailing "\r\n" */
- if (cp == sep)
- goto more;
- if (*cp++ != '\r')
- goto bad;
- if (cp == sep)
- goto more;
- if (*cp++ != '\n')
- goto bad;
- uri->respclen = URI_LEN_NOVALUE;
- break;
- }
- }
- if (uri->respclen > 0) {
- /* Consume some bytes for the current chunk */
- uint32_t sz = (sep - cp);
-
- if (sz > uri->respclen)
- sz = uri->respclen;
- uri->respclen -= sz;
- cp += sz;
- if (uri->respclen == 0) {
- /* End of chunk, skip trailing "\r\n" */
- if (cp == sep) {
- uri->respclen = URI_LEN_CONSUMED;
- goto more;
- }
- if (*cp++ != '\r')
- goto bad;
- if (cp == sep)
- goto more;
- if (*cp++ != '\n')
- goto bad;
- if (cp == sep)
- goto more;
- }
- }
- }
- uri->resplen += (cp - scp);
-
-parsed:
- *cpp = cp;
- return (B_TRUE);
-
-pass:
- *cpp = NULL;
- return (B_TRUE);
-
-bad:
- *cpp = NULL;
- return (B_FALSE);
-
-more:
- uri->resplen += (cp - scp);
- *cpp = cp;
- return (B_FALSE);
-}
-
-boolean_t
-nl7c_http_log(uri_desc_t *quri, uri_desc_t *suri, nca_request_log_t *req,
- char **wp, char **pep, uint32_t *off)
-{
- http_t *qhttp = quri->scheme;
- http_t *shttp = suri->scheme;
- int sz;
-
- if (qhttp->uagent.cp != NULL) {
- sz = (qhttp->uagent.ep - qhttp->uagent.cp);
- if ((*wp + sz + 1) >= *pep) goto full;
- bcopy(qhttp->uagent.cp, *wp, sz);
- *wp += sz;
- *(*wp)++ = 0;
- sz++;
- req->useragent_len = sz;
- req->useragent = *off;
- *off += sz;
- }
-
- req->response_len -= (uint_t)shttp->headlen;
-
- req->method = NCA_GET;
-
- if (qhttp->major == 1) {
- if (qhttp->minor == 0) {
- req->version = HTTP_1_0;
- } else if (qhttp->minor == 1) {
- req->version = HTTP_1_1;
- } else {
- req->version = HTTP_0_0;
- }
- } else if (qhttp->major == 0) {
- req->version = HTTP_0_9;
- } else {
- req->version = HTTP_0_0;
- }
-
- return (B_FALSE);
-
-full:
- return (B_TRUE);
-}
diff --git a/usr/src/uts/common/fs/sockfs/nl7clogd.c b/usr/src/uts/common/fs/sockfs/nl7clogd.c
deleted file mode 100644
index 4dd40abf2d..0000000000
--- a/usr/src/uts/common/fs/sockfs/nl7clogd.c
+++ /dev/null
@@ -1,754 +0,0 @@
-/*
- * 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.
- */
-
-#include <sys/sysmacros.h>
-#include <sys/callb.h>
-#include <sys/fcntl.h>
-#include <sys/filio.h>
-#include <sys/pathname.h>
-#include <sys/cpuvar.h>
-#include <sys/promif.h>
-#include <fs/sockfs/nl7c.h>
-#include <fs/sockfs/nl7curi.h>
-
-#include <inet/nca/ncadoorhdr.h>
-#include <inet/nca/ncalogd.h>
-
-extern boolean_t nl7c_logd_enabled;
-extern boolean_t nl7c_logd_started;
-extern boolean_t nl7c_logd_cycle;
-
-extern void nl7clogd_startup(void);
-
-extern boolean_t nl7c_http_log(uri_desc_t *, uri_desc_t *,
- nca_request_log_t *, char **, char **, uint32_t *);
-
-static void logit_flush(void *);
-
-/*
- * NL7C reuses the NCA logging scheme, the directory "/var/nca" contains
- * the symlink "current" to 1 of up to 16 NCA BLF logging files, by default
- * a single logging file "log", optionally paths of up to 16 log files can
- * be specified via ncalogd.conf(5), note that these log files need not be
- * in the "/var/nca" directory.
- *
- * NL7C reuses the NCA logging APIs defined in <inet/nca/ncalogd.h>, at
- * some future date (when NCA is deprecated or improvements are needed)
- * these need to be moved into NL7C.
- *
- * NL7C implements logging differently in 2 ways, 1st the initialization
- * is handled completely in the kernel by NL7C when it's enabled vs NCA
- * when the kmod was loaded, 2nd a simple worker thread with a FIFO queue
- * is used to process log_buf_t's instead of a squeue_t (this is done as
- * squeue_t's are private to NCA and IP at some future date we may us an
- * IP squeue_t):
- *
- * logd_t - used by various functions to manage a singly linked
- * grounded list of log_buf_t's and it's worker thread.
- */
-
-typedef struct logd_s {
- log_buf_t *head;
- log_buf_t *tail;
- kthread_t *worker;
- kcondvar_t wait;
- kmutex_t lock;
-} logd_t;
-
-/*
- * In-kernel logging:
- *
- * nl7c_logbuf_max - tunable for the number of preallocated next
- * log_buf_t(s) for use by log_buf_alloc(), note if the value is
- * 0 (the default) then max_cpus worth will be allocated.
- *
- * logd - global logd_t used to post log_buf_t's too.
- *
- * log - global current log_buf_t that logit() logs too.
- *
- * logv[] - vector of available next logbuf(s) such that when
- * logbuf is filled another can be used while being processed by
- * the logger() and kmem_cache_alloc() of a replacement is done.
- *
- * logvcnt - count of logv[] vector element(s) and the index
- * plus 1 of the next logbuf.
- *
- * log_buf_kmc - the kmem_cache to alloc/free log_buf_t's from/to.
- *
- * fio - the global nca_fio_t used to manage file i/o to a logfile.
- *
- * dir - path to the directory where the current logfile symlink
- * is created and the default directory for logfile(s).
- *
- * symlink - name of the logfile symlink.
- *
- * symlink_path - path to the logfile symlink.
- *
- * log_lock - the kmutex_t used to guarantee atomic access of
- * all of the above.
- *
- * flush_tid - logit_flush() timeout id.
- *
- * LOGBUFV_ALLOC() - macro used to add log_buf_t(s) to logv[].
- */
-
-int nl7c_logbuf_max = 0;
-static logd_t logd;
-static log_buf_t *log = NULL;
-static log_buf_t **logv = NULL;
-static int logvcnt = 0;
-static kmem_cache_t *log_buf_kmc;
-static nca_fio_t fio;
-static caddr_t dir = "/var/nca/";
-static caddr_t symlink = "current";
-static caddr_t symlink_dir = "/var/nca";
-static caddr_t symlink_path = "/var/nca/current";
-
-static kmutex_t log_lock;
-
-static timeout_id_t flush_tid;
-
-#define LOGBUFV_ALLOC(kmflag) { \
- log_buf_t *_p; \
- \
- ASSERT(mutex_owned(&log_lock)); \
- while (logvcnt < nl7c_logbuf_max) { \
- /*CONSTCOND*/ \
- if (kmflag == KM_SLEEP) \
- mutex_exit(&log_lock); \
- _p = kmem_cache_alloc(log_buf_kmc, kmflag); \
- /*CONSTCOND*/ \
- if (kmflag == KM_SLEEP) { \
- mutex_enter(&log_lock); \
- if (logvcnt == nl7c_logbuf_max) { \
- mutex_exit(&log_lock); \
- kmem_cache_free(log_buf_kmc, _p); \
- mutex_enter(&log_lock); \
- break; \
- } \
- } else { \
- if (_p == NULL) { \
- break; \
- } \
- } \
- logv[logvcnt++] = _p; \
- } \
-}
-
-/*
- * Exports for inet/nca/ncaddi.c:
- */
-
-nca_fio_t *nl7c_logd_fio = &fio;
-
-static void
-log_buf_alloc(int kmflag)
-{
- nca_log_buf_hdr_t *hdr;
- static ulong_t seq = 0;
-
- ASSERT(mutex_owned(&log_lock));
-
- if (logvcnt == 0) {
- /*
- * No logv[] to use for the new log global logbuf,
- * try to allocate one or more before giving up.
- */
- LOGBUFV_ALLOC(kmflag);
- if (logvcnt == 0) {
- /* No joy, just give up. */
- log = NULL;
- return;
- }
- }
- log = logv[--logvcnt];
-
- log->size = NCA_DEFAULT_LOG_BUF_SIZE;
- log->cur_pos = sizeof (*hdr);
-
- hdr = (nca_log_buf_hdr_t *)&log->buffer;
- hdr->nca_loghdr.nca_version = NCA_LOG_VERSION1;
- hdr->nca_loghdr.nca_op = log_op;
- hdr->nca_logstats.n_log_size = NCA_DEFAULT_LOG_BUF_SIZE - sizeof (*hdr);
- hdr->nca_logstats.n_log_recs = 0;
- hdr->nca_logstats.n_log_upcall = seq++;
-
- /* Try to allocate for at least the one we just used */
- LOGBUFV_ALLOC(kmflag);
-}
-
-static void
-logd_off()
-{
- ;
-}
-
-static void
-logd_log_write(kmutex_t *lock, log_buf_t *lbp)
-{
- nca_log_buf_hdr_t *hdr = (nca_log_buf_hdr_t *)lbp->buffer;
- nca_log_stat_t *sts = &hdr->nca_logstats;
- int size = sts->n_log_size + sizeof (*hdr);
- vnode_t *vp;
- uio_t uio;
- iovec_t iov;
- int ret;
- boolean_t noretry = B_FALSE;
- vattr_t attr;
-
- if (size & (DEV_BSIZE - 1)) {
- /*
- * Not appropriately sized for directio(),
- * add some filler so it is.
- */
- sts->n_log_size += DEV_BSIZE - (size & (DEV_BSIZE - 1));
- size = sts->n_log_size + sizeof (*hdr);
- }
-retry:
- if (nca_fio_offset(&fio) + size <= nca_fio_size(&fio)) {
- /*
- * Room in the current log file so write the logbuf out,
- * exit the logd lock while doing the i/o as to not block
- * queuing.
- */
- mutex_exit(lock);
-
- vp = nca_fio_vp(&fio);
- (void) VOP_RWLOCK(vp, V_WRITELOCK_TRUE, NULL);
- iov.iov_base = lbp->buffer;
- iov.iov_len = size;
- uio.uio_iov = &iov;
- uio.uio_iovcnt = 1;
- uio.uio_segflg = UIO_SYSSPACE;
- uio.uio_fmode = 0;
- uio.uio_loffset = (u_offset_t)nca_fio_offset(&fio);
- uio.uio_llimit = curproc->p_fsz_ctl;
- uio.uio_resid = size;
- ret = VOP_WRITE(vp, &uio, 0, kcred, NULL);
- VOP_RWUNLOCK(vp, V_WRITELOCK_TRUE, NULL);
- if (ret != 0) {
- if (ret == EFBIG) {
- /*
- * Out of space for this file,
- * retry with the next.
- */
- nca_fio_size(&fio) = nca_fio_offset(&fio);
- if (noretry) {
- nl7c_logd_enabled = B_FALSE;
- goto done;
- } else
- goto next;
- }
- }
- nca_fio_offset(&fio) = uio.uio_loffset;
-
- mutex_enter(lock);
- goto done;
- }
-
- /*
- * Current logfile doesn't have sufficient space
- * so move on to next file (if any).
- */
-next:
- mutex_exit(lock);
- /* Close current file */
- ret = VOP_CLOSE(nca_fio_vp(&fio), FCREAT|FWRITE|FAPPEND|FTRUNC,
- 1, (offset_t)0, kcred, NULL);
- nca_fio_vp(&fio) = NULL;
- if (ret) {
- cmn_err(CE_WARN, "nl7c_logd: close of %s failed (error %d)",
- nca_fio_name(&fio), ret);
- nl7c_logd_enabled = B_FALSE;
- logd_off();
- return;
- }
-
- /* Go to next file */
- nca_fio_ix(&fio)++;
- if (nca_fio_ix(&fio) == nca_fio_cnt(&fio)) {
- /*
- * We have reached the last file. If cycling
- * is not on, disable logging and bailout.
- */
- if (nl7c_logd_cycle) {
- /* Start from the first file */
- nca_fio_ix(&fio) = 0;
- } else {
- nca_fio_ix(&fio)--;
- nl7c_logd_enabled = B_FALSE;
- logd_off();
- return;
- }
- }
-
- /* Open the next log file */
- ret = vn_open(nca_fio_name(&fio), UIO_SYSSPACE, FCREAT|FWRITE|FTRUNC,
- 0600, &nca_fio_vp(&fio), 0, 0);
- if (ret) {
- cmn_err(CE_WARN, "nl7c_logd: vn_open of %s failed (error %d)",
- nca_fio_name(&fio), ret);
- nl7c_logd_enabled = B_FALSE;
- logd_off();
- return;
- }
-
- /* Turn on directio */
- (void) VOP_IOCTL(nca_fio_vp(&fio), _FIODIRECTIO,
- DIRECTIO_ON, 0, kcred, NULL, NULL);
-
- /* Start writing from the begining of the file */
- nca_fio_offset(&fio) = 0;
-
- /* Remove the current symlink */
- (void) VOP_REMOVE(nca_fio_dvp(&fio), symlink, kcred, NULL, 0);
-
- attr.va_mask = AT_MODE | AT_TYPE;
- attr.va_mode = 0777;
- attr.va_type = VLNK;
-
- /* Create symlink to the new log file */
- ret = VOP_SYMLINK(nca_fio_dvp(&fio), symlink,
- &attr, nca_fio_name(&fio), kcred, NULL, 0);
- if (ret) {
- cmn_err(CE_WARN, "nl7c_logd: symlink of %s to %s failed",
- symlink, nca_fio_name(&fio));
- nl7c_logd_enabled = B_FALSE;
- logd_off();
- return;
- }
- mutex_enter(lock);
- goto retry;
-
-done:
- if (logvcnt < nl7c_logbuf_max) {
- /* May need to allocate some logbuf(s) for logv[] */
- mutex_enter(&log_lock);
- if (logvcnt < nl7c_logbuf_max) {
- /*
- * After acquiring the lock still need logbuf(s),
- * if the global logbuf pointer is NULL then call
- * log_buf_alloc() as it will fill up logbugv[]
- * and initialize a new logbuf else fill up just
- * the logv[] here.
- */
- if (log == NULL) {
- log_buf_alloc(KM_SLEEP);
- } else {
- /*LINTED*/
- LOGBUFV_ALLOC(KM_SLEEP);
- }
- }
- mutex_exit(&log_lock);
- }
-}
-
-static void
-logd_worker(logd_t *logdp)
-{
- log_buf_t *lbp;
- kmutex_t *lock = &logdp->lock;
- kcondvar_t *wait = &logdp->wait;
- callb_cpr_t cprinfo;
-
- CALLB_CPR_INIT(&cprinfo, lock, callb_generic_cpr, "nl7c");
- mutex_enter(lock);
-
- for (;;) {
- /* Wait for something to do */
- while ((lbp = logdp->head) == NULL) {
- CALLB_CPR_SAFE_BEGIN(&cprinfo);
- cv_wait(wait, lock);
- CALLB_CPR_SAFE_END(&cprinfo, lock);
- }
- if ((logdp->head = lbp->next) == NULL)
- logdp->tail = NULL;
- /* Got a logbuf to write out */
- if (nl7c_logd_enabled)
- logd_log_write(lock, lbp);
- kmem_cache_free(log_buf_kmc, lbp);
- }
-}
-
-boolean_t
-nl7c_logd_init(int fsz, caddr_t *fnv)
-{
- vnode_t *dvp;
- vnode_t *svp;
- vnode_t *vp;
- int ret;
- caddr_t *fnp;
- vattr_t attr;
- uio_t uio;
- iovec_t iov;
- char fbuf[TYPICALMAXPATHLEN + 1];
-
- /*
- * Initialize the global logfio.
- */
- nca_fio_cnt(&fio) = 0;
- nca_fio_ix(&fio) = 0;
- fnp = fnv;
- while (*fnp != NULL) {
- nca_fio_cnt(&fio)++;
- nca_fio_name(&fio) = *fnp;
- nca_fio_size(&fio) = fsz;
- nca_fio_offset(&fio) = 0;
- nca_fio_file(&fio) = nca_fio_ix(&fio);
- nca_fio_vp(&fio) = NULL;
-
- if (++fnp == &fnv[NCA_FIOV_SZ])
- break;
-
- nca_fio_ix(&fio)++;
- }
- /*
- * See if we can start logging from where we left off last time,
- * first check if the symlink exists.
- */
- dvp = NULL;
- ret = lookupname(symlink_path, UIO_SYSSPACE, NO_FOLLOW, &dvp, &svp);
- if (ret || dvp == NULL || svp == NULL) {
- if (dvp == NULL) {
- /* No NCA symlink directory, create one */
- attr.va_mask = AT_MODE | AT_TYPE;
- attr.va_mode = 0755;
- attr.va_type = VDIR;
- ret = vn_create(symlink_dir, UIO_SYSSPACE, &attr,
- EXCL, 0, &dvp, CRMKDIR, 0, 0);
- if (ret) {
- cmn_err(CE_WARN, "nl7c_logd_init: create"
- " symlink dir of %s failed(%d).",
- symlink_dir, ret);
- goto error;
- }
- }
- nca_fio_dvp(&fio) = dvp;
- /* No symlink so don't know were to start from */
- goto fresh_start;
- }
- /* Save the symlink dir vnode */
- nca_fio_dvp(&fio) = dvp;
-
- /* Check if the file pointed by the symlink exists */
- ret = lookupname(symlink_path, UIO_SYSSPACE, FOLLOW, NULLVPP, &vp);
- if (ret || vp == NULL)
- goto fresh_start;
- VN_RELE(vp);
-
- /* Read the symlink and find it in fnv[], else fresh start */
- iov.iov_len = TYPICALMAXPATHLEN;
- iov.iov_base = fbuf;
- uio.uio_iov = &iov;
- uio.uio_iovcnt = 1;
- uio.uio_resid = iov.iov_len;
- uio.uio_segflg = UIO_SYSSPACE;
- uio.uio_loffset = 0;
- uio.uio_fmode = 0;
- ret = VOP_READLINK(svp, &uio, kcred, NULL);
- if (ret) {
- (void) VOP_REMOVE(dvp, symlink, kcred, NULL, 0);
- goto fresh_start;
- }
-
- /* Null terminate the buf */
- fbuf[TYPICALMAXPATHLEN - (int)uio.uio_resid] = '\0';
- fnp = fnv;
- nca_fio_ix(&fio) = 0;
- while (*fnp != NULL) {
- if (strcmp(*fnp, fbuf) == 0)
- break;
- if (++fnp == &fnv[NCA_FIOV_SZ])
- goto fresh_start;
- nca_fio_ix(&fio)++;
- }
- if (*fnp == NULL)
- goto fresh_start;
-
- /* Start writing to the end of the file */
- ret = vn_open(*fnp, UIO_SYSSPACE,
- FCREAT|FWRITE|FAPPEND, 0600, &vp, 0, 0);
- if (ret) {
- cmn_err(CE_WARN, "nl7c_logd_init: vn_open of "
- "%s failed (error %d)", *fnp, ret);
- goto error;
- }
- nca_fio_vp(&fio) = vp;
- (void) VOP_IOCTL(vp, _FIODIRECTIO, DIRECTIO_ON, 0, kcred, NULL, NULL);
- attr.va_mask = AT_SIZE;
- ret = VOP_GETATTR(nca_fio_vp(&fio), &attr, 0, NULL, NULL);
- if (ret) {
- cmn_err(CE_WARN, "nl7c_logd_init: getattr of %s failed", *fnp);
- goto error;
- }
- nca_fio_offset(&fio) = (off64_t)attr.va_size;
-
- goto finish;
-
-fresh_start:
- /*
- * Here if no previous logging environment found or if the previous
- * logging environment isn't usable or isn't consistent with the new
- * fnv[]. Remove the existing symlink (if any) then create the new
- * symlink to point to the first logfile.
- */
- nca_fio_ix(&fio) = 0;
- attr.va_mask = AT_MODE | AT_TYPE;
- attr.va_mode = 0777;
- attr.va_type = VLNK;
- (void) VOP_REMOVE(dvp, symlink, kcred, NULL, 0);
- ret = VOP_SYMLINK(dvp, symlink, &attr, nca_fio_name(&fio), kcred, NULL,
- 0);
- if (ret) {
- cmn_err(CE_WARN, "nl7c_logd_init: symlink of %s to %s failed",
- symlink_path, nca_fio_name(&fio));
- goto error;
- }
- ret = vn_open(nca_fio_name(&fio), UIO_SYSSPACE,
- FCREAT|FWRITE|FTRUNC, 0600, &nca_fio_vp(&fio), 0, 0);
- if (ret) {
- cmn_err(CE_WARN, "nl7c_logd_init: vn_open of "
- "%s failed (error %d)", nca_fio_name(&fio), ret);
- goto error;
- }
-
- /* Turn on directio */
- (void) VOP_IOCTL(nca_fio_vp(&fio), _FIODIRECTIO,
- DIRECTIO_ON, 0, kcred, NULL, NULL);
-
-finish:
- log_buf_kmc = kmem_cache_create("NL7C_log_buf_kmc", sizeof (log_buf_t),
- 0, NULL, NULL, NULL, NULL, NULL, 0);
-
- mutex_init(&log_lock, NULL, MUTEX_DEFAULT, NULL);
- mutex_enter(&log_lock);
-
- if (nl7c_logbuf_max == 0)
- nl7c_logbuf_max = max_ncpus;
- logv = kmem_alloc(nl7c_logbuf_max * sizeof (*logv), KM_SLEEP);
- for (logvcnt = 0; logvcnt < nl7c_logbuf_max; logvcnt++) {
- logv[logvcnt] = kmem_cache_alloc(log_buf_kmc, KM_SLEEP);
- }
-
- log_buf_alloc(KM_SLEEP);
-
- mutex_init(&logd.lock, NULL, MUTEX_DEFAULT, NULL);
- cv_init(&logd.wait, NULL, CV_DEFAULT, NULL);
- logd.head = NULL;
- logd.tail = NULL;
- logd.worker = thread_create(NULL, 0, logd_worker, &logd,
- 0, &p0, TS_RUN, maxclsyspri);
-
- mutex_exit(&log_lock);
-
- /* Last, start logger timeout flush */
- logit_flush(NULL);
-
- return (B_TRUE);
-
- /*
- * Error of some sort, free any resources in reverse order.
- */
-error:
- nca_fio_ix(&fio) = 0;
- while (nca_fio_ix(&fio) < nca_fio_cnt(&fio)) {
- char *name = nca_fio_name(&fio);
-
- if ((vp = nca_fio_vp(&fio)) != NULL)
- VN_RELE(vp);
- kmem_free(name, (strlen(name) + 1));
- nca_fio_ix(&fio)++;
- }
- nca_fio_cnt(&fio) = 0;
-
- if (svp)
- VN_RELE(svp);
-
- if (dvp)
- VN_RELE(dvp);
-
- return (B_FALSE);
-}
-
-/*ARGSUSED*/
-static void
-logit_flush(void *arg)
-{
- static log_buf_t *lastlbp = NULL;
- static int lastpos;
- log_buf_t *lbp = log;
-
- flush_tid = 0;
-
- mutex_enter(&log_lock);
- if (log == NULL) {
- /* No global logbuf ? Nothing to flush. */
- goto out;
- }
- if (lbp != NULL && lbp->cur_pos > (sizeof (nca_log_buf_hdr_t)) &&
- lastlbp == lbp && lastpos == lbp->cur_pos) {
- /*
- * We have a logbuf and it has log data and it's the
- * same logbuf and pos as last time and after lock
- * still true, so flush.
- */
- nca_log_stat_t *sp;
-
- sp = &(((nca_log_buf_hdr_t *)lbp)->nca_logstats);
- sp->n_log_size = lbp->cur_pos;
-
- /* Link new logbuf onto end of logd and wake logd up */
- mutex_enter(&logd.lock);
- log->next = NULL;
- if (logd.tail == NULL)
- logd.head = log;
- else
- logd.tail->next = log;
- logd.tail = log;
- cv_signal(&logd.wait);
-
- mutex_exit(&logd.lock);
-
- log_buf_alloc(KM_NOSLEEP);
- }
-
- if ((lastlbp = lbp) != NULL)
- lastpos = lbp->cur_pos;
-
- mutex_exit(&log_lock);
-out:
- /* Check again in 1 second */
- flush_tid = timeout(&logit_flush, NULL, hz);
-}
-
-void
-nl7c_logd_log(uri_desc_t *quri, uri_desc_t *suri, time_t rtime, ipaddr_t faddr)
-{
- nca_request_log_t *req;
- char *wp;
- char *pep;
- int sz;
- uint32_t off = 0;
- int kmflag = servicing_interrupt() ? KM_NOSLEEP : KM_SLEEP;
-
- if (! nl7c_logd_enabled)
- return;
-
- if (! nl7c_logd_started) {
- /* Startup logging */
- nl7clogd_startup();
- }
- mutex_enter(&log_lock);
-again:
- if (log == NULL) {
- /* No global logbuf, try to allocate one before giving up. */
- log_buf_alloc(kmflag);
- if (log == NULL) {
- /* No joy, just give up. */
- mutex_exit(&log_lock);
- return;
- }
- }
- /*
- * Get a pointer to an aligned write position, a pointer to past
- * the end of the logbuf, and a pointer to the request header.
- *
- * As the request header is filled in field by field addtional
- * storage is allcated following the request header.
- *
- * If at any point an allocation from the logbuf overflows (i.e.
- * resulting in a pointer > pep) the current request logging is
- * aborted, the current logbuf is posted for write, a new logbuf
- * is allocated, and start all over.
- */
- pep = &((char *)log)[log->size];
- wp = (log->buffer + log->cur_pos);
- wp = NCA_LOG_ALIGN(wp);
- req = (nca_request_log_t *)wp;
- if ((wp + sizeof (*req)) >= pep) goto full;
- bzero(wp, sizeof (*req));
- wp += sizeof (*req);
-
- sz = MIN((quri->path.ep - quri->path.cp), MAX_URL_LEN);
- if ((wp + sz + 1) >= pep) goto full;
- bcopy(quri->path.cp, wp, sz);
- wp += sz;
- *wp++ = 0;
- sz++;
- req->request_url_len = sz;
- req->request_url = off;
- off += sz;
-
- /*
- * Set response length now as the scheme log function will
- * subtract out any header length as we want the entity body
- * length returned for the response_len.
- */
- req->response_len = (uint_t)suri->resplen;
-
- /* Call scheme log */
- if (nl7c_http_log(quri, suri, req, &wp, &pep, &off)) goto full;
-
- /* Update logbuf */
- log->cur_pos = (wp - log->buffer);
-
- req->response_status = HS_OK;
-
- req->start_process_time = (time32_t)rtime;
- req->end_process_time = (time32_t)gethrestime_sec();
-
- req->remote_host = faddr;
-
- ((nca_log_buf_hdr_t *)log)->nca_logstats.n_log_recs++;
- mutex_exit(&log_lock);
- return;
-
-full:
- /*
- * The logbuf is full, zero fill from current
- * write pointer through the end of the buf.
- */
- wp = (log->buffer + log->cur_pos);
- sz = pep - wp;
- bzero(wp, sz);
- /*
- * Link new logbuf onto end of logd and wake logd up.
- */
- mutex_enter(&logd.lock);
- log->next = NULL;
- if (logd.tail == NULL)
- logd.head = log;
- else
- logd.tail->next = log;
- logd.tail = log;
- cv_signal(&logd.wait);
- mutex_exit(&logd.lock);
- /*
- * Try to allocate a new global logbuf.
- */
- log_buf_alloc(kmflag);
-
- goto again;
-}
diff --git a/usr/src/uts/common/fs/sockfs/nl7cnca.c b/usr/src/uts/common/fs/sockfs/nl7cnca.c
deleted file mode 100644
index 3e1b494fee..0000000000
--- a/usr/src/uts/common/fs/sockfs/nl7cnca.c
+++ /dev/null
@@ -1,452 +0,0 @@
-/*
- * 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 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#include <sys/types.h>
-#include <sys/conf.h>
-#include <sys/modctl.h>
-#include <sys/stream.h>
-#include <sys/strsubr.h>
-#include <sys/stropts.h>
-#define _SUN_TPI_VERSION 2
-#include <sys/ddi.h>
-#include <sys/sunddi.h>
-#include <sys/cmn_err.h>
-#include <sys/debug.h>
-#include <sys/vtrace.h>
-#include <sys/errno.h>
-#include <inet/common.h>
-#include <inet/led.h>
-#include <inet/mi.h>
-#include <inet/nd.h>
-#include <sys/strsun.h>
-
-#include <fs/sockfs/nl7c.h>
-#include <fs/sockfs/nl7curi.h>
-
-#include <inet/nca/nca.h>
-#include <inet/nca/ncalogd.h>
-
-/*
- * This file is for NCA compatability, specifically it provides ndd
- * support for existing NCA ndd ...
- */
-
-extern boolean_t nl7c_logd_enabled;
-extern nca_fio_t *nl7c_logd_fio;
-extern clock_t nl7c_uri_ttl;
-extern boolean_t nl7c_use_kmem;
-extern uint64_t nl7c_file_prefetch;
-extern uint64_t nl7c_uri_max;
-extern uint64_t nl7c_uri_bytes;
-
-extern void nl7c_mi_report_addr(mblk_t *);
-
-#define MS 1L
-#define SECONDS (1000 * MS)
-#define MINUTES (60 * SECONDS)
-#define HOURS (60 * MINUTES)
-#define DAYS (24 * HOURS)
-
-#define PARAM_MAX UINT_MAX
-#define PARAML_MAX ULONG_MAX
-
-#include <inet/nca/ncandd.h>
-
-uint32_t nca_major_version = 1;
-uint32_t nca_minor_version = 3;
-uint32_t nca_httpd_version = NCA_HTTP_VERSION1;
-uint32_t nca_logd_version = NCA_LOG_VERSION1;
-
-caddr_t nca_g_nd; /* Head of 'named dispatch' variable list */
-
-/*
- * min, max, and value are int64_t's, addr is the optional address of an
- * external int64_t to be updated at init/set, name is the ndd name used
- * to access. Note, if min == max then only get is allowed, i.e. RO.
- */
-
-/* BEGIN CSTYLED */
-ncaparam_t nca_param_arr[] = {
- /*min max value name */
- { 0, 1, 1, "nca_log_cycle"},
- { 0, 1, 0, "no_caching"},
- { 0, PARAML_MAX, 0, "nca_log_size"},
- { 0, PARAM_MAX, 10000000, "nca_max_cache_size"},
- { 0, PARAM_MAX, 300*SECONDS, "nca_http_timeout"},
- { 0, PARAM_MAX, 15*SECONDS, "nca_http_keep_alive_timeout"},
- { 0, PARAM_MAX, 100, "nca_http_keep_alive_max"},
- { 0, 1, 1, "nca_inq_nointr"},
- { 0, 1, 1, "nca_use_hwcksum"},
- { 0, PARAM_MAX, 0, "nca_segmap_min_size"},
-};
-
-/*
- * Obsolete ip variables, use "/dev/ip" instead.
- */
-
-ncaparam_t nca_ip_obsolete_arr[] = {
- { 0, 0, 0, "ip_forwarding"},
- { 0, 0, 0, "ip_respond_to_address_mask_broadcast"},
- { 0, 0, 0, "ip_respond_to_echo_broadcast"},
- { 0, 0, 0, "ip_respond_to_timestamp"},
- { 0, 0, 0, "ip_respond_to_timestamp_broadcast"},
- { 0, 0, 0, "ip_send_redirects"},
- { 0, 0, 0, "ip_forward_directed_broadcasts"},
- { 0, 0, 0, "ip_debug"},
- { 0, 0, 0, "ip_mrtdebug"},
- { 0, 0, 0, "ip_ire_cleanup_interval" },
- { 0, 0, 0, "ip_ire_flush_interval" },
- { 0, 0, 0, "ip_ire_redirect_interval" },
- { 0, 0, 0, "ip_def_ttl" },
- { 0, 0, 0, "ip_forward_src_routed"},
- { 0, 0, 0, "ip_wroff_extra" },
- { 0, 0, 0, "ip_ire_pathmtu_interval" },
- { 0, 0, 0, "ip_icmp_return_data_bytes" },
- { 0, 0, 0, "ip_send_source_quench" },
- { 0, 0, 0, "ip_path_mtu_discovery" },
- { 0, 0, 0, "ip_ignore_delete_time" },
- { 0, 0, 0, "ip_ignore_redirect" },
- { 0, 0, 0, "ip_output_queue" },
- { 0, 0, 0, "ip_broadcast_ttl" },
- { 0, 0, 0, "ip_icmp_err_interval" },
- { 0, 0, 0, "ip_reass_queue_bytes" },
- { 0, 0, 0, "ip_strict_dst_multihoming" },
- { 0, 0, 0, "ip_addrs_per_if"},
-};
-
-/*
- * Obsolete tcp variables, use "/dev/tcp" instead.
- */
-
-ncaparam_t nca_tcp_obsolete_arr[] = {
- { 0, 0, 0, "tcp_time_wait_interval"},
- { 0, 0, 0, "tcp_conn_req_max_q" },
- { 0, 0, 0, "tcp_conn_req_max_q0" },
- { 0, 0, 0, "tcp_conn_req_min" },
- { 0, 0, 0, "tcp_conn_grace_period" },
- { 0, 0, 0, "tcp_cwnd_max" },
- { 0, 0, 0, "tcp_debug" },
- { 0, 0, 0, "tcp_smallest_nonpriv_port"},
- { 0, 0, 0, "tcp_ip_abort_cinterval"},
- { 0, 0, 0, "tcp_ip_abort_linterval"},
- { 0, 0, 0, "tcp_ip_abort_interval"},
- { 0, 0, 0, "tcp_ip_notify_cinterval"},
- { 0, 0, 0, "tcp_ip_notify_interval"},
- { 0, 0, 0, "tcp_ip_ttl"},
- { 0, 0, 0, "tcp_keepalive_interval"},
- { 0, 0, 0, "tcp_maxpsz_multiplier" },
- { 0, 0, 0, "tcp_mss_def"},
- { 0, 0, 0, "tcp_mss_max"},
- { 0, 0, 0, "tcp_mss_min"},
- { 0, 0, 0, "tcp_naglim_def"},
- { 0, 0, 0, "tcp_rexmit_interval_initial"},
- { 0, 0, 0, "tcp_rexmit_interval_max"},
- { 0, 0, 0, "tcp_rexmit_interval_min"},
- { 0, 0, 0, "tcp_wroff_xtra" },
- { 0, 0, 0, "tcp_deferred_ack_interval" },
- { 0, 0, 0, "tcp_snd_lowat_fraction" },
- { 0, 0, 0, "tcp_sth_rcv_hiwat" },
- { 0, 0, 0, "tcp_sth_rcv_lowat" },
- { 0, 0, 0, "tcp_dupack_fast_retransmit" },
- { 0, 0, 0, "tcp_ignore_path_mtu" },
- { 0, 0, 0, "tcp_rcv_push_wait" },
- { 0, 0, 0, "tcp_smallest_anon_port"},
- { 0, 0, 0, "tcp_largest_anon_port"},
- { 0, 0, 0, "tcp_xmit_hiwat"},
- { 0, 0, 0, "tcp_xmit_lowat"},
- { 0, 0, 0, "tcp_recv_hiwat"},
- { 0, 0, 0, "tcp_recv_hiwat_minmss"},
- { 0, 0, 0, "tcp_fin_wait_2_flush_interval"},
- { 0, 0, 0, "tcp_max_buf"},
- { 0, 0, 0, "tcp_strong_iss"},
- { 0, 0, 0, "tcp_rtt_updates"},
- { 0, 0, 0, "tcp_wscale_always"},
- { 0, 0, 0, "tcp_tstamp_always"},
- { 0, 0, 0, "tcp_tstamp_if_wscale"},
- { 0, 0, 0, "tcp_rexmit_interval_extra"},
- { 0, 0, 0, "tcp_deferred_acks_max"},
- { 0, 0, 0, "tcp_slow_start_after_idle"},
- { 0, 0, 0, "tcp_slow_start_initial"},
- { 0, 0, 0, "tcp_sack_permitted"},
-#ifdef DEBUG
- { 0, 0, 0, "tcp_drop_oob"},
-#endif
-};
-
-/*
- * Obsolete nca variables, just warn.
- */
-
-ncaparam_t nca_nca_obsolete_arr[] = {
- { 0, 0, 0, "nca_ipport_table_bucket"},
- { 0, 0, 0, "nca_ipport_table_size"},
- { 0, 0, 0, "nca_ipport_table_expand"},
- { 0, 0, 0, "nca_ipport_table_shrink"},
- { 0, 0, 0, "nca_ip_virtual_hosting"},
- { 0, 0, 0, "httpd_door_address"},
- { 0, 0, 0, "httpd_door_path"},
- { 0, 0, 0, "httpd_downdoor_path"},
- { 0, 0, 0, "nca_ppmax"},
- { 0, 0, 0, "nca_vpmax"},
- { 0, 0, 0, "nca_use_segmap"},
- { 0, 0, 0, "nca_availrmem"},
- { 0, 0, 0, "nca_maxkmem"},
- { 0, 0, 0, "nca_log_file"},
- { 0, 0, 0, "conn_status"},
- { 0, 0, 0, "conn_status_all"},
- { 0, 0, 0, "nca_conn_req_max_q"},
- { 0, 0, 0, "nca_conn_req_max_q0"},
- { 0, 0, 0, "cache_clear"},
- { 0, 0, 0, "nca_node_hash"},
- { 0, 0, 0, "node_status"},
-#ifdef DEBUG
- { 0, 0, 0, "nca_debug_counter"},
-#endif
-};
-/* END CSTYLED */
-
-static int
-/*ARGSUSED*/
-nl7c_uri_ttl_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
-{
- (void) mi_mpprintf(mp, "%ld", nl7c_uri_ttl);
- return (0);
-}
-
-static int
-/*ARGSUSED*/
-nl7c_uri_ttl_set(queue_t *q, mblk_t *mp, char *value, caddr_t nu, cred_t *cr)
-{
- if (ddi_strtol(value, NULL, 10, &nl7c_uri_ttl) != 0)
- return (EINVAL);
- return (0);
-}
-
-static int
-/*ARGSUSED*/
-nca_logging_on_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
-{
- (void) mi_mpprintf(mp, "%d", nl7c_logd_enabled);
- return (0);
-}
-
-static int
-/*ARGSUSED*/
-nca_logging_on_set(queue_t *q, mblk_t *mp, char *value, caddr_t nu, cred_t *cr)
-{
- long new_value;
-
- if (ddi_strtol(value, NULL, 10, &new_value) != 0 || new_value < 0 ||
- new_value > 1) {
- return (EINVAL);
- }
- if (nca_fio_cnt(nl7c_logd_fio) == 0)
- return (EINVAL);
- nl7c_logd_enabled = new_value;
-
- return (0);
-}
-
-static int
-/*ARGSUSED*/
-nca_version_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
-{
- (void) mi_mpprintf(mp, "%d.%d", nca_major_version, nca_minor_version);
- return (0);
-}
-
-static int
-/*ARGSUSED*/
-nca_httpd_version_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
-{
- (void) mi_mpprintf(mp, "%d", nca_httpd_version);
- return (0);
-}
-
-static int
-/*ARGSUSED*/
-nca_logd_version_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
-{
- (void) mi_mpprintf(mp, "%d", nca_logd_version);
- return (0);
-}
-
-static int
-/*ARGSUSED*/
-nca_httpd_door_inst_get(queue_t *q, mblk_t *mp, caddr_t nu, cred_t *cr)
-{
- nl7c_mi_report_addr(mp);
- return (0);
-}
-
-static int
-/*ARGSUSED*/
-nca_param_get(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
-{
- ncaparam_t *ncapa = (ncaparam_t *)cp;
-
- (void) mi_mpprintf(mp, "%ld", ncapa->param_val);
- return (0);
-}
-
-static int
-/*ARGSUSED*/
-nca_param_set(queue_t *q, mblk_t *mp, char *value, caddr_t cp, cred_t *cr)
-{
- ulong_t new_value;
- ncaparam_t *ncapa = (ncaparam_t *)cp;
-
- if (ddi_strtoul(value, NULL, 10, &new_value) != 0 ||
- new_value < ncapa->param_min || new_value > ncapa->param_max) {
- return (EINVAL);
- }
- ncapa->param_val = new_value;
- return (0);
-}
-
-static int
-/*ARGSUSED*/
-nca_obsolete(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
-{
- (void) mi_mpprintf(mp, "obsolete");
- return (0);
-}
-
-static int
-/*ARGSUSED*/
-nca_ip_obsolete(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
-{
- (void) mi_mpprintf(mp, "obsolete for /dev/nca, use /dev/ip");
- return (0);
-}
-
-static int
-/*ARGSUSED*/
-nca_tcp_obsolete(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
-{
- (void) mi_mpprintf(mp, "obsolete for /dev/nca, use /dev/tcp");
- return (0);
-}
-
-static int
-/*ARGSUSED*/
-nca_nca_obsolete(queue_t *q, mblk_t *mp, caddr_t cp, cred_t *cr)
-{
- (void) mi_mpprintf(mp, "obsolete for /dev/nca");
- return (0);
-}
-
-static boolean_t
-nca_param_register(ncaparam_t *ncapa, int cnt)
-{
- for (; cnt-- > 0; ncapa++) {
- if (ncapa->param_name && ncapa->param_name[0]) {
- if (!nd_load(&nca_g_nd, ncapa->param_name,
- nca_param_get, nca_param_set,
- (caddr_t)ncapa)) {
- goto error;
- }
- }
-
- }
- if (!nd_load(&nca_g_nd, "nca_version", nca_version_get, nil(pfi_t),
- nil(caddr_t))) {
- goto error;
- }
- if (!nd_load(&nca_g_nd, "nca_logd_version", nca_logd_version_get,
- nil(pfi_t), nil(caddr_t))) {
- goto error;
- }
- if (!nd_load(&nca_g_nd, "nca_logging_on", nca_logging_on_get,
- nca_logging_on_set, nil(caddr_t))) {
- goto error;
- }
-
- if (!nd_load(&nca_g_nd, "uri_time_to_live", nl7c_uri_ttl_get,
- nl7c_uri_ttl_set, nil(caddr_t))) {
- goto error;
- }
- if (!nd_load(&nca_g_nd, "nca_httpd_version", nca_httpd_version_get,
- nil(pfi_t), nil(caddr_t))) {
- goto error;
- }
- if (!nd_load(&nca_g_nd, "httpd_door_instance", nca_httpd_door_inst_get,
- nil(pfi_t), nil(caddr_t))) {
- nd_free(&nca_g_nd);
- return (B_FALSE);
- }
-
- ncapa = nca_ip_obsolete_arr;
- cnt = A_CNT(nca_ip_obsolete_arr);
- for (; cnt-- > 0; ncapa++) {
- if (ncapa->param_name && ncapa->param_name[0]) {
- if (!nd_load(&nca_g_nd, ncapa->param_name,
- nca_ip_obsolete, NULL, (caddr_t)ncapa)) {
- goto error;
- }
- }
-
- }
-
- ncapa = nca_tcp_obsolete_arr;
- cnt = A_CNT(nca_tcp_obsolete_arr);
- for (; cnt-- > 0; ncapa++) {
- if (ncapa->param_name && ncapa->param_name[0]) {
- if (!nd_load(&nca_g_nd, ncapa->param_name,
- nca_tcp_obsolete, NULL, (caddr_t)ncapa)) {
- goto error;
- }
- }
-
- }
-
- ncapa = nca_nca_obsolete_arr;
- cnt = A_CNT(nca_nca_obsolete_arr);
- for (; cnt-- > 0; ncapa++) {
- if (ncapa->param_name && ncapa->param_name[0]) {
- if (!nd_load(&nca_g_nd, ncapa->param_name,
- nca_nca_obsolete, NULL, (caddr_t)ncapa)) {
- goto error;
- }
- }
-
- }
-
- return (B_TRUE);
-
-error:
- nd_free(&nca_g_nd);
- return (B_FALSE);
-}
-
-void
-nl7c_nca_init(void)
-{
- if (! nca_g_nd) {
- if (! nca_param_register(nca_param_arr, A_CNT(nca_param_arr)))
- cmn_err(CE_WARN,
- "nl7c: /dev/nca ndd initialization failed.");
- }
-}
diff --git a/usr/src/uts/common/fs/sockfs/nl7ctokgen b/usr/src/uts/common/fs/sockfs/nl7ctokgen
deleted file mode 100755
index 1cdf1d2d1f..0000000000
--- a/usr/src/uts/common/fs/sockfs/nl7ctokgen
+++ /dev/null
@@ -1,79 +0,0 @@
-#!/bin/ksh
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (the "License"). You may not use this file except in compliance
-# with the License.
-#
-# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
-# or http://www.opensolaris.org/os/licensing.
-# See the License for the specific language governing permissions
-# and limitations under the License.
-#
-# When distributing Covered Code, include this CDDL HEADER in each
-# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
-# If applicable, add the following below this CDDL HEADER, with the
-# fields enclosed by brackets "[]" replaced with your own identifying
-# information: Portions Copyright [yyyy] [name of copyright owner]
-#
-# CDDL HEADER END
-#
-# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# Executed from appropriate arch build directory, e.g. {intel,sparc}/sockfs,
-# to generate the nl7ctokgen.h file from nl7ctok*.txt file(s).
-#
-
-EXIT=0
-IFS=","
-while [ "$1" != "" ]
-do
-NAME=$1
-shift
-<$NAME sort -f +1 |{
-
-while read IDN STR FLG BAD
-do
- if [ "$IDN" != "${IDN#\#}" ]
- then
- continue
- fi
- if [ -n "$BAD" ]
- then
- echo "$IDN: ${BAD## }: too many arguments"
- EXIT=1
- fi
- echo "static char S$IDN[] = ${STR## };"
- ELE="$ELE
- INIT($IDN, ${FLG## }),"
- ENU="$ENU
- $IDN,"
-done
-NAME=${NAME##*nl7c}
-NAME=${NAME%.txt}
-TOKEN="$TOKEN
-token_t $NAME[] = {
-$ELE
- {0}
-};
-
-#define ${NAME}_cnt (sizeof ($NAME) / sizeof (*$NAME))
-"
-ELE=""
-
-}
-done
-
-echo "
-enum tokid_e {
- _Hdr_First_,
-$ENU
- _Hdr_Last_
-};
-$TOKEN
-"
-
-exit $EXIT
diff --git a/usr/src/uts/common/fs/sockfs/nl7ctokreq.txt b/usr/src/uts/common/fs/sockfs/nl7ctokreq.txt
deleted file mode 100644
index 4924ce0e32..0000000000
--- a/usr/src/uts/common/fs/sockfs/nl7ctokreq.txt
+++ /dev/null
@@ -1,44 +0,0 @@
-#
-#ident "%Z%%M% %I% %E% SMI"
-#
-# Copyright 2006 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 (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
-#
-# Executed from appropriate arch build directory, e.g. {intel,sparc}/sockfs,
-# to generate the nl7ctokgen.h file from nl7ctok*.txt file(s).
-#
-Qhdr_Accept, "Accept: ", PASS | QUALIFIER
-Qhdr_Accept_Charset, "Accept-Charset: ", PASS | QUALIFIER
-Qhdr_Accept_Encoding, "Accept-Encoding: ", PASS | QUALIFIER
-Qhdr_Accept_Language, "Accept-Language: ", PASS | QUALIFIER
-Qhdr_Authorization, "Authorization: ", PASS | QUALIFIER | NOCACHE
-Qhdr_Host, "Host: ", PASS | QUALIFIER | HASH
-Qhdr_If_Modified_Since, "If-Modified-Since: ", FILTER | QUALIFIER | DATE
-Qhdr_If_Unmodified_Since, "If-Unmodified-Since: ", FILTER | QUALIFIER | DATE
-Qhdr_User_Agent, "User-Agent: ", PASS | QUALIFIER
-Qhdr_Connection_close, "Connection: close", QUALIFIER
-Qhdr_Connection_Keep_Alive, "Connection: Keep-Alive", QUALIFIER
-Qhdr_Keep_Alive, "Keep-Alive: ", FILTER | QUALIFIER
-Qhdr_Date, "Date: ", PASS | QUALIFIER | DATE
-Qhdr_ETagW, "ETag: W/", PASS | NOCACHE
-Qhdr_ETag, "ETag: ", PASS | QUALIFIER
-Qhdr_Pragma_no_cache, "Pragma: no-cache", PASS | NOCACHE
diff --git a/usr/src/uts/common/fs/sockfs/nl7ctokres.txt b/usr/src/uts/common/fs/sockfs/nl7ctokres.txt
deleted file mode 100644
index 12307d7d37..0000000000
--- a/usr/src/uts/common/fs/sockfs/nl7ctokres.txt
+++ /dev/null
@@ -1,43 +0,0 @@
-#
-#ident "%Z%%M% %I% %E% SMI"
-#
-# Copyright 2006 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 (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
-#
-# Executed from appropriate arch build directory, e.g. {intel,sparc}/sockfs,
-# to generate the nl7ctokgen.h file from nl7ctok*.txt file(s).
-#
-Shdr_Connection_close, "Connection: close", FILTER | QUALIFIER
-Shdr_Connection_Keep_Alive, "Connection: Keep-Alive", FILTER | QUALIFIER
-Shdr_Content_Length, "Content-Length: ", PASS | QUALIFIER | NUMERIC
-Shdr_Date, "Date: ", PASS | QUALIFIER | DATE
-Shdr_Expires, "Expires: ", PASS | QUALIFIER | DATE
-Shdr_Keep_Alive, "Keep-Alive: ", FILTER | QUALIFIER
-Shdr_Last_Modified, "Last-Modified: ", PASS | QUALIFIER | QUALIFIER | DATE
-Shdr_Set_Cookie, "Set-Cookie: ", PASS | NOCACHE
-Shdr_Cache_Control_No_Cache, "Cache-Control: no-cache", PASS | NOCACHE
-Shdr_Cache_Control_No_Store, "Cache-Control: no-store", PASS | NOCACHE
-Shdr_Cache_Control_Max_Age, "Cache-Control: max-age", PASS | NUMERIC
-Shdr_ETagW, "ETag: W/", PASS | NOCACHE
-Shdr_ETag, "ETag: ", PASS | QUALIFIER
-Shdr_Chunked, "Transfer-Encoding: chunked", PASS | QUALIFIER
-Shdr_Server, "Server: ", PASS | QUALIFIER
diff --git a/usr/src/uts/common/fs/sockfs/nl7curi.c b/usr/src/uts/common/fs/sockfs/nl7curi.c
deleted file mode 100644
index 0c8276d227..0000000000
--- a/usr/src/uts/common/fs/sockfs/nl7curi.c
+++ /dev/null
@@ -1,2145 +0,0 @@
-/*
- * 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 (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- */
-
-#include <sys/strsubr.h>
-#include <sys/strsun.h>
-#include <sys/param.h>
-#include <sys/sysmacros.h>
-#include <vm/seg_map.h>
-#include <vm/seg_kpm.h>
-#include <sys/condvar_impl.h>
-#include <sys/sendfile.h>
-#include <fs/sockfs/nl7c.h>
-#include <fs/sockfs/nl7curi.h>
-#include <fs/sockfs/socktpi_impl.h>
-
-#include <inet/common.h>
-#include <inet/ip.h>
-#include <inet/ip6.h>
-#include <inet/tcp.h>
-#include <inet/led.h>
-#include <inet/mi.h>
-
-#include <inet/nca/ncadoorhdr.h>
-#include <inet/nca/ncalogd.h>
-#include <inet/nca/ncandd.h>
-
-#include <sys/promif.h>
-
-/*
- * Some externs:
- */
-
-extern boolean_t nl7c_logd_enabled;
-extern void nl7c_logd_log(uri_desc_t *, uri_desc_t *,
- time_t, ipaddr_t);
-extern boolean_t nl7c_close_addr(struct sonode *);
-extern struct sonode *nl7c_addr2portso(void *);
-extern uri_desc_t *nl7c_http_cond(uri_desc_t *, uri_desc_t *);
-
-/*
- * Various global tuneables:
- */
-
-clock_t nl7c_uri_ttl = -1; /* TTL in seconds (-1 == infinite) */
-
-boolean_t nl7c_use_kmem = B_FALSE; /* Force use of kmem (no segmap) */
-
-uint64_t nl7c_file_prefetch = 1; /* File cache prefetch pages */
-
-uint64_t nl7c_uri_max = 0; /* Maximum bytes (0 == infinite) */
-uint64_t nl7c_uri_bytes = 0; /* Bytes of kmem used by URIs */
-
-/*
- * Locals:
- */
-
-static int uri_rd_response(struct sonode *, uri_desc_t *,
- uri_rd_t *, boolean_t);
-static int uri_response(struct sonode *, uri_desc_t *);
-
-/*
- * HTTP scheme functions called from nl7chttp.c:
- */
-
-boolean_t nl7c_http_request(char **, char *, uri_desc_t *, struct sonode *);
-boolean_t nl7c_http_response(char **, char *, uri_desc_t *, struct sonode *);
-boolean_t nl7c_http_cmp(void *, void *);
-mblk_t *nl7c_http_persist(struct sonode *);
-void nl7c_http_free(void *arg);
-void nl7c_http_init(void);
-
-/*
- * Counters that need to move to kstat and/or be removed:
- */
-
-volatile uint64_t nl7c_uri_request = 0;
-volatile uint64_t nl7c_uri_hit = 0;
-volatile uint64_t nl7c_uri_pass = 0;
-volatile uint64_t nl7c_uri_miss = 0;
-volatile uint64_t nl7c_uri_temp = 0;
-volatile uint64_t nl7c_uri_more = 0;
-volatile uint64_t nl7c_uri_data = 0;
-volatile uint64_t nl7c_uri_sendfilev = 0;
-volatile uint64_t nl7c_uri_reclaim_calls = 0;
-volatile uint64_t nl7c_uri_reclaim_cnt = 0;
-volatile uint64_t nl7c_uri_pass_urifail = 0;
-volatile uint64_t nl7c_uri_pass_dupbfail = 0;
-volatile uint64_t nl7c_uri_more_get = 0;
-volatile uint64_t nl7c_uri_pass_method = 0;
-volatile uint64_t nl7c_uri_pass_option = 0;
-volatile uint64_t nl7c_uri_more_eol = 0;
-volatile uint64_t nl7c_uri_more_http = 0;
-volatile uint64_t nl7c_uri_pass_http = 0;
-volatile uint64_t nl7c_uri_pass_addfail = 0;
-volatile uint64_t nl7c_uri_pass_temp = 0;
-volatile uint64_t nl7c_uri_expire = 0;
-volatile uint64_t nl7c_uri_purge = 0;
-volatile uint64_t nl7c_uri_NULL1 = 0;
-volatile uint64_t nl7c_uri_NULL2 = 0;
-volatile uint64_t nl7c_uri_close = 0;
-volatile uint64_t nl7c_uri_temp_close = 0;
-volatile uint64_t nl7c_uri_free = 0;
-volatile uint64_t nl7c_uri_temp_free = 0;
-volatile uint64_t nl7c_uri_temp_mk = 0;
-volatile uint64_t nl7c_uri_rd_EAGAIN = 0;
-
-/*
- * Various kmem_cache_t's:
- */
-
-kmem_cache_t *nl7c_uri_kmc;
-kmem_cache_t *nl7c_uri_rd_kmc;
-static kmem_cache_t *uri_desb_kmc;
-static kmem_cache_t *uri_segmap_kmc;
-
-static void uri_kmc_reclaim(void *);
-
-static void nl7c_uri_reclaim(void);
-
-/*
- * The URI hash is a dynamically sized A/B bucket hash, when the current
- * hash's average bucket chain length exceeds URI_HASH_AVRG a new hash of
- * the next P2Ps[] size is created.
- *
- * All lookups are done in the current hash then the new hash (if any),
- * if there is a new has then when a current hash bucket chain is examined
- * any uri_desc_t members will be migrated to the new hash and when the
- * last uri_desc_t has been migrated then the new hash will become the
- * current and the previous current hash will be freed leaving a single
- * hash.
- *
- * uri_hash_t - hash bucket (chain) type, contained in the uri_hash_ab[]
- * and can be accessed only after aquiring the uri_hash_access lock (for
- * READER or WRITER) then acquiring the lock uri_hash_t.lock, the uri_hash_t
- * and all linked uri_desc_t.hash members are protected. Note, a REF_HOLD()
- * is placed on all uri_desc_t uri_hash_t list members.
- *
- * uri_hash_access - rwlock for all uri_hash_* variables, READER for read
- * access and WRITER for write access. Note, WRITER is only required for
- * hash geometry changes.
- *
- * uri_hash_which - which uri_hash_ab[] is the current hash.
- *
- * uri_hash_n[] - the P2Ps[] index for each uri_hash_ab[].
- *
- * uri_hash_sz[] - the size for each uri_hash_ab[].
- *
- * uri_hash_cnt[] - the total uri_desc_t members for each uri_hash_ab[].
- *
- * uri_hash_overflow[] - the uri_hash_cnt[] for each uri_hash_ab[] when
- * a new uri_hash_ab[] needs to be created.
- *
- * uri_hash_ab[] - the uri_hash_t entries.
- *
- * uri_hash_lru[] - the last uri_hash_ab[] walked for lru reclaim.
- */
-
-typedef struct uri_hash_s {
- struct uri_desc_s *list; /* List of uri_t(s) */
- kmutex_t lock;
-} uri_hash_t;
-
-#define URI_HASH_AVRG 5 /* Desired average hash chain length */
-#define URI_HASH_N_INIT 9 /* P2Ps[] initial index */
-
-static krwlock_t uri_hash_access;
-static uint32_t uri_hash_which = 0;
-static uint32_t uri_hash_n[2] = {URI_HASH_N_INIT, 0};
-static uint32_t uri_hash_sz[2] = {0, 0};
-static uint32_t uri_hash_cnt[2] = {0, 0};
-static uint32_t uri_hash_overflow[2] = {0, 0};
-static uri_hash_t *uri_hash_ab[2] = {NULL, NULL};
-static uri_hash_t *uri_hash_lru[2] = {NULL, NULL};
-
-/*
- * Primes for N of 3 - 24 where P is first prime less then (2^(N-1))+(2^(N-2))
- * these primes have been foud to be useful for prime sized hash tables.
- */
-
-static const int P2Ps[] = {
- 0, 0, 0, 5, 11, 23, 47, 89, 191, 383, 761, 1531, 3067,
- 6143, 12281, 24571, 49139, 98299, 196597, 393209,
- 786431, 1572853, 3145721, 6291449, 12582893, 0};
-
-/*
- * Hash macros:
- *
- * H2A(char *cp, char *ep, char c) - convert the escaped octet (ASCII)
- * hex multichar of the format "%HH" pointeded to by *cp to a char and
- * return in c, *ep points to past end of (char *), on return *cp will
- * point to the last char consumed.
- *
- * URI_HASH(unsigned hix, char *cp, char *ep) - hash the char(s) from
- * *cp to *ep to the unsigned hix, cp nor ep are modified.
- *
- * URI_HASH_IX(unsigned hix, int which) - convert the hash value hix to
- * a hash index 0 - (uri_hash_sz[which] - 1).
- *
- * URI_HASH_MIGRATE(from, hp, to) - migrate the uri_hash_t *hp list
- * uri_desc_t members from hash from to hash to.
- *
- * URI_HASH_UNLINK(cur, new, hp, puri, uri) - unlink the uri_desc_t
- * *uri which is a member of the uri_hash_t *hp list with a previous
- * list member of *puri for the uri_hash_ab[] cur. After unlinking
- * check for cur hash empty, if so make new cur. Note, as this macro
- * can change a hash chain it needs to be run under hash_access as
- * RW_WRITER, futher as it can change the new hash to cur any access
- * to the hash state must be done after either dropping locks and
- * starting over or making sure the global state is consistent after
- * as before.
- */
-
-#define H2A(cp, ep, c) { \
- int _h = 2; \
- int _n = 0; \
- char _hc; \
- \
- while (_h > 0 && ++(cp) < (ep)) { \
- if (_h == 1) \
- _n *= 0x10; \
- _hc = *(cp); \
- if (_hc >= '0' && _hc <= '9') \
- _n += _hc - '0'; \
- else if (_hc >= 'a' || _hc <= 'f') \
- _n += _hc - 'W'; \
- else if (_hc >= 'A' || _hc <= 'F') \
- _n += _hc - '7'; \
- _h--; \
- } \
- (c) = _n; \
-}
-
-#define URI_HASH(hv, cp, ep) { \
- char *_s = (cp); \
- char _c; \
- \
- while (_s < (ep)) { \
- if ((_c = *_s) == '%') { \
- H2A(_s, (ep), _c); \
- } \
- CHASH(hv, _c); \
- _s++; \
- } \
-}
-
-#define URI_HASH_IX(hix, which) (hix) = (hix) % (uri_hash_sz[(which)])
-
-#define URI_HASH_MIGRATE(from, hp, to) { \
- uri_desc_t *_nuri; \
- uint32_t _nhix; \
- uri_hash_t *_nhp; \
- \
- mutex_enter(&(hp)->lock); \
- while ((_nuri = (hp)->list) != NULL) { \
- (hp)->list = _nuri->hash; \
- atomic_dec_32(&uri_hash_cnt[(from)]); \
- atomic_inc_32(&uri_hash_cnt[(to)]); \
- _nhix = _nuri->hvalue; \
- URI_HASH_IX(_nhix, to); \
- _nhp = &uri_hash_ab[(to)][_nhix]; \
- mutex_enter(&_nhp->lock); \
- _nuri->hash = _nhp->list; \
- _nhp->list = _nuri; \
- _nuri->hit = 0; \
- mutex_exit(&_nhp->lock); \
- } \
- mutex_exit(&(hp)->lock); \
-}
-
-#define URI_HASH_UNLINK(cur, new, hp, puri, uri) { \
- if ((puri) != NULL) { \
- (puri)->hash = (uri)->hash; \
- } else { \
- (hp)->list = (uri)->hash; \
- } \
- if (atomic_dec_32_nv(&uri_hash_cnt[(cur)]) == 0 && \
- uri_hash_ab[(new)] != NULL) { \
- kmem_free(uri_hash_ab[cur], \
- sizeof (uri_hash_t) * uri_hash_sz[cur]); \
- uri_hash_ab[(cur)] = NULL; \
- uri_hash_lru[(cur)] = NULL; \
- uri_hash_which = (new); \
- } else { \
- uri_hash_lru[(cur)] = (hp); \
- } \
-}
-
-void
-nl7c_uri_init(void)
-{
- uint32_t cur = uri_hash_which;
-
- rw_init(&uri_hash_access, NULL, RW_DEFAULT, NULL);
-
- uri_hash_sz[cur] = P2Ps[URI_HASH_N_INIT];
- uri_hash_overflow[cur] = P2Ps[URI_HASH_N_INIT] * URI_HASH_AVRG;
- uri_hash_ab[cur] = kmem_zalloc(sizeof (uri_hash_t) * uri_hash_sz[cur],
- KM_SLEEP);
- uri_hash_lru[cur] = uri_hash_ab[cur];
-
- nl7c_uri_kmc = kmem_cache_create("NL7C_uri_kmc", sizeof (uri_desc_t),
- 0, NULL, NULL, uri_kmc_reclaim, NULL, NULL, 0);
-
- nl7c_uri_rd_kmc = kmem_cache_create("NL7C_uri_rd_kmc",
- sizeof (uri_rd_t), 0, NULL, NULL, NULL, NULL, NULL, 0);
-
- uri_desb_kmc = kmem_cache_create("NL7C_uri_desb_kmc",
- sizeof (uri_desb_t), 0, NULL, NULL, NULL, NULL, NULL, 0);
-
- uri_segmap_kmc = kmem_cache_create("NL7C_uri_segmap_kmc",
- sizeof (uri_segmap_t), 0, NULL, NULL, NULL, NULL, NULL, 0);
-
- nl7c_http_init();
-}
-
-#define CV_SZ 16
-
-void
-nl7c_mi_report_hash(mblk_t *mp)
-{
- uri_hash_t *hp, *pend;
- uri_desc_t *uri;
- uint32_t cur;
- uint32_t new;
- int n, nz, tot;
- uint32_t cv[CV_SZ + 1];
-
- rw_enter(&uri_hash_access, RW_READER);
- cur = uri_hash_which;
- new = cur ? 0 : 1;
-next:
- for (n = 0; n <= CV_SZ; n++)
- cv[n] = 0;
- nz = 0;
- tot = 0;
- hp = &uri_hash_ab[cur][0];
- pend = &uri_hash_ab[cur][uri_hash_sz[cur]];
- while (hp < pend) {
- n = 0;
- for (uri = hp->list; uri != NULL; uri = uri->hash) {
- n++;
- }
- tot += n;
- if (n > 0)
- nz++;
- if (n > CV_SZ)
- n = CV_SZ;
- cv[n]++;
- hp++;
- }
-
- (void) mi_mpprintf(mp, "\nHash=%s, Buckets=%d, "
- "Avrg=%d\nCount by bucket:", cur != new ? "CUR" : "NEW",
- uri_hash_sz[cur], nz != 0 ? ((tot * 10 + 5) / nz) / 10 : 0);
- (void) mi_mpprintf(mp, "Free=%d", cv[0]);
- for (n = 1; n < CV_SZ; n++) {
- int pn = 0;
- char pv[5];
- char *pp = pv;
-
- for (pn = n; pn < 1000; pn *= 10)
- *pp++ = ' ';
- *pp = 0;
- (void) mi_mpprintf(mp, "%s%d=%d", pv, n, cv[n]);
- }
- (void) mi_mpprintf(mp, "Long=%d", cv[CV_SZ]);
-
- if (cur != new && uri_hash_ab[new] != NULL) {
- cur = new;
- goto next;
- }
- rw_exit(&uri_hash_access);
-}
-
-void
-nl7c_mi_report_uri(mblk_t *mp)
-{
- uri_hash_t *hp;
- uri_desc_t *uri;
- uint32_t cur;
- uint32_t new;
- int ix;
- int ret;
- char sc;
-
- rw_enter(&uri_hash_access, RW_READER);
- cur = uri_hash_which;
- new = cur ? 0 : 1;
-next:
- for (ix = 0; ix < uri_hash_sz[cur]; ix++) {
- hp = &uri_hash_ab[cur][ix];
- mutex_enter(&hp->lock);
- uri = hp->list;
- while (uri != NULL) {
- sc = *(uri->path.ep);
- *(uri->path.ep) = 0;
- ret = mi_mpprintf(mp, "%s: %d %d %d",
- uri->path.cp, (int)uri->resplen,
- (int)uri->respclen, (int)uri->count);
- *(uri->path.ep) = sc;
- if (ret == -1) break;
- uri = uri->hash;
- }
- mutex_exit(&hp->lock);
- if (ret == -1) break;
- }
- if (ret != -1 && cur != new && uri_hash_ab[new] != NULL) {
- cur = new;
- goto next;
- }
- rw_exit(&uri_hash_access);
-}
-
-/*
- * The uri_desc_t ref_t inactive function called on the last REF_RELE(),
- * free all resources contained in the uri_desc_t. Note, the uri_desc_t
- * will be freed by REF_RELE() on return.
- */
-
-void
-nl7c_uri_inactive(uri_desc_t *uri)
-{
- int64_t bytes = 0;
-
- if (uri->tail) {
- uri_rd_t *rdp = &uri->response;
- uri_rd_t *free = NULL;
-
- while (rdp) {
- if (rdp->off == -1) {
- bytes += rdp->sz;
- kmem_free(rdp->data.kmem, rdp->sz);
- } else {
- VN_RELE(rdp->data.vnode);
- }
- rdp = rdp->next;
- if (free != NULL) {
- kmem_cache_free(nl7c_uri_rd_kmc, free);
- }
- free = rdp;
- }
- }
- if (bytes) {
- atomic_add_64(&nl7c_uri_bytes, -bytes);
- }
- if (uri->scheme != NULL) {
- nl7c_http_free(uri->scheme);
- }
- if (uri->reqmp) {
- freeb(uri->reqmp);
- }
-}
-
-/*
- * The reclaim is called by the kmem subsystem when kmem is running
- * low. More work is needed to determine the best reclaim policy, for
- * now we just manipulate the nl7c_uri_max global maximum bytes threshold
- * value using a simple arithmetic backoff of the value every time this
- * function is called then call uri_reclaim() to enforce it.
- *
- * Note, this value remains in place and enforced for all subsequent
- * URI request/response processing.
- *
- * Note, nl7c_uri_max is currently initialized to 0 or infinite such that
- * the first call here set it to the current uri_bytes value then backoff
- * from there.
- *
- * XXX how do we determine when to increase nl7c_uri_max ???
- */
-
-/*ARGSUSED*/
-static void
-uri_kmc_reclaim(void *arg)
-{
- uint64_t new_max;
-
- if ((new_max = nl7c_uri_max) == 0) {
- /* Currently infinite, initialize to current bytes used */
- nl7c_uri_max = nl7c_uri_bytes;
- new_max = nl7c_uri_bytes;
- }
- if (new_max > 1) {
- /* Lower max_bytes to 93% of current value */
- new_max >>= 1; /* 50% */
- new_max += (new_max >> 1); /* 75% */
- new_max += (new_max >> 2); /* 93% */
- if (new_max < nl7c_uri_max)
- nl7c_uri_max = new_max;
- else
- nl7c_uri_max = 1;
- }
- nl7c_uri_reclaim();
-}
-
-/*
- * Delete a uri_desc_t from the URI hash.
- */
-
-static void
-uri_delete(uri_desc_t *del)
-{
- uint32_t hix;
- uri_hash_t *hp;
- uri_desc_t *uri;
- uri_desc_t *puri;
- uint32_t cur;
- uint32_t new;
-
- ASSERT(del->hash != URI_TEMP);
- rw_enter(&uri_hash_access, RW_WRITER);
- cur = uri_hash_which;
- new = cur ? 0 : 1;
-next:
- puri = NULL;
- hix = del->hvalue;
- URI_HASH_IX(hix, cur);
- hp = &uri_hash_ab[cur][hix];
- for (uri = hp->list; uri != NULL; uri = uri->hash) {
- if (uri != del) {
- puri = uri;
- continue;
- }
- /*
- * Found the URI, unlink from the hash chain,
- * drop locks, ref release it.
- */
- URI_HASH_UNLINK(cur, new, hp, puri, uri);
- rw_exit(&uri_hash_access);
- REF_RELE(uri);
- return;
- }
- if (cur != new && uri_hash_ab[new] != NULL) {
- /*
- * Not found in current hash and have a new hash so
- * check the new hash next.
- */
- cur = new;
- goto next;
- }
- rw_exit(&uri_hash_access);
-}
-
-/*
- * Add a uri_desc_t to the URI hash.
- */
-
-static void
-uri_add(uri_desc_t *uri, krw_t rwlock, boolean_t nonblocking)
-{
- uint32_t hix;
- uri_hash_t *hp;
- uint32_t cur = uri_hash_which;
- uint32_t new = cur ? 0 : 1;
-
- /*
- * Caller of uri_add() must hold the uri_hash_access rwlock.
- */
- ASSERT((rwlock == RW_READER && RW_READ_HELD(&uri_hash_access)) ||
- (rwlock == RW_WRITER && RW_WRITE_HELD(&uri_hash_access)));
- /*
- * uri_add() always succeeds so add a hash ref to the URI now.
- */
- REF_HOLD(uri);
-again:
- hix = uri->hvalue;
- URI_HASH_IX(hix, cur);
- if (uri_hash_ab[new] == NULL &&
- uri_hash_cnt[cur] < uri_hash_overflow[cur]) {
- /*
- * Easy case, no new hash and current hasn't overflowed,
- * add URI to current hash and return.
- *
- * Note, the check for uri_hash_cnt[] above aren't done
- * atomictally, i.e. multiple threads can be in this code
- * as RW_READER and update the cnt[], this isn't a problem
- * as the check is only advisory.
- */
- fast:
- atomic_inc_32(&uri_hash_cnt[cur]);
- hp = &uri_hash_ab[cur][hix];
- mutex_enter(&hp->lock);
- uri->hash = hp->list;
- hp->list = uri;
- mutex_exit(&hp->lock);
- rw_exit(&uri_hash_access);
- return;
- }
- if (uri_hash_ab[new] == NULL) {
- /*
- * Need a new a or b hash, if not already RW_WRITER
- * try to upgrade our lock to writer.
- */
- if (rwlock != RW_WRITER && ! rw_tryupgrade(&uri_hash_access)) {
- /*
- * Upgrade failed, we can't simple exit and reenter
- * the lock as after the exit and before the reenter
- * the whole world can change so just wait for writer
- * then do everything again.
- */
- if (nonblocking) {
- /*
- * Can't block, use fast-path above.
- *
- * XXX should have a background thread to
- * handle new ab[] in this case so as to
- * not overflow the cur hash to much.
- */
- goto fast;
- }
- rw_exit(&uri_hash_access);
- rwlock = RW_WRITER;
- rw_enter(&uri_hash_access, rwlock);
- cur = uri_hash_which;
- new = cur ? 0 : 1;
- goto again;
- }
- rwlock = RW_WRITER;
- if (uri_hash_ab[new] == NULL) {
- /*
- * Still need a new hash, allocate and initialize
- * the new hash.
- */
- uri_hash_n[new] = uri_hash_n[cur] + 1;
- if (uri_hash_n[new] == 0) {
- /*
- * No larger P2Ps[] value so use current,
- * i.e. 2 of the largest are better than 1 ?
- */
- uri_hash_n[new] = uri_hash_n[cur];
- cmn_err(CE_NOTE, "NL7C: hash index overflow");
- }
- uri_hash_sz[new] = P2Ps[uri_hash_n[new]];
- ASSERT(uri_hash_cnt[new] == 0);
- uri_hash_overflow[new] = uri_hash_sz[new] *
- URI_HASH_AVRG;
- uri_hash_ab[new] = kmem_zalloc(sizeof (uri_hash_t) *
- uri_hash_sz[new], nonblocking ? KM_NOSLEEP :
- KM_SLEEP);
- if (uri_hash_ab[new] == NULL) {
- /*
- * Alloc failed, use fast-path above.
- *
- * XXX should have a background thread to
- * handle new ab[] in this case so as to
- * not overflow the cur hash to much.
- */
- goto fast;
- }
- uri_hash_lru[new] = uri_hash_ab[new];
- }
- }
- /*
- * Hashed against current hash so migrate any current hash chain
- * members, if any.
- *
- * Note, the hash chain list can be checked for a non empty list
- * outside of the hash chain list lock as the hash chain struct
- * can't be destroyed while in the uri_hash_access rwlock, worst
- * case is that a non empty list is found and after acquiring the
- * lock another thread beats us to it (i.e. migrated the list).
- */
- hp = &uri_hash_ab[cur][hix];
- if (hp->list != NULL) {
- URI_HASH_MIGRATE(cur, hp, new);
- }
- /*
- * If new hash has overflowed before current hash has been
- * completely migrated then walk all current hash chains and
- * migrate list members now.
- */
- if (atomic_inc_32_nv(&uri_hash_cnt[new]) >= uri_hash_overflow[new]) {
- for (hix = 0; hix < uri_hash_sz[cur]; hix++) {
- hp = &uri_hash_ab[cur][hix];
- if (hp->list != NULL) {
- URI_HASH_MIGRATE(cur, hp, new);
- }
- }
- }
- /*
- * Add URI to new hash.
- */
- hix = uri->hvalue;
- URI_HASH_IX(hix, new);
- hp = &uri_hash_ab[new][hix];
- mutex_enter(&hp->lock);
- uri->hash = hp->list;
- hp->list = uri;
- mutex_exit(&hp->lock);
- /*
- * Last, check to see if last cur hash chain has been
- * migrated, if so free cur hash and make new hash cur.
- */
- if (uri_hash_cnt[cur] == 0) {
- /*
- * If we don't already hold the uri_hash_access rwlock for
- * RW_WRITE try to upgrade to RW_WRITE and if successful
- * check again and to see if still need to do the free.
- */
- if ((rwlock == RW_WRITER || rw_tryupgrade(&uri_hash_access)) &&
- uri_hash_cnt[cur] == 0 && uri_hash_ab[new] != 0) {
- kmem_free(uri_hash_ab[cur],
- sizeof (uri_hash_t) * uri_hash_sz[cur]);
- uri_hash_ab[cur] = NULL;
- uri_hash_lru[cur] = NULL;
- uri_hash_which = new;
- }
- }
- rw_exit(&uri_hash_access);
-}
-
-/*
- * Lookup a uri_desc_t in the URI hash, if found free the request uri_desc_t
- * and return the found uri_desc_t with a REF_HOLD() placed on it. Else, if
- * add B_TRUE use the request URI to create a new hash entry. Else if add
- * B_FALSE ...
- */
-
-static uri_desc_t *
-uri_lookup(uri_desc_t *ruri, boolean_t add, boolean_t nonblocking)
-{
- uint32_t hix;
- uri_hash_t *hp;
- uri_desc_t *uri;
- uri_desc_t *puri;
- uint32_t cur;
- uint32_t new;
- char *rcp = ruri->path.cp;
- char *rep = ruri->path.ep;
-
-again:
- rw_enter(&uri_hash_access, RW_READER);
- cur = uri_hash_which;
- new = cur ? 0 : 1;
-nexthash:
- puri = NULL;
- hix = ruri->hvalue;
- URI_HASH_IX(hix, cur);
- hp = &uri_hash_ab[cur][hix];
- mutex_enter(&hp->lock);
- for (uri = hp->list; uri != NULL; uri = uri->hash) {
- char *ap = uri->path.cp;
- char *bp = rcp;
- char a, b;
-
- /* Compare paths */
- while (bp < rep && ap < uri->path.ep) {
- if ((a = *ap) == '%') {
- /* Escaped hex multichar, convert it */
- H2A(ap, uri->path.ep, a);
- }
- if ((b = *bp) == '%') {
- /* Escaped hex multichar, convert it */
- H2A(bp, rep, b);
- }
- if (a != b) {
- /* Char's don't match */
- goto nexturi;
- }
- ap++;
- bp++;
- }
- if (bp != rep || ap != uri->path.ep) {
- /* Not same length */
- goto nexturi;
- }
- ap = uri->auth.cp;
- bp = ruri->auth.cp;
- if (ap != NULL) {
- if (bp == NULL) {
- /* URI has auth request URI doesn't */
- goto nexturi;
- }
- while (bp < ruri->auth.ep && ap < uri->auth.ep) {
- if ((a = *ap) == '%') {
- /* Escaped hex multichar, convert it */
- H2A(ap, uri->path.ep, a);
- }
- if ((b = *bp) == '%') {
- /* Escaped hex multichar, convert it */
- H2A(bp, rep, b);
- }
- if (a != b) {
- /* Char's don't match */
- goto nexturi;
- }
- ap++;
- bp++;
- }
- if (bp != ruri->auth.ep || ap != uri->auth.ep) {
- /* Not same length */
- goto nexturi;
- }
- } else if (bp != NULL) {
- /* URI doesn't have auth and request URI does */
- goto nexturi;
- }
- /*
- * Have a path/auth match so before any other processing
- * of requested URI, check for expire or request no cache
- * purge.
- */
- if (uri->expire >= 0 && uri->expire <= ddi_get_lbolt() ||
- ruri->nocache) {
- /*
- * URI has expired or request specified to not use
- * the cached version, unlink the URI from the hash
- * chain, release all locks, release the hash ref
- * on the URI, and last look it up again.
- *
- * Note, this will cause all variants of the named
- * URI to be purged.
- */
- if (puri != NULL) {
- puri->hash = uri->hash;
- } else {
- hp->list = uri->hash;
- }
- mutex_exit(&hp->lock);
- atomic_dec_32(&uri_hash_cnt[cur]);
- rw_exit(&uri_hash_access);
- if (ruri->nocache)
- nl7c_uri_purge++;
- else
- nl7c_uri_expire++;
- REF_RELE(uri);
- goto again;
- }
- if (uri->scheme != NULL) {
- /*
- * URI has scheme private qualifier(s), if request
- * URI doesn't or if no match skip this URI.
- */
- if (ruri->scheme == NULL ||
- ! nl7c_http_cmp(uri->scheme, ruri->scheme))
- goto nexturi;
- } else if (ruri->scheme != NULL) {
- /*
- * URI doesn't have scheme private qualifiers but
- * request URI does, no match, skip this URI.
- */
- goto nexturi;
- }
- /*
- * Have a match, ready URI for return, first put a reference
- * hold on the URI, if this URI is currently being processed
- * then have to wait for the processing to be completed and
- * redo the lookup, else return it.
- */
- REF_HOLD(uri);
- mutex_enter(&uri->proclock);
- if (uri->proc != NULL) {
- /* The URI is being processed, wait for completion */
- mutex_exit(&hp->lock);
- rw_exit(&uri_hash_access);
- if (! nonblocking &&
- cv_wait_sig(&uri->waiting, &uri->proclock)) {
- /*
- * URI has been processed but things may
- * have changed while we were away so do
- * most everything again.
- */
- mutex_exit(&uri->proclock);
- REF_RELE(uri);
- goto again;
- } else {
- /*
- * A nonblocking socket or an interrupted
- * cv_wait_sig() in the first case can't
- * block waiting for the processing of the
- * uri hash hit uri to complete, in both
- * cases just return failure to lookup.
- */
- mutex_exit(&uri->proclock);
- REF_RELE(uri);
- return (NULL);
- }
- }
- mutex_exit(&uri->proclock);
- uri->hit++;
- mutex_exit(&hp->lock);
- rw_exit(&uri_hash_access);
- return (uri);
- nexturi:
- puri = uri;
- }
- mutex_exit(&hp->lock);
- if (cur != new && uri_hash_ab[new] != NULL) {
- /*
- * Not found in current hash and have a new hash so
- * check the new hash next.
- */
- cur = new;
- goto nexthash;
- }
-add:
- if (! add) {
- /* Lookup only so return failure */
- rw_exit(&uri_hash_access);
- return (NULL);
- }
- /*
- * URI not hashed, finish intialization of the
- * request URI, add it to the hash, return it.
- */
- ruri->hit = 0;
- ruri->expire = -1;
- ruri->response.sz = 0;
- ruri->proc = (struct sonode *)~0;
- cv_init(&ruri->waiting, NULL, CV_DEFAULT, NULL);
- mutex_init(&ruri->proclock, NULL, MUTEX_DEFAULT, NULL);
- uri_add(ruri, RW_READER, nonblocking);
- /* uri_add() has done rw_exit(&uri_hash_access) */
- return (ruri);
-}
-
-/*
- * Reclaim URIs until max cache size threshold has been reached.
- *
- * A CLOCK based reclaim modified with a history (hit counter) counter.
- */
-
-static void
-nl7c_uri_reclaim(void)
-{
- uri_hash_t *hp, *start, *pend;
- uri_desc_t *uri;
- uri_desc_t *puri;
- uint32_t cur;
- uint32_t new;
-
- nl7c_uri_reclaim_calls++;
-again:
- rw_enter(&uri_hash_access, RW_WRITER);
- cur = uri_hash_which;
- new = cur ? 0 : 1;
-next:
- hp = uri_hash_lru[cur];
- start = hp;
- pend = &uri_hash_ab[cur][uri_hash_sz[cur]];
- while (nl7c_uri_bytes > nl7c_uri_max) {
- puri = NULL;
- for (uri = hp->list; uri != NULL; uri = uri->hash) {
- if (uri->hit != 0) {
- /*
- * Decrement URI activity counter and skip.
- */
- uri->hit--;
- puri = uri;
- continue;
- }
- if (uri->proc != NULL) {
- /*
- * Currently being processed by a socket, skip.
- */
- continue;
- }
- /*
- * Found a candidate, no hit(s) since added or last
- * reclaim pass, unlink from it's hash chain, update
- * lru scan pointer, drop lock, ref release it.
- */
- URI_HASH_UNLINK(cur, new, hp, puri, uri);
- if (cur == uri_hash_which) {
- if (++hp == pend) {
- /* Wrap pointer */
- hp = uri_hash_ab[cur];
- }
- uri_hash_lru[cur] = hp;
- }
- rw_exit(&uri_hash_access);
- REF_RELE(uri);
- nl7c_uri_reclaim_cnt++;
- goto again;
- }
- if (++hp == pend) {
- /* Wrap pointer */
- hp = uri_hash_ab[cur];
- }
- if (hp == start) {
- if (cur != new && uri_hash_ab[new] != NULL) {
- /*
- * Done with the current hash and have a
- * new hash so check the new hash next.
- */
- cur = new;
- goto next;
- }
- }
- }
- rw_exit(&uri_hash_access);
-}
-
-/*
- * Called for a socket which is being freed prior to close, e.g. errored.
- */
-
-void
-nl7c_urifree(struct sonode *so)
-{
- sotpi_info_t *sti = SOTOTPI(so);
- uri_desc_t *uri = (uri_desc_t *)sti->sti_nl7c_uri;
-
- sti->sti_nl7c_uri = NULL;
- if (uri->hash != URI_TEMP) {
- uri_delete(uri);
- mutex_enter(&uri->proclock);
- uri->proc = NULL;
- if (CV_HAS_WAITERS(&uri->waiting)) {
- cv_broadcast(&uri->waiting);
- }
- mutex_exit(&uri->proclock);
- nl7c_uri_free++;
- } else {
- /* No proclock as uri exclusively owned by so */
- uri->proc = NULL;
- nl7c_uri_temp_free++;
- }
- REF_RELE(uri);
-}
-
-/*
- * ...
- *
- * < 0 need more data
- *
- * 0 parse complete
- *
- * > 0 parse error
- */
-
-volatile uint64_t nl7c_resp_pfail = 0;
-volatile uint64_t nl7c_resp_ntemp = 0;
-volatile uint64_t nl7c_resp_pass = 0;
-
-static int
-nl7c_resp_parse(struct sonode *so, uri_desc_t *uri, char *data, int sz)
-{
- if (! nl7c_http_response(&data, &data[sz], uri, so)) {
- if (data == NULL) {
- /* Parse fail */
- goto pfail;
- }
- /* More data */
- data = NULL;
- } else if (data == NULL) {
- goto pass;
- }
- if (uri->hash != URI_TEMP && uri->nocache) {
- /*
- * After response parse now no cache,
- * delete it from cache, wakeup any
- * waiters on this URI, make URI_TEMP.
- */
- uri_delete(uri);
- mutex_enter(&uri->proclock);
- if (CV_HAS_WAITERS(&uri->waiting)) {
- cv_broadcast(&uri->waiting);
- }
- mutex_exit(&uri->proclock);
- uri->hash = URI_TEMP;
- nl7c_uri_temp_mk++;
- }
- if (data == NULL) {
- /* More data needed */
- return (-1);
- }
- /* Success */
- return (0);
-
-pfail:
- nl7c_resp_pfail++;
- return (EINVAL);
-
-pass:
- nl7c_resp_pass++;
- return (ENOTSUP);
-}
-
-/*
- * Called to sink application response data, the processing of the data
- * is the same for a cached or temp URI (i.e. a URI for which we aren't
- * going to cache the URI but want to parse it for detecting response
- * data end such that for a persistent connection we can parse the next
- * request).
- *
- * On return 0 is returned for sink success, > 0 on error, and < 0 on
- * no so URI (note, data not sinked).
- */
-
-int
-nl7c_data(struct sonode *so, uio_t *uio)
-{
- sotpi_info_t *sti = SOTOTPI(so);
- uri_desc_t *uri = (uri_desc_t *)sti->sti_nl7c_uri;
- iovec_t *iov;
- int cnt;
- int sz = uio->uio_resid;
- char *data, *alloc;
- char *bp;
- uri_rd_t *rdp;
- boolean_t first;
- int error, perror;
-
- nl7c_uri_data++;
-
- if (uri == NULL) {
- /* Socket & NL7C out of sync, disable NL7C */
- sti->sti_nl7c_flags = 0;
- nl7c_uri_NULL1++;
- return (-1);
- }
-
- if (sti->sti_nl7c_flags & NL7C_WAITWRITE) {
- sti->sti_nl7c_flags &= ~NL7C_WAITWRITE;
- first = B_TRUE;
- } else {
- first = B_FALSE;
- }
-
- alloc = kmem_alloc(sz, KM_SLEEP);
- URI_RD_ADD(uri, rdp, sz, -1);
-
- if (uri->hash != URI_TEMP && uri->count > nca_max_cache_size) {
- uri_delete(uri);
- uri->hash = URI_TEMP;
- }
- data = alloc;
- alloc = NULL;
- rdp->data.kmem = data;
- atomic_add_64(&nl7c_uri_bytes, sz);
-
- bp = data;
- while (uio->uio_resid > 0) {
- iov = uio->uio_iov;
- if ((cnt = iov->iov_len) == 0) {
- goto next;
- }
- cnt = MIN(cnt, uio->uio_resid);
- error = xcopyin(iov->iov_base, bp, cnt);
- if (error)
- goto fail;
-
- iov->iov_base += cnt;
- iov->iov_len -= cnt;
- uio->uio_resid -= cnt;
- uio->uio_loffset += cnt;
- bp += cnt;
- next:
- uio->uio_iov++;
- uio->uio_iovcnt--;
- }
-
- /* Successfull sink of data, response parse the data */
- perror = nl7c_resp_parse(so, uri, data, sz);
-
- /* Send the data out the connection */
- error = uri_rd_response(so, uri, rdp, first);
- if (error)
- goto fail;
-
- /* Success */
- if (perror == 0 &&
- ((uri->respclen == URI_LEN_NOVALUE &&
- uri->resplen == URI_LEN_NOVALUE) ||
- uri->count >= uri->resplen)) {
- /*
- * No more data needed and no pending response
- * data or current data count >= response length
- * so close the URI processing for this so.
- */
- nl7c_close(so);
- if (! (sti->sti_nl7c_flags & NL7C_SOPERSIST)) {
- /* Not a persistent connection */
- sti->sti_nl7c_flags = 0;
- }
- }
-
- return (0);
-
-fail:
- if (alloc != NULL) {
- kmem_free(alloc, sz);
- }
- sti->sti_nl7c_flags = 0;
- nl7c_urifree(so);
-
- return (error);
-}
-
-/*
- * Called to read data from file "*fp" at offset "*off" of length "*len"
- * for a maximum of "*max_rem" bytes.
- *
- * On success a pointer to the kmem_alloc()ed file data is returned, "*off"
- * and "*len" are updated for the acutal number of bytes read and "*max_rem"
- * is updated with the number of bytes remaining to be read.
- *
- * Else, "NULL" is returned.
- */
-
-static char *
-nl7c_readfile(file_t *fp, u_offset_t *off, int *len, int max, int *ret)
-{
- vnode_t *vp = fp->f_vnode;
- int flg = 0;
- size_t size = MIN(*len, max);
- char *data;
- int error;
- uio_t uio;
- iovec_t iov;
-
- (void) VOP_RWLOCK(vp, flg, NULL);
-
- if (*off > MAXOFFSET_T) {
- VOP_RWUNLOCK(vp, flg, NULL);
- *ret = EFBIG;
- return (NULL);
- }
-
- if (*off + size > MAXOFFSET_T)
- size = (ssize32_t)(MAXOFFSET_T - *off);
-
- data = kmem_alloc(size, KM_SLEEP);
-
- iov.iov_base = data;
- iov.iov_len = size;
- uio.uio_loffset = *off;
- uio.uio_iov = &iov;
- uio.uio_iovcnt = 1;
- uio.uio_resid = size;
- uio.uio_segflg = UIO_SYSSPACE;
- uio.uio_llimit = MAXOFFSET_T;
- uio.uio_fmode = fp->f_flag;
-
- error = VOP_READ(vp, &uio, fp->f_flag, fp->f_cred, NULL);
- VOP_RWUNLOCK(vp, flg, NULL);
- *ret = error;
- if (error) {
- kmem_free(data, size);
- return (NULL);
- }
- *len = size;
- *off += size;
- return (data);
-}
-
-/*
- * Called to sink application response sendfilev, as with nl7c_data() above
- * all the data will be processed by NL7C unless there's an error.
- */
-
-int
-nl7c_sendfilev(struct sonode *so, u_offset_t *fileoff, sendfilevec_t *sfvp,
- int sfvc, ssize_t *xfer)
-{
- sotpi_info_t *sti = SOTOTPI(so);
- uri_desc_t *uri = (uri_desc_t *)sti->sti_nl7c_uri;
- file_t *fp = NULL;
- vnode_t *vp = NULL;
- char *data = NULL;
- u_offset_t off;
- int len;
- int cnt;
- int total_count = 0;
- char *alloc;
- uri_rd_t *rdp;
- int max;
- int perror;
- int error = 0;
- boolean_t first = B_TRUE;
-
- nl7c_uri_sendfilev++;
-
- if (uri == NULL) {
- /* Socket & NL7C out of sync, disable NL7C */
- sti->sti_nl7c_flags = 0;
- nl7c_uri_NULL2++;
- return (0);
- }
-
- if (sti->sti_nl7c_flags & NL7C_WAITWRITE)
- sti->sti_nl7c_flags &= ~NL7C_WAITWRITE;
-
- while (sfvc-- > 0) {
- /*
- * off - the current sfv read file offset or user address.
- *
- * len - the current sfv length in bytes.
- *
- * cnt - number of bytes kmem_alloc()ed.
- *
- * alloc - the kmem_alloc()ed buffer of size "cnt".
- *
- * data - copy of "alloc" used for post alloc references.
- *
- * fp - the current sfv file_t pointer.
- *
- * vp - the current "*vp" vnode_t pointer.
- *
- * Note, for "data" and "fp" and "vp" a NULL value is used
- * when not allocated such that the common failure path "fail"
- * is used.
- */
- off = sfvp->sfv_off;
- len = sfvp->sfv_len;
- cnt = len;
-
- if (len == 0) {
- sfvp++;
- continue;
- }
-
- if (sfvp->sfv_fd == SFV_FD_SELF) {
- /*
- * User memory, copyin() all the bytes.
- */
- alloc = kmem_alloc(cnt, KM_SLEEP);
- error = xcopyin((caddr_t)(uintptr_t)off, alloc, cnt);
- if (error)
- goto fail;
- } else {
- /*
- * File descriptor, prefetch some bytes.
- */
- if ((fp = getf(sfvp->sfv_fd)) == NULL) {
- error = EBADF;
- goto fail;
- }
- if ((fp->f_flag & FREAD) == 0) {
- error = EACCES;
- goto fail;
- }
- vp = fp->f_vnode;
- if (vp->v_type != VREG) {
- error = EINVAL;
- goto fail;
- }
- VN_HOLD(vp);
-
- /* Read max_rem bytes from file for prefetch */
- if (nl7c_use_kmem) {
- max = cnt;
- } else {
- max = MAXBSIZE * nl7c_file_prefetch;
- }
- alloc = nl7c_readfile(fp, &off, &cnt, max, &error);
- if (alloc == NULL)
- goto fail;
-
- releasef(sfvp->sfv_fd);
- fp = NULL;
- }
- URI_RD_ADD(uri, rdp, cnt, -1);
- data = alloc;
- alloc = NULL;
- rdp->data.kmem = data;
- total_count += cnt;
- if (uri->hash != URI_TEMP && total_count > nca_max_cache_size) {
- uri_delete(uri);
- uri->hash = URI_TEMP;
- }
-
- /* Response parse */
- perror = nl7c_resp_parse(so, uri, data, len);
-
- /* Send kmem data out the connection */
- error = uri_rd_response(so, uri, rdp, first);
-
- if (error)
- goto fail;
-
- if (sfvp->sfv_fd != SFV_FD_SELF) {
- /*
- * File descriptor, if any bytes left save vnode_t.
- */
- if (len > cnt) {
- /* More file data so add it */
- URI_RD_ADD(uri, rdp, len - cnt, off);
- rdp->data.vnode = vp;
-
- /* Send vnode data out the connection */
- error = uri_rd_response(so, uri, rdp, first);
- } else {
- /* All file data fit in the prefetch */
- VN_RELE(vp);
- }
- *fileoff += len;
- vp = NULL;
- }
- *xfer += len;
- sfvp++;
-
- if (first)
- first = B_FALSE;
- }
- if (total_count > 0) {
- atomic_add_64(&nl7c_uri_bytes, total_count);
- }
- if (perror == 0 &&
- ((uri->respclen == URI_LEN_NOVALUE &&
- uri->resplen == URI_LEN_NOVALUE) ||
- uri->count >= uri->resplen)) {
- /*
- * No more data needed and no pending response
- * data or current data count >= response length
- * so close the URI processing for this so.
- */
- nl7c_close(so);
- if (! (sti->sti_nl7c_flags & NL7C_SOPERSIST)) {
- /* Not a persistent connection */
- sti->sti_nl7c_flags = 0;
- }
- }
-
- return (0);
-
-fail:
- if (error == EPIPE)
- tsignal(curthread, SIGPIPE);
-
- if (alloc != NULL)
- kmem_free(data, len);
-
- if (vp != NULL)
- VN_RELE(vp);
-
- if (fp != NULL)
- releasef(sfvp->sfv_fd);
-
- if (total_count > 0) {
- atomic_add_64(&nl7c_uri_bytes, total_count);
- }
-
- sti->sti_nl7c_flags = 0;
- nl7c_urifree(so);
-
- return (error);
-}
-
-/*
- * Called for a socket which is closing or when an application has
- * completed sending all the response data (i.e. for a persistent
- * connection called once for each completed application response).
- */
-
-void
-nl7c_close(struct sonode *so)
-{
- sotpi_info_t *sti = SOTOTPI(so);
- uri_desc_t *uri = (uri_desc_t *)sti->sti_nl7c_uri;
-
- if (uri == NULL) {
- /*
- * No URI being processed so might be a listen()er
- * if so do any cleanup, else nothing more to do.
- */
- if (so->so_state & SS_ACCEPTCONN) {
- (void) nl7c_close_addr(so);
- }
- return;
- }
- sti->sti_nl7c_uri = NULL;
- if (uri->hash != URI_TEMP) {
- mutex_enter(&uri->proclock);
- uri->proc = NULL;
- if (CV_HAS_WAITERS(&uri->waiting)) {
- cv_broadcast(&uri->waiting);
- }
- mutex_exit(&uri->proclock);
- nl7c_uri_close++;
- } else {
- /* No proclock as uri exclusively owned by so */
- uri->proc = NULL;
- nl7c_uri_temp_close++;
- }
- REF_RELE(uri);
- if (nl7c_uri_max > 0 && nl7c_uri_bytes > nl7c_uri_max) {
- nl7c_uri_reclaim();
- }
-}
-
-/*
- * The uri_segmap_t ref_t inactive function called on the last REF_RELE(),
- * release the segmap mapping. Note, the uri_segmap_t will be freed by
- * REF_RELE() on return.
- */
-
-void
-uri_segmap_inactive(uri_segmap_t *smp)
-{
- if (!segmap_kpm) {
- (void) segmap_fault(kas.a_hat, segkmap, smp->base,
- smp->len, F_SOFTUNLOCK, S_OTHER);
- }
- (void) segmap_release(segkmap, smp->base, SM_DONTNEED);
- VN_RELE(smp->vp);
-}
-
-/*
- * The call-back for desballoc()ed mblk_t's, if a segmap mapped mblk_t
- * release the reference, one per desballoc() of a segmap page, if a rd_t
- * mapped mblk_t release the reference, one per desballoc() of a uri_desc_t,
- * last kmem free the uri_desb_t.
- */
-
-static void
-uri_desb_free(uri_desb_t *desb)
-{
- if (desb->segmap != NULL) {
- REF_RELE(desb->segmap);
- }
- REF_RELE(desb->uri);
- kmem_cache_free(uri_desb_kmc, desb);
-}
-
-/*
- * Segmap map up to a page of a uri_rd_t file descriptor.
- */
-
-uri_segmap_t *
-uri_segmap_map(uri_rd_t *rdp, int bytes)
-{
- uri_segmap_t *segmap = kmem_cache_alloc(uri_segmap_kmc, KM_SLEEP);
- int len = MIN(rdp->sz, MAXBSIZE);
-
- if (len > bytes)
- len = bytes;
-
- REF_INIT(segmap, 1, uri_segmap_inactive, uri_segmap_kmc);
- segmap->len = len;
- VN_HOLD(rdp->data.vnode);
- segmap->vp = rdp->data.vnode;
-
- segmap->base = segmap_getmapflt(segkmap, segmap->vp, rdp->off, len,
- segmap_kpm ? SM_FAULT : 0, S_READ);
-
- if (segmap_fault(kas.a_hat, segkmap, segmap->base, len,
- F_SOFTLOCK, S_READ) != 0) {
- REF_RELE(segmap);
- return (NULL);
- }
- return (segmap);
-}
-
-/*
- * Chop up the kernel virtual memory area *data of size *sz bytes for
- * a maximum of *bytes bytes into an besballoc()ed mblk_t chain using
- * the given template uri_desb_t *temp of max_mblk bytes per.
- *
- * The values of *data, *sz, and *bytes are updated on return, the
- * mblk_t chain is returned.
- */
-
-static mblk_t *
-uri_desb_chop(char **data, size_t *sz, int *bytes, uri_desb_t *temp,
- int max_mblk, char *eoh, mblk_t *persist)
-{
- char *ldata = *data;
- size_t lsz = *sz;
- int lbytes = bytes ? *bytes : lsz;
- uri_desb_t *desb;
- mblk_t *mp = NULL;
- mblk_t *nmp, *pmp = NULL;
- int msz;
-
- if (lbytes == 0 && lsz == 0)
- return (NULL);
-
- while (lbytes > 0 && lsz > 0) {
- msz = MIN(lbytes, max_mblk);
- msz = MIN(msz, lsz);
- if (persist && eoh >= ldata && eoh < &ldata[msz]) {
- msz = (eoh - ldata);
- pmp = persist;
- persist = NULL;
- if (msz == 0) {
- nmp = pmp;
- pmp = NULL;
- goto zero;
- }
- }
- desb = kmem_cache_alloc(uri_desb_kmc, KM_SLEEP);
- REF_HOLD(temp->uri);
- if (temp->segmap) {
- REF_HOLD(temp->segmap);
- }
- bcopy(temp, desb, sizeof (*desb));
- desb->frtn.free_arg = (caddr_t)desb;
- nmp = desballoc((uchar_t *)ldata, msz, BPRI_HI, &desb->frtn);
- if (nmp == NULL) {
- if (temp->segmap) {
- REF_RELE(temp->segmap);
- }
- REF_RELE(temp->uri);
- if (mp != NULL) {
- mp->b_next = NULL;
- freemsg(mp);
- }
- if (persist != NULL) {
- freeb(persist);
- }
- return (NULL);
- }
- nmp->b_wptr += msz;
- zero:
- if (mp != NULL) {
- mp->b_next->b_cont = nmp;
- } else {
- mp = nmp;
- }
- if (pmp != NULL) {
- nmp->b_cont = pmp;
- nmp = pmp;
- pmp = NULL;
- }
- mp->b_next = nmp;
- ldata += msz;
- lsz -= msz;
- lbytes -= msz;
- }
- *data = ldata;
- *sz = lsz;
- if (bytes)
- *bytes = lbytes;
- return (mp);
-}
-
-/*
- * Experimential noqwait (i.e. no canput()/qwait() checks), just send
- * the entire mblk_t chain down without flow-control checks.
- */
-
-static int
-kstrwritempnoqwait(struct vnode *vp, mblk_t *mp)
-{
- struct stdata *stp;
- int error = 0;
-
- ASSERT(vp->v_stream);
- stp = vp->v_stream;
-
- /* Fast check of flags before acquiring the lock */
- if (stp->sd_flag & (STWRERR|STRHUP|STPLEX)) {
- mutex_enter(&stp->sd_lock);
- error = strgeterr(stp, STWRERR|STRHUP|STPLEX, 0);
- mutex_exit(&stp->sd_lock);
- if (error != 0) {
- if (!(stp->sd_flag & STPLEX) &&
- (stp->sd_wput_opt & SW_SIGPIPE)) {
- error = EPIPE;
- }
- return (error);
- }
- }
- putnext(stp->sd_wrq, mp);
- return (0);
-}
-
-/*
- * Send the URI uri_desc_t *uri response uri_rd_t *rdp out the socket_t *so.
- */
-
-static int
-uri_rd_response(struct sonode *so,
- uri_desc_t *uri,
- uri_rd_t *rdp,
- boolean_t first)
-{
- vnode_t *vp = SOTOV(so);
- int max_mblk = (int)vp->v_stream->sd_maxblk;
- int wsz;
- mblk_t *mp, *wmp, *persist;
- int write_bytes;
- uri_rd_t rd;
- uri_desb_t desb;
- uri_segmap_t *segmap = NULL;
- char *segmap_data;
- size_t segmap_sz;
- int error;
- int fflg = ((so->so_state & SS_NDELAY) ? FNDELAY : 0) |
- ((so->so_state & SS_NONBLOCK) ? FNONBLOCK : 0);
-
-
- /* Initialize template uri_desb_t */
- desb.frtn.free_func = uri_desb_free;
- desb.frtn.free_arg = NULL;
- desb.uri = uri;
-
- /* Get a local copy of the rd_t */
- bcopy(rdp, &rd, sizeof (rd));
- do {
- if (first) {
- /*
- * For first kstrwrite() enough data to get
- * things going, note non blocking version of
- * kstrwrite() will be used below.
- */
- write_bytes = P2ROUNDUP((max_mblk * 4),
- MAXBSIZE * nl7c_file_prefetch);
- } else {
- if ((write_bytes = so->so_sndbuf) == 0)
- write_bytes = vp->v_stream->sd_qn_maxpsz;
- ASSERT(write_bytes > 0);
- write_bytes = P2ROUNDUP(write_bytes, MAXBSIZE);
- }
- /*
- * Chop up to a write_bytes worth of data.
- */
- wmp = NULL;
- wsz = write_bytes;
- do {
- if (rd.sz == 0)
- break;
- if (rd.off == -1) {
- if (uri->eoh >= rd.data.kmem &&
- uri->eoh < &rd.data.kmem[rd.sz]) {
- persist = nl7c_http_persist(so);
- } else {
- persist = NULL;
- }
- desb.segmap = NULL;
- mp = uri_desb_chop(&rd.data.kmem, &rd.sz,
- &wsz, &desb, max_mblk, uri->eoh, persist);
- if (mp == NULL) {
- error = ENOMEM;
- goto invalidate;
- }
- } else {
- if (segmap == NULL) {
- segmap = uri_segmap_map(&rd,
- write_bytes);
- if (segmap == NULL) {
- error = ENOMEM;
- goto invalidate;
- }
- desb.segmap = segmap;
- segmap_data = segmap->base;
- segmap_sz = segmap->len;
- }
- mp = uri_desb_chop(&segmap_data, &segmap_sz,
- &wsz, &desb, max_mblk, NULL, NULL);
- if (mp == NULL) {
- error = ENOMEM;
- goto invalidate;
- }
- if (segmap_sz == 0) {
- rd.sz -= segmap->len;
- rd.off += segmap->len;
- REF_RELE(segmap);
- segmap = NULL;
- }
- }
- if (wmp == NULL) {
- wmp = mp;
- } else {
- wmp->b_next->b_cont = mp;
- wmp->b_next = mp->b_next;
- mp->b_next = NULL;
- }
- } while (wsz > 0 && rd.sz > 0);
-
- wmp->b_next = NULL;
- if (first) {
- /* First kstrwrite(), use noqwait */
- if ((error = kstrwritempnoqwait(vp, wmp)) != 0)
- goto invalidate;
- /*
- * For the rest of the kstrwrite()s use SO_SNDBUF
- * worth of data at a time, note these kstrwrite()s
- * may (will) block one or more times.
- */
- first = B_FALSE;
- } else {
- if ((error = kstrwritemp(vp, wmp, fflg)) != 0) {
- if (error == EAGAIN) {
- nl7c_uri_rd_EAGAIN++;
- if ((error =
- kstrwritempnoqwait(vp, wmp)) != 0)
- goto invalidate;
- } else
- goto invalidate;
- }
- }
- } while (rd.sz > 0);
-
- return (0);
-
-invalidate:
- if (segmap) {
- REF_RELE(segmap);
- }
- if (wmp)
- freemsg(wmp);
-
- return (error);
-}
-
-/*
- * Send the URI uri_desc_t *uri response out the socket_t *so.
- */
-
-static int
-uri_response(struct sonode *so, uri_desc_t *uri)
-{
- uri_rd_t *rdp = &uri->response;
- boolean_t first = B_TRUE;
- int error;
-
- while (rdp != NULL) {
- error = uri_rd_response(so, uri, rdp, first);
- if (error != 0) {
- goto invalidate;
- }
- first = B_FALSE;
- rdp = rdp->next;
- }
- return (0);
-
-invalidate:
- if (uri->hash != URI_TEMP)
- uri_delete(uri);
- return (error);
-}
-
-/*
- * The pchars[] array is indexed by a char to determine if it's a
- * valid URI path component chararcter where:
- *
- * pchar = unreserved | escaped |
- * ":" | "@" | "&" | "=" | "+" | "$" | ","
- *
- * unreserved = alphanum | mark
- *
- * alphanum = alpha | digit
- *
- * alpha = lowalpha | upalpha
- *
- * lowalpha = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" |
- * "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" |
- * "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" |
- * "y" | "z"
- *
- * upalpha = "A" | "B" | "C" | "D" | "E" | "F" | "G" | "H" |
- * "I" | "J" | "K" | "L" | "M" | "N" | "O" | "P" |
- * "Q" | "R" | "S" | "T" | "U" | "V" | "W" | "X" |
- * "Y" | "Z"
- *
- * digit = "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" |
- * "8" | "9"
- *
- * mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")"
- *
- * escaped = "%" hex hex
- * hex = digit | "A" | "B" | "C" | "D" | "E" | "F" |
- * "a" | "b" | "c" | "d" | "e" | "f"
- */
-
-static char pchars[] = {
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0x00 - 0x07 */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0x08 - 0x0F */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0x10 - 0x17 */
- 0, 0, 0, 0, 0, 0, 0, 0, /* 0x18 - 0x1F */
- 0, 1, 0, 0, 1, 1, 1, 1, /* 0x20 - 0x27 */
- 0, 0, 1, 1, 1, 1, 1, 1, /* 0x28 - 0x2F */
- 1, 1, 1, 1, 1, 1, 1, 1, /* 0x30 - 0x37 */
- 1, 1, 1, 0, 0, 1, 0, 0, /* 0x38 - 0x3F */
- 1, 1, 1, 1, 1, 1, 1, 1, /* 0x40 - 0x47 */
- 1, 1, 1, 1, 1, 1, 1, 1, /* 0x48 - 0x4F */
- 1, 1, 1, 1, 1, 1, 1, 1, /* 0x50 - 0x57 */
- 1, 1, 1, 0, 0, 0, 0, 1, /* 0x58 - 0x5F */
- 0, 1, 1, 1, 1, 1, 1, 1, /* 0x60 - 0x67 */
- 1, 1, 1, 1, 1, 1, 1, 1, /* 0x68 - 0x6F */
- 1, 1, 1, 1, 1, 1, 1, 1, /* 0x70 - 0x77 */
- 1, 1, 1, 0, 0, 0, 1, 0 /* 0x78 - 0x7F */
-};
-
-#define PCHARS_MASK 0x7F
-
-/*
- * This is the main L7 request message parse, we are called each time
- * new data is availble for a socket, each time a single buffer of the
- * entire message to date is given.
- *
- * Here we parse the request looking for the URI, parse it, and if a
- * supported scheme call the scheme parser to commplete the parse of any
- * headers which may further qualify the identity of the requested object
- * then lookup it up in the URI hash.
- *
- * Return B_TRUE for more processing.
- *
- * Note, at this time the parser supports the generic message format as
- * specified in RFC 822 with potentional limitations as specified in RFC
- * 2616 for HTTP messages.
- *
- * Note, the caller supports an mblk_t chain, for now the parser(s)
- * require the complete header in a single mblk_t. This is the common
- * case and certainly for high performance environments, if at a future
- * date mblk_t chains are important the parse can be reved to process
- * mblk_t chains.
- */
-
-boolean_t
-nl7c_parse(struct sonode *so, boolean_t nonblocking, boolean_t *ret)
-{
- sotpi_info_t *sti = SOTOTPI(so);
- char *cp = (char *)sti->sti_nl7c_rcv_mp->b_rptr;
- char *ep = (char *)sti->sti_nl7c_rcv_mp->b_wptr;
- char *get = "GET ";
- char *post = "POST ";
- char c;
- char *uris;
- uri_desc_t *uri = NULL;
- uri_desc_t *ruri = NULL;
- mblk_t *reqmp;
- uint32_t hv = 0;
-
- if ((reqmp = dupb(sti->sti_nl7c_rcv_mp)) == NULL) {
- nl7c_uri_pass_dupbfail++;
- goto pass;
- }
- /*
- * Allocate and initialize minimumal state for the request
- * uri_desc_t, in the cache hit case this uri_desc_t will
- * be freed.
- */
- uri = kmem_cache_alloc(nl7c_uri_kmc, KM_SLEEP);
- REF_INIT(uri, 1, nl7c_uri_inactive, nl7c_uri_kmc);
- uri->hash = NULL;
- uri->tail = NULL;
- uri->scheme = NULL;
- uri->count = 0;
- uri->reqmp = reqmp;
-
- /*
- * Set request time to current time.
- */
- sti->sti_nl7c_rtime = gethrestime_sec();
-
- /*
- * Parse the Request-Line for the URI.
- *
- * For backwards HTTP version compatable reasons skip any leading
- * CRLF (or CR or LF) line terminator(s) preceding Request-Line.
- */
- while (cp < ep && (*cp == '\r' || *cp == '\n')) {
- cp++;
- }
- while (cp < ep && *get == *cp) {
- get++;
- cp++;
- }
- if (*get != 0) {
- /* Note a "GET", check for "POST" */
- while (cp < ep && *post == *cp) {
- post++;
- cp++;
- }
- if (*post != 0) {
- if (cp == ep) {
- nl7c_uri_more_get++;
- goto more;
- }
- /* Not a "GET" or a "POST", just pass */
- nl7c_uri_pass_method++;
- goto pass;
- }
- /* "POST", don't cache but still may want to parse */
- uri->hash = URI_TEMP;
- }
- /*
- * Skip over URI path char(s) and save start and past end pointers.
- */
- uris = cp;
- while (cp < ep && (c = *cp) != ' ' && c != '\r') {
- if (c == '?') {
- /* Don't cache but still may want to parse */
- uri->hash = URI_TEMP;
- }
- CHASH(hv, c);
- cp++;
- }
- if (c != '\r' && cp == ep) {
- nl7c_uri_more_eol++;
- goto more;
- }
- /*
- * Request-Line URI parsed, pass the rest of the request on
- * to the the http scheme parse.
- */
- uri->path.cp = uris;
- uri->path.ep = cp;
- uri->hvalue = hv;
- if (! nl7c_http_request(&cp, ep, uri, so) || cp == NULL) {
- /*
- * Parse not successful or pass on request, the pointer
- * to the parse pointer "cp" is overloaded such that ! NULL
- * for more data and NULL for bad parse of request or pass.
- */
- if (cp != NULL) {
- nl7c_uri_more_http++;
- goto more;
- }
- nl7c_uri_pass_http++;
- goto pass;
- }
- if (uri->nocache) {
- uri->hash = URI_TEMP;
- (void) uri_lookup(uri, B_FALSE, nonblocking);
- } else if (uri->hash == URI_TEMP) {
- uri->nocache = B_TRUE;
- (void) uri_lookup(uri, B_FALSE, nonblocking);
- }
-
- if (uri->hash == URI_TEMP) {
- if (sti->sti_nl7c_flags & NL7C_SOPERSIST) {
- /* Temporary URI so skip hash processing */
- nl7c_uri_request++;
- nl7c_uri_temp++;
- goto temp;
- }
- /* Not persistent so not interested in the response */
- nl7c_uri_pass_temp++;
- goto pass;
- }
- /*
- * Check the URI hash for a cached response, save the request
- * uri in case we need it below.
- */
- ruri = uri;
- if ((uri = uri_lookup(uri, B_TRUE, nonblocking)) == NULL) {
- /*
- * Failed to lookup due to nonblocking wait required,
- * interrupted cv_wait_sig(), KM_NOSLEEP memory alloc
- * failure, ... Just pass on this request.
- */
- nl7c_uri_pass_addfail++;
- goto pass;
- }
- nl7c_uri_request++;
- if (uri->response.sz > 0) {
- /*
- * We have the response cached, update recv mblk rptr
- * to reflect the data consumed in parse.
- */
- mblk_t *mp = sti->sti_nl7c_rcv_mp;
-
- if (cp == (char *)mp->b_wptr) {
- sti->sti_nl7c_rcv_mp = mp->b_cont;
- mp->b_cont = NULL;
- freeb(mp);
- } else {
- mp->b_rptr = (unsigned char *)cp;
- }
- nl7c_uri_hit++;
- /* If logging enabled log request */
- if (nl7c_logd_enabled) {
- ipaddr_t faddr;
-
- if (so->so_family == AF_INET) {
- /* Only support IPv4 addrs */
- faddr = ((struct sockaddr_in *)
- sti->sti_faddr_sa) ->sin_addr.s_addr;
- } else {
- faddr = 0;
- }
- /* XXX need to pass response type, e.g. 200, 304 */
- nl7c_logd_log(ruri, uri, sti->sti_nl7c_rtime, faddr);
- }
-
- /* If conditional request check for substitute response */
- if (ruri->conditional) {
- uri = nl7c_http_cond(ruri, uri);
- }
-
- /*
- * Release reference on request URI, send the response out
- * the socket, release reference on response uri, set the
- * *ret value to B_TRUE to indicate request was consumed
- * then return B_FALSE to indcate no more data needed.
- */
- REF_RELE(ruri);
- (void) uri_response(so, uri);
- REF_RELE(uri);
- *ret = B_TRUE;
- return (B_FALSE);
- }
- /*
- * Miss the cache, the request URI is in the cache waiting for
- * application write-side data to fill it.
- */
- nl7c_uri_miss++;
-temp:
- /*
- * A miss or temp URI for which response data is needed, link
- * uri to so and so to uri, set WAITWRITE in the so such that
- * read-side processing is suspended (so the next read() gets
- * the request data) until a write() is processed by NL7C.
- *
- * Note, sti->sti_nl7c_uri now owns the REF_INIT() ref.
- */
- uri->proc = so;
- sti->sti_nl7c_uri = uri;
- sti->sti_nl7c_flags |= NL7C_WAITWRITE;
- *ret = B_FALSE;
- return (B_FALSE);
-
-more:
- /* More data is needed, note fragmented recv not supported */
- nl7c_uri_more++;
-
-pass:
- /* Pass on this request */
- nl7c_uri_pass++;
- nl7c_uri_request++;
- if (ruri != NULL) {
- REF_RELE(ruri);
- }
- if (uri) {
- REF_RELE(uri);
- }
- sti->sti_nl7c_flags = 0;
- *ret = B_FALSE;
- return (B_FALSE);
-}
diff --git a/usr/src/uts/common/fs/sockfs/nl7curi.h b/usr/src/uts/common/fs/sockfs/nl7curi.h
deleted file mode 100644
index d002a0e5f9..0000000000
--- a/usr/src/uts/common/fs/sockfs/nl7curi.h
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * 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 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _SYS_SOCKFS_NL7CURI_H
-#define _SYS_SOCKFS_NL7CURI_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <sys/types.h>
-#include <sys/atomic.h>
-#include <sys/cmn_err.h>
-#include <sys/stropts.h>
-#include <sys/socket.h>
-#include <sys/socketvar.h>
-
-#undef PROMIF_DEBUG
-
-/*
- * Some usefull chararcter macros:
- */
-
-#ifndef tolower
-#define tolower(c) ((c) >= 'A' && (c) <= 'Z' ? (c) | 0x20 : (c))
-#endif
-
-#ifndef isdigit
-#define isdigit(c) ((c) >= '0' && (c) <= '9')
-#endif
-
-#ifndef isalpha
-#define isalpha(c) (((c) >= 'A' && (c) <= 'Z') || ((c) >= 'a' && (c) <= 'z'))
-#endif
-
-#ifndef isspace
-#define isspace(c) ((c) == ' ' || (c) == '\t' || (c) == '\n' || \
- (c) == '\r' || (c) == '\f' || (c) == '\013')
-#endif
-
-/*
- * ref_t - reference type, ...
- *
- * Note, all struct's must contain a single ref_t, all must use
- * kmem_cache, all must use the REF_* macros for free.
- */
-
-typedef struct ref_s {
- uint32_t cnt; /* Reference count */
- void (*last)(void *); /* Call-back for last ref */
- kmem_cache_t *kmc; /* Container allocator cache */
-} ref_t;
-
-#define REF_INIT(container, count, inactive, kmem) { \
- (container)->ref.cnt = (count); \
- (container)->ref.last = (void (*)(void *))((inactive)); \
- (container)->ref.kmc = (kmem); \
-}
-
-#define REF_HOLD(container) { \
- atomic_inc_32(&(container)->ref.cnt); \
- ASSERT((container)->ref.cnt != 0); \
-}
-
-#define REF_RELE(container) { \
- if (atomic_dec_32_nv(&(container)->ref.cnt) == 0) { \
- (container)->ref.last((container)); \
- kmem_cache_free((container)->ref.kmc, (container)); \
- } \
-}
-
-#define REF_COUNT(container) (container)->ref.cnt
-
-#define REF_ASSERT(container, count) \
- ASSERT((container)->ref.cnt == (count));
-
-/*
- * str_t - string type, used to access a an arbitrary span of a char[].
- */
-
-typedef struct str_s {
- char *cp; /* Char pointer current char */
- char *ep; /* Char pointer past end of string */
-} str_t;
-
-/*
- * uri_*_t - URI descriptor, used to describe a cached URI object.
- */
-
-typedef struct uri_rd_s {
- size_t sz; /* Size of data */
- offset_t off; /* Offset into file or -1 for kmem */
- union { /* Response data */
- char *kmem; /* Data in kmem */
- vnode_t *vnode; /* Data in vnode */
- } data;
- struct uri_rd_s *next; /* Next response descriptor */
-} uri_rd_t;
-
-typedef struct uri_desc_s {
- struct uri_desc_s *hash; /* Hash *next */
- uint64_t hit; /* Hit counter */
- clock_t expire; /* URI lbolt expires on (-1 = NEVER) */
-#ifdef notyet
- void *sslctx; /* SSL context */
-#endif
- boolean_t nocache; /* URI no cache */
- boolean_t conditional; /* Conditional response */
- uint32_t hvalue; /* Hashed value */
-
- mblk_t *reqmp; /* Request mblk_t */
- str_t path; /* Path name of response */
- str_t auth; /* Authority for response */
- ssize_t resplen; /* Response length */
- ssize_t respclen; /* Response chunk length */
- char *eoh; /* End of header pointer */
- void *scheme; /* Scheme private state */
-
- ref_t ref; /* Reference stuff */
-
- size_t count; /* rd_t chain byte count */
- uri_rd_t *tail; /* Last response descriptor */
- uri_rd_t response; /* First response descriptor */
-
- struct sonode *proc; /* Socket processing this uri */
- kcondvar_t waiting; /* Socket(s) waiting for processing */
- kmutex_t proclock; /* Lock for proc and waiting */
-} uri_desc_t;
-
-/* Hash the (char)c to the hash accumulator (uint32_t)hv */
-#define CHASH(hv, c) (hv) = ((hv) << 5) + (hv) + c; (hv) &= 0x7FFFFFFF
-
-#define URI_TEMP (uri_desc_t *)-1 /* Temp (nocache) uri_t.hash pointer */
-
-#define URI_LEN_NOVALUE -1 /* Length (int) counter no value yet */
-#define URI_LEN_CONSUMED -2 /* Length (int) counter consumed */
-
-typedef struct uri_segmap_s {
- ref_t ref; /* Reference, one per uri_desb_t */
- caddr_t base; /* Base addr of segmap mapping */
- size_t len; /* Length of segmap mapping */
- vnode_t *vp; /* Vnode mapped */
-} uri_segmap_t;
-
-typedef struct uri_desb_s {
- frtn_t frtn; /* For use by esballoc() and freinds */
- uri_desc_t *uri; /* Containing URI of REF_HOLD() */
- uri_segmap_t *segmap; /* If segmap mapped else NULL */
-} uri_desb_t;
-
-/*
- * Add (and create if need be) a new uri_rd_t to a uri.
- *
- * Note, macro can block, must be called from a blockable context.
- */
-#define URI_RD_ADD(uri, rdp, size, offset) { \
- if ((uri)->tail == NULL) { \
- (rdp) = &(uri)->response; \
- } else { \
- (rdp) = kmem_cache_alloc(nl7c_uri_rd_kmc, KM_SLEEP); \
- (uri)->tail->next = (rdp); \
- } \
- (rdp)->sz = size; \
- (rdp)->off = offset; \
- (rdp)->next = NULL; \
- (uri)->tail = rdp; \
- (uri)->count += size; \
-}
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _SYS_SOCKFS_NL7CURI_H */
diff --git a/usr/src/uts/common/fs/sockfs/sockcommon.c b/usr/src/uts/common/fs/sockfs/sockcommon.c
index edcb41951c..27b1b3cf26 100644
--- a/usr/src/uts/common/fs/sockfs/sockcommon.c
+++ b/usr/src/uts/common/fs/sockfs/sockcommon.c
@@ -23,6 +23,7 @@
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2015, Joyent, Inc.
* Copyright 2017 Sebastian Wiedenroth
+ * Copyright 2022 Garrett D'Amore
*/
#include <sys/types.h>
@@ -47,7 +48,6 @@
#include <inet/ipclassifier.h>
#include <fs/sockfs/sockcommon.h>
#include <fs/sockfs/sockfilter_impl.h>
-#include <fs/sockfs/nl7c.h>
#include <fs/sockfs/socktpi.h>
#include <fs/sockfs/sodirect.h>
#include <inet/ip.h>
diff --git a/usr/src/uts/common/fs/sockfs/sockcommon_sops.c b/usr/src/uts/common/fs/sockfs/sockcommon_sops.c
index 4c8784e974..b1f74b993b 100644
--- a/usr/src/uts/common/fs/sockfs/sockcommon_sops.c
+++ b/usr/src/uts/common/fs/sockfs/sockcommon_sops.c
@@ -26,6 +26,7 @@
/*
* Copyright (c) 2015, Joyent, Inc. All rights reserved.
* Copyright 2019 OmniOS Community Edition (OmniOSce) Association.
+ * Copyright 2022 Garrett D'Amore
*/
#include <sys/types.h>
@@ -58,7 +59,6 @@
#include <fs/sockfs/socktpi_impl.h>
#include <fs/sockfs/sodirect.h>
#include <sys/tihdr.h>
-#include <fs/sockfs/nl7c.h>
extern int xnet_skip_checks;
extern int xnet_check_print;
@@ -233,33 +233,6 @@ so_bind(struct sonode *so, struct sockaddr *name, socklen_t namelen,
goto dobind;
}
- /*
- * First we check if either NCA or KSSL has been enabled for
- * the requested address, and if so, we fall back to TPI.
- * If neither of those two services are enabled, then we just
- * pass the request to the protocol.
- *
- * Note that KSSL can only be enabled on a socket if NCA is NOT
- * enabled for that socket, hence the else-statement below.
- */
- if (nl7c_enabled && ((so->so_family == AF_INET ||
- so->so_family == AF_INET6) &&
- nl7c_lookup_addr(name, namelen) != NULL)) {
- /*
- * NL7C is not supported in non-global zones,
- * we enforce this restriction here.
- */
- if (so->so_zoneid == GLOBAL_ZONEID) {
- /* NCA should be used, so fall back to TPI */
- error = so_tpi_fallback(so, cr);
- SO_UNBLOCK_FALLBACK(so);
- if (error)
- return (error);
- else
- return (SOP_BIND(so, name, namelen, flags, cr));
- }
- }
-
dobind:
if (so->so_filter_active == 0 ||
(error = sof_filter_bind(so, name, &namelen, cr)) < 0) {
diff --git a/usr/src/uts/common/fs/sockfs/socksubr.c b/usr/src/uts/common/fs/sockfs/socksubr.c
index 73c36ce0d4..3262150f79 100644
--- a/usr/src/uts/common/fs/sockfs/socksubr.c
+++ b/usr/src/uts/common/fs/sockfs/socksubr.c
@@ -24,6 +24,7 @@
* Copyright 2016 Nexenta Systems, Inc. All rights reserved.
* Copyright 2015, Joyent, Inc. All rights reserved.
* Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
+ * Copyright 2022 Garrett D'Amore
*/
#include <sys/types.h>
@@ -72,7 +73,6 @@
#include <c2/audit.h>
-#include <fs/sockfs/nl7c.h>
#include <fs/sockfs/sockcommon.h>
#include <fs/sockfs/sockfilter_impl.h>
#include <fs/sockfs/socktpi.h>
@@ -94,7 +94,6 @@
#define SO_LOCK_WAKEUP_TIME 3000 /* Wakeup time in milliseconds */
dev_t sockdev; /* For fsid in getattr */
-int sockfs_defer_nl7c_init = 0;
struct socklist socklist;
@@ -112,8 +111,6 @@ extern smod_info_t *sotpi_smod_create(void);
extern void sendfile_init();
-extern void nl7c_init(void);
-
extern int modrootloaded;
/*
@@ -282,11 +279,6 @@ sockinit(int fstype, char *name)
mutex_init(&socklist.sl_lock, NULL, MUTEX_DEFAULT, NULL);
sendfile_init();
- if (!modrootloaded) {
- sockfs_defer_nl7c_init = 1;
- } else {
- nl7c_init();
- }
/* Initialize socket filters */
sof_init();
diff --git a/usr/src/uts/common/fs/sockfs/socksyscalls.c b/usr/src/uts/common/fs/sockfs/socksyscalls.c
index 30666f73ca..b9eec810e3 100644
--- a/usr/src/uts/common/fs/sockfs/socksyscalls.c
+++ b/usr/src/uts/common/fs/sockfs/socksyscalls.c
@@ -25,6 +25,7 @@
* Copyright (c) 2013, OmniTI Computer Consulting, Inc. All rights reserved.
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
* Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
+ * Copyright 2022 Garrett D'Amore
*/
#include <sys/types.h>
@@ -69,7 +70,6 @@
#include <vm/seg_map.h>
#include <vm/seg_kpm.h>
-#include <fs/sockfs/nl7c.h>
#include <fs/sockfs/sockcommon.h>
#include <fs/sockfs/sockfilter_impl.h>
#include <fs/sockfs/socktpi.h>
@@ -82,9 +82,6 @@ int do_useracc = 1; /* Controlled by setting SO_DEBUG to 4 */
extern int xnet_truncate_print;
-extern void nl7c_init(void);
-extern int sockfs_defer_nl7c_init;
-
/*
* Kernel component of socket creation.
*
@@ -1699,37 +1696,9 @@ sockconf_add_sock(int family, int type, int protocol, char *name)
}
if (strncmp(buf, "/dev", strlen("/dev")) == 0) {
/* For device */
-
- /*
- * Special handling for NCA:
- *
- * DEV_NCA is never opened even if an application
- * requests for AF_NCA. The device opened is instead a
- * predefined AF_INET transport (NCA_INET_DEV).
- *
- * Prior to Volo (PSARC/2007/587) NCA would determine
- * the device using a lookup, which worked then because
- * all protocols were based on TPI. Since TPI is no
- * longer the default, we have to explicitly state
- * which device to use.
- */
- if (strcmp(buf, NCA_DEV) == 0) {
- /* only support entry <28, 2, 0> */
- if (family != AF_NCA || type != SOCK_STREAM ||
- protocol != 0) {
- kmem_free(buf, MAXPATHLEN);
- return (EINVAL);
- }
-
- pathlen = strlen(NCA_INET_DEV) + 1;
- kdevpath = kmem_alloc(pathlen, KM_SLEEP);
- bcopy(NCA_INET_DEV, kdevpath, pathlen);
- kdevpath[pathlen - 1] = '\0';
- } else {
- kdevpath = kmem_alloc(pathlen, KM_SLEEP);
- bcopy(buf, kdevpath, pathlen);
- kdevpath[pathlen - 1] = '\0';
- }
+ kdevpath = kmem_alloc(pathlen, KM_SLEEP);
+ bcopy(buf, kdevpath, pathlen);
+ kdevpath[pathlen - 1] = '\0';
} else {
/* For socket module */
kmodule = kmem_alloc(pathlen, KM_SLEEP);
@@ -1929,11 +1898,6 @@ sockconfig(int cmd, void *arg1, void *arg2, void *arg3, void *arg4)
if (secpolicy_net_config(CRED(), B_FALSE) != 0)
return (set_errno(EPERM));
- if (sockfs_defer_nl7c_init) {
- nl7c_init();
- sockfs_defer_nl7c_init = 0;
- }
-
switch (cmd) {
case SOCKCONFIG_ADD_SOCK:
error = sockconf_add_sock((int)(uintptr_t)arg1,
diff --git a/usr/src/uts/common/fs/sockfs/socktpi.c b/usr/src/uts/common/fs/sockfs/socktpi.c
index 0e9883498b..678dce986a 100644
--- a/usr/src/uts/common/fs/sockfs/socktpi.c
+++ b/usr/src/uts/common/fs/sockfs/socktpi.c
@@ -23,6 +23,7 @@
* Copyright (c) 1995, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2015, Joyent, Inc.
* Copyright 2016 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2022 Garrett D'Amore
*/
#include <sys/types.h>
@@ -78,9 +79,6 @@
#include <sys/zone.h>
-#include <fs/sockfs/nl7c.h>
-#include <fs/sockfs/nl7curi.h>
-
#include <fs/sockfs/sockcommon.h>
#include <fs/sockfs/socktpi.h>
#include <fs/sockfs/socktpi_impl.h>
@@ -314,10 +312,6 @@ sotpi_create(struct sockparams *sp, int family, int type, int protocol,
sonode_init(so, sp, family, type, protocol, &sotpi_sonodeops);
sotpi_info_init(so);
- if (sfamily == AF_NCA) {
- SOTOTPI(so)->sti_nl7c_flags = NL7C_AF_NCA;
- }
-
if (version == SOV_DEFAULT)
version = so_default_version;
@@ -646,7 +640,6 @@ sotpi_bindlisten(struct sonode *so, struct sockaddr *name,
int save_so_backlog;
t_scalar_t PRIM_type = O_T_BIND_REQ;
boolean_t tcp_udp_xport;
- void *nl7c = NULL;
sotpi_info_t *sti = SOTOTPI(so);
dprintso(so, 1, ("sotpi_bindlisten(%p, %p, %d, %d, 0x%x) %s\n",
@@ -1043,35 +1036,6 @@ sotpi_bindlisten(struct sonode *so, struct sockaddr *name,
}
/*
- * If NL7C addr(s) have been configured check for addr/port match,
- * or if an implicit NL7C socket via AF_NCA mark socket as NL7C.
- *
- * NL7C supports the TCP transport only so check AF_INET and AF_INET6
- * family sockets only. If match mark as such.
- */
- if (nl7c_enabled && ((addr != NULL &&
- (so->so_family == AF_INET || so->so_family == AF_INET6) &&
- (nl7c = nl7c_lookup_addr(addr, addrlen))) ||
- sti->sti_nl7c_flags == NL7C_AF_NCA)) {
- /*
- * NL7C is not supported in non-global zones,
- * we enforce this restriction here.
- */
- if (so->so_zoneid == GLOBAL_ZONEID) {
- /* An NL7C socket, mark it */
- sti->sti_nl7c_flags |= NL7C_ENABLED;
- if (nl7c == NULL) {
- /*
- * Was an AF_NCA bind() so add it to the
- * addr list for reporting purposes.
- */
- nl7c = nl7c_add_addr(addr, addrlen);
- }
- } else
- nl7c = NULL;
- }
-
- /*
* We send a T_BIND_REQ for TCP/UDP since we know it supports it,
* for other transports we will send in a O_T_BIND_REQ.
*/
@@ -1351,11 +1315,6 @@ sotpi_bindlisten(struct sonode *so, struct sockaddr *name,
}
}
- if (nl7c != NULL) {
- /* Register listen()er sonode pointer with NL7C */
- nl7c_listener_addr(nl7c, so);
- }
-
freemsg(mp);
done:
@@ -1965,39 +1924,6 @@ again:
nso->so_proto_handle = (sock_lower_handle_t)opt;
nsti->sti_laddr_valid = 1;
- if (sti->sti_nl7c_flags & NL7C_ENABLED) {
- /*
- * A NL7C marked listen()er so the new socket
- * inherits the listen()er's NL7C state, except
- * for NL7C_POLLIN.
- *
- * Only call NL7C to process the new socket if
- * the listen socket allows blocking i/o.
- */
- nsti->sti_nl7c_flags =
- sti->sti_nl7c_flags & (~NL7C_POLLIN);
- if (so->so_state & (SS_NONBLOCK|SS_NDELAY)) {
- /*
- * Nonblocking accept() just make it
- * persist to defer processing to the
- * read-side syscall (e.g. read).
- */
- nsti->sti_nl7c_flags |= NL7C_SOPERSIST;
- } else if (nl7c_process(nso, B_FALSE)) {
- /*
- * NL7C has completed processing on the
- * socket, close the socket and back to
- * the top to await the next T_CONN_IND.
- */
- mutex_exit(&nso->so_lock);
- (void) VOP_CLOSE(nvp, 0, 1, (offset_t)0,
- cr, NULL);
- VN_RELE(nvp);
- goto again;
- }
- /* Pass the new socket out */
- }
-
mutex_exit(&nso->so_lock);
/*
@@ -2981,75 +2907,6 @@ sorecv_update_oobstate(struct sonode *so)
}
/*
- * Handle recv* calls for an so which has NL7C saved recv mblk_t(s).
- */
-static int
-nl7c_sorecv(struct sonode *so, mblk_t **rmp, uio_t *uiop, rval_t *rp)
-{
- sotpi_info_t *sti = SOTOTPI(so);
- int error = 0;
- mblk_t *tmp = NULL;
- mblk_t *pmp = NULL;
- mblk_t *nmp = sti->sti_nl7c_rcv_mp;
-
- ASSERT(nmp != NULL);
-
- while (nmp != NULL && uiop->uio_resid > 0) {
- ssize_t n;
-
- if (DB_TYPE(nmp) == M_DATA) {
- /*
- * We have some data, uiomove up to resid bytes.
- */
- n = MIN(MBLKL(nmp), uiop->uio_resid);
- if (n > 0)
- error = uiomove(nmp->b_rptr, n, UIO_READ, uiop);
- nmp->b_rptr += n;
- if (nmp->b_rptr == nmp->b_wptr) {
- pmp = nmp;
- nmp = nmp->b_cont;
- }
- if (error)
- break;
- } else {
- /*
- * We only handle data, save for caller to handle.
- */
- if (pmp != NULL) {
- pmp->b_cont = nmp->b_cont;
- }
- nmp->b_cont = NULL;
- if (*rmp == NULL) {
- *rmp = nmp;
- } else {
- tmp->b_cont = nmp;
- }
- nmp = nmp->b_cont;
- tmp = nmp;
- }
- }
- if (pmp != NULL) {
- /* Free any mblk_t(s) which we have consumed */
- pmp->b_cont = NULL;
- freemsg(sti->sti_nl7c_rcv_mp);
- }
- if ((sti->sti_nl7c_rcv_mp = nmp) == NULL) {
- /* Last mblk_t so return the saved kstrgetmsg() rval/error */
- if (error == 0) {
- rval_t *p = (rval_t *)&sti->sti_nl7c_rcv_rval;
-
- error = p->r_v.r_v2;
- p->r_v.r_v2 = 0;
- }
- rp->r_vals = sti->sti_nl7c_rcv_rval;
- sti->sti_nl7c_rcv_rval = 0;
- } else {
- /* More mblk_t(s) to process so no rval to return */
- rp->r_vals = 0;
- }
- return (error);
-}
-/*
* Receive the next message on the queue.
* If msg_controllen is non-zero when called the caller is interested in
* any received control info (options).
@@ -3138,55 +2995,6 @@ sotpi_recvmsg(struct sonode *so, struct nmsghdr *msg, struct uio *uiop,
mutex_enter(&so->so_lock);
/*
- * If an NL7C enabled socket and not waiting for write data.
- */
- if ((sti->sti_nl7c_flags & (NL7C_ENABLED | NL7C_WAITWRITE)) ==
- NL7C_ENABLED) {
- if (sti->sti_nl7c_uri) {
- /* Close uri processing for a previous request */
- nl7c_close(so);
- }
- if ((so_state & SS_CANTRCVMORE) &&
- sti->sti_nl7c_rcv_mp == NULL) {
- /* Nothing to process, EOF */
- mutex_exit(&so->so_lock);
- return (0);
- } else if (sti->sti_nl7c_flags & NL7C_SOPERSIST) {
- /* Persistent NL7C socket, try to process request */
- boolean_t ret;
-
- ret = nl7c_process(so,
- (so->so_state & (SS_NONBLOCK|SS_NDELAY)));
- rval.r_vals = sti->sti_nl7c_rcv_rval;
- error = rval.r_v.r_v2;
- if (error) {
- /* Error of some sort, return it */
- mutex_exit(&so->so_lock);
- return (error);
- }
- if (sti->sti_nl7c_flags &&
- ! (sti->sti_nl7c_flags & NL7C_WAITWRITE)) {
- /*
- * Still an NL7C socket and no data
- * to pass up to the caller.
- */
- mutex_exit(&so->so_lock);
- if (ret) {
- /* EOF */
- return (0);
- } else {
- /* Need more data */
- return (EAGAIN);
- }
- }
- } else {
- /*
- * Not persistent so no further NL7C processing.
- */
- sti->sti_nl7c_flags = 0;
- }
- }
- /*
* Only one reader is allowed at any given time. This is needed
* for T_EXDATA handling and, in the future, MSG_WAITALL.
*
@@ -3239,13 +3047,8 @@ retry:
saved_resid = uiop->uio_resid;
pri = 0;
mp = NULL;
- if (sti->sti_nl7c_rcv_mp != NULL) {
- /* Already kstrgetmsg()ed saved mblk(s) from NL7C */
- error = nl7c_sorecv(so, &mp, uiop, &rval);
- } else {
- error = kstrgetmsg(SOTOV(so), &mp, uiop, &pri, &pflag,
- timout, &rval);
- }
+ error = kstrgetmsg(SOTOV(so), &mp, uiop, &pri, &pflag,
+ timout, &rval);
if (error != 0) {
/* kstrgetmsg returns ETIME when timeout expires */
if (error == ETIME)
@@ -4555,11 +4358,6 @@ sotpi_sendmsg(struct sonode *so, struct nmsghdr *msg, struct uio *uiop,
dprintso(so, 1, ("sotpi_sendmsg: write\n"));
/* Send M_DATA messages */
- if ((sti->sti_nl7c_flags & NL7C_ENABLED) &&
- (error = nl7c_data(so, uiop)) >= 0) {
- /* NL7C consumed the data */
- return (error);
- }
/*
* If there is no SO_DONTROUTE to turn off,
* sti_direct is on, and there is no flow
@@ -5837,11 +5635,6 @@ sotpi_close(struct sonode *so, int flag, struct cred *cr)
ASSERT(so_verify_oobstate(so));
- if (sti->sti_nl7c_flags & NL7C_ENABLED) {
- sti->sti_nl7c_flags = 0;
- nl7c_close(so);
- }
-
if (vp->v_stream != NULL) {
vnode_t *ux_vp;
@@ -6426,14 +6219,6 @@ sotpi_poll(
if (so->so_state & SS_OOBPEND)
*reventsp |= POLLRDBAND & events;
- if (sti->sti_nl7c_rcv_mp != NULL) {
- *reventsp |= (POLLIN|POLLRDNORM) & events;
- }
- if ((sti->sti_nl7c_flags & NL7C_ENABLED) &&
- ((POLLIN|POLLRDNORM) & *reventsp)) {
- sti->sti_nl7c_flags |= NL7C_POLLIN;
- }
-
return (0);
}
@@ -6734,10 +6519,6 @@ i_sotpi_info_constructor(sotpi_info_t *sti)
sti->sti_laddr_sa = NULL;
sti->sti_faddr_sa = NULL;
- sti->sti_nl7c_flags = 0;
- sti->sti_nl7c_uri = NULL;
- sti->sti_nl7c_rcv_mp = NULL;
-
mutex_init(&sti->sti_plumb_lock, NULL, MUTEX_DEFAULT, NULL);
cv_init(&sti->sti_ack_cv, NULL, CV_DEFAULT, NULL);
@@ -6759,10 +6540,6 @@ i_sotpi_info_destructor(sotpi_info_t *sti)
ASSERT(sti->sti_laddr_sa == NULL);
ASSERT(sti->sti_faddr_sa == NULL);
- ASSERT(sti->sti_nl7c_flags == 0);
- ASSERT(sti->sti_nl7c_uri == NULL);
- ASSERT(sti->sti_nl7c_rcv_mp == NULL);
-
mutex_destroy(&sti->sti_plumb_lock);
cv_destroy(&sti->sti_ack_cv);
}
@@ -6895,19 +6672,6 @@ sotpi_info_fini(struct sonode *so)
sti->sti_ack_mp = NULL;
}
- if ((mp = sti->sti_nl7c_rcv_mp) != NULL) {
- sti->sti_nl7c_rcv_mp = NULL;
- freemsg(mp);
- }
- sti->sti_nl7c_rcv_rval = 0;
- if (sti->sti_nl7c_uri != NULL) {
- nl7c_urifree(so);
- /* urifree() cleared nl7c_uri */
- }
- if (sti->sti_nl7c_flags) {
- sti->sti_nl7c_flags = 0;
- }
-
ASSERT(sti->sti_ux_bound_vp == NULL);
if ((mp = sti->sti_unbind_mp) != NULL) {
freemsg(mp);
diff --git a/usr/src/uts/common/fs/sockfs/socktpi.h b/usr/src/uts/common/fs/sockfs/socktpi.h
index 8da8392a68..15d128afb5 100644
--- a/usr/src/uts/common/fs/sockfs/socktpi.h
+++ b/usr/src/uts/common/fs/sockfs/socktpi.h
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2022 Garrett D'Amore
*/
#ifndef _SOCKFS_SOCKTPI_H
@@ -224,30 +225,6 @@ typedef struct sotpi_info {
struct sonode *sti_next_so; /* next sonode on socklist */
struct sonode *sti_prev_so; /* previous sonode on socklist */
mblk_t *sti_discon_ind_mp; /* T_DISCON_IND received from below */
-
- /*
- * For NL7C sockets:
- *
- * sti_nl7c_flags the NL7C state of URL processing.
- *
- * sti_nl7c_rcv_mp mblk_t chain of already received data to be
- * passed up to the app after NL7C gives up on
- * a socket.
- *
- * sti_nl7c_rcv_rval returned rval for last mblk_t from above.
- *
- * sti_nl7c_uri the URI currently being processed.
- *
- * sti_nl7c_rtime URI request gethrestime_sec().
- *
- * sti_nl7c_addr pointer returned by nl7c_addr_lookup().
- */
- uint64_t sti_nl7c_flags;
- mblk_t *sti_nl7c_rcv_mp;
- int64_t sti_nl7c_rcv_rval;
- void *sti_nl7c_uri;
- time_t sti_nl7c_rtime;
- void *sti_nl7c_addr;
} sotpi_info_t;
struct T_capability_ack;
@@ -262,7 +239,7 @@ extern void sotpi_update_state(struct sonode *, struct T_capability_ack *,
struct sockaddr *, socklen_t, struct sockaddr *, socklen_t,
short);
-extern sotpi_info_t *sotpi_sototpi(struct sonode *);
+extern sotpi_info_t *sotpi_sototpi(struct sonode *);
#ifdef DEBUG
#define SOTOTPI(so) (sotpi_sototpi(so))
#else
diff --git a/usr/src/uts/common/inet/nca/ncaddi.c b/usr/src/uts/common/inet/nca/ncaddi.c
deleted file mode 100644
index f02924d131..0000000000
--- a/usr/src/uts/common/inet/nca/ncaddi.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * 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.
- * Copyright (c) 2011 Bayard G. Bell. All rights reserved.
- */
-
-#include <sys/types.h>
-#include <sys/conf.h>
-#include <sys/modctl.h>
-#include <sys/stream.h>
-#include <sys/strsubr.h>
-#include <sys/strsun.h>
-#include <sys/zone.h>
-#include <inet/common.h>
-#include <inet/led.h>
-#include <inet/nd.h>
-#include <netinet/in.h>
-
-#include "ncaconf.h"
-
-extern caddr_t nca_g_nd; /* Head of 'named dispatch' variable list */
-
-#define INET_NAME "nca"
-#define INET_MODSTRTAB ncainfo
-#define INET_DEVSTRTAB ncainfo
-#define INET_MODDESC "NCA STREAMS module 1.6"
-#define INET_DEVDESC "NCA STREAMS driver 1.6"
-#define INET_DEVMINOR 0
-#define INET_DEVMTFLAGS D_MP
-#define INET_MODMTFLAGS D_MP
-
-#include "../inetddi.c"
-
-/*ARGSUSED*/
-static int
-nca_open(queue_t *q, dev_t *devp, int flag, int sflag, cred_t *credp)
-{
- /* Reopen supported */
- if (q->q_ptr != NULL)
- return (0);
-
- /*
- * NCA is not supported in non-global zones; we enforce this restriction
- * here.
- */
- if (credp != NULL && crgetzoneid(credp) != GLOBAL_ZONEID) {
- return (ENOTSUP);
- }
-
- if (! (sflag & MODOPEN)) {
- /* Device instance */
- RD(q)->q_ptr = (void *)B_TRUE;
- WR(q)->q_ptr = (void *)B_TRUE;
- } else {
- /* Modopen just pass through */
- RD(q)->q_ptr = (void *)B_FALSE;
- WR(q)->q_ptr = (void *)B_FALSE;
- }
- qprocson(q);
- return (0);
-}
-
-/* ARGSUSED */
-static int
-nca_close(queue_t *q, int flags __unused, cred_t *credp __unused)
-{
- qprocsoff(q);
- RD(q)->q_ptr = NULL;
- WR(q)->q_ptr = NULL;
- return (0);
-}
-
-static int
-nca_rput(queue_t *q, mblk_t *mp)
-{
- /* Passthrough */
- putnext(q, mp);
- return (0);
-}
-
-static int
-nca_wput(queue_t *q, mblk_t *mp)
-{
- struct iocblk *iocp;
-
- if (! (boolean_t)q->q_ptr) {
- iocp = (struct iocblk *)mp->b_rptr;
- if (DB_TYPE(mp) == M_IOCTL && iocp->ioc_cmd == NCA_SET_IF) {
- miocnak(q, mp, 0, ENOTSUP);
- return (0);
- }
- /* Module, passthrough */
- putnext(q, mp);
- return (0);
- }
-
- switch (DB_TYPE(mp)) {
- case M_IOCTL:
- iocp = (struct iocblk *)mp->b_rptr;
- switch (iocp->ioc_cmd) {
- case ND_SET:
- case ND_GET:
- if (! nd_getset(q, nca_g_nd, mp)) {
- miocnak(q, mp, 0, ENOENT);
- return (0);
- }
- qreply(q, mp);
- break;
- default:
- miocnak(q, mp, 0, ENOTSUP);
- break;
- }
- break;
- default:
- freemsg(mp);
- break;
- }
- return (0);
-}
-
-static struct module_info info = {
- 0, "nca", 1, INFPSZ, 65536, 1024
-};
-
-static struct qinit rinit = {
- nca_rput, NULL, nca_open, nca_close, NULL, &info
-};
-
-static struct qinit winit = {
- nca_wput, NULL, nca_open, nca_close, NULL, &info
-};
-
-struct streamtab ncainfo = {
- &rinit, &winit
-};
-
-int
-_init(void)
-{
- return (mod_install(&modlinkage));
-}
-
-int
-_fini(void)
-{
- return (EBUSY);
-}
-
-int
-_info(struct modinfo *modinfop)
-{
- return (mod_info(&modlinkage, modinfop));
-}
diff --git a/usr/src/uts/common/io/ksocket/ksocket.c b/usr/src/uts/common/io/ksocket/ksocket.c
index 3ce44cce55..3eb23f1dbe 100644
--- a/usr/src/uts/common/io/ksocket/ksocket.c
+++ b/usr/src/uts/common/io/ksocket/ksocket.c
@@ -23,6 +23,7 @@
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2015, Joyent, Inc.
+ * Copyright 2022 Garrett D'Amore
*/
#include <sys/file.h>
@@ -57,9 +58,6 @@ ksocket_socket(ksocket_t *ksp, int domain, int type, int protocol, int flags,
/* All Solaris components should pass a cred for this operation. */
ASSERT(cr != NULL);
- if (domain == AF_NCA)
- return (EAFNOSUPPORT);
-
ASSERT(flags == KSOCKET_SLEEP || flags == KSOCKET_NOSLEEP);
so = socket_create(domain, type, protocol, NULL, NULL, version, flags,
cr, &error);
diff --git a/usr/src/uts/common/sys/socket.h b/usr/src/uts/common/sys/socket.h
index 30f7367bcd..9e61bc7bb0 100644
--- a/usr/src/uts/common/sys/socket.h
+++ b/usr/src/uts/common/sys/socket.h
@@ -19,10 +19,10 @@
* CDDL HEADER END
*/
/*
- * Copyright 2014 Garrett D'Amore <garrett@damore.org>
- *
* Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2015, Joyent, Inc. All rights reserved.
+ * Copyright 2022 Garrett D'Amore
+ *
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
@@ -160,7 +160,7 @@ typedef void *_RESTRICT_KYWD Psocklen_t;
/* when doing zero-copy */
struct so_snd_bufinfo {
- ushort_t sbi_wroff; /* Write offset */
+ ushort_t sbi_wroff; /* Write offset */
ssize_t sbi_maxblk; /* Max size of a single mblk */
ssize_t sbi_maxpsz; /* Max total size of a mblk chain */
ushort_t sbi_tail; /* Extra space available at the end */
@@ -299,7 +299,7 @@ struct linger {
#define AF_LINK 25 /* Link-layer interface */
#define AF_INET6 26 /* Internet Protocol, Version 6 */
#define AF_KEY 27 /* Security Association DB socket */
-#define AF_NCA 28 /* NCA socket */
+#define AF_NCA 28 /* NCA socket (obsolete) */
#define AF_POLICY 29 /* Security Policy DB socket */
#define AF_INET_OFFLOAD 30 /* Sun private; do not use */
#define AF_TRILL 31 /* TRILL interface */
diff --git a/usr/src/uts/common/syscall/sendfile.c b/usr/src/uts/common/syscall/sendfile.c
index 7cfd5bc188..d0667061d3 100644
--- a/usr/src/uts/common/syscall/sendfile.c
+++ b/usr/src/uts/common/syscall/sendfile.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2022 Garrett D'Amore
*/
#include <sys/types.h>
@@ -68,8 +69,6 @@
extern int sosendfile64(file_t *, file_t *, const struct ksendfilevec64 *,
ssize32_t *);
-extern int nl7c_sendfilev(struct sonode *, u_offset_t *, struct sendfilevec *,
- int, ssize_t *);
extern int snf_segmap(file_t *, vnode_t *, u_offset_t, u_offset_t, ssize_t *,
boolean_t);
extern sotpi_info_t *sotpi_sototpi(struct sonode *);
@@ -1319,16 +1318,9 @@ sendfilev(int opcode, int fildes, const struct sendfilevec *vec, int sfvcnt,
* Future zero copy code will plugin into sendvec_chunk
* only because doing zero copy for files smaller then
* pagesize is useless.
- *
- * Note, if socket has NL7C enabled then call NL7C's
- * senfilev() function to consume the sfv[].
*/
if (is_sock) {
- if (!SOCK_IS_NONSTR(so) &&
- _SOTOTPI(so)->sti_nl7c_flags != 0) {
- error = nl7c_sendfilev(so, &fileoff,
- sfv, copy_cnt, &count);
- } else if ((total_size <= (4 * maxblk)) &&
+ if ((total_size <= (4 * maxblk)) &&
error == 0) {
error = sendvec_small_chunk(fp,
&fileoff, sfv, copy_cnt,
diff --git a/usr/src/uts/intel/Makefile.intel b/usr/src/uts/intel/Makefile.intel
index a3708e086a..ac4d9a0548 100644
--- a/usr/src/uts/intel/Makefile.intel
+++ b/usr/src/uts/intel/Makefile.intel
@@ -279,7 +279,6 @@ DRV_KMODS += mouse8042
DRV_KMODS += mpt_sas
DRV_KMODS += mr_sas
DRV_KMODS += mwl
-DRV_KMODS += nca
DRV_KMODS += nsmb
DRV_KMODS += nulldriver
DRV_KMODS += nv_sata
diff --git a/usr/src/uts/intel/ml/modstubs.s b/usr/src/uts/intel/ml/modstubs.s
index 0f97c21ac6..ec0eefd9f7 100644
--- a/usr/src/uts/intel/ml/modstubs.s
+++ b/usr/src/uts/intel/ml/modstubs.s
@@ -364,7 +364,6 @@ fcnname/**/_info: \
NO_UNLOAD_STUB(sockfs, sosendfile64, nomod_zero);
NO_UNLOAD_STUB(sockfs, snf_segmap, nomod_einval);
NO_UNLOAD_STUB(sockfs, sock_getfasync, nomod_zero);
- NO_UNLOAD_STUB(sockfs, nl7c_sendfilev, nomod_zero);
NO_UNLOAD_STUB(sockfs, sotpi_sototpi, nomod_zero);
NO_UNLOAD_STUB(sockfs, socket_sendmblk, nomod_zero);
NO_UNLOAD_STUB(sockfs, socket_setsockopt, nomod_zero);
diff --git a/usr/src/uts/intel/nca/Makefile b/usr/src/uts/intel/nca/Makefile
deleted file mode 100644
index afdba0d636..0000000000
--- a/usr/src/uts/intel/nca/Makefile
+++ /dev/null
@@ -1,83 +0,0 @@
-#
-# 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
-#
-#
-# uts/intel/nca/Makefile
-#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# Copyright (c) 2018, Joyent, Inc.
-
-#
-# Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE = ../..
-
-#
-# Define the module and object file sets.
-#
-MODULE = nca
-OBJECTS = $(NCA_OBJS:%=$(OBJS_DIR)/%)
-ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE)
-ROOTLINK = $(ROOT_STRMOD_DIR)/$(MODULE)
-CONF_SRCDIR = $(UTSBASE)/common/inet/nca
-
-#
-# Include common rules.
-#
-include $(UTSBASE)/intel/Makefile.intel
-
-#
-# Define targets
-#
-ALL_TARGET = $(BINARY) $(SRC_CONFFILE)
-INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOTLINK) $(ROOT_CONFFILE)
-
-#
-# Overrides
-#
-LDFLAGS += -Nfs/sockfs -Ndrv/ip
-
-# needs work
-$(OBJS_DIR)/ncaddi.o := SMOFF += index_overflow
-
-#
-# Default build targets.
-#
-.KEEP_STATE:
-
-def: $(DEF_DEPS)
-
-all: $(ALL_DEPS)
-
-clean: $(CLEAN_DEPS)
-
-clobber: $(CLOBBER_DEPS)
-
-install: $(INSTALL_DEPS)
-
-$(ROOTLINK): $(ROOT_STRMOD_DIR) $(ROOTMODULE)
- -$(RM) $@; ln $(ROOTMODULE) $@
-
-#
-# Include common targets.
-#
-include $(UTSBASE)/intel/Makefile.targ
diff --git a/usr/src/uts/intel/sockrds/Makefile b/usr/src/uts/intel/sockrds/Makefile
index bf78373d38..80a2d0d145 100644
--- a/usr/src/uts/intel/sockrds/Makefile
+++ b/usr/src/uts/intel/sockrds/Makefile
@@ -21,9 +21,6 @@
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
#
-# This makefile drives the production of the nca driver
-# kernel module.
-#
# intel architecture dependent
#
diff --git a/usr/src/uts/intel/socksctp/Makefile b/usr/src/uts/intel/socksctp/Makefile
index fa43835eae..bba3ad9bbe 100644
--- a/usr/src/uts/intel/socksctp/Makefile
+++ b/usr/src/uts/intel/socksctp/Makefile
@@ -22,9 +22,6 @@
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# This makefile drives the production of the nca driver
-# kernel module.
-#
# intel architecture dependent
#
diff --git a/usr/src/uts/intel/socksdp/Makefile b/usr/src/uts/intel/socksdp/Makefile
index 6c4029ba03..b9b9da1c90 100644
--- a/usr/src/uts/intel/socksdp/Makefile
+++ b/usr/src/uts/intel/socksdp/Makefile
@@ -22,9 +22,6 @@
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# This makefile drives the production of the nca driver
-# kernel module.
-#
# intel architecture dependent
#
diff --git a/usr/src/uts/sparc/Makefile.sparc b/usr/src/uts/sparc/Makefile.sparc
index 8c8ca81e30..19dc78dea0 100644
--- a/usr/src/uts/sparc/Makefile.sparc
+++ b/usr/src/uts/sparc/Makefile.sparc
@@ -207,7 +207,7 @@ DRV_KMODS += dtrace fasttrap fbt lockstat profile sdt systrace dcpc
DRV_KMODS += fssnap icmp icmp6 ip ip6 ipnet ipsecah
DRV_KMODS += ipsecesp iptun iwscn keysock kmdb kstat ksyms llc1
DRV_KMODS += lofi
-DRV_KMODS += log logindmux mm nca physmem pm poll pool
+DRV_KMODS += log logindmux mm physmem pm poll pool
DRV_KMODS += pseudo ptc ptm pts ptsl ramdisk random rsm rts sad
DRV_KMODS += simnet softmac sppp sppptun sy sysevent sysmsg
DRV_KMODS += spdsock
diff --git a/usr/src/uts/sparc/ml/modstubs.s b/usr/src/uts/sparc/ml/modstubs.s
index f43346fd48..07aff93702 100644
--- a/usr/src/uts/sparc/ml/modstubs.s
+++ b/usr/src/uts/sparc/ml/modstubs.s
@@ -377,7 +377,6 @@ stubs_base:
NO_UNLOAD_STUB(sockfs, sosendfile64, nomod_zero);
NO_UNLOAD_STUB(sockfs, snf_segmap, nomod_einval);
NO_UNLOAD_STUB(sockfs, sock_getfasync, nomod_zero);
- NO_UNLOAD_STUB(sockfs, nl7c_sendfilev, nomod_zero);
NO_UNLOAD_STUB(sockfs, sotpi_sototpi, nomod_zero);
NO_UNLOAD_STUB(sockfs, socket_sendmblk, nomod_zero);
NO_UNLOAD_STUB(sockfs, socket_setsockopt, nomod_zero);
diff --git a/usr/src/uts/sparc/nca/Makefile b/usr/src/uts/sparc/nca/Makefile
deleted file mode 100644
index e44ddf4c8d..0000000000
--- a/usr/src/uts/sparc/nca/Makefile
+++ /dev/null
@@ -1,83 +0,0 @@
-#
-# 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 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-# This makefile drives the production of the nca driver
-# kernel module.
-#
-# sparc architecture dependent
-#
-
-#
-# Path to the base of the uts directory tree (usually /usr/src/uts).
-#
-UTSBASE = ../..
-
-#
-# Define the module and object file sets.
-#
-MODULE = nca
-OBJECTS = $(NCA_OBJS:%=$(OBJS_DIR)/%)
-ROOTMODULE = $(ROOT_DRV_DIR)/$(MODULE)
-ROOTLINK = $(ROOT_STRMOD_DIR)/$(MODULE)
-CONF_SRCDIR = $(UTSBASE)/common/inet/nca
-
-#
-# Include common rules.
-#
-include $(UTSBASE)/sparc/Makefile.sparc
-
-#
-# Define targets
-#
-ALL_TARGET = $(BINARY) $(SRC_CONFFILE)
-INSTALL_TARGET = $(BINARY) $(ROOTMODULE) $(ROOTLINK) $(ROOT_CONFFILE)
-
-CFLAGS += $(CCVERBOSE)
-
-LDFLAGS += -Nfs/sockfs -Ndrv/ip
-
-#
-# Default build targets.
-#
-.KEEP_STATE:
-
-def: $(DEF_DEPS)
-
-all: $(ALL_DEPS)
-
-clean: $(CLEAN_DEPS)
-
-clobber: $(CLOBBER_DEPS)
-
-install: $(INSTALL_DEPS)
-
-$(ROOTLINK): $(ROOT_STRMOD_DIR) $(ROOTMODULE)
- -$(RM) $@; ln $(ROOTMODULE) $@
-
-#
-# Include common targets.
-#
-include $(UTSBASE)/sparc/Makefile.targ
diff --git a/usr/src/uts/sparc/sockpfp/Makefile b/usr/src/uts/sparc/sockpfp/Makefile
index 3f90a0acd1..647b37dfcc 100644
--- a/usr/src/uts/sparc/sockpfp/Makefile
+++ b/usr/src/uts/sparc/sockpfp/Makefile
@@ -22,9 +22,6 @@
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# This makefile drives the production of the nca driver
-# kernel module.
-#
# sparc architecture dependent
#
diff --git a/usr/src/uts/sparc/sockrds/Makefile b/usr/src/uts/sparc/sockrds/Makefile
index 526b6e7a81..74fd11f083 100644
--- a/usr/src/uts/sparc/sockrds/Makefile
+++ b/usr/src/uts/sparc/sockrds/Makefile
@@ -23,9 +23,6 @@
#
#
-# This makefile drives the production of the nca driver
-# kernel module.
-#
# sparc architecture dependent
#
diff --git a/usr/src/uts/sparc/socksctp/Makefile b/usr/src/uts/sparc/socksctp/Makefile
index bece5cb8db..f59aaa0e00 100644
--- a/usr/src/uts/sparc/socksctp/Makefile
+++ b/usr/src/uts/sparc/socksctp/Makefile
@@ -23,9 +23,6 @@
# Use is subject to license terms.
#
-# This makefile drives the production of the nca driver
-# kernel module.
-#
# sparc architecture dependent
#
diff --git a/usr/src/uts/sparc/socksdp/Makefile b/usr/src/uts/sparc/socksdp/Makefile
index e69985523b..34817b87a8 100644
--- a/usr/src/uts/sparc/socksdp/Makefile
+++ b/usr/src/uts/sparc/socksdp/Makefile
@@ -23,9 +23,6 @@
# Use is subject to license terms.
#
-# This makefile drives the production of the nca driver
-# kernel module.
-#
# sparc architecture dependent
#