From patchwork Tue May 26 10:59:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hangbin Liu X-Patchwork-Id: 11570323 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BB633739 for ; Tue, 26 May 2020 10:59:52 +0000 (UTC) Received: from bastion.fedoraproject.org (bastion01.fedoraproject.org [209.132.181.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8B33D2088E for ; Tue, 26 May 2020 10:59:52 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8B33D2088E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=libteam-bounces@lists.fedorahosted.org Received: from mailman01.phx2.fedoraproject.org (mailman01.phx2.fedoraproject.org [10.5.126.36]) by bastion01.phx2.fedoraproject.org (Postfix) with ESMTP id 864136297430; Tue, 26 May 2020 10:59:51 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org 864136297430 Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id 7DB895DF2D4A1; Tue, 26 May 2020 10:59:51 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id A7C4E5DF2D49D; Tue, 26 May 2020 10:59:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mailman01.phx2.fedoraproject.org X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=disabled version=3.4.0 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 E9CF85DF2D492 for ; Tue, 26 May 2020 10:59:47 +0000 (UTC) Received: from mail-pj1-f65.google.com (mail-pj1-f65.google.com [209.85.216.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by smtp-mm-ib01.fedoraproject.org (Postfix) with ESMTPS id 79B6C605D2EB for ; Tue, 26 May 2020 10:59:47 +0000 (UTC) Received: by mail-pj1-f65.google.com with SMTP id l73so4707164pjb.1 for ; Tue, 26 May 2020 03:59:47 -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:mime-version :content-transfer-encoding; bh=DP2P+zwTE2dlgmm8BEAbQbbq7gHPOD2pYVlRfnFVvTc=; b=CQ6Wpbg6bwVEVUNLbxSmmFuPQxeecTvZDc6QuqxZXIoOacJG+4rHOd6+kOZ1+Oleo/ bBmDzYdzN4m7qHwzXIXvndXckUfWvzsWt/e/BaVTISEsH8b0is4S7fZ3fVE85cmz65Zo J3DqeQFlnAP8TH9dFhaRtOjcjDbZKcyiE+18i9+5Z52+GkaJgEwS3mXgzwW9jLyfm388 bKCQxzVKZrpYKFGkwVcj3sY4dtHAD5l5q0MBTFNuvg1MRcSbUWyPQfgax2xxlPeQNw6n QrLmkS0oW3uBJZm3BMnuKG3f+bV5U0wERhw54gMbbjE14O37dcVNeW2HrQCxnEzYztLV Jkog== X-Gm-Message-State: AOAM533VKPn6WdFALKkJ3HkQ32ZGyJOTw5UQ7iMtrF+DQ13OpQ8Rn0i6 fb1L/CXS3WE7JeGYSe6n80LW6eB0mWjnOQ== X-Google-Smtp-Source: ABdhPJxdqqHHkc+Xm0WVOQobFNRinkR+P7VtZ2oHOVHckxr7duL5TB4+A3+6zPq5ZRShRaD8WdfcnQ== X-Received: by 2002:a17:90a:1d1:: with SMTP id 17mr25652926pjd.211.1590490786278; Tue, 26 May 2020 03:59:46 -0700 (PDT) Received: from dhcp-12-153.nay.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id d18sm15396746pjv.34.2020.05.26.03.59.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 May 2020 03:59:45 -0700 (PDT) From: Hangbin Liu To: libteam@lists.fedorahosted.org Subject: [libteam PATCH] teamd/lacp: silence ignore none LACP frames Date: Tue, 26 May 2020 18:59:33 +0800 Message-Id: <20200526105933.3485343-1-liuhangbin@gmail.com> X-Mailer: git-send-email 2.25.4 MIME-Version: 1.0 Message-ID-Hash: 3YQ3Z5JRZKSRL64E5IZP34MD652BBQNG X-Message-ID-Hash: 3YQ3Z5JRZKSRL64E5IZP34MD652BBQNG 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: According to 802.3, Annex 43B, section 4, aside from LACP, the Slow Protocol linktype is also to be used by other protocols, like 0x02 for LAMP, 0x03 for OAM. So let's only check LACP frames. For none LACP protocols, just silence ignore. Signed-off-by: Hangbin Liu --- teamd/teamd_runner_lacp.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/teamd/teamd_runner_lacp.c b/teamd/teamd_runner_lacp.c index 11d02f1..9437f05 100644 --- a/teamd/teamd_runner_lacp.c +++ b/teamd/teamd_runner_lacp.c @@ -96,17 +96,27 @@ static void lacpdu_init(struct lacpdu *lacpdu) static bool lacpdu_check(struct lacpdu *lacpdu) { + /* + * According to Annex 43B, section 4, aside from LACP, the Slow + * Protocol linktype is also to be used by other protocols, like + * 0x02 for LAMP, 0x03 for OAM. So for none LACP protocols, just + * silence ignore. + */ + if (lacpdu->subtype != 0x01) + return false; + /* * According to 43.4.12 version_number, tlv_type and reserved fields * should not be checked. */ - if (lacpdu->subtype != 0x01 || - lacpdu->actor_info_len != 0x14 || + if (lacpdu->actor_info_len != 0x14 || lacpdu->partner_info_len != 0x14 || lacpdu->collector_info_len != 0x10 || - lacpdu->terminator_info_len != 0x00) + lacpdu->terminator_info_len != 0x00) { + teamd_log_warn("malformed LACP PDU came."); return false; + } return true; } @@ -1088,10 +1098,8 @@ static int lacpdu_recv(struct lacp_port *lacp_port) if (!teamd_port_present(lacp_port->ctx, lacp_port->tdport)) return 0; - if (!lacpdu_check(&lacpdu)) { - teamd_log_warn("malformed LACP PDU came."); + if (!lacpdu_check(&lacpdu)) return 0; - } /* Check if we have correct info about the other side */ if (memcmp(&lacpdu.actor, &lacp_port->partner,