Fair enough.

I'll send a new series that does this.

On Thu, Aug 16, 2012 at 03:55:12PM -0700, Ethan Jackson wrote:
> This is a nit in the existing code which your patch doesn't introduce:
> 
> It's not totally clear to me why we're keeping track of n_listeners.
> The code may be simpler if we replaced it with a bool
> "anyone_listened".  Better yet, we could always
> unixctl_command_reply() with "success" and not keep track of it at
> all.
> 
> Ethan
> 
> On Fri, Aug 10, 2012 at 3:25 PM, Ben Pfaff <b...@nicira.com> wrote:
> > An upcoming patch will add another user.
> >
> > Signed-off-by: Ben Pfaff <b...@nicira.com>
> > ---
> >  lib/netdev-dummy.c |   33 ++++++++++++++++++++++-----------
> >  1 files changed, 22 insertions(+), 11 deletions(-)
> >
> > diff --git a/lib/netdev-dummy.c b/lib/netdev-dummy.c
> > index 2922965..b64a932 100644
> > --- a/lib/netdev-dummy.c
> > +++ b/lib/netdev-dummy.c
> > @@ -415,6 +415,26 @@ eth_from_packet_or_flow(const char *s)
> >      return packet;
> >  }
> >
> > +static int
> > +netdev_dummy_queue_packet(struct netdev_dev_dummy *dummy_dev,
> > +                          const void *data, size_t size)
> > +{
> > +    struct netdev_dummy *dev;
> > +    int n_listeners;
> > +
> > +    n_listeners = 0;
> > +    LIST_FOR_EACH (dev, node, &dummy_dev->devs) {
> > +        if (dev->listening && dev->recv_queue_len < 
> > NETDEV_DUMMY_MAX_QUEUE) {
> > +            struct ofpbuf *packet = ofpbuf_clone_data(data, size);
> > +            list_push_back(&dev->recv_queue, &packet->list_node);
> > +            dev->recv_queue_len++;
> > +            n_listeners++;
> > +        }
> > +    }
> > +
> > +    return n_listeners;
> > +}
> > +
> >  static void
> >  netdev_dummy_receive(struct unixctl_conn *conn,
> >                       int argc, const char *argv[], void *aux OVS_UNUSED)
> > @@ -431,7 +451,6 @@ netdev_dummy_receive(struct unixctl_conn *conn,
> >
> >      n_listeners = 0;
> >      for (i = 2; i < argc; i++) {
> > -        struct netdev_dummy *dev;
> >          struct ofpbuf *packet;
> >
> >          packet = eth_from_packet_or_flow(argv[i]);
> > @@ -440,16 +459,8 @@ netdev_dummy_receive(struct unixctl_conn *conn,
> >              return;
> >          }
> >
> > -        n_listeners = 0;
> > -        LIST_FOR_EACH (dev, node, &dummy_dev->devs) {
> > -            if (dev->listening
> > -                && dev->recv_queue_len < NETDEV_DUMMY_MAX_QUEUE) {
> > -                struct ofpbuf *copy = ofpbuf_clone(packet);
> > -                list_push_back(&dev->recv_queue, &copy->list_node);
> > -                dev->recv_queue_len++;
> > -                n_listeners++;
> > -            }
> > -        }
> > +        n_listeners += netdev_dummy_queue_packet(dummy_dev,
> > +                                                 packet->data, 
> > packet->size);
> >          ofpbuf_delete(packet);
> >      }
> >
> > --
> > 1.7.2.5
> >
> > _______________________________________________
> > dev mailing list
> > dev@openvswitch.org
> > http://openvswitch.org/mailman/listinfo/dev
_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to