From 5053858e6727444baca268e49385e2cc8d188fe6 Mon Sep 17 00:00:00 2001 From: Michael Tuexen <tuexen@fh-muenster.de> Date: Sun, 8 Jan 2017 19:18:01 +0100 Subject: [PATCH] Integrate https://github.com/google/packetdrill/commit/8544aa8ce6ad3c3c268903f586cc665b3afa7254 --- gtests/net/packetdrill/packet_socket_linux.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gtests/net/packetdrill/packet_socket_linux.c b/gtests/net/packetdrill/packet_socket_linux.c index 95e852bd..8abf1066 100644 --- a/gtests/net/packetdrill/packet_socket_linux.c +++ b/gtests/net/packetdrill/packet_socket_linux.c @@ -80,6 +80,8 @@ static void bind_to_interface(int fd, int interface_index) */ static void packet_socket_setup(struct packet_socket *psock) { + struct timeval tv; + psock->packet_fd = socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL)); if (psock->packet_fd < 0) die_perror("socket(PF_PACKET, SOCK_RAW, htons(ETH_P_ALL))"); @@ -92,6 +94,12 @@ static void packet_socket_setup(struct packet_socket *psock) bind_to_interface(psock->packet_fd, psock->index); set_receive_buffer_size(psock->packet_fd, PACKET_SOCKET_RCVBUF_BYTES); + + + /* Pay the non-trivial latency cost to enable timestamps now, before + * the test starts, to avoid significant delays in the middle of tests. + */ + ioctl(psock->packet_fd, SIOCGSTAMP, &tv); } /* Add a filter so we only sniff packets we want. */ -- GitLab