@@ -24,6 +24,9 @@ using namespace swss;
2424#define VXLAN " vxlan"
2525#define VXLAN_IF " vxlan_if"
2626
27+ #define SWITCH " switch"
28+ #define VXLAN_ROUTER_MAC " vxlan_router_mac"
29+
2730#define VXLAN_NAME_PREFIX " Vxlan"
2831#define VXLAN_IF_NAME_PREFIX " Brvxlan"
2932
@@ -86,6 +89,16 @@ static int cmdAddVxlanIntoVxlanIf(const swss::VxlanMgr::VxlanInfo & info, std::s
8689 << shellquote (info.m_vxlanIf )
8790 << " "
8891 << shellquote (info.m_vxlan );
92+ if (!info.m_macAddress .empty ())
93+ {
94+ // Change the MAC address of Vxlan bridge interface to ensure it's same with switch's.
95+ // Otherwise it will not response traceroute packets.
96+ // ip link set dev {{VXLAN_IF}} address {{MAC_ADDRESS}}
97+ cmd << " && " IP_CMD " link set dev "
98+ << shellquote (info.m_vxlanIf )
99+ << " address "
100+ << shellquote (info.m_macAddress );
101+ }
89102 return swss::exec (cmd.str (), res);
90103}
91104
@@ -155,6 +168,7 @@ VxlanMgr::VxlanMgr(DBConnector *cfgDb, DBConnector *appDb, DBConnector *stateDb,
155168 Orch(cfgDb, tables),
156169 m_appVxlanTunnelTable(appDb, APP_VXLAN_TUNNEL_TABLE_NAME),
157170 m_appVxlanTunnelMapTable(appDb, APP_VXLAN_TUNNEL_MAP_TABLE_NAME),
171+ m_appSwitchTable(appDb, APP_SWITCH_TABLE_NAME),
158172 m_cfgVxlanTunnelTable(cfgDb, CFG_VXLAN_TUNNEL_TABLE_NAME),
159173 m_cfgVnetTable(cfgDb, CFG_VNET_TABLE_NAME),
160174 m_stateVrfTable(stateDb, STATE_VRF_TABLE_NAME),
@@ -282,6 +296,16 @@ bool VxlanMgr::doVxlanCreateTask(const KeyOpFieldsValuesTuple & t)
282296 // Suspend this message util the vrf is created
283297 return false ;
284298 }
299+
300+ // If the mac address has been set
301+ auto macAddress = getVxlanRouterMacAddress ();
302+ if (macAddress.first )
303+ {
304+ SWSS_LOG_DEBUG (" Mac address is not ready" );
305+ // Suspend this message util the mac address is set
306+ return false ;
307+ }
308+ info.m_macAddress = macAddress.second ;
285309
286310 auto sourceIp = std::find_if (
287311 it->second .begin (),
@@ -432,6 +456,29 @@ bool VxlanMgr::isVxlanStateOk(const std::string & vxlanName)
432456 return false ;
433457}
434458
459+ std::pair<bool , std::string> VxlanMgr::getVxlanRouterMacAddress ()
460+ {
461+ std::vector<FieldValueTuple> temp;
462+
463+ if (m_appSwitchTable.get (SWITCH, temp))
464+ {
465+ auto itr = std::find_if (
466+ temp.begin (),
467+ temp.end (),
468+ [](const FieldValueTuple &fvt) { return fvt.first == VXLAN_ROUTER_MAC; });
469+ if (itr != temp.end () && !(itr->second .empty ()))
470+ {
471+ SWSS_LOG_DEBUG (" Mac address %s is ready" , itr->second .c_str ());
472+ return std::make_pair (true , itr->second );
473+ }
474+ SWSS_LOG_DEBUG (" Mac address will be automatically set" );
475+ return std::make_pair (true , " " );
476+ }
477+
478+ SWSS_LOG_DEBUG (" Mac address is not ready" );
479+ return std::make_pair (false , " " );
480+ }
481+
435482bool VxlanMgr::createVxlan (const VxlanInfo & info)
436483{
437484 SWSS_LOG_ENTER ();
0 commit comments