2 #include <boost/uuid/uuid_io.hpp>
23 table_index_(table_index),
24 acl_flow_mgmt_tree_(this),
25 interface_flow_mgmt_tree_(this),
26 vn_flow_mgmt_tree_(this),
27 ip4_route_flow_mgmt_tree_(this),
28 ip6_route_flow_mgmt_tree_(this),
29 bridge_route_flow_mgmt_tree_(this),
30 vrf_flow_mgmt_tree_(this),
31 nh_flow_mgmt_tree_(this),
33 request_queue_(agent_->task_scheduler()->GetTaskId(
kTaskFlowMgmt),
36 db_event_queue_(agent_->task_scheduler()->GetTaskId(
kTaskFlowMgmt),
39 db_event_queue_.kMaxSize, 1) {
93 uint32_t source_port) {
120 AclFlowCountResp &data,
121 const std::string &ace_id) {
134 const int last_count) {
176 uint32_t oflow_bytes,
178 if (bytes == 0 && packets == 0 && oflow_bytes == 0) {
188 bytes, packets, oflow_bytes, u));
276 switch (req->
event()) {
370 BgpAsAServiceDelete(key, req);
372 }
else if (bgp_as_a_service_request->
type() ==
376 }
else if (bgp_as_a_service_request->
type() ==
378 bgp_as_a_service_request->
type() ==
386 BgpAsAServiceHealthCheckUpdate(
agent(), key, bgp_as_a_service_request);
394 switch (req->event()) {
400 tbb::mutex::scoped_lock mutex(flow->
mutex());
404 if (flow->
deleted() ==
false) {
421 req->flow().get(), req->params()));
438 req->oflow_bytes(), req->flow_uuid());
464 switch (req->event()) {
486 switch (req->event()) {
511 if (flow->
trace() ==
false)
532 ExtractKeys(flow, tree);
543 string vn_name = vn? vn->
GetName() :
"";
544 string itf_name = vmi? vmi->
cfg_name() :
"";
549 if (!itf_name.empty()) {
556 if (!req->sg_info_valid() && !req->vn_ace_valid() &&
557 !req->fw_policy_valid()) {
570 string itf_name = vmi? vmi->
cfg_name() :
"";
572 if (!itf_name.empty()) {
593 FlowMgmtKeyTree::iterator new_it = new_tree.begin();
594 FlowMgmtKeyTree::iterator old_it = old_tree->begin();
596 while (new_it != new_tree.end() && old_it != old_tree->end()) {
599 if (new_key->
IsLess(old_key)) {
602 }
else if (old_key->
IsLess(new_key)) {
606 FlowMgmtKeyTree::iterator tmp = old_it++;
608 old_tree->erase(tmp);
618 while (new_it != new_tree.end()) {
624 while (old_it != old_tree->end()) {
628 FlowMgmtKeyTree::iterator tmp = old_it++;
630 old_tree->erase(tmp);
635 new_it = new_tree.begin();
636 while (new_it != new_tree.end()) {
637 FlowMgmtKeyTree::iterator tmp = new_it++;
650 if (old_info == NULL)
657 FlowMgmtKeyTree::iterator old_it = old_tree->begin();
658 while (old_it != old_tree->end()) {
661 FlowMgmtKeyTree::iterator tmp = old_it++;
663 old_tree->erase(tmp);
668 assert(old_tree->size() == 0);
673 uint32_t packets, uint32_t oflow_bytes,
697 uint32_t *egress_flow_count) {
703 uint64_t *created, uint64_t *aged,
704 uint32_t *active_flows) {
711 return flow->flow_mgmt_info();
720 flow->set_flow_mgmt_info(info);
728 if (flow_info == NULL)
731 FlowMgmtKeyTree::iterator key_it = flow_info->
tree_.find(&key);
732 if (key_it == flow_info->
tree().end())
745 assert(info->
tree_.size() == 0);
746 flow->set_flow_mgmt_info(NULL);
761 std::pair<FlowMgmtKeyTree::iterator, bool> ret = info->
tree_.insert(
762 make_pair(tmp, node));
763 if (ret.second ==
false) {
775 switch (key->
type()) {
778 (ret.second)? node : NULL);
783 (ret.second)? node : NULL);
788 (ret.second)? node : NULL);
800 (ret.second)? node : NULL);
805 (ret.second)? node : NULL);
810 (ret.second)? node : NULL);
815 (ret.second)? node : NULL);
821 int cn_index = bgp_service_key->
cn_index();
824 (ret.second)? node : NULL);
826 if (
agent()->oper_db()->bgp_as_a_service()->GetBgpHealthCheck(
827 static_cast<const VmInterface *>(flow->
intf_entry()), &hc_uuid)) {
848 FlowMgmtKeyTree::iterator it = info->
tree_.find(key);
849 assert(it != info->
tree_.end());
851 switch (key->
type()) {
893 uint8_t count = bgp_service_key->
cn_index();
StatsManager * stats_manager() const
virtual bool OperEntryDelete(const FlowMgmtRequest *req, FlowMgmtKey *key)
void UpdateFlowStats(FlowEntryPtr &flow, uint32_t bytes, uint32_t packets, uint32_t oflow_bytes, const boost::uuids::uuid &u)
void SetBounded(bool bounded)
const DBEntry * db_entry() const
void DeleteDBEntryEvent(const DBEntry *entry, uint32_t gen_id)
static void LogFlowUnlocked(FlowEntry *flow, const std::string &op)
void AddFlow(FlowEntryPtr &flow)
void EnqueueUveAddEvent(const FlowEntry *flow) const
uint32_t source_port() const
FlowStatsManager * flow_stats_manager() const
bool DBRequestHandler(FlowMgmtRequestPtr req)
void VnFlowCounters(const VnEntry *vn, uint32_t *ingress_flow_count, uint32_t *egress_flow_count)
static bool LogHandler(FlowMgmtRequestPtr req)
void Shutdown(bool delete_entries=true)
WorkQueue< FlowMgmtRequestPtr > FlowMgmtQueue
VnFlowMgmtTree vn_flow_mgmt_tree_
const DBEntry * db_entry() const
FlowMgmtEntry * Find(FlowMgmtKey *key)
size_t FlowDBQueueLength()
AgentUveBase * uve() const
static const uint32_t kPortNatFlowTableInstance
void ExtractKeys(FlowEntry *flow, FlowMgmtKeyTree *tree, uint32_t vrf, const IpAddress &ip, uint8_t plen)
void FreeDBEntryEvent(FlowEvent::Event event, FlowMgmtKey *key, uint32_t gen_id)
FlowMgmtQueue db_event_queue_
void RegisterHealthCheckCb(HealthCheckCb callback)
virtual bool Delete(FlowMgmtKey *key, FlowEntry *flow, FlowMgmtKeyNode *node)
void ExtractKeys(FlowEntry *flow, FlowMgmtKeyTree *tree)
void set_flow_mgmt_request(FlowMgmtRequest *req)
void DeleteFlowEntryInfo(FlowEntryPtr &flow)
static int GetCNIndex(const FlowEntry *flow)
static bool ProcessEvent(FlowMgmtRequest *req, FlowMgmtKey *key, FlowMgmtTree *tree)
bool Add(FlowMgmtKey *key, FlowEntry *flow, FlowMgmtKey *old_key, FlowMgmtKeyNode *node)
BgpAsAServiceFlowMgmtKey * FindBgpAsAServiceInfo(FlowEntry *flow, BgpAsAServiceFlowMgmtKey &key)
#define FLOW_LOCK(flow, rflow, flow_event)
void NonOperEntryEvent(FlowEvent::Event event, FlowEntry *flow)
void UpdateCounterOnDel(FlowEntry *flow, bool local_flow, bool old_ingress)
virtual bool Delete(FlowMgmtKey *key, FlowEntry *flow, FlowMgmtKeyNode *node)
void FillUveFwStatsInfo(FlowUveFwPolicyInfo *info, bool added) const
void DeleteFlowMgmtKey(FlowEntry *flow, FlowEntryInfo *info, FlowMgmtKey *key, FlowMgmtKeyNode *node)
boost::shared_ptr< FlowMgmtRequest > FlowMgmtRequestPtr
void ChangeDBEntryEvent(const DBEntry *entry, uint32_t gen_id)
void EnqueueFlowEvent(FlowEvent *event)
void AddEvent(FlowEntry *low)
void RetryVrfDeleteEvent(const VrfEntry *vrf)
void RegisterControllerChangeCallback(XmppChannelDownCb xmpp_channel_down_cb)
void ControllerNotify(uint8_t index)
bool HasVrfFlows(uint32_t vrf_id, Agent::RouteTableType type)
virtual void KeyToFlowRequest(FlowEvent *req)
static void InitLogQueue(Agent *agent)
InterfaceFlowMgmtTree interface_flow_mgmt_tree_
void RetryDelete(uint32_t vrf_id)
FlowEntryInfo * FindFlowEntryInfo(const FlowEntryPtr &flow)
const std::string & sg_rule_uuid() const
bool RouteNHChangeEvent(const FlowMgmtRequest *req, FlowMgmtKey *key)
const boost::uuids::uuid & vm_uuid() const
int GetTaskId(const std::string &name)
FlowMgmtRequest * flow_mgmt_request() const
virtual bool OperEntryChange(const FlowMgmtRequest *req, FlowMgmtKey *key)
void RouteNHChangeEvent(const DBEntry *entry, uint32_t gen_id)
void ExtractKeys(FlowEntry *flow, FlowMgmtKeyTree *tree)
const AclEntryIDList * ace_id_list() const
void RegisterServiceDeleteCb(ServiceDeleteCb callback)
bool HasVrfFlows(uint32_t vrf_id, Agent::RouteTableType type)
const FlowKey & key() const
void SetAceSandeshData(const AclDBEntry *acl, AclFlowCountResp &data, const std::string &ace_id)
void set_acl_flow_sandesh_data_cb(FlowAclSandeshDataFn fn)
void SetAclFlowSandeshData(const AclDBEntry *acl, AclFlowResp &data, const int last_count)
BgpAsAService * bgp_as_a_service() const
VrfFlowMgmtTree vrf_flow_mgmt_tree_
void StopHealthCheck(FlowEntry *flow)
FlowEntryInfo * LocateFlowEntryInfo(FlowEntryPtr &flow)
bool is_flags_set(const FlowEntryFlags &flags) const
TaskScheduler * task_scheduler() const
const boost::uuids::uuid & uuid() const
void FlowUpdateQueueDisable(bool val)
void MakeFlowMgmtKeyTree(FlowEntry *flow, FlowMgmtKeyTree *tree)
void EnqueueEvent(const boost::shared_ptr< FlowUveStatsRequest > &req)
VNController * controller() const
void BgpAsAServiceNotify(const boost::uuids::uuid &vm_uuid, uint32_t source_port)
static const int kInvalidCnIndex
size_t FlowUpdateQueueLength()
std::map< FlowMgmtKey *, FlowMgmtKeyNode *, FlowMgmtKeyCmp > FlowMgmtKeyTree
BridgeRouteFlowMgmtTree bridge_route_flow_mgmt_tree_
void AddFlowMgmtKey(FlowEntry *flow, FlowEntryInfo *info, FlowMgmtKey *key, FlowMgmtKey *old_key)
void RetryVrfDelete(uint32_t vrf_id)
virtual FlowMgmtKey * Clone()=0
static void ShutdownLogQueue()
void set_measure_busy_time(bool val) const
bool HasVrfFlows(uint32_t vrf)
void InterfaceFlowCount(const Interface *itf, uint64_t *created, uint64_t *aged, uint32_t *active_flows)
#define FLOW_TRACE(obj,...)
void AddEvent(FlowEntryPtr &flow)
FlowMgmtManager(Agent *agent, uint16_t table_index)
void BgpAsAServiceHealthCheckNotify(const boost::uuids::uuid &vm_uuid, uint32_t source_port, const boost::uuids::uuid &hc_uuid, bool add)
void DeleteEvent(FlowEntry *flow, const RevFlowDepParams ¶ms)
void FlowStatsUpdateEvent(FlowEntry *flow, uint32_t bytes, uint32_t packets, uint32_t oflow_bytes, const boost::uuids::uuid &u)
void AddDBEntryEvent(const DBEntry *entry, uint32_t gen_id)
const FlowMgmtKeyTree & tree() const
void UpdateStatsEvent(const FlowEntryPtr &flow, uint32_t bytes, uint32_t packets, uint32_t oflow_bytes, const boost::uuids::uuid &u)
void DBEntryEvent(FlowEvent::Event event, FlowMgmtKey *key, FlowEntry *flow)
virtual const PrefixType & prefix_address() const
Returns the value of a stored prefix address (IPv4, IPv6 or MAC address)
FlowProto * get_flow_proto() const
const Interface * intf_entry() const
virtual bool OperEntryAdd(const FlowMgmtRequest *req, FlowMgmtKey *key)
void set_disable(bool disabled)
bool IsLess(const FlowMgmtKey *rhs) const
void ExtractKeys(FlowEntry *flow, FlowMgmtKeyTree *tree)
InetRouteFlowMgmtTree ip6_route_flow_mgmt_tree_
void DeleteEvent(const FlowEntryPtr &flow, const RevFlowDepParams ¶ms)
void UpdateCounterOnAdd(FlowEntry *flow, bool add_flow, bool local_flow, bool old_ingress)
void ExtractKeys(FlowEntry *flow, FlowMgmtKeyTree *tree, const MatchAclParamsList *acl_list)
virtual bool Add(FlowMgmtKey *key, FlowEntry *flow, FlowMgmtKeyNode *node)
bool BgpAsAServiceRequestHandler(FlowMgmtRequest *req)
NhFlowMgmtTree nh_flow_mgmt_tree_
const VnEntry * vn_entry() const
void FillAceFlowSandeshInfo(const AclDBEntry *acl, AclFlowCountResp &data, const std::string &ace_id)
const std::string & cfg_name() const
FlowEntry * reverse_flow_entry()
void FillAclFlowSandeshInfo(const AclDBEntry *acl, AclFlowResp &data, const int last_count, Agent *agent)
void FillUveVnAceInfo(FlowUveVnAcePolicyInfo *info) const
void EnqueueFlowEvent(FlowEvent *event)
static FlowMgmtQueue * log_queue_
void set_params(const RevFlowDepParams ¶ms)
InetRouteFlowMgmtTree ip4_route_flow_mgmt_tree_
const string & GetName() const
std::unique_ptr< FlowMgmtDbClient > flow_mgmt_dbclient_
void ExtractKeys(FlowEntry *flow, FlowMgmtKeyTree *tree)
void DeleteFlow(FlowEntryPtr &flow, const RevFlowDepParams &p)
void VnFlowCounters(const VnEntry *vn, uint32_t *ingress_flow_count, uint32_t *egress_flow_count)
AclTable * acl_table() const
void StartHealthCheck(Agent *agent, FlowEntry *flow, const boost::uuids::uuid &hc_uuid)
void InterfaceFlowCount(const Interface *itf, uint64_t *created, uint64_t *aged, uint32_t *active_flows)
BgpAsAServiceFlowMgmtRequest::Type type() const
bool Enqueue(QueueEntryT entry)
void FillFlowInfo(FlowInfo &info) const
bool Delete(FlowMgmtKey *key, FlowEntry *flow, FlowMgmtKeyNode *node)
void set_name(const std::string &name)
void set_ace_id_list(const AclEntryIDList *list)
bool RequestHandler(FlowMgmtRequestPtr req)
boost::scoped_ptr< BgpAsAServiceFlowMgmtTree > bgp_as_a_service_flow_mgmt_tree_[MAX_XMPP_SERVERS]
FlowMgmtQueue request_queue_
void set_flow(FlowEntry *flow)
void set_ace_flow_sandesh_data_cb(FlowAceSandeshDataFn fn)
AclFlowMgmtTree acl_flow_mgmt_tree_
void EnqueueUveDeleteEvent(const FlowEntry *flow) const
boost::intrusive_ptr< FlowEntry > FlowEntryPtr