Skip to contentSkip to conversation

net/netfilter/nfnetlink_hook.c:76:7: error: implicit declaration of function 'nft_is_active'

PATCH In review kernel test robot 3 participants 6 messages Jun 8, 2021

Subsystems (3)
lore
Share & tools
lore

kernel test robot

author build bot
#0 lore raw
tree:   https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head:   ab5803bc555fe68b9b0d37b9a850d3ec601b938a
commit: e2cf17d3774c323ef6dab6e9f7c0cfc5e742afd9 [7125/8019] netfilter: add new hook nfnl subsystem
config: arc-randconfig-r031-20210608 (attached as .config)
compiler: arc-elf-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=e2cf17d3774c323ef6dab6e9f7c0cfc5e742afd9
git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git
git fetch --no-tags linux-next master
git checkout e2cf17d3774c323ef6dab6e9f7c0cfc5e742afd9
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

net/netfilter/nfnetlink_hook.c: In function 'nfnl_hook_put_nft_chain_info':

>> net/netfilter/nfnetlink_hook.c:76:7: error: implicit declaration of function 'nft_is_active' [-Werror=implicit-function-declaration]
      76 |  if (!nft_is_active(net, chain))
         |       ^~~~~~~~~~~~~

cc1: some warnings being treated as errors

vim +/nft_is_active +76 net/netfilter/nfnetlink_hook.c

    58	
    59	static int nfnl_hook_put_nft_chain_info(struct sk_buff *nlskb,
    60						const struct nfnl_dump_hook_data *ctx,
    61						unsigned int seq,
    62						const struct nf_hook_ops *ops)
    63	{
    64		struct net *net = sock_net(nlskb->sk);
    65		struct nlattr *nest, *nest2;
    66		struct nft_chain *chain;
    67		int ret = 0;
    68	
    69		if (ops->hook_ops_type != NF_HOOK_OP_NF_TABLES)
    70			return 0;
    71	
    72		chain = ops->priv;
    73		if (WARN_ON_ONCE(!chain))
    74			return 0;
    75	
  > 76		if (!nft_is_active(net, chain))
    77			return 0;
    78	
    79		nest = nla_nest_start(nlskb, NFNLA_HOOK_CHAIN_INFO);
    80		if (!nest)
    81			return -EMSGSIZE;
    82	
    83		ret = nla_put_be32(nlskb, NFNLA_HOOK_INFO_TYPE,
    84				   htonl(NFNL_HOOK_TYPE_NFTABLES));
    85		if (ret)
    86			goto cancel_nest;
    87	
    88		nest2 = nla_nest_start(nlskb, NFNLA_HOOK_INFO_DESC);
    89		if (!nest2)
    90			goto cancel_nest;
    91	
    92		ret = nla_put_string(nlskb, NFTA_CHAIN_TABLE, chain->table->name);
    93		if (ret)
    94			goto cancel_nest;
    95	
    96		ret = nla_put_string(nlskb, NFTA_CHAIN_NAME, chain->name);
    97		if (ret)
    98			goto cancel_nest;
    99	

100 nla_nest_end(nlskb, nest2);
101 nla_nest_end(nlskb, nest);
102 return ret;
103
104 cancel_nest:
105 nla_nest_cancel(nlskb, nest);
106 return -EMSGSIZE;
107 }
108

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

maintainer
#1 lore raw

PATCH 1/1 nfilter: nf_hooks: fix build failure with NF_TABLES=n

nfnetlink_hook.c: In function 'nfnl_hook_put_nft_chain_info':
nfnetlink_hook.c:76:7: error: implicit declaration of 'nft_is_active'

This macro is only defined when NF_TABLES is enabled. Add IS_ENABLED guards for this.

Fixes 252956528caa ("netfilter: add new hook nfnl subsystem")
---
 net/netfilter/nfnetlink_hook.c | 4 ++++
 1 file changed, 4 insertions(+)
