xref: /OK3568_Linux_fs/buildroot/package/libteam/0001-revert-disregard-current-state.patch (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1From 61efd6de2fbb8ee077863ee5a355ac3dfd9365b9 Mon Sep 17 00:00:00 2001
2From: Xin Long <lucien.xin@gmail.com>
3Date: Tue, 1 Sep 2020 13:59:27 +0800
4Subject: [PATCH] Revert "teamd: Disregard current state when considering port
5 enablement"
6
7This reverts commit deadb5b715227429a1879b187f5906b39151eca9.
8
9As Patrick noticed, with that commit, teamd_port_check_enable()
10would set the team port to the new state unconditionally, which
11triggers another change message from kernel to userspace, then
12teamd_port_check_enable() is called again to set the team port
13to the new state.
14
15This would go around and around to update the team port state,
16and even cause teamd to consume 100% cpu.
17
18As the issue caused by that commit is serious, it has to be
19reverted. As for the issued fixed by that commit, I would
20propose a new fix later.
21
22Signed-off-by: Jiri Pirko <jiri@nvidia.com>
23---
24 teamd/teamd_per_port.c | 8 ++++++--
25 1 file changed, 6 insertions(+), 2 deletions(-)
26
27diff --git a/teamd/teamd_per_port.c b/teamd/teamd_per_port.c
28index 166da57..d429753 100644
29--- a/teamd/teamd_per_port.c
30+++ b/teamd/teamd_per_port.c
31@@ -442,14 +442,18 @@ int teamd_port_check_enable(struct teamd_context *ctx,
32 			    bool should_enable, bool should_disable)
33 {
34 	bool new_enabled_state;
35+	bool curr_enabled_state;
36 	int err;
37
38 	if (!teamd_port_present(ctx, tdport))
39 		return 0;
40+	err = teamd_port_enabled(ctx, tdport, &curr_enabled_state);
41+	if (err)
42+		return err;
43
44-	if (should_enable)
45+	if (!curr_enabled_state && should_enable)
46 		new_enabled_state = true;
47-	else if (should_disable)
48+	else if (curr_enabled_state && should_disable)
49 		new_enabled_state = false;
50 	else
51 		return 0;
52