2010-01-06 01:20:30

by Joe Perches

[permalink] [raw]
Subject: [PATCH 0/8] Remove most uses of NIPQUAD and NIPQUAD_FMT

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


2010-01-06 01:20:48

by Joe Perches

[permalink] [raw]
Subject: [PATCH 8/8] drivers/firmware/iscsi_ibft.c: Remove NIPQUAD_FMT, use %pI4

Convert netmask to __be32 and format it with %pI4

Signed-off-by: Joe Perches <[email protected]>
---
drivers/firmware/iscsi_ibft.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/firmware/iscsi_ibft.c b/drivers/firmware/iscsi_ibft.c
index 051d1eb..f82bcda 100644
--- a/drivers/firmware/iscsi_ibft.c
+++ b/drivers/firmware/iscsi_ibft.c
@@ -381,7 +381,7 @@ static ssize_t ibft_attr_show_nic(struct ibft_kobject *entry,
void *ibft_loc = entry->header;
char *str = buf;
char *mac;
- int val;
+ __be32 val;

if (!nic)
return 0;
@@ -397,10 +397,8 @@ static ssize_t ibft_attr_show_nic(struct ibft_kobject *entry,
str += sprintf_ipaddr(str, nic->ip_addr);
break;
case ibft_eth_subnet_mask:
- val = ~((1 << (32-nic->subnet_mask_prefix))-1);
- str += sprintf(str, NIPQUAD_FMT,
- (u8)(val >> 24), (u8)(val >> 16),
- (u8)(val >> 8), (u8)(val));
+ val = cpu_to_be32(~((1 << (32-nic->subnet_mask_prefix))-1));
+ str += sprintf(str, "%pI4", &val);
break;
case ibft_eth_origin:
str += sprintf(str, "%d\n", nic->origin);
--
1.6.6.rc0.57.gad7a

2010-01-06 01:20:50

by Joe Perches

[permalink] [raw]
Subject: [PATCH 7/8] fs/ocfs2/cluster/tcp.c: Remove use of NIPQUAD, use %pI4

Signed-off-by: Joe Perches <[email protected]>
---
fs/ocfs2/cluster/tcp.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c
index 334f231..7a9620e 100644
--- a/fs/ocfs2/cluster/tcp.c
+++ b/fs/ocfs2/cluster/tcp.c
@@ -72,9 +72,9 @@

#include "tcp_internal.h"

-#define SC_NODEF_FMT "node %s (num %u) at %u.%u.%u.%u:%u"
+#define SC_NODEF_FMT "node %s (num %u) at %pI4:%u"
#define SC_NODEF_ARGS(sc) sc->sc_node->nd_name, sc->sc_node->nd_num, \
- NIPQUAD(sc->sc_node->nd_ipv4_address), \
+ &sc->sc_node->nd_ipv4_address, \
ntohs(sc->sc_node->nd_ipv4_port)

/*
--
1.6.6.rc0.57.gad7a

2010-01-06 01:21:12

by Joe Perches

[permalink] [raw]
Subject: [PATCH 5/8] net/ipv4/netfilter/nf_nat_ftp.c: Convert NIPQUAD to %pI4

Signed-off-by: Joe Perches <[email protected]>
---
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

2010-01-06 01:20:26

by Joe Perches

[permalink] [raw]
Subject: [PATCH 1/8] drivers/scsi: Remove uses of NIPQUAD, use %pI4

Signed-off-by: Joe Perches <[email protected]>
---
drivers/scsi/bnx2i/bnx2i_iscsi.c | 4 ++--
drivers/scsi/cxgb3i/cxgb3i_iscsi.c | 5 ++---
drivers/scsi/cxgb3i/cxgb3i_offload.c | 7 ++++---
3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/scsi/bnx2i/bnx2i_iscsi.c b/drivers/scsi/bnx2i/bnx2i_iscsi.c
index 33b2294..51709cb 100644
--- a/drivers/scsi/bnx2i/bnx2i_iscsi.c
+++ b/drivers/scsi/bnx2i/bnx2i_iscsi.c
@@ -1426,8 +1426,8 @@ static int bnx2i_conn_get_param(struct iscsi_cls_conn *cls_conn,
break;
case ISCSI_PARAM_CONN_ADDRESS:
if (bnx2i_conn->ep)
- len = sprintf(buf, NIPQUAD_FMT "\n",
- NIPQUAD(bnx2i_conn->ep->cm_sk->dst_ip));
+ len = sprintf(buf, "%pI4\n",
+ &bnx2i_conn->ep->cm_sk->dst_ip);
break;
default:
return iscsi_conn_get_param(cls_conn, param, buf);
diff --git a/drivers/scsi/cxgb3i/cxgb3i_iscsi.c b/drivers/scsi/cxgb3i/cxgb3i_iscsi.c
index 969c831..1fd89b2 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_iscsi.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_iscsi.c
@@ -591,8 +591,7 @@ static int cxgb3i_conn_bind(struct iscsi_cls_session *cls_session,
cxgb3i_conn_max_recv_dlength(conn);

spin_lock_bh(&conn->session->lock);
- sprintf(conn->portal_address, NIPQUAD_FMT,
- NIPQUAD(c3cn->daddr.sin_addr.s_addr));
+ sprintf(conn->portal_address, "%pI4", &c3cn->daddr.sin_addr.s_addr);
conn->portal_port = ntohs(c3cn->daddr.sin_port);
spin_unlock_bh(&conn->session->lock);

@@ -753,7 +752,7 @@ static int cxgb3i_host_get_param(struct Scsi_Host *shost,
__be32 addr;

addr = cxgb3i_get_private_ipv4addr(hba->ndev);
- len = sprintf(buf, NIPQUAD_FMT, NIPQUAD(addr));
+ len = sprintf(buf, "%pI4", &addr);
break;
}
default:
diff --git a/drivers/scsi/cxgb3i/cxgb3i_offload.c b/drivers/scsi/cxgb3i/cxgb3i_offload.c
index 26ffdcd..edef61c 100644
--- a/drivers/scsi/cxgb3i/cxgb3i_offload.c
+++ b/drivers/scsi/cxgb3i/cxgb3i_offload.c
@@ -1643,10 +1643,11 @@ int cxgb3i_c3cn_connect(struct net_device *dev, struct s3_conn *c3cn,
} else
c3cn->saddr.sin_addr.s_addr = sipv4;

- c3cn_conn_debug("c3cn 0x%p, %u.%u.%u.%u,%u-%u.%u.%u.%u,%u SYN_SENT.\n",
- c3cn, NIPQUAD(c3cn->saddr.sin_addr.s_addr),
+ c3cn_conn_debug("c3cn 0x%p, %pI4,%u-%pI4,%u SYN_SENT.\n",
+ c3cn,
+ &c3cn->saddr.sin_addr.s_addr,
ntohs(c3cn->saddr.sin_port),
- NIPQUAD(c3cn->daddr.sin_addr.s_addr),
+ &c3cn->daddr.sin_addr.s_addr,
ntohs(c3cn->daddr.sin_port));

c3cn_set_state(c3cn, C3CN_STATE_CONNECTING);
--
1.6.6.rc0.57.gad7a

2010-01-06 01:22:22

by Joe Perches

[permalink] [raw]
Subject: [PATCH 4/8] net/sunrpc: Remove uses of NIPQUAD, use %pI4

Signed-off-by: Joe Perches <[email protected]>
---
net/sunrpc/xprtrdma/transport.c | 3 +--
net/sunrpc/xprtsock.c | 5 ++---
2 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/net/sunrpc/xprtrdma/transport.c b/net/sunrpc/xprtrdma/transport.c
index 7018eef..83d339f 100644
--- a/net/sunrpc/xprtrdma/transport.c
+++ b/net/sunrpc/xprtrdma/transport.c
@@ -165,8 +165,7 @@ xprt_rdma_format_addresses(struct rpc_xprt *xprt)

xprt->address_strings[RPC_DISPLAY_PROTO] = "rdma";

- (void)snprintf(buf, sizeof(buf), "%02x%02x%02x%02x",
- NIPQUAD(sin->sin_addr.s_addr));
+ (void)snprintf(buf, sizeof(buf), "%08x", ntohl(sin->sin_addr.s_addr));
xprt->address_strings[RPC_DISPLAY_HEX_ADDR] = kstrdup(buf, GFP_KERNEL);

(void)snprintf(buf, sizeof(buf), "%4hx", rpc_get_port(sap));
diff --git a/net/sunrpc/xprtsock.c b/net/sunrpc/xprtsock.c
index 3d739e5..86234bc 100644
--- a/net/sunrpc/xprtsock.c
+++ b/net/sunrpc/xprtsock.c
@@ -297,12 +297,11 @@ static void xs_format_common_peer_addresses(struct rpc_xprt *xprt)
switch (sap->sa_family) {
case AF_INET:
sin = xs_addr_in(xprt);
- (void)snprintf(buf, sizeof(buf), "%02x%02x%02x%02x",
- NIPQUAD(sin->sin_addr.s_addr));
+ snprintf(buf, sizeof(buf), "%08x", ntohl(sin->sin_addr.s_addr));
break;
case AF_INET6:
sin6 = xs_addr_in6(xprt);
- (void)snprintf(buf, sizeof(buf), "%pi6", &sin6->sin6_addr);
+ snprintf(buf, sizeof(buf), "%pi6", &sin6->sin6_addr);
break;
default:
BUG();
--
1.6.6.rc0.57.gad7a

2010-01-06 01:21:31

by Joe Perches

[permalink] [raw]
Subject: [PATCH 6/8] net/netfilter/ipvs/ip_vs_ftp.c: Use standardized format in sprintf

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 <[email protected]>
---
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

2010-01-06 01:21:46

by Joe Perches

[permalink] [raw]
Subject: [PATCH 2/8] drivers/staging/pohmelfs/inode.c: Remove uses of NIPQUAD, use %pI4

Signed-off-by: Joe Perches <[email protected]>
---
drivers/staging/pohmelfs/inode.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/pohmelfs/inode.c b/drivers/staging/pohmelfs/inode.c
index f69b778..e286fd1 100644
--- a/drivers/staging/pohmelfs/inode.c
+++ b/drivers/staging/pohmelfs/inode.c
@@ -1767,8 +1767,7 @@ static int pohmelfs_show_stats(struct seq_file *m, struct vfsmount *mnt)
seq_printf(m, "%u ", ctl->idx);
if (ctl->addr.sa_family == AF_INET) {
struct sockaddr_in *sin = (struct sockaddr_in *)&st->ctl.addr;
- /* seq_printf(m, "%pi4:%u", &sin->sin_addr.s_addr, ntohs(sin->sin_port)); */
- seq_printf(m, "%u.%u.%u.%u:%u", NIPQUAD(sin->sin_addr.s_addr), ntohs(sin->sin_port));
+ seq_printf(m, "%pI4:%u", &sin->sin_addr.s_addr, ntohs(sin->sin_port));
} else if (ctl->addr.sa_family == AF_INET6) {
struct sockaddr_in6 *sin = (struct sockaddr_in6 *)&st->ctl.addr;
seq_printf(m, "%pi6:%u", &sin->sin6_addr, ntohs(sin->sin6_port));
--
1.6.6.rc0.57.gad7a

2010-01-06 01:22:25

by Joe Perches

[permalink] [raw]
Subject: [PATCH 3/8] net/rds: Remove uses of NIPQUAD, use %pI4

Signed-off-by: Joe Perches <[email protected]>
---
net/rds/tcp_connect.c | 7 +++----
net/rds/tcp_listen.c | 6 +++---
net/rds/tcp_send.c | 4 ++--
3 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/net/rds/tcp_connect.c b/net/rds/tcp_connect.c
index 211522f..0562562 100644
--- a/net/rds/tcp_connect.c
+++ b/net/rds/tcp_connect.c
@@ -90,8 +90,8 @@ int rds_tcp_conn_connect(struct rds_connection *conn)

ret = sock->ops->bind(sock, (struct sockaddr *)&src, sizeof(src));
if (ret) {
- rdsdebug("bind failed with %d at address %u.%u.%u.%u\n",
- ret, NIPQUAD(conn->c_laddr));
+ rdsdebug("bind failed with %d at address %pI4\n",
+ ret, &conn->c_laddr);
goto out;
}

@@ -108,8 +108,7 @@ int rds_tcp_conn_connect(struct rds_connection *conn)
O_NONBLOCK);
sock = NULL;

- rdsdebug("connect to address %u.%u.%u.%u returned %d\n",
- NIPQUAD(conn->c_faddr), ret);
+ rdsdebug("connect to address %pI4 returned %d\n", &conn->c_faddr, ret);
if (ret == -EINPROGRESS)
ret = 0;

diff --git a/net/rds/tcp_listen.c b/net/rds/tcp_listen.c
index 45474a4..53cb1b5 100644
--- a/net/rds/tcp_listen.c
+++ b/net/rds/tcp_listen.c
@@ -66,9 +66,9 @@ static int rds_tcp_accept_one(struct socket *sock)

inet = inet_sk(new_sock->sk);

- rdsdebug("accepted tcp %u.%u.%u.%u:%u -> %u.%u.%u.%u:%u\n",
- NIPQUAD(inet->inet_saddr), ntohs(inet->inet_sport),
- NIPQUAD(inet->inet_daddr), ntohs(inet->inet_dport));
+ rdsdebug("accepted tcp %pI4:%u -> %pI4:%u\n",
+ &inet->inet_saddr, ntohs(inet->inet_sport),
+ &inet->inet_daddr, ntohs(inet->inet_dport));

conn = rds_conn_create(inet->inet_saddr, inet->inet_daddr,
&rds_tcp_transport, GFP_KERNEL);
diff --git a/net/rds/tcp_send.c b/net/rds/tcp_send.c
index ab545e0..34fdcc0 100644
--- a/net/rds/tcp_send.c
+++ b/net/rds/tcp_send.c
@@ -193,9 +193,9 @@ out:
rds_tcp_stats_inc(s_tcp_sndbuf_full);
ret = 0;
} else {
- printk(KERN_WARNING "RDS/tcp: send to %u.%u.%u.%u "
+ printk(KERN_WARNING "RDS/tcp: send to %pI4 "
"returned %d, disconnecting and reconnecting\n",
- NIPQUAD(conn->c_faddr), ret);
+ &conn->c_faddr, ret);
rds_conn_drop(conn);
}
}
--
1.6.6.rc0.57.gad7a

