2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-22 09:58:01 +00:00
ovs/lib/if-notifier.c
Michal Kazior d90b4f2928 rtnetlink: ignore IFLA_WIRELESS events.
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 <michal@plume.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
2021-04-20 00:00:22 +02:00

72 lines
1.6 KiB
C

/*
* Copyright (c) 2015 Red Hat, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <config.h>
#include "if-notifier.h"
#include "rtnetlink.h"
#include "util.h"
struct if_notifier {
struct nln_notifier *notifier;
if_notify_func *cb;
void *aux;
};
static void
if_notifier_cb(const struct rtnetlink_change *change, void *aux)
{
struct if_notifier *notifier;
if (change && change->irrelevant) {
return;
}
notifier = aux;
notifier->cb(notifier->aux);
}
struct if_notifier *
if_notifier_create(if_notify_func *cb, void *aux)
{
struct if_notifier *notifier;
notifier = xmalloc(sizeof *notifier);
notifier->cb = cb;
notifier->aux = aux;
notifier->notifier = rtnetlink_notifier_create(if_notifier_cb, notifier);
return notifier;
}
void
if_notifier_destroy(struct if_notifier *notifier)
{
if (notifier) {
rtnetlink_notifier_destroy(notifier->notifier);
free(notifier);
}
}
void
if_notifier_run(void)
{
rtnetlink_run();
}
void
if_notifier_wait(void)
{
rtnetlink_wait();
}