Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp3256617pxv; Sun, 25 Jul 2021 22:50:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw3+KBVFyoRax/5VyCsoNgK/DEQdOMG9M9JYuX6yYEEMlO/dmSBzW14ukfT7Oq2T58BAB+g X-Received: by 2002:a50:aa97:: with SMTP id q23mr19076915edc.154.1627278655748; Sun, 25 Jul 2021 22:50:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627278655; cv=none; d=google.com; s=arc-20160816; b=ZWKNNEwOQ3BNYpvdLMJS9wvh1Ak4Vt8ZE5wsASs+pJdH4C+FR9OKwrO/dxhTlSKm6Q jJfBm0uaklX7pZefxZ4hmnRpJCQha0U38SgPfprZxynr+xJHNofQ/dNz8h1z+HXUS7Pk 3qKvJl+FnhcSJZtdC6SQmlJrIRIQvYFynQGFVjPd4BBTiOASoGjECe4fnpXtsVzjifYn B2uI4rh0xuCbmGGfyAZ+VMTASJ3hrlsONX+iYXz4gF45kSxs9ubOOhlZYvvL39fJ0xeN 8Pzo+cBrtR05tik0Z703tDb/OyLujV84wPaizQgPgHPVPhvr4dmYawFAeRjQbslhHJPL s7bQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IjUSYUWGzcBLQG2iUil833w4Zd3GqFtQlxGn9nyit5k=; b=We0PuZKAeNcK0CF/uRA3uCAeKo3cwcn1624tshYUaime4C8NvNSWm3rkO+e62bNytQ yscxqQ+3rm8UrpzWB4gFR6QDmf3EsOmz6dPxvLUGmMAZflkasb+IhWxYQjjZEjiVsKHc 4yu47V3TjQB0Js/getwnMx0oy8A7LFMwg2BIxPtw2ttmCvefcYiOaRh/dSz1kyqHlrS+ PkXl9GAQBOXBy1wsHbXkeh4Ul49NHle1eNJlqZ4jKgWSjubOU4qoUDaoj2bRxncz+cpx E6+SKfLh+tJfd+TkauQZ8s3WR5i3FPd5RDljw/n/XmMgxv+JS3PyqMgxQ4UwvEstbyLd 27Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=S9uFWcpx; 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 j7si14066459ejm.280.2021.07.25.22.50.33; Sun, 25 Jul 2021 22:50:55 -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=S9uFWcpx; 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 S231747AbhGZFHe (ORCPT + 99 others); Mon, 26 Jul 2021 01:07:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229654AbhGZFHe (ORCPT ); Mon, 26 Jul 2021 01:07:34 -0400 Received: from mail-qv1-xf2f.google.com (mail-qv1-xf2f.google.com [IPv6:2607:f8b0:4864:20::f2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84688C061757; Sun, 25 Jul 2021 22:48:03 -0700 (PDT) Received: by mail-qv1-xf2f.google.com with SMTP id x12so1037160qvo.12; Sun, 25 Jul 2021 22:48:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=IjUSYUWGzcBLQG2iUil833w4Zd3GqFtQlxGn9nyit5k=; b=S9uFWcpxD/QrakM9dEgq7JCJjBUPkX7T1EySjVtZwLGkdUscQN63QmH6Q5zUZf6AuU WkA3XibX9Evq7Z4Bpxx0BTT46+3hFFkeip6slBVPcazG9e+JYhN9tvJ4SYBdO8Kn1B3M 6kCm7DmeCzcnnKKJw2DZ0hSmeRieTzVEX6axuqOXizgmfAbVSd5vNFWyP+GJ7PzwSJBh yigd0EK/l1Xu0SNQOpEKDTY8g7d4ESRn9WFX39wihsb6/ASbBmZyWdnXka0RDkZQjE6s T2sQctiULV4+IUSaWs9Oxgb/hJWjGRghDcrOIN0LvEpiT5vxam9C5M2hS7smSqNYvHkY 6Ntw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=IjUSYUWGzcBLQG2iUil833w4Zd3GqFtQlxGn9nyit5k=; b=PEGUeXnYcgXG96a01QvU8jHxdaTmEBn2o46iSvrUqE7z24ndFF5R13dUaea2Wa8d3b ci3B7Z4oIa3NKLSnMNpTHzzQCVMDU3DffpMe2ci31XFlbp3lWha554LAhOEQ+zfHTt0/ Zb7gKg6cd7oZic1NZ00Yjjk08beZxAOc065h7X8bbL+z0vshaslDISOzy2LJgw6a7IKO uzanxMrJ9KNS36KDZiN5MZOMyPEdL8Dk9Fgsx/Pn2NMMcvnj3vqImO4GvZBkz34tXRrB 2mqkEkkMFlnLkL6RWd8FTdZgZlicMloYdNV6QjXEK4Tca9wd+3pqX3Eh5/9v3jsPq1eJ w1jQ== X-Gm-Message-State: AOAM532rXz3cis65QqTKFfhPf7YyuzUgDiThKPv8Qp8xN3TU0cNvm6m0 JB5I0rM7RjEW9df/6Jof6Q== X-Received: by 2002:ad4:5cad:: with SMTP id q13mr16416000qvh.10.1627278482331; Sun, 25 Jul 2021 22:48:02 -0700 (PDT) Received: from localhost.localdomain (74.121.150.105.16clouds.com. [74.121.150.105]) by smtp.gmail.com with ESMTPSA id h7sm14799668qtq.79.2021.07.25.22.48.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Jul 2021 22:48:01 -0700 (PDT) From: Chen Shen To: marcelo.leitner@gmail.com Cc: vyasevich@gmail.com, nhorman@tuxdriver.com, davem@davemloft.net, linux-sctp@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Chen Shen Subject: [PATCH v2] sctp: delete addr based on sin6_scope_id Date: Mon, 26 Jul 2021 13:47:34 +0800 Message-Id: <20210726054733.75937-1-peterchenshen@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org sctp_inet6addr_event deletes 'addr' from 'local_addr_list' when setting netdev down, but it is possible to delete the incorrect entry (match the first one with the same ipaddr, but the different 'ifindex'), if there are some netdevs with the same 'local-link' ipaddr added already. It should delete the entry depending on 'sin6_addr' and 'sin6_scope_id' both. otherwise, the endpoint will call 'sctp_sf_ootb' if it can't find the according association when receives 'heartbeat', and finally will reply 'abort'. For example: 1.when linux startup the entries in local_addr_list: ifindex:35 addr:fe80::40:43ff:fe80:0 (eths0.201) ifindex:36 addr:fe80::40:43ff:fe80:0 (eths0.209) ifindex:37 addr:fe80::40:43ff:fe80:0 (eths0.210) the route table: local fe80::40:43ff:fe80:0 dev eths0.201 local fe80::40:43ff:fe80:0 dev eths0.209 local fe80::40:43ff:fe80:0 dev eths0.210 2.after 'ifconfig eths0.209 down' the entries in local_addr_list: ifindex:36 addr:fe80::40:43ff:fe80:0 (eths0.209) ifindex:37 addr:fe80::40:43ff:fe80:0 (eths0.210) the route table: local fe80::40:43ff:fe80:0 dev eths0.201 local fe80::40:43ff:fe80:0 dev eths0.210 3.asoc not found for src:[fe80::40:43ff:fe80:0]:37381 dst:[:1]:53335 ::1->fe80::40:43ff:fe80:0 HEARTBEAT fe80::40:43ff:fe80:0->::1 ABORT Signed-off-by: Chen Shen --- net/sctp/ipv6.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/net/sctp/ipv6.c b/net/sctp/ipv6.c index 52c92b8d827f..f5f54229b055 100644 --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -99,8 +99,9 @@ static int sctp_inet6addr_event(struct notifier_block *this, unsigned long ev, list_for_each_entry_safe(addr, temp, &net->sctp.local_addr_list, list) { if (addr->a.sa.sa_family == AF_INET6 && - ipv6_addr_equal(&addr->a.v6.sin6_addr, - &ifa->addr)) { + ipv6_addr_equal(&addr->a.v6.sin6_addr, + &ifa->addr) && + addr->a.v6.sin6_scope_id == ifa->idev->dev->ifindex) { sctp_addr_wq_mgmt(net, addr, SCTP_ADDR_DEL); found = 1; addr->valid = 0; -- 2.19.0