2010-01-06 02:34:26

by Simon Horman

[permalink] [raw]
Subject: Re: [PATCH 6/8] net/netfilter/ipvs/ip_vs_ftp.c: Use standardized format in sprintf

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 <[email protected]>

Acked-by: Simon Horman <[email protected]>

> ---
> 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 [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2010-01-06 19:23:22

by Joe Perches

[permalink] [raw]
Subject: [PATCH v2 5/8] net/ipv4/netfilter/nf_nat_ftp.c: Remove (*mangle[]) array and functions, use %pI4

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 <[email protected]>

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)

2010-01-07 01:52:30

by Joel Becker

[permalink] [raw]
Subject: Re: [PATCH 7/8] fs/ocfs2/cluster/tcp.c: Remove use of NIPQUAD, use %pI4

On Tue, Jan 05, 2010 at 05:20:19PM -0800, Joe Perches wrote:
> Signed-off-by: Joe Perches <[email protected]>
Acked-by: Joel Becker <[email protected]>


--

The Graham Corollary:

The longer a socially-moderated news website exists, the
probability of an old Paul Graham link appearing at the top
approaches certainty.

Joel Becker
Principal Software Developer
Oracle
E-mail: [email protected]
Phone: (650) 506-8127

2010-01-11 10:51:52

