netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nf-next 1/1] netfilter: Use bool type instead of int as the return value of nf_conntrack_tuple_taken and nf_nat_used_tuple
@ 2017-03-07  4:28 fgao
  2017-03-27 12:24 ` Pablo Neira Ayuso
  0 siblings, 1 reply; 3+ messages in thread
From: fgao @ 2017-03-07  4:28 UTC (permalink / raw)
  To: pablo, netfilter-devel, gfree.wind; +Cc: Gao Feng

From: Gao Feng <fgao@ikuai8.com>

These two functions return 1/0 as true or false, so it could use bool
type directly instead of int.

Signed-off-by: Gao Feng <fgao@ikuai8.com>
---
 include/net/netfilter/nf_conntrack.h | 2 +-
 include/net/netfilter/nf_nat.h       | 2 +-
 net/netfilter/nf_conntrack_core.c    | 6 +++---
 net/netfilter/nf_nat_core.c          | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
index f540f9a..32a0394 100644
--- a/include/net/netfilter/nf_conntrack.h
+++ b/include/net/netfilter/nf_conntrack.h
@@ -160,7 +160,7 @@ void nf_conntrack_alter_reply(struct nf_conn *ct,
 
 /* Is this tuple taken? (ignoring any belonging to the given
    conntrack). */
-int nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple,
+bool nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple,
 			     const struct nf_conn *ignored_conntrack);
 
 #define NFCT_INFOMASK	7UL
diff --git a/include/net/netfilter/nf_nat.h b/include/net/netfilter/nf_nat.h
index c327a43..cfcf25d 100644
--- a/include/net/netfilter/nf_nat.h
+++ b/include/net/netfilter/nf_nat.h
@@ -48,7 +48,7 @@ extern unsigned int nf_nat_alloc_null_binding(struct nf_conn *ct,
 struct nf_conn_nat *nf_ct_nat_ext_add(struct nf_conn *ct);
 
 /* Is this tuple already taken? (not by us)*/
-int nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple,
+bool nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple,
 		      const struct nf_conn *ignored_conntrack);
 
 static inline struct nf_conn_nat *nfct_nat(const struct nf_conn *ct)
diff --git a/net/netfilter/nf_conntrack_core.c b/net/netfilter/nf_conntrack_core.c
index 071b97f..b0eaa24 100644
--- a/net/netfilter/nf_conntrack_core.c
+++ b/net/netfilter/nf_conntrack_core.c
@@ -837,7 +837,7 @@ static int nf_ct_resolve_clash(struct net *net, struct sk_buff *skb,
 
 /* Returns true if a connection correspondings to the tuple (required
    for NAT). */
-int
+bool
 nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple,
 			 const struct nf_conn *ignored_conntrack)
 {
@@ -870,7 +870,7 @@ static int nf_ct_resolve_clash(struct net *net, struct sk_buff *skb,
 		if (nf_ct_key_equal(h, tuple, zone, net)) {
 			NF_CT_STAT_INC_ATOMIC(net, found);
 			rcu_read_unlock();
-			return 1;
+			return true;
 		}
 	}
 
@@ -881,7 +881,7 @@ static int nf_ct_resolve_clash(struct net *net, struct sk_buff *skb,
 
 	rcu_read_unlock();
 
-	return 0;
+	return false;
 }
 EXPORT_SYMBOL_GPL(nf_conntrack_tuple_taken);
 
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c
index 94b14c5..887a08e 100644
--- a/net/netfilter/nf_nat_core.c
+++ b/net/netfilter/nf_nat_core.c
@@ -135,7 +135,7 @@ static u32 nf_nat_bysource_hash(const void *data, u32 len, u32 seed)
 }
 
 /* Is this tuple already taken? (not by us) */
-int
+bool
 nf_nat_used_tuple(const struct nf_conntrack_tuple *tuple,
 		  const struct nf_conn *ignored_conntrack)
 {
-- 
1.9.1



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

* Re: [PATCH nf-next 1/1] netfilter: Use bool type instead of int as the return value of nf_conntrack_tuple_taken and nf_nat_used_tuple
  2017-03-07  4:28 [PATCH nf-next 1/1] netfilter: Use bool type instead of int as the return value of nf_conntrack_tuple_taken and nf_nat_used_tuple fgao
@ 2017-03-27 12:24 ` Pablo Neira Ayuso
  2017-03-27 12:50   ` Gao Feng
  0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2017-03-27 12:24 UTC (permalink / raw)
  To: fgao; +Cc: netfilter-devel, gfree.wind

On Tue, Mar 07, 2017 at 12:28:55PM +0800, fgao@ikuai8.com wrote:
> From: Gao Feng <fgao@ikuai8.com>
> 
> These two functions return 1/0 as true or false, so it could use bool
> type directly instead of int.

Too long patch subject.
 
> Signed-off-by: Gao Feng <fgao@ikuai8.com>
> ---
>  include/net/netfilter/nf_conntrack.h | 2 +-
>  include/net/netfilter/nf_nat.h       | 2 +-
>  net/netfilter/nf_conntrack_core.c    | 6 +++---
>  net/netfilter/nf_nat_core.c          | 2 +-
>  4 files changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/include/net/netfilter/nf_conntrack.h b/include/net/netfilter/nf_conntrack.h
> index f540f9a..32a0394 100644
> --- a/include/net/netfilter/nf_conntrack.h
> +++ b/include/net/netfilter/nf_conntrack.h
> @@ -160,7 +160,7 @@ void nf_conntrack_alter_reply(struct nf_conn *ct,
>  
>  /* Is this tuple taken? (ignoring any belonging to the given
>     conntrack). */
> -int nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple,
> +bool nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple,
>  			     const struct nf_conn *ignored_conntrack);

Did you audit callers if they handle this type change accordingly? I
don't see any description about this on your patch.

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

* RE: [PATCH nf-next 1/1] netfilter: Use bool type instead of int as the return value of nf_conntrack_tuple_taken and nf_nat_used_tuple
  2017-03-27 12:24 ` Pablo Neira Ayuso
