* [PATCH 0/8] Remove most uses of NIPQUAD and NIPQUAD_FMT @ 2010-01-06 1:20 Joe Perches 2010-01-06 1:20 ` [PATCH 5/8] net/ipv4/netfilter/nf_nat_ftp.c: Convert NIPQUAD to %pI4 Joe Perches 2010-01-06 1:20 ` [PATCH 6/8] net/netfilter/ipvs/ip_vs_ftp.c: Use standardized format in sprintf Joe Perches 0 siblings, 2 replies; 7+ messages in thread From: Joe Perches @ 2010-01-06 1:20 UTC (permalink / raw) To: linux-kernel Cc: James E.J. Bottomley, Greg Kroah-Hartman, Mark Fasheh, Joel Becker, Patrick McHardy, David S. Miller, Alexey Kuznetsov, Pekka Savola (ipv6), James Morris, Hideaki YOSHIFUJI, Wensong Zhang, Simon Horman, Julian Anastasov, Andy Grover, J. Bruce Fields, Neil Brown, Trond Myklebust, linux-scsi, devel, ocfs2-devel, netfilter-devel, netfilter, coreteam, netdev, lvs-devel, rds Convert them to the %pI4 format extension where possible Only a couple uses are left in netfilter. Joe Perches (8): drivers/scsi: Remove uses of NIPQUAD, use %pI4 drivers/staging/pohmelfs/inode.c: Remove uses of NIPQUAD, use %pI4 net/rds: Remove uses of NIPQUAD, use %pI4 net/sunrpc: Remove uses of NIPQUAD, use %pI4 net/ipv4/netfilter/nf_nat_ftp.c: Convert NIPQUAD to %pI4 net/netfilter/ipvs/ip_vs_ftp.c: Use standardized format in sprintf fs/ocfs2/cluster/tcp.c: Remove use of NIPQUAD, use %pI4 drivers/firmware/iscsi_ibft.c: Remove NIPQUAD_FMT, use %pI4 drivers/firmware/iscsi_ibft.c | 8 +++----- drivers/scsi/bnx2i/bnx2i_iscsi.c | 4 ++-- drivers/scsi/cxgb3i/cxgb3i_iscsi.c | 5 ++--- drivers/scsi/cxgb3i/cxgb3i_offload.c | 7 ++++--- drivers/staging/pohmelfs/inode.c | 3 +-- fs/ocfs2/cluster/tcp.c | 4 ++-- net/ipv4/netfilter/nf_nat_ftp.c | 2 +- net/netfilter/ipvs/ip_vs_ftp.c | 2 +- net/rds/tcp_connect.c | 7 +++---- net/rds/tcp_listen.c | 6 +++--- net/rds/tcp_send.c | 4 ++-- net/sunrpc/xprtrdma/transport.c | 3 +-- net/sunrpc/xprtsock.c | 5 ++--- 13 files changed, 27 insertions(+), 33 deletions(-) ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 5/8] net/ipv4/netfilter/nf_nat_ftp.c: Convert NIPQUAD to %pI4 2010-01-06 1:20 [PATCH 0/8] Remove most uses of NIPQUAD and NIPQUAD_FMT Joe Perches @ 2010-01-06 1:20 ` Joe Perches 2010-01-06 19:23 ` [PATCH v2 5/8] net/ipv4/netfilter/nf_nat_ftp.c: Remove (*mangle[]) array and functions, use %pI4 Joe Perches 2010-01-06 1:20 ` [PATCH 6/8] net/netfilter/ipvs/ip_vs_ftp.c: Use standardized format in sprintf Joe Perches 1 sibling, 1 reply; 7+ messages in thread From: Joe Perches @ 2010-01-06 1:20 UTC (permalink / raw) To: linux-kernel Cc: Patrick McHardy, David S. Miller, Alexey Kuznetsov, Pekka Savola (ipv6), James Morris, Hideaki YOSHIFUJI, netfilter-devel, netfilter, coreteam, netdev Signed-off-by: Joe Perches <joe@perches.com> --- net/ipv4/netfilter/nf_nat_ftp.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/net/ipv4/netfilter/nf_nat_ftp.c b/net/ipv4/netfilter/nf_nat_ftp.c index a1d5d58..d1c5afc 100644 --- a/net/ipv4/netfilter/nf_nat_ftp.c +++ b/net/ipv4/netfilter/nf_nat_ftp.c @@ -59,7 +59,7 @@ mangle_eprt_packet(struct sk_buff *skb, { char buffer[sizeof("|1|255.255.255.255|65535|")]; - sprintf(buffer, "|1|%u.%u.%u.%u|%u|", NIPQUAD(newip), port); + sprintf(buffer, "|1|%pI4|%u|", &newip, port); pr_debug("calling nf_nat_mangle_tcp_packet\n"); -- 1.6.6.rc0.57.gad7a ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 5/8] net/ipv4/netfilter/nf_nat_ftp.c: Remove (*mangle[]) array and functions, use %pI4 2010-01-06 1:20 ` [PATCH 5/8] net/ipv4/netfilter/nf_nat_ftp.c: Convert NIPQUAD to %pI4 Joe Perches @ 2010-01-06 19:23 ` Joe Perches 2010-01-11 10:51 ` Patrick McHardy 0 siblings, 1 reply; 7+ messages in thread From: Joe Perches @ 2010-01-06 19:23 UTC (permalink / raw) To: linux-kernel Cc: Patrick McHardy, David S. Miller, Alexey Kuznetsov, Pekka Savola (ipv6), James Morris, Hideaki YOSHIFUJI, netfilter-devel, netfilter, coreteam, netdev These functions merely exist to format a buffer and call nf_nat_mangle_tcp_packet. Format the buffer and perform the call in nf_nat_ftp instead. Use %pI4 for the IP address. Saves ~600 bytes of text old: $ size net/ipv4/netfilter/nf_nat_ftp.o text data bss dec hex filename 2187 160 408 2755 ac3 net/ipv4/netfilter/nf_nat_ftp.o new: $ size net/ipv4/netfilter/nf_nat_ftp.o text data bss dec hex filename 1532 112 288 1932 78c net/ipv4/netfilter/nf_nat_ftp.o Signed-off-by: Joe Perches <joe@perches.com> net/ipv4/netfilter/nf_nat_ftp.c | 105 +++++++++++++-------------------------- 1 files changed, 35 insertions(+), 70 deletions(-) diff --git a/net/ipv4/netfilter/nf_nat_ftp.c b/net/ipv4/netfilter/nf_nat_ftp.c index a1d5d58..86e0e84 100644 --- a/net/ipv4/netfilter/nf_nat_ftp.c +++ b/net/ipv4/netfilter/nf_nat_ftp.c @@ -27,76 +27,29 @@ MODULE_ALIAS("ip_nat_ftp"); /* FIXME: Time out? --RR */ -static int -mangle_rfc959_packet(struct sk_buff *skb, - __be32 newip, - u_int16_t port, - unsigned int matchoff, - unsigned int matchlen, - struct nf_conn *ct, - enum ip_conntrack_info ctinfo) +static int nf_nat_ftp_fmt_cmd(enum nf_ct_ftp_type type, + char *buffer, size_t buflen, + __be32 addr, u16 port) { - char buffer[sizeof("nnn,nnn,nnn,nnn,nnn,nnn")]; - - sprintf(buffer, "%u,%u,%u,%u,%u,%u", - NIPQUAD(newip), port>>8, port&0xFF); - - pr_debug("calling nf_nat_mangle_tcp_packet\n"); - - return nf_nat_mangle_tcp_packet(skb, ct, ctinfo, matchoff, - matchlen, buffer, strlen(buffer)); -} - -/* |1|132.235.1.2|6275| */ -static int -mangle_eprt_packet(struct sk_buff *skb, - __be32 newip, - u_int16_t port, - unsigned int matchoff, - unsigned int matchlen, - struct nf_conn *ct, - enum ip_conntrack_info ctinfo) -{ - char buffer[sizeof("|1|255.255.255.255|65535|")]; - - sprintf(buffer, "|1|%u.%u.%u.%u|%u|", NIPQUAD(newip), port); - - pr_debug("calling nf_nat_mangle_tcp_packet\n"); - - return nf_nat_mangle_tcp_packet(skb, ct, ctinfo, matchoff, - matchlen, buffer, strlen(buffer)); -} - -/* |1|132.235.1.2|6275| */ -static int -mangle_epsv_packet(struct sk_buff *skb, - __be32 newip, - u_int16_t port, - unsigned int matchoff, - unsigned int matchlen, - struct nf_conn *ct, - enum ip_conntrack_info ctinfo) -{ - char buffer[sizeof("|||65535|")]; - - sprintf(buffer, "|||%u|", port); - - pr_debug("calling nf_nat_mangle_tcp_packet\n"); + switch (type) { + case NF_CT_FTP_PORT: + case NF_CT_FTP_PASV: + return snprintf(buffer, buflen, "%u,%u,%u,%u,%u,%u", + ((unsigned char *)&addr)[0], + ((unsigned char *)&addr)[1], + ((unsigned char *)&addr)[2], + ((unsigned char *)&addr)[3], + port >> 8, + port & 0xFF); + case NF_CT_FTP_EPRT: + return snprintf(buffer, buflen, "|1|%pI4|%u|", &addr, port); + case NF_CT_FTP_EPSV: + return snprintf(buffer, buflen, "|||%u|", port); + } - return nf_nat_mangle_tcp_packet(skb, ct, ctinfo, matchoff, - matchlen, buffer, strlen(buffer)); + return 0; } -static int (*mangle[])(struct sk_buff *, __be32, u_int16_t, - unsigned int, unsigned int, struct nf_conn *, - enum ip_conntrack_info) -= { - [NF_CT_FTP_PORT] = mangle_rfc959_packet, - [NF_CT_FTP_PASV] = mangle_rfc959_packet, - [NF_CT_FTP_EPRT] = mangle_eprt_packet, - [NF_CT_FTP_EPSV] = mangle_epsv_packet -}; - /* So, this packet has hit the connection tracking matching code. Mangle it, and change the expectation to match the new version. */ static unsigned int nf_nat_ftp(struct sk_buff *skb, @@ -110,6 +63,8 @@ static unsigned int nf_nat_ftp(struct sk_buff *skb, u_int16_t port; int dir = CTINFO2DIR(ctinfo); struct nf_conn *ct = exp->master; + char buffer[sizeof("|1|255.255.255.255|65535|")]; + unsigned int buflen; pr_debug("FTP_NAT: type %i, off %u len %u\n", type, matchoff, matchlen); @@ -132,11 +87,21 @@ static unsigned int nf_nat_ftp(struct sk_buff *skb, if (port == 0) return NF_DROP; - if (!mangle[type](skb, newip, port, matchoff, matchlen, ct, ctinfo)) { - nf_ct_unexpect_related(exp); - return NF_DROP; - } + buflen = nf_nat_ftp_fmt_cmd(type, buffer, sizeof(buffer), newip, port); + if (!buflen) + goto out; + + pr_debug("calling nf_nat_mangle_tcp_packet\n"); + + if (!nf_nat_mangle_tcp_packet(skb, ct, ctinfo, matchoff, + matchlen, buffer, buflen)) + goto out; + return NF_ACCEPT; + +out: + nf_ct_unexpect_related(exp); + return NF_DROP; } static void __exit nf_nat_ftp_fini(void) ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 5/8] net/ipv4/netfilter/nf_nat_ftp.c: Remove (*mangle[]) array and functions, use %pI4 2010-01-06 19:23 ` [PATCH v2 5/8] net/ipv4/netfilter/nf_nat_ftp.c: Remove (*mangle[]) array and functions, use %pI4 Joe Perches @ 2010-01-11 10:51 ` Patrick McHardy 0 siblings, 0 replies; 7+ messages in thread From: Patrick McHardy @ 2010-01-11 10:51 UTC (permalink / raw) To: Joe Perches Cc: linux-kernel, David S. Miller, Alexey Kuznetsov, Pekka Savola (ipv6), James Morris, Hideaki YOSHIFUJI, netfilter-devel, netfilter, coreteam, netdev Joe Perches wrote: > These functions merely exist to format a buffer and call > nf_nat_mangle_tcp_packet. > > Format the buffer and perform the call in nf_nat_ftp instead. > > Use %pI4 for the IP address. > > Saves ~600 bytes of text > > old: > $ size net/ipv4/netfilter/nf_nat_ftp.o > text data bss dec hex filename > 2187 160 408 2755 ac3 net/ipv4/netfilter/nf_nat_ftp.o > new: > $ size net/ipv4/netfilter/nf_nat_ftp.o > text data bss dec hex filename > 1532 112 288 1932 78c net/ipv4/netfilter/nf_nat_ftp.o Applied, thanks. BTW, its enough to CC netfilter-devel and optionally netdev on patches, netfilter and netfilter-core are unnecessary. ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 6/8] net/netfilter/ipvs/ip_vs_ftp.c: Use standardized format in sprintf 2010-01-06 1:20 [PATCH 0/8] Remove most uses of NIPQUAD and NIPQUAD_FMT Joe Perches 2010-01-06 1:20 ` [PATCH 5/8] net/ipv4/netfilter/nf_nat_ftp.c: Convert NIPQUAD to %pI4 Joe Perches @ 2010-01-06 1:20 ` Joe Perches 2010-01-06 2:34 ` Simon Horman 1 sibling, 1 reply; 7+ messages in thread From: Joe Perches @ 2010-01-06 1:20 UTC (permalink / raw) To: linux-kernel Cc: Wensong Zhang, Simon Horman, Julian Anastasov, Patrick McHardy, David S. Miller, netdev, lvs-devel, netfilter-devel, netfilter, coreteam Use the same format string as net/ipv4/netfilter/nf_nat_ftp.c to encode an ipv4 address and port. Both uses should be a single common function. Signed-off-by: Joe Perches <joe@perches.com> --- net/netfilter/ipvs/ip_vs_ftp.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c index 33e2c79..73f38ea 100644 --- a/net/netfilter/ipvs/ip_vs_ftp.c +++ b/net/netfilter/ipvs/ip_vs_ftp.c @@ -208,7 +208,7 @@ 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, "%d,%d,%d,%d,%d,%d", NIPQUAD(from.ip), + sprintf(buf, "%u,%u,%u,%u,%u,%u", NIPQUAD(from.ip), (ntohs(port)>>8)&255, ntohs(port)&255); buf_len = strlen(buf); -- 1.6.6.rc0.57.gad7a ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 6/8] net/netfilter/ipvs/ip_vs_ftp.c: Use standardized format in sprintf 2010-01-06 1:20 ` [PATCH 6/8] net/netfilter/ipvs/ip_vs_ftp.c: Use standardized format in sprintf Joe Perches @ 2010-01-06 2:34 ` Simon Horman 2010-01-11 10:54 ` Patrick McHardy 0 siblings, 1 reply; 7+ messages in thread From: Simon Horman @ 2010-01-06 2:34 UTC (permalink / raw) To: Joe Perches Cc: linux-kernel, Wensong Zhang, Julian Anastasov, Patrick McHardy, David S. Miller, netdev, lvs-devel, netfilter-devel, netfilter, coreteam On Tue, Jan 05, 2010 at 05:20:18PM -0800, Joe Perches wrote: > Use the same format string as net/ipv4/netfilter/nf_nat_ftp.c > to encode an ipv4 address and port. > > Both uses should be a single common function. > > Signed-off-by: Joe Perches <joe@perches.com> Acked-by: Simon Horman <horms@verge.net.au> > --- > net/netfilter/ipvs/ip_vs_ftp.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/net/netfilter/ipvs/ip_vs_ftp.c b/net/netfilter/ipvs/ip_vs_ftp.c > index 33e2c79..73f38ea 100644 > --- a/net/netfilter/ipvs/ip_vs_ftp.c > +++ b/net/netfilter/ipvs/ip_vs_ftp.c > @@ -208,7 +208,7 @@ 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, "%d,%d,%d,%d,%d,%d", NIPQUAD(from.ip), > + sprintf(buf, "%u,%u,%u,%u,%u,%u", NIPQUAD(from.ip), > (ntohs(port)>>8)&255, ntohs(port)&255); > buf_len = strlen(buf); > > -- > 1.6.6.rc0.57.gad7a > > -- > 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] 7+ messages in thread
* Re: [PATCH 6/8] net/netfilter/ipvs/ip_vs_ftp.c: Use standardized format in sprintf 2010-01-06 2:34 ` Simon Horman @ 2010-01-11 10:54 ` Patrick McHardy 0 siblings, 0 replies; 7+ messages in thread From: Patrick McHardy @ 2010-01-11 10:54 UTC (permalink / raw) To: Simon Horman Cc: Joe Perches, linux-kernel, Wensong Zhang, Julian Anastasov, David S. Miller, netdev, lvs-devel, netfilter-devel, netfilter, coreteam Simon Horman wrote: > On Tue, Jan 05, 2010 at 05:20:18PM -0800, Joe Perches wrote: >> Use the same format string as net/ipv4/netfilter/nf_nat_ftp.c >> to encode an ipv4 address and port. >> >> Both uses should be a single common function. >> >> Signed-off-by: Joe Perches <joe@perches.com> > > Acked-by: Simon Horman <horms@verge.net.au> Applied, thanks. ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2010-01-11 10:54 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-01-06 1:20 [PATCH 0/8] Remove most uses of NIPQUAD and NIPQUAD_FMT Joe Perches 2010-01-06 1:20 ` [PATCH 5/8] net/ipv4/netfilter/nf_nat_ftp.c: Convert NIPQUAD to %pI4 Joe Perches 2010-01-06 19:23 ` [PATCH v2 5/8] net/ipv4/netfilter/nf_nat_ftp.c: Remove (*mangle[]) array and functions, use %pI4 Joe Perches 2010-01-11 10:51 ` Patrick McHardy 2010-01-06 1:20 ` [PATCH 6/8] net/netfilter/ipvs/ip_vs_ftp.c: Use standardized format in sprintf Joe Perches 2010-01-06 2:34 ` Simon Horman 2010-01-11 10:54 ` Patrick McHardy
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).