by Patrick McHardy

[permalink] [raw]
Subject: Re: [PATCH v2 5/8] net/ipv4/netfilter/nf_nat_ftp.c: Remove (*mangle[]) array and functions, use %pI4

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.

2010-01-11 10:54:23

by Patrick McHardy

[permalink] [raw]
Subject: Re: [PATCH 6/8] net/netfilter/ipvs/ip_vs_ftp.c: Use standardized format in sprintf

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 <[email protected]>
>
> Acked-by: Simon Horman <[email protected]>

Applied, thanks.

2010-01-11 11:09:46

by Joe Perches

[permalink] [raw]
Subject: [PATCH] MAINTAINERS: netfilter - Remove netfilter and netfilter-core lists

On Mon, 2010-01-11 at 11:51 +0100, Patrick McHardy wrote:
> it's enough to CC netfilter-devel and optionally
> netdev on patches, netfilter and netfilter-core are unnecessary.

Signed-off-by: Joe Perches <[email protected]>

diff --git a/MAINTAINERS b/MAINTAINERS
index 745643b..860d04f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3742,8 +3742,6 @@ P: Harald Welte
P: Jozsef Kadlecsik
M: Patrick McHardy <[email protected]>
L: [email protected]
-L: [email protected]
-L: [email protected]
W: http://www.netfilter.org/
W: http://www.iptables.org/
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git



