Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1700878 > unrolled thread

[PATCH nf-next] netfilter: constify nf_loginfo structures

Started byJulia Lawall <Julia.Lawall@lip6.fr>
First post2017-08-01 13:20 +0200
Last post2017-08-02 14:30 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH nf-next] netfilter: constify nf_loginfo structures Julia Lawall <Julia.Lawall@lip6.fr> - 2017-08-01 13:20 +0200
    Re: [PATCH nf-next] netfilter: constify nf_loginfo structures Pablo Neira Ayuso <pablo@netfilter.org> - 2017-08-02 14:30 +0200

#1700878 — [PATCH nf-next] netfilter: constify nf_loginfo structures

FromJulia Lawall <Julia.Lawall@lip6.fr>
Date2017-08-01 13:20 +0200
Subject[PATCH nf-next] netfilter: constify nf_loginfo structures
Message-ID<u9Dnr-3jr-7@gated-at.bofh.it>
The nf_loginfo structures are only passed as the seventh argument to
nf_log_trace, which is declared as const or stored in a local const
variable.  Thus the nf_loginfo structures themselves can be const.

Done with the help of Coccinelle.

// <smpl>
@r disable optional_qualifier@
identifier i;
position p;
@@
static struct nf_loginfo i@p = { ... };

@ok1@
identifier r.i;
expression list[6] es;
position p;
@@
 nf_log_trace(es,&i@p,...)

@ok2@
identifier r.i;
const struct nf_loginfo *e;
position p;
@@
 e = &i@p

@bad@
position p != {r.p,ok1.p,ok2.p};
identifier r.i;
struct nf_loginfo e;
@@
e@i@p

@depends on !bad disable optional_qualifier@
identifier r.i;
@@
static
+const
 struct nf_loginfo i = { ... };
// </smpl>

Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

---
 net/ipv4/netfilter/ip_tables.c   |    2 +-
 net/ipv4/netfilter/nf_log_arp.c  |    2 +-
 net/ipv4/netfilter/nf_log_ipv4.c |    2 +-
 net/ipv6/netfilter/ip6_tables.c  |    2 +-
 net/ipv6/netfilter/nf_log_ipv6.c |    2 +-
 net/netfilter/nf_tables_core.c   |    2 +-
 net/netfilter/nfnetlink_log.c    |    2 +-
 7 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/net/netfilter/nf_tables_core.c b/net/netfilter/nf_tables_core.c
index c5bab08..dfd0bf3 100644
--- a/net/netfilter/nf_tables_core.c
+++ b/net/netfilter/nf_tables_core.c
@@ -29,7 +29,7 @@
 	[NFT_TRACETYPE_RULE]	= "rule",
 };
 
