Merge branch 'mainstream'
authorGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Sun, 9 Mar 2014 15:04:41 +0000 (16:04 +0100)
committerGiuseppe Lettieri <g.lettieri@iet.unipi.it>
Sun, 9 Mar 2014 15:04:41 +0000 (16:04 +0100)
26 files changed:
acinclude.m4
configure.ac
include/windows/automake.mk
include/windows/sys/resource.h [new file with mode: 0644]
lib/automake.mk
lib/command-line.c
lib/dpif.c
lib/getrusage-windows.c [new file with mode: 0644]
lib/netdev.c
lib/ovs-thread.c
lib/ovs-thread.h
lib/socket-util.c
lib/timeval.c
lib/timeval.h
lib/vlandev.c
ofproto/ofproto-dpif-upcall.c
ofproto/ofproto-provider.h
ofproto/ofproto.c
ofproto/ofproto.h
ovsdb/automake.mk
tests/automake.mk
utilities/automake.mk
vswitchd/automake.mk
vswitchd/bridge.c
vswitchd/system-stats.c
vtep/automake.mk

index 8ff5828..830fd3f 100644 (file)
@@ -1,6 +1,6 @@
 # -*- autoconf -*-
 
-# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
+# Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -579,3 +579,18 @@ AC_DEFUN([OVS_CHECK_PTHREAD_SET_NAME],
          ;;
      esac
    fi])
+
+dnl OVS_CHECK_LINUX_HOST.
+dnl
+dnl Checks whether we're building for a Linux host, based on the presence of
+dnl the __linux__ preprocessor symbol, and sets up an Automake conditional
+dnl LINUX based on the result.
+AC_DEFUN([OVS_CHECK_LINUX_HOST],
+  [AC_CACHE_CHECK(
+     [whether __linux__ is defined],
+     [ovs_cv_linux],
+     [AC_COMPILE_IFELSE(
+        [AC_LANG_PROGRAM([enum { LINUX = __linux__};], [])],
+        [ovs_cv_linux=true],
+        [ovs_cv_linux=false])])
+   AM_CONDITIONAL([LINUX], [$ovs_cv_linux])])
index 2fccc64..09e01fb 100644 (file)
@@ -90,6 +90,7 @@ OVS_CHECK_ATOMIC_ALWAYS_LOCK_FREE(4)
 OVS_CHECK_ATOMIC_ALWAYS_LOCK_FREE(8)
 OVS_CHECK_POSIX_AIO
 OVS_CHECK_PTHREAD_SET_NAME
+OVS_CHECK_LINUX_HOST
 
 OVS_CHECK_INCLUDE_NEXT([stdio.h string.h])
 AC_CONFIG_FILES([lib/stdio.h lib/string.h])
@@ -132,11 +133,6 @@ AC_CONFIG_COMMANDS([include/openflow/openflow.h.stamp])
 
 AC_CONFIG_COMMANDS([utilities/bugtool/dummy], [:])
 
-AM_CONDITIONAL([LINUX_DATAPATH], [test "$HAVE_NETLINK" = yes && test "$ESX" = no])
-if test "$HAVE_NETLINK" = yes && test "$ESX" = no; then
-    AC_DEFINE([LINUX_DATAPATH], [1], [System uses the linux datapath module.])
-fi
-
 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
 
 AC_OUTPUT
index 2771270..b8f144e 100644 (file)
@@ -8,4 +8,5 @@
 noinst_HEADERS += \
        include/windows/getopt.h \
        include/windows/syslog.h \
+       include/windows/sys/resource.h \
        include/windows/windefs.h
diff --git a/include/windows/sys/resource.h b/include/windows/sys/resource.h
new file mode 100644 (file)
index 0000000..d4628f2
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2014 Nicira, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef SYS_RESOURCE_H
+#define SYS_RESOURCE_H 1
+
+struct rusage {
+    struct timeval ru_utime; /* user CPU time used */
+    struct timeval ru_stime; /* system CPU time used */
+    long   ru_maxrss;        /* maximum resident set size */
+    long   ru_ixrss;         /* integral shared memory size */
+    long   ru_idrss;         /* integral unshared data size */
+    long   ru_isrss;         /* integral unshared stack size */
+    long   ru_minflt;        /* page reclaims (soft page faults) */
+    long   ru_majflt;        /* page faults (hard page faults) */
+    long   ru_nswap;         /* swaps */
+    long   ru_inblock;       /* block input operations */
+    long   ru_oublock;       /* block output operations */
+    long   ru_msgsnd;        /* IPC messages sent */
+    long   ru_msgrcv;        /* IPC messages received */
+    long   ru_nsignals;      /* signals received */
+    long   ru_nvcsw;         /* voluntary context switches */
+    long   ru_nivcsw;        /* involuntary context switches */
+};
+
+#ifndef RUSAGE_SELF
+#define RUSAGE_SELF 1
+#endif
+
+#ifndef RUSAGE_CHILDREN
+#define RUSAGE_CHILDREN 2
+#endif
+
+#ifndef RUSAGE_THREAD
+#define RUSAGE_THREAD 3
+#endif
+
+#endif /* sys/resource.h */
index ac583c2..9a55b15 100644 (file)
@@ -240,6 +240,7 @@ if WIN32
 lib_libopenvswitch_la_SOURCES += \
        lib/daemon-windows.c \
        lib/getopt_long.c \
