From patchwork Wed Feb 27 08:05:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 10831385 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3BFAA1399 for ; Wed, 27 Feb 2019 08:06:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 247322C9D3 for ; Wed, 27 Feb 2019 08:06:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 184712CE51; Wed, 27 Feb 2019 08:06:20 +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 B55C52C9D3 for ; Wed, 27 Feb 2019 08:06:19 +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 C1F4D60A5123; Wed, 27 Feb 2019 08:06:18 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org C1F4D60A5123 Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id B318F4EA5A30C; Wed, 27 Feb 2019 08:06:18 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id C9F604EA5A30D; Wed, 27 Feb 2019 08:06:15 +0000 (UTC) Received: from smtp-mm-ib01.fedoraproject.org (smtp-mm-ib01.vpn.fedoraproject.org [192.168.1.83]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id 4DAEF4EA5A30A for ; Wed, 27 Feb 2019 08:06:15 +0000 (UTC) Received: from mail-pl1-f194.google.com (mail-pl1-f194.google.com [209.85.214.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G3" (verified OK)) by smtp-mm-ib01.fedoraproject.org (Postfix) with ESMTPS id CCD75605D1F6 for ; Wed, 27 Feb 2019 08:06:14 +0000 (UTC) Received: by mail-pl1-f194.google.com with SMTP id r14so7604548pls.12 for ; Wed, 27 Feb 2019 00:06:14 -0800 (PST) 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:mime-version :content-transfer-encoding; bh=ZWY2eEgAIlWbQRH8EZk9X2rSSQYnm+hDaouxhGNULW8=; b=jIdvGCEbQ48qQ4tLcNmoWXpBF0GOauEqCPe6fn/GdX1xmw6Y/DNimUrN3dr5eazGLg n2nnjOyPEbcunCg2gsBZoVpoq7SIBxL9rnMgc45+O6CWHUETa1hsrNv2gSI9oxxP5lsU scQBGwJpMf8m0MMkkrJ0aWBVnEIVAtcWRc+xjsHo8MM2yvxU/8XO95+osBnORelPbHow N7IdCg6TdrozdfYvjWDu9Hva+yIlPqkRJERnwfmctWJaudrv7P8Nyo1p16VcgKLrF7dD lKmeMQiA4wXwow1AIR0nS9fyk/f1h3JuviIscoSBQ0azmAyMJKEeyUuHqrzHCjL+kJlQ cm1Q== X-Gm-Message-State: AHQUAuaW535DBQmu38mjAY0aRiwPJQLtfxL236DrfWDjQPrqTTTNF15r qfWP7TVD3/VruCroKY9+eEWMwxd7voc= X-Google-Smtp-Source: AHgI3IZBwAl8G3SyTcM75BKnbRZ9p3LzMx1Fs0ISeVybcbqpKx/iqmV22Jz6fayexdCCfAR0wpsCog== X-Received: by 2002:a17:902:9304:: with SMTP id bc4mr864695plb.81.1551254773538; Wed, 27 Feb 2019 00:06:13 -0800 (PST) Received: from dhcp-12-139.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id 195sm19910857pfc.50.2019.02.27.00.06.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 27 Feb 2019 00:06:12 -0800 (PST) From: Hangbin Liu To: libteam@lists.fedorahosted.org Subject: [PATCH] teamd: remove port if adding fails Date: Wed, 27 Feb 2019 16:05:57 +0800 Message-Id: <20190227080557.23348-1-liuhangbin@gmail.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Message-ID-Hash: 3CRFB2IXTYKH7N46UDYKD3GR7GRYMDWZ X-Message-ID-Hash: 3CRFB2IXTYKH7N46UDYKD3GR7GRYMDWZ X-MailFrom: liuhangbin@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: Jiri Pirko , Hangbin Liu X-Mailman-Version: 3.1.1 Precedence: list List-Id: Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-Virus-Scanned: ClamAV using ClamSMTP When we add a port to team via teamdctl, some drivers do not support changing mac address after dev opened, which would lead to the failure of port_obj_create(). Currently we only destroy the port object if adding port fails. But the port is still enslaved to team in kernel. The interface shows it's a team_slave via ip link cmd, but teamdctl state shows nothing. This may make users confused. Fix it by removing the port if adding fails. Reported-by: Vladimir Benes Signed-off-by: Hangbin Liu --- teamd/teamd_per_port.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/teamd/teamd_per_port.c b/teamd/teamd_per_port.c index 09d1dc7..7f0a45d 100644 --- a/teamd/teamd_per_port.c +++ b/teamd/teamd_per_port.c @@ -42,6 +42,8 @@ struct port_obj { }; #define _port(port_obj) (&(port_obj)->port) +static int teamd_port_remove(struct teamd_context *ctx, + struct teamd_port *tdport); int teamd_port_priv_create_and_get(void **ppriv, struct teamd_port *tdport, const struct teamd_port_priv *pp, @@ -203,6 +205,7 @@ static int port_obj_create(struct teamd_context *ctx, teamd_event_port_removed: teamd_event_port_removed(ctx, tdport); list_del: + teamd_port_remove(ctx, tdport); port_obj_destroy(ctx, port_obj); port_obj_free(port_obj); return err;