Re: tcpdrop(8) for DragonFly
On Sun, 14 Nov 2004, Andre Nathan wrote:
> Anyway, I hope it's alright now :) If all is fine, I'll work on adding
> command line options to tcpdrop(8) so that you can choose which sysctl
> it'll use.
Sorry for the delay on that... there is a patched tcpdrop at
http://andre.people.digirati.com.br/dragonfly/patches/tcpdrop/tcpdrop/
which has two command line options for drop (-d) and shutdown (-s). Drop
mode is the default, because I think this will be more used, and well,
because of the name of the program...
So I guess the pending issue is the race Matt mentioned:
> There is one more issue, and that is how to safely operating on sockets
> owned by other processes. The socket structure is not ref-counted so
> there's a race between finding and operating on the socket via the
> sysctl, and the program that owns the socket trying to close it
> at the same time.
Is the race present even considering that the find/operate code of the
sysctl is run at splnet()?
Hiten mentioned that the socket would have an associated descriptor, so
I guess a test like
if (inp->inp_socket->so_state & SS_NOFDREF == 0)
/* drop/shutdown */
but i'm not sure if that would solve the problem.
Regards,
Andre