Created attachment 186898 [details]
By default (when net.link.bridge.pfil_bridge=1), the packet, forwarded via if_bridge, has to be processed by ipfw 4 times. Suppose such configuration:
em0 <-> bridge0 <-> em1
ipfw will process packet, forwarded from em0 to em1, in the following sequence:
in[em0], in[bridge0], out[bridge0], out[em1].
We can expect, that inbound packets can be matched with the following ipfw rule options:
in[em0] - 'in recv em0' or 'in via em0'
in[bridge0] - 'in via bridge0'
ipfw add 1 count ip from any to any in via em0
ipfw add 2 count ip from any to any in via bridge0
but this doesn't work as expected: each single packet matches 2 times to the rule 1 and not matches to the rule 2 at all.
The reason in the following: despite that if_bridge sends information about corresponding interface to the pfil_run_hooks(), the ipfw doesn't uses it while processing inbound packets.
The attached patch fixes issue:
If the interface on which ipfw processes packet does not match an 'received' interface, then this interface saved and used later in the processing of 'via' rule option.