Skip to content

Commit

Permalink
Merge branch 'master' into eni_cntrs
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekrnv authored Nov 1, 2024
2 parents ab7bf71 + 368e1d6 commit 26d332c
Show file tree
Hide file tree
Showing 13 changed files with 81 additions and 29 deletions.
6 changes: 3 additions & 3 deletions fdbsyncd/fdbsyncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ int main(int argc, char **argv)
{
Logger::linkToDbNative("fdbsyncd");

DBConnector appDb(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector appDb("APPL_DB", 0);
RedisPipeline pipelineAppDB(&appDb);
DBConnector stateDb(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector config_db(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector stateDb("STATE_DB", 0);
DBConnector config_db("CONFIG_DB", 0);

FdbSync sync(&pipelineAppDB, &stateDb, &config_db);

Expand Down
2 changes: 1 addition & 1 deletion gearsyncd/gearparserbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ GearParserBase::init()
{
m_writeToDb = false;
m_rootInit = false;
m_applDb = std::unique_ptr<swss::DBConnector>{new swss::DBConnector(APPL_DB, swss::DBConnector::DEFAULT_UNIXSOCKET, 0)};
m_applDb = std::unique_ptr<swss::DBConnector>{new swss::DBConnector("APPL_DB", 0)};
m_producerStateTable = std::unique_ptr<swss::ProducerStateTable>{new swss::ProducerStateTable(m_applDb.get(), APP_GEARBOX_TABLE_NAME)};
}

Expand Down
4 changes: 2 additions & 2 deletions gearsyncd/gearsyncd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ int main(int argc, char **argv)
}
}

DBConnector cfgDb(CONFIG_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector applDb(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector cfgDb("CONFIG_DB", 0);
DBConnector applDb("APPL_DB", 0);
ProducerStateTable producerStateTable(&applDb, APP_GEARBOX_TABLE_NAME);

WarmStart::initialize("gearsyncd", "swss");
Expand Down
49 changes: 40 additions & 9 deletions orchagent/dash/dashorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ using namespace swss;

extern Directory<Orch*> gDirectory;
extern std::unordered_map<std::string, sai_object_id_t> gVnetNameToId;
extern sai_dash_appliance_api_t* sai_dash_appliance_api;
extern sai_dash_vip_api_t* sai_dash_vip_api;
extern sai_dash_direction_lookup_api_t* sai_dash_direction_lookup_api;
extern sai_dash_eni_api_t* sai_dash_eni_api;
Expand Down Expand Up @@ -95,15 +96,31 @@ bool DashOrch::addApplianceEntry(const string& appliance_id, const dash::applian
}

uint32_t attr_count = 1;
sai_attribute_t appliance_attr;
sai_status_t status;

// NOTE: DASH Appliance object should be the first object pushed to SAI
sai_object_id_t sai_appliance_id = 0UL;
appliance_attr.id = SAI_DASH_APPLIANCE_ATTR_LOCAL_REGION_ID;
appliance_attr.value.u32 = entry.local_region_id();
status = sai_dash_appliance_api->create_dash_appliance(&sai_appliance_id, gSwitchId,
attr_count, &appliance_attr);
if (status != SAI_STATUS_SUCCESS && status != SAI_STATUS_NOT_IMPLEMENTED)
{
SWSS_LOG_ERROR("Failed to create dash appliance object in SAI for %s", appliance_id.c_str());
task_process_status handle_status = handleSaiCreateStatus((sai_api_t) SAI_API_DASH_APPLIANCE, status);
if (handle_status != task_success)
{
return parseHandleSaiStatusFailure(handle_status);
}
}

sai_vip_entry_t vip_entry;
vip_entry.switch_id = gSwitchId;
if (!to_sai(entry.sip(), vip_entry.vip))
{
return false;
}
sai_attribute_t appliance_attr;
vector<sai_attribute_t> appliance_attrs;
sai_status_t status;
appliance_attr.id = SAI_VIP_ENTRY_ATTR_ACTION;
appliance_attr.value.u32 = SAI_VIP_ENTRY_ACTION_ACCEPT;
status = sai_dash_vip_api->create_vip_entry(&vip_entry, attr_count, &appliance_attr);
Expand Down Expand Up @@ -132,8 +149,8 @@ bool DashOrch::addApplianceEntry(const string& appliance_id, const dash::applian
return parseHandleSaiStatusFailure(handle_status);
}
}
appliance_entries_[appliance_id] = entry;
SWSS_LOG_NOTICE("Created vip and direction lookup entries for %s", appliance_id.c_str());
appliance_entries_[appliance_id] = ApplianceEntry { sai_appliance_id, entry };
SWSS_LOG_NOTICE("Created appliance, vip and direction lookup entries for %s", appliance_id.c_str());

return true;
}
Expand All @@ -143,15 +160,14 @@ bool DashOrch::removeApplianceEntry(const string& appliance_id)
SWSS_LOG_ENTER();

sai_status_t status;
dash::appliance::Appliance entry;

if (appliance_entries_.find(appliance_id) == appliance_entries_.end())
{
SWSS_LOG_WARN("Appliance id does not exist: %s", appliance_id.c_str());
return true;
}

entry = appliance_entries_[appliance_id];
const auto& entry = appliance_entries_[appliance_id].metadata;
sai_vip_entry_t vip_entry;
vip_entry.switch_id = gSwitchId;
if (!to_sai(entry.sip(), vip_entry.vip))
Expand Down Expand Up @@ -182,8 +198,23 @@ bool DashOrch::removeApplianceEntry(const string& appliance_id)
return parseHandleSaiStatusFailure(handle_status);
}
}

