Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrchAgent add more logging #12

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions orchagent/intfsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ IntfsOrch::IntfsOrch(DBConnector *db, string tableName, PortsOrch *portsOrch) :

void IntfsOrch::doTask()
{
SWSS_LOG_ENTER();

if (m_toSync.empty())
return;

Expand Down
12 changes: 12 additions & 0 deletions orchagent/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const char *test_profile_get_value (
_In_ sai_switch_profile_id_t profile_id,
_In_ const char *variable)
{
SWSS_LOG_ENTER();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

short function. no need to add this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's better to know which values sai library is reading.

auto it = gProfileMap.find(variable);

if (it == gProfileMap.end())
Expand All @@ -52,6 +54,8 @@ int test_profile_get_next_value (
_Out_ const char **variable,
_Out_ const char **value)
{
SWSS_LOG_ENTER();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

short function. no need to add this.

return -1;
}

Expand All @@ -65,6 +69,8 @@ sai_switch_notification_t switch_notifications = {

void initSaiApi()
{
SWSS_LOG_ENTER();

sai_api_initialize(0, (service_method_table_t *)&test_services);

sai_api_query(SAI_API_SWITCH, (void **)&sai_switch_api);
Expand Down Expand Up @@ -92,6 +98,8 @@ void initSaiApi()

void initDiagShell()
{
SWSS_LOG_ENTER();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it goes into while true in another thread. no need to have it here.

sai_status_t status;

while (true)
Expand All @@ -111,6 +119,10 @@ void initDiagShell()

int main(int argc, char **argv)
{
swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_DEBUG);

SWSS_LOG_ENTER();

int opt;
sai_status_t status;

Expand Down
6 changes: 6 additions & 0 deletions orchagent/neighorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ extern sai_next_hop_api_t* sai_next_hop_api;

void NeighOrch::doTask()
{
SWSS_LOG_ENTER();

if (m_toSync.empty())
return;

Expand Down Expand Up @@ -86,6 +88,8 @@ void NeighOrch::doTask()

bool NeighOrch::addNeighbor(NeighborEntry neighborEntry, MacAddress macAddress)
{
SWSS_LOG_ENTER();

sai_status_t status;
IpAddress ip_address = neighborEntry.ip_address;
string alias = neighborEntry.alias;
Expand Down Expand Up @@ -152,6 +156,8 @@ bool NeighOrch::addNeighbor(NeighborEntry neighborEntry, MacAddress macAddress)

bool NeighOrch::removeNeighbor(NeighborEntry neighborEntry)
{
SWSS_LOG_ENTER();

sai_status_t status;
IpAddress ip_address = neighborEntry.ip_address;
string alias = neighborEntry.alias;
Expand Down
2 changes: 2 additions & 0 deletions orchagent/orch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ Orch::~Orch()

void Orch::execute()
{
SWSS_LOG_ENTER();

KeyOpFieldsValuesTuple t;
m_consumer->pop(t);

Expand Down
6 changes: 6 additions & 0 deletions orchagent/orchdaemon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ OrchDaemon::~OrchDaemon()

bool OrchDaemon::init()
{
SWSS_LOG_ENTER();

m_applDb = new DBConnector(APPL_DB, "localhost", 6379, 0);

m_portsO = new PortsOrch(m_applDb, APP_PORT_TABLE_NAME);
Expand All @@ -37,6 +39,8 @@ bool OrchDaemon::init()

void OrchDaemon::start()
{
SWSS_LOG_ENTER();

int ret;

m_select->addSelectable(m_portsO->getConsumer());
Expand Down Expand Up @@ -65,6 +69,8 @@ void OrchDaemon::start()

Orch *OrchDaemon::getOrchByConsumer(ConsumerTable *c)
{
SWSS_LOG_ENTER();

if (m_portsO->getConsumer() == c)
return m_portsO;
if (m_intfsO->getConsumer() == c)
Expand Down
16 changes: 16 additions & 0 deletions orchagent/portsorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ extern MacAddress gMacAddress;
PortsOrch::PortsOrch(DBConnector *db, string tableName) :
Orch(db, tableName)
{
SWSS_LOG_ENTER();

int i, j;
sai_status_t status;
sai_attribute_t attr;
Expand Down Expand Up @@ -128,6 +130,8 @@ PortsOrch::PortsOrch(DBConnector *db, string tableName) :

bool PortsOrch::getPort(string alias, Port &p)
{
SWSS_LOG_ENTER();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no need here as the function returns bool and if it is false it always prints out error messages.

if (m_portList.find(alias) == m_portList.end())
return false;
p = m_portList[alias];
Expand All @@ -136,6 +140,8 @@ bool PortsOrch::getPort(string alias, Port &p)

bool PortsOrch::setPortAdminStatus(sai_object_id_t id, bool up)
{
SWSS_LOG_ENTER();

sai_attribute_t attr;
attr.id = SAI_PORT_ATTR_ADMIN_STATE;
attr.value.booldata = up;
Expand All @@ -151,6 +157,8 @@ bool PortsOrch::setPortAdminStatus(sai_object_id_t id, bool up)

void PortsOrch::doTask()
{
SWSS_LOG_ENTER();

if (m_toSync.empty())
return;

Expand Down Expand Up @@ -249,6 +257,8 @@ void PortsOrch::doTask()

bool PortsOrch::initializePort(Port &p)
{
SWSS_LOG_ENTER();

SWSS_LOG_NOTICE("Initializing port alias:%s pid:%llx\n", p.m_alias.c_str(), p.m_port_id);

p.m_vlan_id = FRONT_PANEL_PORT_VLAN_BASE + p.m_index;
Expand Down Expand Up @@ -294,6 +304,8 @@ bool PortsOrch::initializePort(Port &p)

bool PortsOrch::setupVlan(sai_vlan_id_t vlan_id, sai_object_id_t port_id, sai_object_id_t &vlan_member_id)
{
SWSS_LOG_ENTER();

sai_status_t status;

status = sai_vlan_api->create_vlan(vlan_id);
Expand Down Expand Up @@ -336,6 +348,8 @@ bool PortsOrch::setupVlan(sai_vlan_id_t vlan_id, sai_object_id_t port_id, sai_ob
bool PortsOrch::setupRouterIntfs(sai_object_id_t virtual_router_id, MacAddress mac_address,
sai_vlan_id_t vlan_id, sai_object_id_t &router_intfs_id)
{
SWSS_LOG_ENTER();

sai_attribute_t attr;
vector<sai_attribute_t> attrs;

Expand Down Expand Up @@ -367,6 +381,8 @@ bool PortsOrch::setupRouterIntfs(sai_object_id_t virtual_router_id, MacAddress m

bool PortsOrch::setupHostIntfs(sai_object_id_t id, string alias, sai_object_id_t &host_intfs_id)
{
SWSS_LOG_ENTER();

sai_attribute_t attr;
vector<sai_attribute_t> attrs;

Expand Down
22 changes: 22 additions & 0 deletions orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ extern sai_object_id_t gVirtualRouterId;

void RouteOrch::doTask()
{
SWSS_LOG_ENTER();

if (m_toSync.empty())
return;

Expand Down Expand Up @@ -129,12 +131,16 @@ void RouteOrch::doTask()

bool RouteOrch::createNextHopEntry(IpAddress ipAddress, sai_object_id_t nextHopId)
{
SWSS_LOG_ENTER();

IpAddresses ip_addresses(ipAddress.to_string());
return createNextHopEntry(ip_addresses, nextHopId);
}

bool RouteOrch::createNextHopEntry(IpAddresses ipAddresses, sai_object_id_t nextHopGroupId)
{
SWSS_LOG_ENTER();

if (m_syncdNextHops.find(ipAddresses) != m_syncdNextHops.end())
{
SWSS_LOG_ERROR("Failed to create existed next hop entry ip:%s nhid:%llx\n", ipAddresses.to_string().c_str(), nextHopGroupId);
Expand All @@ -150,6 +156,8 @@ bool RouteOrch::createNextHopEntry(IpAddresses ipAddresses, sai_object_id_t next

bool RouteOrch::removeNextHopEntry(IpAddress ipAddress)
{
SWSS_LOG_ENTER();

IpAddresses ip_addresses(ipAddress.to_string());

if (m_syncdNextHops.find(ip_addresses) == m_syncdNextHops.end())
Expand All @@ -170,6 +178,8 @@ bool RouteOrch::removeNextHopEntry(IpAddress ipAddress)

bool RouteOrch::removeNextHopEntry(IpAddresses ipAddresses)
{
SWSS_LOG_ENTER();

if (m_syncdNextHops.find(ipAddresses) == m_syncdNextHops.end())
{
SWSS_LOG_ERROR("Failed to remove absent next hop entry ip:%s\n", ipAddresses.to_string().c_str());
Expand Down Expand Up @@ -203,28 +213,38 @@ bool RouteOrch::removeNextHopEntry(IpAddresses ipAddresses)

int RouteOrch::getNextHopRefCount(IpAddress ipAddress)
{
SWSS_LOG_ENTER();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed for these get functions.

IpAddresses ip_addresses(ipAddress.to_string());
return getNextHopRefCount(ip_addresses);
}

int RouteOrch::getNextHopRefCount(IpAddresses ipAddresses)
{
SWSS_LOG_ENTER();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed for these get functions.

return m_syncdNextHops[ipAddresses].ref_count;
}

NextHopEntry RouteOrch::getNextHopEntry(IpAddress ipAddress)
{
SWSS_LOG_ENTER();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed for these get functions.

IpAddresses ip_addresses(ipAddress.to_string());
return getNextHopEntry(ip_addresses);
}

NextHopEntry RouteOrch::getNextHopEntry(IpAddresses ipAddresses)
{
SWSS_LOG_ENTER();

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not needed for these get functions.

return m_syncdNextHops[ipAddresses];
}

bool RouteOrch::addRoute(IpPrefix ipPrefix, IpAddresses nextHops)
{
SWSS_LOG_ENTER();

/* nhid indicates the next hop id or next hop group id of this route */
sai_object_id_t next_hop_id;
auto it_route = m_syncdRoutes.find(ipPrefix);
Expand Down Expand Up @@ -403,6 +423,8 @@ bool RouteOrch::addRoute(IpPrefix ipPrefix, IpAddresses nextHops)

bool RouteOrch::removeRoute(IpPrefix ipPrefix)
{
SWSS_LOG_ENTER();

sai_unicast_route_entry_t route_entry;
route_entry.vr_id = gVirtualRouterId;
route_entry.destination.addr_family = SAI_IP_ADDR_FAMILY_IPV4;
Expand Down
7 changes: 7 additions & 0 deletions orchagent/routeresync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,24 @@
#include <vector>
#include "dbconnector.h"
#include "producertable.h"
#include "logger.h"

using namespace std;
using namespace swss;

void usage(char **argv)
{
SWSS_LOG_ENTER();

cout << "Usage: " << argv[0] << " [start|stop]" << endl;
}

int main(int argc, char **argv)
{
swss::Logger::getInstance().setMinPrio(swss::Logger::SWSS_DEBUG);

SWSS_LOG_ENTER();

DBConnector db(APPL_DB, "localhost", 6379, 0);
ProducerTable r(&db, APP_ROUTE_TABLE_NAME);

Expand Down