5 #ifndef vnsw_agent_session_stats_collector_h
6 #define vnsw_agent_session_stats_collector_h
18 #define SESSION_STATS_TRACE(obj, ...)\
20 SessionStats##obj::TraceMsg(SessionStatsTraceBuf, __FILE__, __LINE__, __VA_ARGS__);\
205 #define CheckFlowLogging(logged) { \
215 bool SampleSession(SessionPreAggInfo::SessionMap::iterator session_map_iter,
218 (SessionPreAggInfo::SessionMap::iterator session_map_iter,
221 (SessionPreAggInfo::SessionMap::iterator session_map_iter,
225 uint64_t k_flow_bytes)
const;
227 uint64_t k_flow_pkts)
const;
229 (SessionPreAggInfo::SessionMap::iterator session_map_iter,
230 SessionInfo *session_info,
bool is_sampling,
bool is_logging)
const;
232 SessionFlowInfo *flow_info,
234 bool is_logging)
const;
238 SessionFlowInfo *flow_info)
const;
245 SessionAggInfo *agg_info,
246 bool is_sampling,
bool is_logging)
const;
248 (SessionPreAggInfo::SessionMap::iterator session_map_iter,
250 SessionIpPort *session_key,
bool is_sampling,
bool is_logging)
const;
252 (SessionPreAggInfo::SessionMap::iterator session_map_iter,
254 SessionIpPort *session_key,
256 bool read_flow,
bool is_sampling,
bool is_logging)
const;
258 SessionIpPortProtocol *session_agg_key)
const;
260 SessionEndpoint *session_ep)
const;
270 uint64_t teardown_time,
275 uint32_t oflow_bytes,
292 uint32_t oflow_bytes,
302 const std::string &match_uuid,
305 const std::string &policy_uuid,
306 const bool &deleted_flag,
308 const bool &exported_once);
310 const std::string &fw_policy_uuid,
311 const std::string &nw_policy_uuid,
312 const std::string &sg_policy_uuid,
313 const bool &deleted_flag,
315 const bool &exported_once);
318 std::string &fw_policy_uuid,
319 std::string &nw_policy_uuid,
320 std::string &sg_policy_uuid);
323 std::string& fw_policy_uuid,
324 std::string& nw_policy_uuid,
325 std::string& sg_policy_uuid);
329 const std::string& fw_policy_uuid,
330 const std::string& nw_policy_uuid,
331 const std::string& sg_policy_uuid,
332 const bool &deleted_flag,
334 const bool &exported_once);
348 const bool &exported_once);
353 const bool &exported_once);
368 const std::vector<autogen::SecurityLoggingObjectRuleEntryType> &list,
378 SessionPreAggInfo::SessionMap::iterator session_map_iter);
516 #endif //vnsw_agent_session_stats_collector_h
bool FlowLogging(const SessionStatsInfo &stats_info, const FlowEntry *fe, bool *logged, const bool &exported_once)
FlowEntry * reverse_flow() const
uint8_t GetSessionMsgIdx()
uint64_t GetUpdatedSessionFlowBytes(uint64_t info_bytes, uint64_t k_flow_bytes) const
SessionAggKey session_agg_key_
void UpdateSessionSloStateRuleEntry(std::string uuid, int rate)
SessionEndpointKey session_endpoint_key()
std::map< const SessionAggKey, SessionPreAggInfo, SessionAggKeyCmp > SessionAggMap
bool GetSessionKey(FlowEntry *fe, SessionAggKey &session_agg_key, SessionKey &session_key, SessionEndpointKey &session_endpoint_key)
bool IsEqual(const SessionEndpointKey &rhs) const
bool IsSamplingEnabled() const
void GetPolicyIdFromDeletedFlow(const SessionFlowExportInfo &flow_info, std::string &fw_policy_uuid, std::string &nw_policy_uuid, std::string &sg_policy_uuid)
uint8_t session_msg_index_
bool SampleSession(SessionPreAggInfo::SessionMap::iterator session_map_iter, SessionStatsParams *params) const
AgentUveBase * agent_uve_
SessionStatsCollector * ssc_
std::vector< SessionEndpoint > session_msg_list_
bool HandleDeletedFlowLogging(const SessionStatsInfo &stats_info)
boost::shared_ptr< SessionStatsCollector > SessionStatsCollectorPtr
void SetExpiryTime(int time)
SessionKey session_iteration_key_
int ComputeSloRate(int rate, SecurityLoggingObject *slo) const
uint32_t instance_id() const
SessionFlowStatsParams rev_flow
void GetPolicyIdFromFlow(const FlowEntry *fe, std::string &fw_policy_uuid, std::string &nw_policy_uuid, std::string &sg_policy_uuid)
bool IsEqual(FlowToSessionMap &rhs)
void UpdateSessionStatsEvent(const FlowEntryPtr &flow, uint32_t bytes, uint32_t packets, uint32_t oflow_bytes, const boost::uuids::uuid &u)
void BuildSloList(const SessionStatsInfo &stats_info, const FlowEntry *fe, SessionSloRuleMap *global_session_slo_rule_map, SessionSloRuleMap *vmi_session_slo_rule_map, SessionSloRuleMap *vn_session_slo_rule_map)
FlowToSessionMap(SessionKey &session_key, SessionAggKey &session_agg_key, SessionEndpointKey &session_endpoint_key)
std::map< std::string, SessionSloRuleEntry > SessionSloRuleMap
DBTable::ListenerId slo_listener_id_
bool SessionStatsChangedLocked(SessionPreAggInfo::SessionMap::iterator session_map_iter, SessionStatsParams *params) const
boost::asio::ip::address IpAddress
DISALLOW_COPY_AND_ASSIGN(SessionStatsCollector)
SessionStatsReq(Event ev, const FlowEntryPtr &flow, uint64_t time, const RevFlowDepParams &p)
static const uint32_t kSessionsPerTask
void AddSloRules(const std::vector< autogen::SecurityLoggingObjectRuleEntryType > &list, SecurityLoggingObject *slo, SessionSloRuleMap *slo_rule_map)
virtual void DispatchSessionMsg(const std::vector< SessionEndpoint > &lst)
static const uint32_t kSessionStatsTimerInterval
void DeleteSession(FlowEntry *fe, const boost::uuids::uuid &del_uuid, uint64_t teardown_time, const RevFlowDepParams *params)
SessionStatsCollectorObject * parent_
SessionStatsCollector(boost::asio::io_context &io, AgentUveBase *uve, uint32_t instance_id, FlowStatsManager *fsm, SessionStatsCollectorObject *obj)
void FillSessionEvictStats(SessionPreAggInfo::SessionMap::iterator session_map_iter, SessionInfo *session_info, bool is_sampling, bool is_logging) const
void FillSessionInfoUnlocked(SessionPreAggInfo::SessionMap::iterator session_map_iter, const SessionStatsParams &stats, SessionInfo *session_info, SessionIpPort *session_key, const RevFlowDepParams *params, bool read_flow, bool is_sampling, bool is_logging) const
void UpdateAggregateStats(const SessionInfo &sinfo, SessionAggInfo *agg_info, bool is_sampling, bool is_logging) const
bool Run()
Code to execute. Returns true if task is completed. Return false to reschedule the task...
uint64_t session_task_starts_
bool CheckPolicyMatch(const SessionSloRuleMap &map, const std::string &policy_uuid, const bool &deleted_flag, bool *match, const bool &exported_once)
SessionEndpointKey session_ep_iteration_key_
uint32_t session_ep_visited_
WorkQueue< boost::shared_ptr< SessionStatsReq > > Queue
SessionStatsReq(Event ev, const FlowEntryPtr &flow, uint64_t time)
boost::shared_ptr< TraceBuffer< SandeshTrace > > SandeshTraceBufferPtr
SessionEndpointMap session_endpoint_map_
std::map< const SessionEndpointKey, SessionEndpointInfo, SessionEndpointKeyCmp > SessionEndpointMap
const RevFlowDepParams & params() const
DISALLOW_COPY_AND_ASSIGN(SessionStatsReq)
const Queue * queue() const
void AddSloFirewallRules(SecurityLoggingObject *slo, SessionSloRuleMap *rule_map)
bool IsEqual(const SessionKey &rhs) const
void SloNotify(DBTablePartBase *partition, DBEntryBase *e)
bool UpdateSessionSloStateRuleRefCount(const std::string &uuid, bool *matc)
bool operator()(const SessionKey &lhs, const SessionKey &rhs) const
bool HandleFlowLogging(const SessionStatsInfo &stats_info)
boost::uuids::uuid slo_uuid
bool MatchSloForFlow(const SessionStatsInfo &stats_info, const FlowEntry *fe, const std::string &fw_policy_uuid, const std::string &nw_policy_uuid, const std::string &sg_policy_uuid, const bool &deleted_flag, bool *logged, const bool &exported_once)
FlowSessionMap flow_session_map_
void AddSloEntry(const boost::uuids::uuid &uuid, SessionSloRuleMap *slo_rule_map)
std::string other_vrouter
SessionStatsCollector * FlowToCollector(const FlowEntry *flow)
void DeleteEvent(const FlowEntryPtr &flow, const RevFlowDepParams ¶ms)
uint32_t oflow_bytes() const
SessionSloRuleEntry(int rate, const boost::uuids::uuid &uuid)
std::map< std::string, SessionSloRuleState > SessionSloRuleStateMap
bool CheckAndDeleteSessionStatsFlow(SessionPreAggInfo::SessionMap::iterator session_map_iter)
bool IsLess(const SessionAggKey &rhs) const
bool RequestHandler(boost::shared_ptr< SessionStatsReq > req)
void AddSessionSloRuleEntry(const std::string &uuid, int rate, SecurityLoggingObject *slo, SessionSloRuleMap *slo_rule_map)
void CopyFlowInfo(SessionStatsInfo &session, const RevFlowDepParams *params)
static const int kMaxSessionCollectors
SessionStatsCollectorPtr collectors[kMaxSessionCollectors]
bool exported_atleast_once
bool FetchFlowStats(SessionFlowStatsInfo *info, SessionFlowStatsParams *params) const
SessionFlowStatsInfo rev_flow
void AddSloList(const UuidList &slo_list, SessionSloRuleMap *slo_rule_map)
void DeleteFlowToSessionMap(FlowEntry *fe)
void FillSessionFlowInfo(const SessionFlowStatsInfo &session_flow, const SessionStatsInfo &sinfo, const SessionFlowExportInfo &einfo, SessionFlowInfo *flow_info) const
SessionStatsCollector * GetCollector(uint8_t idx) const
bool operator()(const SessionEndpointKey &lhs, const SessionEndpointKey &rhs) const
void FillSessionTags(const TagList &list, SessionEndpoint *ep) const
static uint64_t GetCurrentTime()
SandeshTraceBufferPtr SessionStatsTraceBuf
FlowStatsManager * flow_stats_manager_
void AddSloEntryRules(SecurityLoggingObject *slo, SessionSloRuleMap *slo_rule_map)
void FillSessionFlowStats(const SessionFlowStatsParams &stats, SessionFlowInfo *flow_info, bool is_sampling, bool is_logging) const
std::string aps_rule_uuid
std::vector< boost::uuids::uuid > UuidList
bool DeletedFlowLogging(const SessionStatsInfo &stats_info, const SessionFlowExportInfo &flow_info, bool *logged, const bool &exported_once)
void AddEvent(const FlowEntryPtr &flow)
void UpdateSessionFlowStatsInfo(FlowEntry *fe, SessionFlowStatsInfo *session_flow) const
int GetExpiryTime() const
void AddFlowToSessionMap(FlowEntry *fe, SessionKey session_key, SessionAggKey session_agg_key, SessionEndpointKey session_endpoint_key)
void AddSloFirewallPolicies(SecurityLoggingObject *slo, SessionSloRuleMap *r_map)
void FillSessionInfoLocked(SessionPreAggInfo::SessionMap::iterator session_map_iter, const SessionStatsParams &stats, SessionInfo *session_info, SessionIpPort *session_key, bool is_sampling, bool is_logging) const
SessionTask * session_task_
SessionSloRuleStateMap session_rule_state_map_
SessionFlowStatsInfo fwd_flow
SessionFlowExportInfo fwd_flow
bool operator()(const SessionAggKey &lhs, const SessionAggKey &rhs) const
void MakeSloList(const FlowEntry *fe, SessionSloRuleMap *vmi_session_slo_rule_map, SessionSloRuleMap *vn_session_slo_rule_map)
bool IsLess(const SessionKey &rhs) const
DISALLOW_COPY_AND_ASSIGN(SessionStatsCollectorObject)
SessionStatsParams del_stats
bool IsEqual(const SessionAggKey &rhs) const
void CopyFlowInfoInternal(SessionFlowExportInfo *info, const boost::uuids::uuid &u, FlowEntry *fe) const
void UpdateSessionStatsInfo(FlowEntry *fe, uint64_t setup_time, SessionStatsInfo *session) const
SessionFlowStatsParams fwd_flow
SessionFlowExportInfo rev_flow
uint32_t RunSessionEndpointStats(uint32_t max_count)
bool UpdateSloMatchRuleEntry(const boost::uuids::uuid &slo_uuid, const std::string &match_uuid, bool *match)
void DispatchPendingSessionMsg()
std::string remote_prefix
uint64_t threshold() const
SessionAggKey session_agg_iteration_key_
std::map< const SessionKey, SessionStatsInfo, SessionKeyCmp > SessionMap
uint64_t GetUpdatedSessionFlowPackets(uint64_t info_packets, uint64_t k_flow_pkts) const
SessionAggMap session_agg_map_
SessionStatsParams evict_stats
SessionStatsReq(Event event, const FlowEntryPtr &flow, uint32_t bytes, uint32_t packets, uint32_t oflow_bytes, const boost::uuids::uuid &u)
bool SessionStatsChangedUnlocked(SessionPreAggInfo::SessionMap::iterator session_map_iter, SessionStatsParams *params) const
void AddSession(FlowEntry *fe, uint64_t setup_time)
bool RequestHandlerEntry()
void FillSessionAggInfo(SessionEndpointInfo::SessionAggMap::iterator it, SessionIpPortProtocol *session_agg_key) const
uint16_t underlay_src_port
SessionTask(SessionStatsCollector *ssc)
void UpdateSloStateRules(SecurityLoggingObject *slo, SessionSloState *state)
SessionStatsCollectorObject(Agent *agent, FlowStatsManager *mgr)
void FillSessionEndpoint(SessionEndpointMap::iterator it, SessionEndpoint *session_ep) const
bool ProcessSessionEndpoint(const SessionEndpointMap::iterator &it)
Task is a wrapper over tbb::task to support policies.
void FillSessionRemoteTags(const TagList &list, SessionEndpoint *ep) const
void RequestHandlerExit(bool done)
void DeleteSessionSloStateRuleEntry(std::string uuid)
void EvictedSessionStatsUpdate(const FlowEntryPtr &flow, uint32_t bytes, uint32_t packets, uint32_t oflow_bytes, const boost::uuids::uuid &u)
SessionEndpointKey session_endpoint_key_
std::map< FlowEntryPtr, FlowToSessionMap > FlowSessionMap
bool CheckSessionLogging(const SessionStatsInfo &stats_info)
bool IsLess(const SessionEndpointKey &rhs) const
std::string Description() const
SessionAggKey session_agg_key()
virtual ~SessionStatsCollector()
SessionExportInfo export_info
boost::uuids::uuid uuid() const
boost::intrusive_ptr< FlowEntry > FlowEntryPtr
std::vector< int > TagList
bool FindSloMatchRule(const SessionSloRuleMap &map, const std::string &fw_policy_uuid, const std::string &nw_policy_uuid, const std::string &sg_policy_uuid, const bool &deleted_flag, bool *match, const bool &exported_once)