Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Increase performance of filter_configure_sync

    Scheduled Pinned Locked Moved Development
    5 Posts 2 Posters 3.0k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      thekod
      last edited by

      For systems with a lot of firewall rules, filter_configure_sync() in /etc/inc/filter.inc could be sped up by adding break; after line 102, so that you end up with:

          100                         foreach($config['filter']['rule'] as $rule) {
          101                                 if($rule['sched'])
          102                                         $time_based_rules = true;
          103                                         break;
          104                         }
      

      This way, once it finds a match and sets $time_based_rules, it doesn't keep searching through the rules…of which there might be many...just a suggestion...

      1 Reply Last reply Reply Quote 0
      • T
        thekod
        last edited by

        It was early in the morning…I didn't notice that since the if statement only had one action, there were no brackets...the way I wrote it, it'll completely screw up.  Below is a corrected version.

            100                         foreach($config['filter']['rule'] as $rule) {
            101                                 if($rule['sched']) {
            102                                         $time_based_rules = true;
            103                                         break;
            104                                 }
            104                         }
        
        1 Reply Last reply Reply Quote 0
        • E
          eri--
          last edited by

          thx for reminding this i forgot and that is not the best fix ;)

          1 Reply Last reply Reply Quote 0
          • T
            thekod
            last edited by

            What is?  I'm always interested in learning.  :)

            1 Reply Last reply Reply Quote 0
            • E
              eri--
              last edited by

              Short answer, no need to do the loop at all :D ::)

              1 Reply Last reply Reply Quote 0
              • First post
                Last post
              Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.