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 lguohan committed May 10, 2018
1 parent 477d124 commit eef687e
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 eef687e

Please sign in to comment.