From patchwork Fri Apr 13 06:43:34 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 10339583 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AB418604D4 for ; Fri, 13 Apr 2018 06:43:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DDE027D0C for ; Fri, 13 Apr 2018 06:43:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 92695286CF; Fri, 13 Apr 2018 06:43:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from bastion.fedoraproject.org (bastion01.fedoraproject.org [209.132.181.2]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 76F0427D0C for ; Fri, 13 Apr 2018 06:43:49 +0000 (UTC) Received: from mailman01.phx2.fedoraproject.org (mailman01.phx2.fedoraproject.org [10.5.126.36]) by bastion01.phx2.fedoraproject.org (Postfix) with ESMTP id 472136075DBE; Fri, 13 Apr 2018 06:43:48 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org 472136075DBE Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id 3678F254F5DE5; Fri, 13 Apr 2018 06:43:48 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id 702FB254F5DE7; Fri, 13 Apr 2018 06:43:44 +0000 (UTC) Received: from smtp-mm-tummy01.fedoraproject.org (smtp-mm-tummy01.vpn.fedoraproject.org [192.168.1.82]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id A95D0254F5DE5 for ; Fri, 13 Apr 2018 06:43:43 +0000 (UTC) Received: from mail-pl0-f67.google.com (mail-pl0-f67.google.com [209.85.160.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by smtp-mm-tummy01.fedoraproject.org (Postfix) with ESMTPS id 4F3FC607F162 for ; Fri, 13 Apr 2018 06:43:43 +0000 (UTC) Received: by mail-pl0-f67.google.com with SMTP id bj1-v6so5530619plb.8 for ; Thu, 12 Apr 2018 23:43:43 -0700 (PDT) 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; bh=k+aSbiRBBfZUQGZRtGtdVRTJSoImMrNv204wY1t4IOQ=; b=QBWpjlK6sbqb2yaMth7BExQGJDMlAGgwg4hbPqrxyGWOEUOBXqBpv3fn3ji29XxC4h Kx2Rr3v3cvDmm3VdMQh7vJfINJ6ZoMcaHjGDFLR7pTKGLpIF+KTNFArjeP8HrIp/bSZb 4B8pWIEcSYTcNXuxLl5+N6BI54PLE+/qU6M2BcRurp5oS2hSGCaddzdXQOXoxqx7gRgf bmk/K7oyytPUQQbE5yZ9teJFm8N+v5scqpYsi9MeYGBBSZ7o/DzMg4xF+bhDLS8IYS1p RB05g6Bky0dey1qZUTHok9b0Zoc0tW5HoZRcZ1iP3DDLSdwwUGwCc/ytIBiqU32d5Yyb KLvg== X-Gm-Message-State: ALQs6tBhel8Vszq3pP2ucGs/Crt1+aGDecrqhUvynI+DYY/uF/bO62CF wZsuUHc8DUZeuCS61RpgvZAiq81X X-Google-Smtp-Source: AIpwx49mKdASLxaKi//AY2DN4G02TNQ2XtbXG+Is8oXvDrOHVO18lz8s99h6s/6m6YdUO1ni57QuVA== X-Received: by 2002:a17:902:8b84:: with SMTP id ay4-v6mr4004433plb.57.1523601822275; Thu, 12 Apr 2018 23:43:42 -0700 (PDT) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id b187sm9836315pfg.164.2018.04.12.23.43.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 12 Apr 2018 23:43:41 -0700 (PDT) From: Xin Long To: libteam@lists.fedorahosted.org, Jiri Pirko Subject: [PATCH] libteam: do not destroy the ifinfo of current unregistered dev enslaved into team Date: Fri, 13 Apr 2018 14:43:34 +0800 Message-Id: <09f171c8308cfaec4620c038b651cd6886f74bd8.1523601814.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.1.0 Message-ID-Hash: GPTPDNUVTGJ2J3QRYTX47QHVQ6OCHNVG X-Message-ID-Hash: GPTPDNUVTGJ2J3QRYTX47QHVQ6OCHNVG X-MailFrom: lucien.xin@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: Antti Tiainen X-Mailman-Version: 3.1.1 Precedence: list List-Id: Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Virus-Scanned: ClamAV using ClamSMTP When a dev is being unregistered and the corresp team port is being removed, the ifinfo should be delayed to destroy when doing dellink next time, because later on the dbg log still needs it to print the ifname saved in this ifinfo: ... -1450: veth1: down 0Mbit HD <-- ... The smilar process is also used on the team_port's destruction. However, after Commit 046fb6ba0aec ("libteam: resynchronize ifinfo after lost RTNLGRP_LINK notifications"), it would destroy all those ifinfo with REMVOED flag, including the one of current unregistered dev enslaved into team. It would cause a crash later when trying to print the dbg log. A simple way to reproduce: # ip link add veth1 type veth peer name veth1_peer # sleep 5 && ip link del veth1 & # teamd -g -c '{"device":"team0","runner":{"name":"activebackup"}, "ports":{"veth1":{}}}' This patch is to avoid it by simply checking !ifinfo->port before calling ifinfo_destroy in ifinfo_destroy_removed(), as well as in ifinfo_clear_changed(), so that the ifinfo of current unregistered dev enslaved into team will be delayed to destroy next time. Fixes: 046fb6ba0aec ("libteam: resynchronize ifinfo after lost RTNLGRP_LINK notifications") Signed-off-by: Xin Long --- libteam/ifinfo.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) -- 2.1.0 diff --git a/libteam/ifinfo.c b/libteam/ifinfo.c index 5c32a9c..d47c2bf 100644 --- a/libteam/ifinfo.c +++ b/libteam/ifinfo.c @@ -211,7 +211,8 @@ void ifinfo_clear_changed(struct team_handle *th) struct team_ifinfo *ifinfo; list_for_each_node_entry(ifinfo, &th->ifinfo_list, list) - clear_changed(ifinfo); + if (!ifinfo->port) + clear_changed(ifinfo); } static struct team_ifinfo *ifinfo_find_create(struct team_handle *th, @@ -245,7 +246,7 @@ void ifinfo_destroy_removed(struct team_handle *th) struct team_ifinfo *ifinfo, *tmp; list_for_each_node_entry_safe(ifinfo, tmp, &th->ifinfo_list, list) { - if (is_changed(ifinfo, CHANGED_REMOVED)) + if (is_changed(ifinfo, CHANGED_REMOVED) && !ifinfo->port) ifinfo_destroy(ifinfo); } }