From patchwork Mon May 4 19:58:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Pavel Shirshov X-Patchwork-Id: 11527505 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 3B82492A for ; Mon, 4 May 2020 19:58:39 +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 DF100206B8 for ; Mon, 4 May 2020 19:58:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DF100206B8 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 41E1E60EB50A; Mon, 4 May 2020 19:58:38 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 bastion01.phx2.fedoraproject.org 41E1E60EB50A Received: from mailman01.phx2.fedoraproject.org (localhost [IPv6:::1]) by mailman01.phx2.fedoraproject.org (Postfix) with ESMTP id 3612B5E15BF1D; Mon, 4 May 2020 19:58:38 +0000 (UTC) Received: by mailman01.phx2.fedoraproject.org (Postfix, from userid 991) id 61CAA5DED8499; Mon, 4 May 2020 19:58:34 +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 96B625E198C02 for ; Mon, 4 May 2020 19:58:33 +0000 (UTC) Received: from mail-pj1-f66.google.com (mail-pj1-f66.google.com [209.85.216.66]) (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 2DA956085EA1 for ; Mon, 4 May 2020 19:58:33 +0000 (UTC) Received: by mail-pj1-f66.google.com with SMTP id t40so433803pjb.3 for ; Mon, 04 May 2020 12:58:33 -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=q6ekZUMHSYaj+dgzObujwgi5+6r+6Qzsu/0kgTDRm5Q=; b=Wcv8zyzx1eXxFcVYX9z9iVq9mFT6ZQovt33kFcDeAoMiVlDj8GA4puX1gybfnghxKS UrqtXbBwgc6BhZ172r2YEzeQc/o8htNqyh4puDCOp4Pxgzzu9IXzGIzaTaaGjISRusDz pLjUsBGyfObX+DLhC6RhL5LFm7+A82ZvvCLLbpcbH0odfaarIYKvXU655DzQwuVMlMQ/ K5JiZ4KMktArX2o0WOW7jJEEcqpmGBOYOPZF+EdlmM+Oe7nHdvoCUJniN85Rqb7IBfRi 3tQw8fWjYr+w7q94VFvnJTekthHWghdbmAvoua+ibcm1HndZNKlh+UMEMm1ARXhkjycm XQrQ== X-Gm-Message-State: AGi0PuZ671ffbat5GgIJYesNvKKQN5XJ2MhKnHKQnoiaT2qlN8XB8Ayx CDhsUuJk6ROpxalnmQj8EZ6S+XCB X-Google-Smtp-Source: APiQypLPmtL6wD5gGL43oFMx6r0lTTqKpOEoVtGmaRyk2npPDUf5KJaRPvm1i+O7laZ2MfKwCMozZQ== X-Received: by 2002:a17:90a:8b82:: with SMTP id z2mr759900pjn.124.1588622311723; Mon, 04 May 2020 12:58:31 -0700 (PDT) Received: from localhost.localdomain (50-47-139-32.evrt.wa.frontiernet.net. [50.47.139.32]) by smtp.gmail.com with ESMTPSA id h14sm249990pjc.46.2020.05.04.12.58.31 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 May 2020 12:58:31 -0700 (PDT) From: Pavel Shirshov To: libteam@lists.fedorahosted.org Subject: [PATCH] Skip setting the same hwaddr to a lag port if not needed Date: Mon, 4 May 2020 12:58:13 -0700 Message-Id: <1588622293-3463-1-git-send-email-pavel.contrib@gmail.com> X-Mailer: git-send-email 2.7.4 Message-ID-Hash: MWE7YYXNZJUMTH4C4OCFBDXT4YJ65KBZ X-Message-ID-Hash: MWE7YYXNZJUMTH4C4OCFBDXT4YJ65KBZ X-MailFrom: pavel.contrib@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@resnulli.us 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 Avoid setting the same mac address to a LAG port, if the LAG port already has the right one. Benefits: 1. Make libteam avoid changing settings of a link, which prevents the kernel from sending multiply Netlink messages. Netlink message listeners don't need to react to the Netlink messages. 2. Libteam works faster. It doesn't need to use any syscalls and go deep into libteam functions in the case when nothing is changed. A straightforward check and libteam avoid much work. In the case, when libteam user has hundreds of ports, and up to a hundred LAGs, this patch saves them significant CPU time. Signed-off-by: Pavel Shirshov --- teamd/teamd.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/teamd/teamd.c b/teamd/teamd.c index 8cdc16d..f955b19 100644 --- a/teamd/teamd.c +++ b/teamd/teamd.c @@ -837,7 +837,14 @@ static int teamd_set_hwaddr(struct teamd_context *ctx) err = -EINVAL; goto free_hwaddr; } - err = team_hwaddr_set(ctx->th, ctx->ifindex, hwaddr, hwaddr_len); + + if (memcmp(hwaddr, ctx->hwaddr, hwaddr_len)) + err = team_hwaddr_set(ctx->th, ctx->ifindex, hwaddr, hwaddr_len); + else { + err = 0; + teamd_log_dbg(ctx, "Skip setting same hwaddr string: \"%s\".", hwaddr_str); + } + if (!err) ctx->hwaddr_explicit = true; free_hwaddr: