Merge branch 'mainstream'
authorGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Thu, 24 Jan 2013 10:05:16 +0000 (11:05 +0100)
committerGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Thu, 24 Jan 2013 10:05:16 +0000 (11:05 +0100)
1  2 
Makefile.am
lib/automake.mk
lib/dpif-netdev.c
lib/dpif-provider.h
lib/dpif.c
lib/netdev-provider.h
lib/netdev.c

diff --combined Makefile.am
@@@ -106,7 -106,6 +106,7 @@@ ro_shell = printf '\043 Generated autom
  
  SUFFIXES += .in
  .in:
 +      @mkdir -p $$(dirname $@)
        $(PERL) $(srcdir)/build-aux/soexpand.pl -I$(srcdir) < $< | \
            sed \
                -e 's,[@]PKIDIR[@],$(PKIDIR),g' \
@@@ -148,7 -147,7 +148,7 @@@ dist-hook-git: distfile
          (cd datapath && $(MAKE) distfiles);                               \
          (cat distfiles; sed 's|^|datapath/|' datapath/distfiles) |        \
            sort -u > all-distfiles;                                        \
 -        (cd $(srcdir) && git ls-files) | grep -v '\.gitignore$$' |        \
 +        (cd $(srcdir) && git ls-files) | grep -vFf $(srcdir)/.non-distfiles |     \
            sort -u > all-gitfiles;                                         \
          comm -1 -3 all-distfiles all-gitfiles > missing-distfiles;        \
          if test -s missing-distfiles; then                                \
@@@ -196,6 -195,19 +196,19 @@@ rate-limit-check
         fi
  .PHONY: rate-limit-check
  
+ # Check that assert.h is not used outside a whitelist of files.
+ ALL_LOCAL += check-assert-h-usage
+ check-assert-h-usage:
+       @if test -e $(srcdir)/.git && (git --version) >/dev/null 2>&1 && \
+           (cd $(srcdir) && git --no-pager grep -l -E '[<]assert.h[>]') | \
+           $(EGREP) -v '^lib/(sflow_receiver|vlog|worker).c$$|^tests/'; \
+          then \
+           echo "Files listed above unexpectedly #include <""assert.h"">."; \
+           echo "Please use ovs_assert (from util.h) instead of assert."; \
+           exit 1; \
+        fi
+ .PHONY: check-assert-h-usage
  if HAVE_GROFF
  ALL_LOCAL += manpage-check
  manpage-check: $(man_MANS) $(dist_man_MANS) $(noinst_man_MANS)
@@@ -245,4 -257,3 +258,4 @@@ include rhel/automake.m
  include xenserver/automake.mk
  include python/automake.mk
  include python/compat/automake.mk
 +include planetlab/automake.mk
diff --combined lib/automake.mk
@@@ -61,6 -61,8 +61,8 @@@ lib_libopenvswitch_a_SOURCES = 
        lib/hmap.h \
        lib/hmapx.c \
        lib/hmapx.h \
+       lib/jhash.c \
+       lib/jhash.h \
        lib/json.c \
        lib/json.h \
        lib/jsonrpc.c \
@@@ -88,8 -90,6 +90,8 @@@
        lib/multipath.c \
        lib/multipath.h \
        lib/netdev-dummy.c \
 +      lib/netdev-tunnel.c \
 +      lib/netdev-pltap.c \
        lib/netdev-provider.h \
        lib/netdev.c \
        lib/netdev.h \
        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 \
diff --combined lib/dpif-netdev.c
@@@ -17,7 -17,6 +17,6 @@@
  #include <config.h>
  #include "dpif.h"
  
- #include <assert.h>
  #include <ctype.h>
  #include <errno.h>
  #include <fcntl.h>
