Received: by 2002:a25:d783:0:0:0:0:0 with SMTP id o125csp658849ybg; Thu, 19 Mar 2020 06:33:01 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvsaDhdXSovnXEyR5GImlqXctrJ39VLlgKWujvepCSqbd5HywNtTsQZSnZX5WkYmV1Bqgil X-Received: by 2002:a05:6830:403d:: with SMTP id i29mr2143154ots.353.1584624781104; Thu, 19 Mar 2020 06:33:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584624781; cv=none; d=google.com; s=arc-20160816; b=q5NOxwc/Fijr5t8qeVgWAuJ6ZbN4vq4fyhe3ScgKq365cgcW2DaBPb+otZHJ1TouV0 8yizpCAaiCJdcYchMf6Mgpn3avxfQt4C3Dg/rTa+o48u6PswOpSpiTckeHTDJPgiiX38 ssmYQUwaeQx+jFxLtnGCj8urLfpC+kL+Q+WYGBNXoTzPlmuJKdf1psqyL2Q1SFDrJdcw lKZhs7WKK5gBBf+GWw/FRia0UCxz/Jvr8YyWJ95dau8JBW6XIfxi4DQ3H4eiWuojf0oj pfpIu0KXfXTu58x72+ScDpgmEAtqDeeeK7x4dnaFtmB9D6TSCiTJSkyHih5/j8gOWjL4 oNHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Djp8f90Ei8n/2drjqHrEWIcDn/+v/Y0q6zsH6u+87h8=; b=pkCUTtmIMKgeCNR2cTeZGTVo9DFsOo6lZTYxA4f4yibzhVUl8z0A2m7m9Zpbfa3o1p dnzNiA0K6RWfxMclYSqNGMCBJSIIOM7fqZVyPtMfZajU1JcsVCp85FRm8SZZGiREqHe0 nD1To/w1yHubgxw6ylMEDirkXXWKOv4/+b/2Gc2ET53bLkZZx4xzGaqw7GVwOsbxB0/7 VMvPQJomG2iUTqOyyrTaWQBfRfTuyik+VG8EpsoZs3UtH14Gw2zDoCBu217U7l628kyl lFjPVfT+2LYRJWQAiLVdcHp5tuwsacJPArJ6CF7oYXfElhvnVswY9cbjuTmpq1qFFhsM VTFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hKIDIcAq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j11si1157015ota.85.2020.03.19.06.32.48; Thu, 19 Mar 2020 06:33:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hKIDIcAq; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729437AbgCSNPm (ORCPT + 99 others); Thu, 19 Mar 2020 09:15:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:35544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729430AbgCSNPj (ORCPT ); Thu, 19 Mar 2020 09:15:39 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8466F20787; Thu, 19 Mar 2020 13:15:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1584623738; bh=AkPlYqCA7S2+lqhUQkKt7MYM0xyiKSGyeIxF4h7I9vU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hKIDIcAqQAjuUPThgmhNwPpM8zYjuQuAajCLE004LkrEHTVQPeHN/Lap7z4+qdW8c 2JBLVXhV+xChKLrh4iDVW2alDMNmx1USZcHRFrDj0+vZ59q3QVMpwxDsw2c7jH8zIz nshSvjeIWRPd6rlamgG6SyYcJCAo79doy/cKuJYM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , Hangbin Liu , "David S. Miller" Subject: [PATCH 4.14 05/99] ipv6/addrconf: call ipv6_mc_up() for non-Ethernet interface Date: Thu, 19 Mar 2020 14:02:43 +0100 Message-Id: <20200319123943.155391079@linuxfoundation.org> X-Mailer: git-send-email 2.25.2 In-Reply-To: <20200319123941.630731708@linuxfoundation.org> References: <20200319123941.630731708@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hangbin Liu [ Upstream commit 60380488e4e0b95e9e82aa68aa9705baa86de84c ] Rafał found an issue that for non-Ethernet interface, if we down and up frequently, the memory will be consumed slowly. The reason is we add allnodes/allrouters addressed in multicast list in ipv6_add_dev(). When link down, we call ipv6_mc_down(), store all multicast addresses via mld_add_delrec(). But when link up, we don't call ipv6_mc_up() for non-Ethernet interface to remove the addresses. This makes idev->mc_tomb getting bigger and bigger. The call stack looks like: addrconf_notify(NETDEV_REGISTER) ipv6_add_dev ipv6_dev_mc_inc(ff01::1) ipv6_dev_mc_inc(ff02::1) ipv6_dev_mc_inc(ff02::2) addrconf_notify(NETDEV_UP) addrconf_dev_config /* Alas, we support only Ethernet autoconfiguration. */ return; addrconf_notify(NETDEV_DOWN) addrconf_ifdown ipv6_mc_down igmp6_group_dropped(ff02::2) mld_add_delrec(ff02::2) igmp6_group_dropped(ff02::1) igmp6_group_dropped(ff01::1) After investigating, I can't found a rule to disable multicast on non-Ethernet interface. In RFC2460, the link could be Ethernet, PPP, ATM, tunnels, etc. In IPv4, it doesn't check the dev type when calls ip_mc_up() in inetdev_event(). Even for IPv6, we don't check the dev type and call ipv6_add_dev(), ipv6_dev_mc_inc() after register device. So I think it's OK to fix this memory consumer by calling ipv6_mc_up() for non-Ethernet interface. v2: Also check IFF_MULTICAST flag to make sure the interface supports multicast Reported-by: Rafał Miłecki Tested-by: Rafał Miłecki Fixes: 74235a25c673 ("[IPV6] addrconf: Fix IPv6 on tuntap tunnels") Fixes: 1666d49e1d41 ("mld: do not remove mld souce list info when set link down") Signed-off-by: Hangbin Liu Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/addrconf.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -3223,6 +3223,10 @@ static void addrconf_dev_config(struct n (dev->type != ARPHRD_TUNNEL) && (dev->type != ARPHRD_NONE)) { /* Alas, we support only Ethernet autoconfiguration. */ + idev = __in6_dev_get(dev); + if (!IS_ERR_OR_NULL(idev) && dev->flags & IFF_UP && + dev->flags & IFF_MULTICAST) + ipv6_mc_up(idev); return; }