From patchwork Wed Sep 2 06:42:45 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 513317 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from archives.nicira.com (unknown [IPv6:2600:3c00::f03c:91ff:fe6e:bdf7]) by ozlabs.org (Postfix) with ESMTP id 11625140281 for ; Wed, 2 Sep 2015 16:43:18 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id E0C7510A4F; Tue, 1 Sep 2015 23:43:01 -0700 (PDT) X-Original-To: dev@openvswitch.org Delivered-To: dev@openvswitch.org Received: from mx3v1.cudamail.com (mx3.cudamail.com [64.34.241.5]) by archives.nicira.com (Postfix) with ESMTPS id E0E0110A5B for ; Tue, 1 Sep 2015 23:42:59 -0700 (PDT) Received: from bar3.cudamail.com (bar1 [192.168.15.1]) by mx3v1.cudamail.com (Postfix) with ESMTP id 8681A61857D for ; Wed, 2 Sep 2015 00:42:58 -0600 (MDT) X-ASG-Debug-ID: 1441176178-03dd7b127d418910001-byXFYA Received: from mx3-pf1.cudamail.com ([192.168.14.2]) by bar3.cudamail.com with ESMTP id HJ4MYYVUnx8PTXEx (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 02 Sep 2015 00:42:58 -0600 (MDT) X-Barracuda-Envelope-From: blp@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.2 Received: from unknown (HELO mail-pa0-f50.google.com) (209.85.220.50) by mx3-pf1.cudamail.com with ESMTPS (RC4-SHA encrypted); 2 Sep 2015 06:42:57 -0000 Received-SPF: unknown (mx3-pf1.cudamail.com: Multiple SPF records returned) X-Barracuda-Apparent-Source-IP: 209.85.220.50 X-Barracuda-RBL-IP: 209.85.220.50 Received: by padhy1 with SMTP id hy1so1040976pad.1 for ; Tue, 01 Sep 2015 23:42:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=2VenEzjp+T26vOxa8bHEcBUP/hkWEuid/6SCqotJUd0=; b=HBS3506xz63nSK7dhYpUUdnSba1gzZW+e7pLFqMJOZLTn9f/XPSd5/8aSEnBGQ3csL Ckn1m/JOwsWldvpohQuH9rAcwO3MZiOlbeJf2+aCsTTxZs38K96IbEpbOspC0m5uTY1c 7mFN3zkgKmu7bGQEzQWx8EjL5irCsDEY2/4PwCNWRLppv1UxP6xRUVSKuPqaG+zEtfxu CM7DVDRPuCbiW3+52PYL/zPCUfX9f0kEj51zCgDQQt9zL6WpaFv+iJRu0WQxslPyHMSG TJLcrxAmiy7ADoy90o//J19zVdJLq+rxENc4DTKYsv8ylvuIy0RrCfxCx6F9J3vUMsP4 Vr5Q== X-Gm-Message-State: ALoCoQnuIJONG3xX4X81ao82D7fmqyAXYHJRxiJobiNICUvUSgdt1DiVHnxe5sfsqU5sEGL0IJEg X-Received: by 10.68.229.195 with SMTP id ss3mr52973770pbc.100.1441176177531; Tue, 01 Sep 2015 23:42:57 -0700 (PDT) Received: from sigabrt.benpfaff.org (173-228-112-192.dsl.dynamic.fusionbroadband.com. [173.228.112.192]) by smtp.gmail.com with ESMTPSA id pt3sm20317992pbb.38.2015.09.01.23.42.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 01 Sep 2015 23:42:56 -0700 (PDT) X-CudaMail-Envelope-Sender: blp@nicira.com From: Ben Pfaff To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V1-901000630 X-CudaMail-DTE: 090215 X-CudaMail-Originating-IP: 209.85.220.50 Date: Tue, 1 Sep 2015 23:42:45 -0700 X-ASG-Orig-Subj: [##CM-V1-901000630##][PATCH 3/6] pcap-file: Flush packets to operating system immediately. Message-Id: <1441176168-27960-3-git-send-email-blp@nicira.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1441176168-27960-1-git-send-email-blp@nicira.com> References: <1441176168-27960-1-git-send-email-blp@nicira.com> X-Barracuda-Connect: UNKNOWN[192.168.14.2] X-Barracuda-Start-Time: 1441176178 X-Barracuda-Encrypted: DHE-RSA-AES256-SHA X-Barracuda-URL: https://web.cudamail.com:443/cgi-mod/mark.cgi X-ASG-Whitelist: Header =?UTF-8?B?eFwtY3VkYW1haWxcLXdoaXRlbGlzdFwtdG8=?= X-Virus-Scanned: by bsmtpd at cudamail.com X-Barracuda-BRTS-Status: 1 Cc: Ben Pfaff Subject: [ovs-dev] [PATCH 3/6] pcap-file: Flush packets to operating system immediately. X-BeenThere: dev@openvswitch.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dev-bounces@openvswitch.org Sender: "dev" This makes the pcap files written by netdev-dummy up-to-date even if one kills the process with a signal. This could be a performance hit if the pcap file writer were to be used in some kind of performance critical situation, but so far it's only used in netdev-dummy, which is just for testing. Signed-off-by: Ben Pfaff --- lib/pcap-file.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/pcap-file.c b/lib/pcap-file.c index 553a7b6..a850d21 100644 --- a/lib/pcap-file.c +++ b/lib/pcap-file.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2010, 2012, 2013, 2014 Nicira, Inc. + * Copyright (c) 2009, 2010, 2012, 2013, 2014, 2015 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -130,6 +130,7 @@ ovs_pcap_write_header(FILE *file) ph.snaplen = 1518; ph.network = 1; /* Ethernet */ ignore(fwrite(&ph, sizeof ph, 1, file)); + fflush(file); } int @@ -202,6 +203,7 @@ ovs_pcap_write(FILE *file, struct dp_packet *buf) prh.orig_len = dp_packet_size(buf); ignore(fwrite(&prh, sizeof prh, 1, file)); ignore(fwrite(dp_packet_data(buf), dp_packet_size(buf), 1, file)); + fflush(file); } struct tcp_key {