@ 2017-03-27 12:50   ` Gao Feng
  0 siblings, 0 replies; 3+ messages in thread
From: Gao Feng @ 2017-03-27 12:50 UTC (permalink / raw)
  To: 'Pablo Neira Ayuso', fgao; +Cc: netfilter-devel, gfree.wind


> -----Original Message-----
> From: netfilter-devel-owner@vger.kernel.org
> [mailto:netfilter-devel-owner@vger.kernel.org] On Behalf Of Pablo Neira
Ayuso
> Sent: Monday, March 27, 2017 8:25 PM
> To: fgao@ikuai8.com
> Cc: netfilter-devel@vger.kernel.org; gfree.wind@gmail.com
> Subject: Re: [PATCH nf-next 1/1] netfilter: Use bool type instead of int
as the
> return value of nf_conntrack_tuple_taken and nf_nat_used_tuple
> 
> On Tue, Mar 07, 2017 at 12:28:55PM +0800, fgao@ikuai8.com wrote:
> > From: Gao Feng <fgao@ikuai8.com>
> >
> > These two functions return 1/0 as true or false, so it could use bool
> > type directly instead of int.
> 
> Too long patch subject.
Ok, I would make it shorter.
> 
> > Signed-off-by: Gao Feng <fgao@ikuai8.com>
> > ---
> >  include/net/netfilter/nf_conntrack.h | 2 +-
> >  include/net/netfilter/nf_nat.h       | 2 +-
> >  net/netfilter/nf_conntrack_core.c    | 6 +++---
> >  net/netfilter/nf_nat_core.c          | 2 +-
> >  4 files changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/include/net/netfilter/nf_conntrack.h
> > b/include/net/netfilter/nf_conntrack.h
> > index f540f9a..32a0394 100644
> > --- a/include/net/netfilter/nf_conntrack.h
> > +++ b/include/net/netfilter/nf_conntrack.h
> > @@ -160,7 +160,7 @@ void nf_conntrack_alter_reply(struct nf_conn *ct,
> >
> >  /* Is this tuple taken? (ignoring any belonging to the given
> >     conntrack). */
> > -int nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple,
> > +bool nf_conntrack_tuple_taken(const struct nf_conntrack_tuple *tuple,
> >  			     const struct nf_conn *ignored_conntrack);
> 
> Did you audit callers if they handle this type change accordingly? I don't
see
> any description about this on your patch.
I will add the caller description in the update patch.

Regards
Feng
> --
> To unsubscribe from this list: send the line "unsubscribe netfilter-devel"
in the
> body of a message to majordomo@vger.kernel.org More majordomo info at
> http://vger.kernel.org/majordomo-info.html


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

end of thread, other threads:[~2017-03-27 12:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-07  4:28 [PATCH nf-next 1/1] netfilter: Use bool type instead of int as the return value of nf_conntrack_tuple_taken and nf_nat_used_tuple fgao
2017-03-27 12:24 ` Pablo Neira Ayuso
2017-03-27 12:50   ` Gao Feng

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).