fedora core 6 1.2949 + vserver 2.2.0
[linux-2.6.git] / net / ipv4 / ipvs / ip_vs_ftp.c
index a19a33c..687c1de 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/ip.h>
 #include <net/protocol.h>
 #include <net/tcp.h>
+#include <asm/unaligned.h>
 
 #include <net/ip_vs.h>
 
  * List of ports (up to IP_VS_APP_MAX_PORTS) to be handled by helper
  * First port is set to the default port.
  */
-static int ports[IP_VS_APP_MAX_PORTS] = {21, 0};
-module_param_array(ports, int, NULL, 0);
-
-/*
- *     Debug level
- */
-#ifdef CONFIG_IP_VS_DEBUG
-static int debug=0;
-module_param(debug, int, 0);
-#endif
+static unsigned short ports[IP_VS_APP_MAX_PORTS] = {21, 0};
+module_param_array(ports, ushort, NULL, 0);
+MODULE_PARM_DESC(ports, "Ports to monitor for FTP control commands");
 
 
 /*     Dummy variable */
@@ -81,7 +75,7 @@ ip_vs_ftp_done_conn(struct ip_vs_app *app, struct ip_vs_conn *cp)
  */
 static int ip_vs_ftp_get_addrport(char *data, char *data_limit,
                                  const char *pattern, size_t plen, char term,
-                                 __u32 *addr, __u16 *port,
+                                 __be32 *addr, __be16 *port,
                                  char **start, char **end)
 {
        unsigned char p[6];
@@ -121,8 +115,8 @@ static int ip_vs_ftp_get_addrport(char *data, char *data_limit,
        if (i != 5)
                return -1;
 
-       *addr = (p[3]<<24) | (p[2]<<16) | (p[1]<<8) | p[0];
-       *port = (p[5]<<8) | p[4];
+       *addr = get_unaligned((__be32 *)p);
+       *port = get_unaligned((__be16 *)(p + 4));
        return 1;
 }
 
@@ -147,8 +141,8 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
        struct tcphdr *th;
        char *data, *data_limit;
        char *start, *end;
-       __u32 from;
-       __u16 port;
+       __be32 from;
+       __be16 port;
        struct ip_vs_conn *n_cp;
        char buf[24];           /* xxx.xxx.xxx.xxx,ppp,ppp\000 */
        unsigned buf_len;
@@ -177,7 +171,7 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
                                           &start, &end) != 1)
                        return 1;
 
-               IP_VS_DBG(1-debug, "PASV response (%u.%u.%u.%u:%d) -> "
+               IP_VS_DBG(7, "PASV response (%u.%u.%u.%u:%d) -> "
                          "%u.%u.%u.%u:%d detected\n",
                          NIPQUAD(from), ntohs(port), NIPQUAD(cp->caddr), 0);
 
@@ -206,7 +200,7 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
                from = n_cp->vaddr;
                port = n_cp->vport;
                sprintf(buf,"%d,%d,%d,%d,%d,%d", NIPQUAD(from),
-                       port&255, (port>>8)&255);
+                       (ntohs(port)>>8)&255, ntohs(port)&255);
                buf_len = strlen(buf);
 
                /*
@@ -250,8 +244,8 @@ static int ip_vs_ftp_in(struct ip_vs_app *app, struct ip_vs_conn *cp,
        struct tcphdr *th;
        char *data, *data_start, *data_limit;
        char *start, *end;
-       __u32 to;
-       __u16 port;
+       __be32 to;
+       __be16 port;
        struct ip_vs_conn *n_cp;
 
        /* no diff required for incoming packets */
@@ -280,7 +274,7 @@ static int ip_vs_ftp_in(struct ip_vs_app *app, struct ip_vs_conn *cp,
        while (data <= data_limit - 6) {
                if (strnicmp(data, "PASV\r\n", 6) == 0) {
                        /* Passive mode on */
-                       IP_VS_DBG(1-debug, "got PASV at %zd of %zd\n",
+                       IP_VS_DBG(7, "got PASV at %td of %td\n",
                                  data - data_start,
                                  data_limit - data_start);
                        cp->app_data = &ip_vs_ftp_pasv;
@@ -302,7 +296,7 @@ static int ip_vs_ftp_in(struct ip_vs_app *app, struct ip_vs_conn *cp,
                                   &start, &end) != 1)
                return 1;
 
-       IP_VS_DBG(1-debug, "PORT %u.%u.%u.%u:%d detected\n",
+       IP_VS_DBG(7, "PORT %u.%u.%u.%u:%d detected\n",
                  NIPQUAD(to), ntohs(port));
 
        /* Passive mode off */
@@ -311,7 +305,7 @@ static int ip_vs_ftp_in(struct ip_vs_app *app, struct ip_vs_conn *cp,
        /*
         * Now update or create a connection entry for it
         */
-       IP_VS_DBG(1-debug, "protocol %s %u.%u.%u.%u:%d %u.%u.%u.%u:%d\n",
+       IP_VS_DBG(7, "protocol %s %u.%u.%u.%u:%d %u.%u.%u.%u:%d\n",
                  ip_vs_proto_name(iph->protocol),
                  NIPQUAD(to), ntohs(port), NIPQUAD(cp->vaddr), 0);
 
@@ -375,8 +369,8 @@ static int __init ip_vs_ftp_init(void)
                ret = register_ip_vs_app_inc(app, app->protocol, ports[i]);
                if (ret)
                        break;
-               IP_VS_DBG(1-debug, "%s: loaded support on port[%d] = %d\n",
-                         app->name, i, ports[i]);
+               IP_VS_INFO("%s: loaded support on port[%d] = %d\n",
+                          app->name, i, ports[i]);
        }
 
        if (ret)