On Mon, Apr 27, 2020 at 11:05:31PM +0000, Nathanial Sloss wrote:
> Skip pfil_run_hooks if no packet filter configured in kernel.
...

> @@ -398,6 +398,11 @@ pfil_run_hooks(pfil_head_t *ph, struct m
>       int ret = 0;
>  
>       KASSERT(dir == PFIL_IN || dir == PFIL_OUT);
> +
> +     if (__predict_false(ph == NULL)) {
> +             return ret;
> +     }
> +
>       if (__predict_false((phlistset = pfil_hook_get(dir, ph)) == NULL)) {
>               return ret;
>       }
> 

Speaking about the nearby code (Nat is not at fault, just following the
example).

I think that __predict_false should be used in esoteric failure modes,
or debug features. This isn't one of them.

The people who use packet filters have it always be true. The default
branch predicting behaviour (if the hint is even used) is probably better.

Reply via email to