net: keep SYN cache entry if expansion failed

Fixes #283.

When backlog is full upon receiving ACK, keep the entry in SYN
cache. The client will eventually retransmit unacknowledged data and
the connection state promotion will be retried at later time. Dropping
of SYN cache entries was causing connection resets on the client side.

The entry will be dropped when either of these occurs:
 * The connection is successfully ACK'ed
 * Invalid packet is received for that connection
 * SYN+ACK retransmission limit is exceeded
 * SYN cache hashmap bucket fills up - oldest entry is removed.

We could also implement yet another protection mechanism, as a next
step. We could drop SYN requests when we know the backlog is full, but
this patch makes the biggest difference. SYN-dropping might be needed
to avoid resets when the number of sudden connections is so large that
SYN cache buckets fill up. Assuming connection hashing is good, that's
quite a lot of connections - the hash map has 512 entries with buckets
of up to 30 elements.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
core: add 'latch' synchronizer

The synchronizer allows any thread to block on it until it is
unlocked. It is unlocked once count_down() has been called given
number of times.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
tests: add test exploiting client RST problem

The test fails when the problem described in issue #283 exists.

Signed-off-by: Tomasz Grabiec <tgrabiec@cloudius-systems.com>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>