From patchwork Wed Sep 2 23:44:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ben Pfaff X-Patchwork-Id: 513699 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 BF0551401F0 for ; Thu, 3 Sep 2015 09:44:50 +1000 (AEST) Received: from archives.nicira.com (localhost [127.0.0.1]) by archives.nicira.com (Postfix) with ESMTP id 166C910762; Wed, 2 Sep 2015 16:44:26 -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 F304810703 for ; Wed, 2 Sep 2015 16:44:24 -0700 (PDT) Received: from bar4.cudamail.com (bar2 [192.168.15.2]) by mx3v1.cudamail.com (Postfix) with ESMTP id 68C1F61835A for ; Wed, 2 Sep 2015 17:44:24 -0600 (MDT) X-ASG-Debug-ID: 1441237461-03dc211ad845c600001-byXFYA Received: from mx3-pf3.cudamail.com ([192.168.14.3]) by bar4.cudamail.com with ESMTP id cjwAMaKMDb2Bn2JP (version=TLSv1 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Wed, 02 Sep 2015 17:44:21 -0600 (MDT) X-Barracuda-Envelope-From: blp@nicira.com X-Barracuda-RBL-Trusted-Forwarder: 192.168.14.3 Received: from unknown (HELO mail-pa0-f44.google.com) (209.85.220.44) by mx3-pf3.cudamail.com with ESMTPS (RC4-SHA encrypted); 2 Sep 2015 23:44:21 -0000 Received-SPF: unknown (mx3-pf3.cudamail.com: Multiple SPF records returned) X-Barracuda-RBL-Trusted-Forwarder: 209.85.220.44 Received: by padhy1 with SMTP id hy1so26330825pad.1 for ; Wed, 02 Sep 2015 16:44:21 -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=QsgmU2HOM0tXJOVjKiqMq87GVfVMt42xNmtDktf+wqwTEcqpkQJXf//xbD8bGasPv7 hYlEXx2i5QSBuxAmakI2jTjfZAv3HakN1q4T1icekIS3XKdbVzBCgjhr4qxDuxQwS/JW qHoJbTMbGNAbwXuqjcVRmF9r86fEjEwHoH9uJZuUwkl0mh2gFnbrVg6mYXhXxWsshPj+ qFnnz2k9LcEr5cqubls+vFuhFIjl3mcVZgDWpmBytRB4TeIGHki9NQyw3dgvpXXzKDSJ lrLIXkZv5YWyEsY0oPtwmh826bJkrScaNdKJB0KpREpDfP2sfWVTLV1aBJhk7B7+7fCD pQdg== X-Gm-Message-State: ALoCoQn0iVaJhRCyy2kw+blOljT0aRGs2ehdrP4Cdc+mlXqAnDsyN/0XVVJPAEoE/26WGPl9Bmly X-Received: by 10.66.218.135 with SMTP id pg7mr59902581pac.141.1441237460862; Wed, 02 Sep 2015 16:44:20 -0700 (PDT) Received: from sigabrt.benpfaff.org ([208.91.2.4]) by smtp.gmail.com with ESMTPSA id f5sm23046151pas.23.2015.09.02.16.44.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 02 Sep 2015 16:44:20 -0700 (PDT) X-CudaMail-Envelope-Sender: blp@nicira.com X-Barracuda-Apparent-Source-IP: 208.91.2.4 From: Ben Pfaff To: dev@openvswitch.org X-CudaMail-Whitelist-To: dev@openvswitch.org X-CudaMail-MID: CM-V3-901064353 X-CudaMail-DTE: 090215 X-CudaMail-Originating-IP: 209.85.220.44 Date: Wed, 2 Sep 2015 16:44:00 -0700 X-ASG-Orig-Subj: [##CM-V3-901064353##][PATCH v2 03/14] pcap-file: Flush packets to operating system immediately. Message-Id: <1441237451-17940-3-git-send-email-blp@nicira.com> X-Mailer: git-send-email 2.1.3 In-Reply-To: <1441237451-17940-1-git-send-email-blp@nicira.com> References: <1441237451-17940-1-git-send-email-blp@nicira.com> X-Barracuda-Connect: UNKNOWN[192.168.14.3] X-Barracuda-Start-Time: 1441237461 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 v2 03/14] 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 Acked-by: Andy Zhou --- 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 {