From 4fc95b91c81f13cd30614c6e34ae6707b1b33084 Mon Sep 17 00:00:00 2001 From: Michael Tuexen <tuexen@fh-muenster.de> Date: Thu, 27 Oct 2016 21:15:50 +0200 Subject: [PATCH] Improve the handling of out of the blue packets. When injecting out of the blue packet, don't update the socket under test if one is available. This allows to use the python code for TCP info to inspect closed sockets. Sponsored by: Netflix. --- gtests/net/packetdrill/run_packet.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/gtests/net/packetdrill/run_packet.c b/gtests/net/packetdrill/run_packet.c index fa4033be..5a1af9a1 100644 --- a/gtests/net/packetdrill/run_packet.c +++ b/gtests/net/packetdrill/run_packet.c @@ -3274,24 +3274,17 @@ static int do_inbound_script_packet( packet_payload_len(live_packet); } - if (live_packet->ipv4 != NULL) { - if (live_packet->ipv4->src_ip.s_addr == 0) { - DEBUGP("live_packet->ipv4->src_ip.s_addr == 0\n"); - state->socket_under_test = setup_new_child_socket(state, packet); + if ((state->socket_under_test == NULL) && + (((live_packet->ipv4 != NULL) && + (live_packet->ipv4->src_ip.s_addr == htonl(INADDR_ANY))) || + ((live_packet->ipv6 != NULL) && + (IN6_IS_ADDR_UNSPECIFIED(&live_packet->ipv6->src_ip))))) { struct tuple live_inbound; - socket_get_inbound(&state->socket_under_test->live, &live_inbound); - set_packet_tuple(live_packet, &live_inbound); - } - } - if (live_packet->ipv6 != NULL) { - if (IN6_IS_ADDR_UNSPECIFIED(&live_packet->ipv6->src_ip)) { - DEBUGP("live_packet->ipv6->src_ip.s_addr == 0\n"); + DEBUGP("live_packet has wildcard source address\n"); state->socket_under_test = setup_new_child_socket(state, packet); - struct tuple live_inbound; socket_get_inbound(&state->socket_under_test->live, &live_inbound); set_packet_tuple(live_packet, &live_inbound); - } } /* Inject live packet into kernel. */ -- GitLab