Bug #38
closedMalfunctioning of 'No XMLRPC Sync' code, causing some rules to still get synced to CARP members
100%
Description
Bug #26 [[http://redmine.pfsense.org/issues/show/26]] is Resolved,
not sure if my update get's it picked up again, hence this new ticket.
I am in a situation (can provide access to the machines in question if wanted)
where I can consistently reproduce a problem with the nosync flag,
causing some rules to still get synced to CARP members.
Running the sample code provided below with 'php test.php' on a pfSense 1.2.3 snapshot
(at least since the February snapshots and including the 2009-07-18-1920 snapshot),
correctly removes (unset) rule#35, rule#36 and rule#37 but keeps rule#38 and rule#39, despite their nosync flag !!!
This exactly mimics the situation I have with pfSense.
Maybe this is a PHP bug ?
Sample code :
<?php $config_copy['nat']['rule'][0]['desc'] = 'rule 0'; $config_copy['nat']['rule'][1]['desc'] = 'rule 1'; $config_copy['nat']['rule'][2]['desc'] = 'rule 2'; $config_copy['nat']['rule'][3]['desc'] = 'rule 3'; $config_copy['nat']['rule'][4]['desc'] = 'rule 4'; $config_copy['nat']['rule'][5]['desc'] = 'rule 5'; $config_copy['nat']['rule'][6]['desc'] = 'rule 6'; $config_copy['nat']['rule'][7]['desc'] = 'rule 7'; $config_copy['nat']['rule'][8]['desc'] = 'rule 8'; $config_copy['nat']['rule'][9]['desc'] = 'rule 9'; $config_copy['nat']['rule'][10]['desc'] = 'rule 10'; $config_copy['nat']['rule'][11]['desc'] = 'rule 11'; $config_copy['nat']['rule'][12]['desc'] = 'rule 12'; $config_copy['nat']['rule'][13]['desc'] = 'rule 13'; $config_copy['nat']['rule'][14]['desc'] = 'rule 14'; $config_copy['nat']['rule'][15]['desc'] = 'rule 15'; $config_copy['nat']['rule'][16]['desc'] = 'rule 16'; $config_copy['nat']['rule'][17]['desc'] = 'rule 17'; $config_copy['nat']['rule'][18]['desc'] = 'rule 18'; $config_copy['nat']['rule'][19]['desc'] = 'rule 19'; $config_copy['nat']['rule'][20]['desc'] = 'rule 20'; $config_copy['nat']['rule'][21]['desc'] = 'rule 21'; $config_copy['nat']['rule'][22]['desc'] = 'rule 22'; $config_copy['nat']['rule'][23]['desc'] = 'rule 23'; $config_copy['nat']['rule'][24]['desc'] = 'rule 24'; $config_copy['nat']['rule'][25]['desc'] = 'rule 25'; $config_copy['nat']['rule'][26]['desc'] = 'rule 26'; $config_copy['nat']['rule'][27]['desc'] = 'rule 27'; $config_copy['nat']['rule'][28]['desc'] = 'rule 28'; $config_copy['nat']['rule'][29]['desc'] = 'rule 29'; $config_copy['nat']['rule'][30]['desc'] = 'rule 30'; $config_copy['nat']['rule'][31]['desc'] = 'rule 31'; $config_copy['nat']['rule'][32]['desc'] = 'rule 32'; $config_copy['nat']['rule'][33]['desc'] = 'rule 33'; $config_copy['nat']['rule'][34]['desc'] = 'rule 34'; $config_copy['nat']['rule'][35]['desc'] = 'rule 35'; $config_copy['nat']['rule'][35]['nosync'] = ''; $config_copy['nat']['rule'][36]['desc'] = 'rule 36'; $config_copy['nat']['rule'][36]['nosync'] = ''; $config_copy['nat']['rule'][37]['desc'] = 'rule 37'; $config_copy['nat']['rule'][37]['nosync'] = ''; $config_copy['nat']['rule'][38]['desc'] = 'rule 38'; $config_copy['nat']['rule'][38]['nosync'] = ''; $config_copy['nat']['rule'][39]['desc'] = 'rule 39'; $config_copy['nat']['rule'][39]['nosync'] = ''; print("COUNT: ".count($config_copy['nat']['rule']))."\n"; for($x=0;$x<count($config_copy['nat']['rule']);$x++) { if(isset($config_copy['nat']['rule'][$x]['nosync'])) { unset($config_copy['nat']['rule'][$x]); } } print_r($config_copy); ?>
Updated by Wouter de Jong over 15 years ago
Also seems present in PHP 5.2.6
However, replacing unset with array_splice, seems to fix it :
print("COUNT: ".count($config_copy['nat']['rule']))."\n"; for($x=0;$x<count($config_copy['nat']['rule']);$x++) { if(isset($config_copy['nat']['rule'][$x]['nosync'])) { //unset($config_copy['nat']['rule'][$x]); array_splice($config_copy['nat']['rule'],$x,1); $x--; } } print_r($config_copy);
Updated by Chris Buechler over 15 years ago
Looking at this. In the future please do not open duplicate tickets, we see updates on earlier tickets.
Updated by Ermal Luçi over 15 years ago
Can you try to replace the for loop with a
foreach ($config[blabla] as $x => $rule) {
if (isset($rule['nosync']))
unset($config_copy['nat']['rule'][$x]);
}
Updated by Wouter de Jong over 15 years ago
Hi Ermal,
That code does not seem to solve the problem unfortunately, I get the same results.
While my previous suggested code (array_splice ++ $x--) does 'fix' the issue.
Updated by Scott Ullrich about 15 years ago
- Status changed from New to Resolved
- Affected Version set to All
Updated by Scott Ullrich about 15 years ago
- % Done changed from 0 to 100
Applied in changeset d6e8dfa1d6b4bad7ef6f71263f275ca8e8b0a706.