Skip to content

Commit

Permalink
Set LAG mtu value based on kernel netlink msg (sonic-net#922)
Browse files Browse the repository at this point in the history
* Update mtu value based on kernel netlink msg

* Push the calculated MTU size into the fvVector
  • Loading branch information
prsunny authored and yxieca committed Jun 4, 2019
1 parent 348e4b2 commit 819a122
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
11 changes: 7 additions & 4 deletions teamsyncd/teamsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -114,24 +114,27 @@ void TeamSync::onMsg(int nlmsg_type, struct nl_object *obj)
return;
}

unsigned int mtu = rtnl_link_get_mtu(link);
addLag(lagName, rtnl_link_get_ifindex(link),
rtnl_link_get_flags(link) & IFF_UP,
rtnl_link_get_flags(link) & IFF_LOWER_UP);
rtnl_link_get_flags(link) & IFF_LOWER_UP, mtu);
}

void TeamSync::addLag(const string &lagName, int ifindex, bool admin_state,
bool oper_state)
bool oper_state, unsigned int mtu)
{
/* Set the LAG */
std::vector<FieldValueTuple> fvVector;
FieldValueTuple a("admin_status", admin_state ? "up" : "down");
FieldValueTuple o("oper_status", oper_state ? "up" : "down");
FieldValueTuple m("mtu", to_string(mtu));
fvVector.push_back(a);
fvVector.push_back(o);
fvVector.push_back(m);
m_lagTable.set(lagName, fvVector);

SWSS_LOG_INFO("Add %s admin_status:%s oper_status:%s",
lagName.c_str(), admin_state ? "up" : "down", oper_state ? "up" : "down");
SWSS_LOG_INFO("Add %s admin_status:%s oper_status:%s, mtu: %d",
lagName.c_str(), admin_state ? "up" : "down", oper_state ? "up" : "down", mtu);

/* Return when the team instance has already been tracked */
if (m_teamSelectables.find(lagName) != m_teamSelectables.end())
Expand Down
2 changes: 1 addition & 1 deletion teamsyncd/teamsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class TeamSync : public NetMsg

protected:
void addLag(const std::string &lagName, int ifindex, bool admin_state,
bool oper_state);
bool oper_state, unsigned int mtu);
void removeLag(const std::string &lagName);

/* valid only in WR mode */
Expand Down

0 comments on commit 819a122

Please sign in to comment.