Commit fd780ffd authored by Kaarle Ritvanen's avatar Kaarle Ritvanen

consistent chain names in level 5 dump

parent e4df90e6
......@@ -89,6 +89,8 @@ Rule = class(ConfigObject)
function Rule:init(...)
ConfigObject.init(self, unpack(arg))
self.newchains = {}
for i, prop in ipairs({'in', 'out'}) do
self[prop] = self[prop] and util.maplist(self[prop],
function(z)
......@@ -368,14 +370,20 @@ end
function Rule:extraoptfrags() return {} end
function Rule:newchain(base)
function Rule:newchain(key)
if self.newchains[key] then return self.newchains[key] end
if not self.context.lastid then self.context.lastid = {} end
local lastid = self.context.lastid
if self.label then base = base..'-'..self.label end
if not lastid[base] then lastid[base] = -1 end
lastid[base] = lastid[base] + 1
return base..'-'..lastid[base]
local res = key
if self.label then res = res..'-'..self.label end
if not lastid[res] then lastid[res] = -1 end
lastid[res] = lastid[res] + 1
res = res..'-'..lastid[res]
self.newchains[key] = res
return res
end
......
......@@ -95,8 +95,7 @@ end
function Filter:target()
if not self:limit() then return model.Rule.target(self) end
if not self['limit-target'] then self['limit-target'] = self:newchain('limit') end
return self['limit-target']
return self:newchain('limit')
end
function Filter:extraoptfrags()
......
......@@ -26,12 +26,7 @@ end
local RouteTrackRule = model.class(MarkRule)
function RouteTrackRule:target()
if not self['mark-target'] then
self['mark-target'] = self:newchain('mark')
end
return self['mark-target']
end
function RouteTrackRule:target() return self:newchain('mark') end
function RouteTrackRule:servoptfrags()
return awall.optfrag.combinations(MarkRule.servoptfrags(self),
......
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