diff --git lib/vconn.c lib/vconn.c index 5da5026..f8bea57 100644 --- lib/vconn.c +++ lib/vconn.c @@ -284,13 +284,7 @@ vconn_open_block(const char *name, int min_version, struct vconn **vconnp) error = vconn_open(name, min_version, &vconn); if (!error) { - while ((error = vconn_connect(vconn)) == EAGAIN) { - vconn_run(vconn); - vconn_run_wait(vconn); - vconn_connect_wait(vconn); - poll_block(); - } - assert(error != EINPROGRESS); + error = vconn_connect_block(vconn); } if (error) { @@ -608,6 +602,24 @@ do_send(struct vconn *vconn, struct ofpbuf *msg) return retval; } +/* Same as vconn_connect(), except that it waits until the connection on + * 'vconn' completes or fails. Thus, it will never return EAGAIN. */ +int +vconn_connect_block(struct vconn *vconn) +{ + int error; + + while ((error = vconn_connect(vconn)) == EAGAIN) { + vconn_run(vconn); + vconn_run_wait(vconn); + vconn_connect_wait(vconn); + poll_block(); + } + assert(error != EINPROGRESS); + + return error; +} + /* Same as vconn_send, except that it waits until 'msg' can be transmitted. */ int vconn_send_block(struct vconn *vconn, struct ofpbuf *msg) diff --git lib/vconn.h lib/vconn.h index 74b6b49..e9e0831 100644 --- lib/vconn.h +++ lib/vconn.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, 2009, 2010, 2011 Nicira Networks. + * Copyright (c) 2008, 2009, 2010, 2011, 2012 Nicira, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -53,6 +53,7 @@ void vconn_run(struct vconn *); void vconn_run_wait(struct vconn *); int vconn_open_block(const char *name, int min_version, struct vconn **); +int vconn_connect_block(struct vconn *); int vconn_send_block(struct vconn *, struct ofpbuf *); int vconn_recv_block(struct vconn *, struct ofpbuf **); diff --git tests/ofproto-dpif.at tests/ofproto-dpif.at index a306c11..21a9619 100644 --- tests/ofproto-dpif.at +++ tests/ofproto-dpif.at @@ -953,7 +953,7 @@ ovs-appctl -t test-netflow exit AT_CHECK([[sed -e 's/, uptime [0-9]*// s/, now [0-9.]*// -s/time \([0-9]*\)\.\.\.\1\b/time / +s/time \([0-9]*\)\.\.\.\1$/time / s/time [0-9]*\.\.\.[0-9]*/time / ' netflow.log]], [0], [header: v5, seq 0, engine 2,1 diff --git tests/ovs-vsctl.at tests/ovs-vsctl.at index 288b815..233841a 100644 --- tests/ovs-vsctl.at +++ tests/ovs-vsctl.at @@ -769,7 +769,7 @@ AT_CHECK( ]) m4_define([VSCTL_CHECK_FIND], - [AT_CHECK([ovs-vsctl --bare --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket -- --columns=name find bridge '$1' | sort | xargs echo], [0], [$2 + [AT_CHECK([echo `ovs-vsctl --bare --timeout=5 --no-wait -vreconnect:ANY:emer --db=unix:socket -- --columns=name find bridge '$1' | sort`], [0], [$2 ])]) # Arithmetic relational operators without keys. diff --git tests/ovsdb-server.at tests/ovsdb-server.at index ce55886..5914b4d 100644 --- tests/ovsdb-server.at +++ tests/ovsdb-server.at @@ -328,8 +328,8 @@ dnl We can't fully re-check the contents of the database log, because the dnl order of the records is not predictable, but there should only be 4 lines dnl in it now. AT_CAPTURE_FILE([db]) -AT_CHECK([wc -l < db], [0], [4 -], [], [test ! -e pid || kill `cat pid`]) +AT_CHECK([test `wc -l < db` -eq 4], [0], [], [], + [test ! -e pid || kill `cat pid`]) dnl And check that the dumped data is the same too: AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) @@ -354,8 +354,8 @@ AT_CHECK( [0], [[[{"count":3}] ]], [ignore], [test ! -e pid || kill `cat pid`]) dnl There should be 6 lines in the log now. -AT_CHECK([wc -l < db], [0], [6 -], [], [test ! -e pid || kill `cat pid`]) +AT_CHECK([test `wc -l < db` -eq 6], [0], [], [], + [test ! -e pid || kill `cat pid`]) dnl Then check that the dumped data is correct. AT_CHECK([ovsdb-client dump unix:socket ordinals], [0], [stdout], [ignore], [test ! -e pid || kill `cat pid`]) diff --git tests/ovsdb-tool.at tests/ovsdb-tool.at index d48a0c1..74552fa 100644 --- tests/ovsdb-tool.at +++ tests/ovsdb-tool.at @@ -124,8 +124,7 @@ dnl We can't fully re-check the contents of the database log, because the dnl order of the records is not predictable, but there should only be 4 lines dnl in it now. AT_CAPTURE_FILE([db]) -AT_CHECK([wc -l < db], [0], [4 -]) +AT_CHECK([test `wc -l < db` -eq 4]) dnl And check that the dumped data is the same too: AT_CHECK([[ovsdb-server --unixctl=$PWD/unixctl --remote=punix:socket --run "ovsdb-client dump unix:socket ordinals" db]], [0], [stdout], [ignore]) @@ -189,8 +188,7 @@ dnl We can't fully re-check the contents of the database log, because the dnl order of the records is not predictable, but there should only be 4 lines dnl in it now. AT_CAPTURE_FILE([db]) -AT_CHECK([wc -l < db], [0], [4 -]) +AT_CHECK([test `wc -l < db` -eq 4]) dnl And check that the dumped data is the same except for the removed column: AT_CHECK([[ovsdb-server --unixctl=$PWD/unixctl --remote=punix:socket --run "ovsdb-client dump unix:socket ordinals" db]], [0], [stdout], [ignore]) @@ -253,8 +251,7 @@ dnl We can't fully re-check the contents of the database log, because the dnl order of the records is not predictable, but there should only be 4 lines dnl in it now. AT_CAPTURE_FILE([db]) -AT_CHECK([wc -l < db], [0], [4 -]) +AT_CHECK([test `wc -l < db` -eq 4]) dnl And check that the dumped data is the same except for the added column: AT_CHECK([[ovsdb-server --unixctl=$PWD/unixctl --remote=punix:socket --run "ovsdb-client dump unix:socket ordinals" db]], [0], [stdout], [ignore]) diff --git tests/test-vconn.c tests/test-vconn.c index 42940c3..084c2c6 100644 --- tests/test-vconn.c +++ tests/test-vconn.c @@ -56,8 +56,9 @@ static void check_errno(int a, int b, const char *as, const char *file, int line) { if (a != b) { + char *str_b = strdup(strerror(abs(b))); ovs_fatal(0, "%s:%d: %s is %d (%s) but should be %d (%s)", - file, line, as, a, strerror(abs(a)), b, strerror(abs(b))); + file, line, as, a, strerror(abs(a)), b, str_b); } } @@ -138,19 +139,25 @@ static void test_refuse_connection(int argc OVS_UNUSED, char *argv[]) { const char *type = argv[1]; - int expected_error; struct fake_pvconn fpv; struct vconn *vconn; - - expected_error = (!strcmp(type, "unix") ? EPIPE - : !strcmp(type, "tcp") ? ECONNRESET - : EPROTO); + int error; fpv_create(type, &fpv); CHECK_ERRNO(vconn_open(fpv.vconn_name, OFP_VERSION, &vconn), 0); fpv_close(&fpv); vconn_run(vconn); - CHECK_ERRNO(vconn_connect(vconn), expected_error); + + error = vconn_connect_block(vconn); + if (!strcmp(type, "tcp")) { + if (error != ECONNRESET && error != EPIPE) { + ovs_fatal(0, "unexpected vconn_connect() return value %d (%s)", + error, strerror(error)); + } + } else { + CHECK_ERRNO(error, !strcmp(type, "unix") ? EPIPE : EPROTO); + } + vconn_close(vconn); fpv_destroy(&fpv); } @@ -190,6 +197,7 @@ test_read_hello(int argc OVS_UNUSED, char *argv[]) struct fake_pvconn fpv; struct vconn *vconn; struct stream *stream; + int error; fpv_create(type, &fpv); CHECK_ERRNO(vconn_open(fpv.vconn_name, OFP_VERSION, &vconn), 0); @@ -218,7 +226,11 @@ test_read_hello(int argc OVS_UNUSED, char *argv[]) poll_block(); } stream_close(stream); - CHECK_ERRNO(vconn_connect(vconn), ECONNRESET); + error = vconn_connect_block(vconn); + if (error != ECONNRESET && error != EPIPE) { + ovs_fatal(0, "unexpected vconn_connect() return value %d (%s)", + error, strerror(error)); + } vconn_close(vconn); } @@ -307,7 +319,7 @@ test_send_hello(const char *type, const void *out, size_t out_size, poll_block(); } stream_close(stream); - CHECK_ERRNO(vconn_recv(vconn, &msg), EOF); + CHECK_ERRNO(vconn_recv_block(vconn, &msg), EOF); vconn_close(vconn); } diff --git utilities/ovs-pki.in utilities/ovs-pki.in index 0255251..e63d68b 100755 --- utilities/ovs-pki.in +++ utilities/ovs-pki.in @@ -24,6 +24,38 @@ batch=no log='@LOGDIR@/ovs-pki.log' keytype=rsa bits=2048 + +# OS-specific compatibility routines +case $(uname -s) in +FreeBSD) + file_mod_epoch() + { + stat -r "$1" | awk '{print $10}' + } + + file_mod_date() + { + stat -f '%Sm' "$1" + } + + sha1sum() + { + sha1 "$@" + } + ;; +*) + file_mod_epoch() + { + date -r "$1" +%s + } + + file_mod_date() + { + date -r "$1" + } + ;; +esac + for option; do # This option-parsing mechanism borrowed from a Autoconf-generated # configure script under the following license: @@ -360,7 +392,7 @@ make_tmpdir() { fingerprint() { file=$1 name=${1-$2} - date=$(date -r $file) + date=$(file_mod_date "$file") if grep -e '-BEGIN CERTIFICATE-' "$file" > /dev/null; then fingerprint=$(openssl x509 -noout -in "$file" -fingerprint | sed 's/SHA1 Fingerprint=//' | tr -d ':') @@ -604,7 +636,7 @@ elif test "$command" = expire; then for type in switch controller; do cd "$pkidir/${type}ca/incoming" || exit 1 for file in $(glob "*"); do - time=$(date -r "$file" +%s) + time=$(file_mod_epoch "$file") if test "$time" -lt "$cutoff"; then rm -f "$file" fi diff --git xenserver/opt_xensource_libexec_interface-reconfigure xenserver/opt_xensource_libexec_interface-reconfigure index 6c6de9f..72bd5e4 100755 --- xenserver/opt_xensource_libexec_interface-reconfigure +++ xenserver/opt_xensource_libexec_interface-reconfigure @@ -1,4 +1,4 @@ -#!/usr/bin/python +#!/usr/bin/env python # # Copyright (c) 2008,2009 Citrix Systems, Inc. #