+       lib/getrusage-windows.c \
        lib/latch-windows.c \
        lib/stream-fd-windows.c
 else
@@ -278,7 +279,7 @@ if HAVE_WNO_UNUSED_PARAMETER
 lib_libsflow_la_CFLAGS += -Wno-unused-parameter
 endif
 
-if LINUX_DATAPATH
+if LINUX
 lib_libopenvswitch_la_SOURCES += \
        lib/dpif-linux.c \
        lib/dpif-linux.h \
index 805e51b..cb73a25 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010, 2011, 2013 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2013, 2014 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -93,7 +93,7 @@ run_command(int argc, char *argv[], const struct command commands[])
 \f
 /* Process title. */
 
-#ifdef LINUX_DATAPATH
+#ifdef __linux__
 static struct ovs_mutex proctitle_mutex = OVS_MUTEX_INITIALIZER;
 
 /* Start of command-line arguments in memory. */
@@ -199,7 +199,7 @@ proctitle_restore(void)
     }
     ovs_mutex_unlock(&proctitle_mutex);
 }
-#else  /* !LINUX_DATAPATH*/
+#else  /* !__linux__ */
 /* Stubs that don't do anything on non-Linux systems. */
 
 void
@@ -219,4 +219,4 @@ void
 proctitle_restore(void)
 {
 }
-#endif  /* !LINUX_DATAPATH */
+#endif  /* !__linux__ */
index 7d578eb..db1a130 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013 Nicira, Inc.
+ * Copyright (c) 2008, 2009, 2010, 2011, 2012, 2013, 2014 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -57,7 +57,7 @@ COVERAGE_DEFINE(dpif_purge);
 COVERAGE_DEFINE(dpif_execute_with_help);
 
 static const struct dpif_class *base_dpif_classes[] = {
-#ifdef LINUX_DATAPATH
+#ifdef __linux__
     &dpif_linux_class,
 #endif
     &dpif_netdev_class,
diff --git a/lib/getrusage-windows.c b/lib/getrusage-windows.c
new file mode 100644 (file)
index 0000000..0282a17
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (c) 2014 Nicira, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <config.h>
+#include <errno.h>
+#include <psapi.h>
+#include <sys/resource.h>
+#include <time.h>
+#include "util.h"
+#include "vlog.h"
+
+VLOG_DEFINE_THIS_MODULE(getrusage_windows);
+
+static void
+usage_to_timeval(FILETIME *ft, struct timeval *tv)
+{
+    ULARGE_INTEGER time;
+    time.LowPart = ft->dwLowDateTime;
+    time.HighPart = ft->dwHighDateTime;
+
+    tv->tv_sec = time.QuadPart / 10000000;
+    tv->tv_usec = (time.QuadPart % 10000000) / 10;
+}
+
+int
+getrusage(int who, struct rusage *usage)
+{
+    FILETIME creation_time, exit_time, kernel_time, user_time;
+    PROCESS_MEMORY_COUNTERS pmc;
+
+    memset(usage, 0, sizeof(struct rusage));
+
+    if (who == RUSAGE_SELF) {
+        if (!GetProcessTimes(GetCurrentProcess(), &creation_time, &exit_time,
+                             &kernel_time, &user_time)) {
+            VLOG_ERR("failed at GetProcessTimes: %s",
+                      ovs_lasterror_to_string());
+            return -1;
+        }
+
+        if (!GetProcessMemoryInfo(GetCurrentProcess(), &pmc, sizeof(pmc))) {
+            VLOG_ERR("failed at GetProcessMemoryInfo: %s",
+                      ovs_lasterror_to_string());
+            return -1;
+        }
+
+        usage_to_timeval(&kernel_time, &usage->ru_stime);
+        usage_to_timeval(&user_time, &usage->ru_utime);
+        usage->ru_majflt = pmc.PageFaultCount;
+        usage->ru_maxrss = pmc.PeakWorkingSetSize / 1024;
+        return 0;
+    } else if (who == RUSAGE_THREAD) {
+        if (!GetThreadTimes(GetCurrentThread(), &creation_time, &exit_time,
+                            &kernel_time, &user_time)) {
+            VLOG_ERR("failed at GetThreadTimes: %s",
+                      ovs_lasterror_to_string());
+            return -1;
+        }
+        usage_to_timeval(&kernel_time, &usage->ru_stime);
+        usage_to_timeval(&user_time, &usage->ru_utime);
+        return 0;
+    } else {
+        return -1;
+    }
+}
index f5f9233..6aca2f4 100644 (file)
@@ -102,7 +102,7 @@ netdev_initialize(void)
         fatal_signal_add_hook(restore_all_flags, NULL, NULL, true);
         netdev_vport_patch_register();
 
-#ifdef LINUX_DATAPATH
+#ifdef __linux__
         netdev_register_provider(&netdev_linux_class);
         netdev_register_provider(&netdev_internal_class);
         netdev_register_provider(&netdev_tap_class);
index 4dfccaf..b6b51c7 100644 (file)
@@ -117,6 +117,15 @@ UNLOCK_FUNCTION(rwlock, destroy);
             ovs_abort(error, "%s failed", #FUNCTION);   \
         }                                               \
     }
