Skip to content

Commit b57c376

Browse files
Shuotian Chenglguohan
Shuotian Cheng
authored andcommitted
[teamsyncd]: Add team_ifindex2ifname return value check (#500)
Without the return value check, it is possible that ifname is empty due to interface not found. Signed-off-by: Shu0T1an ChenG <[email protected]>
1 parent 236843f commit b57c376

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

teamsyncd/teamsync.cpp

+9-1
Original file line numberDiff line numberDiff line change
@@ -160,11 +160,19 @@ int TeamSync::TeamPortSync::onChange()
160160
bool enabled;
161161

162162
ifindex = team_get_port_ifindex(port);
163-
team_ifindex2ifname(m_team, ifindex, ifname, MAX_IFNAME);
163+
164+
/* Skip if interface is not found */
165+
if (!team_ifindex2ifname(m_team, ifindex, ifname, MAX_IFNAME))
166+
{
167+
SWSS_LOG_INFO("Interface ifindex(%u) is not found", ifindex);
168+
continue;
169+
}
164170

165171
/* Skip the member that is removed from the LAG */
166172
if (team_is_port_removed(port))
173+
{
167174
continue;
175+
}
168176

169177
team_get_port_enabled(m_team, ifindex, &enabled);
170178
tmp_lag_members[string(ifname)] = enabled;

0 commit comments

Comments
 (0)