netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next 0/3] netfilter: header cleanup
@ 2019-04-15 20:43 Paul Gortmaker
  2019-04-15 20:43 ` [PATCH -next 1/3] netfilter: nf_tables: relocate header content to consumer Paul Gortmaker
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Paul Gortmaker @ 2019-04-15 20:43 UTC (permalink / raw)
  To: netdev
  Cc: Paul Gortmaker, David S. Miller, Florian Westphal,
	Jozsef Kadlecsik, Pablo Neira Ayuso, netfilter-devel, coreteam

Having core header files in include/linux that in turn include other
headers with a high number of includes implicitly degenerates into
a formalism that hides what amounts to #include <linux/everything.h>

Some headers, like module.h and device.h are good examples that will
essentially drag in almost everything.

There is nothing module specific about netfilter, but before we try
and stop nf_tables.h from including module.h, we have to fix two
instances of code which are implicitly relying on that module.h
inclusion, so as to not introduce build regressions.

---

Cc: "David S. Miller" <davem@davemloft.net>
Cc: Florian Westphal <fw@strlen.de>
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: netfilter-devel@vger.kernel.org
Cc: coreteam@netfilter.org

Paul Gortmaker (3):
  netfilter: nf_tables: relocate header content to consumer
  netfilter: nf_tables: fix implicit include of module.h
  netfilter: nf_tables: drop include of module.h from nf_tables.h

 include/net/netfilter/nf_tables.h  | 20 ++------------------
 net/netfilter/nf_tables_set_core.c |  1 +
 net/netfilter/nft_dynset.c         | 17 +++++++++++++++++
 3 files changed, 20 insertions(+), 18 deletions(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH -next 1/3] netfilter: nf_tables: relocate header content to consumer
  2019-04-15 20:43 [PATCH -next 0/3] netfilter: header cleanup Paul Gortmaker
@ 2019-04-15 20:43 ` Paul Gortmaker
  2019-04-15 20:43 ` [PATCH -next 2/3] netfilter: nf_tables: fix implicit include of module.h Paul Gortmaker
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Gortmaker @ 2019-04-15 20:43 UTC (permalink / raw)
  To: netdev
  Cc: Paul Gortmaker, Pablo Neira Ayuso, Jozsef Kadlecsik,
	Florian Westphal, David S. Miller, netfilter-devel, coreteam

The nf_tables.h header is used in a lot of files, but it turns out
that there is only one actual user of nft_expr_clone().

Hence we relocate that function to be with the one consumer of it
and avoid having to process it with CPP for all the other files.

This will also enable a reduction in the other headers that the
nf_tables.h itself has to include just to be stand-alone, hence
a pending further significant reduction in the CPP content that
needs to get processed for each netfilter file.

Note that the explicit "inline" has been dropped as part of this
relocation.  In similar changes to this, I believe Dave has asked
this be done, so we free up gcc to make the choice of whether to
inline or not.

Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: Florian Westphal <fw@strlen.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netfilter-devel@vger.kernel.org
Cc: coreteam@netfilter.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 include/net/netfilter/nf_tables.h | 17 -----------------
 net/netfilter/nft_dynset.c        | 17 +++++++++++++++++
 2 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 2d5a0a1a87b8..706f744f7308 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -806,23 +806,6 @@ void nft_expr_destroy(const struct nft_ctx *ctx, struct nft_expr *expr);
 int nft_expr_dump(struct sk_buff *skb, unsigned int attr,
 		  const struct nft_expr *expr);
 
-static inline int nft_expr_clone(struct nft_expr *dst, struct nft_expr *src)
-{
-	int err;
-
-	if (src->ops->clone) {
-		dst->ops = src->ops;
-		err = src->ops->clone(dst, src);
-		if (err < 0)
-			return err;
-	} else {
-		memcpy(dst, src, src->ops->size);
-	}
-
-	__module_get(src->ops->type->owner);
-	return 0;
-}
-
 /**
  *	struct nft_rule - nf_tables rule
  *
diff --git a/net/netfilter/nft_dynset.c b/net/netfilter/nft_dynset.c
index e461007558e8..8394560aa695 100644
--- a/net/netfilter/nft_dynset.c
+++ b/net/netfilter/nft_dynset.c
@@ -28,6 +28,23 @@ struct nft_dynset {
 	struct nft_set_binding		binding;
 };
 
+static int nft_expr_clone(struct nft_expr *dst, struct nft_expr *src)
+{
+	int err;
+
+	if (src->ops->clone) {
+		dst->ops = src->ops;
+		err = src->ops->clone(dst, src);
+		if (err < 0)
+			return err;
+	} else {
+		memcpy(dst, src, src->ops->size);
+	}
+
+	__module_get(src->ops->type->owner);
+	return 0;
+}
+
 static void *nft_dynset_new(struct nft_set *set, const struct nft_expr *expr,
 			    struct nft_regs *regs)
 {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH -next 2/3] netfilter: nf_tables: fix implicit include of module.h
  2019-04-15 20:43 [PATCH -next 0/3] netfilter: header cleanup Paul Gortmaker
  2019-04-15 20:43 ` [PATCH -next 1/3] netfilter: nf_tables: relocate header content to consumer Paul Gortmaker
