From patchwork Sun Apr 22 11:18:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 10354511 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 BEDE96019C for ; Sun, 22 Apr 2018 11:18:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A148C28961 for ; Sun, 22 Apr 2018 11:18:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93F0E28969; Sun, 22 Apr 2018 11:18:27 +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 8021128961 for ; Sun, 22 Apr 2018 11:18:25 +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 2B85760754A9; Sun, 22 Apr 2018 11:18:25 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org 2B85760754A9 Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id 16C2B256493A3; Sun, 22 Apr 2018 11:18:25 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id 0DCB0256493A3; Sun, 22 Apr 2018 11:18:21 +0000 (UTC) Received: from smtp-mm-osuosl01.fedoraproject.org (smtp-mm-osuosl01.vpn.fedoraproject.org [192.168.1.23]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id 570BE256493A2 for ; Sun, 22 Apr 2018 11:18:20 +0000 (UTC) Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) (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-osuosl01.fedoraproject.org (Postfix) with ESMTPS id 14F8898069 for ; Sun, 22 Apr 2018 11:18:20 +0000 (UTC) Received: by mail-pf0-x243.google.com with SMTP id a2so6942073pff.8 for ; Sun, 22 Apr 2018 04:18:20 -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=E7/5XfoO4dsIkDEpMt19TNpvKRshRnugeFe7UEHa9YM=; b=TI66v6iJ2hKK4uEG5DHteRM1NnQcaaT6UjG/LhGkCXVowHjTyDjiw846FrB4d+sRZn YxhnDTJ5gLMUWM2t79bfMk1kx2j5UfAg74hLtiC4EoVW83g/E245WviOBA1j9a4Y69Pb xppdJi0xsSJWH0DHPLTByaEEZB+XQPlNFub0tDP32j3Um1cg06cpEAWK5kC4yi9lMZaV o4MnLQyi/Mn1UelxejbA2tlgWijbNFAHmcqIttudXKyrysRdkp78e4Zatvm4x5PTjwhR fIf9JlY5Qu7KSPFh4qy4mYS9zfBWe8aAAULUgtlNFufIks0oFWtxpK6vxRMnd8j5tASt RJiA== X-Gm-Message-State: ALQs6tANDQDTEikwmIJlLUZgIqskmYjq62hoGsdVPMnTOel+yjQ53oPF +Gwx9vO6K5O4jjK+w5cJZzvkgfSb X-Google-Smtp-Source: AIpwx48ZipHjLkn6+Vc0Z022XsRl2e3Aj1daJtsmbzY9vSAL1lt4JAiyzmLWTyHIOMT9Nng1lBghrw== X-Received: by 10.99.102.196 with SMTP id a187mr13987921pgc.349.1524395899454; Sun, 22 Apr 2018 04:18:19 -0700 (PDT) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id t64sm19546198pfi.34.2018.04.22.04.18.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Apr 2018 04:18:18 -0700 (PDT) From: Xin Long To: libteam@lists.fedorahosted.org, Jiri Pirko Subject: [PATCHv2] libteam: do not destroy the ifinfo of current unregistered slave dev Date: Sun, 22 Apr 2018 19:18:11 +0800 Message-Id: <064e21f1dc9a34e637411c9ecbcd833057994609.1524395891.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.1.0 Message-ID-Hash: W2ZUV2QVZ7DRTUK3HMWFAP3QPSQCYW7U X-Message-ID-Hash: W2ZUV2QVZ7DRTUK3HMWFAP3QPSQCYW7U 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 that is saved in this ifinfo: ... -1450: veth1: down 0Mbit HD <-- ... The similar 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 REMOVED flag, including the one of current unregistered slave dev. It would cause a crash later when printing the dbg log. An easy 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 check !ifinfo->port before calling ifinfo_destroy in ifinfo_destroy_removed and clear_changed in ifinfo_destroy_removed. After this fix, the ifinfo of current unregistered slave dev will not be destroyed this time until next time when processing IFINFO_CHANGE flag for another ifinfo's change in check_call_change_handlers. v1->v2: - improve the changelog, including some typos Jiri noticed. 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); } }