linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/netfilter/ipvs/ip_vs_ftp.c: Remove use of NIPQUAD
@ 2010-03-09  0:31 Joe Perches
  2010-03-09  4:08 ` Simon Horman
  2010-03-15 16:20 ` Patrick McHardy
  0 siblings, 2 replies; 6+ messages in thread
From: Joe Perches @ 2010-03-09  0:31 UTC (permalink / raw)
  To: Wensong Zhang, Simon Horman, Julian Anastasov, Patrick McHardy,
	David S. Miller
  Cc: netdev, lvs-devel, LKML

NIPQUAD has very few uses left.

Remove this use and make the code have the identical form of the only
other use of "%u,%u,%u,%u,%u,%u" in net/ipv4/netfilter/nf_nat_ftp.c

Signed-off-by: Joe Perches <joe@perches.com>
---
 net/netfilter/ipvs/ip_vs_ftp.c |   10 ++++++++--
 1 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/net/netfilter/ipvs/ip_vs_ftp.c
b/net/netfilter/ipvs/ip_vs_ftp.c
index 73f38ea..9f63283 100644
--- a/net/netfilter/ipvs/ip_vs_ftp.c
+++ b/net/netfilter/ipvs/ip_vs_ftp.c
@@ -208,8 +208,14 @@ static int ip_vs_ftp_out(struct ip_vs_app *app,
struct ip_vs_conn *cp,
 		 */
 		from.ip = n_cp->vaddr.ip;
 		port = n_cp->vport;
-		sprintf(buf, "%u,%u,%u,%u,%u,%u", NIPQUAD(from.ip),
-			(ntohs(port)>>8)&255, ntohs(port)&255);
+		snprintf(buf, sizeof(buf), "%u,%u,%u,%u,%u,%u",
+			 ((unsigned char *)&from.ip)[0],
+			 ((unsigned char *)&from.ip)[1],
+			 ((unsigned char *)&from.ip)[2],
+			 ((unsigned char *)&from.ip)[3],
+			 ntohs(port) >> 8,
+			 ntohs(port) & 0xFF);
+
 		buf_len = strlen(buf);
 
 		/*



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

* Re: [PATCH] net/netfilter/ipvs/ip_vs_ftp.c: Remove use of NIPQUAD
  2010-03-09  0:31 [PATCH] net/netfilter/ipvs/ip_vs_ftp.c: Remove use of NIPQUAD Joe Perches
@ 2010-03-09  4:08 ` Simon Horman
  2010-03-15 16:20 ` Patrick McHardy
  1 sibling, 0 replies; 6+ messages in thread
From: Simon Horman @ 2010-03-09  4:08 UTC (permalink / raw)
  To: Joe Perches
  Cc: Wensong Zhang, Julian Anastasov, Patrick McHardy, David S. Miller,
	netdev, lvs-devel, LKML

On Mon, Mar 08, 2010 at 04:31:39PM -0800, Joe Perches wrote:
> NIPQUAD has very few uses left.
> 
> Remove this use and make the code have the identical form of the only
> other use of "%u,%u,%u,%u,%u,%u" in net/ipv4/netfilter/nf_nat_ftp.c
> 
> Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Simon Horman <horms@verge.net.au>

> ---
>  net/netfilter/ipvs/ip_vs_ftp.c |   10 ++++++++--
>  1 files changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/net/netfilter/ipvs/ip_vs_ftp.c
> b/net/netfilter/ipvs/ip_vs_ftp.c
> index 73f38ea..9f63283 100644
> --- a/net/netfilter/ipvs/ip_vs_ftp.c
> +++ b/net/netfilter/ipvs/ip_vs_ftp.c
> @@ -208,8 +208,14 @@ static int ip_vs_ftp_out(struct ip_vs_app *app,
> struct ip_vs_conn *cp,
>  		 */
>  		from.ip = n_cp->vaddr.ip;
>  		port = n_cp->vport;
> -		sprintf(buf, "%u,%u,%u,%u,%u,%u", NIPQUAD(from.ip),
> -			(ntohs(port)>>8)&255, ntohs(port)&255);
> +		snprintf(buf, sizeof(buf), "%u,%u,%u,%u,%u,%u",
> +			 ((unsigned char *)&from.ip)[0],
> +			 ((unsigned char *)&from.ip)[1],
> +			 ((unsigned char *)&from.ip)[2],
> +			 ((unsigned char *)&from.ip)[3],
> +			 ntohs(port) >> 8,
> +			 ntohs(port) & 0xFF);
> +
>  		buf_len = strlen(buf);
>  
>  		/*
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe lvs-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] 6+ messages in thread

* Re: [PATCH] net/netfilter/ipvs/ip_vs_ftp.c: Remove use of NIPQUAD
  2010-03-09  0:31 [PATCH] net/netfilter/ipvs/ip_vs_ftp.c: Remove use of NIPQUAD Joe Perches
  2010-03-09  4:08 ` Simon Horman
@ 2010-03-15 16:20 ` Patrick McHardy
  2010-03-15 16:58   ` Joe Perches
  2010-03-15 19:01   ` David Miller
  1 sibling, 2 replies; 6+ messages in thread
From: Patrick McHardy @ 2010-03-15 16:20 UTC (permalink / raw)
  To: Joe Perches
  Cc: Wensong Zhang, Simon Horman, Julian Anastasov, David S. Miller,
	netdev, lvs-devel, LKML

Joe Perches wrote:
> NIPQUAD has very few uses left.
> 
> Remove this use and make the code have the identical form of the only
> other use of "%u,%u,%u,%u,%u,%u" in net/ipv4/netfilter/nf_nat_ftp.c

Are we trying to remove NIPQUAD? In my opinion the current code is
preferrable to open-coding NIPQUAD.

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

* Re: [PATCH] net/netfilter/ipvs/ip_vs_ftp.c: Remove use of NIPQUAD
  2010-03-15 16:20 ` Patrick McHardy
@ 2010-03-15 16:58   ` Joe Perches
  2010-03-15 17:04     ` Patrick McHardy
  2010-03-15 19:01   ` David Miller
  1 sibling, 1 reply; 6+ messages in thread
From: Joe Perches @ 2010-03-15 16:58 UTC (permalink / raw)
  To: Patrick McHardy
  Cc: Wensong Zhang, Simon Horman, Julian Anastasov, David S. Miller,
	netdev, lvs-devel, LKML

On Mon, 2010-03-15 at 17:20 +0100, Patrick McHardy wrote:
> Joe Perches wrote:
> > NIPQUAD has very few uses left.
> > Remove this use and make the code have the identical form of the only
> > other use of "%u,%u,%u,%u,%u,%u" in net/ipv4/netfilter/nf_nat_ftp.c
> 
> Are we trying to remove NIPQUAD? 

That is a goal for me yes.
Elimination of unnecessary stuff from kernel.h is useful.

> In my opinion the current code is
> preferrable to open-coding NIPQUAD.

$ grep -r --include=*.[ch] NIPQUAD *
include/linux/kernel.h:#define NIPQUAD(addr) \
include/linux/kernel.h:#define NIPQUAD_FMT "%u.%u.%u.%u"
net/netfilter/ipvs/ip_vs_ftp.c:		sprintf(buf, "%u,%u,%u,%u,%u,%u", NIPQUAD(from.ip),

As of right now NIPQUAD_FMT is unused and
could be removed from kernel.h

There's 1 use of NIPQUAD.

Maybe instead of removal the #define could be
moved to netfilter.h or netfilter_ipv4.h

Another is to consolidate the two uses of
"%u,%u,%u,%u,%u,%u"

$ grep -r --include=*.[ch] "%u,%u,%u,%u,%u,u%" *
fs/cachefiles/bind.c:	_enter("{%u,%u,%u,%u,%u,%u},%s",
net/ipv4/netfilter/nf_nat_ftp.c:		return snprintf(buffer, buflen, "%u,%u,%u,%u,%u,%u",
net/netfilter/ipvs/ip_vs_ftp.c:		sprintf(buf, "%u,%u,%u,%u,%u,%u", NIPQUAD(from.ip),

Maybe these 2 open coded sprintf/snprintf could be
consolidated and moved to an appropriate include
like netfilter_ipv4 or another.

What do you suggest?


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

* Re: [PATCH] net/netfilter/ipvs/ip_vs_ftp.c: Remove use of NIPQUAD
  2010-03-15 16:58   ` Joe Perches
@ 2010-03-15 17:04     ` Patrick McHardy
  0 siblings, 0 replies; 6+ messages in thread
From: Patrick McHardy @ 2010-03-15 17:04 UTC (permalink / raw)
  To: Joe Perches
  Cc: Wensong Zhang, Simon Horman, Julian Anastasov, David S. Miller,
	netdev, lvs-devel, LKML

Joe Perches wrote:
> On Mon, 2010-03-15 at 17:20 +0100, Patrick McHardy wrote:
>> Joe Perches wrote:
>>> NIPQUAD has very few uses left.
>>> Remove this use and make the code have the identical form of the only
>>> other use of "%u,%u,%u,%u,%u,%u" in net/ipv4/netfilter/nf_nat_ftp.c
>> Are we trying to remove NIPQUAD? 
> 
> That is a goal for me yes.
> Elimination of unnecessary stuff from kernel.h is useful.
> 
>> In my opinion the current code is
>> preferrable to open-coding NIPQUAD.
> 
> $ grep -r --include=*.[ch] NIPQUAD *
> include/linux/kernel.h:#define NIPQUAD(addr) \
> include/linux/kernel.h:#define NIPQUAD_FMT "%u.%u.%u.%u"
> net/netfilter/ipvs/ip_vs_ftp.c:		sprintf(buf, "%u,%u,%u,%u,%u,%u", NIPQUAD(from.ip),
> 
> As of right now NIPQUAD_FMT is unused and
> could be removed from kernel.h
> 
> There's 1 use of NIPQUAD.
> 
> Maybe instead of removal the #define could be
> moved to netfilter.h or netfilter_ipv4.h
> 
> Another is to consolidate the two uses of
> "%u,%u,%u,%u,%u,%u"
> 
> $ grep -r --include=*.[ch] "%u,%u,%u,%u,%u,u%" *
> fs/cachefiles/bind.c:	_enter("{%u,%u,%u,%u,%u,%u},%s",
> net/ipv4/netfilter/nf_nat_ftp.c:		return snprintf(buffer, buflen, "%u,%u,%u,%u,%u,%u",
> net/netfilter/ipvs/ip_vs_ftp.c:		sprintf(buf, "%u,%u,%u,%u,%u,%u", NIPQUAD(from.ip),
> 
> Maybe these 2 open coded sprintf/snprintf could be
> consolidated and moved to an appropriate include
> like netfilter_ipv4 or another.
> 
> What do you suggest?

Well, removing the last user sounds acceptable :) Applied, thanks.

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

* Re: [PATCH] net/netfilter/ipvs/ip_vs_ftp.c: Remove use of NIPQUAD
  2010-03-15 16:20 ` Patrick McHardy
  2010-03-15 16:58   ` Joe Perches
@ 2010-03-15 19:01   ` David Miller
  1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2010-03-15 19:01 UTC (permalink / raw)
  To: kaber; +Cc: joe, wensong, horms, ja, netdev, lvs-devel, linux-kernel

From: Patrick McHardy <kaber@trash.net>
Date: Mon, 15 Mar 2010 17:20:19 +0100

> Joe Perches wrote:
>> NIPQUAD has very few uses left.
>> 
>> Remove this use and make the code have the identical form of the only
>> other use of "%u,%u,%u,%u,%u,%u" in net/ipv4/netfilter/nf_nat_ftp.c
> 
> Are we trying to remove NIPQUAD?

Yes.


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

end of thread, other threads:[~2010-03-15 19:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-09  0:31 [PATCH] net/netfilter/ipvs/ip_vs_ftp.c: Remove use of NIPQUAD Joe Perches
2010-03-09  4:08 ` Simon Horman
2010-03-15 16:20 ` Patrick McHardy
2010-03-15 16:58   ` Joe Perches
2010-03-15 17:04     ` Patrick McHardy
2010-03-15 19:01   ` David Miller

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