1
0
mirror of https://github.com/fwbuilder/fwbuilder synced 2026-03-19 01:37:17 +01:00

see #2191 "Crash when compiling a route with table object". Compiler

for PF crashed when run-time AddressTable object was used in RDst of a
routing rule.
This commit is contained in:
Vadim Kurland 2011-07-07 18:58:46 -07:00
parent 3cd58db242
commit 98593d3843
4 changed files with 61 additions and 0 deletions

View File

@ -1,5 +1,10 @@
2011-07-07 Vadim Kurland <vadim@netcitadel.com>
* RoutingCompiler.cpp (processNext): see #2191 "Crash when
compiling a route with table object". Compiler for PF crashed
when run-time AddressTable object was used in RDst of a routing
rule.
* PFImporter.cpp (makeAddressObj): see #2546 "PF import - negation
inside of inline tables is ignored". Since we can not import
address lists or tables that contain a mix of negated and

View File

@ -32,6 +32,7 @@
#include "RoutingCompiler.h"
#include "fwbuilder/AddressTable.h"
#include "fwbuilder/AddressRange.h"
#include "fwbuilder/RuleElement.h"
#include "fwbuilder/Network.h"
@ -53,6 +54,7 @@
#include "fwbuilder/XMLTools.h"
#include "fwbuilder/FWException.h"
#include "fwbuilder/Group.h"
#include "fwbuilder/MultiAddress.h"
#include <iostream>
#include <iomanip>
@ -831,4 +833,35 @@ bool RoutingCompiler::createSortedDstIdsLabel::processNext()
return true;
}
/*
* This is identical to
* PolicyCompiler_ipf::processMultiAddressObjectsInRE::processNext()
* TODO: move the code to the class Compiler so it can be reused.
*/
bool RoutingCompiler::processMultiAddressObjectsInRE::processNext()
{
RoutingRule *rule = getNext(); if (rule==NULL) return false;
RuleElement *re = RuleElement::cast( rule->getFirstByType(re_type) );
for (FWObject::iterator i=re->begin(); i!=re->end(); i++)
{
FWObject *o= *i;
if (FWReference::cast(o)!=NULL) o=FWReference::cast(o)->getPointer();
MultiAddressRunTime *atrt = MultiAddressRunTime::cast(o);
if (atrt!=NULL && atrt->getSubstitutionTypeName()==AddressTable::TYPENAME)
compiler->abort(
rule,
"Run-time AddressTable objects are not supported.");
AddressTable *at = AddressTable::cast(o);
if (at && at->isRunTime())
compiler->abort(
rule,
"Run-time AddressTable objects are not supported.");
}
tmp_queue.push_back(rule);
return true;
}

View File

@ -230,6 +230,26 @@ namespace fwcompiler
};
friend class RoutingCompiler::classifyRoutingRules;
/**
* Placeholders for MultiAddressRunTime objects
*/
class processMultiAddressObjectsInRE : public RoutingRuleProcessor
{
std::string re_type;
public:
processMultiAddressObjectsInRE(const std::string &name,
const std::string &t) : RoutingRuleProcessor(name) { re_type=t; }
virtual bool processNext();
};
class processMultiAddressObjectsInRDst : public processMultiAddressObjectsInRE
{
public:
processMultiAddressObjectsInRDst(const std::string &n) :
processMultiAddressObjectsInRE(
n, libfwbuilder::RuleElementRDst::TYPENAME) {}
};
/**
* detects if rules r1 and r2 are identical (that is, have the
* same effect, rather than use the same objects)

View File

@ -207,6 +207,9 @@ void RoutingCompiler_openbsd::compile()
add(new addressRangesInDst("process address ranges"));
add( new processMultiAddressObjectsInRDst(
"process MultiAddress objects in RDst") );
//add(new eliminateDuplicatesInDST("Eliminate duplicates in DST"));
add(new FindDefaultRoute("Find rules that install default route"));