From patchwork Thu Mar 4 15:32:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Micha=C5=82_Kazior?= X-Patchwork-Id: 1447431 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=openvswitch.org (client-ip=140.211.166.137; helo=smtp4.osuosl.org; envelope-from=ovs-dev-bounces@openvswitch.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=Li+w71mL; dkim-atps=neutral Received: from smtp4.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DrxDF3yybz9sW4 for ; Fri, 5 Mar 2021 03:30:05 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 44C914EBD1; Thu, 4 Mar 2021 16:30:03 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nQpEshRLLZNq; Thu, 4 Mar 2021 16:30:02 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp4.osuosl.org (Postfix) with ESMTP id 041E34981D; Thu, 4 Mar 2021 16:30:00 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id CEABAC000A; Thu, 4 Mar 2021 16:30:00 +0000 (UTC) X-Original-To: dev@openvswitch.org Delivered-To: ovs-dev@lists.linuxfoundation.org Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 6EA15C0001 for ; Thu, 4 Mar 2021 16:30:00 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 563F143273 for ; Thu, 4 Mar 2021 16:30:00 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id QTqLJLR_Fqj6 for ; Thu, 4 Mar 2021 16:29:59 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) by smtp2.osuosl.org (Postfix) with ESMTPS id 578174326E for ; Thu, 4 Mar 2021 16:29:59 +0000 (UTC) Received: by mail-ej1-x630.google.com with SMTP id mm21so50247075ejb.12 for ; Thu, 04 Mar 2021 08:29:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v9NWbluernF+7MxeBPcW3uMEjQsAowaN+e8uNgqGgMY=; b=Li+w71mL2nAxriwTGHo2LiRIor3/gVZRA+P3d7L/78/DBbfeb/9eLltmMxf+bOr7oq v+RH5udhDoifnwgcW5oNvqmnlgaB22vA6phezDYhMIRnMKx0RAd5H3XDvoKSSMylnMoO agHx0sjZ2SJBwjFgmaa30t8xxa6DuwWunTFXO7Geja4evf3L8BuKC3rnHPDZfdjOftoi 0nj98pPJ8bk5vvcRI03ZFTr1aQ8CrMckYgHbBiQzclH69F0lEogrnvZDZBwwLRLRaXJ5 Z2pYR2TzrpWJeoG/OGPd+TsENFBEnOXAO7pFDRqfsZgTso2QnvZAGFnw4MGh3kkAJ7vl oXzw== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=v9NWbluernF+7MxeBPcW3uMEjQsAowaN+e8uNgqGgMY=; b=CHAhaX3pv5JFh2AARrWlz7Z1DJ0+ZSFAL2GtBxTx1oPa3HTdPOaYVALtK2L68f6QcO M2Boyll2YHDnBA492J385UzQeqQyZ6JG3lCAY28GjGaxYFgcOAv/SXNPKybZumWIqSRA Dm6YdqlKPabUy75AaFUOgEpzIOUhjjmFO73qCih0WRYL1ogyXeHNhXqIoAqwbeGXQRZX otflAMQxKlyHIHDvcTg0ou1zkmLhuIOgDcvcFFCmVMAhv470lvHwSsqxghg7yTf7rcdD gaIGLZ5ilel4dOo+Et7VhQFqMV5Y76zNEan1LDyo9u5pOyHn+Zp9VM9kEKo12nDAZTYt MzQA== X-Gm-Message-State: AOAM5313bVLtKLYQOcgQOQPcojgfEhbnGW9fiejoZr4p7N1CNRU/Xc3q nYO6vYJLsO/fecukKPmWKRRApGvOr8g= X-Google-Smtp-Source: ABdhPJyM34ITls7hhN6oq4yTzOegxW1M2A7VPBv4OHUQn2fdm/n8VsGrxUbjlbaLoFM6e1A2obNMUw== X-Received: by 2002:a2e:9bcd:: with SMTP id w13mr2557615ljj.43.1614871985148; Thu, 04 Mar 2021 07:33:05 -0800 (PST) Received: from drun:home-michalkazior-docker-linux-alpine.pl.plumewifi.com ([2a03:4b00:0:4:692:26ff:fed9:4198]) by smtp.gmail.com with ESMTPSA id c16sm3319761lft.264.2021.03.04.07.33.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Mar 2021 07:33:01 -0800 (PST) From: Michal Kazior To: dev@openvswitch.org Date: Thu, 4 Mar 2021 15:32:54 +0000 Message-Id: <20210304153254.1088-1-kazikcz@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210304144243.25078-1-kazikcz@gmail.com> References: <20210304144243.25078-1-kazikcz@gmail.com> MIME-Version: 1.0 Cc: Michal Kazior Subject: [ovs-dev] [PATCH v4] netlink: ignore IFLA_WIRELESS events X-BeenThere: ovs-dev@openvswitch.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: ovs-dev-bounces@openvswitch.org Sender: "dev" From: Michal Kazior Some older wireless drivers - ones relying on the old and long deprecated wireless extension ioctl system - can generate quite a bit of IFLA_WIRELESS events depending on their configuration and runtime conditions. These are delivered as RTNLGRP_LINK via RTM_NEWLINK messages. These tend to be relatively easily identifiable because they report the change mask being 0. This isn't guaranteed but in practice it shouldn't be a problem. None of the wireless events that I ever observed actually carry any unique information about netdev states that ovs-vswitchd is interested in. Hence ignoring these shouldn't cause any problems. These events can be responsible for a significant CPU churn as ovs-vswitchd attempts to do plenty of work for each and every netlink message regardless of what that message carries. On low-end devices such as consumer-grade routers these can lead to a lot of CPU cycles being wasted, adding up to heat output and reducing performance. It could be argued that wireless drivers in question should be fixed, but that isn't exactly a trivial thing to do. Patching ovs seems far more viable while still making sense. Signed-off-by: Michal Kazior --- Notes: v4: - fixed comment-too-long checkpatch warnin [0day robot] v3: - dont change rtnetlink_parse() semantics, instead extend rtnetlink_change struct and update its consumers [Ilya] - adjusted commit log to reflect different approach [Ilya] v2: - fix bracing style [0day robot / checkpatch] lib/if-notifier.c | 7 ++++++- lib/netdev-linux.c | 9 +++++++++ lib/route-table.c | 4 ++++ lib/rtnetlink.c | 18 ++++++++++++++++++ lib/rtnetlink.h | 3 +++ 5 files changed, 40 insertions(+), 1 deletion(-) diff --git a/lib/if-notifier.c b/lib/if-notifier.c index 9a64f9b15..7ba9cc316 100644 --- a/lib/if-notifier.c +++ b/lib/if-notifier.c @@ -26,9 +26,14 @@ struct if_notifier { }; static void -if_notifier_cb(const struct rtnetlink_change *change OVS_UNUSED, void *aux) +if_notifier_cb(const struct rtnetlink_change *change, void *aux) { struct if_notifier *notifier; + + if (change->irrelevant) { + return; + } + notifier = aux; notifier->cb(notifier->aux); } diff --git a/lib/netdev-linux.c b/lib/netdev-linux.c index 6be23dbee..388288f71 100644 --- a/lib/netdev-linux.c +++ b/lib/netdev-linux.c @@ -663,6 +663,10 @@ netdev_linux_update_lag(struct rtnetlink_change *change) { struct linux_lag_member *lag; + if (change->irrelevant) { + return; + } + if (change->sub && netdev_linux_kind_is_lag(change->sub)) { lag = shash_find_data(&lag_shash, change->ifname); @@ -887,6 +891,10 @@ netdev_linux_update(struct netdev_linux *dev, int nsid, const struct rtnetlink_change *change) OVS_REQUIRES(dev->mutex) { + if (change->irrelevant) { + return; + } + if (netdev_linux_netnsid_is_eq(dev, nsid)) { netdev_linux_update__(dev, change); } @@ -6344,6 +6352,7 @@ netdev_linux_update_via_netlink(struct netdev_linux *netdev) } if (rtnetlink_parse(reply, change) + && !change->irrelevant && change->nlmsg_type == RTM_NEWLINK) { bool changed = false; error = 0; diff --git a/lib/route-table.c b/lib/route-table.c index 6c82cdfdd..a4531df1e 100644 --- a/lib/route-table.c +++ b/lib/route-table.c @@ -342,6 +342,10 @@ static void name_table_change(const struct rtnetlink_change *change, void *aux OVS_UNUSED) { + if (change->irrelevant) { + return; + } + /* Changes to interface status can cause routing table changes that some * versions of the linux kernel do not advertise for some reason. */ route_table_valid = false; diff --git a/lib/rtnetlink.c b/lib/rtnetlink.c index 125802925..ebb032aa7 100644 --- a/lib/rtnetlink.c +++ b/lib/rtnetlink.c @@ -99,6 +99,7 @@ rtnetlink_parse(struct ofpbuf *buf, struct rtnetlink_change *change) [IFLA_MTU] = { .type = NL_A_U32, .optional = true }, [IFLA_ADDRESS] = { .type = NL_A_UNSPEC, .optional = true }, [IFLA_LINKINFO] = { .type = NL_A_NESTED, .optional = true }, + [IFLA_WIRELESS] = { .type = NL_A_UNSPEC, .optional = true }, }; struct nlattr *attrs[ARRAY_SIZE(policy)]; @@ -111,6 +112,23 @@ rtnetlink_parse(struct ofpbuf *buf, struct rtnetlink_change *change) ifinfo = ofpbuf_at(buf, NLMSG_HDRLEN, sizeof *ifinfo); + /* Wireless events can be spammy and cause a + * lot of unnecessary churn and CPU load in + * ovs-vswitchd. The best way to filter them out + * is to rely on the IFLA_WIRELESS and + * ifi_change. As per rtnetlink_ifinfo_prep() in + * the kernel, the ifi_change = 0. That combined + * with the fact wireless events never really + * change interface state (as far as core + * networking is concerned) they can be ignored + * by ovs-vswitchd. It doesn't understand + * wireless extensions anyway and has no way of + * presenting these bits into ovsdb. + */ + if (attrs[IFLA_WIRELESS] && ifinfo->ifi_change == 0) { + change->irrelevant = true; + } + change->nlmsg_type = nlmsg->nlmsg_type; change->if_index = ifinfo->ifi_index; change->ifname = nl_attr_get_string(attrs[IFLA_IFNAME]); diff --git a/lib/rtnetlink.h b/lib/rtnetlink.h index b6ddb4bd1..4d11a6409 100644 --- a/lib/rtnetlink.h +++ b/lib/rtnetlink.h @@ -45,6 +45,9 @@ struct rtnetlink_change { int mtu; /* Current MTU. */ struct eth_addr mac; unsigned int ifi_flags; /* Flags of network device. */ + bool irrelevant; /* Some events, notably wireless extensions, + don't really indicate real netdev change + that ovs should care about */ /* Network device address status. */ /* xxx To be added when needed. */