-static struct nf_loginfo trace_loginfo = {
+static const struct nf_loginfo trace_loginfo = {
 	.type = NF_LOG_TYPE_LOG,
 	.u = {
 		.log = {
diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index c684ba9..cad6498 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -606,7 +606,7 @@ static void nfulnl_instance_free_rcu(struct rcu_head *head)
 	return -1;
 }
 
-static struct nf_loginfo default_loginfo = {
+static const struct nf_loginfo default_loginfo = {
 	.type =		NF_LOG_TYPE_ULOG,
 	.u = {
 		.ulog = {
diff --git a/net/ipv4/netfilter/ip_tables.c b/net/ipv4/netfilter/ip_tables.c
index 2a55a40..96a289c 100644
--- a/net/ipv4/netfilter/ip_tables.c
+++ b/net/ipv4/netfilter/ip_tables.c
@@ -151,7 +151,7 @@ enum nf_ip_trace_comments {
 	[NF_IP_TRACE_COMMENT_POLICY]	= "policy",
 };
 
-static struct nf_loginfo trace_loginfo = {
+static const struct nf_loginfo trace_loginfo = {
 	.type = NF_LOG_TYPE_LOG,
 	.u = {
 		.log = {
diff --git a/net/ipv4/netfilter/nf_log_arp.c b/net/ipv4/netfilter/nf_log_arp.c
index 2f3895d..df5c2a2 100644
--- a/net/ipv4/netfilter/nf_log_arp.c
+++ b/net/ipv4/netfilter/nf_log_arp.c
@@ -25,7 +25,7 @@
 #include <linux/netfilter/xt_LOG.h>
 #include <net/netfilter/nf_log.h>
 
-static struct nf_loginfo default_loginfo = {
+static const struct nf_loginfo default_loginfo = {
 	.type	= NF_LOG_TYPE_LOG,
 	.u = {
 		.log = {
diff --git a/net/ipv4/netfilter/nf_log_ipv4.c b/net/ipv4/netfilter/nf_log_ipv4.c
index c83a996..4388de0 100644
--- a/net/ipv4/netfilter/nf_log_ipv4.c
+++ b/net/ipv4/netfilter/nf_log_ipv4.c
@@ -24,7 +24,7 @@
 #include <linux/netfilter/xt_LOG.h>
 #include <net/netfilter/nf_log.h>
 
-static struct nf_loginfo default_loginfo = {
+static const struct nf_loginfo default_loginfo = {
 	.type	= NF_LOG_TYPE_LOG,
 	.u = {
 		.log = {
diff --git a/net/ipv6/netfilter/ip6_tables.c b/net/ipv6/netfilter/ip6_tables.c
index 1f90644..9f66449 100644
--- a/net/ipv6/netfilter/ip6_tables.c
+++ b/net/ipv6/netfilter/ip6_tables.c
@@ -176,7 +176,7 @@ enum nf_ip_trace_comments {
 	[NF_IP6_TRACE_COMMENT_POLICY]	= "policy",
 };
 
-static struct nf_loginfo trace_loginfo = {
+static const struct nf_loginfo trace_loginfo = {
 	.type = NF_LOG_TYPE_LOG,
 	.u = {
 		.log = {
diff --git a/net/ipv6/netfilter/nf_log_ipv6.c b/net/ipv6/netfilter/nf_log_ipv6.c
index 97c7242..b397a8f 100644
--- a/net/ipv6/netfilter/nf_log_ipv6.c
+++ b/net/ipv6/netfilter/nf_log_ipv6.c
@@ -25,7 +25,7 @@
 #include <linux/netfilter/xt_LOG.h>
 #include <net/netfilter/nf_log.h>
 
-static struct nf_loginfo default_loginfo = {
+static const struct nf_loginfo default_loginfo = {
 	.type	= NF_LOG_TYPE_LOG,
 	.u = {
 		.log = {

[toc] | [next] | [standalone]


#1702074

FromPablo Neira Ayuso <pablo@netfilter.org>
Date2017-08-02 14:30 +0200
Message-ID<ua0WK-1ph-5@gated-at.bofh.it>
In reply to#1700878
On Tue, Aug 01, 2017 at 12:48:03PM +0200, Julia Lawall wrote:
> The nf_loginfo structures are only passed as the seventh argument to
> nf_log_trace, which is declared as const or stored in a local const
> variable.  Thus the nf_loginfo structures themselves can be const.
> 
> Done with the help of Coccinelle.
> 
> // <smpl>
> @r disable optional_qualifier@
> identifier i;
> position p;
> @@
> static struct nf_loginfo i@p = { ... };
> 
> @ok1@
> identifier r.i;
> expression list[6] es;
> position p;
> @@
>  nf_log_trace(es,&i@p,...)
> 
> @ok2@
> identifier r.i;
> const struct nf_loginfo *e;
> position p;
> @@
>  e = &i@p
> 
> @bad@
> position p != {r.p,ok1.p,ok2.p};
> identifier r.i;
> struct nf_loginfo e;
> @@
> e@i@p
> 
> @depends on !bad disable optional_qualifier@
> identifier r.i;
> @@
> static
> +const
>  struct nf_loginfo i = { ... };
> // </smpl>

Applied, thanks Julia.

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web