Skip to content

Commit

Permalink
IPv4 reassembly: Periodically update counters
Browse files Browse the repository at this point in the history
  • Loading branch information
wingo committed Aug 16, 2017
1 parent 90b9c54 commit 597f744
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/apps/ipv4/reassemble.lua
Original file line number Diff line number Diff line change
Expand Up @@ -158,12 +158,16 @@ function Reassembler:new(conf)
o.ctab = ctablew.new(params)
o.scratch_fragment_key = params.key_type()
o.scratch_reassembly = params.value_type()
o.next_counter_update = -1

-- counter.set(o.counters["memuse-ipv4-frag-reassembly-buffer"],
-- o.ctab:get_backing_size())
return setmetatable(o, {__index=Reassembler})
end

function Reassembler:update_counters()
counter.set(self.shm["memuse-ipv4-frag-reassembly-buffer"],
o.ctab:get_backing_size())
end

function Reassembler:record_eviction()
counter.add(self.shm["drop-ipv4-frag-random-evicted"])
end
Expand Down Expand Up @@ -298,6 +302,13 @@ function Reassembler:push ()
packet.free(pkt)
end
end

if self.next_counter_update < engine.now() then
-- Update counters every second, but add a bit of jitter to smooth
-- things out.
self:update_counters()
self.next_counter_update = engine.now() + math.random(0.9, 1.1)
end
end

function selftest()
Expand Down

0 comments on commit 597f744

Please sign in to comment.