tests: Avoid race conditions, by letting the kernel choose ports to bind.
An occasionally occurring problem with "make check", especially when
parallel tests are enabled, is that multiple tests try to bind the same
TCP port and, of course, fail. This happens because the code to select
a TCP port to bind just generates random numbers until it finds a port that
is not currently in use and uses the first one, which is of course prone
to races.
This commit changes the tests to let the kernel directly choose an
available port, which should avoid this type of failure.
Also, some of the tests that generated a random free TCP port actually
used the port number to bind a UDP socket, which of course doesn't work
well. This commit fixes that problem too as a side effect.
Signed-off-by: Ben Pfaff <blp@nicira.com>