core.c: Reject join when no parent can be determined

In order to support arbitrary rather than structured SSA
distribution tree bringup, when no parent for a node can
be found (e.g. consumer node is joining and there are no nodes
with access), the join is rejected (status SSA_STATUS_REQ_DENIED).
This rejection forms the basis for the client to rerequest the
join at a later time (after which a suitable parent may be present).

In order to do this, find_best_parent was needed to be moved
out of core_build_tree. This required core_build_tree to take
an additional parameter (union ibv *parentgid).

Note that clients currently ignore join status.

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Add error log message when ssa_add_access_consumer fails

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: In ssa_upstream_mad, determine whether join succeeded

When joining, MAD status indicates whether join succeeded (set parent
to follow) or whether it was rejected (no parent available). In
latter case, join request needs to be retried. That part is not
currently implemented.

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Fix SSA_PR_SUCCESS handling in ssa_calculate_prdb

This has been broken since the signature for ssa_pr_compute_half_world
was changed. It results in successful PRDB calculation logging
a failure message and improper dumping depending on the option settings.
The above is not critical to proper operation but is confusing
to someone (like me) reading and debugging via the log.

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: In ssa_access_handler, access_context.smdb NULL is not an error

on receipt of SSA_CONN_DONE message

It is possible that the upstream is not connected or the SMDB has not
yet been received when the downstream connection occurs. So this is
"normal" and not an error.

In this case of access_context.smdb NULL, the access consumer needs
to be added to the core member map so that later when the SMDB DB
update occurs (after the SMDB SSA DB is received on the upstream
connection), the PRDB will be recalculated as well as the updated
epoch being riowritten into the consumer/ACM causing it to pull
it's updated PRDB.

This was tested by inserting immediate rejoin (ssa_svc_join(svc))
in ssa_upstream_mad when status is rejected. This was a temporary
hack for testing. The real mechanism of implementing a timed retry
with exponential backoff up to some max needs to be implemented.

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Cosmetic formatting changes in ssa_calculate_prdb

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Refactor code for handling NULL access_context.smdb in ssa_access_handler

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
acm.c: In acm_issue_query, delay until joined (and upstream connected)

so can handle case where no parent is yet available due to no
nodes capable of access support being started

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Make returned events consistent on several error code paths

In various error paths when rsend'ing or riowrite'ing, returned
events was 0 which would stop SSA connection dead in it's tracks.

Found during code inspection but not tested currently as
there is no easy way to exercise these code paths.

Signed-off-by: Hal Rosenstock <hal@mellanox.com>