Skip to content

Commit

Permalink
Logic to reset statistics of the evicted reverse flow
Browse files Browse the repository at this point in the history
The point where we reset statistics for an evicted flow is when we
trap the first packet to the agent. The trap message carries the
old statistics. However, for the reverse flow, there is no trap.
Hence, the statistics of the evicted reverse flow entry is sent
back to the agent in the sandesh flow message and reset once the
agent tries to add the reverse flow entry.

Change-Id: Ic67318b9632f39560292512be503f90eb6f33068
Closes-BUG: 1362701
  • Loading branch information
anandhk-juniper committed Dec 15, 2015
1 parent c8bffc8 commit a345a66
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
28 changes: 22 additions & 6 deletions dp-core/vr_flow.c
Original file line number Diff line number Diff line change
Expand Up @@ -1789,18 +1789,34 @@ vr_flow_set(struct vrouter *router, vr_flow_req *req)
fe->fe_drop_reason = (uint8_t)req->fr_drop_reason;

fe->fe_flags = VR_FLOW_FLAG_MASK(req->fr_flags);
if (new_flow && (fe->fe_flags & VR_RFLOW_VALID)) {
rfe = vr_get_flow_entry(router, fe->fe_rflow);
if (rfe) {
if (rfe->fe_tcp_flags & VR_FLOW_TCP_SYN) {
(void)__sync_fetch_and_or(&fe->fe_tcp_flags,
VR_FLOW_TCP_SYN_R);
if (new_flow) {

req->fr_flow_bytes = fe->fe_stats.flow_bytes;
req->fr_flow_packets = fe->fe_stats.flow_packets;
req->fr_flow_stats_oflow = (fe->fe_stats.flow_bytes_oflow |
(fe->fe_stats.flow_packets_oflow << 16));

if (fe->fe_flags & VR_FLOW_FLAG_NEW_FLOW) {
if (fe->fe_stats.flow_packets || fe->fe_stats.flow_packets_oflow)
memset(&fe->fe_stats, 0, sizeof(fe->fe_stats));
}

if (fe->fe_flags & VR_RFLOW_VALID) {
rfe = vr_get_flow_entry(router, fe->fe_rflow);
if (rfe) {
if (rfe->fe_tcp_flags & VR_FLOW_TCP_SYN) {
(void)__sync_fetch_and_or(&fe->fe_tcp_flags,
VR_FLOW_TCP_SYN_R);
}
}
}
}

vr_flow_udp_src_port(router, fe);

if (fe->fe_flags & VR_FLOW_FLAG_NEW_FLOW)
fe->fe_flags &= ~VR_FLOW_FLAG_NEW_FLOW;

ret = vr_flow_schedule_transition(router, req, fe);

exit_set:
Expand Down
3 changes: 3 additions & 0 deletions sandesh/vr.sandesh
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ buffer sandesh vr_flow_req {
30: i32 fr_cpus;
31: i32 fr_hold_oflows;
32: list<i32> fr_hold_stat;
33: u32 fr_flow_bytes;
34: u32 fr_flow_packets;
35: u32 fr_flow_stats_oflow;
}

buffer sandesh vr_vrf_assign_req {
Expand Down

0 comments on commit a345a66

Please sign in to comment.