@@@ -160,7 -159,7 +159,7 @@@ static void dp_netdev_execute_actions(s
  static struct dpif_netdev *
  dpif_netdev_cast(const struct dpif *dpif)
  {
-     assert(dpif->dpif_class->open == dpif_netdev_open);
+     ovs_assert(dpif->dpif_class->open == dpif_netdev_open);
      return CONTAINER_OF(dpif, struct dpif_netdev, dpif);
  }
  
@@@ -189,14 -188,6 +188,14 @@@ dpif_netdev_port_open_type(const struc
                    : "tap";
  }
  
 +static const char *
 +dpif_planetlab_port_open_type(const struct dpif_class *class, const char *type)
 +{
 +    return strcmp(type, "internal") ? type
 +                  : class != &dpif_planetlab_class ? "dummy"
 +                  : "pltap";
 +}
 +
  static struct dpif *
  create_dpif_netdev(struct dp_netdev *dp)
  {
@@@ -218,8 -209,7 +217,8 @@@ choose_port(struct dp_netdev *dp, cons
  {
      int port_no;
  
 -    if (dp->class != &dpif_netdev_class) {
 +    if (dp->class != &dpif_netdev_class && 
 +        dp->class != &dpif_planetlab_class) {
          const char *p;
          int start_no = 0;
  
@@@ -298,7 -288,7 +297,7 @@@ dpif_netdev_open(const struct dpif_clas
              if (error) {
                  return error;
              }
-             assert(dp != NULL);
+             ovs_assert(dp != NULL);
          }
      } else {
          if (dp->class != class) {
@@@ -346,7 -336,7 +345,7 @@@ static voi
  dpif_netdev_close(struct dpif *dpif)
  {
      struct dp_netdev *dp = get_dp_netdev(dpif);
-     assert(dp->open_cnt > 0);
+     ovs_assert(dp->open_cnt > 0);
      if (--dp->open_cnt == 0 && dp->destroyed) {
          shash_find_and_delete(&dp_netdevs, dp->name);
          dp_netdev_free(dp);
@@@ -1202,7 -1192,7 +1201,7 @@@ execute_set_action(struct ofpbuf *packe
      case OVS_KEY_ATTR_TUN_ID:
      case OVS_KEY_ATTR_PRIORITY:
      case OVS_KEY_ATTR_SKB_MARK:
-     case OVS_KEY_ATTR_IPV4_TUNNEL:
+     case OVS_KEY_ATTR_TUNNEL:
          /* not implemented */
          break;
  
@@@ -1259,7 -1249,6 +1258,6 @@@ dp_netdev_execute_actions(struct dp_net
      unsigned int left;
  
      NL_ATTR_FOR_EACH_UNSAFE (a, left, actions, actions_len) {
-         const struct ovs_action_push_vlan *vlan;
          int type = nl_attr_type(a);
  
          switch ((enum ovs_action_attr) type) {
              dp_netdev_action_userspace(dp, packet, key, a);
              break;
  
-         case OVS_ACTION_ATTR_PUSH_VLAN:
-             vlan = nl_attr_get(a);
+         case OVS_ACTION_ATTR_PUSH_VLAN: {
+             const struct ovs_action_push_vlan *vlan = nl_attr_get(a);
              eth_push_vlan(packet, vlan->vlan_tci);
              break;
+         }
  
          case OVS_ACTION_ATTR_POP_VLAN:
              eth_pop_vlan(packet);
      }
  }
  
 +#define DPIF_NETDEV_CLASS_FUNCTIONS(PORT_OPEN_TYPE)   \
 +    dpif_netdev_enumerate,                            \
 +    PORT_OPEN_TYPE,                                   \
 +    dpif_netdev_open,                                 \
 +    dpif_netdev_close,                                        \
 +    dpif_netdev_destroy,                              \
 +    dpif_netdev_run,                                  \
 +    dpif_netdev_wait,                                 \
 +    dpif_netdev_get_stats,                            \
 +    dpif_netdev_port_add,                             \
 +    dpif_netdev_port_del,                             \
 +    dpif_netdev_port_query_by_number,                 \
 +    dpif_netdev_port_query_by_name,                   \
 +    dpif_netdev_get_max_ports,                                \
 +    NULL,                       /* port_get_pid */    \
 +    dpif_netdev_port_dump_start,                      \
 +    dpif_netdev_port_dump_next,                               \
 +    dpif_netdev_port_dump_done,                               \
 +    dpif_netdev_port_poll,                            \
 +    dpif_netdev_port_poll_wait,                               \
 +    dpif_netdev_flow_get,                             \
 +    dpif_netdev_flow_put,                             \
 +    dpif_netdev_flow_del,                             \
 +    dpif_netdev_flow_flush,                           \
 +    dpif_netdev_flow_dump_start,                      \
 +    dpif_netdev_flow_dump_next,                               \
 +    dpif_netdev_flow_dump_done,                               \
 +    dpif_netdev_execute,                              \
 +    NULL,                       /* operate */         \
 +    dpif_netdev_recv_set,                             \
 +    dpif_netdev_queue_to_priority,                    \
 +    dpif_netdev_recv,                                 \
 +    dpif_netdev_recv_wait,                            \
 +    dpif_netdev_recv_purge,                           \
 +
  const struct dpif_class dpif_netdev_class = {
      "netdev",
 -    dpif_netdev_enumerate,
 -    dpif_netdev_port_open_type,
 -    dpif_netdev_open,
 -    dpif_netdev_close,
 -    dpif_netdev_destroy,
 -    dpif_netdev_run,
 -    dpif_netdev_wait,
 -    dpif_netdev_get_stats,
 -    dpif_netdev_port_add,
 -    dpif_netdev_port_del,
 -    dpif_netdev_port_query_by_number,
 -    dpif_netdev_port_query_by_name,
 -    dpif_netdev_get_max_ports,
 -    NULL,                       /* port_get_pid */
 -    dpif_netdev_port_dump_start,
 -    dpif_netdev_port_dump_next,
 -    dpif_netdev_port_dump_done,
 -    dpif_netdev_port_poll,
 -    dpif_netdev_port_poll_wait,
 -    dpif_netdev_flow_get,
 -    dpif_netdev_flow_put,
 -    dpif_netdev_flow_del,
 -    dpif_netdev_flow_flush,
 -    dpif_netdev_flow_dump_start,
 -    dpif_netdev_flow_dump_next,
 -    dpif_netdev_flow_dump_done,
 -    dpif_netdev_execute,
 -    NULL,                       /* operate */
 -    dpif_netdev_recv_set,
 -    dpif_netdev_queue_to_priority,
 -    dpif_netdev_recv,
 -    dpif_netdev_recv_wait,
 -    dpif_netdev_recv_purge,
 +    DPIF_NETDEV_CLASS_FUNCTIONS(dpif_netdev_port_open_type)
 +};
 +
 +const struct dpif_class dpif_planetlab_class = {
 +    "planetlab",
 +    DPIF_NETDEV_CLASS_FUNCTIONS(dpif_planetlab_port_open_type)
  };
  
  static void
@@@ -1370,4 -1352,3 +1369,4 @@@ dpif_dummy_register(bool override
  
      dpif_dummy_register__("dummy");
  }
 +
diff --combined lib/dpif-provider.h
@@@ -22,7 -22,6 +22,6 @@@
   * exposed over OpenFlow as a single switch.  Datapaths and the collections of
   * ports that they contain may be fixed or dynamic. */
  
- #include <assert.h>
  #include "openflow/openflow.h"
  #include "dpif.h"
  #include "util.h"
@@@ -49,7 -48,7 +48,7 @@@ void dpif_uninit(struct dpif *dpif, boo
  static inline void dpif_assert_class(const struct dpif *dpif,
                                       const struct dpif_class *dpif_class)
  {
-     assert(dpif->dpif_class == dpif_class);
+     ovs_assert(dpif->dpif_class == dpif_class);
  }
  
  /* Datapath interface class structure, to be defined by each implementation of
@@@ -353,7 -352,6 +352,7 @@@ struct dpif_class 
  
  extern const struct dpif_class dpif_linux_class;
  extern const struct dpif_class dpif_netdev_class;
 +extern const struct dpif_class dpif_planetlab_class;
  
  #ifdef  __cplusplus
  }
diff --combined lib/dpif.c
@@@ -17,7 -17,6 +17,6 @@@
  #include <config.h>
  #include "dpif-provider.h"
  
- #include <assert.h>
  #include <ctype.h>
  #include <errno.h>
  #include <inttypes.h>
@@@ -62,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 {
@@@ -266,7 -264,7 +265,7 @@@ do_open(const char *name, const char *t
      error = registered_class->dpif_class->open(registered_class->dpif_class,
                                                 name, create, &dpif);
      if (!error) {
-         assert(dpif->dpif_class == registered_class->dpif_class);
+         ovs_assert(dpif->dpif_class == registered_class->dpif_class);
          registered_class->refcount++;
      }
  
@@@ -330,8 -328,8 +329,8 @@@ dpif_close(struct dpif *dpif
  
          registered_class = shash_find_data(&dpif_classes,
                  dpif->dpif_class->type);
-         assert(registered_class);
-         assert(registered_class->refcount);
+         ovs_assert(registered_class);
+         ovs_assert(registered_class->refcount);
  
          registered_class->refcount--;
          dpif_uninit(dpif, true);
@@@ -615,7 -613,7 +614,7 @@@ dpif_port_get_name(struct dpif *dpif, u
      struct dpif_port port;
      int error;
  
-     assert(name_size > 0);
+     ovs_assert(name_size > 0);
  
      error = dpif_port_query_by_number(dpif, port_no, &port);
      if (!error) {
@@@ -822,8 -820,8 +821,8 @@@ dpif_flow_put__(struct dpif *dpif, cons
      int error;
  
      COVERAGE_INC(dpif_flow_put);
-     assert(!(put->flags & ~(DPIF_FP_CREATE | DPIF_FP_MODIFY
-                             | DPIF_FP_ZERO_STATS)));
+     ovs_assert(!(put->flags & ~(DPIF_FP_CREATE | DPIF_FP_MODIFY
+                                 | DPIF_FP_ZERO_STATS)));
  
      error = dpif->dpif_class->flow_put(dpif, put);
      if (error && put->stats) {
diff --combined lib/netdev-provider.h
@@@ -19,8 -19,6 +19,6 @@@
  
  /* Generic interface to network devices. */
  
- #include <assert.h>
  #include "netdev.h"
  #include "list.h"
  #include "shash.h"
@@@ -55,7 -53,7 +53,7 @@@ void netdev_dev_get_devices(const struc
  static inline void netdev_dev_assert_class(const struct netdev_dev *netdev_dev,
                                             const struct netdev_class *class_)
  {
-     assert(netdev_dev->netdev_class == class_);
+     ovs_assert(netdev_dev->netdev_class == class_);
  }
  
  /* A instance of an open network device.
@@@ -607,9 -605,6 +605,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
@@@ -17,7 -17,6 +17,6 @@@
  #include <config.h>
  #include "netdev.h"
  
- #include <assert.h>
  #include <errno.h>
  #include <inttypes.h>
  #include <netinet/in.h>
@@@ -85,8 -84,6 +84,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);
      }
  }
  
@@@ -230,7 -227,7 +229,7 @@@ netdev_open(const char *name, const cha
          if (error) {
              return error;
          }
-         assert(netdev_dev->netdev_class == class);
+         ovs_assert(netdev_dev->netdev_class == class);
  
      }
  
@@@ -311,7 -308,7 +310,7 @@@ netdev_close(struct netdev *netdev
      if (netdev) {
          struct netdev_dev *netdev_dev = netdev_get_dev(netdev);
  
-         assert(netdev_dev->ref_cnt);
+         ovs_assert(netdev_dev->ref_cnt);
          netdev_dev->ref_cnt--;
          netdev_uninit(netdev, true);
  
@@@ -406,8 -403,8 +405,8 @@@ netdev_recv(struct netdev *netdev, stru
      int (*recv)(struct netdev *, void *, size_t);
      int retval;
  
-     assert(buffer->size == 0);
-     assert(ofpbuf_tailroom(buffer) >= ETH_TOTAL_MIN);
+     ovs_assert(buffer->size == 0);
+     ovs_assert(ofpbuf_tailroom(buffer) >= ETH_TOTAL_MIN);
  
      recv = netdev_get_dev(netdev)->netdev_class->recv;
      retval = (recv
@@@ -1318,7 -1315,7 +1317,7 @@@ voi
  netdev_dev_init(struct netdev_dev *netdev_dev, const char *name,
                  const struct netdev_class *netdev_class)
  {
-     assert(!shash_find(&netdev_dev_shash, name));
+     ovs_assert(!shash_find(&netdev_dev_shash, name));
  
      memset(netdev_dev, 0, sizeof *netdev_dev);
      netdev_dev->netdev_class = netdev_class;
@@@ -1338,7 -1335,7 +1337,7 @@@ netdev_dev_uninit(struct netdev_dev *ne
  {
      char *name = netdev_dev->name;
  
-     assert(!netdev_dev->ref_cnt);
+     ovs_assert(!netdev_dev->ref_cnt);
  
      shash_delete(&netdev_dev_shash, netdev_dev->node);