Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1441953ybs; Mon, 25 May 2020 16:33:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsGkn3RfCG9nW+n47JHar+i/SHA1tSlFDXfGCLRM7stlVAQM2Lr3Db+DMY3zvSbdQW2w1S X-Received: by 2002:a17:906:a0c2:: with SMTP id bh2mr20316900ejb.406.1590449602467; Mon, 25 May 2020 16:33:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590449602; cv=none; d=google.com; s=arc-20160816; b=rbZhjD193omz7Fqzr0O3h9b306pCNTC0KmjP0SsoQ1m8HL4TIKSoMmEB5PhhuW3Xty O4Wp9DrLhE8cLkF4YeaP7ZbR20qPGLuMxCNHmQog4SkOJJRMV/gPd9G5+n6/xJjIFd5g mWjGTFVItQe17FbfUNyaIS8Mm4N4pzue6wZ42/7PgNjb0SjtPOIYFEgPG5GcgnLRa/hR Zm06p2S+6yUKCdCEyFPHjTelPFYh06w7xJH5nDA0rKzA2f4lZihpQI/cC6ysITF1OPoE UncZgUzXYbCbx+BRmvyAO+z1uIrzGRs6acUClfciQWSc0h5Qy4eSrlqgi5VHVG/S61fu nPgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=MLeVvYrTYMYJfLw2SqD/fO7uDAqzrwrJACplTDu/IZ0=; b=O5tMJOdETY2hA9Nh5N9/8dWuYJytZGIaAYb4yQy00AIKANQQlrCQP0LzBSkaFoRiMt 4F+36ulzskqAXM0AfkPM5kjsl8Yt9pbrX4PJxZH+0FBZJiTQzE+QvJFWLdYdIOkI9aGh oYXEaeEfqQ4IXQnjScQ4vWBLLwriOaREg+8n+rrtIvRT0wrl97R3zINmkzTgIRfOhHaE DrHrUshP5NbnR+rVhvrWq6OF89890XsDo9wBQkdY/j0oc5R3hbnYYrk+QC4waao6zEJu cjowzVbhbKW+WpkBWZsn8qvQCxd94+Kz2idU3L49ZFlXcidmnl6fDsVqix71XXfF0467 JN9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m9RFvrfd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id si17si10581945ejb.288.2020.05.25.16.32.59; Mon, 25 May 2020 16:33:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m9RFvrfd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390724AbgEYUwF (ORCPT + 99 others); Mon, 25 May 2020 16:52:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388714AbgEYUwF (ORCPT ); Mon, 25 May 2020 16:52:05 -0400 Received: from mail-qv1-xf43.google.com (mail-qv1-xf43.google.com [IPv6:2607:f8b0:4864:20::f43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D27A0C061A0E; Mon, 25 May 2020 13:52:04 -0700 (PDT) Received: by mail-qv1-xf43.google.com with SMTP id z5so8552947qvw.4; Mon, 25 May 2020 13:52:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=MLeVvYrTYMYJfLw2SqD/fO7uDAqzrwrJACplTDu/IZ0=; b=m9RFvrfdNTkbbjfzQYISDexRTtf6OaOV3pQqX+BGncXEnPlSh01lH9Ch/bWzMRNmJo FyhZGrsVzahSOQsjZe9RYoZGCmz0dgEvokil7mD0sitItZx4QkQYnGL+LYEOtHUkIYtG PdugN0/KzUTk5/QCTD9yc1Q5VCPI1+4urVlSNyV2MNyx0iT03fBe8saVLvxogd4Yejdt KUTun20Baq4QW/z2NG39++7uTzy4Si4yrVZ4v5oUEsj7wfpsKRHPwoMtI90oB9BzRY8A JNehw9m2lggBKzQG/ejWx2yWiB33FQIuSc5yhg6+kGjHhTGoV+zprLFM12inIURUTG8I btsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=MLeVvYrTYMYJfLw2SqD/fO7uDAqzrwrJACplTDu/IZ0=; b=mAf1J1kHBux8vXF2mDeRi8SdzyEi7o0ng+b4aXAMthsyrF2Zmj/ZdPBoCKPVPlvwRh UwVlCEKlos9aZTbx2qbrFszIPI+pbs3HnySo9ZypsSOLz5IXA4x7yHV5rXsEe29H6/Ra 8drbyAaU5v78aFaboKVAJFT1tlmtPPslPUFpDK5qBviYYioze6KryOlf0mBDmlIG+um4 9/ayR0G9N3nGivodfdKXxhhArRPb38ajKOV9kMjpTwzevKj6cXwzk9ZREVqcpf+jMz8t qgY82L3JaM6O58l56BpAQlgxpR8PK8MFLEziDgZH7ZKAKL858iUYED/NQxsRfB6fShWm XRRA== X-Gm-Message-State: AOAM532pwiWFq1zFEipJcqOyEqicY8BW8DnUoUyWt3QEd/1TfkWbrbBB AlVzpaXeWXICTioApBBeVVI= X-Received: by 2002:a05:6214:1594:: with SMTP id m20mr17497026qvw.110.1590439923896; Mon, 25 May 2020 13:52:03 -0700 (PDT) Received: from localhost.localdomain ([2001:1284:f013:8992:a39b:b6ab:3df8:5b60]) by smtp.gmail.com with ESMTPSA id o23sm3898134qko.124.2020.05.25.13.52.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 May 2020 13:52:03 -0700 (PDT) Received: by localhost.localdomain (Postfix, from userid 1000) id BB1C4C1B76; Mon, 25 May 2020 17:52:00 -0300 (-03) Date: Mon, 25 May 2020 17:52:00 -0300 From: Marcelo Ricardo Leitner To: Jonas Falkevik Cc: Xin Long , Vlad Yasevich , Neil Horman , "David S. Miller" , Jakub Kicinski , linux-sctp@vger.kernel.org, network dev , LKML Subject: Re: [PATCH] sctp: check assoc before SCTP_ADDR_{MADE_PRIM,ADDED} event Message-ID: <20200525205200.GB2491@localhost.localdomain> References: <20200513160116.GA2491@localhost.localdomain> <20200513213230.GE2491@localhost.localdomain> <20200519204229.GQ2491@localhost.localdomain> <20200525131036.GA2491@localhost.localdomain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 25, 2020 at 10:49:06PM +0200, Jonas Falkevik wrote: > On Mon, May 25, 2020 at 6:10 PM Xin Long wrote: > > > > On Mon, May 25, 2020 at 9:10 PM Marcelo Ricardo Leitner > > wrote: > > > > > > On Mon, May 25, 2020 at 04:42:16PM +0800, Xin Long wrote: > > > > On Sat, May 23, 2020 at 8:04 PM Jonas Falkevik wrote: > > > > > > > > > > On Tue, May 19, 2020 at 10:42 PM Marcelo Ricardo Leitner > > > > > wrote: > > > > > > > > > > > > On Fri, May 15, 2020 at 10:30:29AM +0200, Jonas Falkevik wrote: > > > > > > > On Wed, May 13, 2020 at 11:32 PM Marcelo Ricardo Leitner > > > > > > > wrote: > > > > > > > > > > > > > > > > On Wed, May 13, 2020 at 10:11:05PM +0200, Jonas Falkevik wrote: > > > > > > > > > On Wed, May 13, 2020 at 6:01 PM Marcelo Ricardo Leitner > > > > > > > > > wrote: > > > > > > > > > > > > > > > > > > > > On Wed, May 13, 2020 at 04:52:16PM +0200, Jonas Falkevik wrote: > > > > > > > > > > > Do not generate SCTP_ADDR_{MADE_PRIM,ADDED} events for SCTP_FUTURE_ASSOC assocs. > > > > > > > > > > > > > > > > > > > > How did you get them? > > > > > > > > > > > > > > > > > > > > > > > > > > > > I think one case is when receiving INIT chunk in sctp_sf_do_5_1B_init(). > > > > > > > > > Here a closed association is created, sctp_make_temp_assoc(). > > > > > > > > > Which is later used when calling sctp_process_init(). > > > > > > > > > In sctp_process_init() one of the first things are to call > > > > > > > > > sctp_assoc_add_peer() > > > > > > > > > on the closed / temp assoc. > > > > > > > > > > > > > > > > > > sctp_assoc_add_peer() are generating the SCTP_ADDR_ADDED event on the socket > > > > > > > > > for the potentially new association. > > > > > > > > > > > > > > > > I see, thanks. The SCTP_FUTURE_ASSOC means something different. It is > > > > > > > > for setting/getting socket options that will be used for new asocs. In > > > > > > > > this case, it is just a coincidence that asoc_id is not set (but > > > > > > > > initialized to 0) and SCTP_FUTURE_ASSOC is also 0. > > > > > > > > > > > > > > yes, you are right, I overlooked that. > > > > > > > > > > > > > > > Moreso, if I didn't > > > > > > > > miss anything, it would block valid events, such as those from > > > > > > > > sctp_sf_do_5_1D_ce > > > > > > > > sctp_process_init > > > > > > > > because sctp_process_init will only call sctp_assoc_set_id() by its > > > > > > > > end. > > > > > > > > > > > > > > Do we want these events at this stage? > > > > > > > Since the association is a newly established one, have the peer address changed? > > > > > > > Should we enqueue these messages with sm commands instead? > > > > > > > And drop them if we don't have state SCTP_STATE_ESTABLISHED? > > > > > > > > > > > > > > > > > > > > > > > I can't see a good reason for generating any event on temp assocs. So > > > > > > > > I'm thinking the checks on this patch should be on whether the asoc is > > > > > > > > a temporary one instead. WDYT? > > > > > > > > > > > > > > > > > > > > > > Agree, we shouldn't rely on coincidence. > > > > > > > Either check temp instead or the above mentioned state? > > > > > > > > > > > > > > > Then, considering the socket is locked, both code points should be > > > > > > > > allocating the IDR earlier. It's expensive, yes (point being, it could > > > > > > > > be avoided in case of other failures), but it should be generating > > > > > > > > events with the right assoc id. Are you interested in pursuing this > > > > > > > > fix as well? > > > > > > > > > > > > > > Sure. > > > > > > > > > > > > > > If we check temp status instead, we would need to allocate IDR earlier, > > > > > > > as you mention. So that we send the notification with correct assoc id. > > > > > > > > > > > > > > But shouldn't the SCTP_COMM_UP, for a newly established association, be the > > > > > > > first notification event sent? > > > > > > > The SCTP_COMM_UP notification is enqueued later in sctp_sf_do_5_1D_ce(). > > > > > > > > > > > > The RFC doesn't mention any specific ordering for them, but it would > > > > > > make sense. Reading the FreeBSD code now (which I consider a reference > > > > > > implementation), it doesn't raise these notifications from > > > > > > INIT_ACK/COOKIE_ECHO at all. The only trigger for SCTP_ADDR_ADDED > > > > > > event is ASCONF ADD command itself. So these are extra in Linux, and > > > > > > I'm afraid we got to stick with them. > > > > > > > > > > > > Considering the error handling it already has, looks like the > > > > > > reordering is feasible and welcomed. I'm thinking the temp check and > > > > > > reordering is the best way forward here. > > > > > > > > > > > > Thoughts? Neil? Xin? The assoc_id change might be considered an UAPI > > > > > > breakage. > > > > > > > > > > Some order is mentioned in RFC 6458 Chapter 6.1.1. > > > > > > > > > > SCTP_COMM_UP: A new association is now ready, and data may be > > > > > exchanged with this peer. When an association has been > > > > > established successfully, this notification should be the > > > > > first one. > > > > > > Oh, nice finding. > > > > > > > If this is true, as SCTP_COMM_UP event is always followed by state changed > > > > to ESTABLISHED. So I'm thinking to NOT make addr events by checking the > > > > state: > > > > > > > > @@ -343,6 +343,9 @@ void sctp_ulpevent_nofity_peer_addr_change(struct > > > > sctp_transport *transport, > > > > struct sockaddr_storage addr; > > > > struct sctp_ulpevent *event; > > > > > > > > + if (asoc->state < SCTP_STATE_ESTABLISHED) > > > > + return; > > > > + > > > > memset(&addr, 0, sizeof(struct sockaddr_storage)); > > > > memcpy(&addr, &transport->ipaddr, transport->af_specific->sockaddr_len); > > > > > > With the above said, yep. Thanks. > > > > > > > > > > > It's not easy to completely do assoc_id change/event reordering/temp check. > > > > As: > > > > > > Temp check should be fine, but agree re the others. Anyhow, the above > > > will be good already. :-) > > Hi Jonas, > > > > What do you think? If you agree, can you please continue to go with it > > after testing? > > > > Thanks. > > > I agree, it looks good. Looks like it will produce results similar to > the initial change. > Will test and verify as well. > Then should I submit v2 of the patch? Yes, > > While at it, I have a patch renaming nofity to notify in the function > sctp_ulpevent_nofity_peer_addr_change. > Did I misunderstand the name or is it a typo? Worth submitting as well? Oops! Yes :-) (as a different patch) Thanks, Marcelo