tipc: fix link overflow issue at socket shutdown
authorTuong Lien <tuong.t.lien@dektech.com.au>
Wed, 8 Jan 2020 02:18:15 +0000 (09:18 +0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 8 Jan 2020 23:57:07 +0000 (15:57 -0800)
commit49afb806cb650dd1f06f191994f3aa657d264009
tree2e27c5f283e31f268f93feeb10641fdc2f26ced3
parentb73a65610b7decff6415d24940722e8aa09195cf
tipc: fix link overflow issue at socket shutdown

When a socket is suddenly shutdown or released, it will reject all the
unreceived messages in its receive queue. This applies to a connected
socket too, whereas there is only one 'FIN' message required to be sent
back to its peer in this case.

In case there are many messages in the queue and/or some connections
with such messages are shutdown at the same time, the link layer will
easily get overflowed at the 'TIPC_SYSTEM_IMPORTANCE' backlog level
because of the message rejections. As a result, the link will be taken
down. Moreover, immediately when the link is re-established, the socket
layer can continue to reject the messages and the same issue happens...

The commit refactors the '__tipc_shutdown()' function to only send one
'FIN' in the situation mentioned above. For the connectionless case, it
is unavoidable but usually there is no rejections for such socket
messages because they are 'dest-droppable' by default.

In addition, the new code makes the other socket states clear
(e.g.'TIPC_LISTEN') and treats as a separate case to avoid misbehaving.

Acked-by: Ying Xue <ying.xue@windriver.com>
Acked-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: Tuong Lien <tuong.t.lien@dektech.com.au>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/socket.c