How can I close an active TCP connection?

How can I close an active TCP connection?

Post by Pete Francoi » Wed, 19 Jun 2002 23:05:18



Hello ALL:

I am trying to figure out a way to close a single active TCP
connection on Solaris 7, 8, and 9 - at the OS, network or kernel
level without stopping the layer 7 application.  I don't believe there
is
any utilities built in to the OS for doing this.  I am looking
for a freeware/shareware tool or some insight on how to
program such a utility.

Example:

# netstat -an
   Local Address        Remote Address    Swind Send-Q Rwind Recv-Q
State
-------------------- -------------------- ----- ------
.
.
.
192.168.1.1.22       192.168.1.10.1022    24820      0 33580      0
ESTABLISHED
.
.
.
Let's say I want to force this connection to drop withOUT re-booting or
killing
the ssh daemon, or in the case of inetd controlled processes, I do not
want to kill
inetd or all of any particular daemon or processes.

I am currently investigating a way to obtain the socket descriptor and
writing some code
to utilize the "shutdown"  (man 3N)  library routine to close the
connection.

Any suggestions or ideas would be appreciated.

regards,

Pete

 
 
 

How can I close an active TCP connection?

Post by Philip Bro » Thu, 20 Jun 2002 08:48:30



>Hello ALL:
>...
>I am trying to figure out a way to close a single active TCP
>connection on Solaris 7, 8, and 9 - at the OS, network or kernel
>level without stopping the layer 7 application.

>Any suggestions or ideas would be appreciated.

well, you could always forge a FIN packet, I would think.
or RST

similarly, I'm sure there's some interesting use of adb to wade into the
kernel file descriptor table, and mark the fd as closed.

--
[Trim the no-bots from my address to reply to me by email!]
[ Do NOT email-CC me on posts. Pick one or the other.]

http://www.spamlaws.com/state/ca1.html

 
 
 

How can I close an active TCP connection?

Post by Thomas Tornblo » Fri, 21 Jun 2002 05:59:32



> Hello ALL:

> I am trying to figure out a way to close a single active TCP
> connection on Solaris 7, 8, and 9 - at the OS, network or kernel
> level without stopping the layer 7 application.  I don't believe there
> is
> any utilities built in to the OS for doing this.  I am looking
> for a freeware/shareware tool or some insight on how to
> program such a utility.

> Example:

> # netstat -an
>    Local Address        Remote Address    Swind Send-Q Rwind Recv-Q
> State
> -------------------- -------------------- ----- ------
> .
> .
> .
> 192.168.1.1.22       192.168.1.10.1022    24820      0 33580      0
> ESTABLISHED
> .
> .
> .
> Let's say I want to force this connection to drop withOUT re-booting or
> killing
> the ssh daemon, or in the case of inetd controlled processes, I do not
> want to kill
> inetd or all of any particular daemon or processes.

> I am currently investigating a way to obtain the socket descriptor and
> writing some code
> to utilize the "shutdown"  (man 3N)  library routine to close the
> connection.

> Any suggestions or ideas would be appreciated.

> regards,

> Pete

I have used a de* in the past to attach to the process, and while
the process is stopped, called close() on the fd.

I just tested:
---
spiff:~ (201)> /opt/SUNWspro/bin/dbx /usr/lib/ssh/sshd
...
(/opt/SUNWspro/bin/../WS6U1/bin/sparcv9/dbx) attach 14034
...
(/opt/SUNWspro/bin/../WS6U1/bin/sparcv9/dbx) call shutdown(5)
---

and the connection was shutdown nicely.

The socket is fd #5 with the stock Solaris 9 sshd, which can easily be
verified with "pfiles <pid of sshd>"

sshd forks a process for each session, so you may just as well kill
the corresponding process. The daemon sshd will not die from this, and
calling shutdown on the socket will have the process exit anyway.

Thomas

 
 
 

1. closing active connections

Does anyone know how to identify/close the connections passing through a
FreeBSD host being used as a gateway.  For example, I have a system with
dhcpd running on a wireless interface (10.0.1.1) and a wired interface
connected to the internet.  I'm trying to identify connections from say
10.0.1.10 passing through the gateway and close those connections.  I'm
dynamically opening and closing the firewall to let traffic through but
established connections are allowed even after the firewall is closed,
this is intentional.

--
Joe Bynum
Software Engineer
Netsville, Inc.
http://www.netsville.com

2. Which version of tchs

3. active tcp connections

4. HP 8100 CD-RW

5. How can i detect that a client has closed a TCP-stream connection ???

6. Access sounter for CERN server

7. Help! TCP connection closed by foreign host

8. schedule ftp commands

9. Netscape server not closing TCP connection

10. HELP: reading from a closed TCP connection

11. How do you flush wierd CLOSE-state TCP connections?

12. Closing Bad TCP Connections

13. Closing a TCP connection