auto sai_appliance_id = appliance_entries_[appliance_id].appliance_id;
if (sai_appliance_id != 0UL)
{
status = sai_dash_appliance_api->remove_dash_appliance(sai_appliance_id);
if (status != SAI_STATUS_SUCCESS && status != SAI_STATUS_NOT_IMPLEMENTED)
{
SWSS_LOG_ERROR("Failed to remove dash appliance object in SAI for %s", appliance_id.c_str());
task_process_status handle_status = handleSaiRemoveStatus((sai_api_t) SAI_API_DASH_APPLIANCE, status);
if (handle_status != task_success)
{
return parseHandleSaiStatusFailure(handle_status);
}
}
}
appliance_entries_.erase(appliance_id);
SWSS_LOG_NOTICE("Removed vip and direction lookup entries for %s", appliance_id.c_str());
SWSS_LOG_NOTICE("Removed appliance, vip and direction lookup entries for %s", appliance_id.c_str());

return true;
}
Expand Down Expand Up @@ -412,7 +443,7 @@ bool DashOrch::addEniObject(const string& eni, EniEntry& entry)
eni_attrs.push_back(eni_attr);

eni_attr.id = SAI_ENI_ATTR_VM_VNI;
auto app_entry = appliance_entries_.begin()->second;
auto& app_entry = appliance_entries_.begin()->second.metadata;
eni_attr.value.u32 = app_entry.vm_vni();
eni_attrs.push_back(eni_attr);

Expand Down
8 changes: 7 additions & 1 deletion orchagent/dash/dashorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ struct EniEntry
dash::eni::Eni metadata;
};

typedef std::map<std::string, dash::appliance::Appliance> ApplianceTable;
struct ApplianceEntry
{
sai_object_id_t appliance_id;
dash::appliance::Appliance metadata;
};

typedef std::map<std::string, ApplianceEntry> ApplianceTable;
typedef std::map<dash::route_type::RoutingType, dash::route_type::RouteType> RoutingTypeTable;
typedef std::map<std::string, EniEntry> EniTable;
typedef std::map<std::string, dash::qos::Qos> QosTable;
Expand Down
2 changes: 1 addition & 1 deletion orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9094,7 +9094,7 @@ bool PortsOrch::addSystemPorts()
vector<string> keys;
vector<FieldValueTuple> spFv;

