Re: [PATCH v2] net: netfilter: Fix undefined reference to nf_nat_redirect_* functions

From: Florian Westphal
Date: Wed Nov 26 2014 - 06:26:42 EST


Andreas Ruprecht <rupran@xxxxxxxxxxxx> wrote:
> When the file is compiled, i.e. CONFIG_NETFILTER_XT_TARGET_REDIRECT is
> selected, all headers will be included and all functions inside the file
> will be compiled, regardless of other Kconfig options.
>
> This means redirect_tg6 and redirect_tg4 will be compiled (which doesn't
> necessarily mean they will be _called_) but the linker needs to resolve
> nf_nat_redirect_ipv4() due to the compilation of the redirect_tg4()
> function.

So the problem is eg.
CONFIG_NETFILTER_XT_TARGET_REDIRECT=y
CONFIG_NF_NAT_IPV4=n

which yields
undefined reference to `nf_nat_redirect_ipv4'

adding stub fixes this; we will still register a netfilter target for
ipv4 redirect, but it cannot be called ever since that target is
resticted to 'nat' table, which doesn't exist for ipv4 in the above
config.

To me it seem cleaner to put

IS_ENABLED(NF_NAT_REDIRECT_IPV4)

into xt_REDIRECT.c instead of building not-working-but-never-called
ipv4 redirect.

Pablo, if you disagree I am fine with the patch, although
the stubs should get a 'static inline' prefix to not cause sym clash
in case we ever gain another call site.

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/