tcpdrop(8) for DragonFly

Matthew Dillon dillon at
Sat Nov 13 15:59:06 PST 2004

:Would you mind pointing me to some documentation on this, or maybe to some
:example code? Would it be something like the messages sent in tcp_drain()
:or in tcp_close(), ie,
:msg = malloc(...);
:/* fill message */

    Heh, documentation is fairly lacking considering how new the code

    Ok, I have researched it.  The nominal way of injecting a message
    into the protocol stack is to follow how the so_pru_*() functions
    do it.  For example, so_pru_disconnect() (see kern/uipc_msg.c).

    BUT, I don't think you have to do that.  I think all you need to
    do to disconnect a TCP connection is to call soshutdown() on the
    socket, which you can do directly.  soshutdown() calls so_pru_shutdown()
    which does all the messaging.

    So I think it may be easier then you thought.

    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.

					Matthew Dillon 
					<dillon at xxxxxxxxxxxxx>

More information about the Submit mailing list