aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPavel Shirshov <pavel.contrib@gmail.com>2020-05-04 12:58:13 -0700
committerJiri Pirko <jiri@mellanox.com>2020-05-11 07:36:07 +0200
commit95037b14e011f236d8b0fbb72e6bf5a88efae101 (patch)
tree39501038315922391bf135d595c87b73ad394149
parent808f4509f9e16e744984939677caa270dce7fa8f (diff)
downloadlibteam-95037b14e011f236d8b0fbb72e6bf5a88efae101.tar.gz
Skip setting the same hwaddr to a lag port if not needed
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 <pavel.contrib@gmail.com> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
-rw-r--r--teamd/teamd.c9
1 files changed, 8 insertions, 1 deletions
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: