linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] netfilter: conntrack: remote a return value of the 'seq_print_acct' function.
@ 2023-01-23  8:19 Gavrilov Ilia
  2023-01-23 13:28 ` Leon Romanovsky
  0 siblings, 1 reply; 6+ messages in thread
From: Gavrilov Ilia @ 2023-01-23  8:19 UTC (permalink / raw)
  To: Pablo Neira Ayuso
  Cc: Jozsef Kadlecsik, Florian Westphal, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, Joe Perches,
	netfilter-devel, coreteam, netdev, linux-kernel, lvc-project

The static 'seq_print_acct' function always returns 0.

Change the return value to 'void' and remove unnecessary checks.

Found by InfoTeCS on behalf of Linux Verification Center
(linuxtesting.org) with SVACE.

Fixes: 1ca9e41770cb ("netfilter: Remove uses of seq_<foo> return values")
Signed-off-by: Ilia.Gavrilov <Ilia.Gavrilov@infotecs.ru>
---
 net/netfilter/nf_conntrack_standalone.c | 26 ++++++++++---------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 0250725e38a4..bee99d4bcf36 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -275,22 +275,18 @@ static const char* l4proto_name(u16 proto)
 	return "unknown";
 }
 
-static unsigned int
+static void
 seq_print_acct(struct seq_file *s, const struct nf_conn *ct, int dir)
 {
-	struct nf_conn_acct *acct;
-	struct nf_conn_counter *counter;
+	struct nf_conn_acct *acct = nf_conn_acct_find(ct);
 
-	acct = nf_conn_acct_find(ct);
-	if (!acct)
-		return 0;
-
-	counter = acct->counter;
-	seq_printf(s, "packets=%llu bytes=%llu ",
-		   (unsigned long long)atomic64_read(&counter[dir].packets),
-		   (unsigned long long)atomic64_read(&counter[dir].bytes));
+	if (acct) {
+		struct nf_conn_counter *counter = acct->counter;
 
-	return 0;
+		seq_printf(s, "packets=%llu bytes=%llu ",
+			   (unsigned long long)atomic64_read(&counter[dir].packets),
+			   (unsigned long long)atomic64_read(&counter[dir].bytes));
+	}
 }
 
 /* return 0 on success, 1 in case of error */
@@ -342,8 +338,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
 	if (seq_has_overflowed(s))
 		goto release;
 
-	if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL))
-		goto release;
+	seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL);
 
 	if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status)))
 		seq_puts(s, "[UNREPLIED] ");
@@ -352,8 +347,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
 
 	ct_show_zone(s, ct, NF_CT_ZONE_DIR_REPL);
 
-	if (seq_print_acct(s, ct, IP_CT_DIR_REPLY))
-		goto release;
+	seq_print_acct(s, ct, IP_CT_DIR_REPLY);
 
 	if (test_bit(IPS_HW_OFFLOAD_BIT, &ct->status))
 		seq_puts(s, "[HW_OFFLOAD] ");
-- 
2.30.2

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

* Re: [PATCH] netfilter: conntrack: remote a return value of the 'seq_print_acct' function.
  2023-01-23  8:19 [PATCH] netfilter: conntrack: remote a return value of the 'seq_print_acct' function Gavrilov Ilia
@ 2023-01-23 13:28 ` Leon Romanovsky
  2023-01-23 14:06   ` Gavrilov Ilia
  2023-01-23 14:31   ` [PATCH v2] " Gavrilov Ilia
  0 siblings, 2 replies; 6+ messages in thread
From: Leon Romanovsky @ 2023-01-23 13:28 UTC (permalink / raw)
  To: Gavrilov Ilia
  Cc: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Joe Perches, netfilter-devel, coreteam, netdev, linux-kernel,
	lvc-project

