Re: [PATCH v2 net-next 2/3] ipvlan: Common code from v6/v4 validator_event

From: Kuniyuki Iwashima

Date: Tue Jan 27 2026 - 03:12:45 EST


On Mon, Jan 26, 2026 at 11:54 PM Dmitry Skorodumov
<skorodumov.dmitry@xxxxxxxxxx> wrote:
>
> On 1/27/2026 10:37 AM, Eric Dumazet wrote:
> > On Tue, Jan 27, 2026 at 6:56 AM Dmitry Skorodumov
> > <skorodumov.dmitry@xxxxxxxxxx> wrote:
> >> It even might be a good idea to replace wherever possible preprocessor
> >> checks with runtime checks. Use
> >> if (IS_ENABLED(CONFIG_IPV6)) { ... }
> >>
> >> instead of #if IS_ENABLED(CONFIG_IPV6) ... #endif
> >>
> >> --
> >>
> >> I'm ok with both approaches (though i tend to like runtime checks) - but
> >> unsure what is a common practice in bpf-net
> >
> > What you call runtime checks is in reality the same : C compiler is
> > able to optimize constant boolean expressions
>
> Should I fix patches to be something like
>
> if (nblock == &ipvlan_addr4_vtor_notifier_block) {
> } else if (IS_ENABLED(CONFIG_IPV6)) {
> ...
> }
>
> but still with __maybe_unused for ipvlan_addr6_vtor_notifier_block ?

If IS_ENABLED() or #if is used properly, __maybe_unused
should be unnecessary. Actually the patch moved
ipvlan_addr6_vtor_notifier_block out of the existing #if guard.

Also, ipvlan_main.c already has such #if guards.

>
> I see that this __maybe_unused is used quite often in linux-kernel in
> similar way

but not that under net/.

$ grep -rnI __maybe_unused | wc -l
4827
$ grep -rnI __maybe_unused net | wc -l
33