Skip to content

Commit

Permalink
Fix review comment
Browse files Browse the repository at this point in the history
  • Loading branch information
Junchao-Mellanox committed Apr 12, 2022
1 parent fef7d62 commit 930b021
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 17 deletions.
25 changes: 18 additions & 7 deletions orchagent/flex_counter/flowcounterrouteorch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,6 @@ gRouteBulker(sai_route_api, gMaxBulkSize)
{
SWSS_LOG_ENTER();
initRouteFlowCounterCapability();
if (mRouteFlowCounterSupported)
{
auto intervT = timespec { .tv_sec = FLEX_COUNTER_UPD_INTERVAL , .tv_nsec = 0 };
mFlexCounterUpdTimer = new SelectableTimer(intervT);
auto executorT = new ExecutableTimer(mFlexCounterUpdTimer, this, "FLEX_COUNTER_UPD_TIMER");
Orch::addExecutor(executorT);
}
}

FlowCounterRouteOrch::~FlowCounterRouteOrch()
Expand Down Expand Up @@ -177,9 +170,27 @@ void FlowCounterRouteOrch::initRouteFlowCounterCapability()
capability_table.set(FLOW_COUNTER_ROUTE_KEY, fvs);
}

void FlowCounterRouteOrch::createFlexCounterUpdateTimer()
{
if (!mFlexCounterUpdTimer)
{
auto intervT = timespec { .tv_sec = FLEX_COUNTER_UPD_INTERVAL , .tv_nsec = 0 };
mFlexCounterUpdTimer = new SelectableTimer(intervT);
auto executorT = new ExecutableTimer(mFlexCounterUpdTimer, this, "FLEX_COUNTER_UPD_TIMER");
Orch::addExecutor(executorT);
}
}

void FlowCounterRouteOrch::generateRouteFlowStats()
{
SWSS_LOG_ENTER();
if (!mRouteFlowCounterSupported)
{
return;
}

createFlexCounterUpdateTimer();

for (const auto &route_pattern : mRoutePatternSet)
{
createRouteFlowCounterByPattern(route_pattern, 0);
Expand Down
1 change: 1 addition & 0 deletions orchagent/flex_counter/flowcounterrouteorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class FlowCounterRouteOrch : public Orch

EntityBulker<sai_route_api_t> gRouteBulker;

void createFlexCounterUpdateTimer();
void initRouteFlowCounterCapability();
void removeRoutePattern(const RoutePattern &route_pattern);
void removeRouteFlowCounterFromDB(sai_object_id_t vrf_id, const IpPrefix& ip_prefix, sai_object_id_t counter_oid);
Expand Down
4 changes: 0 additions & 4 deletions orchagent/routeorch.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
#include <assert.h>
#include <inttypes.h>
#include <algorithm>
#include <sstream>
#include <list>
#include "routeorch.h"
#include "nhgorch.h"
#include "cbf/cbfnhgorch.h"
#include "flexcounterorch.h"
#include "logger.h"
#include "flowcounterrouteorch.h"
#include "swssnet.h"
#include "crmorch.h"
#include "directory.h"
#include "timer.h"

extern sai_object_id_t gVirtualRouterId;
extern sai_object_id_t gSwitchId;
Expand Down
2 changes: 1 addition & 1 deletion orchagent/routeorch.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,6 @@ struct LabelRouteBulkContext
}
};


class RouteOrch : public Orch, public Subject
{
public:
Expand Down Expand Up @@ -215,6 +214,7 @@ class RouteOrch : public Orch, public Subject

unsigned int getNhgCount() { return m_nextHopGroupCount; }
unsigned int getMaxNhgCount() { return m_maxNextHopGroupCount; }

void increaseNextHopGroupCount();
void decreaseNextHopGroupCount();
bool checkNextHopGroupCount();
Expand Down
6 changes: 3 additions & 3 deletions orchagent/swssnet.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ inline static sai_ip_prefix_t& copy(sai_ip_prefix_t& dst, const IpAddress& src)
return dst;
}

static int getPrefixLenFromAddr(const uint8_t *addr, int len)
static int getPrefixLenFromAddrMask(const uint8_t *addr, int len)
{
int i = 0;
uint8_t non_zero = 0xFF;
Expand Down Expand Up @@ -114,11 +114,11 @@ inline static IpPrefix convert(const sai_ip_prefix_t& src)
case SAI_IP_ADDR_FAMILY_IPV4:
ip.family = AF_INET;
ip.ip_addr.ipv4_addr = src.addr.ip4;
return IpPrefix(ip, getPrefixLenFromAddr(reinterpret_cast<const uint8_t*>(&src.mask.ip4), 4));
return IpPrefix(ip, getPrefixLenFromAddrMask(reinterpret_cast<const uint8_t*>(&src.mask.ip4), 4));
case SAI_IP_ADDR_FAMILY_IPV6:
ip.family = AF_INET6;
memcpy(ip.ip_addr.ipv6_addr, src.addr.ip6, 16);
return IpPrefix(ip, getPrefixLenFromAddr(src.mask.ip6, 16));
return IpPrefix(ip, getPrefixLenFromAddrMask(src.mask.ip6, 16));
default:
throw std::logic_error("Invalid family");
}
Expand Down
2 changes: 0 additions & 2 deletions orchagent/vrforch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include "request_parser.h"
#include "vrforch.h"
#include "vxlanorch.h"
#include "routeorch.h"
#include "flowcounterrouteorch.h"
#include "directory.h"

Expand All @@ -23,7 +22,6 @@ extern sai_object_id_t gSwitchId;

extern Directory<Orch*> gDirectory;
extern PortsOrch* gPortsOrch;
extern RouteOrch* gRouteOrch;
extern FlowCounterRouteOrch* gFlowCounterRouteOrch;

bool VRFOrch::addOperation(const Request& request)
Expand Down

0 comments on commit 930b021

Please sign in to comment.