• Paolo Abeni's avatar
    mptcp: refactor shutdown and close · e16163b6
    Paolo Abeni authored
    We must not close the subflows before all the MPTCP level
    data, comprising the DATA_FIN has been acked at the MPTCP
    level, otherwise we could be unable to retransmit as needed.
    
    __mptcp_wr_shutdown() shutdown is responsible to check for the
    correct status and close all subflows. Is called by the output
    path after spooling any data and at shutdown/close time.
    
    In a similar way, __mptcp_destroy_sock() is responsible to clean-up
    the MPTCP level status, and is called when the msk transition
    to TCP_CLOSE.
    
    The protocol level close() does not force anymore the TCP_CLOSE
    status, but orphan the msk socket and all the subflows.
    Orphaned msk sockets are forciby closed after a timeout or
    when all MPTCP-level data is acked.
    
    There is a caveat about keeping the orphaned subflows around:
    the TCP stack can asynchronusly call tcp_cleanup_ulp() on them via
    tcp_close(). To prevent accessing freed memory on later MPTCP
    level operations, the msk acquires a reference to each subflow
    socket and prevent subflow_ulp_release() from releasing the
    subflow context before __mptcp_destroy_sock().
    
    The additional subflow references are released by __mptcp_done()
    and the async ULP release is detected checking ULP ops. If such
    field has been already cleared by the ULP release path, the
    dangling context is freed directly by __mptcp_done().
    Co-developed-by: default avatarDavide Caratti <dcaratti@redhat.com>
    Signed-off-by: default avatarDavide Caratti <dcaratti@redhat.com>
    Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
    Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
    e16163b6
protocol.h 16.8 KB