2010-01-11 11:14:23

by Patrick McHardy

[permalink] [raw]
Subject: Re: [PATCH] MAINTAINERS: netfilter - Remove netfilter and netfilter-core lists

Joe Perches wrote:
> On Mon, 2010-01-11 at 11:51 +0100, Patrick McHardy wrote:
>> it's enough to CC netfilter-devel and optionally
>> netdev on patches, netfilter and netfilter-core are unnecessary.
>
> Signed-off-by: Joe Perches <[email protected]>
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 745643b..860d04f 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -3742,8 +3742,6 @@ P: Harald Welte
> P: Jozsef Kadlecsik
> M: Patrick McHardy <[email protected]>
> L: [email protected]
> -L: [email protected]
> -L: [email protected]

A comment stating the purpose of each list would be more approriate IMO.
netfilter-devel is for developers and patches, netfilter is for users
and netfilter-core is only meant to reach the coreteam privately.

2010-01-11 11:27:52

by Joe Perches

[permalink] [raw]
Subject: [PATCH V2] MAINTAINERS: netfilter - Document netfilter and netfilter-core lists purposes

> On Mon, 2010-01-11 at 11:51 +0100, Patrick McHardy wrote:
> it's enough to CC netfilter-devel and optionally
> netdev on patches, netfilter and netfilter-core are unnecessary.
> On Mon, 2010-01-11 at 12:14 +0100, Patrick McHardy wrote:
> A comment stating the purpose of each list would be more appropriate.
> netfilter-devel is for developers and patches, netfilter is for users
> and netfilter-core is only meant to reach the coreteam privately.

