From 99e4891392d7377224154cb1ad593d4806684152 Mon Sep 17 00:00:00 2001 From: Sandeep Kulambi Date: Tue, 5 Nov 2019 01:57:28 -0800 Subject: [PATCH] Use port-channel id as LACP key so that multiple port-channels from the peer can be distinguished --- cfgmgr/teammgr.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/cfgmgr/teammgr.cpp b/cfgmgr/teammgr.cpp index 2149e1ce5f..b0e60a56ed 100644 --- a/cfgmgr/teammgr.cpp +++ b/cfgmgr/teammgr.cpp @@ -447,12 +447,26 @@ task_process_status TeamMgr::addLagMember(const string &lag, const string &membe stringstream cmd; string res; + string PoId, PoId2; + size_t found = lag.find('l'); + if (found == string::npos) + { + SWSS_LOG_ERROR("Failed to parse %s", lag.c_str()); + return task_failed; + } + PoId = lag.substr(found+1); + /* Ignore all 0's in the Port-channel id*/ + PoId2 = PoId.erase(0, min(PoId.find_first_not_of('0'), PoId.size()-1)); // Set admin down LAG member (required by teamd) and enslave it // ip link set dev down; // teamdctl port add ; cmd << IP_CMD << " link set dev " << shellquote(member) << " down; "; - cmd << TEAMDCTL_CMD << " " << shellquote(lag) << " port add " << shellquote(member); + cmd << TEAMDCTL_CMD << " " << shellquote(lag) << " port config update " << shellquote(member) + << " '{\"lacp_key\":" + << shellquote(PoId2) + << ",\"link_watch\": {\"name\": \"ethtool\"} }'; "; + cmd << TEAMDCTL_CMD << " " << shellquote(lag) << " port add " << shellquote(member) << ";"; if (exec(cmd.str(), res) != 0) {