[ovs-dev] [PATCH 4/8] ovsdb-idl.at: Better choosing of wrong ports.

Ilya Maximets i.maximets at samsung.com
Wed Dec 26 15:23:57 UTC 2018


On some systems (ex. FreeBSD) kernel could allocate outcoming tcp ports
too close to the listening port of ovsdb-server. This could lead to having
outcoming tcp port of test-ovsdb application equal to one of the
WRONG_PORTs. In this case self-connection to the WRONG_PORT succeeds and
fails the tests:

  WRONG_PORT_1=51835
  WRONG_PORT_2=51836
  remotes="tcp:127.0.0.1:51835,tcp:127.0.0.1:51834,tcp:127.0.0.1:51836"
  # lsof -P -n -i @127.0.0.1
  COMMAND     PID TYPE  NODE NAME
  ovsdb-ser 82174 IPv4   TCP 127.0.0.1:51834 (LISTEN)
  python2.7 82179 IPv4   TCP 127.0.0.1:51835->127.0.0.1:51835 (ESTABLISHED)
  python2.7 82179 IPv4   TCP 127.0.0.1:51836->127.0.0.1:51836 (ESTABLISHED)

  ./ovsdb-idl.at:312: $PYTHON $srcdir/test-ovsdb.py  -t10 idl \
                                   $srcdir/idltest.ovsschema $remote
  Alarm clock
  ./ovsdb-idl.at:312: exit code was 1, expected 0

It's more likely to have outcoming port not equal to TCP_PORT + 101 or 102.
Let's use them instead.

Signed-off-by: Ilya Maximets <i.maximets at samsung.com>
---
 tests/ovsdb-idl.at | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/tests/ovsdb-idl.at b/tests/ovsdb-idl.at
index b5f2ce942..4aba7a3a7 100644
--- a/tests/ovsdb-idl.at
+++ b/tests/ovsdb-idl.at
@@ -148,8 +148,8 @@ m4_define([OVSDB_CHECK_IDL_TCP_MULTIPLE_REMOTES_PYN],
    AT_KEYWORDS([ovsdb server idl positive Python with tcp socket $5])
    AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
    PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
-   WRONG_PORT_1=$((TCP_PORT + 1))
-   WRONG_PORT_2=$((TCP_PORT + 2))
+   WRONG_PORT_1=$((TCP_PORT + 101))
+   WRONG_PORT_2=$((TCP_PORT + 102))
    remote=tcp:127.0.0.1:$WRONG_PORT_1,tcp:127.0.0.1:$TCP_PORT,tcp:127.0.0.1:$WRONG_PORT_2
    m4_if([$2], [], [],
      [AT_CHECK([ovsdb-client transact tcp:127.0.0.1:$TCP_PORT $2], [0], [ignore], [ignore])])
@@ -200,8 +200,8 @@ m4_define([OVSDB_CHECK_IDL_TCP6_MULTIPLE_REMOTES_PYN],
    AT_KEYWORDS([ovsdb server idl positive Python with tcp6 socket $5])
    AT_CHECK([ovsdb_start_idltest "ptcp:0:[[::1]]"])
    PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
-   WRONG_PORT_1=$((TCP_PORT + 1))
-   WRONG_PORT_2=$((TCP_PORT + 2))
+   WRONG_PORT_1=$((TCP_PORT + 101))
+   WRONG_PORT_2=$((TCP_PORT + 102))
    remote="tcp:[[::1]]:$WRONG_PORT_1,tcp:[[::1]]:$TCP_PORT,tcp:[[::1]]:$WRONG_PORT_2"
    m4_if([$2], [], [],
      [AT_CHECK([ovsdb-client transact "tcp:[[::1]]:$TCP_PORT" $2], [0], [ignore], [ignore])])
@@ -1828,7 +1828,7 @@ m4_define([CHECK_STREAM_OPEN_BLOCK],
    AT_KEYWORDS([Check Stream open block $1])
    AT_CHECK([ovsdb_start_idltest "ptcp:0:$2"])
    PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
-   WRONG_PORT=$(($TCP_PORT+1))
+   WRONG_PORT=$(($TCP_PORT + 101))
    AT_CHECK([test-stream tcp:$2:$TCP_PORT], [0], [ignore])
    AT_CHECK([test-stream tcp:$2:$WRONG_PORT], [1], [ignore], [ignore])
    OVSDB_SERVER_SHUTDOWN
@@ -1844,7 +1844,7 @@ m4_define([CHECK_STREAM_OPEN_BLOCK_PY],
    AT_KEYWORDS([Check PY Stream open block - $3])
    AT_CHECK([ovsdb_start_idltest "ptcp:0:127.0.0.1"])
    PARSE_LISTENING_PORT([ovsdb-server.log], [TCP_PORT])
-   WRONG_PORT=$(($TCP_PORT+1))
+   WRONG_PORT=$(($TCP_PORT + 101))
    AT_CHECK([$3 $srcdir/test-stream.py tcp:127.0.0.1:$TCP_PORT], [0], [ignore])
    AT_CHECK([$3 $srcdir/test-stream.py tcp:127.0.0.1:$WRONG_PORT], [1], [ignore])
    OVSDB_SERVER_SHUTDOWN
-- 
2.17.1



More information about the dev mailing list