aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4/ipvs
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4/ipvs')
-rw-r--r--net/ipv4/ipvs/ip_vs_conn.c24
-rw-r--r--net/ipv4/ipvs/ip_vs_core.c14
-rw-r--r--net/ipv4/ipvs/ip_vs_ctl.c36
-rw-r--r--net/ipv4/ipvs/ip_vs_dh.c4
-rw-r--r--net/ipv4/ipvs/ip_vs_est.c4
-rw-r--r--net/ipv4/ipvs/ip_vs_ftp.c42
-rw-r--r--net/ipv4/ipvs/ip_vs_lblc.c8
-rw-r--r--net/ipv4/ipvs/ip_vs_lblcr.c8
-rw-r--r--net/ipv4/ipvs/ip_vs_proto.c2
-rw-r--r--net/ipv4/ipvs/ip_vs_proto_tcp.c18
-rw-r--r--net/ipv4/ipvs/ip_vs_proto_udp.c22
-rw-r--r--net/ipv4/ipvs/ip_vs_sh.c4
-rw-r--r--net/ipv4/ipvs/ip_vs_sync.c18
-rw-r--r--net/ipv4/ipvs/ip_vs_xmit.c2
14 files changed, 97 insertions, 109 deletions
diff --git a/net/ipv4/ipvs/ip_vs_conn.c b/net/ipv4/ipvs/ip_vs_conn.c
index 87b83813cf2c..8832eb517d52 100644
--- a/net/ipv4/ipvs/ip_vs_conn.c
+++ b/net/ipv4/ipvs/ip_vs_conn.c
@@ -115,9 +115,9 @@ static inline void ct_write_unlock_bh(unsigned key)
115/* 115/*
116 * Returns hash value for IPVS connection entry 116 * Returns hash value for IPVS connection entry
117 */ 117 */
118static unsigned int ip_vs_conn_hashkey(unsigned proto, __u32 addr, __u16 port) 118static unsigned int ip_vs_conn_hashkey(unsigned proto, __be32 addr, __be16 port)
119{ 119{
120 return jhash_3words(addr, port, proto, ip_vs_conn_rnd) 120 return jhash_3words((__force u32)addr, (__force u32)port, proto, ip_vs_conn_rnd)
121 & IP_VS_CONN_TAB_MASK; 121 & IP_VS_CONN_TAB_MASK;
122} 122}
123 123
@@ -188,7 +188,7 @@ static inline int ip_vs_conn_unhash(struct ip_vs_conn *cp)
188 * d_addr, d_port: pkt dest address (load balancer) 188 * d_addr, d_port: pkt dest address (load balancer)
189 */ 189 */
190static inline struct ip_vs_conn *__ip_vs_conn_in_get 190static inline struct ip_vs_conn *__ip_vs_conn_in_get
191(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port) 191(int protocol, __be32 s_addr, __be16 s_port, __be32 d_addr, __be16 d_port)
192{ 192{
193 unsigned hash; 193 unsigned hash;
194 struct ip_vs_conn *cp; 194 struct ip_vs_conn *cp;
@@ -215,7 +215,7 @@ static inline struct ip_vs_conn *__ip_vs_conn_in_get
215} 215}
216 216
217struct ip_vs_conn *ip_vs_conn_in_get 217struct ip_vs_conn *ip_vs_conn_in_get
218(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port) 218(int protocol, __be32 s_addr, __be16 s_port, __be32 d_addr, __be16 d_port)
219{ 219{
220 struct ip_vs_conn *cp; 220 struct ip_vs_conn *cp;
221 221
@@ -234,7 +234,7 @@ struct ip_vs_conn *ip_vs_conn_in_get
234 234
235/* Get reference to connection template */ 235/* Get reference to connection template */
236struct ip_vs_conn *ip_vs_ct_in_get 236struct ip_vs_conn *ip_vs_ct_in_get
237(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port) 237(int protocol, __be32 s_addr, __be16 s_port, __be32 d_addr, __be16 d_port)
238{ 238{
239 unsigned hash; 239 unsigned hash;
240 struct ip_vs_conn *cp; 240 struct ip_vs_conn *cp;
@@ -274,7 +274,7 @@ struct ip_vs_conn *ip_vs_ct_in_get
274 * d_addr, d_port: pkt dest address (foreign host) 274 * d_addr, d_port: pkt dest address (foreign host)
275 */ 275 */
276struct ip_vs_conn *ip_vs_conn_out_get 276struct ip_vs_conn *ip_vs_conn_out_get
277(int protocol, __u32 s_addr, __u16 s_port, __u32 d_addr, __u16 d_port) 277(int protocol, __be32 s_addr, __be16 s_port, __be32 d_addr, __be16 d_port)
278{ 278{
279 unsigned hash; 279 unsigned hash;
280 struct ip_vs_conn *cp, *ret=NULL; 280 struct ip_vs_conn *cp, *ret=NULL;
@@ -324,7 +324,7 @@ void ip_vs_conn_put(struct ip_vs_conn *cp)
324/* 324/*
325 * Fill a no_client_port connection with a client port number 325 * Fill a no_client_port connection with a client port number
326 */ 326 */
327void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __u16 cport) 327void ip_vs_conn_fill_cport(struct ip_vs_conn *cp, __be16 cport)
328{ 328{
329 if (ip_vs_conn_unhash(cp)) { 329 if (ip_vs_conn_unhash(cp)) {
330 spin_lock(&cp->lock); 330 spin_lock(&cp->lock);
@@ -508,10 +508,10 @@ int ip_vs_check_template(struct ip_vs_conn *ct)
508 /* 508 /*
509 * Invalidate the connection template 509 * Invalidate the connection template
510 */ 510 */
511 if (ct->vport != 65535) { 511 if (ct->vport != htons(0xffff)) {
512 if (ip_vs_conn_unhash(ct)) { 512 if (ip_vs_conn_unhash(ct)) {
513 ct->dport = 65535; 513 ct->dport = htons(0xffff);
514 ct->vport = 65535; 514 ct->vport = htons(0xffff);
515 ct->cport = 0; 515 ct->cport = 0;
516 ip_vs_conn_hash(ct); 516 ip_vs_conn_hash(ct);
517 } 517 }
@@ -596,8 +596,8 @@ void ip_vs_conn_expire_now(struct ip_vs_conn *cp)
596 * Create a new connection entry and hash it into the ip_vs_conn_tab 596 * Create a new connection entry and hash it into the ip_vs_conn_tab
597 */ 597 */
598struct ip_vs_conn * 598struct ip_vs_conn *
599ip_vs_conn_new(int proto, __u32 caddr, __u16 cport, __u32 vaddr, __u16 vport, 599ip_vs_conn_new(int proto, __be32 caddr, __be16 cport, __be32 vaddr, __be16 vport,
600 __u32 daddr, __u16 dport, unsigned flags, 600 __be32 daddr, __be16 dport, unsigned flags,
601 struct ip_vs_dest *dest) 601 struct ip_vs_dest *dest)
602{ 602{
603 struct ip_vs_conn *cp; 603 struct ip_vs_conn *cp;
diff --git a/net/ipv4/ipvs/ip_vs_core.c b/net/ipv4/ipvs/ip_vs_core.c
index 3f47ad8e1cad..6dee03935f78 100644
--- a/net/ipv4/ipvs/ip_vs_core.c
+++ b/net/ipv4/ipvs/ip_vs_core.c
@@ -209,14 +209,14 @@ int ip_vs_make_skb_writable(struct sk_buff **pskb, int writable_len)
209static struct ip_vs_conn * 209static struct ip_vs_conn *
210ip_vs_sched_persist(struct ip_vs_service *svc, 210ip_vs_sched_persist(struct ip_vs_service *svc,
211 const struct sk_buff *skb, 211 const struct sk_buff *skb,
212 __u16 ports[2]) 212 __be16 ports[2])
213{ 213{
214 struct ip_vs_conn *cp = NULL; 214 struct ip_vs_conn *cp = NULL;
215 struct iphdr *iph = skb->nh.iph; 215 struct iphdr *iph = skb->nh.iph;
216 struct ip_vs_dest *dest; 216 struct ip_vs_dest *dest;
217 struct ip_vs_conn *ct; 217 struct ip_vs_conn *ct;
218 __u16 dport; /* destination port to forward */ 218 __be16 dport; /* destination port to forward */
219 __u32 snet; /* source network of the client, after masking */ 219 __be32 snet; /* source network of the client, after masking */
220 220
221 /* Mask saddr with the netmask to adjust template granularity */ 221 /* Mask saddr with the netmask to adjust template granularity */
222 snet = iph->saddr & svc->netmask; 222 snet = iph->saddr & svc->netmask;
@@ -383,7 +383,7 @@ ip_vs_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
383 struct ip_vs_conn *cp = NULL; 383 struct ip_vs_conn *cp = NULL;
384 struct iphdr *iph = skb->nh.iph; 384 struct iphdr *iph = skb->nh.iph;
385 struct ip_vs_dest *dest; 385 struct ip_vs_dest *dest;
386 __u16 _ports[2], *pptr; 386 __be16 _ports[2], *pptr;
387 387
388 pptr = skb_header_pointer(skb, iph->ihl*4, 388 pptr = skb_header_pointer(skb, iph->ihl*4,
389 sizeof(_ports), _ports); 389 sizeof(_ports), _ports);
@@ -446,7 +446,7 @@ ip_vs_schedule(struct ip_vs_service *svc, const struct sk_buff *skb)
446int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb, 446int ip_vs_leave(struct ip_vs_service *svc, struct sk_buff *skb,
447 struct ip_vs_protocol *pp) 447 struct ip_vs_protocol *pp)
448{ 448{
449 __u16 _ports[2], *pptr; 449 __be16 _ports[2], *pptr;
450 struct iphdr *iph = skb->nh.iph; 450 struct iphdr *iph = skb->nh.iph;
451 451
452 pptr = skb_header_pointer(skb, iph->ihl*4, 452 pptr = skb_header_pointer(skb, iph->ihl*4,
@@ -576,7 +576,7 @@ void ip_vs_nat_icmp(struct sk_buff *skb, struct ip_vs_protocol *pp,
576 576
577 /* the TCP/UDP port */ 577 /* the TCP/UDP port */
578 if (IPPROTO_TCP == ciph->protocol || IPPROTO_UDP == ciph->protocol) { 578 if (IPPROTO_TCP == ciph->protocol || IPPROTO_UDP == ciph->protocol) {
579 __u16 *ports = (void *)ciph + ciph->ihl*4; 579 __be16 *ports = (void *)ciph + ciph->ihl*4;
580 580
581 if (inout) 581 if (inout)
582 ports[1] = cp->vport; 582 ports[1] = cp->vport;
@@ -775,7 +775,7 @@ ip_vs_out(unsigned int hooknum, struct sk_buff **pskb,
775 if (sysctl_ip_vs_nat_icmp_send && 775 if (sysctl_ip_vs_nat_icmp_send &&
776 (pp->protocol == IPPROTO_TCP || 776 (pp->protocol == IPPROTO_TCP ||
777 pp->protocol == IPPROTO_UDP)) { 777 pp->protocol == IPPROTO_UDP)) {
778 __u16 _ports[2], *pptr; 778 __be16 _ports[2], *pptr;
779 779
780 pptr = skb_header_pointer(skb, ihl, 780 pptr = skb_header_pointer(skb, ihl,
781 sizeof(_ports), _ports); 781 sizeof(_ports), _ports);
diff --git a/net/ipv4/ipvs/ip_vs_ctl.c b/net/ipv4/ipvs/ip_vs_ctl.c
index f28ec6882162..f261616e4602 100644
--- a/net/ipv4/ipvs/ip_vs_ctl.c
+++ b/net/ipv4/ipvs/ip_vs_ctl.c
@@ -283,7 +283,7 @@ static atomic_t ip_vs_nullsvc_counter = ATOMIC_INIT(0);
283 * Returns hash value for virtual service 283 * Returns hash value for virtual service
284 */ 284 */
285static __inline__ unsigned 285static __inline__ unsigned
286ip_vs_svc_hashkey(unsigned proto, __u32 addr, __u16 port) 286ip_vs_svc_hashkey(unsigned proto, __be32 addr, __be16 port)
287{ 287{
288 register unsigned porth = ntohs(port); 288 register unsigned porth = ntohs(port);
289 289
@@ -365,7 +365,7 @@ static int ip_vs_svc_unhash(struct ip_vs_service *svc)
365 * Get service by {proto,addr,port} in the service table. 365 * Get service by {proto,addr,port} in the service table.
366 */ 366 */
367static __inline__ struct ip_vs_service * 367static __inline__ struct ip_vs_service *
368__ip_vs_service_get(__u16 protocol, __u32 vaddr, __u16 vport) 368__ip_vs_service_get(__u16 protocol, __be32 vaddr, __be16 vport)
369{ 369{
370 unsigned hash; 370 unsigned hash;
371 struct ip_vs_service *svc; 371 struct ip_vs_service *svc;
@@ -410,7 +410,7 @@ static __inline__ struct ip_vs_service *__ip_vs_svc_fwm_get(__u32 fwmark)
410} 410}
411 411
412struct ip_vs_service * 412struct ip_vs_service *
413ip_vs_service_get(__u32 fwmark, __u16 protocol, __u32 vaddr, __u16 vport) 413ip_vs_service_get(__u32 fwmark, __u16 protocol, __be32 vaddr, __be16 vport)
414{ 414{
415 struct ip_vs_service *svc; 415 struct ip_vs_service *svc;
416 416
@@ -480,7 +480,7 @@ __ip_vs_unbind_svc(struct ip_vs_dest *dest)
480/* 480/*
481 * Returns hash value for real service 481 * Returns hash value for real service
482 */ 482 */
483static __inline__ unsigned ip_vs_rs_hashkey(__u32 addr, __u16 port) 483static __inline__ unsigned ip_vs_rs_hashkey(__be32 addr, __be16 port)
484{ 484{
485 register unsigned porth = ntohs(port); 485 register unsigned porth = ntohs(port);
486 486
@@ -531,7 +531,7 @@ static int ip_vs_rs_unhash(struct ip_vs_dest *dest)
531 * Lookup real service by <proto,addr,port> in the real service table. 531 * Lookup real service by <proto,addr,port> in the real service table.
532 */ 532 */
533struct ip_vs_dest * 533struct ip_vs_dest *
534ip_vs_lookup_real_service(__u16 protocol, __u32 daddr, __u16 dport) 534ip_vs_lookup_real_service(__u16 protocol, __be32 daddr, __be16 dport)
535{ 535{
536 unsigned hash; 536 unsigned hash;
537 struct ip_vs_dest *dest; 537 struct ip_vs_dest *dest;
@@ -562,7 +562,7 @@ ip_vs_lookup_real_service(__u16 protocol, __u32 daddr, __u16 dport)
562 * Lookup destination by {addr,port} in the given service 562 * Lookup destination by {addr,port} in the given service
563 */ 563 */
564static struct ip_vs_dest * 564static struct ip_vs_dest *
565ip_vs_lookup_dest(struct ip_vs_service *svc, __u32 daddr, __u16 dport) 565ip_vs_lookup_dest(struct ip_vs_service *svc, __be32 daddr, __be16 dport)
566{ 566{
567 struct ip_vs_dest *dest; 567 struct ip_vs_dest *dest;
568 568
@@ -591,7 +591,7 @@ ip_vs_lookup_dest(struct ip_vs_service *svc, __u32 daddr, __u16 dport)
591 * scheduling. 591 * scheduling.
592 */ 592 */
593static struct ip_vs_dest * 593static struct ip_vs_dest *
594ip_vs_trash_get_dest(struct ip_vs_service *svc, __u32 daddr, __u16 dport) 594ip_vs_trash_get_dest(struct ip_vs_service *svc, __be32 daddr, __be16 dport)
595{ 595{
596 struct ip_vs_dest *dest, *nxt; 596 struct ip_vs_dest *dest, *nxt;
597 597
@@ -735,12 +735,11 @@ ip_vs_new_dest(struct ip_vs_service *svc, struct ip_vs_dest_user *udest,
735 if (atype != RTN_LOCAL && atype != RTN_UNICAST) 735 if (atype != RTN_LOCAL && atype != RTN_UNICAST)
736 return -EINVAL; 736 return -EINVAL;
737 737
738 dest = kmalloc(sizeof(struct ip_vs_dest), GFP_ATOMIC); 738 dest = kzalloc(sizeof(struct ip_vs_dest), GFP_ATOMIC);
739 if (dest == NULL) { 739 if (dest == NULL) {
740 IP_VS_ERR("ip_vs_new_dest: kmalloc failed.\n"); 740 IP_VS_ERR("ip_vs_new_dest: kmalloc failed.\n");
741 return -ENOMEM; 741 return -ENOMEM;
742 } 742 }
743 memset(dest, 0, sizeof(struct ip_vs_dest));
744 743
745 dest->protocol = svc->protocol; 744 dest->protocol = svc->protocol;
746 dest->vaddr = svc->addr; 745 dest->vaddr = svc->addr;
@@ -774,8 +773,8 @@ static int
774ip_vs_add_dest(struct ip_vs_service *svc, struct ip_vs_dest_user *udest) 773ip_vs_add_dest(struct ip_vs_service *svc, struct ip_vs_dest_user *udest)
775{ 774{
776 struct ip_vs_dest *dest; 775 struct ip_vs_dest *dest;
777 __u32 daddr = udest->addr; 776 __be32 daddr = udest->addr;
778 __u16 dport = udest->port; 777 __be16 dport = udest->port;
779 int ret; 778 int ret;
780 779
781 EnterFunction(2); 780 EnterFunction(2);
@@ -880,8 +879,8 @@ static int
880ip_vs_edit_dest(struct ip_vs_service *svc, struct ip_vs_dest_user *udest) 879ip_vs_edit_dest(struct ip_vs_service *svc, struct ip_vs_dest_user *udest)
881{ 880{
882 struct ip_vs_dest *dest; 881 struct ip_vs_dest *dest;
883 __u32 daddr = udest->addr; 882 __be32 daddr = udest->addr;
884 __u16 dport = udest->port; 883 __be16 dport = udest->port;
885 884
886 EnterFunction(2); 885 EnterFunction(2);
887 886
@@ -992,8 +991,8 @@ static int
992ip_vs_del_dest(struct ip_vs_service *svc,struct ip_vs_dest_user *udest) 991ip_vs_del_dest(struct ip_vs_service *svc,struct ip_vs_dest_user *udest)
993{ 992{
994 struct ip_vs_dest *dest; 993 struct ip_vs_dest *dest;
995 __u32 daddr = udest->addr; 994 __be32 daddr = udest->addr;
996 __u16 dport = udest->port; 995 __be16 dport = udest->port;
997 996
998 EnterFunction(2); 997 EnterFunction(2);
999 998
@@ -1050,14 +1049,12 @@ ip_vs_add_service(struct ip_vs_service_user *u, struct ip_vs_service **svc_p)
1050 goto out_mod_dec; 1049 goto out_mod_dec;
1051 } 1050 }
1052 1051
1053 svc = (struct ip_vs_service *) 1052 svc = kzalloc(sizeof(struct ip_vs_service), GFP_ATOMIC);
1054 kmalloc(sizeof(struct ip_vs_service), GFP_ATOMIC);
1055 if (svc == NULL) { 1053 if (svc == NULL) {
1056 IP_VS_DBG(1, "ip_vs_add_service: kmalloc failed.\n"); 1054 IP_VS_DBG(1, "ip_vs_add_service: kmalloc failed.\n");
1057 ret = -ENOMEM; 1055 ret = -ENOMEM;
1058 goto out_err; 1056 goto out_err;
1059 } 1057 }
1060 memset(svc, 0, sizeof(struct ip_vs_service));
1061 1058
1062 /* I'm the first user of the service */ 1059 /* I'm the first user of the service */
1063 atomic_set(&svc->usecnt, 1); 1060 atomic_set(&svc->usecnt, 1);
@@ -1797,7 +1794,7 @@ static int ip_vs_info_open(struct inode *inode, struct file *file)
1797{ 1794{
1798 struct seq_file *seq; 1795 struct seq_file *seq;
1799 int rc = -ENOMEM; 1796 int rc = -ENOMEM;
1800 struct ip_vs_iter *s = kmalloc(sizeof(*s), GFP_KERNEL); 1797 struct ip_vs_iter *s = kzalloc(sizeof(*s), GFP_KERNEL);
1801 1798
1802 if (!s) 1799 if (!s)
1803 goto out; 1800 goto out;
@@ -1808,7 +1805,6 @@ static int ip_vs_info_open(struct inode *inode, struct file *file)
1808 1805
1809 seq = file->private_data; 1806 seq = file->private_data;
1810 seq->private = s; 1807 seq->private = s;
1811 memset(s, 0, sizeof(*s));
1812out: 1808out:
1813 return rc; 1809 return rc;
1814out_kfree: 1810out_kfree:
diff --git a/net/ipv4/ipvs/ip_vs_dh.c b/net/ipv4/ipvs/ip_vs_dh.c
index 9fee19c4c617..502111fba872 100644
--- a/net/ipv4/ipvs/ip_vs_dh.c
+++ b/net/ipv4/ipvs/ip_vs_dh.c
@@ -66,7 +66,7 @@ struct ip_vs_dh_bucket {
66/* 66/*
67 * Returns hash value for IPVS DH entry 67 * Returns hash value for IPVS DH entry
68 */ 68 */
69static inline unsigned ip_vs_dh_hashkey(__u32 addr) 69static inline unsigned ip_vs_dh_hashkey(__be32 addr)
70{ 70{
71 return (ntohl(addr)*2654435761UL) & IP_VS_DH_TAB_MASK; 71 return (ntohl(addr)*2654435761UL) & IP_VS_DH_TAB_MASK;
72} 72}
@@ -76,7 +76,7 @@ static inline unsigned ip_vs_dh_hashkey(__u32 addr)
76 * Get ip_vs_dest associated with supplied parameters. 76 * Get ip_vs_dest associated with supplied parameters.
77 */ 77 */
78static inline struct ip_vs_dest * 78static inline struct ip_vs_dest *
79ip_vs_dh_get(struct ip_vs_dh_bucket *tbl, __u32 addr) 79ip_vs_dh_get(struct ip_vs_dh_bucket *tbl, __be32 addr)
80{ 80{
81 return (tbl[ip_vs_dh_hashkey(addr)]).dest; 81 return (tbl[ip_vs_dh_hashkey(addr)]).dest;
82} 82}
diff --git a/net/ipv4/ipvs/ip_vs_est.c b/net/ipv4/ipvs/ip_vs_est.c
index c453e1e57f4b..7d68b80c4c19 100644
--- a/net/ipv4/ipvs/ip_vs_est.c
+++ b/net/ipv4/ipvs/ip_vs_est.c
@@ -13,7 +13,6 @@
13 * Changes: 13 * Changes:
14 * 14 *
15 */ 15 */
16#include <linux/config.h>
17#include <linux/kernel.h> 16#include <linux/kernel.h>
18#include <linux/jiffies.h> 17#include <linux/jiffies.h>
19#include <linux/slab.h> 18#include <linux/slab.h>
@@ -124,11 +123,10 @@ int ip_vs_new_estimator(struct ip_vs_stats *stats)
124{ 123{
125 struct ip_vs_estimator *est; 124 struct ip_vs_estimator *est;
126 125
127 est = kmalloc(sizeof(*est), GFP_KERNEL); 126 est = kzalloc(sizeof(*est), GFP_KERNEL);
128 if (est == NULL) 127 if (est == NULL)
129 return -ENOMEM; 128 return -ENOMEM;
130 129
131 memset(est, 0, sizeof(*est));
132 est->stats = stats; 130 est->stats = stats;
133 est->last_conns = stats->conns; 131 est->last_conns = stats->conns;
134 est->cps = stats->cps<<10; 132 est->cps = stats->cps<<10;
diff --git a/net/ipv4/ipvs/ip_vs_ftp.c b/net/ipv4/ipvs/ip_vs_ftp.c
index a19a33ceb811..e433cb0ff894 100644
--- a/net/ipv4/ipvs/ip_vs_ftp.c
+++ b/net/ipv4/ipvs/ip_vs_ftp.c
@@ -32,6 +32,7 @@
32#include <linux/ip.h> 32#include <linux/ip.h>
33#include <net/protocol.h> 33#include <net/protocol.h>
34#include <net/tcp.h> 34#include <net/tcp.h>
35#include <asm/unaligned.h>
35 36
36#include <net/ip_vs.h> 37#include <net/ip_vs.h>
37 38
@@ -44,16 +45,9 @@
44 * List of ports (up to IP_VS_APP_MAX_PORTS) to be handled by helper 45 * List of ports (up to IP_VS_APP_MAX_PORTS) to be handled by helper
45 * First port is set to the default port. 46 * First port is set to the default port.
46 */ 47 */
47static int ports[IP_VS_APP_MAX_PORTS] = {21, 0}; 48static unsigned short ports[IP_VS_APP_MAX_PORTS] = {21, 0};
48module_param_array(ports, int, NULL, 0); 49module_param_array(ports, ushort, NULL, 0);
49 50MODULE_PARM_DESC(ports, "Ports to monitor for FTP control commands");
50/*
51 * Debug level
52 */
53#ifdef CONFIG_IP_VS_DEBUG
54static int debug=0;
55module_param(debug, int, 0);
56#endif
57 51
58 52
59/* Dummy variable */ 53/* Dummy variable */
@@ -81,7 +75,7 @@ ip_vs_ftp_done_conn(struct ip_vs_app *app, struct ip_vs_conn *cp)
81 */ 75 */
82static int ip_vs_ftp_get_addrport(char *data, char *data_limit, 76static int ip_vs_ftp_get_addrport(char *data, char *data_limit,
83 const char *pattern, size_t plen, char term, 77 const char *pattern, size_t plen, char term,
84 __u32 *addr, __u16 *port, 78 __be32 *addr, __be16 *port,
85 char **start, char **end) 79 char **start, char **end)
86{ 80{
87 unsigned char p[6]; 81 unsigned char p[6];
@@ -121,8 +115,8 @@ static int ip_vs_ftp_get_addrport(char *data, char *data_limit,
121 if (i != 5) 115 if (i != 5)
122 return -1; 116 return -1;
123 117
124 *addr = (p[3]<<24) | (p[2]<<16) | (p[1]<<8) | p[0]; 118 *addr = get_unaligned((__be32 *)p);
125 *port = (p[5]<<8) | p[4]; 119 *port = get_unaligned((__be16 *)(p + 4));
126 return 1; 120 return 1;
127} 121}
128 122
@@ -147,8 +141,8 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
147 struct tcphdr *th; 141 struct tcphdr *th;
148 char *data, *data_limit; 142 char *data, *data_limit;
149 char *start, *end; 143 char *start, *end;
150 __u32 from; 144 __be32 from;
151 __u16 port; 145 __be16 port;
152 struct ip_vs_conn *n_cp; 146 struct ip_vs_conn *n_cp;
153 char buf[24]; /* xxx.xxx.xxx.xxx,ppp,ppp\000 */ 147 char buf[24]; /* xxx.xxx.xxx.xxx,ppp,ppp\000 */
154 unsigned buf_len; 148 unsigned buf_len;
@@ -177,7 +171,7 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
177 &start, &end) != 1) 171 &start, &end) != 1)
178 return 1; 172 return 1;
179 173
180 IP_VS_DBG(1-debug, "PASV response (%u.%u.%u.%u:%d) -> " 174 IP_VS_DBG(7, "PASV response (%u.%u.%u.%u:%d) -> "
181 "%u.%u.%u.%u:%d detected\n", 175 "%u.%u.%u.%u:%d detected\n",
182 NIPQUAD(from), ntohs(port), NIPQUAD(cp->caddr), 0); 176 NIPQUAD(from), ntohs(port), NIPQUAD(cp->caddr), 0);
183 177
@@ -206,7 +200,7 @@ static int ip_vs_ftp_out(struct ip_vs_app *app, struct ip_vs_conn *cp,
206 from = n_cp->vaddr; 200 from = n_cp->vaddr;
207 port = n_cp->vport; 201 port = n_cp->vport;
208 sprintf(buf,"%d,%d,%d,%d,%d,%d", NIPQUAD(from), 202 sprintf(buf,"%d,%d,%d,%d,%d,%d", NIPQUAD(from),
209 port&255, (port>>8)&255); 203 ntohs(port)&255, (ntohs(port)>>8)&255);
210 buf_len = strlen(buf); 204 buf_len = strlen(buf);
211 205
212 /* 206 /*
@@ -250,8 +244,8 @@ static int ip_vs_ftp_in(struct ip_vs_app *app, struct ip_vs_conn *cp,
250 struct tcphdr *th; 244 struct tcphdr *th;
251 char *data, *data_start, *data_limit; 245 char *data, *data_start, *data_limit;
252 char *start, *end; 246 char *start, *end;
253 __u32 to; 247 __be32 to;
254 __u16 port; 248 __be16 port;
255 struct ip_vs_conn *n_cp; 249 struct ip_vs_conn *n_cp;
256 250
257 /* no diff required for incoming packets */ 251 /* 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,
280 while (data <= data_limit - 6) { 274 while (data <= data_limit - 6) {
281 if (strnicmp(data, "PASV\r\n", 6) == 0) { 275 if (strnicmp(data, "PASV\r\n", 6) == 0) {
282 /* Passive mode on */ 276 /* Passive mode on */
283 IP_VS_DBG(1-debug, "got PASV at %zd of %zd\n", 277 IP_VS_DBG(7, "got PASV at %zd of %zd\n",
284 data - data_start, 278 data - data_start,
285 data_limit - data_start); 279 data_limit - data_start);
286 cp->app_data = &ip_vs_ftp_pasv; 280 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,
302 &start, &end) != 1) 296 &start, &end) != 1)
303 return 1; 297 return 1;
304 298
305 IP_VS_DBG(1-debug, "PORT %u.%u.%u.%u:%d detected\n", 299 IP_VS_DBG(7, "PORT %u.%u.%u.%u:%d detected\n",
306 NIPQUAD(to), ntohs(port)); 300 NIPQUAD(to), ntohs(port));
307 301
308 /* Passive mode off */ 302 /* Passive mode off */
@@ -311,7 +305,7 @@ static int ip_vs_ftp_in(struct ip_vs_app *app, struct ip_vs_conn *cp,
311 /* 305 /*
312 * Now update or create a connection entry for it 306 * Now update or create a connection entry for it
313 */ 307 */
314 IP_VS_DBG(1-debug, "protocol %s %u.%u.%u.%u:%d %u.%u.%u.%u:%d\n", 308 IP_VS_DBG(7, "protocol %s %u.%u.%u.%u:%d %u.%u.%u.%u:%d\n",
315 ip_vs_proto_name(iph->protocol), 309 ip_vs_proto_name(iph->protocol),
316 NIPQUAD(to), ntohs(port), NIPQUAD(cp->vaddr), 0); 310 NIPQUAD(to), ntohs(port), NIPQUAD(cp->vaddr), 0);
317 311
@@ -375,8 +369,8 @@ static int __init ip_vs_ftp_init(void)
375 ret = register_ip_vs_app_inc(app, app->protocol, ports[i]); 369 ret = register_ip_vs_app_inc(app, app->protocol, ports[i]);
376 if (ret) 370 if (ret)
377 break; 371 break;
378 IP_VS_DBG(1-debug, "%s: loaded support on port[%d] = %d\n", 372 IP_VS_INFO("%s: loaded support on port[%d] = %d\n",
379 app->name, i, ports[i]); 373 app->name, i, ports[i]);
380 } 374 }
381 375
382 if (ret) 376 if (ret)
diff --git a/net/ipv4/ipvs/ip_vs_lblc.c b/net/ipv4/ipvs/ip_vs_lblc.c
index 6e5cb92a5c83..524751e031de 100644
--- a/net/ipv4/ipvs/ip_vs_lblc.c
+++ b/net/ipv4/ipvs/ip_vs_lblc.c
@@ -87,7 +87,7 @@ static int sysctl_ip_vs_lblc_expiration = 24*60*60*HZ;
87 */ 87 */
88struct ip_vs_lblc_entry { 88struct ip_vs_lblc_entry {
89 struct list_head list; 89 struct list_head list;
90 __u32 addr; /* destination IP address */ 90 __be32 addr; /* destination IP address */
91 struct ip_vs_dest *dest; /* real server (cache) */ 91 struct ip_vs_dest *dest; /* real server (cache) */
92 unsigned long lastuse; /* last used time */ 92 unsigned long lastuse; /* last used time */
93}; 93};
@@ -160,7 +160,7 @@ static struct ctl_table_header * sysctl_header;
160 * IP address to a server. 160 * IP address to a server.
161 */ 161 */
162static inline struct ip_vs_lblc_entry * 162static inline struct ip_vs_lblc_entry *
163ip_vs_lblc_new(__u32 daddr, struct ip_vs_dest *dest) 163ip_vs_lblc_new(__be32 daddr, struct ip_vs_dest *dest)
164{ 164{
165 struct ip_vs_lblc_entry *en; 165 struct ip_vs_lblc_entry *en;
166 166
@@ -195,7 +195,7 @@ static inline void ip_vs_lblc_free(struct ip_vs_lblc_entry *en)
195/* 195/*
196 * Returns hash value for IPVS LBLC entry 196 * Returns hash value for IPVS LBLC entry
197 */ 197 */
198static inline unsigned ip_vs_lblc_hashkey(__u32 addr) 198static inline unsigned ip_vs_lblc_hashkey(__be32 addr)
199{ 199{
200 return (ntohl(addr)*2654435761UL) & IP_VS_LBLC_TAB_MASK; 200 return (ntohl(addr)*2654435761UL) & IP_VS_LBLC_TAB_MASK;
201} 201}
@@ -234,7 +234,7 @@ ip_vs_lblc_hash(struct ip_vs_lblc_table *tbl, struct ip_vs_lblc_entry *en)
234 * Get ip_vs_lblc_entry associated with supplied parameters. 234 * Get ip_vs_lblc_entry associated with supplied parameters.
235 */ 235 */
236static inline struct ip_vs_lblc_entry * 236static inline struct ip_vs_lblc_entry *
237ip_vs_lblc_get(struct ip_vs_lblc_table *tbl, __u32 addr) 237ip_vs_lblc_get(struct ip_vs_lblc_table *tbl, __be32 addr)
238{ 238{
239 unsigned hash; 239 unsigned hash;
240 struct ip_vs_lblc_entry *en; 240 struct ip_vs_lblc_entry *en;
diff --git a/net/ipv4/ipvs/ip_vs_lblcr.c b/net/ipv4/ipvs/ip_vs_lblcr.c
index 32ba37ba72d8..08990192b6ec 100644
--- a/net/ipv4/ipvs/ip_vs_lblcr.c
+++ b/net/ipv4/ipvs/ip_vs_lblcr.c
@@ -276,7 +276,7 @@ static inline struct ip_vs_dest *ip_vs_dest_set_max(struct ip_vs_dest_set *set)
276 */ 276 */
277struct ip_vs_lblcr_entry { 277struct ip_vs_lblcr_entry {
278 struct list_head list; 278 struct list_head list;
279 __u32 addr; /* destination IP address */ 279 __be32 addr; /* destination IP address */
280 struct ip_vs_dest_set set; /* destination server set */ 280 struct ip_vs_dest_set set; /* destination server set */
281 unsigned long lastuse; /* last used time */ 281 unsigned long lastuse; /* last used time */
282}; 282};
@@ -348,7 +348,7 @@ static struct ctl_table_header * sysctl_header;
348 * new/free a ip_vs_lblcr_entry, which is a mapping of a destination 348 * new/free a ip_vs_lblcr_entry, which is a mapping of a destination
349 * IP address to a server. 349 * IP address to a server.
350 */ 350 */
351static inline struct ip_vs_lblcr_entry *ip_vs_lblcr_new(__u32 daddr) 351static inline struct ip_vs_lblcr_entry *ip_vs_lblcr_new(__be32 daddr)
352{ 352{
353 struct ip_vs_lblcr_entry *en; 353 struct ip_vs_lblcr_entry *en;
354 354
@@ -381,7 +381,7 @@ static inline void ip_vs_lblcr_free(struct ip_vs_lblcr_entry *en)
381/* 381/*
382 * Returns hash value for IPVS LBLCR entry 382 * Returns hash value for IPVS LBLCR entry
383 */ 383 */
384static inline unsigned ip_vs_lblcr_hashkey(__u32 addr) 384static inline unsigned ip_vs_lblcr_hashkey(__be32 addr)
385{ 385{
386 return (ntohl(addr)*2654435761UL) & IP_VS_LBLCR_TAB_MASK; 386 return (ntohl(addr)*2654435761UL) & IP_VS_LBLCR_TAB_MASK;
387} 387}
@@ -420,7 +420,7 @@ ip_vs_lblcr_hash(struct ip_vs_lblcr_table *tbl, struct ip_vs_lblcr_entry *en)
420 * Get ip_vs_lblcr_entry associated with supplied parameters. 420 * Get ip_vs_lblcr_entry associated with supplied parameters.
421 */ 421 */
422static inline struct ip_vs_lblcr_entry * 422static inline struct ip_vs_lblcr_entry *
423ip_vs_lblcr_get(struct ip_vs_lblcr_table *tbl, __u32 addr) 423ip_vs_lblcr_get(struct ip_vs_lblcr_table *tbl, __be32 addr)
424{ 424{
425 unsigned hash; 425 unsigned hash;
426 struct ip_vs_lblcr_entry *en; 426 struct ip_vs_lblcr_entry *en;
diff --git a/net/ipv4/ipvs/ip_vs_proto.c b/net/ipv4/ipvs/ip_vs_proto.c
index 867d4e9c6594..c4528b5c800d 100644
--- a/net/ipv4/ipvs/ip_vs_proto.c
+++ b/net/ipv4/ipvs/ip_vs_proto.c
@@ -176,7 +176,7 @@ ip_vs_tcpudp_debug_packet(struct ip_vs_protocol *pp,
176 pp->name, NIPQUAD(ih->saddr), 176 pp->name, NIPQUAD(ih->saddr),
177 NIPQUAD(ih->daddr)); 177 NIPQUAD(ih->daddr));
178 else { 178 else {
179 __u16 _ports[2], *pptr 179 __be16 _ports[2], *pptr
180; 180;
181 pptr = skb_header_pointer(skb, offset + ih->ihl*4, 181 pptr = skb_header_pointer(skb, offset + ih->ihl*4,
182 sizeof(_ports), _ports); 182 sizeof(_ports), _ports);
diff --git a/net/ipv4/ipvs/ip_vs_proto_tcp.c b/net/ipv4/ipvs/ip_vs_proto_tcp.c
index bc28b1160a3a..bfe779e74590 100644
--- a/net/ipv4/ipvs/ip_vs_proto_tcp.c
+++ b/net/ipv4/ipvs/ip_vs_proto_tcp.c
@@ -29,7 +29,7 @@ static struct ip_vs_conn *
29tcp_conn_in_get(const struct sk_buff *skb, struct ip_vs_protocol *pp, 29tcp_conn_in_get(const struct sk_buff *skb, struct ip_vs_protocol *pp,
30 const struct iphdr *iph, unsigned int proto_off, int inverse) 30 const struct iphdr *iph, unsigned int proto_off, int inverse)
31{ 31{
32 __u16 _ports[2], *pptr; 32 __be16 _ports[2], *pptr;
33 33
34 pptr = skb_header_pointer(skb, proto_off, sizeof(_ports), _ports); 34 pptr = skb_header_pointer(skb, proto_off, sizeof(_ports), _ports);
35 if (pptr == NULL) 35 if (pptr == NULL)
@@ -50,7 +50,7 @@ static struct ip_vs_conn *
50tcp_conn_out_get(const struct sk_buff *skb, struct ip_vs_protocol *pp, 50tcp_conn_out_get(const struct sk_buff *skb, struct ip_vs_protocol *pp,
51 const struct iphdr *iph, unsigned int proto_off, int inverse) 51 const struct iphdr *iph, unsigned int proto_off, int inverse)
52{ 52{
53 __u16 _ports[2], *pptr; 53 __be16 _ports[2], *pptr;
54 54
55 pptr = skb_header_pointer(skb, proto_off, sizeof(_ports), _ports); 55 pptr = skb_header_pointer(skb, proto_off, sizeof(_ports), _ports);
56 if (pptr == NULL) 56 if (pptr == NULL)
@@ -112,12 +112,12 @@ tcp_conn_schedule(struct sk_buff *skb,
112 112
113 113
114static inline void 114static inline void
115tcp_fast_csum_update(struct tcphdr *tcph, u32 oldip, u32 newip, 115tcp_fast_csum_update(struct tcphdr *tcph, __be32 oldip, __be32 newip,
116 u16 oldport, u16 newport) 116 __be16 oldport, __be16 newport)
117{ 117{
118 tcph->check = 118 tcph->check =
119 ip_vs_check_diff(~oldip, newip, 119 ip_vs_check_diff(~oldip, newip,
120 ip_vs_check_diff(oldport ^ 0xFFFF, 120 ip_vs_check_diff(oldport ^ htonl(0xFFFF),
121 newport, tcph->check)); 121 newport, tcph->check));
122} 122}
123 123
@@ -151,7 +151,7 @@ tcp_snat_handler(struct sk_buff **pskb,
151 /* Only port and addr are changed, do fast csum update */ 151 /* Only port and addr are changed, do fast csum update */
152 tcp_fast_csum_update(tcph, cp->daddr, cp->vaddr, 152 tcp_fast_csum_update(tcph, cp->daddr, cp->vaddr,
153 cp->dport, cp->vport); 153 cp->dport, cp->vport);
154 if ((*pskb)->ip_summed == CHECKSUM_HW) 154 if ((*pskb)->ip_summed == CHECKSUM_COMPLETE)
155 (*pskb)->ip_summed = CHECKSUM_NONE; 155 (*pskb)->ip_summed = CHECKSUM_NONE;
156 } else { 156 } else {
157 /* full checksum calculation */ 157 /* full checksum calculation */
@@ -204,7 +204,7 @@ tcp_dnat_handler(struct sk_buff **pskb,
204 /* Only port and addr are changed, do fast csum update */ 204 /* Only port and addr are changed, do fast csum update */
205 tcp_fast_csum_update(tcph, cp->vaddr, cp->daddr, 205 tcp_fast_csum_update(tcph, cp->vaddr, cp->daddr,
206 cp->vport, cp->dport); 206 cp->vport, cp->dport);
207 if ((*pskb)->ip_summed == CHECKSUM_HW) 207 if ((*pskb)->ip_summed == CHECKSUM_COMPLETE)
208 (*pskb)->ip_summed = CHECKSUM_NONE; 208 (*pskb)->ip_summed = CHECKSUM_NONE;
209 } else { 209 } else {
210 /* full checksum calculation */ 210 /* full checksum calculation */
@@ -229,7 +229,7 @@ tcp_csum_check(struct sk_buff *skb, struct ip_vs_protocol *pp)
229 switch (skb->ip_summed) { 229 switch (skb->ip_summed) {
230 case CHECKSUM_NONE: 230 case CHECKSUM_NONE:
231 skb->csum = skb_checksum(skb, tcphoff, skb->len - tcphoff, 0); 231 skb->csum = skb_checksum(skb, tcphoff, skb->len - tcphoff, 0);
232 case CHECKSUM_HW: 232 case CHECKSUM_COMPLETE:
233 if (csum_tcpudp_magic(skb->nh.iph->saddr, skb->nh.iph->daddr, 233 if (csum_tcpudp_magic(skb->nh.iph->saddr, skb->nh.iph->daddr,
234 skb->len - tcphoff, 234 skb->len - tcphoff,
235 skb->nh.iph->protocol, skb->csum)) { 235 skb->nh.iph->protocol, skb->csum)) {
@@ -239,7 +239,7 @@ tcp_csum_check(struct sk_buff *skb, struct ip_vs_protocol *pp)
239 } 239 }
240 break; 240 break;
241 default: 241 default:
242 /* CHECKSUM_UNNECESSARY */ 242 /* No need to checksum. */
243 break; 243 break;
244 } 244 }
245 245
diff --git a/net/ipv4/ipvs/ip_vs_proto_udp.c b/net/ipv4/ipvs/ip_vs_proto_udp.c
index 89d9175d8f28..54aa7603591f 100644
--- a/net/ipv4/ipvs/ip_vs_proto_udp.c
+++ b/net/ipv4/ipvs/ip_vs_proto_udp.c
@@ -29,7 +29,7 @@ udp_conn_in_get(const struct sk_buff *skb, struct ip_vs_protocol *pp,
29 const struct iphdr *iph, unsigned int proto_off, int inverse) 29 const struct iphdr *iph, unsigned int proto_off, int inverse)
30{ 30{
31 struct ip_vs_conn *cp; 31 struct ip_vs_conn *cp;
32 __u16 _ports[2], *pptr; 32 __be16 _ports[2], *pptr;
33 33
34 pptr = skb_header_pointer(skb, proto_off, sizeof(_ports), _ports); 34 pptr = skb_header_pointer(skb, proto_off, sizeof(_ports), _ports);
35 if (pptr == NULL) 35 if (pptr == NULL)
@@ -54,7 +54,7 @@ udp_conn_out_get(const struct sk_buff *skb, struct ip_vs_protocol *pp,
54 const struct iphdr *iph, unsigned int proto_off, int inverse) 54 const struct iphdr *iph, unsigned int proto_off, int inverse)
55{ 55{
56 struct ip_vs_conn *cp; 56 struct ip_vs_conn *cp;
57 __u16 _ports[2], *pptr; 57 __be16 _ports[2], *pptr;
58 58
59 pptr = skb_header_pointer(skb, skb->nh.iph->ihl*4, 59 pptr = skb_header_pointer(skb, skb->nh.iph->ihl*4,
60 sizeof(_ports), _ports); 60 sizeof(_ports), _ports);
@@ -117,15 +117,15 @@ udp_conn_schedule(struct sk_buff *skb, struct ip_vs_protocol *pp,
117 117
118 118
119static inline void 119static inline void
120udp_fast_csum_update(struct udphdr *uhdr, u32 oldip, u32 newip, 120udp_fast_csum_update(struct udphdr *uhdr, __be32 oldip, __be32 newip,
121 u16 oldport, u16 newport) 121 __be16 oldport, __be16 newport)
122{ 122{
123 uhdr->check = 123 uhdr->check =
124 ip_vs_check_diff(~oldip, newip, 124 ip_vs_check_diff(~oldip, newip,
125 ip_vs_check_diff(oldport ^ 0xFFFF, 125 ip_vs_check_diff(oldport ^ htonl(0xFFFF),
126 newport, uhdr->check)); 126 newport, uhdr->check));
127 if (!uhdr->check) 127 if (!uhdr->check)
128 uhdr->check = 0xFFFF; 128 uhdr->check = htonl(0xFFFF);
129} 129}
130 130
131static int 131static int
@@ -161,7 +161,7 @@ udp_snat_handler(struct sk_buff **pskb,
161 /* Only port and addr are changed, do fast csum update */ 161 /* Only port and addr are changed, do fast csum update */
162 udp_fast_csum_update(udph, cp->daddr, cp->vaddr, 162 udp_fast_csum_update(udph, cp->daddr, cp->vaddr,
163 cp->dport, cp->vport); 163 cp->dport, cp->vport);
164 if ((*pskb)->ip_summed == CHECKSUM_HW) 164 if ((*pskb)->ip_summed == CHECKSUM_COMPLETE)
165 (*pskb)->ip_summed = CHECKSUM_NONE; 165 (*pskb)->ip_summed = CHECKSUM_NONE;
166 } else { 166 } else {
167 /* full checksum calculation */ 167 /* full checksum calculation */
@@ -173,7 +173,7 @@ udp_snat_handler(struct sk_buff **pskb,
173 cp->protocol, 173 cp->protocol,
174 (*pskb)->csum); 174 (*pskb)->csum);
175 if (udph->check == 0) 175 if (udph->check == 0)
176 udph->check = 0xFFFF; 176 udph->check = htonl(0xFFFF);
177 IP_VS_DBG(11, "O-pkt: %s O-csum=%d (+%zd)\n", 177 IP_VS_DBG(11, "O-pkt: %s O-csum=%d (+%zd)\n",
178 pp->name, udph->check, 178 pp->name, udph->check,
179 (char*)&(udph->check) - (char*)udph); 179 (char*)&(udph->check) - (char*)udph);
@@ -216,7 +216,7 @@ udp_dnat_handler(struct sk_buff **pskb,
216 /* Only port and addr are changed, do fast csum update */ 216 /* Only port and addr are changed, do fast csum update */
217 udp_fast_csum_update(udph, cp->vaddr, cp->daddr, 217 udp_fast_csum_update(udph, cp->vaddr, cp->daddr,
218 cp->vport, cp->dport); 218 cp->vport, cp->dport);
219 if ((*pskb)->ip_summed == CHECKSUM_HW) 219 if ((*pskb)->ip_summed == CHECKSUM_COMPLETE)
220 (*pskb)->ip_summed = CHECKSUM_NONE; 220 (*pskb)->ip_summed = CHECKSUM_NONE;
221 } else { 221 } else {
222 /* full checksum calculation */ 222 /* full checksum calculation */
@@ -250,7 +250,7 @@ udp_csum_check(struct sk_buff *skb, struct ip_vs_protocol *pp)
250 case CHECKSUM_NONE: 250 case CHECKSUM_NONE:
251 skb->csum = skb_checksum(skb, udphoff, 251 skb->csum = skb_checksum(skb, udphoff,
252 skb->len - udphoff, 0); 252 skb->len - udphoff, 0);
253 case CHECKSUM_HW: 253 case CHECKSUM_COMPLETE:
254 if (csum_tcpudp_magic(skb->nh.iph->saddr, 254 if (csum_tcpudp_magic(skb->nh.iph->saddr,
255 skb->nh.iph->daddr, 255 skb->nh.iph->daddr,
256 skb->len - udphoff, 256 skb->len - udphoff,
@@ -262,7 +262,7 @@ udp_csum_check(struct sk_buff *skb, struct ip_vs_protocol *pp)
262 } 262 }
263 break; 263 break;
264 default: 264 default:
265 /* CHECKSUM_UNNECESSARY */ 265 /* No need to checksum. */
266 break; 266 break;
267 } 267 }
268 } 268 }
diff --git a/net/ipv4/ipvs/ip_vs_sh.c b/net/ipv4/ipvs/ip_vs_sh.c
index 7775e6cc68be..338668f88fe2 100644
--- a/net/ipv4/ipvs/ip_vs_sh.c
+++ b/net/ipv4/ipvs/ip_vs_sh.c
@@ -63,7 +63,7 @@ struct ip_vs_sh_bucket {
63/* 63/*
64 * Returns hash value for IPVS SH entry 64 * Returns hash value for IPVS SH entry
65 */ 65 */
66static inline unsigned ip_vs_sh_hashkey(__u32 addr) 66static inline unsigned ip_vs_sh_hashkey(__be32 addr)
67{ 67{
68 return (ntohl(addr)*2654435761UL) & IP_VS_SH_TAB_MASK; 68 return (ntohl(addr)*2654435761UL) & IP_VS_SH_TAB_MASK;
69} 69}
@@ -73,7 +73,7 @@ static inline unsigned ip_vs_sh_hashkey(__u32 addr)
73 * Get ip_vs_dest associated with supplied parameters. 73 * Get ip_vs_dest associated with supplied parameters.
74 */ 74 */
75static inline struct ip_vs_dest * 75static inline struct ip_vs_dest *
76ip_vs_sh_get(struct ip_vs_sh_bucket *tbl, __u32 addr) 76ip_vs_sh_get(struct ip_vs_sh_bucket *tbl, __be32 addr)
77{ 77{
78 return (tbl[ip_vs_sh_hashkey(addr)]).dest; 78 return (tbl[ip_vs_sh_hashkey(addr)]).dest;
79} 79}
diff --git a/net/ipv4/ipvs/ip_vs_sync.c b/net/ipv4/ipvs/ip_vs_sync.c
index 1bca714bda3d..6ab57d72b615 100644
--- a/net/ipv4/ipvs/ip_vs_sync.c
+++ b/net/ipv4/ipvs/ip_vs_sync.c
@@ -48,16 +48,16 @@ struct ip_vs_sync_conn {
48 48
49 /* Protocol, addresses and port numbers */ 49 /* Protocol, addresses and port numbers */
50 __u8 protocol; /* Which protocol (TCP/UDP) */ 50 __u8 protocol; /* Which protocol (TCP/UDP) */
51 __u16 cport; 51 __be16 cport;
52 __u16 vport; 52 __be16 vport;
53 __u16 dport; 53 __be16 dport;
54 __u32 caddr; /* client address */ 54 __be32 caddr; /* client address */
55 __u32 vaddr; /* virtual address */ 55 __be32 vaddr; /* virtual address */
56 __u32 daddr; /* destination address */ 56 __be32 daddr; /* destination address */
57 57
58 /* Flags and state transition */ 58 /* Flags and state transition */
59 __u16 flags; /* status flags */ 59 __be16 flags; /* status flags */
60 __u16 state; /* state info */ 60 __be16 state; /* state info */
61 61
62 /* The sequence options start here */ 62 /* The sequence options start here */
63}; 63};
@@ -464,7 +464,7 @@ join_mcast_group(struct sock *sk, struct in_addr *addr, char *ifname)
464static int bind_mcastif_addr(struct socket *sock, char *ifname) 464static int bind_mcastif_addr(struct socket *sock, char *ifname)
465{ 465{
466 struct net_device *dev; 466 struct net_device *dev;
467 u32 addr; 467 __be32 addr;
468 struct sockaddr_in sin; 468 struct sockaddr_in sin;
469 469
470 if ((dev = __dev_get_by_name(ifname)) == NULL) 470 if ((dev = __dev_get_by_name(ifname)) == NULL)
diff --git a/net/ipv4/ipvs/ip_vs_xmit.c b/net/ipv4/ipvs/ip_vs_xmit.c
index 52c12e9edbbc..e1f77bd7c9a5 100644
--- a/net/ipv4/ipvs/ip_vs_xmit.c
+++ b/net/ipv4/ipvs/ip_vs_xmit.c
@@ -232,7 +232,7 @@ ip_vs_nat_xmit(struct sk_buff *skb, struct ip_vs_conn *cp,
232 232
233 /* check if it is a connection of no-client-port */ 233 /* check if it is a connection of no-client-port */
234 if (unlikely(cp->flags & IP_VS_CONN_F_NO_CPORT)) { 234 if (unlikely(cp->flags & IP_VS_CONN_F_NO_CPORT)) {
235 __u16 _pt, *p; 235 __be16 _pt, *p;
236 p = skb_header_pointer(skb, iph->ihl*4, sizeof(_pt), &_pt); 236 p = skb_header_pointer(skb, iph->ihl*4, sizeof(_pt), &_pt);
237 if (p == NULL) 237 if (p == NULL)
238 goto tx_error; 238 goto tx_error;