diff --git a/src/pf/pf.cpp b/src/pf/pf.cpp index 5e16f28b1..cfa86517c 100644 --- a/src/pf/pf.cpp +++ b/src/pf/pf.cpp @@ -519,11 +519,6 @@ int main(int argc, char * const *argv) options->getStr("pf_limit_table_entries")); if (limits.size() > 0) - - if ( ! options->getStr("pf_optimization").empty() ) - pf_file << "set optimization " - << options->getStr("pf_optimization") << endl; - { pf_file << "set limit "; if (limits.size() > 1 ) pf_file << "{ "; @@ -534,6 +529,10 @@ int main(int argc, char * const *argv) pf_file << endl; } + if ( ! options->getStr("pf_optimization").empty() ) + pf_file << "set optimization " + << options->getStr("pf_optimization") << endl; + pf_file << printTimeout(options, "pf_do_timeout_interval","pf_timeout_interval", "interval"); diff --git a/src/pflib/NATCompiler_pf.cpp b/src/pflib/NATCompiler_pf.cpp index 3a6302212..0f724ffed 100644 --- a/src/pflib/NATCompiler_pf.cpp +++ b/src/pflib/NATCompiler_pf.cpp @@ -388,16 +388,17 @@ bool NATCompiler_pf::addVirtualAddress::processNext() if (rule->getRuleType()==NATRule::DNAT) a=compiler->getFirstODst(rule); else return true; assert(a!=NULL); + const InetAddr *a_addr = a->getAddressPtr(); - if ( ! a->isAny() && a->getId()!=compiler->getFwId() ) + if ( ! a->isAny() && a->getId()!=compiler->getFwId() && a_addr) { list l2=compiler->fw->getByType(Interface::TYPENAME); for (list::iterator i=l2.begin(); i!=l2.end(); ++i) { Interface *iface=dynamic_cast(*i); assert(iface); - - if ( *(a->getAddressPtr()) == *(iface->getAddressPtr()) ) + const InetAddr *iface_addr = iface->getAddressPtr(); + if (iface_addr && *a_addr == *iface_addr ) return true; } compiler->osconfigurator->addVirtualAddressForNAT( a ); @@ -418,7 +419,8 @@ bool NATCompiler_pf::splitForTSrc::processNext() { FWObject *o= *i; if (FWReference::cast(o)!=NULL) o=FWReference::cast(o)->getPointer(); - Interface *iface = compiler->findInterfaceFor(Address::cast(o),compiler->fw); + Interface *iface = compiler->findInterfaceFor(Address::cast(o), + compiler->fw); if (iface!=NULL) interfaceGroups[iface->getId()].push_back(o); } diff --git a/src/pflib/NATCompiler_pf_writers.cpp b/src/pflib/NATCompiler_pf_writers.cpp index 04d7b9372..ac39e4f5e 100644 --- a/src/pflib/NATCompiler_pf_writers.cpp +++ b/src/pflib/NATCompiler_pf_writers.cpp @@ -324,38 +324,39 @@ void NATCompiler_pf::PrintRule::_printAddr(FWObject *o) assert(atrt==NULL); } - Address *a = Address::cast(o); - const InetAddr *addr = a->getAddressPtr(); - InetAddr mask = *(a->getNetmaskPtr()); - if (Interface::cast(o)!=NULL) { - Interface *interface_=Interface::cast(o); - if (interface_->isDyn()) + Interface *iface=Interface::cast(o); + if (iface->isDyn()) { - compiler->output << "(" << interface_->getName() << ") "; + compiler->output << "(" << iface->getName() << ") "; return; } - - mask = InetAddr(InetAddr::getAllOnes()); } - if (Address::cast(o)->dimension()==1) + Address *a = Address::cast(o); + const InetAddr *addr = a->getAddressPtr(); + if (addr) { - mask = InetAddr(InetAddr::getAllOnes()); - } + InetAddr mask = *(a->getNetmaskPtr()); - if (addr->isAny() && mask.isAny()) - { - compiler->output << "any "; - } else - { - compiler->output << addr->toString(); - if (!mask.isHostMask()) + if (Interface::cast(o)!=NULL || Address::cast(o)->dimension()==1) { - compiler->output << "/" << mask.getLength(); + mask = InetAddr(InetAddr::getAllOnes()); + } + + if (addr->isAny() && mask.isAny()) + { + compiler->output << "any "; + } else + { + compiler->output << addr->toString(); + if (!mask.isHostMask()) + { + compiler->output << "/" << mask.getLength(); + } + compiler->output << " "; } - compiler->output << " "; } } diff --git a/test/pf/objects-for-regression-tests.fwb b/test/pf/objects-for-regression-tests.fwb index 4a2192604..27a8ac010 100644 --- a/test/pf/objects-for-regression-tests.fwb +++ b/test/pf/objects-for-regression-tests.fwb @@ -1,6 +1,6 @@ - + @@ -76,9 +76,9 @@ - - - + @@ -92,9 +92,9 @@ - - - + @@ -202,9 +202,9 @@ - - - + @@ -219,9 +219,9 @@ - - - + @@ -235,9 +235,9 @@ - - - + @@ -252,9 +252,9 @@ - - - + @@ -269,9 +269,9 @@ - - - + @@ -286,9 +286,9 @@ - - - + @@ -303,9 +303,9 @@ - - - + @@ -320,9 +320,9 @@ - - - + @@ -337,9 +337,9 @@ - - - + @@ -408,8 +408,7 @@ - - + @@ -463,39 +462,35 @@ - - + - - + - - + - - - + - - + + -m ip_conntrack_talk -m ip_nat_talk - - - + + + proto {tcp udp icmp gre} - - + + + @@ -694,9 +689,9 @@ - + - + @@ -740,10 +735,10 @@ - - + - + @@ -763,10 +758,10 @@ - - + - + @@ -789,10 +784,10 @@ - - + - + @@ -815,10 +810,10 @@ - - + - + @@ -843,18 +838,18 @@ - - + - + - + - + @@ -881,10 +876,10 @@ - - + - + @@ -910,10 +905,10 @@ - - + - + @@ -934,10 +929,10 @@ - - + - + @@ -957,10 +952,10 @@ - - + - + @@ -980,10 +975,10 @@ - - + - + @@ -1024,10 +1019,10 @@ - - + - + @@ -1047,11 +1042,11 @@ - - + - - + @@ -1075,26 +1070,26 @@ - - - + - - + - + - + - - - + @@ -1119,9 +1114,9 @@ - - - + @@ -1140,7 +1135,7 @@ - + @@ -1183,11 +1178,11 @@ - - - - - + @@ -1679,10 +1674,10 @@ - + - + @@ -1704,10 +1699,10 @@ - + - + @@ -1792,10 +1787,10 @@ - + - + @@ -1925,26 +1920,26 @@ - - - + - - + - + - + - - - + @@ -1956,18 +1951,18 @@ - + - + - - - + @@ -1980,7 +1975,7 @@ - + @@ -2029,11 +2024,11 @@ - - - - - + @@ -2183,19 +2178,19 @@ - - + - + - - - + @@ -2207,7 +2202,7 @@ - + @@ -2218,13 +2213,13 @@ - - + - + @@ -2236,10 +2231,10 @@ - - - - + @@ -2267,7 +2262,7 @@ - + @@ -2292,7 +2287,7 @@ - + @@ -2340,7 +2335,7 @@ - + @@ -2365,7 +2360,7 @@ - + @@ -2413,7 +2408,7 @@ - + @@ -2438,7 +2433,7 @@ - + @@ -2549,7 +2544,7 @@ - + @@ -2928,8 +2923,8 @@ - - + @@ -2953,8 +2948,8 @@ - - + @@ -2979,8 +2974,8 @@ - - + @@ -3005,8 +3000,8 @@ - - + @@ -3027,8 +3022,8 @@ - - + @@ -3051,7 +3046,7 @@ - + @@ -3073,7 +3068,7 @@ - + @@ -3134,7 +3129,7 @@ - + @@ -3193,7 +3188,7 @@ - + @@ -3223,27 +3218,27 @@ - - - + - - + - + - + - + - - - + @@ -3270,9 +3265,9 @@ - - - + @@ -3336,11 +3331,11 @@ # prolog commands go after set commands - - - - - + @@ -3368,7 +3363,7 @@ - + @@ -3391,7 +3386,7 @@ - + @@ -3508,7 +3503,7 @@ - + @@ -3529,7 +3524,7 @@ - + @@ -3551,7 +3546,7 @@ - + @@ -3574,7 +3569,7 @@ - + @@ -3595,7 +3590,7 @@ - + @@ -3615,7 +3610,7 @@ - + @@ -3645,27 +3640,27 @@ - - - + - - + - + - + - + - - - + @@ -3677,18 +3672,18 @@ - + - + - - - + @@ -3701,7 +3696,7 @@ - + @@ -3745,11 +3740,11 @@ - - - - - + @@ -3797,10 +3792,10 @@ - + - - + @@ -3822,10 +3817,10 @@ - + - - + @@ -3869,23 +3864,23 @@ - - + - - + - + - - - + @@ -3897,7 +3892,7 @@ - + @@ -3908,13 +3903,13 @@ - - + - + @@ -3927,10 +3922,10 @@ - - - - + @@ -4003,19 +3998,19 @@ - - + - + - - - + @@ -4027,20 +4022,20 @@ - + - - + - + @@ -4053,10 +4048,10 @@ - - - - + @@ -4131,19 +4126,19 @@ - - + - + - - - + @@ -4155,20 +4150,20 @@ - + - - + - + @@ -4181,10 +4176,10 @@ - - - - + @@ -4517,14 +4512,14 @@ - - + - + @@ -4535,7 +4530,7 @@ - + @@ -4546,9 +4541,9 @@ - - - + @@ -4712,22 +4707,22 @@ - - + - + - - - + - - - + @@ -4739,20 +4734,20 @@ - + - - + - + @@ -4765,10 +4760,10 @@ - - - - + @@ -5107,50 +5102,50 @@ - - - + - - + - - + - - - + - - - - - - - - - - - - - - - - + - - - - + @@ -5164,20 +5159,20 @@ - + - + - + - - - - - + @@ -5535,7 +5530,7 @@ - + @@ -5544,7 +5539,7 @@ - + @@ -5609,50 +5604,50 @@ - - - + - - + - - + - - - + - - - - - - - - - - - - - - - - + - - - - + @@ -5666,20 +5661,20 @@ - + - + - + - - - - - + @@ -5753,12 +5748,12 @@ - - - + - + @@ -5925,14 +5920,14 @@ - + - + - + - + @@ -5976,29 +5971,29 @@ - - - + - - + - + - + - - - + - - - + @@ -6010,18 +6005,18 @@ - + - + - - - + @@ -6034,7 +6029,7 @@ - + @@ -6074,13 +6069,13 @@ - + - - - - - + @@ -6273,7 +6268,7 @@ - + @@ -6301,16 +6296,16 @@ - - - + - - + - + @@ -6326,11 +6321,11 @@ - + - + @@ -6343,7 +6338,7 @@ - + @@ -6401,7 +6396,7 @@ - + @@ -6469,12 +6464,12 @@ - - - + - + @@ -6650,14 +6645,14 @@ - + - + - + - + @@ -6801,29 +6796,29 @@ - - - + - - + - + - + - - - + - - - + @@ -6835,18 +6830,18 @@ - + - + - - - + @@ -6859,7 +6854,7 @@ - + @@ -6899,13 +6894,13 @@ - + - - - - - + @@ -6974,7 +6969,7 @@ - + @@ -6999,7 +6994,7 @@ - + @@ -7025,28 +7020,28 @@ - - - - - - - + - - + - + - + @@ -7067,28 +7062,28 @@ - - - - - - - + - - + - + - + @@ -7152,16 +7147,16 @@ - - - + - - + - + @@ -7177,11 +7172,11 @@ - + - + @@ -7194,7 +7189,7 @@ - + @@ -7245,11 +7240,11 @@ - + - + @@ -7453,16 +7448,16 @@ - + - + - + @@ -7488,16 +7483,16 @@ - + - + - + @@ -7544,29 +7539,29 @@ - - - + - - + - + - + - - - + - - - + @@ -7578,7 +7573,7 @@ - + @@ -7587,9 +7582,9 @@ - - - + @@ -7608,7 +7603,7 @@ - + @@ -7649,13 +7644,13 @@ - + - - - - - + @@ -7745,16 +7740,16 @@ - + - + - + @@ -7780,16 +7775,16 @@ - + - + - + @@ -7836,29 +7831,29 @@ - - - + - - + - + - + - - - + - - - + @@ -7870,7 +7865,7 @@ - + @@ -7879,9 +7874,9 @@ - - - + @@ -7900,7 +7895,7 @@ - + @@ -7941,13 +7936,13 @@ - + - - - - - + @@ -8037,16 +8032,16 @@ - + - + - + @@ -8072,16 +8067,16 @@ - + - + - + @@ -8128,29 +8123,29 @@ - - - + - - + - + - + - - - + - - - + @@ -8162,7 +8157,7 @@ - + @@ -8171,9 +8166,9 @@ - - - + @@ -8192,7 +8187,7 @@ - + @@ -8233,13 +8228,13 @@ - + - - - - - + @@ -8329,16 +8324,16 @@ - + - + - + @@ -8364,16 +8359,16 @@ - + - + - + @@ -8420,29 +8415,29 @@ - - - + - - + - + - + - - - + - - - + @@ -8454,7 +8449,7 @@ - + @@ -8463,9 +8458,9 @@ - - - + @@ -8484,7 +8479,7 @@ - + @@ -8525,13 +8520,13 @@ - + - - - - - + @@ -8600,16 +8595,16 @@ - + - + - + @@ -8656,16 +8651,16 @@ - + - + - + @@ -8691,16 +8686,16 @@ - + - + - + @@ -8747,29 +8742,29 @@ - - - + - - + - + - + - - - + - - - + @@ -8781,7 +8776,7 @@ - + @@ -8790,9 +8785,9 @@ - - - + @@ -8811,7 +8806,7 @@ - + @@ -8852,13 +8847,13 @@ - + - - - - - + @@ -8948,16 +8943,16 @@ - + - + - + @@ -8983,16 +8978,16 @@ - + - + - + @@ -9039,29 +9034,29 @@ - - - + - - + - + - + - - - + - - - + @@ -9073,7 +9068,7 @@ - + @@ -9082,9 +9077,9 @@ - - - + @@ -9103,7 +9098,7 @@ - + @@ -9144,13 +9139,13 @@ - + - - - - - + @@ -9219,35 +9214,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9257,7 +9252,7 @@ - + @@ -9278,35 +9273,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9316,7 +9311,7 @@ - + @@ -9337,35 +9332,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9375,7 +9370,7 @@ - + @@ -9396,35 +9391,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9434,7 +9429,7 @@ - + @@ -9455,35 +9450,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9493,7 +9488,7 @@ - + @@ -9514,35 +9509,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9552,7 +9547,7 @@ - + @@ -9573,35 +9568,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9611,7 +9606,7 @@ - + @@ -9632,35 +9627,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9670,7 +9665,7 @@ - + @@ -9691,35 +9686,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9729,7 +9724,7 @@ - + @@ -9750,35 +9745,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9788,7 +9783,7 @@ - + @@ -9809,35 +9804,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9847,7 +9842,7 @@ - + @@ -9868,35 +9863,35 @@ - - - - + - - - + - - + - + - + - + - + @@ -9906,7 +9901,7 @@ - + @@ -9932,16 +9927,16 @@ - - - + - - + - + @@ -9957,11 +9952,11 @@ - + - + @@ -9974,7 +9969,7 @@ - + @@ -10025,11 +10020,11 @@ - + - + @@ -10051,14 +10046,9 @@ - - - - - - - - + + + @@ -10077,14 +10067,9 @@ - - - - - - - - + + + @@ -10111,14 +10096,9 @@ - - - - - - - - + + + @@ -10145,13 +10125,8 @@ - - - - - - - + + @@ -10410,26 +10385,26 @@ - + - - + - + - - - + @@ -10439,9 +10414,9 @@ - + - + @@ -10450,13 +10425,13 @@ - + - - - - - + @@ -10469,7 +10444,7 @@ - + @@ -10510,12 +10485,12 @@ - - - - - - + @@ -10702,33 +10677,33 @@ - + - - + - + - - - - - - + - - - + @@ -10738,9 +10713,9 @@ - + - + @@ -10749,13 +10724,13 @@ - + - - - - - + @@ -10768,7 +10743,7 @@ - + @@ -10808,12 +10783,12 @@ - - - - - - + @@ -11004,26 +10979,26 @@ - + - + - - + - + - - - + @@ -11033,9 +11008,9 @@ - + - + @@ -11044,13 +11019,13 @@ - + - - - - - + @@ -11063,7 +11038,7 @@ - + @@ -11104,12 +11079,12 @@ - - - - - - + @@ -11300,26 +11275,26 @@ - + - + - - + - + - - - + @@ -11329,9 +11304,9 @@ - + - + @@ -11340,13 +11315,13 @@ - + - - - - - + @@ -11365,7 +11340,7 @@ - + @@ -11406,12 +11381,12 @@ - - - - - - + @@ -11431,13 +11406,8 @@ - - - - - - - + + @@ -11451,8 +11421,7 @@ - - + @@ -11490,13 +11459,11 @@ - - + - - + @@ -11507,8 +11474,7 @@ - - + @@ -11516,6 +11482,7 @@ + diff --git a/test/pf/run.all b/test/pf/run.all index 670f8606e..9c372c813 100755 --- a/test/pf/run.all +++ b/test/pf/run.all @@ -8,6 +8,8 @@ while (<>) { while ( $str=~ /]+name="([^"]*).*$"/; $fw=$1; + printf "\n"; + printf "echo '********* $fw'\n"; printf "fwb_pf -v -f $XMLFILE $fw\n"; $str=~ s/^.*]+name="$fw"[^>]+>//; }