net/netfilter/nfnetlink_hook.c +4 -0
index 04586dfa2acd..d624805e977c 100644
@@ -61,6 +61,7 @@ static int nfnl_hook_put_nft_chain_info(struct sk_buff *nlskb,
 					unsigned int seq,
 					const struct nf_hook_ops *ops)
 {
+#if IS_ENABLED(CONFIG_NF_TABLES)
 	struct net *net = sock_net(nlskb->sk);
 	struct nlattr *nest, *nest2;
 	struct nft_chain *chain;
@@ -104,6 +105,9 @@ static int nfnl_hook_put_nft_chain_info(struct sk_buff *nlskb,
 cancel_nest:
 	nla_nest_cancel(nlskb, nest);
 	return -EMSGSIZE;
+#else
+	return 0;
+#endif
 }
 
 static int nfnl_hook_dump_one(struct sk_buff *nlskb,
Signature · 1 line
2.31.1
#2 lore raw

Re: [PATCH nf-next] nfilter: nf_hooks: fix build failure with NF_TABLES=n

Maybe from Kconfig, select CONFIG_NF_TABLES from NFNETLINK_HOOK to reduce ifdef pollution?

Quoted 38 lines · Florian Westphal

nfnetlink_hook.c: In function 'nfnl_hook_put_nft_chain_info':
nfnetlink_hook.c:76:7: error: implicit declaration of 'nft_is_active'

This macro is only defined when NF_TABLES is enabled. Add IS_ENABLED guards for this.

Fixes 252956528caa ("netfilter: add new hook nfnl subsystem")
---
 net/netfilter/nfnetlink_hook.c | 4 ++++
 1 file changed, 4 insertions(+)
net/netfilter/nfnetlink_hook.c +4 -0
index 04586dfa2acd..d624805e977c 100644
@@ -61,6 +61,7 @@ static int nfnl_hook_put_nft_chain_info(struct sk_buff *nlskb,
 					unsigned int seq,
 					const struct nf_hook_ops *ops)
 {
+#if IS_ENABLED(CONFIG_NF_TABLES)
 	struct net *net = sock_net(nlskb->sk);
 	struct nlattr *nest, *nest2;
 	struct nft_chain *chain;
@@ -104,6 +105,9 @@ static int nfnl_hook_put_nft_chain_info(struct sk_buff *nlskb,
 cancel_nest:
 	nla_nest_cancel(nlskb, nest);
 	return -EMSGSIZE;
+#else
+	return 0;
+#endif
 }
 
 static int nfnl_hook_dump_one(struct sk_buff *nlskb,
Signature · 1 line
2.31.1
maintainer
#3 lore raw

Re: [PATCH nf-next] nfilter: nf_hooks: fix build failure with NF_TABLES=n

Quoted 2 lines · Pablo Neira Ayuso

Maybe from Kconfig, select CONFIG_NF_TABLES from NFNETLINK_HOOK to reduce ifdef pollution?

Why? It doesn't depend on nftables?

#4 lore raw

Re: [PATCH nf-next] nfilter: nf_hooks: fix build failure with NF_TABLES=n

Quoted 5 lines · Florian Westphal
Quoted 2 lines · Pablo Neira Ayuso

Maybe from Kconfig, select CONFIG_NF_TABLES from NFNETLINK_HOOK to reduce ifdef pollution?

Why? It doesn't depend on nftables?

From kernelside, yes. But you have to compile userspace nftables to use this infra, unless there is separated tooling, userspace library or you code your own netlink userspace code.

Adding the "depends on" might also help signal distros that this subsystem is useful to be turned on.

The #ifdef is perfectly fine to fix the kbuild robot issue, I was just thinking if it is probably better a different path when looking at the whole picture.

maintainer
#5 lore raw

Re: [PATCH nf-next] nfilter: nf_hooks: fix build failure with NF_TABLES=n

Quoted 11 lines · Pablo Neira Ayuso
Quoted 5 lines · Florian Westphal
Quoted 2 lines · Pablo Neira Ayuso

Maybe from Kconfig, select CONFIG_NF_TABLES from NFNETLINK_HOOK to reduce ifdef pollution?

Why? It doesn't depend on nftables?

From kernelside, yes. But you have to compile userspace nftables to use this infra, unless there is separated tooling, userspace library or you code your own netlink userspace code.

Quoted 6 lines

Adding the "depends on" might also help signal distros that this subsystem is useful to be turned on.

The #ifdef is perfectly fine to fix the kbuild robot issue, I was just thinking if it is probably better a different path when looking at the whole picture.

Fair enough, please discard this, I will send the depends-on patch then.