Commit 543bf7e7 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

Filter: zero limits

ref #9641
parent 6f98251b
......@@ -295,7 +295,7 @@ function Filter:extratrules()
end
if self.action == 'accept' then
if self:position() == 'prepend' then
if self:position() == 'prepend' and self['flow-limit'].count > 0 then
extrarules('final', LoggingRule, {update={log=self.log}})
end
......@@ -381,9 +381,14 @@ function Filter:mangleoptfrags(ofrags)
incompatible('action: '..self.action)
end
local limitchain = self:uniqueid('limit')
local limitlog = self[limit].log
local function drop(ofs)
return self:combinelog(ofs, limitlog, 'drop', 'DROP')
end
local limitobj = self:create(FilterLimit, self[limit], 'limit')
if limitobj.count == 0 then return drop(ofrags) end
local ofs
local final = self:position() == 'append'
......@@ -391,10 +396,11 @@ function Filter:mangleoptfrags(ofrags)
local ft = final and target
local pl = not target and self.log
local limitchain = self:uniqueid('limit')
local cofs, sofs = limitobj:recentofrags(limitchain)
if cofs then
ofs = self:combinelog(cofs, limitlog, 'drop', 'DROP')
ofs = drop(cofs)
local nxt
if ft then
......
--[[
Filter limit test cases for Alpine Wall
Copyright (C) 2012-2017 Kaarle Ritvanen
Copyright (C) 2012-2020 Kaarle Ritvanen
See LICENSE file for license details
]]--
......@@ -14,7 +14,9 @@ function add(limit_type, filter)
local logopts = {false, true, 'mirror', 'none', 'ulog'}
for _, high_rate in ipairs{false, true} do
for _, count in ipairs{0, false, 150} do
local high_rate = count == 150
local function add_limit(limit)
for _, log in ipairs(logopts) do
......@@ -36,12 +38,11 @@ function add(limit_type, filter)
end
end
local count = high_rate and 150 or nil
add_limit(count or 1)
for _, interval in ipairs{false, 5} do
for _, log in ipairs(logopts) do
local limit = {count=count, interval=interval or nil}
local limit = {count=count or nil, interval=interval or nil}
if log ~= true then limit.log = log end
add_limit(limit)
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment