#!/bin/ksh # # set_fin_time: # # Script to modify the keepalive values: # tcp_fin_wait_timer - time period before connection in fin_wait2 # is silently dropped. # # Hewlett Packard Corporation # This script is UNSUPPORTED. Use at own risk. # Written: 11 October 95 Scott Millward # # @(#)$Revision: 1.3 $ $Author: scotty $ $Date: 95/12/06 14:35:59 $ # PATH=/bin:/usr/bin:/etc:. # # Range of accepted values # max_maxidle=32767 # maximum for a short. min_maxidle=1200 # 10 minutes # # Default Values # bsdmaxidle=1200 # 8 * 75 seconds (10 minutes) defmaxidle=0 # default is infinite # # # Temporary Dumping Ground # TMPFILE=/tmp/keep$$ # initialize variables # max=$defmaxidle #flags setmax=0 #misc New for version 1.3 .. Allow for 9.X and 10.X OS_VERSION=$(uname -r | awk -F. '{print $2}') kernel_file="/hp-ux" # # Usage Subroutine # # usage() { echo "usage: set_fin_time [-d] [-i] [-b] [-t ] [-help] [-p]" exit } # # Help Information Subroutine - called when -help option given # printhelp() { echo "set_fin_time:" echo " Will set the kernel's TCP FIN_WAIT_2 timer" echo "" echo "- The \"- i\" option sets the timer to infinite(0)" echo "" echo "- The \"-t\" option will set the FIN_WAIT_2 timer to the" echo " specified value. This value is in half-seconds." echo "" echo "- The \"-d\" option sets these values to their defaults." echo "" echo "- The \"-b\" option sets these values to the BSD 4.4 value (10 minutes)" echo "" echo "- The \"-help\" option prints this message." echo "" echo "- The \"- p\" option prints out the current values." } # # Kernel value reading subroutine # read_values() { adb $kernel_file /dev/kmem << EOF > $TMPFILE tcp_fin_wait_timer/d EOF vals=`cat $TMPFILE | grep tcp | awk '{if ($2 != "") printf "%d ", $2}'` once=0 for i in $vals do case $once in 0) max_image=$i once=`expr $once + 1`;; *) echo "internal error" esac done rm $TMPFILE } # Begin of Program # # check for options if [ $(id -u) -ne 0 ] then print print "Sorry, you are not a super-user." print print "You must be a super-user to run this script." print exit 1 fi if [ $OS_VERSION -lt 10 ] then kernel_file="/hp-ux" else kernel_file="/stand/vmunix" fi for i in $* do case $i in -t ) shift setmax=1 max=$1 if [ $max -le $max_maxidle ] && [ $max -ge $min_maxidle ] then shift else echo "FIN_WAIT_2 timer, $max, is out of recommended range ( $min_maxidle to $max_maxidle ), " shift if [ $max -ge $max_maxidle+1 ] then echo "Setting FIN_WAIT_2 timer to 0 (infinite)" echo "" max=0 else echo "but change will be made" echo "" fi fi;; -d ) max=$defmaxidle echo "Setting FIN_WAIT_2 timer to 0 (infinite)" setmax=1;; -b ) max=$bsdmaxidle setmax=1;; -i ) max=0 echo "Setting FIN_WAIT_2 timer to 0 (infinite)" setmax=1;; -p) ;; #default case -help ) printhelp exit ;; -* ) echo $1 is an unknown parameter usage;; esac done read_values # # if we are not setting values, then print out the current ones # if [ $setmax -eq 0 ] then echo "The FIN_WAIT_2 timer is set to $max_image half seconds" exit fi # # Set the value # if [ $setmax -eq 1 ] then # write value to kernel adb -w $kernel_file /dev/kmem << EOF > /dev/null tcp_fin_wait_timer/w 0d$max EOF read_values if [ $max_image -eq $max ] then echo "FIN_WAIT_2 timer changed to $max half seconds." else echo "ERROR: FIN_WAIT_2 timer change failed. Timer left at $max_image" fi fi