* [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks
[not found] <20141029215602.535533597@goodmis.org>
@ 2014-10-29 21:56 ` Steven Rostedt
2014-10-29 22:16 ` Florian Westphal
2014-11-04 13:05 ` Steven Rostedt
2014-10-29 21:56 ` [RFA][PATCH 3/8] netfilter: Convert print_tuple functions to return void Steven Rostedt
2014-10-29 21:56 ` [RFA][PATCH 4/8] netfilter: Remove checks of seq_printf() return values Steven Rostedt
2 siblings, 2 replies; 18+ messages in thread
From: Steven Rostedt @ 2014-10-29 21:56 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Al Viro, Joe Perches,
Pablo Neira Ayuso, Patrick McHardy, Jozsef Kadlecsik,
netfilter-devel, coreteam
[-- Attachment #1: 0002-netfilter-Remove-return-values-for-print_conntrack-c.patch --]
[-- Type: text/plain, Size: 6247 bytes --]
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
[ REQUEST FOR ACKS ]
The seq_printf() and friends are having their return values removed.
The print_conntrack() returns the result of seq_printf(), which is
meaningless when seq_printf() returns void. Might as well remove the
return values of print_conntrack() as well.
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Patrick McHardy <kaber@trash.net>
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: netfilter-devel@vger.kernel.org
Cc: coreteam@netfilter.org
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
include/net/netfilter/nf_conntrack_l4proto.h | 2 +-
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c | 5 ++++-
net/netfilter/nf_conntrack_proto_dccp.c | 4 ++--
net/netfilter/nf_conntrack_proto_gre.c | 8 ++++----
net/netfilter/nf_conntrack_proto_sctp.c | 4 ++--
net/netfilter/nf_conntrack_proto_tcp.c | 4 ++--
net/netfilter/nf_conntrack_standalone.c | 4 ++--
7 files changed, 17 insertions(+), 14 deletions(-)
diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h
index 4c8d573830b7..82e4ec002a39 100644
--- a/include/net/netfilter/nf_conntrack_l4proto.h
+++ b/include/net/netfilter/nf_conntrack_l4proto.h
@@ -60,7 +60,7 @@ struct nf_conntrack_l4proto {
const struct nf_conntrack_tuple *);
/* Print out the private part of the conntrack. */
- int (*print_conntrack)(struct seq_file *s, struct nf_conn *);
+ void (*print_conntrack)(struct seq_file *s, struct nf_conn *);
/* Return the array of timeouts for this protocol. */
unsigned int *(*get_timeouts)(struct net *net);
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
index 4c48e434bb1f..91f207c2cb69 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
@@ -147,7 +147,10 @@ static int ct_seq_show(struct seq_file *s, void *v)
? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0)
goto release;
- if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct))
+ if (l4proto->print_conntrack)
+ l4proto->print_conntrack(s, ct);
+
+ if (seq_has_overflowed(s))
goto release;
if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
index cb372f96f10d..15971177470a 100644
--- a/net/netfilter/nf_conntrack_proto_dccp.c
+++ b/net/netfilter/nf_conntrack_proto_dccp.c
@@ -626,9 +626,9 @@ static int dccp_print_tuple(struct seq_file *s,
ntohs(tuple->dst.u.dccp.port));
}
-static int dccp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
+static void dccp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
{
- return seq_printf(s, "%s ", dccp_state_names[ct->proto.dccp.state]);
+ seq_printf(s, "%s ", dccp_state_names[ct->proto.dccp.state]);
}
#if IS_ENABLED(CONFIG_NF_CT_NETLINK)
diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c
index d5665739e3b1..cba607ada069 100644
--- a/net/netfilter/nf_conntrack_proto_gre.c
+++ b/net/netfilter/nf_conntrack_proto_gre.c
@@ -235,11 +235,11 @@ static int gre_print_tuple(struct seq_file *s,
}
/* print private data for conntrack */
-static int gre_print_conntrack(struct seq_file *s, struct nf_conn *ct)
+static void gre_print_conntrack(struct seq_file *s, struct nf_conn *ct)
{
- return seq_printf(s, "timeout=%u, stream_timeout=%u ",
- (ct->proto.gre.timeout / HZ),
- (ct->proto.gre.stream_timeout / HZ));
+ seq_printf(s, "timeout=%u, stream_timeout=%u ",
+ (ct->proto.gre.timeout / HZ),
+ (ct->proto.gre.stream_timeout / HZ));
}
static unsigned int *gre_get_timeouts(struct net *net)
diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
index 1314d33f6bcf..c61f4cd6407d 100644
--- a/net/netfilter/nf_conntrack_proto_sctp.c
+++ b/net/netfilter/nf_conntrack_proto_sctp.c
@@ -175,7 +175,7 @@ static int sctp_print_tuple(struct seq_file *s,
}
/* Print out the private part of the conntrack. */
-static int sctp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
+static void sctp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
{
enum sctp_conntrack state;
@@ -183,7 +183,7 @@ static int sctp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
state = ct->proto.sctp.state;
spin_unlock_bh(&ct->lock);
- return seq_printf(s, "%s ", sctp_conntrack_names[state]);
+ seq_printf(s, "%s ", sctp_conntrack_names[state]);
}
#define for_each_sctp_chunk(skb, sch, _sch, offset, dataoff, count) \
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 44d1ea32570a..79668fd3db96 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -311,7 +311,7 @@ static int tcp_print_tuple(struct seq_file *s,
}
/* Print out the private part of the conntrack. */
-static int tcp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
+static void tcp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
{
enum tcp_conntrack state;
@@ -319,7 +319,7 @@ static int tcp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
state = ct->proto.tcp.state;
spin_unlock_bh(&ct->lock);
- return seq_printf(s, "%s ", tcp_conntrack_names[state]);
+ seq_printf(s, "%s ", tcp_conntrack_names[state]);
}
static unsigned int get_conntrack_index(const struct tcphdr *tcph)
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index cf65a1e040dd..348aa3602787 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -199,8 +199,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0)
goto release;
- if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct))
- goto release;
+ if (l4proto->print_conntrack)
+ l4proto->print_conntrack(s, ct);
if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
l3proto, l4proto))
--
2.1.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFA][PATCH 3/8] netfilter: Convert print_tuple functions to return void
[not found] <20141029215602.535533597@goodmis.org>
2014-10-29 21:56 ` [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks Steven Rostedt
@ 2014-10-29 21:56 ` Steven Rostedt
2014-11-04 13:07 ` Steven Rostedt
2014-11-04 14:50 ` Steven Rostedt
2014-10-29 21:56 ` [RFA][PATCH 4/8] netfilter: Remove checks of seq_printf() return values Steven Rostedt
2 siblings, 2 replies; 18+ messages in thread
From: Steven Rostedt @ 2014-10-29 21:56 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Al Viro, Joe Perches,
Pablo Neira Ayuso, Patrick McHardy, Jozsef Kadlecsik,
netfilter-devel, coreteam
[-- Attachment #1: 0003-netfilter-Convert-print_tuple-functions-to-return-vo.patch --]
[-- Type: text/plain, Size: 16008 bytes --]
From: Joe Perches <joe@perches.com>
[ REQUEST FOR ACKS ]
Since adding a new function to seq_file (seq_has_overflowed())
there isn't any value for functions called from seq_show to
return anything. Remove the int returns of the various
print_tuple/<foo>_print_tuple functions.
Link: http://lkml.kernel.org/p/f2e8cf8df433a197daa62cbaf124c900c708edc7.1412031505.git.joe@perches.com
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Patrick McHardy <kaber@trash.net>
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: netfilter-devel@vger.kernel.org
Cc: coreteam@netfilter.org
Signed-off-by: Joe Perches <joe@perches.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
include/net/netfilter/nf_conntrack_core.h | 2 +-
include/net/netfilter/nf_conntrack_l3proto.h | 4 ++--
include/net/netfilter/nf_conntrack_l4proto.h | 4 ++--
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 6 +++---
net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c | 12 ++++++++----
net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 10 +++++-----
net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 6 +++---
net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 10 +++++-----
net/netfilter/nf_conntrack_l3proto_generic.c | 5 ++---
net/netfilter/nf_conntrack_proto_dccp.c | 10 +++++-----
net/netfilter/nf_conntrack_proto_generic.c | 5 ++---
net/netfilter/nf_conntrack_proto_gre.c | 10 +++++-----
net/netfilter/nf_conntrack_proto_sctp.c | 10 +++++-----
net/netfilter/nf_conntrack_proto_tcp.c | 10 +++++-----
net/netfilter/nf_conntrack_proto_udp.c | 10 +++++-----
net/netfilter/nf_conntrack_proto_udplite.c | 10 +++++-----
net/netfilter/nf_conntrack_standalone.c | 15 +++++++--------
17 files changed, 70 insertions(+), 69 deletions(-)
diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h
index cc0c18827602..f2f0fa3bb150 100644
--- a/include/net/netfilter/nf_conntrack_core.h
+++ b/include/net/netfilter/nf_conntrack_core.h
@@ -72,7 +72,7 @@ static inline int nf_conntrack_confirm(struct sk_buff *skb)
return ret;
}
-int
+void
print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
const struct nf_conntrack_l3proto *l3proto,
const struct nf_conntrack_l4proto *proto);
diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h
index adc1fa3dd7ab..cdc920b4c4c2 100644
--- a/include/net/netfilter/nf_conntrack_l3proto.h
+++ b/include/net/netfilter/nf_conntrack_l3proto.h
@@ -38,8 +38,8 @@ struct nf_conntrack_l3proto {
const struct nf_conntrack_tuple *orig);
/* Print out the per-protocol part of the tuple. */
- int (*print_tuple)(struct seq_file *s,
- const struct nf_conntrack_tuple *);
+ void (*print_tuple)(struct seq_file *s,
+ const struct nf_conntrack_tuple *);
/*
* Called before tracking.
diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h
index 82e4ec002a39..1f7061313d54 100644
--- a/include/net/netfilter/nf_conntrack_l4proto.h
+++ b/include/net/netfilter/nf_conntrack_l4proto.h
@@ -56,8 +56,8 @@ struct nf_conntrack_l4proto {
u_int8_t pf, unsigned int hooknum);
/* Print out the per-protocol part of the tuple. Return like seq_* */
- int (*print_tuple)(struct seq_file *s,
- const struct nf_conntrack_tuple *);
+ void (*print_tuple)(struct seq_file *s,
+ const struct nf_conntrack_tuple *);
/* Print out the private part of the conntrack. */
void (*print_conntrack)(struct seq_file *s, struct nf_conn *);
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
index a054fe083431..5c61328b7704 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
@@ -56,11 +56,11 @@ static bool ipv4_invert_tuple(struct nf_conntrack_tuple *tuple,
return true;
}
-static int ipv4_print_tuple(struct seq_file *s,
+static void ipv4_print_tuple(struct seq_file *s,
const struct nf_conntrack_tuple *tuple)
{
- return seq_printf(s, "src=%pI4 dst=%pI4 ",
- &tuple->src.u3.ip, &tuple->dst.u3.ip);
+ seq_printf(s, "src=%pI4 dst=%pI4 ",
+ &tuple->src.u3.ip, &tuple->dst.u3.ip);
}
static int ipv4_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
index 91f207c2cb69..d927f9e72130 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
@@ -153,8 +153,10 @@ static int ct_seq_show(struct seq_file *s, void *v)
if (seq_has_overflowed(s))
goto release;
- if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
- l3proto, l4proto))
+ print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
+ l3proto, l4proto);
+
+ if (seq_has_overflowed(s))
goto release;
if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL))
@@ -164,8 +166,10 @@ static int ct_seq_show(struct seq_file *s, void *v)
if (seq_printf(s, "[UNREPLIED] "))
goto release;
- if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
- l3proto, l4proto))
+ print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
+ l3proto, l4proto);
+
+ if (seq_has_overflowed(s))
goto release;
if (seq_print_acct(s, ct, IP_CT_DIR_REPLY))
diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
index b91b2641adda..80d5554b9a88 100644
--- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
+++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
@@ -72,13 +72,13 @@ static bool icmp_invert_tuple(struct nf_conntrack_tuple *tuple,
}
/* Print out the per-protocol part of the tuple. */
-static int icmp_print_tuple(struct seq_file *s,
+static void icmp_print_tuple(struct seq_file *s,
const struct nf_conntrack_tuple *tuple)
{
- return seq_printf(s, "type=%u code=%u id=%u ",
- tuple->dst.u.icmp.type,
- tuple->dst.u.icmp.code,
- ntohs(tuple->src.u.icmp.id));
+ seq_printf(s, "type=%u code=%u id=%u ",
+ tuple->dst.u.icmp.type,
+ tuple->dst.u.icmp.code,
+ ntohs(tuple->src.u.icmp.id));
}
static unsigned int *icmp_get_timeouts(struct net *net)
diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
index 4cbc6b290dd5..b68d0e59c1f8 100644
--- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
@@ -60,11 +60,11 @@ static bool ipv6_invert_tuple(struct nf_conntrack_tuple *tuple,
return true;
}
-static int ipv6_print_tuple(struct seq_file *s,
+static void ipv6_print_tuple(struct seq_file *s,
const struct nf_conntrack_tuple *tuple)
{
- return seq_printf(s, "src=%pI6 dst=%pI6 ",
- tuple->src.u3.ip6, tuple->dst.u3.ip6);
+ seq_printf(s, "src=%pI6 dst=%pI6 ",
+ tuple->src.u3.ip6, tuple->dst.u3.ip6);
}
static int ipv6_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
index b3807c5cb888..90388d606483 100644
--- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
+++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
@@ -84,13 +84,13 @@ static bool icmpv6_invert_tuple(struct nf_conntrack_tuple *tuple,
}
/* Print out the per-protocol part of the tuple. */
-static int icmpv6_print_tuple(struct seq_file *s,
+static void icmpv6_print_tuple(struct seq_file *s,
const struct nf_conntrack_tuple *tuple)
{
- return seq_printf(s, "type=%u code=%u id=%u ",
- tuple->dst.u.icmp.type,
- tuple->dst.u.icmp.code,
- ntohs(tuple->src.u.icmp.id));
+ seq_printf(s, "type=%u code=%u id=%u ",
+ tuple->dst.u.icmp.type,
+ tuple->dst.u.icmp.code,
+ ntohs(tuple->src.u.icmp.id));
}
static unsigned int *icmpv6_get_timeouts(struct net *net)
diff --git a/net/netfilter/nf_conntrack_l3proto_generic.c b/net/netfilter/nf_conntrack_l3proto_generic.c
index e7eb807fe07d..cf9ace70bece 100644
--- a/net/netfilter/nf_conntrack_l3proto_generic.c
+++ b/net/netfilter/nf_conntrack_l3proto_generic.c
@@ -49,10 +49,9 @@ static bool generic_invert_tuple(struct nf_conntrack_tuple *tuple,
return true;
}
-static int generic_print_tuple(struct seq_file *s,
- const struct nf_conntrack_tuple *tuple)
+static void generic_print_tuple(struct seq_file *s,
+ const struct nf_conntrack_tuple *tuple)
{
- return 0;
}
static int generic_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
index 15971177470a..6dd995c7c72b 100644
--- a/net/netfilter/nf_conntrack_proto_dccp.c
+++ b/net/netfilter/nf_conntrack_proto_dccp.c
@@ -618,12 +618,12 @@ out_invalid:
return -NF_ACCEPT;
}
-static int dccp_print_tuple(struct seq_file *s,
- const struct nf_conntrack_tuple *tuple)
+static void dccp_print_tuple(struct seq_file *s,
+ const struct nf_conntrack_tuple *tuple)
{
- return seq_printf(s, "sport=%hu dport=%hu ",
- ntohs(tuple->src.u.dccp.port),
- ntohs(tuple->dst.u.dccp.port));
+ seq_printf(s, "sport=%hu dport=%hu ",
+ ntohs(tuple->src.u.dccp.port),
+ ntohs(tuple->dst.u.dccp.port));
}
static void dccp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
diff --git a/net/netfilter/nf_conntrack_proto_generic.c b/net/netfilter/nf_conntrack_proto_generic.c
index 957c1db66652..60865f110309 100644
--- a/net/netfilter/nf_conntrack_proto_generic.c
+++ b/net/netfilter/nf_conntrack_proto_generic.c
@@ -63,10 +63,9 @@ static bool generic_invert_tuple(struct nf_conntrack_tuple *tuple,
}
/* Print out the per-protocol part of the tuple. */
-static int generic_print_tuple(struct seq_file *s,
- const struct nf_conntrack_tuple *tuple)
+static void generic_print_tuple(struct seq_file *s,
+ const struct nf_conntrack_tuple *tuple)
{
- return 0;
}
static unsigned int *generic_get_timeouts(struct net *net)
diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c
index cba607ada069..7648674f29c3 100644
--- a/net/netfilter/nf_conntrack_proto_gre.c
+++ b/net/netfilter/nf_conntrack_proto_gre.c
@@ -226,12 +226,12 @@ static bool gre_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,
}
/* print gre part of tuple */
-static int gre_print_tuple(struct seq_file *s,
- const struct nf_conntrack_tuple *tuple)
+static void gre_print_tuple(struct seq_file *s,
+ const struct nf_conntrack_tuple *tuple)
{
- return seq_printf(s, "srckey=0x%x dstkey=0x%x ",
- ntohs(tuple->src.u.gre.key),
- ntohs(tuple->dst.u.gre.key));
+ seq_printf(s, "srckey=0x%x dstkey=0x%x ",
+ ntohs(tuple->src.u.gre.key),
+ ntohs(tuple->dst.u.gre.key));
}
/* print private data for conntrack */
diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
index c61f4cd6407d..b45da90fad32 100644
--- a/net/netfilter/nf_conntrack_proto_sctp.c
+++ b/net/netfilter/nf_conntrack_proto_sctp.c
@@ -166,12 +166,12 @@ static bool sctp_invert_tuple(struct nf_conntrack_tuple *tuple,
}
/* Print out the per-protocol part of the tuple. */
-static int sctp_print_tuple(struct seq_file *s,
- const struct nf_conntrack_tuple *tuple)
+static void sctp_print_tuple(struct seq_file *s,
+ const struct nf_conntrack_tuple *tuple)
{
- return seq_printf(s, "sport=%hu dport=%hu ",
- ntohs(tuple->src.u.sctp.port),
- ntohs(tuple->dst.u.sctp.port));
+ seq_printf(s, "sport=%hu dport=%hu ",
+ ntohs(tuple->src.u.sctp.port),
+ ntohs(tuple->dst.u.sctp.port));
}
/* Print out the private part of the conntrack. */
diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
index 79668fd3db96..36a3ac8ee9f5 100644
--- a/net/netfilter/nf_conntrack_proto_tcp.c
+++ b/net/netfilter/nf_conntrack_proto_tcp.c
@@ -302,12 +302,12 @@ static bool tcp_invert_tuple(struct nf_conntrack_tuple *tuple,
}
/* Print out the per-protocol part of the tuple. */
-static int tcp_print_tuple(struct seq_file *s,
- const struct nf_conntrack_tuple *tuple)
+static void tcp_print_tuple(struct seq_file *s,
+ const struct nf_conntrack_tuple *tuple)
{
- return seq_printf(s, "sport=%hu dport=%hu ",
- ntohs(tuple->src.u.tcp.port),
- ntohs(tuple->dst.u.tcp.port));
+ seq_printf(s, "sport=%hu dport=%hu ",
+ ntohs(tuple->src.u.tcp.port),
+ ntohs(tuple->dst.u.tcp.port));
}
/* Print out the private part of the conntrack. */
diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c
index 9d7721cbce4b..6957281ffee5 100644
--- a/net/netfilter/nf_conntrack_proto_udp.c
+++ b/net/netfilter/nf_conntrack_proto_udp.c
@@ -63,12 +63,12 @@ static bool udp_invert_tuple(struct nf_conntrack_tuple *tuple,
}
/* Print out the per-protocol part of the tuple. */
-static int udp_print_tuple(struct seq_file *s,
- const struct nf_conntrack_tuple *tuple)
+static void udp_print_tuple(struct seq_file *s,
+ const struct nf_conntrack_tuple *tuple)
{
- return seq_printf(s, "sport=%hu dport=%hu ",
- ntohs(tuple->src.u.udp.port),
- ntohs(tuple->dst.u.udp.port));
+ seq_printf(s, "sport=%hu dport=%hu ",
+ ntohs(tuple->src.u.udp.port),
+ ntohs(tuple->dst.u.udp.port));
}
static unsigned int *udp_get_timeouts(struct net *net)
diff --git a/net/netfilter/nf_conntrack_proto_udplite.c b/net/netfilter/nf_conntrack_proto_udplite.c
index 2750e6c69f82..c5903d1649f9 100644
--- a/net/netfilter/nf_conntrack_proto_udplite.c
+++ b/net/netfilter/nf_conntrack_proto_udplite.c
@@ -71,12 +71,12 @@ static bool udplite_invert_tuple(struct nf_conntrack_tuple *tuple,
}
/* Print out the per-protocol part of the tuple. */
-static int udplite_print_tuple(struct seq_file *s,
- const struct nf_conntrack_tuple *tuple)
+static void udplite_print_tuple(struct seq_file *s,
+ const struct nf_conntrack_tuple *tuple)
{
- return seq_printf(s, "sport=%hu dport=%hu ",
- ntohs(tuple->src.u.udp.port),
- ntohs(tuple->dst.u.udp.port));
+ seq_printf(s, "sport=%hu dport=%hu ",
+ ntohs(tuple->src.u.udp.port),
+ ntohs(tuple->dst.u.udp.port));
}
static unsigned int *udplite_get_timeouts(struct net *net)
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 348aa3602787..23a0dcab21d4 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -36,12 +36,13 @@
MODULE_LICENSE("GPL");
#ifdef CONFIG_NF_CONNTRACK_PROCFS
-int
+void
print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
const struct nf_conntrack_l3proto *l3proto,
const struct nf_conntrack_l4proto *l4proto)
{
- return l3proto->print_tuple(s, tuple) || l4proto->print_tuple(s, tuple);
+ l3proto->print_tuple(s, tuple);
+ l4proto->print_tuple(s, tuple);
}
EXPORT_SYMBOL_GPL(print_tuple);
@@ -202,9 +203,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
if (l4proto->print_conntrack)
l4proto->print_conntrack(s, ct);
- if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
- l3proto, l4proto))
- goto release;
+ print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
+ l3proto, l4proto);
if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL))
goto release;
@@ -213,9 +213,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
if (seq_printf(s, "[UNREPLIED] "))
goto release;
- if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
- l3proto, l4proto))
- goto release;
+ print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
+ l3proto, l4proto);
if (seq_print_acct(s, ct, IP_CT_DIR_REPLY))
goto release;
--
2.1.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [RFA][PATCH 4/8] netfilter: Remove checks of seq_printf() return values
[not found] <20141029215602.535533597@goodmis.org>
2014-10-29 21:56 ` [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks Steven Rostedt
2014-10-29 21:56 ` [RFA][PATCH 3/8] netfilter: Convert print_tuple functions to return void Steven Rostedt
@ 2014-10-29 21:56 ` Steven Rostedt
2014-11-04 13:08 ` Steven Rostedt
2 siblings, 1 reply; 18+ messages in thread
From: Steven Rostedt @ 2014-10-29 21:56 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Al Viro, Joe Perches,
Pablo Neira Ayuso, Patrick McHardy, Jozsef Kadlecsik,
netfilter-devel, coreteam
[-- Attachment #1: 0004-netfilter-Remove-checks-of-seq_printf-return-values.patch --]
[-- Type: text/plain, Size: 13276 bytes --]
From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
[ REQUEST FOR ACKS ]
The return value of seq_printf() is soon to be removed. Remove the
checks from seq_printf() in favor of seq_has_overflowed().
Cc: Pablo Neira Ayuso <pablo@netfilter.org>
Cc: Patrick McHardy <kaber@trash.net>
Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
Cc: netfilter-devel@vger.kernel.org
Cc: coreteam@netfilter.org
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
.../netfilter/nf_conntrack_l3proto_ipv4_compat.c | 36 ++++++-------
net/netfilter/nf_conntrack_standalone.c | 60 +++++++++++-----------
net/netfilter/nf_log.c | 30 ++++++-----
net/netfilter/nfnetlink_queue_core.c | 13 ++---
net/netfilter/x_tables.c | 19 ++++---
net/netfilter/xt_hashlimit.c | 36 ++++++-------
6 files changed, 97 insertions(+), 97 deletions(-)
diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
index d927f9e72130..a460a87e14f8 100644
--- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
+++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
@@ -94,7 +94,7 @@ static void ct_seq_stop(struct seq_file *s, void *v)
}
#ifdef CONFIG_NF_CONNTRACK_SECMARK
-static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
+static void ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
{
int ret;
u32 len;
@@ -102,17 +102,15 @@ static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
ret = security_secid_to_secctx(ct->secmark, &secctx, &len);
if (ret)
- return 0;
+ return;
- ret = seq_printf(s, "secctx=%s ", secctx);
+ seq_printf(s, "secctx=%s ", secctx);
security_release_secctx(secctx, len);
- return ret;
}
#else
-static inline int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
+static inline void ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
{
- return 0;
}
#endif
@@ -141,11 +139,10 @@ static int ct_seq_show(struct seq_file *s, void *v)
NF_CT_ASSERT(l4proto);
ret = -ENOSPC;
- if (seq_printf(s, "%-8s %u %ld ",
- l4proto->name, nf_ct_protonum(ct),
- timer_pending(&ct->timeout)
- ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0)
- goto release;
+ seq_printf(s, "%-8s %u %ld ",
+ l4proto->name, nf_ct_protonum(ct),
+ timer_pending(&ct->timeout)
+ ? (long)(ct->timeout.expires - jiffies)/HZ : 0);
if (l4proto->print_conntrack)
l4proto->print_conntrack(s, ct);
@@ -163,8 +160,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
goto release;
if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status)))
- if (seq_printf(s, "[UNREPLIED] "))
- goto release;
+ seq_printf(s, "[UNREPLIED] ");
print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
l3proto, l4proto);
@@ -176,19 +172,19 @@ static int ct_seq_show(struct seq_file *s, void *v)
goto release;
if (test_bit(IPS_ASSURED_BIT, &ct->status))
- if (seq_printf(s, "[ASSURED] "))
- goto release;
+ seq_printf(s, "[ASSURED] ");
#ifdef CONFIG_NF_CONNTRACK_MARK
- if (seq_printf(s, "mark=%u ", ct->mark))
- goto release;
+ seq_printf(s, "mark=%u ", ct->mark);
#endif
- if (ct_show_secctx(s, ct))
- goto release;
+ ct_show_secctx(s, ct);
+
+ seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use));
- if (seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use)))
+ if (seq_has_overflowed(s))
goto release;
+
ret = 0;
release:
nf_ct_put(ct);
diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 23a0dcab21d4..fc823fa5dcf5 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -120,7 +120,7 @@ static void ct_seq_stop(struct seq_file *s, void *v)
}
#ifdef CONFIG_NF_CONNTRACK_SECMARK
-static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
+static void ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
{
int ret;
u32 len;
@@ -128,22 +128,20 @@ static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
ret = security_secid_to_secctx(ct->secmark, &secctx, &len);
if (ret)
- return 0;
+ return;
- ret = seq_printf(s, "secctx=%s ", secctx);
+ seq_printf(s, "secctx=%s ", secctx);
security_release_secctx(secctx, len);
- return ret;
}
#else
-static inline int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
+static inline void ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
{
- return 0;
}
#endif
#ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
-static int ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)
+static void ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)
{
struct ct_iter_state *st = s->private;
struct nf_conn_tstamp *tstamp;
@@ -157,16 +155,15 @@ static int ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)
else
delta_time = 0;
- return seq_printf(s, "delta-time=%llu ",
- (unsigned long long)delta_time);
+ seq_printf(s, "delta-time=%llu ",
+ (unsigned long long)delta_time);
}
- return 0;
+ return;
}
#else
-static inline int
+static inline void
ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)
{
- return 0;
}
#endif
@@ -193,12 +190,11 @@ static int ct_seq_show(struct seq_file *s, void *v)
NF_CT_ASSERT(l4proto);
ret = -ENOSPC;
- if (seq_printf(s, "%-8s %u %-8s %u %ld ",
- l3proto->name, nf_ct_l3num(ct),
- l4proto->name, nf_ct_protonum(ct),
- timer_pending(&ct->timeout)
- ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0)
- goto release;
+ seq_printf(s, "%-8s %u %-8s %u %ld ",
+ l3proto->name, nf_ct_l3num(ct),
+ l4proto->name, nf_ct_protonum(ct),
+ timer_pending(&ct->timeout)
+ ? (long)(ct->timeout.expires - jiffies)/HZ : 0);
if (l4proto->print_conntrack)
l4proto->print_conntrack(s, ct);
@@ -206,12 +202,14 @@ static int ct_seq_show(struct seq_file *s, void *v)
print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
l3proto, l4proto);
+ if (seq_has_overflowed(s))
+ goto release;
+
if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL))
goto release;
if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status)))
- if (seq_printf(s, "[UNREPLIED] "))
- goto release;
+ seq_printf(s, "[UNREPLIED] ");
print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
l3proto, l4proto);
@@ -220,26 +218,26 @@ static int ct_seq_show(struct seq_file *s, void *v)
goto release;
if (test_bit(IPS_ASSURED_BIT, &ct->status))
- if (seq_printf(s, "[ASSURED] "))
- goto release;
+ seq_printf(s, "[ASSURED] ");
-#if defined(CONFIG_NF_CONNTRACK_MARK)
- if (seq_printf(s, "mark=%u ", ct->mark))
+ if (seq_has_overflowed(s))
goto release;
+
+#if defined(CONFIG_NF_CONNTRACK_MARK)
+ seq_printf(s, "mark=%u ", ct->mark);
#endif
- if (ct_show_secctx(s, ct))
- goto release;
+ ct_show_secctx(s, ct);
#ifdef CONFIG_NF_CONNTRACK_ZONES
- if (seq_printf(s, "zone=%u ", nf_ct_zone(ct)))
- goto release;
+ seq_printf(s, "zone=%u ", nf_ct_zone(ct));
#endif
- if (ct_show_delta_time(s, ct))
- goto release;
+ ct_show_delta_time(s, ct);
+
+ seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use));
- if (seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use)))
+ if (seq_has_overflowed(s))
goto release;
ret = 0;
diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
index d7197649dba6..6e3b9117db1f 100644
--- a/net/netfilter/nf_log.c
+++ b/net/netfilter/nf_log.c
@@ -294,19 +294,19 @@ static int seq_show(struct seq_file *s, void *v)
{
loff_t *pos = v;
const struct nf_logger *logger;
- int i, ret;
+ int i;
struct net *net = seq_file_net(s);
logger = rcu_dereference_protected(net->nf.nf_loggers[*pos],
lockdep_is_held(&nf_log_mutex));
if (!logger)
- ret = seq_printf(s, "%2lld NONE (", *pos);
+ seq_printf(s, "%2lld NONE (", *pos);
else
- ret = seq_printf(s, "%2lld %s (", *pos, logger->name);
+ seq_printf(s, "%2lld %s (", *pos, logger->name);
- if (ret < 0)
- return ret;
+ if (seq_has_overflowed(s))
+ return -ENOSPC;
for (i = 0; i < NF_LOG_TYPE_MAX; i++) {
if (loggers[*pos][i] == NULL)
@@ -314,17 +314,19 @@ static int seq_show(struct seq_file *s, void *v)
logger = rcu_dereference_protected(loggers[*pos][i],
lockdep_is_held(&nf_log_mutex));
- ret = seq_printf(s, "%s", logger->name);
- if (ret < 0)
- return ret;
- if (i == 0 && loggers[*pos][i + 1] != NULL) {
- ret = seq_printf(s, ",");
- if (ret < 0)
- return ret;
- }
+ seq_printf(s, "%s", logger->name);
+ if (i == 0 && loggers[*pos][i + 1] != NULL)
+ seq_printf(s, ",");
+
+ if (seq_has_overflowed(s))
+ return -ENOSPC;
}
- return seq_printf(s, ")\n");
+ seq_printf(s, ")\n");
+
+ if (seq_has_overflowed(s))
+ return -ENOSPC;
+ return 0;
}
static const struct seq_operations nflog_seq_ops = {
diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
index a82077d9f59b..f823f1538c4f 100644
--- a/net/netfilter/nfnetlink_queue_core.c
+++ b/net/netfilter/nfnetlink_queue_core.c
@@ -1242,12 +1242,13 @@ static int seq_show(struct seq_file *s, void *v)
{
const struct nfqnl_instance *inst = v;
- return seq_printf(s, "%5d %6d %5d %1d %5d %5d %5d %8d %2d\n",
- inst->queue_num,
- inst->peer_portid, inst->queue_total,
- inst->copy_mode, inst->copy_range,
- inst->queue_dropped, inst->queue_user_dropped,
- inst->id_sequence, 1);
+ seq_printf(s, "%5d %6d %5d %1d %5d %5d %5d %8d %2d\n",
+ inst->queue_num,
+ inst->peer_portid, inst->queue_total,
+ inst->copy_mode, inst->copy_range,
+ inst->queue_dropped, inst->queue_user_dropped,
+ inst->id_sequence, 1);
+ return seq_has_overflowed(s);
}
static const struct seq_operations nfqnl_seq_ops = {
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
index 133eb4772f12..51a459c3c649 100644
--- a/net/netfilter/x_tables.c
+++ b/net/netfilter/x_tables.c
@@ -947,9 +947,10 @@ static int xt_table_seq_show(struct seq_file *seq, void *v)
{
struct xt_table *table = list_entry(v, struct xt_table, list);
- if (strlen(table->name))
- return seq_printf(seq, "%s\n", table->name);
- else
+ if (strlen(table->name)) {
+ seq_printf(seq, "%s\n", table->name);
+ return seq_has_overflowed(seq);
+ } else
return 0;
}
@@ -1086,8 +1087,10 @@ static int xt_match_seq_show(struct seq_file *seq, void *v)
if (trav->curr == trav->head)
return 0;
match = list_entry(trav->curr, struct xt_match, list);
- return (*match->name == '\0') ? 0 :
- seq_printf(seq, "%s\n", match->name);
+ if (*match->name == '\0')
+ return 0;
+ seq_printf(seq, "%s\n", match->name);
+ return seq_has_overflowed(seq);
}
return 0;
}
@@ -1139,8 +1142,10 @@ static int xt_target_seq_show(struct seq_file *seq, void *v)
if (trav->curr == trav->head)
return 0;
target = list_entry(trav->curr, struct xt_target, list);
- return (*target->name == '\0') ? 0 :
- seq_printf(seq, "%s\n", target->name);
+ if (*target->name == '\0')
+ return 0;
+ seq_printf(seq, "%s\n", target->name);
+ return seq_has_overflowed(seq);
}
return 0;
}
diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
index 05fbc2a0be46..178696852bde 100644
--- a/net/netfilter/xt_hashlimit.c
+++ b/net/netfilter/xt_hashlimit.c
@@ -789,7 +789,6 @@ static void dl_seq_stop(struct seq_file *s, void *v)
static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family,
struct seq_file *s)
{
- int res;
const struct xt_hashlimit_htable *ht = s->private;
spin_lock(&ent->lock);
@@ -798,33 +797,32 @@ static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family,
switch (family) {
case NFPROTO_IPV4:
- res = seq_printf(s, "%ld %pI4:%u->%pI4:%u %u %u %u\n",
- (long)(ent->expires - jiffies)/HZ,
- &ent->dst.ip.src,
- ntohs(ent->dst.src_port),
- &ent->dst.ip.dst,
- ntohs(ent->dst.dst_port),
- ent->rateinfo.credit, ent->rateinfo.credit_cap,
- ent->rateinfo.cost);
+ seq_printf(s, "%ld %pI4:%u->%pI4:%u %u %u %u\n",
+ (long)(ent->expires - jiffies)/HZ,
+ &ent->dst.ip.src,
+ ntohs(ent->dst.src_port),
+ &ent->dst.ip.dst,
+ ntohs(ent->dst.dst_port),
+ ent->rateinfo.credit, ent->rateinfo.credit_cap,
+ ent->rateinfo.cost);
break;
#if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
case NFPROTO_IPV6:
- res = seq_printf(s, "%ld %pI6:%u->%pI6:%u %u %u %u\n",
- (long)(ent->expires - jiffies)/HZ,
- &ent->dst.ip6.src,
- ntohs(ent->dst.src_port),
- &ent->dst.ip6.dst,
- ntohs(ent->dst.dst_port),
- ent->rateinfo.credit, ent->rateinfo.credit_cap,
- ent->rateinfo.cost);
+ seq_printf(s, "%ld %pI6:%u->%pI6:%u %u %u %u\n",
+ (long)(ent->expires - jiffies)/HZ,
+ &ent->dst.ip6.src,
+ ntohs(ent->dst.src_port),
+ &ent->dst.ip6.dst,
+ ntohs(ent->dst.dst_port),
+ ent->rateinfo.credit, ent->rateinfo.credit_cap,
+ ent->rateinfo.cost);
break;
#endif
default:
BUG();
- res = 0;
}
spin_unlock(&ent->lock);
- return res;
+ return seq_has_overflowed(s);
}
static int dl_seq_show(struct seq_file *s, void *v)
--
2.1.1
^ permalink raw reply related [flat|nested] 18+ messages in thread
* Re: [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks
2014-10-29 21:56 ` [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks Steven Rostedt
@ 2014-10-29 22:16 ` Florian Westphal
2014-10-29 23:53 ` Steven Rostedt
2014-10-30 1:06 ` Steven Rostedt
2014-11-04 13:05 ` Steven Rostedt
1 sibling, 2 replies; 18+ messages in thread
From: Florian Westphal @ 2014-10-29 22:16 UTC (permalink / raw)
To: Steven Rostedt
Cc: linux-kernel, Ingo Molnar, Andrew Morton, Al Viro, Joe Perches,
Pablo Neira Ayuso, Patrick McHardy, Jozsef Kadlecsik,
netfilter-devel, coreteam
Steven Rostedt <rostedt@goodmis.org> wrote:
> From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
>
> [ REQUEST FOR ACKS ]
>
> The seq_printf() and friends are having their return values removed.
> The print_conntrack() returns the result of seq_printf(), which is
> meaningless when seq_printf() returns void. Might as well remove the
> return values of print_conntrack() as well.
[..]
> diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> index 4c48e434bb1f..91f207c2cb69 100644
> --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> @@ -147,7 +147,10 @@ static int ct_seq_show(struct seq_file *s, void *v)
> ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0)
> goto release;
>
> - if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct))
> + if (l4proto->print_conntrack)
> + l4proto->print_conntrack(s, ct);
> +
> + if (seq_has_overflowed(s))
> goto release;
Its not obvious to me why nf_conntrack_l3proto_ipv4_compat now calls
seq_has_overflowed ...
> > diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
> index cf65a1e040dd..348aa3602787 100644
> --- a/net/netfilter/nf_conntrack_standalone.c
> +++ b/net/netfilter/nf_conntrack_standalone.c
> @@ -199,8 +199,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
> ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0)
> goto release;
>
> - if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct))
> - goto release;
> + if (l4proto->print_conntrack)
> + l4proto->print_conntrack(s, ct);
>
> if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> l3proto, l4proto))
... while nf_conntrack_standalone does not.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks
2014-10-29 22:16 ` Florian Westphal
@ 2014-10-29 23:53 ` Steven Rostedt
2014-10-30 1:06 ` Steven Rostedt
1 sibling, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2014-10-29 23:53 UTC (permalink / raw)
To: Florian Westphal
Cc: linux-kernel, Ingo Molnar, Andrew Morton, Al Viro, Joe Perches,
Pablo Neira Ayuso, Patrick McHardy, Jozsef Kadlecsik,
netfilter-devel, coreteam
On Wed, 29 Oct 2014 23:16:01 +0100
Florian Westphal <fw@strlen.de> wrote:
> Steven Rostedt <rostedt@goodmis.org> wrote:
> > From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> >
> > [ REQUEST FOR ACKS ]
> >
> > The seq_printf() and friends are having their return values removed.
> > The print_conntrack() returns the result of seq_printf(), which is
> > meaningless when seq_printf() returns void. Might as well remove the
> > return values of print_conntrack() as well.
> [..]
>
> > diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> > index 4c48e434bb1f..91f207c2cb69 100644
> > --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> > +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> > @@ -147,7 +147,10 @@ static int ct_seq_show(struct seq_file *s, void *v)
> > ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0)
> > goto release;
> >
> > - if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct))
> > + if (l4proto->print_conntrack)
> > + l4proto->print_conntrack(s, ct);
> > +
> > + if (seq_has_overflowed(s))
> > goto release;
>
> Its not obvious to me why nf_conntrack_l3proto_ipv4_compat now calls
> seq_has_overflowed ...
>
> > > diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
> > index cf65a1e040dd..348aa3602787 100644
> > --- a/net/netfilter/nf_conntrack_standalone.c
> > +++ b/net/netfilter/nf_conntrack_standalone.c
> > @@ -199,8 +199,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
> > ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0)
> > goto release;
> >
> > - if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct))
> > - goto release;
> > + if (l4proto->print_conntrack)
> > + l4proto->print_conntrack(s, ct);
> >
> > if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> > l3proto, l4proto))
>
> ... while nf_conntrack_standalone does not.
Because I did those two changes separately at different times ;-)
I can add it here too to be consistent. The goto release logic is not
that critical, as it's really a micro optimization for a slow path.
If we were to remove all the goto release calls, what would happen is
if the buffer were to fill up, the rest of the code would be done in
vain, because it would do the work but the result will be thrown away.
The seq_file code would throw away the buffer completely (does this
regardless of the goto release call when the buffer fills up), and
would allocate a new buffer, and then run the code again. This time it
would hopefully have enough buffer space to hold the entire content,
otherwise, wash rinse repeat.
As this is to output text from a proc file, and the user will most
likely never notice this delay. It's probably done as more of a good
feeling that we didn't waste computer cycles and burn more green house
gasses than necessary, then anything that is remotely noticeable.
Although, I haven't run benchmarks to see what the difference is.
I'll make the change for consistency.
Thanks!
-- Steve
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks
2014-10-29 22:16 ` Florian Westphal
2014-10-29 23:53 ` Steven Rostedt
@ 2014-10-30 1:06 ` Steven Rostedt
1 sibling, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2014-10-30 1:06 UTC (permalink / raw)
To: Florian Westphal
Cc: linux-kernel, Ingo Molnar, Andrew Morton, Al Viro, Joe Perches,
Pablo Neira Ayuso, Patrick McHardy, Jozsef Kadlecsik,
netfilter-devel, coreteam
On Wed, 29 Oct 2014 23:16:01 +0100
Florian Westphal <fw@strlen.de> wrote:
> Steven Rostedt <rostedt@goodmis.org> wrote:
> > From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> >
> > [ REQUEST FOR ACKS ]
> >
> > The seq_printf() and friends are having their return values removed.
> > The print_conntrack() returns the result of seq_printf(), which is
> > meaningless when seq_printf() returns void. Might as well remove the
> > return values of print_conntrack() as well.
> [..]
>
> > diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> > index 4c48e434bb1f..91f207c2cb69 100644
> > --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> > +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> > @@ -147,7 +147,10 @@ static int ct_seq_show(struct seq_file *s, void *v)
> > ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0)
> > goto release;
> >
> > - if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct))
> > + if (l4proto->print_conntrack)
> > + l4proto->print_conntrack(s, ct);
> > +
> > + if (seq_has_overflowed(s))
> > goto release;
>
> Its not obvious to me why nf_conntrack_l3proto_ipv4_compat now calls
> seq_has_overflowed ...
>
> > > diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
> > index cf65a1e040dd..348aa3602787 100644
> > --- a/net/netfilter/nf_conntrack_standalone.c
> > +++ b/net/netfilter/nf_conntrack_standalone.c
> > @@ -199,8 +199,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
> > ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0)
> > goto release;
> >
> > - if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct))
> > - goto release;
> > + if (l4proto->print_conntrack)
> > + l4proto->print_conntrack(s, ct);
> >
> > if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> > l3proto, l4proto))
>
> ... while nf_conntrack_standalone does not.
Oh, looks like it was added here in patch 3/8.
The reason for the two patches is that patch 3/8 is from Joe. I added
places that he missed, and put that patch before his (2/8).
-- Steve
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks
2014-10-29 21:56 ` [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks Steven Rostedt
2014-10-29 22:16 ` Florian Westphal
@ 2014-11-04 13:05 ` Steven Rostedt
2014-11-04 14:11 ` Steven Rostedt
2014-11-04 14:22 ` Pablo Neira Ayuso
1 sibling, 2 replies; 18+ messages in thread
From: Steven Rostedt @ 2014-11-04 13:05 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Al Viro, Joe Perches,
Pablo Neira Ayuso, Patrick McHardy, Jozsef Kadlecsik,
netfilter-devel, coreteam
On Wed, 29 Oct 2014 17:56:04 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
>
> [ REQUEST FOR ACKS ]
Can any of the netfilter folks give me an Acked-by for this?
Thanks!
-- Steve
>
> The seq_printf() and friends are having their return values removed.
> The print_conntrack() returns the result of seq_printf(), which is
> meaningless when seq_printf() returns void. Might as well remove the
> return values of print_conntrack() as well.
>
> Cc: Pablo Neira Ayuso <pablo@netfilter.org>
> Cc: Patrick McHardy <kaber@trash.net>
> Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
> Cc: netfilter-devel@vger.kernel.org
> Cc: coreteam@netfilter.org
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
> include/net/netfilter/nf_conntrack_l4proto.h | 2 +-
> net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c | 5 ++++-
> net/netfilter/nf_conntrack_proto_dccp.c | 4 ++--
> net/netfilter/nf_conntrack_proto_gre.c | 8 ++++----
> net/netfilter/nf_conntrack_proto_sctp.c | 4 ++--
> net/netfilter/nf_conntrack_proto_tcp.c | 4 ++--
> net/netfilter/nf_conntrack_standalone.c | 4 ++--
> 7 files changed, 17 insertions(+), 14 deletions(-)
>
> diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h
> index 4c8d573830b7..82e4ec002a39 100644
> --- a/include/net/netfilter/nf_conntrack_l4proto.h
> +++ b/include/net/netfilter/nf_conntrack_l4proto.h
> @@ -60,7 +60,7 @@ struct nf_conntrack_l4proto {
> const struct nf_conntrack_tuple *);
>
> /* Print out the private part of the conntrack. */
> - int (*print_conntrack)(struct seq_file *s, struct nf_conn *);
> + void (*print_conntrack)(struct seq_file *s, struct nf_conn *);
>
> /* Return the array of timeouts for this protocol. */
> unsigned int *(*get_timeouts)(struct net *net);
> diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> index 4c48e434bb1f..91f207c2cb69 100644
> --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> @@ -147,7 +147,10 @@ static int ct_seq_show(struct seq_file *s, void *v)
> ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0)
> goto release;
>
> - if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct))
> + if (l4proto->print_conntrack)
> + l4proto->print_conntrack(s, ct);
> +
> + if (seq_has_overflowed(s))
> goto release;
>
> if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
> index cb372f96f10d..15971177470a 100644
> --- a/net/netfilter/nf_conntrack_proto_dccp.c
> +++ b/net/netfilter/nf_conntrack_proto_dccp.c
> @@ -626,9 +626,9 @@ static int dccp_print_tuple(struct seq_file *s,
> ntohs(tuple->dst.u.dccp.port));
> }
>
> -static int dccp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
> +static void dccp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
> {
> - return seq_printf(s, "%s ", dccp_state_names[ct->proto.dccp.state]);
> + seq_printf(s, "%s ", dccp_state_names[ct->proto.dccp.state]);
> }
>
> #if IS_ENABLED(CONFIG_NF_CT_NETLINK)
> diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c
> index d5665739e3b1..cba607ada069 100644
> --- a/net/netfilter/nf_conntrack_proto_gre.c
> +++ b/net/netfilter/nf_conntrack_proto_gre.c
> @@ -235,11 +235,11 @@ static int gre_print_tuple(struct seq_file *s,
> }
>
> /* print private data for conntrack */
> -static int gre_print_conntrack(struct seq_file *s, struct nf_conn *ct)
> +static void gre_print_conntrack(struct seq_file *s, struct nf_conn *ct)
> {
> - return seq_printf(s, "timeout=%u, stream_timeout=%u ",
> - (ct->proto.gre.timeout / HZ),
> - (ct->proto.gre.stream_timeout / HZ));
> + seq_printf(s, "timeout=%u, stream_timeout=%u ",
> + (ct->proto.gre.timeout / HZ),
> + (ct->proto.gre.stream_timeout / HZ));
> }
>
> static unsigned int *gre_get_timeouts(struct net *net)
> diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
> index 1314d33f6bcf..c61f4cd6407d 100644
> --- a/net/netfilter/nf_conntrack_proto_sctp.c
> +++ b/net/netfilter/nf_conntrack_proto_sctp.c
> @@ -175,7 +175,7 @@ static int sctp_print_tuple(struct seq_file *s,
> }
>
> /* Print out the private part of the conntrack. */
> -static int sctp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
> +static void sctp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
> {
> enum sctp_conntrack state;
>
> @@ -183,7 +183,7 @@ static int sctp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
> state = ct->proto.sctp.state;
> spin_unlock_bh(&ct->lock);
>
> - return seq_printf(s, "%s ", sctp_conntrack_names[state]);
> + seq_printf(s, "%s ", sctp_conntrack_names[state]);
> }
>
> #define for_each_sctp_chunk(skb, sch, _sch, offset, dataoff, count) \
> diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
> index 44d1ea32570a..79668fd3db96 100644
> --- a/net/netfilter/nf_conntrack_proto_tcp.c
> +++ b/net/netfilter/nf_conntrack_proto_tcp.c
> @@ -311,7 +311,7 @@ static int tcp_print_tuple(struct seq_file *s,
> }
>
> /* Print out the private part of the conntrack. */
> -static int tcp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
> +static void tcp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
> {
> enum tcp_conntrack state;
>
> @@ -319,7 +319,7 @@ static int tcp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
> state = ct->proto.tcp.state;
> spin_unlock_bh(&ct->lock);
>
> - return seq_printf(s, "%s ", tcp_conntrack_names[state]);
> + seq_printf(s, "%s ", tcp_conntrack_names[state]);
> }
>
> static unsigned int get_conntrack_index(const struct tcphdr *tcph)
> diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
> index cf65a1e040dd..348aa3602787 100644
> --- a/net/netfilter/nf_conntrack_standalone.c
> +++ b/net/netfilter/nf_conntrack_standalone.c
> @@ -199,8 +199,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
> ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0)
> goto release;
>
> - if (l4proto->print_conntrack && l4proto->print_conntrack(s, ct))
> - goto release;
> + if (l4proto->print_conntrack)
> + l4proto->print_conntrack(s, ct);
>
> if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> l3proto, l4proto))
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFA][PATCH 3/8] netfilter: Convert print_tuple functions to return void
2014-10-29 21:56 ` [RFA][PATCH 3/8] netfilter: Convert print_tuple functions to return void Steven Rostedt
@ 2014-11-04 13:07 ` Steven Rostedt
2014-11-04 14:50 ` Steven Rostedt
1 sibling, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2014-11-04 13:07 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Al Viro, Joe Perches,
Pablo Neira Ayuso, Patrick McHardy, Jozsef Kadlecsik,
netfilter-devel, coreteam
On Wed, 29 Oct 2014 17:56:05 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> From: Joe Perches <joe@perches.com>
>
> [ REQUEST FOR ACKS ]
Can any of the netfilter maintainers give me an Acked-by for this?
Thanks!
-- Steve
>
> Since adding a new function to seq_file (seq_has_overflowed())
> there isn't any value for functions called from seq_show to
> return anything. Remove the int returns of the various
> print_tuple/<foo>_print_tuple functions.
>
> Link: http://lkml.kernel.org/p/f2e8cf8df433a197daa62cbaf124c900c708edc7.1412031505.git.joe@perches.com
>
> Cc: Pablo Neira Ayuso <pablo@netfilter.org>
> Cc: Patrick McHardy <kaber@trash.net>
> Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
> Cc: netfilter-devel@vger.kernel.org
> Cc: coreteam@netfilter.org
> Signed-off-by: Joe Perches <joe@perches.com>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
> include/net/netfilter/nf_conntrack_core.h | 2 +-
> include/net/netfilter/nf_conntrack_l3proto.h | 4 ++--
> include/net/netfilter/nf_conntrack_l4proto.h | 4 ++--
> net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 6 +++---
> net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c | 12 ++++++++----
> net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 10 +++++-----
> net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 6 +++---
> net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 10 +++++-----
> net/netfilter/nf_conntrack_l3proto_generic.c | 5 ++---
> net/netfilter/nf_conntrack_proto_dccp.c | 10 +++++-----
> net/netfilter/nf_conntrack_proto_generic.c | 5 ++---
> net/netfilter/nf_conntrack_proto_gre.c | 10 +++++-----
> net/netfilter/nf_conntrack_proto_sctp.c | 10 +++++-----
> net/netfilter/nf_conntrack_proto_tcp.c | 10 +++++-----
> net/netfilter/nf_conntrack_proto_udp.c | 10 +++++-----
> net/netfilter/nf_conntrack_proto_udplite.c | 10 +++++-----
> net/netfilter/nf_conntrack_standalone.c | 15 +++++++--------
> 17 files changed, 70 insertions(+), 69 deletions(-)
>
> diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h
> index cc0c18827602..f2f0fa3bb150 100644
> --- a/include/net/netfilter/nf_conntrack_core.h
> +++ b/include/net/netfilter/nf_conntrack_core.h
> @@ -72,7 +72,7 @@ static inline int nf_conntrack_confirm(struct sk_buff *skb)
> return ret;
> }
>
> -int
> +void
> print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
> const struct nf_conntrack_l3proto *l3proto,
> const struct nf_conntrack_l4proto *proto);
> diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h
> index adc1fa3dd7ab..cdc920b4c4c2 100644
> --- a/include/net/netfilter/nf_conntrack_l3proto.h
> +++ b/include/net/netfilter/nf_conntrack_l3proto.h
> @@ -38,8 +38,8 @@ struct nf_conntrack_l3proto {
> const struct nf_conntrack_tuple *orig);
>
> /* Print out the per-protocol part of the tuple. */
> - int (*print_tuple)(struct seq_file *s,
> - const struct nf_conntrack_tuple *);
> + void (*print_tuple)(struct seq_file *s,
> + const struct nf_conntrack_tuple *);
>
> /*
> * Called before tracking.
> diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h
> index 82e4ec002a39..1f7061313d54 100644
> --- a/include/net/netfilter/nf_conntrack_l4proto.h
> +++ b/include/net/netfilter/nf_conntrack_l4proto.h
> @@ -56,8 +56,8 @@ struct nf_conntrack_l4proto {
> u_int8_t pf, unsigned int hooknum);
>
> /* Print out the per-protocol part of the tuple. Return like seq_* */
> - int (*print_tuple)(struct seq_file *s,
> - const struct nf_conntrack_tuple *);
> + void (*print_tuple)(struct seq_file *s,
> + const struct nf_conntrack_tuple *);
>
> /* Print out the private part of the conntrack. */
> void (*print_conntrack)(struct seq_file *s, struct nf_conn *);
> diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
> index a054fe083431..5c61328b7704 100644
> --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
> +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
> @@ -56,11 +56,11 @@ static bool ipv4_invert_tuple(struct nf_conntrack_tuple *tuple,
> return true;
> }
>
> -static int ipv4_print_tuple(struct seq_file *s,
> +static void ipv4_print_tuple(struct seq_file *s,
> const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "src=%pI4 dst=%pI4 ",
> - &tuple->src.u3.ip, &tuple->dst.u3.ip);
> + seq_printf(s, "src=%pI4 dst=%pI4 ",
> + &tuple->src.u3.ip, &tuple->dst.u3.ip);
> }
>
> static int ipv4_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
> diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> index 91f207c2cb69..d927f9e72130 100644
> --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> @@ -153,8 +153,10 @@ static int ct_seq_show(struct seq_file *s, void *v)
> if (seq_has_overflowed(s))
> goto release;
>
> - if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> - l3proto, l4proto))
> + print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> + l3proto, l4proto);
> +
> + if (seq_has_overflowed(s))
> goto release;
>
> if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL))
> @@ -164,8 +166,10 @@ static int ct_seq_show(struct seq_file *s, void *v)
> if (seq_printf(s, "[UNREPLIED] "))
> goto release;
>
> - if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
> - l3proto, l4proto))
> + print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
> + l3proto, l4proto);
> +
> + if (seq_has_overflowed(s))
> goto release;
>
> if (seq_print_acct(s, ct, IP_CT_DIR_REPLY))
> diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
> index b91b2641adda..80d5554b9a88 100644
> --- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
> +++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
> @@ -72,13 +72,13 @@ static bool icmp_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int icmp_print_tuple(struct seq_file *s,
> +static void icmp_print_tuple(struct seq_file *s,
> const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "type=%u code=%u id=%u ",
> - tuple->dst.u.icmp.type,
> - tuple->dst.u.icmp.code,
> - ntohs(tuple->src.u.icmp.id));
> + seq_printf(s, "type=%u code=%u id=%u ",
> + tuple->dst.u.icmp.type,
> + tuple->dst.u.icmp.code,
> + ntohs(tuple->src.u.icmp.id));
> }
>
> static unsigned int *icmp_get_timeouts(struct net *net)
> diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
> index 4cbc6b290dd5..b68d0e59c1f8 100644
> --- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
> +++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
> @@ -60,11 +60,11 @@ static bool ipv6_invert_tuple(struct nf_conntrack_tuple *tuple,
> return true;
> }
>
> -static int ipv6_print_tuple(struct seq_file *s,
> +static void ipv6_print_tuple(struct seq_file *s,
> const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "src=%pI6 dst=%pI6 ",
> - tuple->src.u3.ip6, tuple->dst.u3.ip6);
> + seq_printf(s, "src=%pI6 dst=%pI6 ",
> + tuple->src.u3.ip6, tuple->dst.u3.ip6);
> }
>
> static int ipv6_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
> diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
> index b3807c5cb888..90388d606483 100644
> --- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
> +++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
> @@ -84,13 +84,13 @@ static bool icmpv6_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int icmpv6_print_tuple(struct seq_file *s,
> +static void icmpv6_print_tuple(struct seq_file *s,
> const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "type=%u code=%u id=%u ",
> - tuple->dst.u.icmp.type,
> - tuple->dst.u.icmp.code,
> - ntohs(tuple->src.u.icmp.id));
> + seq_printf(s, "type=%u code=%u id=%u ",
> + tuple->dst.u.icmp.type,
> + tuple->dst.u.icmp.code,
> + ntohs(tuple->src.u.icmp.id));
> }
>
> static unsigned int *icmpv6_get_timeouts(struct net *net)
> diff --git a/net/netfilter/nf_conntrack_l3proto_generic.c b/net/netfilter/nf_conntrack_l3proto_generic.c
> index e7eb807fe07d..cf9ace70bece 100644
> --- a/net/netfilter/nf_conntrack_l3proto_generic.c
> +++ b/net/netfilter/nf_conntrack_l3proto_generic.c
> @@ -49,10 +49,9 @@ static bool generic_invert_tuple(struct nf_conntrack_tuple *tuple,
> return true;
> }
>
> -static int generic_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void generic_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return 0;
> }
>
> static int generic_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
> diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
> index 15971177470a..6dd995c7c72b 100644
> --- a/net/netfilter/nf_conntrack_proto_dccp.c
> +++ b/net/netfilter/nf_conntrack_proto_dccp.c
> @@ -618,12 +618,12 @@ out_invalid:
> return -NF_ACCEPT;
> }
>
> -static int dccp_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void dccp_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "sport=%hu dport=%hu ",
> - ntohs(tuple->src.u.dccp.port),
> - ntohs(tuple->dst.u.dccp.port));
> + seq_printf(s, "sport=%hu dport=%hu ",
> + ntohs(tuple->src.u.dccp.port),
> + ntohs(tuple->dst.u.dccp.port));
> }
>
> static void dccp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
> diff --git a/net/netfilter/nf_conntrack_proto_generic.c b/net/netfilter/nf_conntrack_proto_generic.c
> index 957c1db66652..60865f110309 100644
> --- a/net/netfilter/nf_conntrack_proto_generic.c
> +++ b/net/netfilter/nf_conntrack_proto_generic.c
> @@ -63,10 +63,9 @@ static bool generic_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int generic_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void generic_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return 0;
> }
>
> static unsigned int *generic_get_timeouts(struct net *net)
> diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c
> index cba607ada069..7648674f29c3 100644
> --- a/net/netfilter/nf_conntrack_proto_gre.c
> +++ b/net/netfilter/nf_conntrack_proto_gre.c
> @@ -226,12 +226,12 @@ static bool gre_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,
> }
>
> /* print gre part of tuple */
> -static int gre_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void gre_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "srckey=0x%x dstkey=0x%x ",
> - ntohs(tuple->src.u.gre.key),
> - ntohs(tuple->dst.u.gre.key));
> + seq_printf(s, "srckey=0x%x dstkey=0x%x ",
> + ntohs(tuple->src.u.gre.key),
> + ntohs(tuple->dst.u.gre.key));
> }
>
> /* print private data for conntrack */
> diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
> index c61f4cd6407d..b45da90fad32 100644
> --- a/net/netfilter/nf_conntrack_proto_sctp.c
> +++ b/net/netfilter/nf_conntrack_proto_sctp.c
> @@ -166,12 +166,12 @@ static bool sctp_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int sctp_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void sctp_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "sport=%hu dport=%hu ",
> - ntohs(tuple->src.u.sctp.port),
> - ntohs(tuple->dst.u.sctp.port));
> + seq_printf(s, "sport=%hu dport=%hu ",
> + ntohs(tuple->src.u.sctp.port),
> + ntohs(tuple->dst.u.sctp.port));
> }
>
> /* Print out the private part of the conntrack. */
> diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
> index 79668fd3db96..36a3ac8ee9f5 100644
> --- a/net/netfilter/nf_conntrack_proto_tcp.c
> +++ b/net/netfilter/nf_conntrack_proto_tcp.c
> @@ -302,12 +302,12 @@ static bool tcp_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int tcp_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void tcp_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "sport=%hu dport=%hu ",
> - ntohs(tuple->src.u.tcp.port),
> - ntohs(tuple->dst.u.tcp.port));
> + seq_printf(s, "sport=%hu dport=%hu ",
> + ntohs(tuple->src.u.tcp.port),
> + ntohs(tuple->dst.u.tcp.port));
> }
>
> /* Print out the private part of the conntrack. */
> diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c
> index 9d7721cbce4b..6957281ffee5 100644
> --- a/net/netfilter/nf_conntrack_proto_udp.c
> +++ b/net/netfilter/nf_conntrack_proto_udp.c
> @@ -63,12 +63,12 @@ static bool udp_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int udp_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void udp_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "sport=%hu dport=%hu ",
> - ntohs(tuple->src.u.udp.port),
> - ntohs(tuple->dst.u.udp.port));
> + seq_printf(s, "sport=%hu dport=%hu ",
> + ntohs(tuple->src.u.udp.port),
> + ntohs(tuple->dst.u.udp.port));
> }
>
> static unsigned int *udp_get_timeouts(struct net *net)
> diff --git a/net/netfilter/nf_conntrack_proto_udplite.c b/net/netfilter/nf_conntrack_proto_udplite.c
> index 2750e6c69f82..c5903d1649f9 100644
> --- a/net/netfilter/nf_conntrack_proto_udplite.c
> +++ b/net/netfilter/nf_conntrack_proto_udplite.c
> @@ -71,12 +71,12 @@ static bool udplite_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int udplite_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void udplite_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "sport=%hu dport=%hu ",
> - ntohs(tuple->src.u.udp.port),
> - ntohs(tuple->dst.u.udp.port));
> + seq_printf(s, "sport=%hu dport=%hu ",
> + ntohs(tuple->src.u.udp.port),
> + ntohs(tuple->dst.u.udp.port));
> }
>
> static unsigned int *udplite_get_timeouts(struct net *net)
> diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
> index 348aa3602787..23a0dcab21d4 100644
> --- a/net/netfilter/nf_conntrack_standalone.c
> +++ b/net/netfilter/nf_conntrack_standalone.c
> @@ -36,12 +36,13 @@
> MODULE_LICENSE("GPL");
>
> #ifdef CONFIG_NF_CONNTRACK_PROCFS
> -int
> +void
> print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
> const struct nf_conntrack_l3proto *l3proto,
> const struct nf_conntrack_l4proto *l4proto)
> {
> - return l3proto->print_tuple(s, tuple) || l4proto->print_tuple(s, tuple);
> + l3proto->print_tuple(s, tuple);
> + l4proto->print_tuple(s, tuple);
> }
> EXPORT_SYMBOL_GPL(print_tuple);
>
> @@ -202,9 +203,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
> if (l4proto->print_conntrack)
> l4proto->print_conntrack(s, ct);
>
> - if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> - l3proto, l4proto))
> - goto release;
> + print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> + l3proto, l4proto);
>
> if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL))
> goto release;
> @@ -213,9 +213,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
> if (seq_printf(s, "[UNREPLIED] "))
> goto release;
>
> - if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
> - l3proto, l4proto))
> - goto release;
> + print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
> + l3proto, l4proto);
>
> if (seq_print_acct(s, ct, IP_CT_DIR_REPLY))
> goto release;
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFA][PATCH 4/8] netfilter: Remove checks of seq_printf() return values
2014-10-29 21:56 ` [RFA][PATCH 4/8] netfilter: Remove checks of seq_printf() return values Steven Rostedt
@ 2014-11-04 13:08 ` Steven Rostedt
0 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2014-11-04 13:08 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Al Viro, Joe Perches,
Pablo Neira Ayuso, Patrick McHardy, Jozsef Kadlecsik,
netfilter-devel, coreteam
On Wed, 29 Oct 2014 17:56:06 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
>
> [ REQUEST FOR ACKS ]
Can any of the netfilter maintainers give me an Acked-by for this?
Thanks!
-- Steve
>
> The return value of seq_printf() is soon to be removed. Remove the
> checks from seq_printf() in favor of seq_has_overflowed().
>
> Cc: Pablo Neira Ayuso <pablo@netfilter.org>
> Cc: Patrick McHardy <kaber@trash.net>
> Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
> Cc: netfilter-devel@vger.kernel.org
> Cc: coreteam@netfilter.org
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
> .../netfilter/nf_conntrack_l3proto_ipv4_compat.c | 36 ++++++-------
> net/netfilter/nf_conntrack_standalone.c | 60 +++++++++++-----------
> net/netfilter/nf_log.c | 30 ++++++-----
> net/netfilter/nfnetlink_queue_core.c | 13 ++---
> net/netfilter/x_tables.c | 19 ++++---
> net/netfilter/xt_hashlimit.c | 36 ++++++-------
> 6 files changed, 97 insertions(+), 97 deletions(-)
>
> diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> index d927f9e72130..a460a87e14f8 100644
> --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> @@ -94,7 +94,7 @@ static void ct_seq_stop(struct seq_file *s, void *v)
> }
>
> #ifdef CONFIG_NF_CONNTRACK_SECMARK
> -static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
> +static void ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
> {
> int ret;
> u32 len;
> @@ -102,17 +102,15 @@ static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
>
> ret = security_secid_to_secctx(ct->secmark, &secctx, &len);
> if (ret)
> - return 0;
> + return;
>
> - ret = seq_printf(s, "secctx=%s ", secctx);
> + seq_printf(s, "secctx=%s ", secctx);
>
> security_release_secctx(secctx, len);
> - return ret;
> }
> #else
> -static inline int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
> +static inline void ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
> {
> - return 0;
> }
> #endif
>
> @@ -141,11 +139,10 @@ static int ct_seq_show(struct seq_file *s, void *v)
> NF_CT_ASSERT(l4proto);
>
> ret = -ENOSPC;
> - if (seq_printf(s, "%-8s %u %ld ",
> - l4proto->name, nf_ct_protonum(ct),
> - timer_pending(&ct->timeout)
> - ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0)
> - goto release;
> + seq_printf(s, "%-8s %u %ld ",
> + l4proto->name, nf_ct_protonum(ct),
> + timer_pending(&ct->timeout)
> + ? (long)(ct->timeout.expires - jiffies)/HZ : 0);
>
> if (l4proto->print_conntrack)
> l4proto->print_conntrack(s, ct);
> @@ -163,8 +160,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
> goto release;
>
> if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status)))
> - if (seq_printf(s, "[UNREPLIED] "))
> - goto release;
> + seq_printf(s, "[UNREPLIED] ");
>
> print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
> l3proto, l4proto);
> @@ -176,19 +172,19 @@ static int ct_seq_show(struct seq_file *s, void *v)
> goto release;
>
> if (test_bit(IPS_ASSURED_BIT, &ct->status))
> - if (seq_printf(s, "[ASSURED] "))
> - goto release;
> + seq_printf(s, "[ASSURED] ");
>
> #ifdef CONFIG_NF_CONNTRACK_MARK
> - if (seq_printf(s, "mark=%u ", ct->mark))
> - goto release;
> + seq_printf(s, "mark=%u ", ct->mark);
> #endif
>
> - if (ct_show_secctx(s, ct))
> - goto release;
> + ct_show_secctx(s, ct);
> +
> + seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use));
>
> - if (seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use)))
> + if (seq_has_overflowed(s))
> goto release;
> +
> ret = 0;
> release:
> nf_ct_put(ct);
> diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
> index 23a0dcab21d4..fc823fa5dcf5 100644
> --- a/net/netfilter/nf_conntrack_standalone.c
> +++ b/net/netfilter/nf_conntrack_standalone.c
> @@ -120,7 +120,7 @@ static void ct_seq_stop(struct seq_file *s, void *v)
> }
>
> #ifdef CONFIG_NF_CONNTRACK_SECMARK
> -static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
> +static void ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
> {
> int ret;
> u32 len;
> @@ -128,22 +128,20 @@ static int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
>
> ret = security_secid_to_secctx(ct->secmark, &secctx, &len);
> if (ret)
> - return 0;
> + return;
>
> - ret = seq_printf(s, "secctx=%s ", secctx);
> + seq_printf(s, "secctx=%s ", secctx);
>
> security_release_secctx(secctx, len);
> - return ret;
> }
> #else
> -static inline int ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
> +static inline void ct_show_secctx(struct seq_file *s, const struct nf_conn *ct)
> {
> - return 0;
> }
> #endif
>
> #ifdef CONFIG_NF_CONNTRACK_TIMESTAMP
> -static int ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)
> +static void ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)
> {
> struct ct_iter_state *st = s->private;
> struct nf_conn_tstamp *tstamp;
> @@ -157,16 +155,15 @@ static int ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)
> else
> delta_time = 0;
>
> - return seq_printf(s, "delta-time=%llu ",
> - (unsigned long long)delta_time);
> + seq_printf(s, "delta-time=%llu ",
> + (unsigned long long)delta_time);
> }
> - return 0;
> + return;
> }
> #else
> -static inline int
> +static inline void
> ct_show_delta_time(struct seq_file *s, const struct nf_conn *ct)
> {
> - return 0;
> }
> #endif
>
> @@ -193,12 +190,11 @@ static int ct_seq_show(struct seq_file *s, void *v)
> NF_CT_ASSERT(l4proto);
>
> ret = -ENOSPC;
> - if (seq_printf(s, "%-8s %u %-8s %u %ld ",
> - l3proto->name, nf_ct_l3num(ct),
> - l4proto->name, nf_ct_protonum(ct),
> - timer_pending(&ct->timeout)
> - ? (long)(ct->timeout.expires - jiffies)/HZ : 0) != 0)
> - goto release;
> + seq_printf(s, "%-8s %u %-8s %u %ld ",
> + l3proto->name, nf_ct_l3num(ct),
> + l4proto->name, nf_ct_protonum(ct),
> + timer_pending(&ct->timeout)
> + ? (long)(ct->timeout.expires - jiffies)/HZ : 0);
>
> if (l4proto->print_conntrack)
> l4proto->print_conntrack(s, ct);
> @@ -206,12 +202,14 @@ static int ct_seq_show(struct seq_file *s, void *v)
> print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> l3proto, l4proto);
>
> + if (seq_has_overflowed(s))
> + goto release;
> +
> if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL))
> goto release;
>
> if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status)))
> - if (seq_printf(s, "[UNREPLIED] "))
> - goto release;
> + seq_printf(s, "[UNREPLIED] ");
>
> print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
> l3proto, l4proto);
> @@ -220,26 +218,26 @@ static int ct_seq_show(struct seq_file *s, void *v)
> goto release;
>
> if (test_bit(IPS_ASSURED_BIT, &ct->status))
> - if (seq_printf(s, "[ASSURED] "))
> - goto release;
> + seq_printf(s, "[ASSURED] ");
>
> -#if defined(CONFIG_NF_CONNTRACK_MARK)
> - if (seq_printf(s, "mark=%u ", ct->mark))
> + if (seq_has_overflowed(s))
> goto release;
> +
> +#if defined(CONFIG_NF_CONNTRACK_MARK)
> + seq_printf(s, "mark=%u ", ct->mark);
> #endif
>
> - if (ct_show_secctx(s, ct))
> - goto release;
> + ct_show_secctx(s, ct);
>
> #ifdef CONFIG_NF_CONNTRACK_ZONES
> - if (seq_printf(s, "zone=%u ", nf_ct_zone(ct)))
> - goto release;
> + seq_printf(s, "zone=%u ", nf_ct_zone(ct));
> #endif
>
> - if (ct_show_delta_time(s, ct))
> - goto release;
> + ct_show_delta_time(s, ct);
> +
> + seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use));
>
> - if (seq_printf(s, "use=%u\n", atomic_read(&ct->ct_general.use)))
> + if (seq_has_overflowed(s))
> goto release;
>
> ret = 0;
> diff --git a/net/netfilter/nf_log.c b/net/netfilter/nf_log.c
> index d7197649dba6..6e3b9117db1f 100644
> --- a/net/netfilter/nf_log.c
> +++ b/net/netfilter/nf_log.c
> @@ -294,19 +294,19 @@ static int seq_show(struct seq_file *s, void *v)
> {
> loff_t *pos = v;
> const struct nf_logger *logger;
> - int i, ret;
> + int i;
> struct net *net = seq_file_net(s);
>
> logger = rcu_dereference_protected(net->nf.nf_loggers[*pos],
> lockdep_is_held(&nf_log_mutex));
>
> if (!logger)
> - ret = seq_printf(s, "%2lld NONE (", *pos);
> + seq_printf(s, "%2lld NONE (", *pos);
> else
> - ret = seq_printf(s, "%2lld %s (", *pos, logger->name);
> + seq_printf(s, "%2lld %s (", *pos, logger->name);
>
> - if (ret < 0)
> - return ret;
> + if (seq_has_overflowed(s))
> + return -ENOSPC;
>
> for (i = 0; i < NF_LOG_TYPE_MAX; i++) {
> if (loggers[*pos][i] == NULL)
> @@ -314,17 +314,19 @@ static int seq_show(struct seq_file *s, void *v)
>
> logger = rcu_dereference_protected(loggers[*pos][i],
> lockdep_is_held(&nf_log_mutex));
> - ret = seq_printf(s, "%s", logger->name);
> - if (ret < 0)
> - return ret;
> - if (i == 0 && loggers[*pos][i + 1] != NULL) {
> - ret = seq_printf(s, ",");
> - if (ret < 0)
> - return ret;
> - }
> + seq_printf(s, "%s", logger->name);
> + if (i == 0 && loggers[*pos][i + 1] != NULL)
> + seq_printf(s, ",");
> +
> + if (seq_has_overflowed(s))
> + return -ENOSPC;
> }
>
> - return seq_printf(s, ")\n");
> + seq_printf(s, ")\n");
> +
> + if (seq_has_overflowed(s))
> + return -ENOSPC;
> + return 0;
> }
>
> static const struct seq_operations nflog_seq_ops = {
> diff --git a/net/netfilter/nfnetlink_queue_core.c b/net/netfilter/nfnetlink_queue_core.c
> index a82077d9f59b..f823f1538c4f 100644
> --- a/net/netfilter/nfnetlink_queue_core.c
> +++ b/net/netfilter/nfnetlink_queue_core.c
> @@ -1242,12 +1242,13 @@ static int seq_show(struct seq_file *s, void *v)
> {
> const struct nfqnl_instance *inst = v;
>
> - return seq_printf(s, "%5d %6d %5d %1d %5d %5d %5d %8d %2d\n",
> - inst->queue_num,
> - inst->peer_portid, inst->queue_total,
> - inst->copy_mode, inst->copy_range,
> - inst->queue_dropped, inst->queue_user_dropped,
> - inst->id_sequence, 1);
> + seq_printf(s, "%5d %6d %5d %1d %5d %5d %5d %8d %2d\n",
> + inst->queue_num,
> + inst->peer_portid, inst->queue_total,
> + inst->copy_mode, inst->copy_range,
> + inst->queue_dropped, inst->queue_user_dropped,
> + inst->id_sequence, 1);
> + return seq_has_overflowed(s);
> }
>
> static const struct seq_operations nfqnl_seq_ops = {
> diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c
> index 133eb4772f12..51a459c3c649 100644
> --- a/net/netfilter/x_tables.c
> +++ b/net/netfilter/x_tables.c
> @@ -947,9 +947,10 @@ static int xt_table_seq_show(struct seq_file *seq, void *v)
> {
> struct xt_table *table = list_entry(v, struct xt_table, list);
>
> - if (strlen(table->name))
> - return seq_printf(seq, "%s\n", table->name);
> - else
> + if (strlen(table->name)) {
> + seq_printf(seq, "%s\n", table->name);
> + return seq_has_overflowed(seq);
> + } else
> return 0;
> }
>
> @@ -1086,8 +1087,10 @@ static int xt_match_seq_show(struct seq_file *seq, void *v)
> if (trav->curr == trav->head)
> return 0;
> match = list_entry(trav->curr, struct xt_match, list);
> - return (*match->name == '\0') ? 0 :
> - seq_printf(seq, "%s\n", match->name);
> + if (*match->name == '\0')
> + return 0;
> + seq_printf(seq, "%s\n", match->name);
> + return seq_has_overflowed(seq);
> }
> return 0;
> }
> @@ -1139,8 +1142,10 @@ static int xt_target_seq_show(struct seq_file *seq, void *v)
> if (trav->curr == trav->head)
> return 0;
> target = list_entry(trav->curr, struct xt_target, list);
> - return (*target->name == '\0') ? 0 :
> - seq_printf(seq, "%s\n", target->name);
> + if (*target->name == '\0')
> + return 0;
> + seq_printf(seq, "%s\n", target->name);
> + return seq_has_overflowed(seq);
> }
> return 0;
> }
> diff --git a/net/netfilter/xt_hashlimit.c b/net/netfilter/xt_hashlimit.c
> index 05fbc2a0be46..178696852bde 100644
> --- a/net/netfilter/xt_hashlimit.c
> +++ b/net/netfilter/xt_hashlimit.c
> @@ -789,7 +789,6 @@ static void dl_seq_stop(struct seq_file *s, void *v)
> static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family,
> struct seq_file *s)
> {
> - int res;
> const struct xt_hashlimit_htable *ht = s->private;
>
> spin_lock(&ent->lock);
> @@ -798,33 +797,32 @@ static int dl_seq_real_show(struct dsthash_ent *ent, u_int8_t family,
>
> switch (family) {
> case NFPROTO_IPV4:
> - res = seq_printf(s, "%ld %pI4:%u->%pI4:%u %u %u %u\n",
> - (long)(ent->expires - jiffies)/HZ,
> - &ent->dst.ip.src,
> - ntohs(ent->dst.src_port),
> - &ent->dst.ip.dst,
> - ntohs(ent->dst.dst_port),
> - ent->rateinfo.credit, ent->rateinfo.credit_cap,
> - ent->rateinfo.cost);
> + seq_printf(s, "%ld %pI4:%u->%pI4:%u %u %u %u\n",
> + (long)(ent->expires - jiffies)/HZ,
> + &ent->dst.ip.src,
> + ntohs(ent->dst.src_port),
> + &ent->dst.ip.dst,
> + ntohs(ent->dst.dst_port),
> + ent->rateinfo.credit, ent->rateinfo.credit_cap,
> + ent->rateinfo.cost);
> break;
> #if IS_ENABLED(CONFIG_IP6_NF_IPTABLES)
> case NFPROTO_IPV6:
> - res = seq_printf(s, "%ld %pI6:%u->%pI6:%u %u %u %u\n",
> - (long)(ent->expires - jiffies)/HZ,
> - &ent->dst.ip6.src,
> - ntohs(ent->dst.src_port),
> - &ent->dst.ip6.dst,
> - ntohs(ent->dst.dst_port),
> - ent->rateinfo.credit, ent->rateinfo.credit_cap,
> - ent->rateinfo.cost);
> + seq_printf(s, "%ld %pI6:%u->%pI6:%u %u %u %u\n",
> + (long)(ent->expires - jiffies)/HZ,
> + &ent->dst.ip6.src,
> + ntohs(ent->dst.src_port),
> + &ent->dst.ip6.dst,
> + ntohs(ent->dst.dst_port),
> + ent->rateinfo.credit, ent->rateinfo.credit_cap,
> + ent->rateinfo.cost);
> break;
> #endif
> default:
> BUG();
> - res = 0;
> }
> spin_unlock(&ent->lock);
> - return res;
> + return seq_has_overflowed(s);
> }
>
> static int dl_seq_show(struct seq_file *s, void *v)
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks
2014-11-04 13:05 ` Steven Rostedt
@ 2014-11-04 14:11 ` Steven Rostedt
2014-11-04 14:22 ` Pablo Neira Ayuso
1 sibling, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2014-11-04 14:11 UTC (permalink / raw)
To: linux-kernel
Cc: Ingo Molnar, Andrew Morton, Al Viro, Joe Perches,
Pablo Neira Ayuso, Patrick McHardy, Jozsef Kadlecsik,
netfilter-devel, coreteam
On Tue, 4 Nov 2014 08:05:35 -0500
Steven Rostedt <rostedt@goodmis.org> wrote:
> On Wed, 29 Oct 2014 17:56:04 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
>
> > From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> >
> > [ REQUEST FOR ACKS ]
>
> Can any of the netfilter folks give me an Acked-by for this?
>
I hope nobody expects Jozsef Kadlecsik to do this, as I'm getting "Mail
Delivery Failures" from him with this message:
>>> kadlec@blackhole.kfki.hu (after RCPT TO): 550 5.7.1 <kadlec@blackhole.kfki.hu>: Recipient address rejected: Access denied. Your site is banned because of the unsolicited mail messages received from it.
Wow, seems they are banning all Time Warner Cable customers in my area!
-- Steve
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks
2014-11-04 13:05 ` Steven Rostedt
2014-11-04 14:11 ` Steven Rostedt
@ 2014-11-04 14:22 ` Pablo Neira Ayuso
2014-11-04 14:31 ` Steven Rostedt
1 sibling, 1 reply; 18+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-04 14:22 UTC (permalink / raw)
To: Steven Rostedt
Cc: linux-kernel, Ingo Molnar, Andrew Morton, Al Viro, Joe Perches,
Patrick McHardy, Jozsef Kadlecsik, netfilter-devel, coreteam
On Tue, Nov 04, 2014 at 08:05:35AM -0500, Steven Rostedt wrote:
> On Wed, 29 Oct 2014 17:56:04 -0400
> Steven Rostedt <rostedt@goodmis.org> wrote:
>
> > From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> >
> > [ REQUEST FOR ACKS ]
>
> Can any of the netfilter folks give me an Acked-by for this?
If Florian's concern were addressed, then:
Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
to this patch and 4/8.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks
2014-11-04 14:22 ` Pablo Neira Ayuso
@ 2014-11-04 14:31 ` Steven Rostedt
2014-11-04 14:46 ` Joe Perches
2014-11-04 14:46 ` Pablo Neira Ayuso
0 siblings, 2 replies; 18+ messages in thread
From: Steven Rostedt @ 2014-11-04 14:31 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: linux-kernel, Ingo Molnar, Andrew Morton, Al Viro, Joe Perches,
Patrick McHardy, Jozsef Kadlecsik, netfilter-devel, coreteam
On Tue, 4 Nov 2014 15:22:36 +0100
Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> On Tue, Nov 04, 2014 at 08:05:35AM -0500, Steven Rostedt wrote:
> > On Wed, 29 Oct 2014 17:56:04 -0400
> > Steven Rostedt <rostedt@goodmis.org> wrote:
> >
> > > From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> > >
> > > [ REQUEST FOR ACKS ]
> >
> > Can any of the netfilter folks give me an Acked-by for this?
>
> If Florian's concern were addressed, then:
Yeah, the change he mentioned was done is 3/8. As that was written by
Joe Perches, I did some work that he missed and put it before his
patch, which showed a discrepancy between the two functions. After all
patches are applied, it should be consistent to his liking.
>
> Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
>
> to this patch and 4/8.
Thanks for this!
Can I get someone to ack 3/8?
Thanks again,
-- Steve
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks
2014-11-04 14:31 ` Steven Rostedt
@ 2014-11-04 14:46 ` Joe Perches
2014-11-04 14:52 ` Steven Rostedt
2014-11-04 14:46 ` Pablo Neira Ayuso
1 sibling, 1 reply; 18+ messages in thread
From: Joe Perches @ 2014-11-04 14:46 UTC (permalink / raw)
To: Steven Rostedt
Cc: Pablo Neira Ayuso, linux-kernel, Ingo Molnar, Andrew Morton,
Al Viro, Patrick McHardy, Jozsef Kadlecsik, netfilter-devel,
coreteam
On Tue, 2014-11-04 at 09:31 -0500, Steven Rostedt wrote:
> On Tue, 4 Nov 2014 15:22:36 +0100
> Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > On Tue, Nov 04, 2014 at 08:05:35AM -0500, Steven Rostedt wrote:
> > > On Wed, 29 Oct 2014 17:56:04 -0400 Steven Rostedt <rostedt@goodmis.org> wrote:
> > > > From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> > > > [ REQUEST FOR ACKS ]
> > > Can any of the netfilter folks give me an Acked-by for this?
> > If Florian's concern were addressed, then:
> Yeah, the change he mentioned was done is 3/8. As that was written by
> Joe Perches, I did some work that he missed and put it before his
> patch, which showed a discrepancy between the two functions. After all
> patches are applied, it should be consistent to his liking.
I think seq_has_overflowed does not need
to be used after every seq_<put/print> call.
It interrupts reading code flow and just
isn't alll that necessary as every operation
before it will be redone anyway.
It should be used before or after a large
blocks though.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks
2014-11-04 14:31 ` Steven Rostedt
2014-11-04 14:46 ` Joe Perches
@ 2014-11-04 14:46 ` Pablo Neira Ayuso
2014-11-04 14:48 ` Steven Rostedt
2014-11-04 19:59 ` Steven Rostedt
1 sibling, 2 replies; 18+ messages in thread
From: Pablo Neira Ayuso @ 2014-11-04 14:46 UTC (permalink / raw)
To: Steven Rostedt
Cc: linux-kernel, Ingo Molnar, Andrew Morton, Al Viro, Joe Perches,
Patrick McHardy, Jozsef Kadlecsik, netfilter-devel, coreteam
On Tue, Nov 04, 2014 at 09:31:50AM -0500, Steven Rostedt wrote:
> On Tue, 4 Nov 2014 15:22:36 +0100
> Pablo Neira Ayuso <pablo@netfilter.org> wrote:
>
> > On Tue, Nov 04, 2014 at 08:05:35AM -0500, Steven Rostedt wrote:
> > > On Wed, 29 Oct 2014 17:56:04 -0400
> > > Steven Rostedt <rostedt@goodmis.org> wrote:
> > >
> > > > From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> > > >
> > > > [ REQUEST FOR ACKS ]
> > >
> > > Can any of the netfilter folks give me an Acked-by for this?
> >
> > If Florian's concern were addressed, then:
>
> Yeah, the change he mentioned was done is 3/8. As that was written by
> Joe Perches, I did some work that he missed and put it before his
> patch, which showed a discrepancy between the two functions. After all
> patches are applied, it should be consistent to his liking.
>
> >
> > Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
> >
> > to this patch and 4/8.
>
> Thanks for this!
>
> Can I get someone to ack 3/8?
I don't see any 3/8 in my inbox, only 2/8 and 4/8.
Let me know, thanks.
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks
2014-11-04 14:46 ` Pablo Neira Ayuso
@ 2014-11-04 14:48 ` Steven Rostedt
2014-11-04 19:59 ` Steven Rostedt
1 sibling, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2014-11-04 14:48 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: linux-kernel, Ingo Molnar, Andrew Morton, Al Viro, Joe Perches,
Patrick McHardy, Jozsef Kadlecsik, netfilter-devel, coreteam
On Tue, 4 Nov 2014 15:46:32 +0100
Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > Can I get someone to ack 3/8?
>
> I don't see any 3/8 in my inbox, only 2/8 and 4/8.
>
> Let me know, thanks.
Strange, you were on the Cc of that patch.
Let me go back and check to make sure that didn't bounce too.
-- Steve
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFA][PATCH 3/8] netfilter: Convert print_tuple functions to return void
2014-10-29 21:56 ` [RFA][PATCH 3/8] netfilter: Convert print_tuple functions to return void Steven Rostedt
2014-11-04 13:07 ` Steven Rostedt
@ 2014-11-04 14:50 ` Steven Rostedt
1 sibling, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2014-11-04 14:50 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: linux-kernel, Ingo Molnar, Andrew Morton, Al Viro, Joe Perches,
Patrick McHardy, Jozsef Kadlecsik, netfilter-devel, coreteam
Pablo,
I'm replying to the patch that was sent. Hopefully you get it.
Thanks,
-- Steve
On Wed, 29 Oct 2014 17:56:05 -0400
Steven Rostedt <rostedt@goodmis.org> wrote:
> From: Joe Perches <joe@perches.com>
>
> [ REQUEST FOR ACKS ]
>
> Since adding a new function to seq_file (seq_has_overflowed())
> there isn't any value for functions called from seq_show to
> return anything. Remove the int returns of the various
> print_tuple/<foo>_print_tuple functions.
>
> Link: http://lkml.kernel.org/p/f2e8cf8df433a197daa62cbaf124c900c708edc7.1412031505.git.joe@perches.com
>
> Cc: Pablo Neira Ayuso <pablo@netfilter.org>
> Cc: Patrick McHardy <kaber@trash.net>
> Cc: Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>
> Cc: netfilter-devel@vger.kernel.org
> Cc: coreteam@netfilter.org
> Signed-off-by: Joe Perches <joe@perches.com>
> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
> ---
> include/net/netfilter/nf_conntrack_core.h | 2 +-
> include/net/netfilter/nf_conntrack_l3proto.h | 4 ++--
> include/net/netfilter/nf_conntrack_l4proto.h | 4 ++--
> net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c | 6 +++---
> net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c | 12 ++++++++----
> net/ipv4/netfilter/nf_conntrack_proto_icmp.c | 10 +++++-----
> net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c | 6 +++---
> net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c | 10 +++++-----
> net/netfilter/nf_conntrack_l3proto_generic.c | 5 ++---
> net/netfilter/nf_conntrack_proto_dccp.c | 10 +++++-----
> net/netfilter/nf_conntrack_proto_generic.c | 5 ++---
> net/netfilter/nf_conntrack_proto_gre.c | 10 +++++-----
> net/netfilter/nf_conntrack_proto_sctp.c | 10 +++++-----
> net/netfilter/nf_conntrack_proto_tcp.c | 10 +++++-----
> net/netfilter/nf_conntrack_proto_udp.c | 10 +++++-----
> net/netfilter/nf_conntrack_proto_udplite.c | 10 +++++-----
> net/netfilter/nf_conntrack_standalone.c | 15 +++++++--------
> 17 files changed, 70 insertions(+), 69 deletions(-)
>
> diff --git a/include/net/netfilter/nf_conntrack_core.h b/include/net/netfilter/nf_conntrack_core.h
> index cc0c18827602..f2f0fa3bb150 100644
> --- a/include/net/netfilter/nf_conntrack_core.h
> +++ b/include/net/netfilter/nf_conntrack_core.h
> @@ -72,7 +72,7 @@ static inline int nf_conntrack_confirm(struct sk_buff *skb)
> return ret;
> }
>
> -int
> +void
> print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
> const struct nf_conntrack_l3proto *l3proto,
> const struct nf_conntrack_l4proto *proto);
> diff --git a/include/net/netfilter/nf_conntrack_l3proto.h b/include/net/netfilter/nf_conntrack_l3proto.h
> index adc1fa3dd7ab..cdc920b4c4c2 100644
> --- a/include/net/netfilter/nf_conntrack_l3proto.h
> +++ b/include/net/netfilter/nf_conntrack_l3proto.h
> @@ -38,8 +38,8 @@ struct nf_conntrack_l3proto {
> const struct nf_conntrack_tuple *orig);
>
> /* Print out the per-protocol part of the tuple. */
> - int (*print_tuple)(struct seq_file *s,
> - const struct nf_conntrack_tuple *);
> + void (*print_tuple)(struct seq_file *s,
> + const struct nf_conntrack_tuple *);
>
> /*
> * Called before tracking.
> diff --git a/include/net/netfilter/nf_conntrack_l4proto.h b/include/net/netfilter/nf_conntrack_l4proto.h
> index 82e4ec002a39..1f7061313d54 100644
> --- a/include/net/netfilter/nf_conntrack_l4proto.h
> +++ b/include/net/netfilter/nf_conntrack_l4proto.h
> @@ -56,8 +56,8 @@ struct nf_conntrack_l4proto {
> u_int8_t pf, unsigned int hooknum);
>
> /* Print out the per-protocol part of the tuple. Return like seq_* */
> - int (*print_tuple)(struct seq_file *s,
> - const struct nf_conntrack_tuple *);
> + void (*print_tuple)(struct seq_file *s,
> + const struct nf_conntrack_tuple *);
>
> /* Print out the private part of the conntrack. */
> void (*print_conntrack)(struct seq_file *s, struct nf_conn *);
> diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
> index a054fe083431..5c61328b7704 100644
> --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
> +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4.c
> @@ -56,11 +56,11 @@ static bool ipv4_invert_tuple(struct nf_conntrack_tuple *tuple,
> return true;
> }
>
> -static int ipv4_print_tuple(struct seq_file *s,
> +static void ipv4_print_tuple(struct seq_file *s,
> const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "src=%pI4 dst=%pI4 ",
> - &tuple->src.u3.ip, &tuple->dst.u3.ip);
> + seq_printf(s, "src=%pI4 dst=%pI4 ",
> + &tuple->src.u3.ip, &tuple->dst.u3.ip);
> }
>
> static int ipv4_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
> diff --git a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> index 91f207c2cb69..d927f9e72130 100644
> --- a/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> +++ b/net/ipv4/netfilter/nf_conntrack_l3proto_ipv4_compat.c
> @@ -153,8 +153,10 @@ static int ct_seq_show(struct seq_file *s, void *v)
> if (seq_has_overflowed(s))
> goto release;
>
> - if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> - l3proto, l4proto))
> + print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> + l3proto, l4proto);
> +
> + if (seq_has_overflowed(s))
> goto release;
>
> if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL))
> @@ -164,8 +166,10 @@ static int ct_seq_show(struct seq_file *s, void *v)
> if (seq_printf(s, "[UNREPLIED] "))
> goto release;
>
> - if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
> - l3proto, l4proto))
> + print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
> + l3proto, l4proto);
> +
> + if (seq_has_overflowed(s))
> goto release;
>
> if (seq_print_acct(s, ct, IP_CT_DIR_REPLY))
> diff --git a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
> index b91b2641adda..80d5554b9a88 100644
> --- a/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
> +++ b/net/ipv4/netfilter/nf_conntrack_proto_icmp.c
> @@ -72,13 +72,13 @@ static bool icmp_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int icmp_print_tuple(struct seq_file *s,
> +static void icmp_print_tuple(struct seq_file *s,
> const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "type=%u code=%u id=%u ",
> - tuple->dst.u.icmp.type,
> - tuple->dst.u.icmp.code,
> - ntohs(tuple->src.u.icmp.id));
> + seq_printf(s, "type=%u code=%u id=%u ",
> + tuple->dst.u.icmp.type,
> + tuple->dst.u.icmp.code,
> + ntohs(tuple->src.u.icmp.id));
> }
>
> static unsigned int *icmp_get_timeouts(struct net *net)
> diff --git a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
> index 4cbc6b290dd5..b68d0e59c1f8 100644
> --- a/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
> +++ b/net/ipv6/netfilter/nf_conntrack_l3proto_ipv6.c
> @@ -60,11 +60,11 @@ static bool ipv6_invert_tuple(struct nf_conntrack_tuple *tuple,
> return true;
> }
>
> -static int ipv6_print_tuple(struct seq_file *s,
> +static void ipv6_print_tuple(struct seq_file *s,
> const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "src=%pI6 dst=%pI6 ",
> - tuple->src.u3.ip6, tuple->dst.u3.ip6);
> + seq_printf(s, "src=%pI6 dst=%pI6 ",
> + tuple->src.u3.ip6, tuple->dst.u3.ip6);
> }
>
> static int ipv6_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
> diff --git a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
> index b3807c5cb888..90388d606483 100644
> --- a/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
> +++ b/net/ipv6/netfilter/nf_conntrack_proto_icmpv6.c
> @@ -84,13 +84,13 @@ static bool icmpv6_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int icmpv6_print_tuple(struct seq_file *s,
> +static void icmpv6_print_tuple(struct seq_file *s,
> const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "type=%u code=%u id=%u ",
> - tuple->dst.u.icmp.type,
> - tuple->dst.u.icmp.code,
> - ntohs(tuple->src.u.icmp.id));
> + seq_printf(s, "type=%u code=%u id=%u ",
> + tuple->dst.u.icmp.type,
> + tuple->dst.u.icmp.code,
> + ntohs(tuple->src.u.icmp.id));
> }
>
> static unsigned int *icmpv6_get_timeouts(struct net *net)
> diff --git a/net/netfilter/nf_conntrack_l3proto_generic.c b/net/netfilter/nf_conntrack_l3proto_generic.c
> index e7eb807fe07d..cf9ace70bece 100644
> --- a/net/netfilter/nf_conntrack_l3proto_generic.c
> +++ b/net/netfilter/nf_conntrack_l3proto_generic.c
> @@ -49,10 +49,9 @@ static bool generic_invert_tuple(struct nf_conntrack_tuple *tuple,
> return true;
> }
>
> -static int generic_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void generic_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return 0;
> }
>
> static int generic_get_l4proto(const struct sk_buff *skb, unsigned int nhoff,
> diff --git a/net/netfilter/nf_conntrack_proto_dccp.c b/net/netfilter/nf_conntrack_proto_dccp.c
> index 15971177470a..6dd995c7c72b 100644
> --- a/net/netfilter/nf_conntrack_proto_dccp.c
> +++ b/net/netfilter/nf_conntrack_proto_dccp.c
> @@ -618,12 +618,12 @@ out_invalid:
> return -NF_ACCEPT;
> }
>
> -static int dccp_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void dccp_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "sport=%hu dport=%hu ",
> - ntohs(tuple->src.u.dccp.port),
> - ntohs(tuple->dst.u.dccp.port));
> + seq_printf(s, "sport=%hu dport=%hu ",
> + ntohs(tuple->src.u.dccp.port),
> + ntohs(tuple->dst.u.dccp.port));
> }
>
> static void dccp_print_conntrack(struct seq_file *s, struct nf_conn *ct)
> diff --git a/net/netfilter/nf_conntrack_proto_generic.c b/net/netfilter/nf_conntrack_proto_generic.c
> index 957c1db66652..60865f110309 100644
> --- a/net/netfilter/nf_conntrack_proto_generic.c
> +++ b/net/netfilter/nf_conntrack_proto_generic.c
> @@ -63,10 +63,9 @@ static bool generic_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int generic_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void generic_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return 0;
> }
>
> static unsigned int *generic_get_timeouts(struct net *net)
> diff --git a/net/netfilter/nf_conntrack_proto_gre.c b/net/netfilter/nf_conntrack_proto_gre.c
> index cba607ada069..7648674f29c3 100644
> --- a/net/netfilter/nf_conntrack_proto_gre.c
> +++ b/net/netfilter/nf_conntrack_proto_gre.c
> @@ -226,12 +226,12 @@ static bool gre_pkt_to_tuple(const struct sk_buff *skb, unsigned int dataoff,
> }
>
> /* print gre part of tuple */
> -static int gre_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void gre_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "srckey=0x%x dstkey=0x%x ",
> - ntohs(tuple->src.u.gre.key),
> - ntohs(tuple->dst.u.gre.key));
> + seq_printf(s, "srckey=0x%x dstkey=0x%x ",
> + ntohs(tuple->src.u.gre.key),
> + ntohs(tuple->dst.u.gre.key));
> }
>
> /* print private data for conntrack */
> diff --git a/net/netfilter/nf_conntrack_proto_sctp.c b/net/netfilter/nf_conntrack_proto_sctp.c
> index c61f4cd6407d..b45da90fad32 100644
> --- a/net/netfilter/nf_conntrack_proto_sctp.c
> +++ b/net/netfilter/nf_conntrack_proto_sctp.c
> @@ -166,12 +166,12 @@ static bool sctp_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int sctp_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void sctp_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "sport=%hu dport=%hu ",
> - ntohs(tuple->src.u.sctp.port),
> - ntohs(tuple->dst.u.sctp.port));
> + seq_printf(s, "sport=%hu dport=%hu ",
> + ntohs(tuple->src.u.sctp.port),
> + ntohs(tuple->dst.u.sctp.port));
> }
>
> /* Print out the private part of the conntrack. */
> diff --git a/net/netfilter/nf_conntrack_proto_tcp.c b/net/netfilter/nf_conntrack_proto_tcp.c
> index 79668fd3db96..36a3ac8ee9f5 100644
> --- a/net/netfilter/nf_conntrack_proto_tcp.c
> +++ b/net/netfilter/nf_conntrack_proto_tcp.c
> @@ -302,12 +302,12 @@ static bool tcp_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int tcp_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void tcp_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "sport=%hu dport=%hu ",
> - ntohs(tuple->src.u.tcp.port),
> - ntohs(tuple->dst.u.tcp.port));
> + seq_printf(s, "sport=%hu dport=%hu ",
> + ntohs(tuple->src.u.tcp.port),
> + ntohs(tuple->dst.u.tcp.port));
> }
>
> /* Print out the private part of the conntrack. */
> diff --git a/net/netfilter/nf_conntrack_proto_udp.c b/net/netfilter/nf_conntrack_proto_udp.c
> index 9d7721cbce4b..6957281ffee5 100644
> --- a/net/netfilter/nf_conntrack_proto_udp.c
> +++ b/net/netfilter/nf_conntrack_proto_udp.c
> @@ -63,12 +63,12 @@ static bool udp_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int udp_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void udp_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "sport=%hu dport=%hu ",
> - ntohs(tuple->src.u.udp.port),
> - ntohs(tuple->dst.u.udp.port));
> + seq_printf(s, "sport=%hu dport=%hu ",
> + ntohs(tuple->src.u.udp.port),
> + ntohs(tuple->dst.u.udp.port));
> }
>
> static unsigned int *udp_get_timeouts(struct net *net)
> diff --git a/net/netfilter/nf_conntrack_proto_udplite.c b/net/netfilter/nf_conntrack_proto_udplite.c
> index 2750e6c69f82..c5903d1649f9 100644
> --- a/net/netfilter/nf_conntrack_proto_udplite.c
> +++ b/net/netfilter/nf_conntrack_proto_udplite.c
> @@ -71,12 +71,12 @@ static bool udplite_invert_tuple(struct nf_conntrack_tuple *tuple,
> }
>
> /* Print out the per-protocol part of the tuple. */
> -static int udplite_print_tuple(struct seq_file *s,
> - const struct nf_conntrack_tuple *tuple)
> +static void udplite_print_tuple(struct seq_file *s,
> + const struct nf_conntrack_tuple *tuple)
> {
> - return seq_printf(s, "sport=%hu dport=%hu ",
> - ntohs(tuple->src.u.udp.port),
> - ntohs(tuple->dst.u.udp.port));
> + seq_printf(s, "sport=%hu dport=%hu ",
> + ntohs(tuple->src.u.udp.port),
> + ntohs(tuple->dst.u.udp.port));
> }
>
> static unsigned int *udplite_get_timeouts(struct net *net)
> diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
> index 348aa3602787..23a0dcab21d4 100644
> --- a/net/netfilter/nf_conntrack_standalone.c
> +++ b/net/netfilter/nf_conntrack_standalone.c
> @@ -36,12 +36,13 @@
> MODULE_LICENSE("GPL");
>
> #ifdef CONFIG_NF_CONNTRACK_PROCFS
> -int
> +void
> print_tuple(struct seq_file *s, const struct nf_conntrack_tuple *tuple,
> const struct nf_conntrack_l3proto *l3proto,
> const struct nf_conntrack_l4proto *l4proto)
> {
> - return l3proto->print_tuple(s, tuple) || l4proto->print_tuple(s, tuple);
> + l3proto->print_tuple(s, tuple);
> + l4proto->print_tuple(s, tuple);
> }
> EXPORT_SYMBOL_GPL(print_tuple);
>
> @@ -202,9 +203,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
> if (l4proto->print_conntrack)
> l4proto->print_conntrack(s, ct);
>
> - if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> - l3proto, l4proto))
> - goto release;
> + print_tuple(s, &ct->tuplehash[IP_CT_DIR_ORIGINAL].tuple,
> + l3proto, l4proto);
>
> if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL))
> goto release;
> @@ -213,9 +213,8 @@ static int ct_seq_show(struct seq_file *s, void *v)
> if (seq_printf(s, "[UNREPLIED] "))
> goto release;
>
> - if (print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
> - l3proto, l4proto))
> - goto release;
> + print_tuple(s, &ct->tuplehash[IP_CT_DIR_REPLY].tuple,
> + l3proto, l4proto);
>
> if (seq_print_acct(s, ct, IP_CT_DIR_REPLY))
> goto release;
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks
2014-11-04 14:46 ` Joe Perches
@ 2014-11-04 14:52 ` Steven Rostedt
0 siblings, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2014-11-04 14:52 UTC (permalink / raw)
To: Joe Perches
Cc: Pablo Neira Ayuso, linux-kernel, Ingo Molnar, Andrew Morton,
Al Viro, Patrick McHardy, Jozsef Kadlecsik, netfilter-devel,
coreteam
On Tue, 04 Nov 2014 06:46:19 -0800
Joe Perches <joe@perches.com> wrote:
> On Tue, 2014-11-04 at 09:31 -0500, Steven Rostedt wrote:
> > On Tue, 4 Nov 2014 15:22:36 +0100
> > Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > > On Tue, Nov 04, 2014 at 08:05:35AM -0500, Steven Rostedt wrote:
> > > > On Wed, 29 Oct 2014 17:56:04 -0400 Steven Rostedt <rostedt@goodmis.org> wrote:
> > > > > From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>
> > > > > [ REQUEST FOR ACKS ]
> > > > Can any of the netfilter folks give me an Acked-by for this?
> > > If Florian's concern were addressed, then:
> > Yeah, the change he mentioned was done is 3/8. As that was written by
> > Joe Perches, I did some work that he missed and put it before his
> > patch, which showed a discrepancy between the two functions. After all
> > patches are applied, it should be consistent to his liking.
>
> I think seq_has_overflowed does not need
> to be used after every seq_<put/print> call.
>
> It interrupts reading code flow and just
> isn't alll that necessary as every operation
> before it will be redone anyway.
>
> It should be used before or after a large
> blocks though.
>
It's not used in every occurrence. The problem that Florian had was that
there were two almost identical functions, and you changed one to have
the seq_has_overflowed() check, but the other one was left without it.
It wasn't about checking multiple times, it was about consistency
between two similar functions.
-- Steve
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks
2014-11-04 14:46 ` Pablo Neira Ayuso
2014-11-04 14:48 ` Steven Rostedt
@ 2014-11-04 19:59 ` Steven Rostedt
1 sibling, 0 replies; 18+ messages in thread
From: Steven Rostedt @ 2014-11-04 19:59 UTC (permalink / raw)
To: Pablo Neira Ayuso
Cc: linux-kernel, Ingo Molnar, Andrew Morton, Al Viro, Joe Perches,
Patrick McHardy, Jozsef Kadlecsik, netfilter-devel, coreteam
On Tue, 4 Nov 2014 15:46:32 +0100
Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > >
> > > Acked-by: Pablo Neira Ayuso <pablo@netfilter.org>
> > >
> > > to this patch and 4/8.
> >
> > Thanks for this!
> >
> > Can I get someone to ack 3/8?
>
> I don't see any 3/8 in my inbox, only 2/8 and 4/8.
>
> Let me know, thanks.
I replied to the patch. Did you get that reply?
Or did it somehow end up in your spam filter?
-- Steve
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2014-11-04 19:59 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20141029215602.535533597@goodmis.org>
2014-10-29 21:56 ` [RFA][PATCH 2/8] netfilter: Remove return values for print_conntrack callbacks Steven Rostedt
2014-10-29 22:16 ` Florian Westphal
2014-10-29 23:53 ` Steven Rostedt
2014-10-30 1:06 ` Steven Rostedt
2014-11-04 13:05 ` Steven Rostedt
2014-11-04 14:11 ` Steven Rostedt
2014-11-04 14:22 ` Pablo Neira Ayuso
2014-11-04 14:31 ` Steven Rostedt
2014-11-04 14:46 ` Joe Perches
2014-11-04 14:52 ` Steven Rostedt
2014-11-04 14:46 ` Pablo Neira Ayuso
2014-11-04 14:48 ` Steven Rostedt
2014-11-04 19:59 ` Steven Rostedt
2014-10-29 21:56 ` [RFA][PATCH 3/8] netfilter: Convert print_tuple functions to return void Steven Rostedt
2014-11-04 13:07 ` Steven Rostedt
2014-11-04 14:50 ` Steven Rostedt
2014-10-29 21:56 ` [RFA][PATCH 4/8] netfilter: Remove checks of seq_printf() return values Steven Rostedt
2014-11-04 13:08 ` Steven Rostedt
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).