Re: [PATCH v2 net-next 2/3] ipvlan: Common code from v6/v4 validator_event
From: Eric Dumazet
Date: Tue Jan 27 2026 - 02:37:59 EST
On Tue, Jan 27, 2026 at 6:56 AM Dmitry Skorodumov
<skorodumov.dmitry@xxxxxxxxxx> wrote:
>
> On 1/26/2026 9:01 PM, Kuniyuki Iwashima wrote:
> > On Fri, Jan 23, 2026 at 9:04 AM Dmitry Skorodumov <dskr99@xxxxxxxxx> wrote:
>
> >> +static int ipvlan_addr_validator_event_cb(struct notifier_block *nblock,
> >> + unsigned long event, void *ptr)
> >> +{
> >> + struct in6_validator_info *i6vi;
> >> + struct net_device *dev;
> >> +
> >> + if (nblock == &ipvlan_addr4_vtor_notifier_block) {
> >
> > If you check this against the v6 one instead, the if block
> > and the i6vi definition can be guarded with
> > #if IS_ENABLED(CONFIG_IPV6)
>
> Hm... Few months ago, I had a conversation here that convinced me: avoid
> #ifdef whenever possible. They overburden code and reduce readability.
>
> 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
if (0) {
code_0;
}
if (0 && anything) {
code_0_1;
}
-> Compiler will completely remove all of this.