Merge branch 'master' of git://openvswitch.org/openvswitch
authorGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Thu, 8 Aug 2013 14:42:27 +0000 (16:42 +0200)
committerGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Thu, 8 Aug 2013 14:42:27 +0000 (16:42 +0200)
1  2 
lib/automake.mk
lib/dpif.c
lib/netdev-provider.h
lib/netdev.c

diff --combined lib/automake.mk
@@@ -93,8 -93,6 +93,8 @@@ lib_libopenvswitch_a_SOURCES = 
        lib/multipath.c \
        lib/multipath.h \
        lib/netdev-dummy.c \
 +      lib/netdev-tunnel.c \
 +      lib/netdev-pltap.c \
        lib/netdev-provider.h \
        lib/netdev-vport.c \
        lib/netdev-vport.h \
        lib/svec.h \
        lib/table.c \
        lib/table.h \
-       lib/tag.c \
-       lib/tag.h \
        lib/timer.c \
        lib/timer.h \
        lib/timeval.c \
        lib/timeval.h \
        lib/token-bucket.c \
        lib/token-bucket.h \
 +      lib/tunalloc.c \
 +      lib/tunalloc.h \
        lib/type-props.h \
        lib/unaligned.h \
        lib/unicode.c \
@@@ -267,7 -261,7 +265,7 @@@ endi
  if HAVE_POSIX_AIO
  lib_libopenvswitch_a_SOURCES += lib/async-append-aio.c
  else
- lib_libopenvswitch_a_SOURCES += lib/async-append-sync.c
+ lib_libopenvswitch_a_SOURCES += lib/async-append-null.c
  endif
  
  if ESX
diff --combined lib/dpif.c
@@@ -61,7 -61,6 +61,7 @@@ static const struct dpif_class *base_dp
      &dpif_linux_class,
  #endif
      &dpif_netdev_class,
 +    &dpif_planetlab_class,
  };
  
  struct registered_dpif_class {
@@@ -1352,7 -1351,7 +1352,7 @@@ log_flow_message(const struct dpif *dpi
      if (error) {
          ds_put_format(&ds, "(%s) ", ovs_strerror(error));
      }
-     odp_flow_format(key, key_len, mask, mask_len, &ds);
+     odp_flow_format(key, key_len, mask, mask_len, &ds, true);
      if (stats) {
          ds_put_cstr(&ds, ", ");
          dpif_flow_stats_format(stats, &ds);
diff --combined lib/netdev-provider.h
@@@ -50,12 -50,6 +50,6 @@@ struct netdev *netdev_from_name(const c
  void netdev_get_devices(const struct netdev_class *,
                          struct shash *device_list);
  
- static inline void netdev_assert_class(const struct netdev *netdev,
-                                            const struct netdev_class *class_)
- {
-     ovs_assert(netdev->netdev_class == class_);
- }
  /* Network device class structure, to be defined by each implementation of a
   * network device.
   *
@@@ -579,9 -573,6 +573,9 @@@ extern const struct netdev_class netdev
  extern const struct netdev_class netdev_bsd_class;
  #endif
  
 +extern const struct netdev_class netdev_tunnel_class;
 +extern const struct netdev_class netdev_pltap_class;
 +
  #ifdef  __cplusplus
  }
  #endif
diff --combined lib/netdev.c
@@@ -89,8 -89,6 +89,8 @@@ netdev_initialize(void
          netdev_register_provider(&netdev_tap_class);
          netdev_register_provider(&netdev_bsd_class);
  #endif
 +      netdev_register_provider(&netdev_tunnel_class);
 +      netdev_register_provider(&netdev_pltap_class);
      }
  }
  
@@@ -928,8 -926,7 +928,7 @@@ netdev_arp_lookup(const struct netdev *
                    ovs_be32 ip, uint8_t mac[ETH_ADDR_LEN])
  {
      int error = (netdev->netdev_class->arp_lookup
-                  ? netdev->netdev_class->arp_lookup(netdev,
-                         ip, mac)
+                  ? netdev->netdev_class->arp_lookup(netdev, ip, mac)
                   : EOPNOTSUPP);
      if (error) {
          memset(mac, 0, ETH_ADDR_LEN);
@@@ -954,8 -951,7 +953,7 @@@ netdev_get_carrier(const struct netdev 
          return true;
      }
  
-     error = netdev->netdev_class->get_carrier(netdev,
-                                                               &carrier);
+     error = netdev->netdev_class->get_carrier(netdev, &carrier);
      if (error) {
          VLOG_DBG("%s: failed to get network device carrier status, assuming "
                   "down: %s", netdev_get_name(netdev), ovs_strerror(error));
@@@ -1390,17 -1386,24 +1388,24 @@@ netdev_get_class(const struct netdev *n
  
  /* Returns the netdev with 'name' or NULL if there is none.
   *
-  * The caller must not free the returned value. */
+  * The caller must free the returned netdev with netdev_close(). */
  struct netdev *
  netdev_from_name(const char *name)
  {
-     return shash_find_data(&netdev_shash, name);
+     struct netdev *netdev;
+     netdev = shash_find_data(&netdev_shash, name);
+     if (netdev) {
+         netdev_ref(netdev);
+     }
+     return netdev;
  }
  
  /* Fills 'device_list' with devices that match 'netdev_class'.
   *
-  * The caller is responsible for initializing and destroying 'device_list'
-  * but the contained netdevs must not be freed. */
+  * The caller is responsible for initializing and destroying 'device_list' and
+  * must close each device on the list. */
  void
  netdev_get_devices(const struct netdev_class *netdev_class,
                     struct shash *device_list)
          struct netdev *dev = node->data;
  
          if (dev->netdev_class == netdev_class) {
+             dev->ref_cnt++;
              shash_add(device_list, node->name, node->data);
          }
      }
  const char *
  netdev_get_type_from_name(const char *name)
  {
-     const struct netdev *dev = netdev_from_name(name);
-     return dev ? netdev_get_type(dev) : NULL;
+     struct netdev *dev = netdev_from_name(name);
+     const char *type = dev ? netdev_get_type(dev) : NULL;
+     netdev_close(dev);
+     return type;
  }
  \f
  void