Adding "subscribers-only" after the list address stops
scripts/get_maintainer.pl from including the address
unless --s is used. Doesn't matter if the list really
is subscribers-only or not.

Signed-off-by: Joe Perches <[email protected]>

diff --git a/MAINTAINERS b/MAINTAINERS
index 745643b..ea5ddc8 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3742,8 +3742,8 @@ P: Harald Welte
P: Jozsef Kadlecsik
M: Patrick McHardy <[email protected]>
L: [email protected]
-L: [email protected]
-L: [email protected]
+L: [email protected] for user issues, not subscribers-only
+L: [email protected] for private emails, not subscribers-only
W: http://www.netfilter.org/
W: http://www.iptables.org/
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git

2010-01-11 11:31:19

by Jan Engelhardt

[permalink] [raw]
Subject: Re: [PATCH V2] MAINTAINERS: netfilter - Document netfilter and netfilter-core lists purposes


On Monday 2010-01-11 12:27, Joe Perches wrote:

>Adding "subscribers-only" after the list address stops
>scripts/get_maintainer.pl from including the address
>unless --s is used. Doesn't matter if the list really
>is subscribers-only or not.
>
>Signed-off-by: Joe Perches <[email protected]>
>
>+++ b/MAINTAINERS
>@@ -3742,8 +3742,8 @@ P: Harald Welte
> P: Jozsef Kadlecsik
> M: Patrick McHardy <[email protected]>
> L: [email protected]
>-L: [email protected]
>-L: [email protected]
>+L: [email protected] for user issues, not subscribers-only
>+L: [email protected] for private emails, not subscribers-only
> W: http://www.netfilter.org/

This is a little stab-through-the-back -
rather than "subscribers-only", I'd use "subscriber-free" or FFA,
or just leave it blank and use "subscribers-only" instead
for these.

L: [email protected]
L: [email protected] subscribers-only

> W: http://www.iptables.org/

netfilter.org/

2010-01-11 11:43:54

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH V2] MAINTAINERS: netfilter - Document netfilter and netfilter-core lists purposes

On Mon, 2010-01-11 at 12:31 +0100, Jan Engelhardt wrote:
> On Monday 2010-01-11 12:27, Joe Perches wrote:
> >Adding "subscribers-only" after the list address stops
> >scripts/get_maintainer.pl from including the address
> >unless --s is used. Doesn't matter if the list really
> >is subscribers-only or not.

> This is a little stab-through-the-back -
> rather than "subscribers-only", I'd use "subscriber-free" or FFA,
> or just leave it blank and use "subscribers-only" instead
> for these.

You're welcome and free to change the script
and MAINTAINERS.

I think this works well-enough though.

cheers, Joe

2010-01-12 19:31:06

by Joe Perches

[permalink] [raw]
Subject: [PATCH V3] MAINTAINERS: Document list types, add "A:" section type, update NETFILTER

On Mon, 2010-01-11 at 12:31 +0100, Jan Engelhardt wrote:
> This is a little stab-through-the-back -
> rather than "subscribers-only", I'd use "subscriber-free" or FFA,
> or just leave it blank and use "subscribers-only" instead
> for these.

