netfilter: nfnetlink_queue: get rid of nfnetlink_queue_ct.c
Subsystems (2)
Pablo Neira Ayuso
maintainerPATCH v2 1/2 netfilter: nfnetlink_queue: get rid of nfnetlink_queue_ct.c
The original intention was to avoid dependencies between nfnetlink_queue and conntrack without ifdef pollution. However, we can achieve this by moving the conntrack dependent code into ctnetlink and keep some glue code to access the nfq_ct indirection from nfqueue.
After this patch, the nfq_ct indirection is always compiled in the netfilter core to avoid polluting nfqueue with ifdefs. Thus, if nf_conntrack is not compiled this results in only 8-bytes of memory waste in x86_64.
This patch also adds ctnetlink_nfqueue_seqadj() to avoid that the nf_conn structure layout if exposed to nf_queue, which creates another dependency with nf_conntrack at compilation time.
---
v2: Resolve problems reported by kbuild robot.
include/linux/netfilter.h | 12 ++-- include/net/netfilter/nfnetlink_queue.h | 51 -------------- net/netfilter/Makefile | 1 - net/netfilter/core.c | 9 ++- net/netfilter/nf_conntrack_netlink.c | 49 +++++++++++++- net/netfilter/nfnetlink_queue_core.c | 52 +++++++++++---- net/netfilter/nfnetlink_queue_ct.c | 113 -------------------------------- 7 files changed, 102 insertions(+), 185 deletions(-) delete mode 100644 include/net/netfilter/nfnetlink_queue.h delete mode 100644 net/netfilter/nfnetlink_queue_ct.c
include/linux/netfilter.h +8 -4
@@ -369,14 +369,21 @@ nf_nat_decode_session(struct sk_buff *skb, struct flowi *fl, u_int8_t family)extern void (*ip_ct_attach)(struct sk_buff *,const struct sk_buff *)__rcu ;void nf_ct_attach (struct sk_buff *,const struct sk_buff *);extern void (*nf_ct_destroy)(struct nf_conntrack *)__rcu ; +#else +static inline void nf_ct_attach (struct sk_buff *new,struct sk_buff *skb) {} +#endif struct nf_conn ;enum ip_conntrack_info ;struct nlattr ;struct nfq_ct_hook { +struct nf_conn *(*get_ct)(struct sk_buff *skb, +enum ip_conntrack_info *ctinfo);size_t (*build_size)(const struct nf_conn *ct); -int (*build)(struct sk_buff *skb,struct nf_conn *ct); +int (*build)(struct sk_buff *skb,struct nf_conn *ct, +enum ip_conntrack_info ctinfo, +u_int16_t ct_attr,u_int16_t ct_info_attr);int (*parse)(const struct nlattr *attr,struct nf_conn *ct);int (*attach_expect)(const struct nlattr *attr,struct nf_conn *ct,u32 portid,u32 report);
@@ -384,9 +391,6 @@ struct nfq_ct_hook { enum ip_conntrack_info ctinfo, s32 off); };extern struct nfq_ct_hook __rcu *nfq_ct_hook; -#else -static inline void nf_ct_attach (struct sk_buff *new,struct sk_buff *skb) {} -#endif /** * nf_skb_duplicated - TEE target has sent a packet
include/net/netfilter/nfnetlink_queue.h deleted +0 -51
51 lines not on this page · raw message
net/netfilter/Makefile +0 -1
@@ -11,7 +11,6 @@ obj-$(CONFIG_NETFILTER) = netfilter.o obj-$(CONFIG_NETFILTER_NETLINK) += nfnetlink.o obj-$(CONFIG_NETFILTER_NETLINK_ACCT) += nfnetlink_acct.o nfnetlink_queue-y := nfnetlink_queue_core.o -nfnetlink_queue-$(CONFIG_NETFILTER_NETLINK_QUEUE_CT) += nfnetlink_queue_ct.o obj-$(CONFIG_NETFILTER_NETLINK_QUEUE) += nfnetlink_queue.o obj-$(CONFIG_NETFILTER_NETLINK_LOG) += nfnetlink_log.o
net/netfilter/core.c +6 -3
@@ -348,6 +348,12 @@ int skb_make_writable(struct sk_buff *skb, unsigned int writable_len) }EXPORT_SYMBOL (skb_make_writable); +/* This needs to be compiled in any case to avoid dependencies between the +* nfnetlink_queue code and nf_conntrack. +*/ +struct nfq_ct_hook __rcu *nfq_ct_hook__read_mostly ; +EXPORT_SYMBOL_GPL (nfq_ct_hook); +#if IS_ENABLED (CONFIG_NF_CONNTRACK )/* This does not belong here, but locally generated errors need it if connection tracking in use: without this, connection may not be in hash table, and hence
@@ -385,9 +391,6 @@ void nf_conntrack_destroy(struct nf_conntrack *nfct) }EXPORT_SYMBOL (nf_conntrack_destroy); -struct nfq_ct_hook __rcu *nfq_ct_hook__read_mostly ; -EXPORT_SYMBOL_GPL (nfq_ct_hook); -/* Built-in default zone used e.g. by modules. */ const struct nf_conntrack_zone nf_ct_zone_dflt = { .id =NF_CT_DEFAULT_ZONE_ID ,
net/netfilter/nf_conntrack_netlink.c +48 -1
72 lines not on this page · raw message
net/netfilter/nfnetlink_queue_core.c +40 -12
105 lines not on this page · raw message
net/netfilter/nfnetlink_queue_ct.c deleted +0 -113
113 lines not on this page · raw message
Signature · 1 line
2.1.4
Pablo Neira Ayuso
maintainerPATCH v2 2/2 netfilter: rename nfnetlink_queue_core.c to nfnetlink_queue.c
Now that we have integrated the ct glue code into nfnetlink_queue without introducing dependencies with the conntrack code.
--- net/netfilter/Makefile | 1 - net/netfilter/nfnetlink_queue.c | 1443 ++++++++++++++++++++++++++++++++++ net/netfilter/nfnetlink_queue_core.c | 1443 ---------------------------------- 3 files changed, 1443 insertions(+), 1444 deletions(-) create mode 100644 net/netfilter/nfnetlink_queue.c delete mode 100644 net/netfilter/nfnetlink_queue_core.c
net/netfilter/Makefile +0 -1
@@ -10,7 +10,6 @@ obj-$(CONFIG_NETFILTER) = netfilter.o obj-$(CONFIG_NETFILTER_NETLINK) += nfnetlink.o obj-$(CONFIG_NETFILTER_NETLINK_ACCT) += nfnetlink_acct.o -nfnetlink_queue-y := nfnetlink_queue_core.o obj-$(CONFIG_NETFILTER_NETLINK_QUEUE) += nfnetlink_queue.o obj-$(CONFIG_NETFILTER_NETLINK_LOG) += nfnetlink_log.o
net/netfilter/nfnetlink_queue.c new file +1443 -0
1,443 lines not on this page · raw message
net/netfilter/nfnetlink_queue_core.c deleted +0 -1443
1,443 lines not on this page · raw message
Signature · 1 line
2.1.4
kbuild test robot
build botRe: [PATCH nf-next v2 2/2] netfilter: rename nfnetlink_queue_core.c to nfnetlink_queue.c
config: m68k-sun3_defconfig (attached as .config) reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross…
Hi Pablo,
[auto build test results on next-20151001 -- if it's inappropriate base, please ignore]
config: m68k-sun3_defconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
git checkout 31ae4524f70d7992a3f918bab674e2fe8588edfa
# save the attached .config to linux build tree
make.cross ARCH=m68k
Note: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_Warnings
All warnings (new ones prefixed by >>):
net/netfilter/nfnetlink_queue.c: In function '__nfqnl_enqueue_packet':
>> net/netfilter/nfnetlink_queue.c:518:18: warning: 'nfq_ct' may be used uninitialized in this function [-Wmaybe-uninitialized]
if (ct && nfq_ct->build(skb, ct, ctinfo, NFQA_CT, NFQA_CT_INFO) < 0)
^
net/netfilter/nfnetlink_queue.c:316:22: note: 'nfq_ct' was declared here
struct nfq_ct_hook *nfq_ct;
^vim +/nfq_ct +518 net/netfilter/nfnetlink_queue.c
7af4cc3f net/netfilter/nfnetlink_queue.c Harald Welte 2005-08-09 502 struct nfqnl_msg_packet_timestamp ts; b7aa0bf7 net/netfilter/nfnetlink_queue.c Eric Dumazet 2007-04-19 503 struct timeval tv = ktime_to_timeval(entskb->tstamp); b7aa0bf7 net/netfilter/nfnetlink_queue.c Eric Dumazet 2007-04-19 504 ts.sec = cpu_to_be64(tv.tv_sec); b7aa0bf7 net/netfilter/nfnetlink_queue.c Eric Dumazet 2007-04-19 505 ts.usec = cpu_to_be64(tv.tv_usec); 7af4cc3f net/netfilter/nfnetlink_queue.c Harald Welte 2005-08-09 506 a447189e net/netfilter/nfnetlink_queue.c David S. Miller 2012-03-29 507 if (nla_put(skb, NFQA_TIMESTAMP, sizeof(ts), &ts)) a447189e net/netfilter/nfnetlink_queue.c David S. Miller 2012-03-29 508 goto nla_put_failure; 7af4cc3f net/netfilter/nfnetlink_queue.c Harald Welte 2005-08-09 509 } 7af4cc3f net/netfilter/nfnetlink_queue.c Harald Welte 2005-08-09 510 08c0cad6 net/netfilter/nfnetlink_queue_core.c Valentina Giusti 2013-12-20 511 if ((queue->flags & NFQA_CFG_F_UID_GID) && entskb->sk && 08c0cad6 net/netfilter/nfnetlink_queue_core.c Valentina Giusti 2013-12-20 512 nfqnl_put_sk_uidgid(skb, entskb->sk) < 0) 08c0cad6 net/netfilter/nfnetlink_queue_core.c Valentina Giusti 2013-12-20 513 goto nla_put_failure; 08c0cad6 net/netfilter/nfnetlink_queue_core.c Valentina Giusti 2013-12-20 514 ef493bd9 net/netfilter/nfnetlink_queue_core.c Roman Kubiak 2015-06-12 515 if (seclen && nla_put(skb, NFQA_SECCTX, seclen, secdata)) ef493bd9 net/netfilter/nfnetlink_queue_core.c Roman Kubiak 2015-06-12 516 goto nla_put_failure; ef493bd9 net/netfilter/nfnetlink_queue_core.c Roman Kubiak 2015-06-12 517 d343eb79 net/netfilter/nfnetlink_queue_core.c Pablo Neira Ayuso 2015-10-01 @518 if (ct && nfq_ct->build(skb, ct, ctinfo, NFQA_CT, NFQA_CT_INFO) < 0) ae08ce00 net/netfilter/nfnetlink_queue_core.c Eric Dumazet 2013-03-17 519 goto nla_put_failure; ae08ce00 net/netfilter/nfnetlink_queue_core.c Eric Dumazet 2013-03-17 520 7f87712c net/netfilter/nfnetlink_queue_core.c Florian Westphal 2013-06-04 521 if (cap_len > data_len && 7f87712c net/netfilter/nfnetlink_queue_core.c Florian Westphal 2013-06-04 522 nla_put_be32(skb, NFQA_CAP_LEN, htonl(cap_len))) ae08ce00 net/netfilter/nfnetlink_queue_core.c Eric Dumazet 2013-03-17 523 goto nla_put_failure; ae08ce00 net/netfilter/nfnetlink_queue_core.c Eric Dumazet 2013-03-17 524 496e4ae7 net/netfilter/nfnetlink_queue_core.c Florian Westphal 2013-06-29 525 if (nfqnl_put_packet_info(skb, entskb, csum_verify)) 7237190d net/netfilter/nfnetlink_queue_core.c Florian Westphal 2013-04-19 526 goto nla_put_failure;
:::::: The code at line 518 was first introduced by commit
:::::: d343eb794f25c72b22631ffc19be0d15fc7f607c netfilter: nfnetlink_queue: get rid of nfnetlink_queue_ct.c
:::::: TO: Pablo Neira Ayuso <[email protected]> :::::: CC: 0day robot <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Pablo Neira Ayuso
maintainerRe: [PATCH nf-next v2 2/2] netfilter: rename nfnetlink_queue_core.c to nfnetlink_queue.c
Quoted 17 lines · kbuild test robot
Hi Pablo,
[auto build test results on next-20151001 -- if it's inappropriate base, please ignore]
config: m68k-sun3_defconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
git checkout31ae4524f70d7992a3f918bab674e2fe8588edfa
# save the attached .config to linux build tree
make.cross ARCH=m68kNote: it may well be a FALSE warning. FWIW you are at least aware of it now.
http://gcc.gnu.org/wiki/Better_Uninitialized_WarningsAll warnings (new ones prefixed by >>):
Quoted 7 lines
net/netfilter/nfnetlink_queue.c: In function '__nfqnl_enqueue_packet':Quoted 1 line
Quoted 1 line
net/netfilter/nfnetlink_queue.c:518:18: warning: 'nfq_ct' may be used uninitialized in this function [-Wmaybe-uninitialized]if (ct && nfq_ct->build(skb, ct, ctinfo, NFQA_CT, NFQA_CT_INFO) < 0) ^ net/netfilter/nfnetlink_queue.c:316:22: note: 'nfq_ct' was declared here struct nfq_ct_hook *nfq_ct; ^
JFYI: This is a false positive as the note above states, if ct is set then nfq_ct is set too.