socket-util: Log kernel-chosen bound ports in inet_open_passive().
authorBen Pfaff <blp@nicira.com>
Wed, 3 Apr 2013 18:24:27 +0000 (13:24 -0500)
committerBen Pfaff <blp@nicira.com>
Thu, 18 Apr 2013 23:43:15 +0000 (16:43 -0700)
commitdf451457ad9a02bcd9793126b66be445f4d5a8a7
tree00635533a8b9bddf24894857e23c6642e113edcd
parent977529e4ac7b5a5e99cc6d080347f84eb5291720
socket-util: Log kernel-chosen bound ports in inet_open_passive().

Usually, for passive sockets, one wishes to bind a particular well-known
port, so that clients can easily connect.  But automated tests cannot
necessarily bind a well-known port, because that would cause multiple
concurrent tests to interfere with each other or with a real instance of
the service running on the system.  They could bind to a randomly selected
port chosen by the user (the Open vSwitch automated tests currently do this)
but this leads to occasional "false negative" test failures when the port
selected happens to be in use.

The best alternative for automated tests is to let the kernel choose a
port that is not otherwise in use, which can be accomplished by specifying
port 0.  But in that case there is no easy way for other software to know
what port the kernel chose.  This commit fixes that problem one way by
logging the bound port when it is chosen by the kernel.

Signed-off-by: Ben Pfaff <blp@nicira.com>
lib/socket-util.c