DBConnector appDb(APPL_DB, DBConnector::DEFAULT_UNIXSOCKET, 0);
DBConnector appDb("APPL_DB", 0);
Table appSystemPortTable(&appDb, APP_SYSTEM_PORT_TABLE_NAME);

//Retrieve system port configurations from APP DB
Expand Down
8 changes: 8 additions & 0 deletions orchagent/rif_rates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,21 @@ for i = 1, n do
local out_octets = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS')
local out_pkts = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS')

if not in_octets or not in_pkts or not out_octets or not out_pkts then
return logtable
end

if initialized == "DONE" or initialized == "COUNTERS_LAST" then
-- Get old COUNTERS values
local in_octets_last = redis.call('HGET', rates_table_name .. ':' .. KEYS[i], 'SAI_ROUTER_INTERFACE_STAT_IN_OCTETS_last')
local in_pkts_last = redis.call('HGET', rates_table_name .. ':' .. KEYS[i], 'SAI_ROUTER_INTERFACE_STAT_IN_PACKETS_last')
local out_octets_last = redis.call('HGET', rates_table_name .. ':' .. KEYS[i], 'SAI_ROUTER_INTERFACE_STAT_OUT_OCTETS_last')
local out_pkts_last = redis.call('HGET', rates_table_name .. ':' .. KEYS[i], 'SAI_ROUTER_INTERFACE_STAT_OUT_PACKETS_last')

if not in_octets_last or not in_pkts_last or not out_octets_last or not out_pkts_last then
return logtable
end

