ssa.c: A couple of cosmetic commentary changes

Also, a couple of cosmetic formatting changes to add a blank line

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Only SSA Set method is unsolicited currently in ssa_open_port

Removed unneeded unsolicited methods from being registered with umad

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Indicate ssa_open_port failures and handle such failures in ssa_open_dev

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Add SMDB epoch to some log messages in ssa_calculate_prdb

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa_signal_handler.c: Return an error if add2line can't find a function name

run_add2line function skips garbage from add2line utility.
For a skipped frame, it didn't print a line into backtrace, but
returned success. As result, the frame disappeared from the trace.

Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa_signal_handler.c: Add frame number to back trace line

In case of add2line utility failure, a frame number in
backtrace line was absent.

Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa_signal_handler.c: Remove ssa_signal_handler before calling abort()

abort will send SIGABRT. It may cause a race in ssa_signal_handler.
In any case, an application is going to exit. We don't need to handle
SIGABRT sent from abort(); leave it to default signal handler
to do its job.

Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
configure: Check for pstack utility in configure

Some Linux distro include pstack utility instead of gstack.
pstack and gstack have the same command line interface and
are developed by the same author.

See: http://linuxcommand.org/man_pages/pstack1.html
     http://linux.die.net/man/1/pstack

Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa_signal_handler.c: Print signal number to log

Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Pass ssa_access_member instead of gid into ssa_calculate_prdb

Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Log last used SMDB epoch in case ACM (consumer) not found

Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
.gitignore: Ignore patches generated by git format-patch

Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Resolve rsocket id race between access and downstream threads

SSA_DB_UPDATE message sent from access to downstream includes
rsocket id. The id is a key in fd_to_conn lookup table.
Using the id downstream obtains pointer to connection structure.

A client may disconnect from AL while SSA_DB_UPDATE message with its
socket number is waiting in the socket or in db_update queue.
Other client may connect to the AL and recieve the same rsocket id.
In this case, downstream may obtain wrong connection.

GID checking avoids using wrong connection. GID is unique for
a client and can't be changed.

Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: In downstream handler, optimize rsock search when DB update msg received from access

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Move comment in ssa_downstream_handler

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Minor code refactoring in ssa_downstream_handler

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Cosmetic change to remove trailing whitespace

Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: In ssa_downstream_close_ssa_conn, make sure connection parameter is valid

and not already closed (NULL)

Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: Close rsocket if ACM reconnects without disconnect

In case of port bouncing, ACM could reconnect to AL within
keepalive time interval. As result, AL could hold two connections
to the same ACM.

This patch removes the keepalive disabled check from
the code in ssa_check_listen_events which checked
for duplicated rsocket ID/number.

Original commit for that code segment:
commit d202bb6a685ef568f94ac37b02adbd3d3a8eb96f
Author: Sasha Kotchubievsky <sashakot@mellanox.com>
Date:   Thu Jul 31 14:40:33 2014 +0300

    ssa.c: Close old connection after fast client reconnection

    Only close connection if keepalive disabled (0).
    Otherwise, close stalls downstream thread (~33 seconds
    using default parameters).

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

Note that when duplicated connection is detected, underlying rclose
can stall downstream thread. Solution is to move the actual rclose
into a separate thread (and handle any errors appropriately in
rsocket calls in downstream thread if they could occur).

Signed-off-by: Sasha Kotchubievsky <sashakot@mellanox.com>
Signed-off-by: Hal Rosenstock <hal@mellanox.com>
ssa.c: In ssa_stop_access, handle NULL SMDB reference object

If ibssa application couldn't open ib devices and exits,
smdb pointer is NULL. This can cause crash.

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