Skip to content

Commit

Permalink
pcap-file: Flush packets to operating system immediately.
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Andy Zhou <[email protected]>
  • Loading branch information
blp committed Sep 9, 2015
1 parent 53eb8cb commit f9ef227
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/pcap-file.c
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit f9ef227

Please sign in to comment.