From 8ccf33c1550ae8554de0cfb79292aa95b3c78f59 Mon Sep 17 00:00:00 2001 From: Michael Tuexen <tuexen@fh-muenster.de> Date: Sun, 7 Jun 2015 00:56:46 +0200 Subject: [PATCH] Don't send TCP RST / SCTP ABORT for non-existing connections. Only send the cleanup messages when the socket is not in a front state. This fixes a bug where in case of the SUT being a server was sent a TCP RST with wildcard addresses and ports. --- gtests/net/packetdrill/run.c | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/gtests/net/packetdrill/run.c b/gtests/net/packetdrill/run.c index 3edfb49b..bb962e13 100644 --- a/gtests/net/packetdrill/run.c +++ b/gtests/net/packetdrill/run.c @@ -103,15 +103,22 @@ static void close_all_sockets(struct state *state) if (close(socket->live.fd)) die_perror("close"); } - if (socket->protocol == IPPROTO_TCP && - !state->config->is_wire_client && - reset_connection(state, socket)) { - die("error reseting connection\n"); - } - if (socket->protocol == IPPROTO_SCTP && - !state->config->is_wire_client && - abort_association(state, socket)) { - die("error aborting association\n"); + if ((socket->state != SOCKET_INIT) && + (socket->state != SOCKET_NEW) && + (socket->state != SOCKET_PASSIVE_LISTENING) && + (state->config->is_wire_client == false)) { + switch (socket->protocol) { + case IPPROTO_TCP: + if (reset_connection(state, socket) != STATUS_OK) + die("error reseting connection\n"); + break; + case IPPROTO_SCTP: + if (abort_association(state, socket) != STATUS_OK) + die("error aborting association\n"); + break; + default: + break; + } } struct socket *dead_socket = socket; socket = socket->next; -- GitLab