diff mbox

[ovs-dev,v2,03/14] pcap-file: Flush packets to operating system immediately.

Message ID 1441237451-17940-3-git-send-email-blp@nicira.com
State Accepted
Headers show

Commit Message

Ben Pfaff Sept. 2, 2015, 11:44 p.m. UTC
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 <blp@nicira.com>
---
 lib/pcap-file.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Andy Zhou Sept. 9, 2015, 12:19 a.m. UTC | #1
Acked-by: Andy Zhou <azhou@nicira.com>

On Wed, Sep 2, 2015 at 4:44 PM, Ben Pfaff <blp@nicira.com> wrote:
> 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 <blp@nicira.com>
> ---
>  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 {
> --
> 2.1.3
>
> _______________________________________________
> dev mailing list
> dev@openvswitch.org
> http://openvswitch.org/mailman/listinfo/dev
Ben Pfaff Sept. 9, 2015, 5:29 p.m. UTC | #2
Thanks Andy, applied to master.

On Tue, Sep 08, 2015 at 05:19:32PM -0700, Andy Zhou wrote:
> Acked-by: Andy Zhou <azhou@nicira.com>
> 
> On Wed, Sep 2, 2015 at 4:44 PM, Ben Pfaff <blp@nicira.com> wrote:
> > 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 <blp@nicira.com>
> > ---
> >  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 {
> > --
> > 2.1.3
> >
> > _______________________________________________
> > dev mailing list
> > dev@openvswitch.org
> > http://openvswitch.org/mailman/listinfo/dev
diff mbox

Patch

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 {