summaryrefslogtreecommitdiff
path: root/usr/src/cmd
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 /usr/src/cmd
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>
Diffstat (limited to 'usr/src/cmd')
-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
23 files changed, 33 insertions, 4280 deletions
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;
}
}