Commit adc33e79 authored by Kaarle Ritvanen's avatar Kaarle Ritvanen
Browse files

Filter: allow limits with pass action

parent 1d8ee361
......@@ -341,8 +341,12 @@ function Filter:mangleoptfrags(ofrags)
local limit = self:limit()
if not limit then return Filter.super(self):mangleoptfrags(ofrags) end
if self.action ~= 'accept' then
self:error('Cannot specify limit for '..self.action..' filter')
local function incompatible(item)
self:error('Limit incompatible with '..item)
if self:customtarget() or self:logdefault() then
incompatible('action: '..self.action)
local limitchain = self:uniqueid('limit')
......@@ -351,17 +355,27 @@ function Filter:mangleoptfrags(ofrags)
local ofs
local conn = limit == 'conn-limit'
local target = self:target()
local ct = conn and target
local pl = not target and self.log
local uofs, sofs = limitobj:recentofrags(limitchain)
if uofs then
ofs = self:combinelog(uofs, limitlog, 'drop', 'DROP')
if conn then extend(ofs, self:actofrags(self.log)) end
extend(ofs, combinations(sofs, {{target=conn and 'ACCEPT'}}))
local nxt
if ct then
extend(ofs, self:actofrags(self.log))
nxt = target
elseif not pl then nxt = false end
extend(ofs, combinations(sofs, self:actofrags(pl, nxt)))
if pl then incompatible('action or log') end
local limofs = limitobj:limitofrags(limitchain)
ofs = conn and Filter.super(self):mangleoptfrags(limofs) or
ofs = ct and Filter.super(self):mangleoptfrags(limofs) or
combinations(limofs, {{target='RETURN'}})
extend(ofs, self:actofrags(limitlog, 'DROP'))
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