-- Calculate new rates values
local rx_bps_new = (in_octets - in_octets_last) / delta * 1000
local tx_bps_new = (out_octets - out_octets_last) / delta * 1000
Expand Down
2 changes: 2 additions & 0 deletions orchagent/saihelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ sai_counter_api_t* sai_counter_api;
sai_bfd_api_t* sai_bfd_api;
sai_my_mac_api_t* sai_my_mac_api;
sai_generic_programmable_api_t* sai_generic_programmable_api;
sai_dash_appliance_api_t* sai_dash_appliance_api;
sai_dash_acl_api_t* sai_dash_acl_api;
sai_dash_vnet_api_t sai_dash_vnet_api;
sai_dash_outbound_ca_to_pa_api_t* sai_dash_outbound_ca_to_pa_api;
Expand Down Expand Up @@ -221,6 +222,7 @@ void initSaiApi()
sai_api_query(SAI_API_BFD, (void **)&sai_bfd_api);
sai_api_query(SAI_API_MY_MAC, (void **)&sai_my_mac_api);
sai_api_query(SAI_API_GENERIC_PROGRAMMABLE, (void **)&sai_generic_programmable_api);
sai_api_query((sai_api_t)SAI_API_DASH_APPLIANCE, (void**)&sai_dash_appliance_api);
sai_api_query((sai_api_t)SAI_API_DASH_ACL, (void**)&sai_dash_acl_api);
sai_api_query((sai_api_t)SAI_API_DASH_VNET, (void**)&sai_dash_vnet_api);
sai_api_query((sai_api_t)SAI_API_DASH_OUTBOUND_CA_TO_PA, (void**)&sai_dash_outbound_ca_to_pa_api);
Expand Down
4 changes: 2 additions & 2 deletions orchagent/switchorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,10 @@ SwitchOrch::SwitchOrch(DBConnector *db, vector<TableConnector>& connectors, Tabl
Orch(connectors),
m_switchTable(switchTable.first, switchTable.second),
m_db(db),
m_stateDb(new DBConnector(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)),
m_stateDb(new DBConnector("STATE_DB", 0)),
m_asicSensorsTable(new Table(m_stateDb.get(), ASIC_TEMPERATURE_INFO_TABLE_NAME)),
m_sensorsPollerTimer (new SelectableTimer((timespec { .tv_sec = DEFAULT_ASIC_SENSORS_POLLER_INTERVAL, .tv_nsec = 0 }))),
m_stateDbForNotification(new DBConnector(STATE_DB, DBConnector::DEFAULT_UNIXSOCKET, 0)),
m_stateDbForNotification(new DBConnector("STATE_DB", 0)),
m_asicSdkHealthEventTable(new Table(m_stateDbForNotification.get(), STATE_ASIC_SDK_HEALTH_EVENT_TABLE_NAME))
{
m_restartCheckNotificationConsumer = new NotificationConsumer(db, "RESTARTCHECK");
Expand Down
3 changes: 2 additions & 1 deletion orchagent/trap_rates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ for i = 1, n do
logit(initialized)

-- Get new COUNTERS values
local in_pkts = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_COUNTER_STAT_PACKETS')
local in_pkts_str = redis.call('HGET', counters_table_name .. ':' .. KEYS[i], 'SAI_COUNTER_STAT_PACKETS')
local in_pkts = tonumber(in_pkts_str) or 0

if initialized == 'DONE' or initialized == 'COUNTERS_LAST' then
-- Get old COUNTERS values
Expand Down
5 changes: 3 additions & 2 deletions tests/dash/dash_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"sip": {
"ipv4": socket.htonl(int(IP(SIP)))
},
"vm_vni": int(VM_VNI)
"vm_vni": int(VM_VNI),
"local_region_id": 10
}

VNET_CONFIG = {
Expand Down Expand Up @@ -168,4 +169,4 @@

ENI_ROUTE_GROUP2_CONFIG = {
"group_id": ROUTE_GROUP2,
}
}
1 change: 1 addition & 0 deletions tests/dash/test_dash_vnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def test_appliance(self, dash_db: DashDB):
self.appliance_id = "100"
self.sip = "10.0.0.1"
self.vm_vni = "4321"
self.local_region_id = "10"
pb = Appliance()
pb.sip.ipv4 = socket.htonl(int(ipaddress.ip_address(self.sip)))
pb.vm_vni = int(self.vm_vni)
Expand Down
16 changes: 9 additions & 7 deletions tlm_teamd/values_store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,14 @@ void ValuesStore::remove_keys_db(const std::vector<std::string> & keys)
const auto & p = split_key(key);
const auto & table_name = p.first;
const auto & table_key = p.second;
// Do not delete te key from State Db for table LAB_TABLE. LAB_TABLE entry is created/deleted
// from teamsyncd on detecting netlink of teamd dev as up/down. For some reason
// if we do not get state dump from teamdctl it might be transient issue. If it is
// persistent issue then teamsyncd might be able to catch it and delete state db entry
// or we can keep entry in it's current state as best effort. Similar to try_add_lag which is best effort
// to connect to teamdctl and if it fails we do not delete State Db entry.
if (table_name == "LAG_TABLE")
continue;
swss::Table table(m_db, table_name);
table.del(table_key);
}
Expand Down Expand Up @@ -366,13 +374,7 @@ void ValuesStore::update(const std::vector<StringPair> & dumps)
{
const auto & storage = from_json(dumps);
const auto & old_keys = get_old_keys(storage);
// Do not delete te key from State Db. State DB LAB_TABLE entry is created/deleted
// from teamsyncd on detecting netlink of teamd dev as up/down. For some reason
// if we do not get state dump from teamdctl it might be transient issue. If it is
// persistent issue then teamsyncd might be able to catch it and delete state db entry
// or we can keep entry in it's current state as best effort. Similar to try_add_lag which is best effort
// to connect to teamdctl and if it fails we do not delete State Db entry.
//remove_keys_db(old_keys);
remove_keys_db(old_keys);
remove_keys_storage(old_keys);
const auto & keys_to_refresh = update_storage(storage);
update_db(storage, keys_to_refresh);
Expand Down

0 comments on commit 26d332c

Please sign in to comment.