On Mon, Jan 23, 2023 at 08:19:50AM +0000, Gavrilov Ilia wrote:
> The static 'seq_print_acct' function always returns 0.
> 
> Change the return value to 'void' and remove unnecessary checks.
> 
> Found by InfoTeCS on behalf of Linux Verification Center
> (linuxtesting.org) with SVACE.
> 
> Fixes: 1ca9e41770cb ("netfilter: Remove uses of seq_<foo> return values")
> Signed-off-by: Ilia.Gavrilov <Ilia.Gavrilov@infotecs.ru>
> ---
>  net/netfilter/nf_conntrack_standalone.c | 26 ++++++++++---------------
>  1 file changed, 10 insertions(+), 16 deletions(-)
> 
> diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
> index 0250725e38a4..bee99d4bcf36 100644
> --- a/net/netfilter/nf_conntrack_standalone.c
> +++ b/net/netfilter/nf_conntrack_standalone.c
> @@ -275,22 +275,18 @@ static const char* l4proto_name(u16 proto)
>  	return "unknown";
>  }
>  
> -static unsigned int
> +static void
>  seq_print_acct(struct seq_file *s, const struct nf_conn *ct, int dir)
>  {
> -	struct nf_conn_acct *acct;
> -	struct nf_conn_counter *counter;
> +	struct nf_conn_acct *acct = nf_conn_acct_find(ct);
>  
> -	acct = nf_conn_acct_find(ct);
> -	if (!acct)
> -		return 0;
> -
> -	counter = acct->counter;
> -	seq_printf(s, "packets=%llu bytes=%llu ",
> -		   (unsigned long long)atomic64_read(&counter[dir].packets),
> -		   (unsigned long long)atomic64_read(&counter[dir].bytes));
> +	if (acct) {
> +		struct nf_conn_counter *counter = acct->counter;
>  
> -	return 0;
> +		seq_printf(s, "packets=%llu bytes=%llu ",
> +			   (unsigned long long)atomic64_read(&counter[dir].packets),
> +			   (unsigned long long)atomic64_read(&counter[dir].bytes));
> +	}

The preferred linux kernel style is to perform if (check_error) return;
In this case, this pattern should stay.

acct = nf_conn_acct_find(ct);
if (!acct)
   return;

Thanks

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

* Re: [PATCH] netfilter: conntrack: remote a return value of the 'seq_print_acct' function.
  2023-01-23 13:28 ` Leon Romanovsky
@ 2023-01-23 14:06   ` Gavrilov Ilia
  2023-01-23 14:31   ` [PATCH v2] " Gavrilov Ilia
  1 sibling, 0 replies; 6+ messages in thread
From: Gavrilov Ilia @ 2023-01-23 14:06 UTC (permalink / raw)
  To: Leon Romanovsky
  Cc: Pablo Neira Ayuso, Jozsef Kadlecsik, Florian Westphal,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Joe Perches, netfilter-devel, coreteam, netdev, linux-kernel,
	lvc-project




С уважением,
Илья Гаврилов
Ведущий программист
Отдел разработки
АО "ИнфоТеКС" в г. Санкт-Петербург
127287, г. Москва, Старый Петровско-Разумовский проезд, дом 1/23, стр. 1
T: +7 495 737-61-92 ( доб. 4921)
Ф: +7 495 737-72-78


Ilia.Gavrilov@infotecs.ru
www.infotecs.ru


On 1/23/23 16:28, Leon Romanovsky wrote:
> On Mon, Jan 23, 2023 at 08:19:50AM +0000, Gavrilov Ilia wrote:
>> The static 'seq_print_acct' function always returns 0.
>>
>> Change the return value to 'void' and remove unnecessary checks.
>>
>> Found by InfoTeCS on behalf of Linux Verification Center
>> (linuxtesting.org) with SVACE.
>>
>> Fixes: 1ca9e41770cb ("netfilter: Remove uses of seq_<foo> return values")
>> Signed-off-by: Ilia.Gavrilov <Ilia.Gavrilov@infotecs.ru>
>> ---
>>   net/netfilter/nf_conntrack_standalone.c | 26 ++++++++++---------------
>>   1 file changed, 10 insertions(+), 16 deletions(-)
>>
>> diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
>> index 0250725e38a4..bee99d4bcf36 100644
>> --- a/net/netfilter/nf_conntrack_standalone.c
>> +++ b/net/netfilter/nf_conntrack_standalone.c
>> @@ -275,22 +275,18 @@ static const char* l4proto_name(u16 proto)
>>   return "unknown";
>>   }
>>
>> -static unsigned int
>> +static void
>>   seq_print_acct(struct seq_file *s, const struct nf_conn *ct, int dir)
>>   {
>> -struct nf_conn_acct *acct;
>> -struct nf_conn_counter *counter;
>> +struct nf_conn_acct *acct = nf_conn_acct_find(ct);
>>
>> -acct = nf_conn_acct_find(ct);
>> -if (!acct)
>> -return 0;
>> -
>> -counter = acct->counter;
>> -seq_printf(s, "packets=%llu bytes=%llu ",
>> -   (unsigned long long)atomic64_read(&counter[dir].packets),
>> -   (unsigned long long)atomic64_read(&counter[dir].bytes));
>> +if (acct) {
>> +struct nf_conn_counter *counter = acct->counter;
>>
>> -return 0;
>> +seq_printf(s, "packets=%llu bytes=%llu ",
>> +   (unsigned long long)atomic64_read(&counter[dir].packets),
>> +   (unsigned long long)atomic64_read(&counter[dir].bytes));
>> +}
>
> The preferred linux kernel style is to perform if (check_error) return;
> In this case, this pattern should stay.
>
> acct = nf_conn_acct_find(ct);
> if (!acct)
>     return;
>
> Thanks

Thank you for review. I'll fix it in v2.

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

* [PATCH v2] netfilter: conntrack: remote a return value of the 'seq_print_acct' function.
  2023-01-23 13:28 ` Leon Romanovsky
  2023-01-23 14:06   ` Gavrilov Ilia
@ 2023-01-23 14:31   ` Gavrilov Ilia
  2023-01-23 17:44     ` Leon Romanovsky
  2023-02-01 11:17     ` Pablo Neira Ayuso
  1 sibling, 2 replies; 6+ messages in thread
From: Gavrilov Ilia @ 2023-01-23 14:31 UTC (permalink / raw)
  To: leon
  Cc: Gavrilov Ilia, coreteam, davem, edumazet, fw, joe, kadlec, kuba,
	linux-kernel, lvc-project, netdev, netfilter-devel, pabeni,
	pablo

The static 'seq_print_acct' function always returns 0.

Change the return value to 'void' and remove unnecessary checks.

Found by InfoTeCS on behalf of Linux Verification Center
(linuxtesting.org) with SVACE.

Fixes: 1ca9e41770cb ("netfilter: Remove uses of seq_<foo> return values")
Signed-off-by: Ilia.Gavrilov <Ilia.Gavrilov@infotecs.ru>
---
V2: Fix coding style
 net/netfilter/nf_conntrack_standalone.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/net/netfilter/nf_conntrack_standalone.c b/net/netfilter/nf_conntrack_standalone.c
index 0250725e38a4..6819d07f9692 100644
--- a/net/netfilter/nf_conntrack_standalone.c
+++ b/net/netfilter/nf_conntrack_standalone.c
@@ -275,7 +275,7 @@ static const char* l4proto_name(u16 proto)
 	return "unknown";
 }
 
