From patchwork Wed Oct 11 06:17:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xin Long X-Patchwork-Id: 9998709 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 08B9260216 for ; Wed, 11 Oct 2017 06:17:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECA8D288F7 for ; Wed, 11 Oct 2017 06:17:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DED2C288F9; Wed, 11 Oct 2017 06:17:55 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID 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 504AC288F7 for ; Wed, 11 Oct 2017 06:17:54 +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 3FB3A6070D4A; Wed, 11 Oct 2017 06:17:54 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org 3FB3A6070D4A Authentication-Results: bastion01.phx2.fedoraproject.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eIwrBbts" Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id 2E22E21496C78; Wed, 11 Oct 2017 06:17:54 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id 1E34921496C77; Wed, 11 Oct 2017 06:17:48 +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 6C2A22148A61F for ; Wed, 11 Oct 2017 06:17:47 +0000 (UTC) Received: from mail-pg0-f66.google.com (mail-pg0-f66.google.com [74.125.83.66]) (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 23C4B6087DFB for ; Wed, 11 Oct 2017 06:17:47 +0000 (UTC) Received: by mail-pg0-f66.google.com with SMTP id u144so1196633pgb.3 for ; Tue, 10 Oct 2017 23:17:47 -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; bh=80+d4LQNhkRVgnw1wzFimBM84UwvfjHY8dmj2fHzQfE=; b=eIwrBbts+RrXNuj6DzGPXYpIqTWHijAPVwaQJfCCxLDZlG3emfanqMXbtSfertGEzi f2ozExIhAR5XF8xrtxPNYL8+Kaah8Qxz2HD+KU9rNkSB1QPWXVfiKvAL8pvmLWhXlVaV HaAAr8KmrH8sjervjBqDiFTAJKN+cEaJh6Q21OxjHqDX9YAkjLG0koi+oCv2H4oaQh/Q JqSB04xv401Hqi0kiEUA5nI39K2yfewDIma1YV6YEK1zpj85Vvc5sLGOvvz2RTDIzzO0 PZZGqlv18+zRO3WrQOPpG8X8rXoFj90hkNjcXUjf/0o2fqfpnTnL+QLSUqnschwT1mYg oSCg== 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=80+d4LQNhkRVgnw1wzFimBM84UwvfjHY8dmj2fHzQfE=; b=dt/RTfgZ9iTt9rT7PVzSZY13nHz4NqH8P8ia6xA4JHSdoXo7h71jJt8Mxg6NA8fCQZ Oj8+p7NuL8AdP3q+bsZpbF1H5H0E/EfA1q1OqdWFr8ynZbFMINdbb4I9sjDyYlEo82qH RuDo50yMZSWugipNwNoQXQTNSTx//dUIE9XSqGeNAQsPqoMFW2F1L5yUN2N6QjZZ1Oq5 XH4PGKgfsLSs11rxTDQHQFRPvAWPOAmUHSuNp+Kf1QVedeqph4kmDAv78kNPWr5FicpA agBL+7CzhanC3z/2aUyf8EEq/Nh6fb7dELCUf3rBMwwAGT0nNSoUf6AGVp3cd5lWYtJu 4Aow== X-Gm-Message-State: AMCzsaWq+a4Pk4me4eG/T0BKQV9zN9Vuk3yyFZjLw84wQviwIMFQIy8U kXi/XZRfaXiHucrVZ+aMqG9mmuvB X-Google-Smtp-Source: AOwi7QB9vkBWruBcDzy6MzxN3vhUY9KljwIpUn26jJ5C9wy36G+ampoHOhAeXDMU//2oDw4EncNUiA== X-Received: by 10.98.144.142 with SMTP id q14mr15541603pfk.303.1507702666387; Tue, 10 Oct 2017 23:17:46 -0700 (PDT) Received: from localhost ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id m9sm7920083pff.26.2017.10.10.23.17.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 10 Oct 2017 23:17:45 -0700 (PDT) From: Xin Long To: libteam@lists.fedorahosted.org, Jiri Pirko Subject: [PATCH] teamd: do not process lacpdu before the port ifinfo is set Date: Wed, 11 Oct 2017 14:17:38 +0800 Message-Id: <03dad1d0e40ad18d2965fdc924506d701bf38f82.1507702658.git.lucien.xin@gmail.com> X-Mailer: git-send-email 2.1.0 Message-ID-Hash: PRMGRAO372E7NKJM2LDYR6QX36REFDYB X-Message-ID-Hash: PRMGRAO372E7NKJM2LDYR6QX36REFDYB X-MailFrom: lucien.xin@gmail.com X-Mailman-Rule-Misses: dmarc-mitigation; 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: Patrick Talbert , Marcelo Ricardo Leitner X-Mailman-Version: 3.1.0 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 Now the port ifinfo will be set in obj_input_newlink when a RTM_NEWLINK event is received. But when a port is being added, if a lacpdu gets received on this port before the RTM_NEWLINK event, lacpdu_recv will process the packet with incorrect port ifinfo. In Patrick's case, as ifinfo->master_ifindex was 0, it would skip this port in teamd_for_each_tdport, which caused lacp_port->agg_lead not to be updated in lacp_switch_agg_lead. Later the lacp_port actor would go to a unexpected state. This patch is to avoid it by checking teamd_port_present in lacpdu_recv so that it would not process lacpdu before the port ifinfo is set. Reported-by: Patrick Talbert Tested-by: Patrick Talbert Signed-off-by: Xin Long --- teamd/teamd_runner_lacp.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.1.0 diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c index 5601278..1310f67 100644 --- a/teamd/teamd_runner_lacp.c +++ b/teamd/teamd_runner_lacp.c @@ -1075,6 +1075,9 @@ static int lacpdu_recv(struct lacp_port *lacp_port) if (err <= 0) return err; + if (!teamd_port_present(lacp_port->ctx, lacp_port->tdport)) + return 0; + if (!lacpdu_check(&lacpdu)) { teamd_log_warn("malformed LACP PDU came."); return 0;