The Linux kernel code is open source. You can look it up yourself. This is the Mikrotik Beginner Basics forum, not a technical debate club.
…to pass many rules before they are accepted, the CPU load will be high…
Can you prove it? Tik can easily handle hundreds of rules with no / minimal impact (caveat: as long as no heavy matchers are used)
Just because your router has enough CPU power to handle an inefficient firewall design doesn’t mean it generally doesn’t matter.
One of the first rules in the filter table input chain is to accept packets belonging to established and related connections.
(BTW: that depends on configuration)
Yes, it does depend on configuration. You can run without connection tracking, without a firewall or with just a stateless firewall, but the default configuration (not the blank configuration) comes with a stateful firewall configuration that has an “accept established, related” rule very high in the filter table input/forward chains. Beginner Basics forum, remember?
And how do you imagine all those packets are matched to existing table of connections? By MAGIC?
The Linux kernel (which is at the heart of every Mikrotik router) uses hash tables for connection tracking. The kernel does not search a list to find the matching connection for a packet. A hash table is a “constant time” data structure. In contrast, every packet needs to be checked against every firewall rule (in order) until a packet is accepted, rejected or dropped.
for each packet some cpu cycles will be used to compare with existing list of connections and determine if it’s established or related to them and if they can be allowed to pass
Yes, except it’s not a comparison with a list but essentially a constant time lookup, and unless you don’t use connection tracking for a particular packet, this happens anyway, so checking packets which belong to already established connections against additional rules adds unnecessary overhead to the processing of these packets. This matters when the router is operating close to its maximum throughput.
I DO have rules in raw table, and whether I enable them or disable there is NO measurable impact on cpu load with heavy traffic throughput.
So come with founded data + info, or don’t bother…
It’s really common sense that the order of firewall rules matters, if you’ve read the iptables documentation. Anyway, does Mikrotik documentation count?
https://wiki.mikrotik.com/wiki/Tips_and_Tricks_for_Beginners_and_Experienced_Users_of_RouterOS#Ease_load_on_firewall_by_sorting_firewall_filter.2C_NAT_and_mangle_rules