-static unsigned int
+static void
 seq_print_acct(struct seq_file *s, const struct nf_conn *ct, int dir)
 {
 	struct nf_conn_acct *acct;
@@ -283,14 +283,12 @@ seq_print_acct(struct seq_file *s, const struct nf_conn *ct, int dir)
 
 	acct = nf_conn_acct_find(ct);
 	if (!acct)
-		return 0;
+		return;
 
 	counter = acct->counter;
 	seq_printf(s, "packets=%llu bytes=%llu ",
 		   (unsigned long long)atomic64_read(&counter[dir].packets),
 		   (unsigned long long)atomic64_read(&counter[dir].bytes));
-
-	return 0;
 }
 
 /* return 0 on success, 1 in case of error */
@@ -342,8 +340,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
 	if (seq_has_overflowed(s))
 		goto release;
 
-	if (seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL))
-		goto release;
+	seq_print_acct(s, ct, IP_CT_DIR_ORIGINAL);
 
 	if (!(test_bit(IPS_SEEN_REPLY_BIT, &ct->status)))
 		seq_puts(s, "[UNREPLIED] ");
@@ -352,8 +349,7 @@ static int ct_seq_show(struct seq_file *s, void *v)
 
 	ct_show_zone(s, ct, NF_CT_ZONE_DIR_REPL);
 
