[squid-users] TCP_RESET non http requests on port 80

Alex Rousskov rousskov at measurement-factory.com
Wed Sep 7 13:47:17 UTC 2016


On 09/07/2016 01:56 AM, Matus UHLAR - fantomas wrote:

> and how is this done? Which system or library call does drop connection to
> send a RST immediately?

This is not a squid-users question, but Squid calls comm_reset_close()
(quoted below) to reset the connection. That function uses zero
SO_LINGER option value to trigger a TCP reset when the connection is
closed. AFAICT, this is a "standard" approach.

I do not know whether that approach results in an actual TCP reset
packet immediately sent (as opposed to responding to any incoming
packets on the same connection with TCP reset packets).


HTH,

Alex.

> /**
>  * enable linger with time of 0 so that when the socket is
>  * closed, TCP generates a RESET
>  */
> void
> comm_reset_close(const Comm::ConnectionPointer &conn)
> {
>     struct linger L;
>     L.l_onoff = 1;
>     L.l_linger = 0;
> 
>     if (setsockopt(conn->fd, SOL_SOCKET, SO_LINGER, (char *) &L, sizeof(L)) < 0) {
>         int xerrno = errno;
>         debugs(50, DBG_CRITICAL, "ERROR: Closing " << conn << " with TCP RST: " << xstrerr(xerrno));
>     }
>     conn->close();
> }



More information about the squid-users mailing list