• Matthieu Baerts (NGI0)'s avatar
    mptcp: avoid duplicated SUB_CLOSED events · d82809b6
    Matthieu Baerts (NGI0) authored
    The initial subflow might have already been closed, but still in the
    connection list. When the worker is instructed to close the subflows
    that have been marked as closed, it might then try to close the initial
    subflow again.
    
     A consequence of that is that the SUB_CLOSED event can be seen twice:
    
      # ip mptcp endpoint
      1.1.1.1 id 1 subflow dev eth0
      2.2.2.2 id 2 subflow dev eth1
    
      # ip mptcp monitor &
      [         CREATED] remid=0 locid=0 saddr4=1.1.1.1 daddr4=9.9.9.9
      [     ESTABLISHED] remid=0 locid=0 saddr4=1.1.1.1 daddr4=9.9.9.9
      [  SF_ESTABLISHED] remid=0 locid=2 saddr4=2.2.2.2 daddr4=9.9.9.9
    
      # ip mptcp endpoint delete id 1
      [       SF_CLOSED] remid=0 locid=0 saddr4=1.1.1.1 daddr4=9.9.9.9
      [       SF_CLOSED] remid=0 locid=0 saddr4=1.1.1.1 daddr4=9.9.9.9
    
    The first one is coming from mptcp_pm_nl_rm_subflow_received(), and the
    second one from __mptcp_close_subflow().
    
    To avoid doing the post-closed processing twice, the subflow is now
    marked as closed the first time.
    
    Note that it is not enough to check if we are dealing with the first
    subflow and check its sk_state: the subflow might have been reset or
    closed before calling mptcp_close_ssk().
    
    Fixes: b911c97c ("mptcp: add netlink event support")
    Cc: stable@vger.kernel.org
    Tested-by: default avatarArınç ÜNAL <arinc.unal@arinc9.com>
    Reviewed-by: default avatarMat Martineau <martineau@kernel.org>
    Signed-off-by: default avatarMatthieu Baerts (NGI0) <matttbe@kernel.org>
    Signed-off-by: default avatarPaolo Abeni <pabeni@redhat.com>
    d82809b6
protocol.c 107 KB