[ovs-dev] [netdev 27/27] netdev: Make netdev access thread-safe.

Ben Pfaff blp at nicira.com
Sat Aug 10 04:31:27 UTC 2013


On Wed, Aug 07, 2013 at 04:43:18PM -0700, Andy Zhou wrote:
> On Thu, Aug 1, 2013 at 2:29 PM, Ben Pfaff <blp at nicira.com> wrote:
> 
> > Signed-off-by: Ben Pfaff <blp at nicira.com>
> > @@ -491,18 +500,20 @@ netdev_bsd_rx_construct(struct netdev_rx *rx_)
> >      struct netdev_rx_bsd *rx = netdev_rx_bsd_cast(rx_);
> >      struct netdev *netdev_ = rx->up.netdev;
> >      struct netdev_bsd *netdev = netdev_bsd_cast(netdev_);
> > +    int error;
> >
> >      if (!strcmp(netdev_get_type(netdev_), "tap")) {
> >          rx->pcap_handle = NULL;
> >          rx->fd = netdev->tap_fd;
> > +        error = 0;
> >      } else {
> > -        int error = netdev_bsd_open_pcap(netdev_get_kernel_name(netdev_),
> > -                                         &rx->pcap_handle, &rx->fd);
> > -        if (error) {
> > -            return error;
> > +        ovs_mutex_lock(&netdev->mutex);
> > +        error = netdev_bsd_open_pcap(netdev_get_kernel_name(netdev_),
> > +                                     &rx->pcap_handle, &rx->fd);
> > +        if (!error) {
> > +            netdev_bsd_changed(netdev);
> >          }
> > -
> > -        netdev_bsd_changed(netdev);
> > +        ovs_mutex_unlock(&netdev->mutex);
> >      }
> >
> >      return 0;
> >
> Should this function return error?

Yes.  This was already fixed in my tree; I guess it must have been a bug
in an earlier patch that was already found elsewhere in review.

> > @@ -733,6 +752,7 @@ netdev_bsd_set_etheraddr(struct netdev *netdev_,
> >      struct netdev_bsd *netdev = netdev_bsd_cast(netdev_);
> >      int error;
> >
> > It may be more consistent with the functions below to initialize error to
> zero here.

Done.



More information about the dev mailing list