Skip to content

Commit

Permalink
[teamsyncd]: Add team_ifindex2ifname return value check (sonic-net#500)
Browse files Browse the repository at this point in the history
Without the return value check, it is possible that ifname is
empty due to interface not found.

Signed-off-by: Shu0T1an ChenG <shuche@microsoft.com>
  • Loading branch information
Shuotian Cheng authored and yangbashuang committed May 12, 2018
1 parent 87da9b2 commit 1b774a1
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion teamsyncd/teamsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,19 @@ int TeamSync::TeamPortSync::onChange()
bool enabled;

ifindex = team_get_port_ifindex(port);
team_ifindex2ifname(m_team, ifindex, ifname, MAX_IFNAME);

/* Skip if interface is not found */
if (!team_ifindex2ifname(m_team, ifindex, ifname, MAX_IFNAME))
{
SWSS_LOG_INFO("Interface ifindex(%u) is not found", ifindex);
continue;
}

/* Skip the member that is removed from the LAG */
if (team_is_port_removed(port))
{
continue;
}

team_get_port_enabled(m_team, ifindex, &enabled);
tmp_lag_members[string(ifname)] = enabled;
Expand Down

0 comments on commit 1b774a1

Please sign in to comment.