8 #include <netinet/in.h>
12 #include <boost/date_time/posix_time/posix_time.hpp>
13 #include <boost/assign/list_of.hpp>
14 #include <boost/unordered_map.hpp>
15 #include <sandesh/sandesh_trace.h>
45 #include <pkt/pkt_types.h>
53 using namespace boost::asio::ip;
54 using boost::uuids::nil_uuid;
55 const std::map<FlowEntry::FlowPolicyState, const char*>
57 (NOT_EVALUATED,
"00000000-0000-0000-0000-000000000000")
58 (IMPLICIT_ALLOW,
"00000000-0000-0000-0000-000000000001")
59 (IMPLICIT_DENY,
"00000000-0000-0000-0000-000000000002")
60 (DEFAULT_GW_ICMP_OR_DNS,
"00000000-0000-0000-0000-000000000003")
61 (LINKLOCAL_FLOW,
"00000000-0000-0000-0000-000000000004")
62 (MULTICAST_FLOW,
"00000000-0000-0000-0000-000000000005")
63 (NON_IP_FLOW,
"00000000-0000-0000-0000-000000000006")
64 (BGPROUTERSERVICE_FLOW,
"00000000-0000-0000-0000-000000000007");
66 const std::map<uint16_t, const char*>
68 ((uint16_t)DROP_UNKNOWN,
"UNKNOWN")
69 ((uint16_t)SHORT_UNAVIALABLE_INTERFACE,
70 "Short flow Interface unavialable")
71 ((uint16_t)SHORT_IPV4_FWD_DIS,
"Short flow Ipv4 forwarding disabled")
72 ((uint16_t)SHORT_UNAVIALABLE_VRF,
73 "Short flow VRF unavailable")
74 ((uint16_t)SHORT_NO_SRC_ROUTE,
"Short flow No Source route")
75 ((uint16_t)SHORT_NO_DST_ROUTE,
"Short flow No Destination route")
76 ((uint16_t)SHORT_AUDIT_ENTRY,
"Short flow Audit Entry")
77 ((uint16_t)SHORT_VRF_CHANGE,
"Short flow VRF CHANGE")
78 ((uint16_t)SHORT_NO_REVERSE_FLOW,
"Short flow No Reverse flow")
79 ((uint16_t)SHORT_REVERSE_FLOW_CHANGE,
80 "Short flow Reverse flow change")
81 ((uint16_t)SHORT_NAT_CHANGE,
"Short flow NAT Changed")
82 ((uint16_t)SHORT_FLOW_LIMIT,
"Short flow Flow Limit Reached")
83 ((uint16_t)SHORT_LINKLOCAL_SRC_NAT,
84 "Short flow Linklocal source NAT failed")
85 ((uint16_t)SHORT_FAILED_VROUTER_INSTALL,
86 "Short flow vrouter install failed")
87 ((uint16_t)SHORT_INVALID_L2_FLOW,
"Short flow invalid L2 flow")
88 ((uint16_t)SHORT_FLOW_ON_TSN,
"Short flow TSN flow")
89 ((uint16_t)SHORT_NO_MIRROR_ENTRY,
"Short flow No mirror entry ")
90 ((uint16_t)SHORT_SAME_FLOW_RFLOW_KEY,
"Short flow same flow and rflow")
91 ((uint16_t)DROP_POLICY,
"Flow drop Policy")
92 ((uint16_t)DROP_OUT_POLICY,
"Flow drop Out Policy")
93 ((uint16_t)DROP_SG,
"Flow drop SG")
94 ((uint16_t)DROP_OUT_SG,
"Flow drop OUT SG")
95 ((uint16_t)DROP_REVERSE_SG,
"Flow drop REVERSE SG")
96 ((uint16_t)DROP_REVERSE_OUT_SG,
"Flow drop REVERSE OUT SG")
97 ((uint16_t)DROP_FIREWALL_POLICY,
"Flow drop Firewall Policy")
98 ((uint16_t)DROP_OUT_FIREWALL_POLICY,
"Flow drop OUT Firewall Policy")
99 ((uint16_t)DROP_REVERSE_FIREWALL_POLICY,
"Flow drop REVERSE Firewall Policy")
100 ((uint16_t)DROP_REVERSE_OUT_FIREWALL_POLICY,
"Flow drop REVERSE OUT Firewall Policy")
101 ((uint16_t)SHORT_NO_SRC_ROUTE_L2RPF,
"Short flow No Source route for RPF NH")
102 ((uint16_t)SHORT_FAT_FLOW_NAT_CONFLICT,
"Short flow Conflicting config for NAT and FAT flow")
103 ((uint16_t)DROP_FWAAS_POLICY,
"Flow drop FWAAS Policy")
104 ((uint16_t)DROP_FWAAS_OUT_POLICY,
"Flow drop OUT FWAAS Policy")
105 ((uint16_t)DROP_FWAAS_REVERSE_POLICY,
"Flow drop REVERSE FWAAS Policy")
106 ((uint16_t)DROP_FWAAS_REVERSE_OUT_POLICY,
"Flow drop REVERSE OUT FWAAS Policy")
107 ((uint16_t)SHORT_L3MH_PHY_INTF_DOWN,
"Short flow l3mh compute physical interface flap");
117 vm_(NULL), fd_(kInvalidFd), port_(0), flow_(NULL) {
142 assert(rhs.
port_ == 0);
146 assert(rhs.
vm_.get() == NULL);
176 if (
vm_.get() == NULL)
179 vm_->update_flow_count(-1);
181 vm_->update_linklocal_flow_count(-1);
212 vm_->update_linklocal_flow_count(1);
227 if (l3_proto == IPPROTO_TCP) {
228 fd_ = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
229 }
else if (l3_proto == IPPROTO_UDP) {
230 fd_ = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
243 if (l3_proto == IPPROTO_TCP) {
245 setsockopt(
fd_, SOL_SOCKET, SO_REUSEADDR,
246 (
const char*)&optval,
sizeof(optval));
249 struct sockaddr_in address;
250 memset(&address, 0,
sizeof(address));
251 address.sin_family = AF_INET;
252 if (::bind(
fd_, (
struct sockaddr*) &address,
sizeof(address)) < 0) {
257 struct sockaddr_in bound_to;
258 socklen_t len =
sizeof(bound_to);
259 if (getsockname(
fd_, (
struct sockaddr*) &bound_to, &len) < 0) {
264 port_ = ntohs(bound_to.sin_port);
331 std::vector<std::string> olist;
332 for (VnListType::const_iterator it = ilist.begin();
333 it != ilist.end(); ++it) {
334 olist.push_back(*it);
436 flow_handle_(
FlowEntry::kInvalidFlowHandle), flow_gen_id_(0),
437 ksync_entry_(NULL), hash_id_(
FlowEntry::kInvalidFlowHandle), gen_id_(0),
438 vrouter_flow_handle_(
FlowEntry::kInvalidFlowHandle), vrouter_gen_id_(0) {
448 flow_table_(flow_table), flags_(0),
450 fip_vmi_(
AgentKey::ADD_DEL_CHANGE, nil_uuid(),
""),
451 flow_mgmt_request_(NULL), flow_mgmt_info_() {
554 if (update ==
false) {
572 int prev = fe->
refcount_.fetch_and_decrement();
582 FlowTable::FlowEntryMap::iterator it =
594 boost::hash_combine(hash, val);
604 }
else if (ip.is_v4()) {
691 if (
InitFlowCmn(info, ctrl, rev_ctrl, rflow) ==
false) {
712 if (ctrl->
rt_ != NULL) {
717 if (info->
ttl == 1) {
775 info->
pkt->ip_saddr, info->
pkt->ip_daddr,
776 info->
pkt->ip_proto, info->
pkt->sport, info->
pkt->dport);
784 if (
InitFlowCmn(info, ctrl, rev_ctrl, rflow) ==
false) {
805 if (ctrl->
rt_ != NULL) {
867 info->
pkt->ip_saddr, info->
pkt->ip_daddr,
868 info->
pkt->ip_proto, info->
pkt->sport, info->
pkt->dport);
931 std::ostringstream collector;
934 std::vector<string>::const_iterator it =
937 if (collector.str() == *it) {
943 uint16_t metadata_fabric_port = 0;
945 uint16_t local_port = 0;
946 std::string nova_hostname;
949 &local_ip, &local_port,
952 &metadata_fabric_port);
1008 uint32_t ethernet_tag) {
1019 return rflow->
fip();
1055 bool set_dest_vrf =
true;
1062 set_dest_vrf =
false;
1211 if (bridge_rt != NULL) {
1254 bool rpf_enable =
true;
1288 if (src_ip_rt == NULL) {
1324 if (rflow == NULL) {
1340 assert(cnh != NULL);
1373 "in reverse flow", flow_info);
1383 "destination vrf", flow_info);
1478 std::map<uint16_t, const char*>::const_iterator it =
1481 return string(it->second);
1496 static_cast<const VrfEntry *
>(agent->
1539 static_cast<const VrfNH *
>(anh);
1570 static_cast<const VrfEntry *
>(agent->
1612 static_cast<const VrfNH *
>(anh);
1697 bool vgw_pass =
true;
1852 bool vgw_pass =
false;
1873 if (rflow != NULL) {
1876 reverse_vm_port =
static_cast<const VmInterface *
>
1911 if (vm_port != NULL) {
1913 FirewallPolicyList::const_iterator it =
1941 if (r_intf == NULL) {
1945 vm_port =
dynamic_cast<const VmInterface *
>(r_intf);
1946 if (vm_port != NULL) {
1948 FirewallPolicyList::const_iterator it =
1979 std::list<MatchAclParams> &list) {
1985 for (VmInterface::SecurityGroupEntrySet::const_iterator it =
1988 if (it->sg_ == NULL)
1991 if (it->sg_->IsAclSet()) {
1999 acl.
acl = it->sg_->GetEgressAcl();
2001 acl.
acl = it->sg_->GetIngressAcl();
2004 list.push_back(acl);
2021 if (reverse_vm_port) {
2040 if (reverse_vm_port) {
2128 if ( src_intf == NULL || dst_intf == NULL ) {
2154 (src_intf->
id() < dst_intf->
id()) ?
2196 std::string vrf_assigned_name =
2198 std::list<MatchAclParams>::const_iterator acl_it;
2199 for (acl_it =
match_p().m_vrf_assign_acl_l.begin();
2200 acl_it !=
match_p().m_vrf_assign_acl_l.end();
2202 std::string vrf = acl_it->action_info.vrf_translate_action_.vrf_name();
2207 acl_it->action_info.vrf_translate_action_.ignore_acl();
2224 std::list<MatchAclParams> &acl,
2225 bool add_implicit_deny,
bool add_implicit_allow,
2230 if (acl.size() == 0 && add_implicit_allow) {
2260 if ((hdr.
protocol == IPPROTO_ICMP ||
2272 uint32_t action = 0;
2273 for (std::list<MatchAclParams>::iterator it = acl.begin();
2274 it != acl.end(); ++it) {
2275 if (it->acl.get() == NULL) {
2279 if (it->acl->PacketMatch(hdr, *it, info)) {
2280 action |= it->action_info.action;
2284 it->action_info.mirror_l.begin(),
2285 it->action_info.mirror_l.end());
2288 if (it->terminal_rule) {
2295 if (action == 0 && add_implicit_deny) {
2357 bool tcp_rev,
bool is_sg) {
2360 if (rflow == NULL) {
2372 if (fwd_flow_info.
drop) {
2380 if (rev_flow_info.
drop) {
2386 if (tcp_rev ==
false) {
2410 if (tcp_rev ==
true) {
2498 SetAclInfo(sp, rsp, acl_info, out_acl_info,
false, is_sg);
2504 SetAclInfo(sp, rsp, acl_info, out_acl_info,
false, is_sg);
2514 SetAclInfo(sp, rsp, acl_info, out_acl_info,
false, is_sg);
2516 SetAclInfo(sp, rsp, rev_out_acl_info, rev_acl_info,
true, is_sg);
2596 true, &nw_acl_info);
2600 true,
true, &nw_acl_info);
2606 uint32_t r_policy_action =
MatchAcl(hdr,
2612 uint32_t r_out_policy_action =
MatchAcl(hdr,
2703 MatchAclParamsList::const_iterator it;
2743 it->action_info.qos_config_action_.id()
2745 i = it->action_info.qos_config_action_.id();
2753 it->action_info.qos_config_action_.id() !=
2755 i = it->action_info.qos_config_action_.id();
2763 it->action_info.qos_config_action_.id() !=
2765 i = it->action_info.qos_config_action_.id();
2773 it->action_info.qos_config_action_.id() !=
2775 i = it->action_info.qos_config_action_.id();
2800 uint32_t action = 0;
2906 if (vn && vn->
GetVrf()) {
2915 if (rvn && rvn->
GetVrf()) {
3069 std::vector<ActionStr> &action_str_l) {
3070 std::bitset<32> bs(action_info.
action);
3071 for (
unsigned int i = 0; i < bs.size(); i++) {
3076 action_str_l.push_back(astr);
3078 std::vector<MirrorActionSpec>::const_iterator m_it;
3079 for (m_it = action_info.
mirror_l.begin();
3080 m_it != action_info.
mirror_l.end();
3083 mstr.action += (*m_it).ip.to_string();
3087 mstr.action += (*m_it).vrf_name;
3089 mstr.action += (*m_it).encap;
3090 action_str_l.push_back(mstr);
3094 ActionStr vrf_action_str;
3095 vrf_action_str.action +=
3097 action_str_l.push_back(vrf_action_str);
3100 ActionStr hbf_action_str;
3101 hbf_action_str.action +=
"hbs";
3102 action_str_l.push_back(hbf_action_str);
3109 std::vector<AclAction> &acl_action_l,
3110 std::string &acl_type) {
3111 std::list<MatchAclParams>::const_iterator it;
3112 for(it = acl_l.begin(); it != acl_l.end(); ++it) {
3113 AclAction acl_action;
3114 acl_action.set_acl_id(
UuidToString((*it).acl->GetUuid()));
3115 acl_action.set_acl_type(acl_type);
3116 std::vector<ActionStr> action_str_l;
3118 acl_action.set_action_l(action_str_l);
3119 acl_action_l.push_back(acl_action);
3125 std::string acl_type(
"nw policy");
3133 acl_type =
"dynamic";
3137 acl_type =
"o nw policy";
3140 const std::list<MatchAclParams> &out_sg_acl_l =
3145 const std::list<MatchAclParams> &out_m_acl_l =
3147 acl_type =
"o dynamic";
3154 const std::list<MatchAclParams> &r_out_sg_l =
3156 acl_type =
"r o sg";
3159 const std::list<MatchAclParams> &vrf_assign_acl_l =
3161 acl_type =
"vrf assign";
3164 const std::list<MatchAclParams> &aps_l =
3166 acl_type =
"fw acl";
3169 const std::list<MatchAclParams> &out_aps_l =
3171 acl_type =
"reverse fw acl";
3173 acl_action_l, acl_type);
3175 const std::list<MatchAclParams> &fwaas_l =
3177 acl_type =
"fwaas acl";
3180 const std::list<MatchAclParams> &out_fwaas_l =
3182 acl_type =
"reverse fwaas acl";
3184 acl_action_l, acl_type);
3192 info.set_destination_ip(
key_.
dst_addr.to_v4().to_ulong());
3194 uint64_t sip[2], dip[2];
3197 info.set_sip_upper(sip[0]);
3198 info.set_sip_lower(sip[1]);
3199 info.set_dip_upper(dip[0]);
3200 info.set_dip_lower(dip[1]);
3201 info.set_source_ip(0);
3202 info.set_destination_ip(0);
3214 std::vector<uint32_t> v;
3215 SecurityGroupList::const_iterator it;
3220 info.set_source_sg_id_l(v);
3226 info.set_dest_sg_id_l(v);
3230 info.set_deny(
true);
3232 info.set_allow(
true);
3246 info.set_nat_source_ip
3249 info.set_nat_source_ip(0);
3255 info.set_nat_destination_ip
3258 info.set_nat_destination_ip(0);
3263 info.set_nat_source_port(nat_flow->
key().
dst_port);
3267 info.set_nat_destination_port(nat_flow->
key().
src_port);
3276 info.set_mirror(
true);
3277 std::vector<MirrorActionSpec>::const_iterator it;
3278 std::vector<MirrorInfo> mirror_l;
3282 MirrorInfo mirror_info;
3283 mirror_info.set_mirror_destination((*it).ip.to_string());
3284 mirror_info.set_mirror_port((*it).port);
3285 mirror_info.set_mirror_vrf((*it).vrf_name);
3286 mirror_info.set_analyzer((*it).analyzer_name);
3287 mirror_l.push_back(mirror_info);
3289 info.set_mirror_l(mirror_l);
3299 info.set_trap(
true);
3312 info.set_rpf_nh(
rpf_nh()->
id());
3314 info.set_rpf_nh(0xFFFFFFFF);
3319 info.set_src_ip_nh(0xFFFFFFFF);
3325 std::vector<AceId> &ace_l) {
3326 std::list<MatchAclParams>::const_iterator ma_it;
3327 for (ma_it = acl_l.begin();
3328 ma_it != acl_l.end();
3330 if ((*ma_it).acl != acl) {
3333 AclEntryIDList::const_iterator ait;
3334 for (ait = (*ma_it).ace_id_list.begin();
3335 ait != (*ma_it).ace_id_list.end(); ++ ait) {
3337 ace_id.id = ait->id_;
3338 ace_l.push_back(ace_id);
3344 FlowSandeshData &fe_sandesh_data,
Agent *agent)
const {
3352 std::vector<ActionStr> action_str_l;
3354 fe_sandesh_data.set_action_l(action_str_l);
3356 std::vector<AclAction> acl_action_l;
3358 fe_sandesh_data.set_acl_action_l(acl_action_l);
3381 std::vector<uint32_t> v;
3382 SecurityGroupList::const_iterator it;
3387 fe_sandesh_data.set_source_sg_id_l(v);
3393 fe_sandesh_data.set_dest_sg_id_l(v);
3401 fe_sandesh_data.set_teardown_time(
3404 fe_sandesh_data.set_teardown_time(
"");
3416 fe_sandesh_data.ace_l);
3418 fe_sandesh_data.ace_l);
3421 fe_sandesh_data.ace_l);
3423 fe_sandesh_data.ace_l);
3425 fe_sandesh_data.ace_l);
3427 fe_sandesh_data.ace_l);
3429 fe_sandesh_data.ace_l);
3431 fe_sandesh_data.ace_l);
3439 fe_sandesh_data.set_l3_flow(
l3_flow_);
3445 std::ostringstream str;
3447 str <<
" Idx : " << idx
3459 std::string &event_str) {
3462 event_str =
"FlowAdd";
3465 event_str =
"FlowUpdate";
3468 event_str =
"FlowDelete";
3471 event_str =
"FlowEvict";
3474 event_str =
"FlowHandleAssign";
3477 event_str =
"FlowMessageSkippedEvictedFlow";
3480 event_str =
"Unknown";
3499 std::vector<SandeshFlowIndexTrace> trace_list;
3500 for (
int i = 0; i < count; i++) {
3501 SandeshFlowIndexTrace
trace;
3512 trace_list.push_back(
trace);
3514 info->set_flow_index_trace(trace_list);
3518 uint32_t flow_handle, uint8_t gen_id) {
3523 <<
" flow = " << (
void *)
this
3525 <<
" flow->gen_id = " << (
int)
gen_id_
3526 <<
" ksync = " << (
void *)ksync
3527 <<
" Ksync->hash_id = " << ((ksync != NULL) ? ksync->
hash_id() : -1)
3528 <<
" Ksync->gen_id = " << ((ksync != NULL) ? (
int)ksync->
gen_id() : 0)
3530 <<
" new_gen_id = " << (
int)
gen_id);
3573 FlowRouteRefMap::const_iterator it;
3574 for (it = rt_list.begin(); it != rt_list.end(); it++) {
3575 if (it->first ==
static_cast<int>(vrf)) {
3702 const IpAddress &dip, uint8_t proto, uint16_t sport,
3703 uint16_t dport)
const {
3708 uint8_t underlay_gw_index = -1;
3711 if (rflow != NULL) {
3714 return underlay_gw_index;
3719 const TunnelNH *tunnel_nh = rt !=
nullptr ?
3729 FindInterface(intf_in);
3731 underlay_gw_index = intf->
id();
3732 return underlay_gw_index;
3734 std::size_t hash = 0;
3735 hash =
HashIp(hash, sip);
3736 hash =
HashIp(hash, dip);
3744 if (rt ==
nullptr) {
3747 if ( !(tunnel_nh && (tunnel_nh->
IsValid()))) {
3752 while (index < encap_list.size()) {
3753 if (encap_list[index].get()->interface_.get() &&
3754 underlay_gw_index == (encap_list[index].get()->interface_).get()->id()) {
3755 underlay_gw_index = index;
3762 return underlay_gw_index;
3763 }
else if ( ((underlay_gw_index +1) < (uint8_t)tunnel_nh->
GetEncapDataList().size()) &&
3765 return underlay_gw_index +1;
3766 }
else if (((underlay_gw_index +1) >= (uint8_t)tunnel_nh->
GetEncapDataList().size()) &&
3778 boost::system::error_code ec;
3793 boost::system::error_code ec;
3824 *(table->agent()->event_manager())->io_service(),
3825 "FlowPortBindTimer",
3838 if (
tree_.size() == 0) {
3844 uint16_t entries_processed = 0;
3847 PortCacheTree::iterator it =
tree_.lower_bound(
hash_);
3848 while (it !=
tree_.end() && entries_processed <= no_of_entries) {
3851 PortCacheEntryList::iterator pcit = it->second.begin();
3852 while (pcit != it->second.end() && entries_processed <= no_of_entries) {
3853 PortCacheEntryList::iterator saved_pcit = pcit;
3855 if (saved_pcit->CanBeAged(current_time,
timeout_)) {
3860 entries_processed++;
3865 if (it ==
tree_.end()) {
3886 tree_[hash].insert(cache_entry);
3888 if (
tree_.size() == 1) {
3895 tree_[hash].erase(cache_entry);
3896 if (
tree_[hash].size() == 0) {
3900 if (
tree_.size() == 0) {
3908 PortCacheEntryList::iterator it =
tree_[hash].find(cache_entry);
3909 if (it !=
tree_[hash].end()) {
3919 PortCacheTree::const_iterator pct_it =
tree_.find(hash);
3920 if (pct_it ==
tree_.end()) {
3924 PortCacheEntryList::const_iterator it = pct_it->second.find(cache_entry);
3925 if (it != pct_it->second.end()) {
3933 std::size_t hash = 0;
3934 boost::hash_combine(hash, key.
dst_addr.to_v4().to_ulong());
3935 boost::hash_combine(hash, key.
dst_port);
3941 agent_(agent), protocol_(protocol), cache_(this),
3942 hash_table_size_(hash_table_size) {
3943 for (uint32_t i = 0; i < hash_table_size; i++) {
3959 tbb::recursive_mutex::scoped_lock lock(
mutex_);
3964 return entry->
port();
3973 uint16_t index = bit_map->Insert(key);
3975 bit_map->Remove(index);
4003 tbb::recursive_mutex::scoped_lock lock(
mutex_);
4018 if (existing_key.
IsEqual(key)) {
4064 Free(key, port_no,
true);
4075 uint16_t index = it->second;
4086 std::vector<PortConfig::PortRange>::const_iterator it =
4090 if (port >= it->port_start && port <= it->port_end) {
4111 new_pc), task_id, 0));
4116 tbb::recursive_mutex::scoped_lock lock(
mutex_);
4122 for (uint16_t index = 0; index < old_port_count; index++) {
4124 if (port.get() &&
IsValidPort(port->port(), count) ==
false) {
4135 std::vector<PortConfig::PortRange>::const_iterator it =
4140 for (uint16_t port = it->port_start;
4141 it->port_end && port <= it->port_end;
4163 std::vector<FlowKey> &list)
const {
4164 tbb::recursive_mutex::scoped_lock lock(
mutex_);
4173 list.push_back(existing_key);
4188 for (uint16_t proto = 0; proto < IPPROTO_MAX; proto++) {
boost::asio::ip::address IpAddress
boost::asio::ip::address_v4 Ip4Address
void Ip6AddressToU64Array(const Ip6Address &addr, uint64_t *arr, int size)
std::vector< int > TagList
std::vector< int > SecurityGroupList
std::set< std::string > VnListType
static const uint8_t kMaxV4PrefixLen
AgentDBEntry * FindActiveEntry(const DBEntry *key)
const VnListType & dest_vn_list() const
const SecurityGroupList & sg_list() const
const std::string & origin_vn() const
const TagList & tag_list() const
static const uint32_t kInvalidIndex
virtual const PrefixType & prefix_address() const
Returns the value of a stored prefix address (IPv4, IPv6 or MAC address)
Base class for all Route entries in agent.
bool IsRPFInvalid() const
const AgentPath * GetActivePath() const
const NextHop * GetActiveNextHop() const
virtual uint8_t prefix_length() const
Returns the length of a stored prefix address.
bool is_multicast() const
InterfaceTable * interface_table() const
const std::string & dns_server(uint8_t idx) const
const std::vector< std::string > & fabric_interface_name_list() const
VrfTable * vrf_table() const
EventManager * event_manager() const
bool get_vhost_disable_policy()
const std::string & controller_ifmap_xmpp_server(uint8_t idx) const
const uint16_t dns_server_port(uint8_t idx) const
const uint16_t controller_ifmap_xmpp_port(uint8_t idx) const
static const std::string & NullString()
void set_port_config_handler(PortConfigHandler handler)
static Agent * GetInstance()
AgentStats * stats() const
std::vector< string > & GetCollectorlist()
Ip4Address router_id() const
BridgeRouteEntry * FindRoute(const MacAddress &mac)
BridgeRouteEntry * FindRouteNoLock(const MacAddress &mac)
uint8_t prefix_length() const
The length of L3 IP prefix (if present) associated with this L2 address.
static const uint32_t kInvalidComponentNHIdx
bool HasVmInterface(const VmInterface *vmi) const
static const uint16_t DnsXmpp()
static const uint16_t CollectorPort()
boost::asio::io_context * io_service()
EvpnRouteEntry * FindRouteNoLock(const MacAddress &mac, const IpAddress &ip_addr, uint32_t plen, uint32_t ethernet_tag)
static uint32_t ComputeHostIpPlen(const IpAddress &addr)
FlowEntry * Allocate(const FlowKey &key)
void Free(FlowEntry *flow)
@ DROP_FWAAS_REVERSE_POLICY
@ DROP_OUT_FIREWALL_POLICY
@ DROP_FWAAS_REVERSE_OUT_POLICY
@ DROP_REVERSE_FIREWALL_POLICY
@ DROP_REVERSE_OUT_FIREWALL_POLICY
FlowEntry * reverse_flow_entry()
void GetNonLocalFlowSgList(const VmInterface *vm_port)
const FlowKey & key() const
void SetMirrorVrfFromAction()
bool ImplicitDenyFlow() const
void SetAclAction(std::vector< AclAction > &acl_action_l) const
const boost::uuids::uuid & uuid() const
uint32_t InterfaceKeyToId(Agent *agent, const VmInterfaceKey &key)
const std::string fw_policy_uuid() const
void SetAclFlowSandeshData(const AclDBEntry *acl, FlowSandeshData &fe_sandesh_data, Agent *agent) const
void GetApplicationPolicySet(const Interface *intf, const FlowEntry *rflow)
FlowEntryPtr reverse_flow_entry_
const std::string InterfaceIdToVmCfgName(Agent *agent, uint32_t id)
FlowTableKSyncEntry * ksync_entry_
void set_flow_handle(uint32_t flow_handle, uint8_t gen_id)
const Interface * intf_entry() const
const NextHop * rpf_nh() const
void SetOutPacketHeader(PacketHeader *hdr)
const boost::uuids::uuid & egress_uuid() const
static const uint32_t kInvalidFlowHandle
uint32_t reverse_flow_fip() const
void LogFlow(FlowEventLog::Event event, FlowTableKSyncEntry *ksync, uint32_t flow_handle, uint8_t gen_id)
void InitRevFlow(const PktFlowInfo *info, const PktInfo *pkt, const PktControlInfo *ctrl, const PktControlInfo *rev_ctrl, FlowEntry *rflow, Agent *agent)
FlowEntry(FlowTable *flow_table)
const TagList & remote_tagset() const
bool is_flags_set(const FlowEntryFlags &flags) const
VmInterfaceKey fip_vmi() const
uint32_t flow_handle() const
static bool ShouldDrop(uint32_t action)
void set_acl_assigned_vrf_index()
const MacAddress & smac() const
tbb::atomic< int > refcount_
void set_flags(const FlowEntryFlags &flags)
bool is_flow_on_unresolved_list
void set_flow_mgmt_info(FlowEntryInfo *info)
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
static const std::map< FlowPolicyState, const char * > FlowPolicyStateStr
const std::string RemotePrefix() const
bool IsFabricControlFlow() const
FlowMgmtEntryInfoPtr flow_mgmt_info_
static const SecurityGroupList & default_sg_list()
const std::string & nw_ace_uuid() const
void FillUveFwdFlowStatsInfo(FlowUveFwPolicyInfo *info, bool added) const
void InitAuditFlow(uint32_t flow_idx, uint8_t gen_id)
VmInterfaceKey InterfaceIdToKey(Agent *agent, uint32_t id)
FlowStatsCollector * fsc_
static tbb::atomic< int > alloc_count_
boost::uuids::uuid egress_uuid_
void GetPolicy(const VnEntry *vn, const FlowEntry *rflow)
const std::string fw_policy_name_uuid() const
bool RpfFromSrcIpNh() const
const std::string & sg_rule_uuid() const
static AgentRoute * GetL2Route(const VrfEntry *entry, const MacAddress &mac)
void SetEventSandeshData(SandeshFlowIndexInfo *info)
void SetMirrorVrf(const uint32_t id)
static FlowEntry * Allocate(const FlowKey &key, FlowTable *flow_table)
uint32_t acl_assigned_vrf_index() const
void FillUveLocalRevFlowStatsInfo(FlowUveFwPolicyInfo *info, bool added) const
void UpdateFipStatsInfo(uint32_t fip, uint32_t id, Agent *agent)
void RpfSetSrcIpNhFields(const AgentRoute *rt, const NextHop *src_ip_nh)
uint16_t short_flow_reason_
void UpdateReflexiveAction()
bool IsIngressFlow() const
const MacAddress & dmac() const
std::string KeyString() const
const std::string BuildRemotePrefix(const FlowRouteRefMap &rt_list, uint32_t vr, const IpAddress &ip) const
void SetHbsInfofromAction()
static AgentRoute * GetUcRoute(const VrfEntry *entry, const IpAddress &addr)
void GetLocalFlowSgList(const VmInterface *vm_port, const VmInterface *reverse_vm_port)
@ SHORT_NO_SRC_ROUTE_L2RPF
void reset_flags(const FlowEntryFlags &flags)
void Copy(FlowEntry *rhs, bool update)
const MatchPolicy & match_p() const
void FillUveVnAceInfo(FlowUveVnAcePolicyInfo *info) const
static const std::map< uint16_t, const char * > FlowDropReasonStr
static SecurityGroupList default_sg_list_
void RpfSetRpfNhFields(const NextHop *rpf_nh)
FlowTable * flow_table() const
void SetHbsInterface(HbsInterface intf)
static std::string DropReasonStr(uint16_t reason)
static AgentRoute * GetEvpnRoute(const VrfEntry *entry, const MacAddress &mac, const IpAddress &addr, uint32_t ethernet_tag)
void Reset(const FlowKey &k)
const VrfEntry * GetDestinationVrf() const
void RpfInit(const AgentRoute *rt, const IpAddress &sip)
std::string peer_vrouter_
void GetSgList(const Interface *intf)
void GetDestRouteInfo(const AgentRoute *rt)
VmInterfaceKey reverse_flow_vmi() const
void MakeShortFlow(FlowShortReason reason)
void InitFwdFlow(const PktFlowInfo *info, const PktInfo *pkt, const PktControlInfo *ctrl, const PktControlInfo *rev_ctrl, FlowEntry *rflow, Agent *agent)
void SetAclInfo(SessionPolicy *sp, SessionPolicy *rsp, const FlowPolicyInfo &fwd_flow_info, const FlowPolicyInfo &rev_flow_info, bool tcp_rev, bool is_sg)
uint16_t event_log_index_
const TagList & local_tagset() const
const VnEntry * vn_entry() const
void FillUveFwStatsInfo(FlowUveFwPolicyInfo *info, bool added) const
void SessionMatch(SessionPolicy *sp, SessionPolicy *rsp, bool is_sg)
void FillFlowInfo(FlowInfo &info) const
const NextHop * src_ip_nh() const
boost::scoped_array< FlowEventLog > event_logs_
void RevFlowDepInfo(RevFlowDepParams *params)
uint8_t GetUnderlayGwIndex(uint32_t intf_in, const IpAddress &sip, const IpAddress &dip, uint8_t proto, uint16_t sport, uint16_t dport) const
void SetPacketHeader(PacketHeader *hdr)
void GetSourceRouteInfo(const AgentRoute *rt)
uint8_t flow_retry_attempts_
FlowMgmtRequest * flow_mgmt_request_
FlowPendingAction pending_actions_
bool InitFlowCmn(const PktFlowInfo *info, const PktControlInfo *ctrl, const PktControlInfo *rev_ctrl, FlowEntry *rflow)
@ LinkLocalBindLocalSrcPort
uint64_t teardown_time() const
static const VnListType UnknownVnList()
static const std::string UnknownVn()
bool SetRecomputeDBEntry()
bool CanRecomputeDBEntry()
void ResetRecomputeDBEntry()
void DeleteFlowRequest(FlowEntry *flow)
void ForceEnqueueFreeFlowReference(FlowEntryPtr &flow)
void update_linklocal_flow_count(int val)
PortTableManager * port_table_manager()
bool FindFlowExportInfo(const FlowEntry *fe, FlowEntryTree::iterator &it)
static void GetFlowSandeshActionParams(const FlowAction &action_info, std::string &action_str)
void DelLinkLocalFlowInfo(int fd)
uint16_t table_index() const
FlowEntryFreeList * free_list()
boost::uuids::uuid rand_gen()
FlowEntryMap flow_entry_map_
void AddLinkLocalFlowInfo(int fd, uint32_t index, const FlowKey &key, const uint64_t timestamp)
bool ConcurrencyCheck(int task_id, bool check_task_instance)
static const std::string kMetadataService
size_t Insert(EntryType entry)
EntryType At(size_t index) const
void Remove(size_t index)
uint8_t prefix_length() const
!
const Interface * FindInterface(size_t index) const
const NextHop * flow_key_nh() const
const std::string & name() const
const AgentQosConfig * qos_config() const
static const uint32_t kInvalidIndex
const boost::uuids::uuid & GetUuid() const
const uint32_t id() const
uint16_t sm_log_count() const
KSyncFlowIndexManager * ksync_flow_index_manager() const
std::string ToString() const
GlobalVrouter * global_vrouter() const
FlowRouteRefMap flow_dest_plen_map
boost::shared_ptr< PktInfo > pkt
bool linklocal_bind_local_port
bool bgp_router_service_flow
uint32_t out_component_nh_idx
bool flood_unknown_unicast
uint16_t short_flow_reason
FlowRouteRefMap flow_source_plen_map
static bool ComputeDirection(const Interface *intf)
bool IsGwPacket(const Interface *intf, const IpAddress &dst_ip)
FlowProto * get_flow_proto() const
PktHandler * pkt_handler() const
bool CanBeAged(uint64_t current_time, uint64_t timeout) const
const FlowKey & key() const
bool operator<(const PortCacheEntry &rhs) const
void set_stale(bool stale) const
const PortCacheEntry * Find(const FlowKey &key) const
static const uint64_t kCacheAging
PortCacheTable(PortTable *table)
void MarkDelete(const PortCacheEntry &cache_entry)
void Add(const PortCacheEntry &cache_entry)
void Delete(const PortCacheEntry &cache_entry)
PortTablePtr port_table_list_[IPPROTO_MAX]
static void PortConfigHandler(Agent *agent, uint8_t protocol, const PortConfig *pc)
void Free(const FlowKey &key, uint16_t port, bool release)
boost::shared_ptr< PortTable > PortTablePtr
void UpdatePortConfig(uint8_t protocol, const PortConfig *config)
uint16_t Allocate(const FlowKey &key)
PortTableManager(Agent *agent, uint16_t hash_table_size)
std::pair< uint16_t, uint16_t > PortToBitIndexPair
uint16_t hash_table_size_
void GetFlowKeyList(uint16_t port, std::vector< FlowKey > &key) const
uint16_t HashFlowKey(const FlowKey &key)
tbb::recursive_mutex mutex_
void UpdatePortConfig(const PortConfig *port_config)
tbb::recursive_mutex & mutex()
boost::shared_ptr< PortBitMap > PortBitMapPtr
static const uint8_t kInvalidPort
uint16_t GetPortIndex(uint16_t port) const
uint16_t Allocate(const FlowKey &key)
PortToBitIndexMap port_to_bit_index_
void DeletePort(uint16_t port_no)
std::unique_ptr< TaskTrigger > task_trigger_
IndexVector< FlowKey > PortBitMap
bool HandlePortConfig(const PortConfig &pc)
boost::shared_ptr< Port > PortPtr
void Free(const FlowKey &key, uint16_t port, bool release)
bool IsValidPort(uint16_t port, uint16_t count)
void DeleteAllFlow(uint16_t port, uint16_t index)
void Relocate(uint16_t port_no)
void AddPort(uint16_t port_no)
PortPtr CreatePortEntry(uint16_t port_no)
PortTable(Agent *agent, uint32_t bucket_size, uint8_t protocol)
PortHashTable hash_table_
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
int GetTaskId(const std::string &name)
static TaskScheduler * GetInstance()
boost::asio::ip::tcp::socket socket_
static bool DeleteTimer(Timer *Timer)
bool Start(int time, Handler handler, ErrorHandler error_handler=NULL)
static std::string ActionToString(enum Action at)
static const uint32_t IMPLICIT_DENY_FLAGS
static const uint32_t DROP_FLAGS
std::vector< EncapDataPtr > EncapDataList
const bool & IsEncapValid(const uint32_t &i) const
const EncapDataList GetEncapDataList() const
boost::asio::ip::udp::socket socket_
void update_flow_count(int val) const
const string & GetCfgName() const
void operator=(const VmFlowRef &rhs)
bool AllocateFd(Agent *agent, uint8_t l3_proto)
void SetVm(const VmEntry *vm)
void Reset(bool reset_flow)
void Init(FlowEntry *flow)
void Move(VmFlowRef *rhs)
static const int kInvalidFd
const VmEntry * vm() const
bool policy_enabled() const
VmInterface::VmiType vmi_type() const
const std::string & service_intf_type() const
const boost::uuids::uuid & vmi_cfg_uuid() const
const FirewallPolicyList & fwaas_fw_policy_list() const
const FirewallPolicyList & fw_policy_list() const
const VmEntry * vm() const
const SecurityGroupEntryList & sg_list() const
bool is_vn_qos_config() const
const AclDBEntry * vrf_assign_acl() const
void update_flow_count(int val) const
VrfEntry * GetVrf() const
const string & GetName() const
const AclDBEntry * GetAcl() const
const AclDBEntry * GetMirrorAcl() const
const AclDBEntry * GetMirrorCfgAcl() const
AgentRouteTable * GetBridgeRouteTable() const
InetUnicastRouteEntry * GetUcRoute(const IpAddress &addr) const
static const uint32_t kInvalidIndex
const uint32_t vrf_id() const
AgentRouteTable * GetEvpnRouteTable() const
const VrfEntry * GetVrf() const
VrfEntry * FindVrfFromId(size_t index)
static void SetAclListAceId(const AclDBEntry *acl, const MatchAclParamsList &acl_l, std::vector< AceId > &ace_l)
void SetActionStr(const FlowAction &action_info, std::vector< ActionStr > &action_str_l)
static bool CopySgEntries(const VmInterface *vm_port, bool ingress_acl, std::list< MatchAclParams > &list)
static void SetAclListAclAction(const std::list< MatchAclParams > &acl_l, std::vector< AclAction > &acl_action_l, std::string &acl_type)
void intrusive_ptr_release(FlowEntry *fe)
static std::string EventToString(FlowEventLog::Event event, std::string &event_str)
static std::size_t HashCombine(std::size_t hash, uint64_t val)
static std::size_t HashIp(std::size_t hash, const IpAddress &ip)
void intrusive_ptr_add_ref(FlowEntry *fe)
static std::vector< std::string > MakeList(const VnListType &ilist)
static void SetRpfFieldsInternal(FlowEntry *flow, const AgentRoute *rt)
boost::intrusive_ptr< FlowEntry > FlowEntryPtr
std::list< MatchAclParams > MatchAclParamsList
#define FLOW_TRACE(obj,...)
#define LOG(_Level, _Msg)
map< int, int > FlowRouteRefMap
#define BGP_SERVICE_TTL_REV_FLOW
#define BGP_SERVICE_TTL_FWD_FLOW
static std::string UuidToString(const boost::uuids::uuid &id)
static const std::string integerToString(const NumberType &num)
VrfTranslateActionSpec vrf_translate_action_
std::vector< MirrorActionSpec > mirror_l
uint32_t bgp_as_a_service_dport
std::string origin_vn_dst
std::vector< std::string > OriginVnSrcList() const
NextHopConstRef src_ip_nh
uint8_t underlay_gw_index_
uint32_t acl_assigned_vrf_index_
FlowRouteRefMap flow_dest_plen_map
std::vector< std::string > OriginVnDstList() const
std::string source_vn_match
VnListType origin_vn_src_list
std::vector< std::string > SourceVnList() const
uint32_t component_nh_idx
FlowRouteRefMap flow_source_plen_map
std::vector< std::string > DestinationVnList() const
SecurityGroupList source_sg_id_l
VnListType source_vn_list
std::string origin_vn_src
bool vrf_assign_evaluated
uint32_t bgp_as_a_service_sport
std::string dest_vn_match
SecurityGroupList dest_sg_id_l
InterfaceConstRef intf_entry
VnListType origin_vn_dst_list
uint32_t vrouter_flow_handle_
FlowTableKSyncEntry * ksync_entry_
bool IsEqual(const FlowKey &key) const
bool IsLess(const FlowKey &key) const
std::string remote_prefix_
uint32_t out_mirror_action
MatchAclParamsList m_mirror_acl_l
MatchAclParamsList m_vrf_assign_acl_l
SessionPolicy fwaas_policy
MatchAclParamsList m_out_acl_l
MatchAclParamsList m_out_mirror_acl_l
MatchAclParamsList m_acl_l
uint32_t vrf_assign_acl_action
uint32_t out_policy_action
const AgentHdr & GetAgentHdr() const
std::vector< PortRange > port_range
boost::uuids::uuid rev_egress_uuid_
boost::uuids::uuid rev_uuid_
uint32_t reverse_out_action
MatchAclParamsList m_reverse_out_acl_l
bool reverse_out_rule_present
void ResetRuleMatchInfo()
MatchAclParamsList m_reverse_acl_l
MatchAclParamsList m_acl_l
MatchAclParamsList m_out_acl_l
bool reverse_rule_present
SecurityGroupEntrySet list_
void set_ignore_acl(bool ignore_acl)
void set_vrf_name(const std::string &vrf_name)
const std::string & vrf_name() const
static uint64_t ClockMonotonicUsec()
static boost::posix_time::ptime UTCUsecToPTime(uint64_t tusec)
static uint64_t UTCTimestampUsec()