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