Prepare Open vSwitch 1.1.2 release.
[sliver-openvswitch.git] / acinclude.m4
index 0af7fd0..fa6f534 100644 (file)
@@ -1,6 +1,6 @@
 # -*- autoconf -*-
 
-# Copyright (c) 2008, 2009, 2010 Nicira Networks.
+# Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -103,9 +103,11 @@ AC_DEFUN([OVS_CHECK_LINUX26], [
   AM_CONDITIONAL(L26_ENABLED, test -n "$KBUILD26")
 ])
 
-dnl OVS_GREP_IFELSE(FILE, REGEX, IF-MATCH, IF-NO-MATCH)
+dnl OVS_GREP_IFELSE(FILE, REGEX, [IF-MATCH], [IF-NO-MATCH])
 dnl
 dnl Greps FILE for REGEX.  If it matches, runs IF-MATCH, otherwise IF-NO-MATCH.
+dnl If IF-MATCH is empty then it defines to OVS_DEFINE(HAVE_<REGEX>), with
+dnl <REGEX> translated to uppercase.
 AC_DEFUN([OVS_GREP_IFELSE], [
   AC_MSG_CHECKING([whether $2 matches in $1])
   if test -f $1; then
@@ -114,7 +116,7 @@ AC_DEFUN([OVS_GREP_IFELSE], [
     case $status in
       0) 
         AC_MSG_RESULT([yes])
-        $3
+        m4_if([$3], [], [OVS_DEFINE([HAVE_]m4_toupper([$2]))], [$3])
         ;;
       1) 
         AC_MSG_RESULT([no])
@@ -156,17 +158,21 @@ AC_DEFUN([OVS_CHECK_LINUX26_COMPAT], [
   mkdir -p datapath/linux-2.6
   : > datapath/linux-2.6/kcompat.h.new
 
-  OVS_GREP_IFELSE([$KSRC26/include/linux/err.h], [ERR_CAST],
-                  [OVS_DEFINE([HAVE_ERR_CAST])])
+  OVS_GREP_IFELSE([$KSRC26/arch/x86/include/asm/checksum_32.h], [src_err,],
+                  [OVS_DEFINE([HAVE_CSUM_COPY_DBG])])
 
-  OVS_GREP_IFELSE([$KSRC26/include/linux/in.h], [ipv4_is_multicast],
-                  [OVS_DEFINE([HAVE_IPV4_IS_MULTICAST])])
+  OVS_GREP_IFELSE([$KSRC26/include/linux/err.h], [ERR_CAST])
 
-  OVS_GREP_IFELSE([$KSRC26/include/linux/netdevice.h], [dev_disable_lro],
-                  [OVS_DEFINE([HAVE_DEV_DISABLE_LRO])])
-  OVS_GREP_IFELSE([$KSRC26/include/linux/netdevice.h], [dev_get_stats],
-                  [OVS_DEFINE([HAVE_DEV_GET_STATS])])
+  OVS_GREP_IFELSE([$KSRC26/include/linux/in.h], [ipv4_is_multicast])
 
+  OVS_GREP_IFELSE([$KSRC26/include/linux/netdevice.h], [dev_disable_lro])
+  OVS_GREP_IFELSE([$KSRC26/include/linux/netdevice.h], [dev_get_stats])
+  OVS_GREP_IFELSE([$KSRC26/include/linux/netdevice.h], [dev_get_by_index_rcu])
+
+  OVS_GREP_IFELSE([$KSRC26/include/linux/rcupdate.h], [rcu_read_lock_held], [],
+                  [OVS_GREP_IFELSE([$KSRC26/include/linux/rtnetlink.h],
+                                   [rcu_read_lock_held])])
+  
   # Check for the proto_data_valid member in struct sk_buff.  The [^@]
   # is necessary because some versions of this header remove the
   # member but retain the kerneldoc comment that describes it (which
@@ -179,30 +185,34 @@ AC_DEFUN([OVS_CHECK_LINUX26_COMPAT], [
   OVS_GREP_IFELSE([$KSRC26/include/linux/skbuff.h], [skb_dst(],
                   [OVS_DEFINE([HAVE_SKB_DST_ACCESSOR_FUNCS])])
   OVS_GREP_IFELSE([$KSRC26/include/linux/skbuff.h], 
-                  [skb_copy_from_linear_data_offset],
-                  [OVS_DEFINE([HAVE_SKB_COPY_FROM_LINEAR_DATA_OFFSET])])
-  OVS_GREP_IFELSE([$KSRC26/include/linux/skbuff.h], [skb_cow_head],
-                  [OVS_DEFINE([HAVE_SKB_COW_HEAD])])
+                  [skb_copy_from_linear_data_offset])
+  OVS_GREP_IFELSE([$KSRC26/include/linux/skbuff.h], [skb_cow_head])
   OVS_GREP_IFELSE([$KSRC26/include/linux/skbuff.h], [skb_transport_header],
                   [OVS_DEFINE([HAVE_SKBUFF_HEADER_HELPERS])])
+  OVS_GREP_IFELSE([$KSRC26/include/linux/icmpv6.h], [icmp6_hdr],
+                  [OVS_DEFINE([HAVE_ICMP6_HDR])])
   OVS_GREP_IFELSE([$KSRC26/include/linux/skbuff.h], [skb_warn_if_lro],
                   [OVS_DEFINE([HAVE_SKB_WARN_LRO])])
 
-  OVS_GREP_IFELSE([$KSRC26/include/linux/string.h $KSRC26/include/linux/slab.h],
-                  [kmemdup], [OVS_DEFINE([HAVE_KMEMDUP])])
+  OVS_GREP_IFELSE([$KSRC26/include/linux/string.h], [kmemdup], [],
+                  [OVS_GREP_IFELSE([$KSRC26/include/linux/slab.h], [kmemdup])])
 
   OVS_GREP_IFELSE([$KSRC26/include/linux/types.h], [bool],
                   [OVS_DEFINE([HAVE_BOOL_TYPE])])
   OVS_GREP_IFELSE([$KSRC26/include/linux/types.h], [__wsum],
                   [OVS_DEFINE([HAVE_CSUM_TYPES])])
 
-  OVS_GREP_IFELSE([$KSRC26/include/net/checksum.h], [csum_unfold],
-                  [OVS_DEFINE([HAVE_CSUM_UNFOLD])])
+  OVS_GREP_IFELSE([$KSRC26/include/net/checksum.h], [csum_replace4])
+  OVS_GREP_IFELSE([$KSRC26/include/net/checksum.h], [csum_unfold])
+
+  OVS_GREP_IFELSE([$KSRC26/include/net/netlink.h], [NLA_NUL_STRING])
+  OVS_GREP_IFELSE([$KSRC26/include/net/netlink.h], [nla_get_be16])
+  OVS_GREP_IFELSE([$KSRC26/include/net/netlink.h], [nla_find_nested])
+
+  OVS_GREP_IFELSE([$KSRC26/include/linux/if_link.h], [rtnl_link_stats64])
 
-  OVS_GREP_IFELSE([$KSRC26/include/net/netlink.h], [NLA_NUL_STRING],
-                  [OVS_DEFINE([HAVE_NLA_NUL_STRING])])
-  OVS_GREP_IFELSE([$KSRC26/include/net/netlink.h], [nla_get_be16],
-                  [OVS_DEFINE([HAVE_NLA_GET_BE16])])
+  OVS_GREP_IFELSE([$KSRC26/include/linux/if_vlan.h], [ADD_ALL_VLANS_CMD],
+                  [OVS_DEFINE([HAVE_VLAN_BUG_WORKAROUND])])
 
   OVS_CHECK_LOG2_H
 
@@ -300,3 +310,29 @@ AC_DEFUN([OVS_CONDITIONAL_CC_OPTION],
     [$1], [ovs_have_cc_option=yes], [ovs_have_cc_option=no])
    AM_CONDITIONAL([$2], [test $ovs_have_cc_option = yes])])
 dnl ----------------------------------------------------------------------
+
+dnl Check for too-old XenServer.
+AC_DEFUN([OVS_CHECK_XENSERVER_VERSION],
+  [AC_CACHE_CHECK([XenServer release], [ovs_cv_xsversion],
+    [if test -e /etc/redhat-release; then
+       ovs_cv_xsversion=`sed -n 's/^XenServer DDK release \([[^-]]*\)-.*/\1/p' /etc/redhat-release`
+     fi
+     if test -z "$ovs_cv_xsversion"; then
+       ovs_cv_xsversion=none
+     fi])
+  case $ovs_cv_xsversion in
+    none)
+      ;;
+
+    [[1-9]][[0-9]]* |                    dnl XenServer 10 or later
+    [[6-9]]* |                           dnl XenServer 6 or later
+    5.[[7-9]]* |                         dnl XenServer 5.7 or later
+    5.6.[[1-9]][[0-9]][[0-9]][[0-9]]* |  dnl XenServer 5.6.1000 or later
+    5.6.[[2-9]][[0-9]][[0-9]]* |         dnl XenServer 5.6.200 or later
+    5.6.1[[0-9]][[0-9]])                 dnl Xenserver 5.6.100 or later
+      ;;
+
+    *)
+      AC_MSG_ERROR([This appears to be XenServer $ovs_cv_xsversion, but only XenServer 5.6.100 or later is supported.  (If you are really using a supported version of XenServer, you may override this error message by specifying 'ovs_cv_xsversion=5.6.100' on the "configure" command line.)])
+      ;;
+  esac])