-	if (seq_print_acct(s, ct, IP_CT_DIR_REPLY))
-		goto release;
+	seq_print_acct(s, ct, IP_CT_DIR_REPLY);
 
 	if (test_bit(IPS_HW_OFFLOAD_BIT, &ct->status))
 		seq_puts(s, "[HW_OFFLOAD] ");
-- 
2.30.2

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

* Re: [PATCH v2] netfilter: conntrack: remote a return value of the 'seq_print_acct' function.
  2023-01-23 14:31   ` [PATCH v2] " Gavrilov Ilia
@ 2023-01-23 17:44     ` Leon Romanovsky
  2023-02-01 11:17     ` Pablo Neira Ayuso
  1 sibling, 0 replies; 6+ messages in thread
From: Leon Romanovsky @ 2023-01-23 17:44 UTC (permalink / raw)
  To: Gavrilov Ilia
  Cc: coreteam, davem, edumazet, fw, joe, kadlec, kuba, linux-kernel,
	lvc-project, netdev, netfilter-devel, pabeni, pablo

On Mon, Jan 23, 2023 at 02:31:54PM +0000, Gavrilov Ilia wrote:
> The static 'seq_print_acct' function always returns 0.
> 
> Change the return value to 'void' and remove unnecessary checks.
> 
> Found by InfoTeCS on behalf of Linux Verification Center
> (linuxtesting.org) with SVACE.
> 
> Fixes: 1ca9e41770cb ("netfilter: Remove uses of seq_<foo> return values")
> Signed-off-by: Ilia.Gavrilov <Ilia.Gavrilov@infotecs.ru>
> ---
> V2: Fix coding style
>  net/netfilter/nf_conntrack_standalone.c | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
> 

Thanks,
Reviewed-by: Leon Romanovsky <leonro@nvidia.com>

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

* Re: [PATCH v2] netfilter: conntrack: remote a return value of the 'seq_print_acct' function.
  2023-01-23 14:31   ` [PATCH v2] " Gavrilov Ilia
  2023-01-23 17:44     ` Leon Romanovsky
@ 2023-02-01 11:17     ` Pablo Neira Ayuso
  1 sibling, 0 replies; 6+ messages in thread
From: Pablo Neira Ayuso @ 2023-02-01 11:17 UTC (permalink / raw)
  To: Gavrilov Ilia
  Cc: leon, coreteam, davem, edumazet, fw, joe, kadlec, kuba,
	linux-kernel, lvc-project, netdev, netfilter-devel, pabeni

On Mon, Jan 23, 2023 at 02:31:54PM +0000, Gavrilov Ilia wrote:
> The static 'seq_print_acct' function always returns 0.
> 
> Change the return value to 'void' and remove unnecessary checks.
> 
> Found by InfoTeCS on behalf of Linux Verification Center
> (linuxtesting.org) with SVACE.

Applied, thanks

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

end of thread, other threads:[~2023-02-01 11:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-23  8:19 [PATCH] netfilter: conntrack: remote a return value of the 'seq_print_acct' function Gavrilov Ilia
2023-01-23 13:28 ` Leon Romanovsky
2023-01-23 14:06   ` Gavrilov Ilia
2023-01-23 14:31   ` [PATCH v2] " Gavrilov Ilia
2023-01-23 17:44     ` Leon Romanovsky
2023-02-01 11:17     ` Pablo Neira Ayuso

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