5 #ifndef __AGENT_PKT_FLOW_ENTRY_H__
6 #define __AGENT_PKT_FLOW_ENTRY_H__
8 #include <boost/uuid/uuid_io.hpp>
9 #include <boost/intrusive_ptr.hpp>
10 #include <boost/intrusive/list.hpp>
11 #include <tbb/atomic.h>
12 #include <tbb/mutex.h>
13 #include <tbb/recursive_mutex.h>
22 #include <pkt/pkt_types.h>
27 #include <sandesh/sandesh_trace.h>
37 #include <sandesh/common/flow_types.h>
76 const std::string &vmi_uuid,
77 const std::string &sg_uuid,
78 const std::string &vm_cfg_name,
79 uint16_t &drop_reason,
80 std::string &nw_ace_uuid,
106 void Reset(
bool reset_flow);
135 uint8_t proto_p, uint16_t sport_p, uint16_t dport_p)
141 uint8_t proto_p, uint16_t sport_p, uint16_t dport_p)
585 const IpAddress &addr, uint32_t ethernet_tag);
674 (1 << action)) ?
true :
false);
720 void SetAclAction(std::vector<AclAction> &acl_action_l)
const;
724 FlowSandeshData &fe_sandesh_data,
810 const IpAddress &dip, uint8_t proto, uint16_t sport,
811 uint16_t dport)
const;
875 for (uint32_t i = 0; i <
size_; i++) {
915 virtual uint16_t
Bind() = 0;
926 virtual uint16_t
Bind();
937 virtual uint16_t
Bind();
948 const uint16_t
port):
965 bool CanBeAged(uint64_t current_time, uint64_t timeout)
const;
1028 void Free(
const FlowKey &key, uint16_t port,
bool release);
1055 tbb::recursive_mutex::scoped_lock lock(
mutex_);
1056 std::vector<uint16_t> port_list;
1059 port_list.push_back(it->first);
1064 void GetFlowKeyList(uint16_t port, std::vector<FlowKey> &key)
const;
1069 void AddPort(uint16_t port_no);
1110 void Free(
const FlowKey &key, uint16_t port,
bool release);
1122 #endif // __AGENT_PKT_FLOW_ENTRY_H__
bool InitFlowCmn(const PktFlowInfo *info, const PktControlInfo *ctrl, const PktControlInfo *rev_ctrl, FlowEntry *rflow)
bool AllocateFd(Agent *agent, uint8_t l3_proto)
boost::uuids::uuid bgp_health_check_uuid
static tbb::atomic< int > alloc_count_
void Delete(const PortCacheEntry &cache_entry)
bool is_flow_on_unresolved_list
void Move(VmFlowRef *rhs)
VmInterfaceKey reverse_flow_vmi() const
VnListType source_vn_list
int intrusive_ptr_add_ref(const AsPath *cpath)
FlowStatsCollector * fsc_
VnListType origin_vn_dst_list
void SetVm(const VmEntry *vm)
void GetSourceRouteInfo(const AgentRoute *rt)
bool operator<(const PortCacheEntry &rhs) const
uint16_t short_flow_reason_
void LogFlow(FlowEventLog::Event event, FlowTableKSyncEntry *ksync, uint32_t flow_handle, uint8_t gen_id)
const TagList & local_tagset() const
void FillUveLocalRevFlowStatsInfo(FlowUveFwPolicyInfo *info, bool added) const
boost::asio::ip::udp::socket socket_
MatchAclParamsList m_reverse_acl_l
uint16_t HashFlowKey(const FlowKey &key)
const std::string BuildRemotePrefix(const FlowRouteRefMap &rt_list, uint32_t vr, const IpAddress &ip) const
VmInterfaceKey InterfaceIdToKey(Agent *agent, uint32_t id)
void ResetRecomputeDBEntry()
void SetUnResolvedList(bool added)
TcpPort(boost::asio::io_context &io, uint16_t port)
void set_fsc(FlowStatsCollector *fsc)
bool IsLess(const FlowKey &key) const
void SetAclAction(std::vector< AclAction > &acl_action_l) const
const std::string fw_policy_name_uuid() const
std::string dest_vn_match
void SetAclInfo(SessionPolicy *sp, SessionPolicy *rsp, const FlowPolicyInfo &fwd_flow_info, const FlowPolicyInfo &rev_flow_info, bool tcp_rev, bool is_sg)
FlowKey(uint32_t nh_p, const Ip4Address &sip_p, const Ip4Address &dip_p, uint8_t proto_p, uint16_t sport_p, uint16_t dport_p)
uint32_t GetEcmpIndex() const
uint16_t port_count() const
FlowTable * flow_table() const
uint32_t bgp_as_a_service_dport
void set_timeout(uint64_t timeout)
boost::shared_ptr< PortBitMap > PortBitMapPtr
uint32_t GetTransactionId()
MatchAclParamsList m_vrf_assign_acl_l
tbb::atomic< int > refcount_
uint32_t component_nh_idx
void Add(const PortCacheEntry &cache_entry)
const VmEntry * in_vm_entry() const
std::string source_vn_match
void DeleteAllFlow(uint16_t port, uint16_t index)
const MacAddress & dmac() const
static const uint32_t size_
FlowEntryEventHistory e_history_
uint32_t vrf_assign_acl_action
MatchAclParamsList m_acl_l
boost::intrusive_ptr< const VmEntry > VmEntryConstRef
FlowPendingAction * GetPendingAction()
friend void intrusive_ptr_release(FlowEntry *fe)
int linklocal_src_port() const
uint32_t reverse_flow_fip() const
uint32_t acl_assigned_vrf_index_
boost::asio::ip::address IpAddress
void reset_flags(const FlowEntryFlags &flags)
uint8_t underlay_gw_index_
FlowEntryInfo * flow_mgmt_info() const
std::vector< int > SecurityGroupList
void set_flow_mgmt_request(FlowMgmtRequest *req)
boost::uuids::uuid egress_uuid_
uint32_t InterfaceKeyToId(Agent *agent, const VmInterfaceKey &key)
uint8_t flow_retry_attempts_
static bool ShouldDrop(uint32_t action)
static const uint64_t kAgingTimeout
std::vector< std::string > SourceVnList() const
void FillUveFwdFlowStatsInfo(FlowUveFwPolicyInfo *info, bool added) const
void SetMirrorVrfFromAction()
std::pair< uint16_t, uint16_t > PortToBitIndexPair
void Init(FlowEntry *flow)
PortCacheTable(PortTable *table)
uint16_t event_log_index_
void SetHbsInfofromAction()
boost::shared_ptr< PortTable > PortTablePtr
static const uint64_t kCacheAging
static AgentRoute * GetEvpnRoute(const VrfEntry *entry, const MacAddress &mac, const IpAddress &addr, uint32_t ethernet_tag)
static AgentRoute * GetL2Route(const VrfEntry *entry, const MacAddress &mac)
std::vector< std::string > OriginVnDstList() const
void FillUveFwStatsInfo(FlowUveFwPolicyInfo *info, bool added) const
uint32_t bgp_as_a_service_sport
bool CanRecomputeDBEntry()
void set_source_sg_id_l(const SecurityGroupList &sg_l)
uint32_t last_events_[size_]
bool IsFabricControlFlow() const
bool RpfFromSrcIpNh() const
FlowTableKSyncEntry * ksync_entry()
uint16_t hash_table_size_
void RpfInit(const AgentRoute *rt, const IpAddress &sip)
HbsInterface GetHbsInterface()
static void PortConfigHandler(Agent *agent, uint8_t protocol, const PortConfig *pc)
tbb::recursive_mutex & mutex()
void set_timeout(uint64_t timeout)
FlowPendingAction pending_actions_
FlowRouteRefMap flow_source_plen_map
boost::shared_ptr< Port > PortPtr
static FlowEntry * Allocate(const FlowKey &key, FlowTable *flow_table)
Base class for all Route entries in agent.
VmFlowRef * in_vm_flow_ref()
FlowEntryPtr reverse_flow_entry_
uint32_t out_mirror_action
uint16_t allocated_port()
static const int kInvalidFd
void InitRevFlow(const PktFlowInfo *info, const PktInfo *pkt, const PktControlInfo *ctrl, const PktControlInfo *rev_ctrl, FlowEntry *rflow, Agent *agent)
const std::string & sg_rule_uuid() const
const VmEntry * vm() const
uint16_t Allocate(const FlowKey &key)
boost::asio::ip::tcp::socket socket_
const std::string & peer_vrouter() const
void UpdatePortConfig(const PortConfig *port_config)
FlowMgmtRequest * flow_mgmt_request() const
void InitFwdFlow(const PktFlowInfo *info, const PktInfo *pkt, const PktControlInfo *ctrl, const PktControlInfo *rev_ctrl, FlowEntry *rflow, Agent *agent)
static const SecurityGroupList & default_sg_list()
MatchAclParamsList m_out_mirror_acl_l
TunnelType tunnel_type() const
const FlowKey & key() const
const std::string fw_policy_
static const uint32_t kFlowRetryAttempts
static const uint8_t kInvalidPort
void SetOutPacketHeader(PacketHeader *hdr)
void operator=(const VmFlowRef &rhs)
FlowRouteRefMap flow_dest_plen_map
void MarkDelete(const PortCacheEntry &cache_entry)
bool reverse_rule_present
IndexVector< FlowKey > PortBitMap
std::vector< std::string > OriginVnSrcList() const
static SecurityGroupList default_sg_list_
void SetHbsInterface(HbsInterface intf)
void ComputeReflexiveAction()
FlowKey(uint32_t nh_p, const IpAddress &sip_p, const IpAddress &dip_p, uint8_t proto_p, uint16_t sport_p, uint16_t dport_p)
PortTable(Agent *agent, uint32_t bucket_size, uint8_t protocol)
std::map< uint16_t, uint16_t > PortToBitIndexMap
bool is_flags_set(const FlowEntryFlags &flags) const
bool IsEqual(const FlowKey &key) const
std::map< uint16_t, PortCacheEntryList > PortCacheTree
void SetMirrorVrf(const uint32_t id)
bool ActionSet(TrafficAction::Action action) const
PortToBitIndexMap port_to_bit_index_
void set_dest_sg_id_l(const SecurityGroupList &sg_l)
const FlowKey & key() const
void RevFlowDepInfo(RevFlowDepParams *params)
bool reverse_out_rule_present
const std::string fw_policy_uuid() const
std::vector< PortBitMapPtr > PortHashTable
std::string peer_vrouter_
void UpdateReflexiveAction()
void IncrementTransactionId()
const FlowEntry * reverse_flow_entry() const
void Copy(FlowEntry *rhs, bool update)
const boost::uuids::uuid & uuid() const
int linklocal_src_port_fd() const
SessionPolicy fwaas_policy
bool CanBeAged(uint64_t current_time, uint64_t timeout) const
void set_deleted(bool deleted)
std::set< PortCacheEntry > PortCacheEntryList
void InitAuditFlow(uint32_t flow_idx, uint8_t gen_id)
map< int, int > FlowRouteRefMap
const uint32_t bgp_as_a_service_sport() const
MatchAclParamsList m_acl_l
MatchAclParamsList m_reverse_out_acl_l
VmInterfaceKey fip_vmi() const
const boost::uuids::uuid & egress_uuid() const
FlowTableKSyncEntry * ksync_entry_
const VmEntry * out_vm_entry() const
RevFlowDepParams(const boost::uuids::uuid &rev_uuid, const boost::uuids::uuid &rev_egress_uuid, IpAddress sip, const std::string &vmi_uuid, const std::string &sg_uuid, const std::string &vm_cfg_name, uint16_t &drop_reason, std::string &nw_ace_uuid, FlowAction &action_info)
const FlowData & data() const
uint32_t out_policy_action
void set_last_event(uint32_t event)
bool vrf_assign_evaluated
bool IsValidPort(uint16_t port, uint16_t count)
void set_reverse_flow_entry(FlowEntry *reverse_flow_entry)
static std::string DropReasonStr(uint16_t reason)
void Reset(bool reset_flow)
boost::intrusive_ptr< const Interface > InterfaceConstRef
void set_flags(const FlowEntryFlags &flags)
void Free(const FlowKey &key, uint16_t port, bool release)
FlowTableKSyncEntry * ksync_entry_
void GetDestRouteInfo(const AgentRoute *rt)
void MakeShortFlow(FlowShortReason reason)
static AgentRoute * GetUcRoute(const VrfEntry *entry, const IpAddress &addr)
bool ImplicitDenyFlow() const
std::string origin_vn_src
const PortConfig * port_config() const
void set_stale(bool stale) const
void set_acl_assigned_vrf_index()
std::set< std::string > VnListType
bool HandlePortConfig(const PortConfig &pc)
void RpfSetSrcIpNhFields(const AgentRoute *rt, const NextHop *src_ip_nh)
const PortTable * GetPortTable(uint8_t proto)
PortTablePtr port_table_list_[IPPROTO_MAX]
void RpfSetRpfNhFields(const NextHop *rpf_nh)
boost::asio::ip::address_v4 Ip4Address
void GetPolicy(const VnEntry *vn, const FlowEntry *rflow)
const uint32_t bgp_as_a_service_dport() const
void SessionMatch(SessionPolicy *sp, SessionPolicy *rsp, bool is_sg)
void SetPacketHeader(PacketHeader *hdr)
const MacAddress & smac() const
const Interface * intf_entry() const
std::string origin_vn_dst
FlowMgmtRequest * flow_mgmt_request_
const TagList & remote_tagset() const
friend void intrusive_ptr_add_ref(FlowEntry *fe)
uint16_t Allocate(const FlowKey &key)
std::unique_ptr< FlowEntryInfo > FlowMgmtEntryInfoPtr
uint16_t GetPortIndex(uint16_t port) const
SecurityGroupList dest_sg_id_l
uint32_t last_event() const
MatchAclParamsList m_mirror_acl_l
boost::scoped_array< FlowEventLog > event_logs_
void Relocate(uint16_t port_no)
uint32_t flow_handle() const
MatchAclParamsList m_out_acl_l
const VnEntry * vn_entry() const
MatchAclParamsList m_out_acl_l
static const std::map< uint16_t, const char * > FlowDropReasonStr
uint8_t GetUnderlayGwIndex(uint32_t intf_in, const IpAddress &sip, const IpAddress &dip, uint8_t proto, uint16_t sport, uint16_t dport) const
const PortCacheEntry * Find(const FlowKey &key) const
static const uint8_t kMaxMirrorsPerFlow
void GetApplicationPolicySet(const Interface *intf, const FlowEntry *rflow)
virtual uint16_t Bind()=0
boost::uuids::uuid rev_uuid_
boost::intrusive_ptr< const NextHop > NextHopConstRef
boost::intrusive::list_member_hook free_list_node_
void SetAclFlowSandeshData(const AclDBEntry *acl, FlowSandeshData &fe_sandesh_data, Agent *agent) const
static const uint32_t kInvalidFlowHandle
bool IsOnUnresolvedList()
FlowEntry * reverse_flow_entry()
static const std::map< FlowPolicyState, const char * > FlowPolicyStateStr
void set_flow_handle(uint32_t flow_handle, uint8_t gen_id)
void DeletePort(uint16_t port_no)
void AddPort(uint16_t port_no)
void FillUveVnAceInfo(FlowUveVnAcePolicyInfo *info) const
uint8_t GetMaxRetryAttempts()
std::list< MatchAclParams > MatchAclParamsList
void Free(const FlowKey &key, uint16_t port, bool release)
void GetNonLocalFlowSgList(const VmInterface *vm_port)
std::vector< uint16_t > GetPortList() const
void intrusive_ptr_release(const AsPath *cpath)
void set_flow_mgmt_info(FlowEntryInfo *info)
uint16_t short_flow_reason() const
const std::string RemotePrefix() const
const VrfEntry * GetDestinationVrf() const
bool SetRecomputeDBEntry()
PortPtr CreatePortEntry(uint16_t port_no)
std::string KeyString() const
void UpdatePortConfig(uint8_t protocol, const PortConfig *config)
const std::string & nw_ace_uuid() const
boost::uuids::uuid rev_egress_uuid_
uint32_t vrouter_flow_handle_
std::string sg_rule_uuid_
void IncrementRetrycount()
void GetLocalFlowSgList(const VmInterface *vm_port, const VmInterface *reverse_vm_port)
void UpdateFipStatsInfo(uint32_t fip, uint32_t id, Agent *agent)
const NextHop * src_ip_nh() const
void GetSgList(const Interface *intf)
void ResetRuleMatchInfo()
UdpPort(boost::asio::io_context &io, uint16_t port)
PortTableManager(Agent *agent, uint16_t hash_table_size)
boost::intrusive_ptr< const VnEntry > VnEntryConstRef
uint32_t reverse_out_action
const NextHop * rpf_nh() const
FlowKey(const FlowKey &key)
uint32_t MatchAcl(const PacketHeader &hdr, MatchAclParamsList &acl, bool add_implicit_deny, bool add_implicit_allow, FlowPolicyInfo *info)
const std::string & acl_assigned_vrf() const
SecurityGroupList source_sg_id_l
PortHashTable hash_table_
std::vector< std::string > DestinationVnList() const
void FillFlowInfo(FlowInfo &info) const
tbb::recursive_mutex mutex_
IndexVector< PortPtr > PortList
FlowMgmtEntryInfoPtr flow_mgmt_info_
const MatchPolicy & match_p() const
const std::string InterfaceIdToVmCfgName(Agent *agent, uint32_t id)
InterfaceConstRef intf_entry
PortCacheEntry(const FlowKey &key, const uint16_t port)
bool IsIngressFlow() const
VnListType origin_vn_src_list
void GetFlowKeyList(uint16_t port, std::vector< FlowKey > &key) const
uint32_t acl_assigned_vrf_index() const
FlowEntry(FlowTable *flow_table)
FlowStatsCollector * fsc() const
boost::intrusive_ptr< FlowEntry > FlowEntryPtr
void SetEventSandeshData(SandeshFlowIndexInfo *info)
NextHopConstRef src_ip_nh
std::vector< int > TagList
void UpdateEvtHistory(uint32_t event)
std::unique_ptr< TaskTrigger > task_trigger_