13 #include <vr_mirror.h>
24 0), response_context_(resp_ctx), flow_idx_(idx), evicted_(0),
25 flow_iteration_key_(0), agent_(agent) {
29 const string &iter_idx) :
31 0), response_context_(resp_ctx), flow_idx_(-1), evicted_(0),
32 flow_iteration_key_(0), agent_(agent) {
43 case VR_FLOW_FLAG_ACTIVE:
45 case VR_FLOW_FLAG_MIRROR:
47 case VR_FLOW_FLAG_VRFT:
49 case VR_FLOW_FLAG_SNAT:
51 case VR_FLOW_FLAG_SPAT:
53 case VR_FLOW_FLAG_DNAT:
55 case VR_FLOW_FLAG_DPAT:
57 case VR_FLOW_FLAG_LINK_LOCAL:
58 return " LINK_LOCAL ";
59 case VR_FLOW_FLAG_EVICTED:
61 case VR_FLOW_FLAG_EVICT_CANDIDATE:
62 return " EVICT_CANDIDATE ";
63 case VR_FLOW_FLAG_NEW_FLOW:
65 case VR_FLOW_FLAG_MODIFIED:
68 return " RFLOW_VALID ";
78 case VR_FLOW_TCP_SYN_R:
80 case VR_FLOW_TCP_ESTABLISHED:
82 case VR_FLOW_TCP_ESTABLISHED_R:
86 case VR_FLOW_TCP_FIN_R:
90 case VR_FLOW_TCP_HALF_CLOSE:
91 return " HALF_CLOSE ";
92 case VR_FLOW_TCP_DEAD:
100 unsigned cflag)
const {
109 str.append(
"|" + flag_str);
111 str.assign(flag_str);
119 case VR_FLOW_DR_UNKNOWN:
121 case VR_FLOW_DR_UNAVIALABLE_INTF:
123 case VR_FLOW_DR_IPv4_FWD_DIS:
125 case VR_FLOW_DR_UNAVAILABLE_VRF:
127 case VR_FLOW_DR_NO_SRC_ROUTE:
129 case VR_FLOW_DR_NO_DST_ROUTE:
131 case VR_FLOW_DR_AUDIT_ENTRY:
133 case VR_FLOW_DR_VRF_CHANGE:
135 case VR_FLOW_DR_NO_REVERSE_FLOW:
137 case VR_FLOW_DR_REVERSE_FLOW_CHANGE:
138 return "RevFlowChng";
139 case VR_FLOW_DR_NAT_CHANGE:
141 case VR_FLOW_DR_FLOW_LIMIT:
143 case VR_FLOW_DR_LINKLOCAL_SRC_NAT:
144 return "LinkSrcNatErr";
145 case VR_FLOW_DR_POLICY:
147 case VR_FLOW_DR_OUT_POLICY:
151 case VR_FLOW_DR_OUT_SG:
153 case VR_FLOW_DR_REVERSE_SG:
155 case VR_FLOW_DR_REVERSE_OUT_SG:
157 case VR_FLOW_DR_FW_POLICY:
159 case VR_FLOW_DR_OUT_FW_POLICY:
160 return "OutFwPolicy";
161 case VR_FLOW_DR_REVERSE_FW_POLICY:
162 return "RevFwPolicy";
163 case VR_FLOW_DR_REVERSE_OUT_FW_POLICY:
164 return "RevOutFwPolicy";
165 case VR_FLOW_DR_SAME_FLOW_RFLOW_KEY:
166 return "SameFlowRflowKey";
181 const vr_flow_entry *k_flow,
182 const int index)
const {
184 bool action_drop =
false;
189 string flag_str, tcp_flags;
190 data.set_index((
unsigned int)index);
191 data.set_sport((
unsigned)ntohs(k_flow->fe_key.flow4_sport));
192 data.set_dport((
unsigned)ntohs(k_flow->fe_key.flow4_dport));
193 data.set_sip(sip.to_string());
194 data.set_dip(dip.to_string());
195 data.set_vrf_id(k_flow->fe_vrf);
196 data.set_proto(k_flow->fe_key.flow4_proto);
197 data.set_nhid(k_flow->fe_key.flow_nh_id);
198 switch (k_flow->fe_action) {
199 case VR_FLOW_ACTION_FORWARD:
200 action_str.assign(
"FORWARD");
202 case VR_FLOW_ACTION_DROP:
203 action_str.assign(
"DROP");
206 case VR_FLOW_ACTION_NAT:
207 action_str.assign(
"NAT");
209 case VR_FLOW_ACTION_HOLD:
210 action_str.assign(
"HOLD");
213 action_str.assign(
"INVALID");
215 data.set_action(action_str);
216 bool assigned =
false;
218 VR_FLOW_FLAG_ACTIVE);
220 VR_FLOW_FLAG_MIRROR);
232 VR_FLOW_FLAG_LINK_LOCAL);
234 VR_FLOW_FLAG_EVICTED);
236 VR_FLOW_FLAG_EVICT_CANDIDATE);
238 VR_FLOW_FLAG_NEW_FLOW);
240 VR_FLOW_FLAG_MODIFIED);
241 UpdateFlagStr(flag_str, assigned,
false, k_flow->fe_flags, VR_RFLOW_VALID);
242 data.set_flags(flag_str);
244 if (k_flow->fe_key.flow4_proto == IPPROTO_TCP) {
246 UpdateFlagStr(tcp_flags, assigned,
true, k_flow->fe_tcp_flags,
248 UpdateFlagStr(tcp_flags, assigned,
true, k_flow->fe_tcp_flags,
250 UpdateFlagStr(tcp_flags, assigned,
true, k_flow->fe_tcp_flags,
251 VR_FLOW_TCP_ESTABLISHED);
252 UpdateFlagStr(tcp_flags, assigned,
true, k_flow->fe_tcp_flags,
253 VR_FLOW_TCP_ESTABLISHED_R);
254 UpdateFlagStr(tcp_flags, assigned,
true, k_flow->fe_tcp_flags,
256 UpdateFlagStr(tcp_flags, assigned,
true, k_flow->fe_tcp_flags,
258 UpdateFlagStr(tcp_flags, assigned,
true, k_flow->fe_tcp_flags,
260 UpdateFlagStr(tcp_flags, assigned,
true, k_flow->fe_tcp_flags,
261 VR_FLOW_TCP_HALF_CLOSE);
262 UpdateFlagStr(tcp_flags, assigned,
true, k_flow->fe_tcp_flags,
264 data.set_tcp_flags(tcp_flags);
269 data.set_underlay_udp_sport(k_flow->fe_udp_src_port);
270 data.set_rflow(k_flow->fe_rflow);
271 data.set_d_vrf_id(k_flow->fe_dvrf);
272 data.set_bytes(k_flow->fe_stats.flow_bytes);
273 data.set_pkts(k_flow->fe_stats.flow_packets);
274 if (k_flow->fe_mirror_id != VR_MAX_MIRROR_INDICES) {
275 data.set_mirror_id(k_flow->fe_mirror_id);
277 if (k_flow->fe_sec_mirror_id != VR_MAX_MIRROR_INDICES) {
278 data.set_sec_mirror_id(k_flow->fe_sec_mirror_id);
280 if (k_flow->fe_ecmp_nh_index != -1) {
281 data.set_ecmp_index(k_flow->fe_ecmp_nh_index);
283 data.set_ttl(k_flow->fe_ttl);
284 data.set_qos_id(k_flow->fe_qos_id);
285 data.set_gen_id(k_flow->fe_gen_id);
286 data.set_tcp_seq(k_flow->fe_tcp_seq);
287 data.set_oflow_bytes(k_flow->fe_stats.flow_bytes_oflow);
288 data.set_oflow_packets(k_flow->fe_stats.flow_packets_oflow);
289 data.set_underlay_gw_index(k_flow->fe_underlay_ecmp_index);
290 list.push_back(data);
295 const vr_flow_entry *k_flow;
303 resp =
new KFlowResp();
304 vector<KFlowInfo> &list =
const_cast<std::vector<KFlowInfo>&
>
305 (resp->get_flow_list());
309 ErrResp *resp =
new ErrResp();
318 resp =
new KFlowResp();
319 vector<KFlowInfo> &list =
const_cast<std::vector<KFlowInfo>&
>
320 (resp->get_flow_list());
321 while(idx < max_flows) {
325 if((k_flow->fe_flags & VR_FLOW_FLAG_EVICTED) && (!
evicted_)) {
332 if (idx != max_flows) {
The TaskScheduler keeps track of what tasks are currently schedulable. When a task is enqueued it is ...
void SetFlowHandle(KFlowResp *resp, const uint32_t idx) const
uint32_t flow_iteration_key_
boost::asio::ip::address IpAddress
bool stringToInteger(const std::string &str, NumberType &num)
std::string response_context_
void SetFlowData(std::vector< KFlowInfo > &list, const vr_flow_entry *k_flow, int index) const
const std::string FlagToStr(unsigned int flag) const
static void VrFlowToIp(const vr_flow_entry *kflow, IpAddress *sip, IpAddress *dip)
const std::string TcpFlagToStr(unsigned int flag) const
static const std::string integerToString(const NumberType &num)
virtual bool Run()
Code to execute. Returns true if task is completed. Return false to reschedule the task...
uint32_t table_entries_count()
const vr_flow_entry * GetKernelFlowEntry(uint32_t idx, bool ignore_active_status) const
static const int kMaxEntriesPerResponse
FlowKState(Agent *agent, const std::string &resp_ctx, int idx)
const std::string DropCodeToStr(uint8_t drop_code) const
KSyncFlowMemory * ksync_flow_memory() const
Task is a wrapper over tbb::task to support policies.
virtual void SendResponse(KFlowResp *resp) const
void UpdateFlagStr(std::string &str, bool &set, bool tcp, unsigned sflag, unsigned cflag) const