diff --git a/src/etc/inc/filter.inc b/src/etc/inc/filter.inc index e42ed1d07..72973749d 100644 --- a/src/etc/inc/filter.inc +++ b/src/etc/inc/filter.inc @@ -2641,49 +2641,6 @@ function filter_rules_generate(&$FilterIflist) unset($rule_arr1, $rule_arr2, $rule_arr3); } - /* pass traffic between statically routed subnets and the subnet on the - * interface in question to avoid problems with complicated routing - * topologies - */ - if (isset($config['filter']['bypassstaticroutes']) && isset($config['staticroutes']['route']) && count($config['staticroutes']['route'])) { - $ipfrules .= "# Add rules to bypass firewall rules for static routes\n"; - foreach (get_staticroutes() as $route) { - $friendly = $GatewaysList[$route['gateway']]['friendlyiface']; - if (is_array($FilterIflist[$friendly])) { - $oc = $FilterIflist[$friendly]; - $routeent = explode("/", $route['network']); - unset($sa); - if (is_ipaddrv4($oc['ip'])) { - $sa = $oc['sa']; - $sn = $oc['sn']; - } - if ($sa && is_ipaddrv4($routeent[0])) { - $ipfrules .= << "pass", "log" => !isset($config['syslog']['nologdefaultpass'])); + + /* + * pass traffic between statically routed subnets and the subnet on the + * interface in question to avoid problems with complicated routing + * topologies + */ + if (isset($config['filter']['bypassstaticroutes']) && isset($config['staticroutes']['route']) && count($config['staticroutes']['route'])) { + $FilterIflist = filter_generate_optcfg_array(); + filter_generate_gateways(); // loads global $GatewaysList + + foreach (get_staticroutes() as $route) { + $friendly = $GatewaysList[$route['gateway']]['friendlyiface']; + if (is_array($FilterIflist[$friendly])) { + $oc = $FilterIflist[$friendly]; + $routeent = explode("/", $route['network']); + if (is_ipaddrv4($routeent[0]) && is_ipaddrv4($oc['ip'])) { + $sa = $oc['sa']; + $sn = $oc['sn']; + } elseif (is_ipaddrv6($routeent[0]) && is_ipaddrv6($oc['ipv6'])) { + $sa = $oc['sav6']; + $sn = $oc['snv6']; + } else { + continue; + } + + $networks = array(); + $networks[] = array('from' => "{$sa}/{$sn}", 'to' => $route['network']); + $networks[] = array('to' => "{$sa}/{$sn}", 'from' => $route['network']); + foreach ($networks as $network) { + $fw->registerFilterRule(10, + array('interface' => $friendly, 'statetype' => 'sloppy', + 'protocol' => 'tcp','flags' => 'any', 'from' => $network['from'], + 'to' => $network['to'], 'quick' => false, + 'label' => "pass traffic between statically routed subnets"), + $defaults['pass'] + ); + $fw->registerFilterRule(10, + array('interface' => $friendly, 'statetype' => 'sloppy', + 'from' => $network['from'],'to' => $network['to'], 'quick' => false, + 'label' => "pass traffic between statically routed subnets"), + $defaults['pass'] + ); + } + } + } + } +}