@ 2019-04-15 20:43 ` Paul Gortmaker
  2019-04-15 20:43 ` [PATCH -next 3/3] netfilter: nf_tables: drop include of module.h from nf_tables.h Paul Gortmaker
  2019-04-30 11:39 ` [PATCH -next 0/3] netfilter: header cleanup Pablo Neira Ayuso
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Gortmaker @ 2019-04-15 20:43 UTC (permalink / raw)
  To: netdev
  Cc: Paul Gortmaker, Pablo Neira Ayuso, Jozsef Kadlecsik,
	Florian Westphal, David S. Miller, netfilter-devel, coreteam

This file clearly uses modular infrastructure but does not call
out the inclusion of <linux/module.h> explicitly.  We add that
include explicitly here, so we can tidy up some header usage
elsewhere w/o causing build breakage.

Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: Florian Westphal <fw@strlen.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netfilter-devel@vger.kernel.org
Cc: coreteam@netfilter.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 net/netfilter/nf_tables_set_core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/netfilter/nf_tables_set_core.c b/net/netfilter/nf_tables_set_core.c
index 814789644bd3..a9fce8d10051 100644
--- a/net/netfilter/nf_tables_set_core.c
+++ b/net/netfilter/nf_tables_set_core.c
@@ -1,4 +1,5 @@
 /* SPDX-License-Identifier: GPL-2.0 */
+#include <linux/module.h>
 #include <net/netfilter/nf_tables_core.h>
 
 static int __init nf_tables_set_module_init(void)
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH -next 3/3] netfilter: nf_tables: drop include of module.h from nf_tables.h
  2019-04-15 20:43 [PATCH -next 0/3] netfilter: header cleanup Paul Gortmaker
  2019-04-15 20:43 ` [PATCH -next 1/3] netfilter: nf_tables: relocate header content to consumer Paul Gortmaker
  2019-04-15 20:43 ` [PATCH -next 2/3] netfilter: nf_tables: fix implicit include of module.h Paul Gortmaker
@ 2019-04-15 20:43 ` Paul Gortmaker
  2019-04-30 11:39 ` [PATCH -next 0/3] netfilter: header cleanup Pablo Neira Ayuso
  3 siblings, 0 replies; 5+ messages in thread
From: Paul Gortmaker @ 2019-04-15 20:43 UTC (permalink / raw)
  To: netdev
  Cc: Paul Gortmaker, Pablo Neira Ayuso, Jozsef Kadlecsik,
	Florian Westphal, David S. Miller, netfilter-devel, coreteam

Ideally, header files under include/linux shouldn't be adding
includes of other headers, in anticipation of their consumers,
but just the headers needed for the header itself to pass
parsing with CPP.

The module.h is particularly bad in this sense, as it itself does
include a whole bunch of other headers, due to the complexity of
module support.

Since nf_tables.h is not going into a module struct looking for
specific fields, we can just let it know that module is a struct,
just like about 60 other include/linux headers already do.

Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: Florian Westphal <fw@strlen.de>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: netfilter-devel@vger.kernel.org
Cc: coreteam@netfilter.org
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
---
 include/net/netfilter/nf_tables.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 706f744f7308..5b8624ae4a27 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -2,7 +2,6 @@
 #ifndef _NET_NF_TABLES_H
 #define _NET_NF_TABLES_H
 
-#include <linux/module.h>
 #include <linux/list.h>
 #include <linux/netfilter.h>
 #include <linux/netfilter/nfnetlink.h>
@@ -13,6 +12,8 @@
 #include <net/netfilter/nf_flow_table.h>
 #include <net/netlink.h>
 
+struct module;
+
 #define NFT_JUMP_STACK_SIZE	16
 
 struct nft_pktinfo {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH -next 0/3] netfilter: header cleanup
  2019-04-15 20:43 [PATCH -next 0/3] netfilter: header cleanup Paul Gortmaker
                   ` (2 preceding siblings ...)
  2019-04-15 20:43 ` [PATCH -next 3/3] netfilter: nf_tables: drop include of module.h from nf_tables.h Paul Gortmaker
@ 2019-04-30 11:39 ` Pablo Neira Ayuso
  3 siblings, 0 replies; 5+ messages in thread
From: Pablo Neira Ayuso @ 2019-04-30 11:39 UTC (permalink / raw)
  To: Paul Gortmaker
  Cc: netdev, David S. Miller, Florian Westphal, Jozsef Kadlecsik,
	netfilter-devel, coreteam

On Mon, Apr 15, 2019 at 04:43:13PM -0400, Paul Gortmaker wrote:
> Having core header files in include/linux that in turn include other
> headers with a high number of includes implicitly degenerates into
> a formalism that hides what amounts to #include <linux/everything.h>
> 
> Some headers, like module.h and device.h are good examples that will
> essentially drag in almost everything.
> 
> There is nothing module specific about netfilter, but before we try
> and stop nf_tables.h from including module.h, we have to fix two
> instances of code which are implicitly relying on that module.h
> inclusion, so as to not introduce build regressions.

Series applied.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-04-30 11:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-15 20:43 [PATCH -next 0/3] netfilter: header cleanup Paul Gortmaker
2019-04-15 20:43 ` [PATCH -next 1/3] netfilter: nf_tables: relocate header content to consumer Paul Gortmaker
2019-04-15 20:43 ` [PATCH -next 2/3] netfilter: nf_tables: fix implicit include of module.h Paul Gortmaker
2019-04-15 20:43 ` [PATCH -next 3/3] netfilter: nf_tables: drop include of module.h from nf_tables.h Paul Gortmaker
2019-04-30 11:39 ` [PATCH -next 0/3] netfilter: header cleanup Pablo Neira Ayuso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).