+#define XPTHREAD_FUNC3(FUNCTION, PARAM1, PARAM2, PARAM3)\
+    void                                                \
+    x##FUNCTION(PARAM1 arg1, PARAM2 arg2, PARAM3 arg3)  \
+    {                                                   \
+        int error = FUNCTION(arg1, arg2, arg3);         \
+        if (OVS_UNLIKELY(error)) {                      \
+            ovs_abort(error, "%s failed", #FUNCTION);   \
+        }                                               \
+    }
 
 XPTHREAD_FUNC1(pthread_mutex_lock, pthread_mutex_t *);
 XPTHREAD_FUNC1(pthread_mutex_unlock, pthread_mutex_t *);
@@ -136,6 +145,10 @@ XPTHREAD_FUNC1(pthread_cond_destroy, pthread_cond_t *);
 XPTHREAD_FUNC1(pthread_cond_signal, pthread_cond_t *);
 XPTHREAD_FUNC1(pthread_cond_broadcast, pthread_cond_t *);
 
+XPTHREAD_FUNC3(pthread_barrier_init, pthread_barrier_t *,
+               pthread_barrierattr_t *, unsigned int);
+XPTHREAD_FUNC1(pthread_barrier_destroy, pthread_barrier_t *);
+
 XPTHREAD_FUNC2(pthread_join, pthread_t, void **);
 
 typedef void destructor_func(void *);
@@ -215,6 +228,19 @@ ovs_mutex_cond_wait(pthread_cond_t *cond, const struct ovs_mutex *mutex_)
         ovs_abort(error, "pthread_cond_wait failed");
     }
 }
+
+int
+xpthread_barrier_wait(pthread_barrier_t *barrier)
+{
+    int error;
+
+    error = pthread_barrier_wait(barrier);
+    if (error && OVS_UNLIKELY(error != PTHREAD_BARRIER_SERIAL_THREAD)) {
+        ovs_abort(error, "pthread_barrier_wait failed");
+    }
+
+    return error;
+}
 \f
 DEFINE_EXTERN_PER_THREAD_DATA(ovsthread_id, 0);
 
index 2e9a937..8868c51 100644 (file)
@@ -146,6 +146,12 @@ void xpthread_cond_destroy(pthread_cond_t *);
 void xpthread_cond_signal(pthread_cond_t *);
 void xpthread_cond_broadcast(pthread_cond_t *);
 
+/* Wrappers for pthread_barrier_*() that abort the process on any error. */
+void xpthread_barrier_init(pthread_barrier_t *, pthread_barrierattr_t *,
+                           unsigned int count);
+int xpthread_barrier_wait(pthread_barrier_t *);
+void xpthread_barrier_destroy(pthread_barrier_t *);
+
 void xpthread_key_create(pthread_key_t *, void (*destructor)(void *));
 void xpthread_key_delete(pthread_key_t);
 void xpthread_setspecific(pthread_key_t, const void *);
index f7d2d0f..4c79cd6 100644 (file)
@@ -39,7 +39,7 @@
 #include "poll-loop.h"
 #include "util.h"
 #include "vlog.h"
-#if AF_PACKET && LINUX_DATAPATH
+#ifdef __linux__
 #include <linux/if_packet.h>
 #endif
 #ifdef HAVE_NETLINK
@@ -51,9 +51,11 @@ VLOG_DEFINE_THIS_MODULE(socket_util);
 
 /* #ifdefs make it a pain to maintain code: you have to try to build both ways.
  * Thus, this file compiles all of the code regardless of the target, by
- * writing "if (LINUX_DATAPATH)" instead of "#ifdef __linux__". */
-#ifndef LINUX_DATAPATH
-#define LINUX_DATAPATH 0
+ * writing "if (LINUX)" instead of "#ifdef __linux__". */
+#ifdef __linux__
+#define LINUX 0
+#else
+#define LINUX 1
 #endif
 
 #ifndef O_DIRECTORY
@@ -292,7 +294,7 @@ drain_rcvbuf(int fd)
          *
          * On other Unix-like OSes, MSG_TRUNC has no effect in the flags
          * argument. */
