tipc: fix two bugs in secondary destination lookup
authorJon Paul Maloy <jon.maloy@ericsson.com>
Fri, 27 Mar 2015 14:19:19 +0000 (10:19 -0400)
committerDavid S. Miller <davem@davemloft.net>
Sun, 29 Mar 2015 20:47:36 +0000 (13:47 -0700)
commitd482994fca82380912b3a80201b74d5118ff0487
tree42831f6ce50ea0c79fe958d71d9ec5fd02b51121
parent4d92a3e9b90e23eaf7d893d1841cd0391403b99a
tipc: fix two bugs in secondary destination lookup

A message sent to a node after a successful name table lookup may still
find that the destination socket has disappeared, because distribution
of name table updates is non-atomic. If so, the message will be rejected
back to the sender with error code TIPC_ERR_NO_PORT. If the source
socket of the message has disappeared in the meantime, the message
should be dropped.

However, in the currrent code, the message will instead be subject to an
unwanted tertiary lookup, because the function tipc_msg_lookup_dest()
doesn't check if there is an error code present in the message before
performing the lookup. In the worst case, the message may now find the
old destination again, and be redirected once more, instead of being
dropped directly as it should be.

A second bug in this function is that the "prev_node" field in the message
is not updated after successful lookup, something that may have
unpredictable consequences.

The problems arising from those bugs occur very infrequently.

The third change in this function; the test on msg_reroute_msg_cnt() is
purely cosmetic, reflecting that the returned value never can be negative.

This commit corrects the two bugs described above.

Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/addr.c
net/tipc/addr.h
net/tipc/msg.c