Hello:
Thanks to:
sweh@mpn.com (Stephen Harris)
peter.allan@aeat.co.uk (Peter Allan)
Susan Feng <sfeng@CAST.Stanford.EDU>
Anderson McCammont <and@morgan.com>
shawnb@pobox.com
my original question was:
>
> Hello:
>
> Does anyboy know how end a connection established from another network,
> whithout reboot machine?
>
> netstaf -f shows:
>
> tcp 15 0 cicese.cicese.mx.7002 xxxx.xxxx.xx.3736 CLOSE_WAIT
>
> where cicese.mx is my node and 7002 is a port attached to an service
> similar to telnet.
>
>
>
> Regards
>
>
> Sylvia
>
Susan and "shawnb" sent me a script wrote by:
cdjohns@NSWC-G.ARP and mkhaw@teknowledge-vaxc.arpa
which force a socket to close, it really works fine, so thank you very much.
>
> #! /bin/sh
>
> # original from cdjohns@NSWC-G.ARPA
> #
> # TIMETODEATH expressed in decimal instead of hex
> # -- mkhaw@teknowledge-vaxc.arpa
>
> # Use this script to force sockets in FIN_WAIT_2 state to close.
> # It works by setting the 2MSL timer in the TCP Protocol Control Block (PCB)
> # to a non-zero value. The kernel then begins to decrement this value until
> # it reaches zero, at which point the kernel forces a close on the socket and
> # deletes the TCP PCB. If both sides of the connection are hung, clearing one
> # side will possibly clear the other.
>
> # MSLOFFSET is the offset in the tcpcb record for the 2MSL timer.
> # <netinet/tcp_var.h> describes the tcpcb record.
> # This value is the number of bytes offset, expressed in hexadecimal.
>
> MSLOFFSET=10
> STATEOFFSET=8
>
> # TIMETODEATH is the number of half seconds until the connection is
> # closed. This value is expressed in decimal and must be greater
> # than zero.
>
> TIMETODEATH=06
>
> # Display netstat to get PCB addresses (first column).
> echo 'Active connections
> PCB Proto Recv-Q Send-Q Local Address Foreign Address (state)'
> netstat -A | egrep 'FIN_WAIT_[12]'
>
> echo
> echo -n 'PCB address to terminate? '
> read addr
> echo
>
> # Use adb on kernel to display the PCB of the specified address
> adb -k /vmunix /dev/mem << SHAR_EOF
> $addr\$<tcpcb
> \$q
> SHAR_EOF
>
> # Check to see if this was the correct address and PCB. state should be
> # 8 for LAST_ACK, 9 for FIN_WAIT_2
> echo
> echo 'state = 9 = FIN_WAIT_2, state = 8 = LAST_ACK'
> echo -n 'Is this the correct PCB (y/n)? '
> read ans
> echo
> case $ans in
> [Yy]*)
> ;;
> *)
> echo 'No Changes.'
> exit
> ;;
> esac
>
> # Use adb on kernel to set the 2MSL timer for the PCB
> # and state=CLOSED (0)
> adb -k -w /vmunix /dev/mem << SHAR_EOF
> $addr+$MSLOFFSET/w 0t$TIMETODEATH
> $addr+$STATEOFFSET/w 0
> \$q
> SHAR_EOF
>
> # Use these lines in place of the above for testing the script.
> #adb -k /vmunix /dev/mem << SHAR_EOF
> #$addr+$MSLOFFSET/x
> #\$q
> #SHAR_EOF
>
> echo
> echo "Connection will be terminated in `expr $TIMETODEATH / 2` seconds."
> echo
>
>
Regards
Sylvia
This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:10:58 CDT