-        char buffer[LINUX_DATAPATH ? 1 : 2048];
+        char buffer[LINUX ? 1 : 2048];
         ssize_t n_bytes = recv(fd, buffer, sizeof buffer,
                                MSG_TRUNC | MSG_DONTWAIT);
         if (n_bytes <= 0 || n_bytes >= rcvbuf) {
@@ -350,7 +352,7 @@ shorten_name_via_proc(const char *name, char short_name[MAX_UN_LEN + 1],
     int dirfd;
     int len;
 
-    if (!LINUX_DATAPATH) {
+    if (LINUX) {
         return ENAMETOOLONG;
     }
 
@@ -1146,7 +1148,7 @@ describe_sockaddr(struct ds *string, int fd,
             }
         }
 #endif
-#if AF_PACKET && LINUX_DATAPATH
+#if __linux__
         else if (ss.ss_family == AF_PACKET) {
             struct sockaddr_ll sll;
 
@@ -1176,7 +1178,7 @@ describe_sockaddr(struct ds *string, int fd,
 }
 
 
-#ifdef LINUX_DATAPATH
+#ifdef __linux__
 static void
 put_fd_filename(struct ds *string, int fd)
 {
@@ -1221,7 +1223,7 @@ describe_fd(int fd)
                               : S_ISFIFO(s.st_mode) ? "FIFO"
                               : S_ISLNK(s.st_mode) ? "symbolic link"
                               : "unknown"));
-#ifdef LINUX_DATAPATH
+#ifdef __linux__
         put_fd_filename(&string, fd);
 #endif
     }
index 3e7719f..74efa59 100644 (file)
 
 VLOG_DEFINE_THIS_MODULE(timeval);
 
+#ifdef _WIN32
+typedef unsigned int clockid_t;
+
+#ifndef CLOCK_MONOTONIC
+#define CLOCK_MONOTONIC 1
+#endif
+
+#ifndef CLOCK_REALTIME
+#define CLOCK_REALTIME 2
+#endif
+
+/* Number of 100 ns intervals from January 1, 1601 till January 1, 1970. */
+static ULARGE_INTEGER unix_epoch;
+#endif /* _WIN32 */
+
 struct clock {
     clockid_t id;               /* CLOCK_MONOTONIC or CLOCK_REALTIME. */
 
@@ -96,6 +111,16 @@ do_init_time(void)
 {
     struct timespec ts;
 
+#ifdef _WIN32
+    /* Calculate number of 100-nanosecond intervals till 01/01/1970. */
+    SYSTEMTIME unix_epoch_st = { 1970, 1, 0, 1, 0, 0, 0, 0};
+    FILETIME unix_epoch_ft;
+
+    SystemTimeToFileTime(&unix_epoch_st, &unix_epoch_ft);
+    unix_epoch.LowPart = unix_epoch_ft.dwLowDateTime;
+    unix_epoch.HighPart = unix_epoch_ft.dwHighDateTime;
+#endif
+
     coverage_init();
 
     init_clock(&monotonic_clock, (!clock_gettime(CLOCK_MONOTONIC, &ts)
@@ -325,12 +350,69 @@ time_boot_msec(void)
     return boot_time;
 }
 
+#ifdef _WIN32
+static ULARGE_INTEGER
+xgetfiletime(void)
+{
+    ULARGE_INTEGER current_time;
+    FILETIME current_time_ft;
+
+    /* Returns current time in UTC as a 64-bit value representing the number
+     * of 100-nanosecond intervals since January 1, 1601 . */
+    GetSystemTimePreciseAsFileTime(&current_time_ft);
+    current_time.LowPart = current_time_ft.dwLowDateTime;
+    current_time.HighPart = current_time_ft.dwHighDateTime;
+
+    return current_time;
+}
+
+static int
+clock_gettime(clock_t id, struct timespec *ts)
+{
+    if (id == CLOCK_MONOTONIC) {
+        static LARGE_INTEGER freq;
+        LARGE_INTEGER count;
+        long long int ns;
+
+        if (!freq.QuadPart) {
+            /* Number of counts per second. */
+            QueryPerformanceFrequency(&freq);
+        }
+        /* Total number of counts from a starting point. */
+        QueryPerformanceCounter(&count);
+
+        /* Total nano seconds from a starting point. */
+        ns = (double) count.QuadPart / freq.QuadPart * 1000000000;
+
+        ts->tv_sec = count.QuadPart / freq.QuadPart;
+        ts->tv_nsec = ns % 1000000000;
+    } else if (id == CLOCK_REALTIME) {
+        ULARGE_INTEGER current_time = xgetfiletime();
+
+        /* Time from Epoch to now. */
+        ts->tv_sec = (current_time.QuadPart - unix_epoch.QuadPart) / 10000000;
+        ts->tv_nsec = ((current_time.QuadPart - unix_epoch.QuadPart) %
+                       10000000) * 100;
+    } else {
+        return -1;
+    }
+}
+#endif /* _WIN32 */
+
 void
 xgettimeofday(struct timeval *tv)
 {
+#ifndef _WIN32
     if (gettimeofday(tv, NULL) == -1) {
         VLOG_FATAL("gettimeofday failed (%s)", ovs_strerror(errno));
     }
+#else
+    ULARGE_INTEGER current_time = xgetfiletime();
+
+    tv->tv_sec = (current_time.QuadPart - unix_epoch.QuadPart) / 10000000;
+    tv->tv_usec = ((current_time.QuadPart - unix_epoch.QuadPart) %
+                   10000000) / 10;
+#endif
 }
 
 void
index c207f23..0bd74cc 100644 (file)
@@ -40,6 +40,11 @@ BUILD_ASSERT_DECL(TYPE_IS_SIGNED(time_t));
 #define TIME_MAX TYPE_MAXIMUM(time_t)
 #define TIME_MIN TYPE_MINIMUM(time_t)
 
+#ifdef _WIN32
+#define localtime_r(timep, result) localtime_s(result, timep)
+#define gmtime_r(timep, result) gmtime_s(result, timep)
+#endif /* _WIN32 */
+
 struct tm_msec {
   struct tm tm;
   int msec;
index b793f77..382487c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2011, 2013 Nicira, Inc.
+ * Copyright (c) 2011, 2013, 2014 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -38,7 +38,7 @@ struct vlandev_class {
     int (*vd_del)(const char *vlan_dev);
 };
 
-#ifdef LINUX_DATAPATH
+#ifdef __linux__
 static const struct vlandev_class vlandev_linux_class;
 #endif
 static const struct vlandev_class vlandev_stub_class;
@@ -61,7 +61,7 @@ static const struct vlandev_class *
 vlandev_get_class(void)
 {
     if (!vd_class) {
-#ifdef LINUX_DATAPATH
+#if __linux__
         vd_class = &vlandev_linux_class;
 #else
         vd_class = &vlandev_stub_class;
@@ -161,7 +161,7 @@ vlandev_get_name(const char *real_dev_name, int vid)
 \f
 /* The Linux vlandev implementation. */
 
-#ifdef LINUX_DATAPATH
+#ifdef __linux__
 #include "rtnetlink-link.h"
 #include <linux/if_vlan.h>
 #include <linux/sockios.h>
index 7dbd7f7..0d5b251 100644 (file)
@@ -41,7 +41,6 @@
 #define MAX_QUEUE_LENGTH 512
 #define FLOW_MISS_MAX_BATCH 50
 #define REVALIDATE_MAX_BATCH 50
-#define MAX_IDLE 1500
 
 VLOG_DEFINE_THIS_MODULE(ofproto_dpif_upcall);
 
@@ -646,7 +645,7 @@ udpif_flow_dumper(void *arg)
         }
 
 skip:
-        poll_timer_wait_until(start_time + MIN(MAX_IDLE, 500));
+        poll_timer_wait_until(start_time + MIN(ofproto_max_idle, 500));
         seq_wait(udpif->reval_seq, udpif->last_reval_seq);
         latch_wait(&udpif->exit_latch);
         poll_block();
@@ -1510,7 +1509,7 @@ revalidate_udumps(struct revalidator *revalidator, struct list *udumps)
     n_flows = udpif_get_n_flows(udpif);
 
     must_del = false;
-    max_idle = MAX_IDLE;
+    max_idle = ofproto_max_idle;
     if (n_flows > flow_limit) {
         must_del = n_flows > 2 * flow_limit;
         max_idle = 100;
index 2c72fbc..d116451 100644 (file)
@@ -464,6 +464,11 @@ void rule_collection_destroy(struct rule_collection *);
  * ofproto-dpif implementation. */
 extern unsigned ofproto_flow_limit;
 
+/* Maximum idle time (in ms) for flows to be cached in the datapath.
+ * Revalidators may expire flows more quickly than the configured value based
+ * on system load and other factors. This variable is subject to change. */
+extern unsigned ofproto_max_idle;
+
 /* Number of upcall handler and revalidator threads. Only affects the
  * ofproto-dpif implementation. */
 extern size_t n_handlers, n_revalidators;
index 19e7091..e691bb9 100644 (file)
@@ -307,6 +307,7 @@ static size_t allocated_ofproto_classes;
 struct ovs_mutex ofproto_mutex = OVS_MUTEX_INITIALIZER;
 
 unsigned ofproto_flow_limit = OFPROTO_FLOW_LIMIT_DEFAULT;
+unsigned ofproto_max_idle = OFPROTO_MAX_IDLE_DEFAULT;
 
 size_t n_handlers, n_revalidators;
 
@@ -697,6 +698,14 @@ ofproto_set_flow_limit(unsigned limit)
     ofproto_flow_limit = limit;
 }
 
+/* Sets the maximum idle time for flows in the datapath before they are
+ * expired. */
+void
+ofproto_set_max_idle(unsigned max_idle)
+{
+    ofproto_max_idle = max_idle;
+}
+
 /* If forward_bpdu is true, the NORMAL action will forward frames with
  * reserved (e.g. STP) destination Ethernet addresses. if forward_bpdu is false,
  * the NORMAL action will drop these frames. */
index 1f9cb15..546827f 100644 (file)
@@ -214,6 +214,7 @@ int ofproto_port_dump_done(struct ofproto_port_dump *);
         )
 
 #define OFPROTO_FLOW_LIMIT_DEFAULT 200000
+#define OFPROTO_MAX_IDLE_DEFAULT 1500
 
 const char *ofproto_port_open_type(const char *datapath_type,
                                    const char *port_type);
@@ -236,6 +237,7 @@ void ofproto_set_extra_in_band_remotes(struct ofproto *,
                                        const struct sockaddr_in *, size_t n);
 void ofproto_set_in_band_queue(struct ofproto *, int queue_id);
 void ofproto_set_flow_limit(unsigned limit);
+void ofproto_set_max_idle(unsigned max_idle);
 void ofproto_set_forward_bpdu(struct ofproto *, bool forward_bpdu);
 void ofproto_set_mac_table_config(struct ofproto *, unsigned idle_time,
                                   size_t max_entries);
index 69e7900..dfb900a 100644 (file)
@@ -40,7 +40,7 @@ MAN_FRAGMENTS += \
 # ovsdb-tool
 bin_PROGRAMS += ovsdb/ovsdb-tool
 ovsdb_ovsdb_tool_SOURCES = ovsdb/ovsdb-tool.c
-ovsdb_ovsdb_tool_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la $(SSL_LIBS)
+ovsdb_ovsdb_tool_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la
 # ovsdb-tool.1
 man_MANS += ovsdb/ovsdb-tool.1
 DISTCLEANFILES += ovsdb/ovsdb-tool.1
@@ -49,7 +49,7 @@ MAN_ROOTS += ovsdb/ovsdb-tool.1.in
 # ovsdb-client
 bin_PROGRAMS += ovsdb/ovsdb-client
 ovsdb_ovsdb_client_SOURCES = ovsdb/ovsdb-client.c
-ovsdb_ovsdb_client_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la $(SSL_LIBS)
+ovsdb_ovsdb_client_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la
 # ovsdb-client.1
 man_MANS += ovsdb/ovsdb-client.1
 DISTCLEANFILES += ovsdb/ovsdb-client.1
@@ -58,7 +58,7 @@ MAN_ROOTS += ovsdb/ovsdb-client.1.in
 # ovsdb-server
 sbin_PROGRAMS += ovsdb/ovsdb-server
 ovsdb_ovsdb_server_SOURCES = ovsdb/ovsdb-server.c
-ovsdb_ovsdb_server_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la $(SSL_LIBS)
+ovsdb_ovsdb_server_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la
 # ovsdb-server.1
 man_MANS += ovsdb/ovsdb-server.1
 DISTCLEANFILES += ovsdb/ovsdb-server.1
index 0cf45a4..739d79e 100644 (file)
@@ -181,38 +181,38 @@ $(srcdir)/package.m4: $(top_srcdir)/configure.ac
 
 noinst_PROGRAMS += tests/test-aes128
 tests_test_aes128_SOURCES = tests/test-aes128.c
-tests_test_aes128_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_aes128_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-atomic
 tests_test_atomic_SOURCES = tests/test-atomic.c
-tests_test_atomic_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_atomic_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-bundle
 tests_test_bundle_SOURCES = tests/test-bundle.c
-tests_test_bundle_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_bundle_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-classifier
 tests_test_classifier_SOURCES = tests/test-classifier.c
-tests_test_classifier_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_classifier_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-controller
 MAN_ROOTS += tests/test-controller.8.in
 DISTCLEANFILES += tests/test-controller.8
 noinst_man_MANS += tests/test-controller.8
 tests_test_controller_SOURCES = tests/test-controller.c
-tests_test_controller_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_controller_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-csum
 tests_test_csum_SOURCES = tests/test-csum.c
-tests_test_csum_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_csum_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-file_name
 tests_test_file_name_SOURCES = tests/test-file_name.c
-tests_test_file_name_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_file_name_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-flows
 tests_test_flows_SOURCES = tests/test-flows.c
-tests_test_flows_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_flows_LDADD = lib/libopenvswitch.la
 dist_check_SCRIPTS = tests/flowgen.pl
 
 noinst_PROGRAMS += tests/test-hash
@@ -221,63 +221,63 @@ tests_test_hash_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-heap
 tests_test_heap_SOURCES = tests/test-heap.c
-tests_test_heap_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_heap_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-hindex
 tests_test_hindex_SOURCES = tests/test-hindex.c
-tests_test_hindex_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_hindex_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-hmap
 tests_test_hmap_SOURCES = tests/test-hmap.c
-tests_test_hmap_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_hmap_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-json
 tests_test_json_SOURCES = tests/test-json.c
-tests_test_json_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_json_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-jsonrpc
 tests_test_jsonrpc_SOURCES = tests/test-jsonrpc.c
-tests_test_jsonrpc_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_jsonrpc_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-list
 tests_test_list_SOURCES = tests/test-list.c
-tests_test_list_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_list_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-lockfile
 tests_test_lockfile_SOURCES = tests/test-lockfile.c
-tests_test_lockfile_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_lockfile_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-multipath
 tests_test_multipath_SOURCES = tests/test-multipath.c
-tests_test_multipath_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_multipath_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-packets
 tests_test_packets_SOURCES = tests/test-packets.c
-tests_test_packets_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_packets_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-random
 tests_test_random_SOURCES = tests/test-random.c
-tests_test_random_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_random_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-stp
 tests_test_stp_SOURCES = tests/test-stp.c
-tests_test_stp_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_stp_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-sflow
 tests_test_sflow_SOURCES = tests/test-sflow.c
-tests_test_sflow_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_sflow_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-netflow
 tests_test_netflow_SOURCES = tests/test-netflow.c
-tests_test_netflow_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_netflow_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-unix-socket
 tests_test_unix_socket_SOURCES = tests/test-unix-socket.c
-tests_test_unix_socket_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_unix_socket_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-odp
 tests_test_odp_SOURCES = tests/test-odp.c
-tests_test_odp_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_odp_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-ovsdb
 tests_test_ovsdb_SOURCES = \
@@ -285,7 +285,7 @@ tests_test_ovsdb_SOURCES = \
        tests/idltest.c \
        tests/idltest.h
 EXTRA_DIST += tests/uuidfilt.pl tests/ovsdb-monitor-sort.pl
-tests_test_ovsdb_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_ovsdb_LDADD = ovsdb/libovsdb.la lib/libopenvswitch.la
 
 # idltest schema and IDL
 OVSIDL_BUILT += tests/idltest.c tests/idltest.h tests/idltest.ovsidl
@@ -299,11 +299,11 @@ tests/idltest.c: tests/idltest.h
 
 noinst_PROGRAMS += tests/test-reconnect
 tests_test_reconnect_SOURCES = tests/test-reconnect.c
-tests_test_reconnect_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_reconnect_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-sha1
 tests_test_sha1_SOURCES = tests/test-sha1.c
-tests_test_sha1_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_sha1_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-strtok_r
 tests_test_strtok_r_SOURCES = tests/test-strtok_r.c
@@ -313,15 +313,15 @@ tests_test_type_props_SOURCES = tests/test-type-props.c
 
 noinst_PROGRAMS += tests/test-util
 tests_test_util_SOURCES = tests/test-util.c
-tests_test_util_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_util_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-uuid
 tests_test_uuid_SOURCES = tests/test-uuid.c
-tests_test_uuid_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_uuid_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-vconn
 tests_test_vconn_SOURCES = tests/test-vconn.c
-tests_test_vconn_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+tests_test_vconn_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += tests/test-byte-order
 tests_test_byte_order_SOURCES = tests/test-byte-order.c
index ffc48b1..ce1c8b2 100644 (file)
@@ -97,32 +97,31 @@ man_MANS += \
 dist_man_MANS += utilities/ovs-ctl.8
 
 utilities_ovs_appctl_SOURCES = utilities/ovs-appctl.c
-utilities_ovs_appctl_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+utilities_ovs_appctl_LDADD = lib/libopenvswitch.la
 
 utilities_ovs_dpctl_SOURCES = utilities/ovs-dpctl.c
-utilities_ovs_dpctl_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+utilities_ovs_dpctl_LDADD = lib/libopenvswitch.la
 
 utilities_ovs_ofctl_SOURCES = utilities/ovs-ofctl.c
 utilities_ovs_ofctl_LDADD = \
        ofproto/libofproto.la \
-       lib/libopenvswitch.la \
-       $(SSL_LIBS)
+       lib/libopenvswitch.la
 
 utilities_ovs_vsctl_SOURCES = utilities/ovs-vsctl.c
-utilities_ovs_vsctl_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+utilities_ovs_vsctl_LDADD = lib/libopenvswitch.la
 
-if LINUX_DATAPATH
+if LINUX
 sbin_PROGRAMS += utilities/ovs-vlan-bug-workaround
 utilities_ovs_vlan_bug_workaround_SOURCES = utilities/ovs-vlan-bug-workaround.c
-utilities_ovs_vlan_bug_workaround_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+utilities_ovs_vlan_bug_workaround_LDADD = lib/libopenvswitch.la
 
 noinst_PROGRAMS += utilities/nlmon
 utilities_nlmon_SOURCES = utilities/nlmon.c
-utilities_nlmon_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+utilities_nlmon_LDADD = lib/libopenvswitch.la
 endif
 
 bin_PROGRAMS += utilities/ovs-benchmark
 utilities_ovs_benchmark_SOURCES = utilities/ovs-benchmark.c
-utilities_ovs_benchmark_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+utilities_ovs_benchmark_LDADD = lib/libopenvswitch.la
 
 include utilities/bugtool/automake.mk
index b0a386b..c45d01d 100644 (file)
@@ -14,8 +14,7 @@ vswitchd_ovs_vswitchd_SOURCES = \
 vswitchd_ovs_vswitchd_LDADD = \
        ofproto/libofproto.la \
        lib/libsflow.la \
-       lib/libopenvswitch.la \
-       $(SSL_LIBS)
+       lib/libopenvswitch.la
 EXTRA_DIST += vswitchd/INTERNALS
 MAN_ROOTS += vswitchd/ovs-vswitchd.8.in
 
index 0f7ca84..f7bd657 100644 (file)
@@ -493,6 +493,8 @@ bridge_reconfigure(const struct ovsrec_open_vswitch *ovs_cfg)
 
     ofproto_set_flow_limit(smap_get_int(&ovs_cfg->other_config, "flow-limit",
                                         OFPROTO_FLOW_LIMIT_DEFAULT));
+    ofproto_set_max_idle(smap_get_int(&ovs_cfg->other_config, "max-idle",
+                                      OFPROTO_MAX_IDLE_DEFAULT));
 
     ofproto_set_threads(
         smap_get_int(&ovs_cfg->other_config, "n-handler-threads", 0),
index 1d9cb78..ca98b03 100644 (file)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010, 2012, 2013 Nicira, Inc.
+/* Copyright (c) 2010, 2012, 2013, 2014 Nicira, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,12 +48,13 @@ VLOG_DEFINE_THIS_MODULE(system_stats);
 
 /* #ifdefs make it a pain to maintain code: you have to try to build both ways.
  * Thus, this file tries to compile as much of the code as possible regardless
- * of the target, by writing "if (LINUX_DATAPATH)" instead of "#ifdef
- * __linux__" where this is possible. */
-#ifdef LINUX_DATAPATH
+ * of the target, by writing "if (LINUX)" instead of "#ifdef __linux__" where
+ * this is possible. */
+#ifdef __linux__
+#define LINUX 1
 #include <asm/param.h>
 #else
-#define LINUX_DATAPATH 0
+#define LINUX 0
 #endif
 
 static void
@@ -96,7 +97,7 @@ get_page_size(void)
 static void
 get_memory_stats(struct smap *stats)
 {
-    if (!LINUX_DATAPATH) {
+    if (!LINUX) {
         unsigned int pagesize = get_page_size();
 #ifdef _SC_PHYS_PAGES
         long int phys_pages = sysconf(_SC_PHYS_PAGES);
@@ -174,7 +175,7 @@ get_boot_time(void)
     static long long int cache_expiration = LLONG_MIN;
     static long long int boot_time;
 
-    ovs_assert(LINUX_DATAPATH);
+    ovs_assert(LINUX);
 
     if (time_msec() >= cache_expiration) {
         static const char stat_file[] = "/proc/stat";
@@ -207,7 +208,7 @@ get_boot_time(void)
 static unsigned long long int
 ticks_to_ms(unsigned long long int ticks)
 {
-    ovs_assert(LINUX_DATAPATH);
+    ovs_assert(LINUX);
 
 #ifndef USER_HZ
 #define USER_HZ 100
@@ -240,7 +241,7 @@ get_raw_process_info(pid_t pid, struct raw_process_info *raw)
     FILE *stream;
     int n;
 
-    ovs_assert(LINUX_DATAPATH);
+    ovs_assert(LINUX);
 
     sprintf(file_name, "/proc/%lu/stat", (unsigned long int) pid);
     stream = fopen(file_name, "r");
@@ -326,7 +327,7 @@ count_crashes(pid_t pid)
     int crashes = 0;
     FILE *stream;
 
-    ovs_assert(LINUX_DATAPATH);
+    ovs_assert(LINUX);
 
     sprintf(file_name, "/proc/%lu/cmdline", (unsigned long int) pid);
     stream = fopen(file_name, "r");
@@ -369,7 +370,7 @@ get_process_info(pid_t pid, struct process_info *pinfo)
 {
     struct raw_process_info child;
 
-    ovs_assert(LINUX_DATAPATH);
+    ovs_assert(LINUX);
     if (!get_raw_process_info(pid, &child)) {
         return false;
     }
@@ -435,7 +436,7 @@ get_process_stats(struct smap *stats)
         key = xasprintf("process_%.*s",
                         (int) (extension - de->d_name), de->d_name);
         if (!smap_get(stats, key)) {
-            if (LINUX_DATAPATH && get_process_info(pid, &pinfo)) {
+            if (LINUX && get_process_info(pid, &pinfo)) {
                 smap_add_format(stats, key, "%lu,%lu,%lld,%d,%lld,%lld",
                                 pinfo.vsz, pinfo.rss, pinfo.cputime,
                                 pinfo.crashes, pinfo.booted, pinfo.uptime);
index 978747d..f06148a 100644 (file)
@@ -11,7 +11,7 @@ man_MANS += \
    vtep/vtep-ctl.8
 
 vtep_vtep_ctl_SOURCES = vtep/vtep-ctl.c
-vtep_vtep_ctl_LDADD = lib/libopenvswitch.la $(SSL_LIBS)
+vtep_vtep_ctl_LDADD = lib/libopenvswitch.la
 
 # ovs-vtep
 scripts_SCRIPTS += \