Here's another option:

Signed-off-by: Joe Perches <[email protected]>

diff --git a/MAINTAINERS b/MAINTAINERS
index 745643b..8abf3be 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -69,7 +69,20 @@ Descriptions of section entries:

P: Person (obsolete)
M: Mail patches to: FullName <address@domain>
- L: Mailing list that is relevant to this area
+ L: Mailing list that should receive patches, bug reports or
+ developer questions.
+ Mailing lists can be one of:
+ (open list): the default, unmarked case
+ Subscription to the list is not required, but emails
+ may be rejected by spam filters without notification.
+ (moderated for non-subscribers):
+ emails from non-subscribers are actively filtered
+ and may be arbitrarily delayed or rejected without
+ notification if off-topic. Upon receipt of the email,
+ a moderation notification email may be automatically
+ sent by the list manager.
+ (subscribers-only):
+ emails from non-subscribers are not accepted.
W: Web-page with status/info
T: SCM tree type and location. Type is one of: git, hg, quilt, stgit.
S: Status, one of the following:
@@ -102,6 +115,7 @@ Descriptions of section entries:
matches patches or files that contain one or more of the words
printk, pr_info or pr_err
One regex pattern per line. Multiple K: lines acceptable.
+ A: Additional useful unstructured information.

Note: For the hard of thinking, this list is meant to remain in alphabetical
order. If you could add yourselves to it in alphabetical order that would be
@@ -3742,8 +3756,8 @@ P: Harald Welte
P: Jozsef Kadlecsik
M: Patrick McHardy <[email protected]>
L: [email protected]
-L: [email protected]
-L: [email protected]
+A: [email protected] (email list for user issues)
+A: [email protected] (private emails to core developers)
W: http://www.netfilter.org/
W: http://www.iptables.org/
T: git git://git.kernel.org/pub/scm/linux/kernel/git/kaber/nf-2.6.git

2010-01-13 15:15:31

by Stefan Richter

[permalink] [raw]
Subject: Re: [PATCH V3] MAINTAINERS: Document list types, add "A:" section type, update NETFILTER

Joe Perches wrote:
> + A: Additional useful unstructured information.

Can be implemented with a level of indirection via the W: entries.
--
Stefan Richter
-=====-==-=- ---= -==-=
http://arcgraph.de/sr/

2010-01-13 16:15:06

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH V3] MAINTAINERS: Document list types, add "A:" section type, update NETFILTER

On Wed, 2010-01-13 at 16:13 +0100, Stefan Richter wrote:
> Joe Perches wrote:
> > + A: Additional useful unstructured information.
> Can be implemented with a level of indirection via the W: entries.

Mailing lists aren't web addresses.

2010-01-13 17:12:09

by Stefan Richter

[permalink] [raw]
Subject: Re: [PATCH V3] MAINTAINERS: Document list types, add "A:" section type, update NETFILTER

Joe Perches wrote:
> On Wed, 2010-01-13 at 16:13 +0100, Stefan Richter wrote:
>> Joe Perches wrote:
>> > + A: Additional useful unstructured information.
>> Can be implemented with a level of indirection via the W: entries.
>
> Mailing lists aren't web addresses.

Project web sites typically contain contact pages (which is what you
used the first two proposed A: entries for --- contacts that apparently
do not play a role for patch submission), and web sites can carry any
other "unstructured information".

Keep redundancy low.
--
Stefan Richter
-=====-==-=- ---= -==-=
http://arcgraph.de/sr/

2010-01-15 20:04:00

by Pavel Machek

[permalink] [raw]
Subject: Re: [PATCH V3] MAINTAINERS: Document list types, add "A:" section type, update NETFILTER

On Wed 2010-01-13 18:10:28, Stefan Richter wrote:
> Joe Perches wrote:
> > On Wed, 2010-01-13 at 16:13 +0100, Stefan Richter wrote:
> >> Joe Perches wrote:
> >> > + A: Additional useful unstructured information.
> >> Can be implemented with a level of indirection via the W: entries.
> >
> > Mailing lists aren't web addresses.
>
> Project web sites typically contain contact pages (which is what you
> used the first two proposed A: entries for --- contacts that apparently
> do not play a role for patch submission), and web sites can carry any
> other "unstructured information".
>
> Keep redundancy low.

Well, I'd say that kernel maintainance info should be
kept... well... in kernel...
Pavel

--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html