Skip to content

Commit

Permalink
[vnetorch]: Bitmap VNet implementation (sonic-net#773)
Browse files Browse the repository at this point in the history
* [vnetorch]: Bitmap VNet implementation
* Adress review comments

Signed-off-by: Marian Pritsak <marianp@mellanox.com>
  • Loading branch information
marian-pritsak authored and prsunny committed Feb 21, 2019
1 parent 920c3a4 commit dd6bdd9
Show file tree
Hide file tree
Showing 8 changed files with 693 additions and 18 deletions.
10 changes: 10 additions & 0 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,11 @@ void IntfsOrch::doTask(Consumer &consumer)
continue;
}

if (m_vnetInfses.find(alias) != m_vnetInfses.end())
{
vnet_name = m_vnetInfses.at(alias);
}

if (!vnet_name.empty())
{
VNetOrch* vnet_orch = gDirectory.get<VNetOrch*>();
Expand All @@ -327,6 +332,11 @@ void IntfsOrch::doTask(Consumer &consumer)
it++;
continue;
}

if (m_vnetInfses.find(alias) == m_vnetInfses.end())
{
m_vnetInfses.emplace(alias, vnet_name);
}
}
else
{
Expand Down
13 changes: 10 additions & 3 deletions orchagent/intfsorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,23 @@ class IntfsOrch : public Orch
void removeRifFromFlexCounter(const string&, const string&);

bool setIntf(const string& alias, sai_object_id_t vrf_id = gVirtualRouterId, const IpPrefix *ip_prefix = nullptr);

void addIp2MeRoute(sai_object_id_t vrf_id, const IpPrefix &ip_prefix);
void removeIp2MeRoute(sai_object_id_t vrf_id, const IpPrefix &ip_prefix);

const IntfsTable& getSyncdIntfses(void)
{
return m_syncdIntfses;
}

private:

SelectableTimer* m_updateMapsTimer = nullptr;
std::vector<Port> m_rifsToAdd;

VRFOrch *m_vrfOrch;
IntfsTable m_syncdIntfses;
map<string, string> m_vnetInfses;
void doTask(Consumer &consumer);
void doTask(SelectableTimer &timer);

Expand All @@ -73,9 +83,6 @@ class IntfsOrch : public Orch
void addSubnetRoute(const Port &port, const IpPrefix &ip_prefix);
void removeSubnetRoute(const Port &port, const IpPrefix &ip_prefix);

void addIp2MeRoute(sai_object_id_t vrf_id, const IpPrefix &ip_prefix);
void removeIp2MeRoute(sai_object_id_t vrf_id, const IpPrefix &ip_prefix);

void addDirectedBroadcast(const Port &port, const IpPrefix &ip_prefix);
void removeDirectedBroadcast(const Port &port, const IpPrefix &ip_prefix);
};
Expand Down
1 change: 1 addition & 0 deletions orchagent/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ sai_object_id_t gVirtualRouterId;
sai_object_id_t gUnderlayIfId;
sai_object_id_t gSwitchId = SAI_NULL_OBJECT_ID;
MacAddress gMacAddress;
MacAddress gVxlanMacAddress;

#define DEFAULT_BATCH_SIZE 128
int gBatchSize = DEFAULT_BATCH_SIZE;
Expand Down
10 changes: 9 additions & 1 deletion orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,15 @@ bool OrchDaemon::init()
APP_VNET_RT_TABLE_NAME,
APP_VNET_RT_TUNNEL_TABLE_NAME
};
VNetOrch *vnet_orch = new VNetOrch(m_applDb, APP_VNET_TABLE_NAME);
VNetOrch *vnet_orch;
if (platform == MLNX_PLATFORM_SUBSTRING)
{
vnet_orch = new VNetOrch(m_applDb, APP_VNET_TABLE_NAME, VNET_EXEC::VNET_EXEC_BRIDGE);
}
else
{
vnet_orch = new VNetOrch(m_applDb, APP_VNET_TABLE_NAME);
}
gDirectory.set(vnet_orch);
VNetRouteOrch *vnet_rt_orch = new VNetRouteOrch(m_applDb, vnet_tables, vnet_orch);
gDirectory.set(vnet_rt_orch);
Expand Down
4 changes: 4 additions & 0 deletions orchagent/saihelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ extern "C" {

#include "sai.h"
#include "saistatus.h"
#include "saiextensions.h"
}

#include <fstream>
Expand Down Expand Up @@ -39,6 +40,7 @@ sai_acl_api_t* sai_acl_api;
sai_mirror_api_t* sai_mirror_api;
sai_fdb_api_t* sai_fdb_api;
sai_dtel_api_t* sai_dtel_api;
sai_bmtor_api_t* sai_bmtor_api;

extern sai_object_id_t gSwitchId;
extern bool gSairedisRecord;
Expand Down Expand Up @@ -127,6 +129,7 @@ void initSaiApi()
sai_api_query(SAI_API_SCHEDULER_GROUP, (void **)&sai_scheduler_group_api);
sai_api_query(SAI_API_ACL, (void **)&sai_acl_api);
sai_api_query(SAI_API_DTEL, (void **)&sai_dtel_api);
sai_api_query((sai_api_t)SAI_API_BMTOR, (void **)&sai_bmtor_api);

sai_log_set(SAI_API_SWITCH, SAI_LOG_LEVEL_NOTICE);
sai_log_set(SAI_API_BRIDGE, SAI_LOG_LEVEL_NOTICE);
Expand All @@ -152,6 +155,7 @@ void initSaiApi()
sai_log_set(SAI_API_SCHEDULER_GROUP, SAI_LOG_LEVEL_NOTICE);
sai_log_set(SAI_API_ACL, SAI_LOG_LEVEL_NOTICE);
sai_log_set(SAI_API_DTEL, SAI_LOG_LEVEL_NOTICE);
sai_log_set((sai_api_t)SAI_API_BMTOR, SAI_LOG_LEVEL_NOTICE);
}

void initSaiRedis(const string &record_location)
Expand Down
2 changes: 2 additions & 0 deletions orchagent/switchorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ using namespace swss;

extern sai_object_id_t gSwitchId;
extern sai_switch_api_t *sai_switch_api;
extern MacAddress gVxlanMacAddress;

const map<string, sai_switch_attr_t> switch_attribute_map =
{
Expand Down Expand Up @@ -100,6 +101,7 @@ void SwitchOrch::doTask(Consumer &consumer)

case SAI_SWITCH_ATTR_VXLAN_DEFAULT_ROUTER_MAC:
mac_addr = value;
gVxlanMacAddress = mac_addr;
memcpy(attr.value.mac, mac_addr.getMac(), sizeof(sai_mac_t));
break;

Expand Down
Loading

0 comments on commit dd6bdd9

Please sign in to comment.