aboutsummaryrefslogtreecommitdiffstats
path: root/net/ipv4
diff options
context:
space:
mode:
Diffstat (limited to 'net/ipv4')
-rw-r--r--net/ipv4/ah4.c4
-rw-r--r--net/ipv4/esp4.c4
-rw-r--r--net/ipv4/ip_gre.c52
-rw-r--r--net/ipv4/ipip.c16
4 files changed, 38 insertions, 38 deletions
diff --git a/net/ipv4/ah4.c b/net/ipv4/ah4.c
index 99542977e47e..67a5509e26fc 100644
--- a/net/ipv4/ah4.c
+++ b/net/ipv4/ah4.c
@@ -14,7 +14,7 @@
14 * into IP header for icv calculation. Options are already checked 14 * into IP header for icv calculation. Options are already checked
15 * for validity, so paranoia is not required. */ 15 * for validity, so paranoia is not required. */
16 16
17static int ip_clear_mutable_options(struct iphdr *iph, u32 *daddr) 17static int ip_clear_mutable_options(struct iphdr *iph, __be32 *daddr)
18{ 18{
19 unsigned char * optptr = (unsigned char*)(iph+1); 19 unsigned char * optptr = (unsigned char*)(iph+1);
20 int l = iph->ihl*4 - sizeof(struct iphdr); 20 int l = iph->ihl*4 - sizeof(struct iphdr);
@@ -162,7 +162,7 @@ static int ah_input(struct xfrm_state *x, struct sk_buff *skb)
162 iph->frag_off = 0; 162 iph->frag_off = 0;
163 iph->check = 0; 163 iph->check = 0;
164 if (ihl > sizeof(*iph)) { 164 if (ihl > sizeof(*iph)) {
165 u32 dummy; 165 __be32 dummy;
166 if (ip_clear_mutable_options(iph, &dummy)) 166 if (ip_clear_mutable_options(iph, &dummy))
167 goto out; 167 goto out;
168 } 168 }
diff --git a/net/ipv4/esp4.c b/net/ipv4/esp4.c
index b5c205b57669..f2c6776ea0e6 100644
--- a/net/ipv4/esp4.c
+++ b/net/ipv4/esp4.c
@@ -67,7 +67,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
67 if (x->encap) { 67 if (x->encap) {
68 struct xfrm_encap_tmpl *encap = x->encap; 68 struct xfrm_encap_tmpl *encap = x->encap;
69 struct udphdr *uh; 69 struct udphdr *uh;
70 u32 *udpdata32; 70 __be32 *udpdata32;
71 71
72 uh = (struct udphdr *)esph; 72 uh = (struct udphdr *)esph;
73 uh->source = encap->encap_sport; 73 uh->source = encap->encap_sport;
@@ -81,7 +81,7 @@ static int esp_output(struct xfrm_state *x, struct sk_buff *skb)
81 esph = (struct ip_esp_hdr *)(uh + 1); 81 esph = (struct ip_esp_hdr *)(uh + 1);
82 break; 82 break;
83 case UDP_ENCAP_ESPINUDP_NON_IKE: 83 case UDP_ENCAP_ESPINUDP_NON_IKE:
84 udpdata32 = (u32 *)(uh + 1); 84 udpdata32 = (__be32 *)(uh + 1);
85 udpdata32[0] = udpdata32[1] = 0; 85 udpdata32[0] = udpdata32[1] = 0;
86 esph = (struct ip_esp_hdr *)(udpdata32 + 2); 86 esph = (struct ip_esp_hdr *)(udpdata32 + 2);
87 break; 87 break;
diff --git a/net/ipv4/ip_gre.c b/net/ipv4/ip_gre.c
index d5b5dec075b8..25221146debb 100644
--- a/net/ipv4/ip_gre.c
+++ b/net/ipv4/ip_gre.c
@@ -144,7 +144,7 @@ static struct net_device *ipgre_fb_tunnel_dev;
144 */ 144 */
145 145
146#define HASH_SIZE 16 146#define HASH_SIZE 16
147#define HASH(addr) ((addr^(addr>>4))&0xF) 147#define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&0xF)
148 148
149static struct ip_tunnel *tunnels[4][HASH_SIZE]; 149static struct ip_tunnel *tunnels[4][HASH_SIZE];
150 150
@@ -157,7 +157,7 @@ static DEFINE_RWLOCK(ipgre_lock);
157 157
158/* Given src, dst and key, find appropriate for input tunnel. */ 158/* Given src, dst and key, find appropriate for input tunnel. */
159 159
160static struct ip_tunnel * ipgre_tunnel_lookup(u32 remote, u32 local, u32 key) 160static struct ip_tunnel * ipgre_tunnel_lookup(__be32 remote, __be32 local, __be32 key)
161{ 161{
162 unsigned h0 = HASH(remote); 162 unsigned h0 = HASH(remote);
163 unsigned h1 = HASH(key); 163 unsigned h1 = HASH(key);
@@ -194,9 +194,9 @@ static struct ip_tunnel * ipgre_tunnel_lookup(u32 remote, u32 local, u32 key)
194 194
195static struct ip_tunnel **ipgre_bucket(struct ip_tunnel *t) 195static struct ip_tunnel **ipgre_bucket(struct ip_tunnel *t)
196{ 196{
197 u32 remote = t->parms.iph.daddr; 197 __be32 remote = t->parms.iph.daddr;
198 u32 local = t->parms.iph.saddr; 198 __be32 local = t->parms.iph.saddr;
199 u32 key = t->parms.i_key; 199 __be32 key = t->parms.i_key;
200 unsigned h = HASH(key); 200 unsigned h = HASH(key);
201 int prio = 0; 201 int prio = 0;
202 202
@@ -236,9 +236,9 @@ static void ipgre_tunnel_unlink(struct ip_tunnel *t)
236 236
237static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int create) 237static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int create)
238{ 238{
239 u32 remote = parms->iph.daddr; 239 __be32 remote = parms->iph.daddr;
240 u32 local = parms->iph.saddr; 240 __be32 local = parms->iph.saddr;
241 u32 key = parms->i_key; 241 __be32 key = parms->i_key;
242 struct ip_tunnel *t, **tp, *nt; 242 struct ip_tunnel *t, **tp, *nt;
243 struct net_device *dev; 243 struct net_device *dev;
244 unsigned h = HASH(key); 244 unsigned h = HASH(key);
@@ -319,12 +319,12 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
319 */ 319 */
320 320
321 struct iphdr *iph = (struct iphdr*)skb->data; 321 struct iphdr *iph = (struct iphdr*)skb->data;
322 u16 *p = (u16*)(skb->data+(iph->ihl<<2)); 322 __be16 *p = (__be16*)(skb->data+(iph->ihl<<2));
323 int grehlen = (iph->ihl<<2) + 4; 323 int grehlen = (iph->ihl<<2) + 4;
324 int type = skb->h.icmph->type; 324 int type = skb->h.icmph->type;
325 int code = skb->h.icmph->code; 325 int code = skb->h.icmph->code;
326 struct ip_tunnel *t; 326 struct ip_tunnel *t;
327 u16 flags; 327 __be16 flags;
328 328
329 flags = p[0]; 329 flags = p[0];
330 if (flags&(GRE_CSUM|GRE_KEY|GRE_SEQ|GRE_ROUTING|GRE_VERSION)) { 330 if (flags&(GRE_CSUM|GRE_KEY|GRE_SEQ|GRE_ROUTING|GRE_VERSION)) {
@@ -370,7 +370,7 @@ static void ipgre_err(struct sk_buff *skb, u32 info)
370 } 370 }
371 371
372 read_lock(&ipgre_lock); 372 read_lock(&ipgre_lock);
373 t = ipgre_tunnel_lookup(iph->daddr, iph->saddr, (flags&GRE_KEY) ? *(((u32*)p) + (grehlen>>2) - 1) : 0); 373 t = ipgre_tunnel_lookup(iph->daddr, iph->saddr, (flags&GRE_KEY) ? *(((__be32*)p) + (grehlen>>2) - 1) : 0);
374 if (t == NULL || t->parms.iph.daddr == 0 || MULTICAST(t->parms.iph.daddr)) 374 if (t == NULL || t->parms.iph.daddr == 0 || MULTICAST(t->parms.iph.daddr))
375 goto out; 375 goto out;
376 376
@@ -388,14 +388,14 @@ out:
388#else 388#else
389 struct iphdr *iph = (struct iphdr*)dp; 389 struct iphdr *iph = (struct iphdr*)dp;
390 struct iphdr *eiph; 390 struct iphdr *eiph;
391 u16 *p = (u16*)(dp+(iph->ihl<<2)); 391 __be16 *p = (__be16*)(dp+(iph->ihl<<2));
392 int type = skb->h.icmph->type; 392 int type = skb->h.icmph->type;
393 int code = skb->h.icmph->code; 393 int code = skb->h.icmph->code;
394 int rel_type = 0; 394 int rel_type = 0;
395 int rel_code = 0; 395 int rel_code = 0;
396 __be32 rel_info = 0; 396 __be32 rel_info = 0;
397 __u32 n = 0; 397 __u32 n = 0;
398 u16 flags; 398 __be16 flags;
399 int grehlen = (iph->ihl<<2) + 4; 399 int grehlen = (iph->ihl<<2) + 4;
400 struct sk_buff *skb2; 400 struct sk_buff *skb2;
401 struct flowi fl; 401 struct flowi fl;
@@ -556,9 +556,9 @@ static int ipgre_rcv(struct sk_buff *skb)
556{ 556{
557 struct iphdr *iph; 557 struct iphdr *iph;
558 u8 *h; 558 u8 *h;
559 u16 flags; 559 __be16 flags;
560 u16 csum = 0; 560 u16 csum = 0;
561 u32 key = 0; 561 __be32 key = 0;
562 u32 seqno = 0; 562 u32 seqno = 0;
563 struct ip_tunnel *tunnel; 563 struct ip_tunnel *tunnel;
564 int offset = 4; 564 int offset = 4;
@@ -568,7 +568,7 @@ static int ipgre_rcv(struct sk_buff *skb)
568 568
569 iph = skb->nh.iph; 569 iph = skb->nh.iph;
570 h = skb->data; 570 h = skb->data;
571 flags = *(u16*)h; 571 flags = *(__be16*)h;
572 572
573 if (flags&(GRE_CSUM|GRE_KEY|GRE_ROUTING|GRE_SEQ|GRE_VERSION)) { 573 if (flags&(GRE_CSUM|GRE_KEY|GRE_ROUTING|GRE_SEQ|GRE_VERSION)) {
574 /* - Version must be 0. 574 /* - Version must be 0.
@@ -592,11 +592,11 @@ static int ipgre_rcv(struct sk_buff *skb)
592 offset += 4; 592 offset += 4;
593 } 593 }
594 if (flags&GRE_KEY) { 594 if (flags&GRE_KEY) {
595 key = *(u32*)(h + offset); 595 key = *(__be32*)(h + offset);
596 offset += 4; 596 offset += 4;
597 } 597 }
598 if (flags&GRE_SEQ) { 598 if (flags&GRE_SEQ) {
599 seqno = ntohl(*(u32*)(h + offset)); 599 seqno = ntohl(*(__be32*)(h + offset));
600 offset += 4; 600 offset += 4;
601 } 601 }
602 } 602 }
@@ -605,7 +605,7 @@ static int ipgre_rcv(struct sk_buff *skb)
605 if ((tunnel = ipgre_tunnel_lookup(iph->saddr, iph->daddr, key)) != NULL) { 605 if ((tunnel = ipgre_tunnel_lookup(iph->saddr, iph->daddr, key)) != NULL) {
606 secpath_reset(skb); 606 secpath_reset(skb);
607 607
608 skb->protocol = *(u16*)(h + 2); 608 skb->protocol = *(__be16*)(h + 2);
609 /* WCCP version 1 and 2 protocol decoding. 609 /* WCCP version 1 and 2 protocol decoding.
610 * - Change protocol to IP 610 * - Change protocol to IP
611 * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header 611 * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header
@@ -673,13 +673,13 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
673 struct iphdr *old_iph = skb->nh.iph; 673 struct iphdr *old_iph = skb->nh.iph;
674 struct iphdr *tiph; 674 struct iphdr *tiph;
675 u8 tos; 675 u8 tos;
676 u16 df; 676 __be16 df;
677 struct rtable *rt; /* Route to the other host */ 677 struct rtable *rt; /* Route to the other host */
678 struct net_device *tdev; /* Device to other host */ 678 struct net_device *tdev; /* Device to other host */
679 struct iphdr *iph; /* Our new IP header */ 679 struct iphdr *iph; /* Our new IP header */
680 int max_headroom; /* The extra header space needed */ 680 int max_headroom; /* The extra header space needed */
681 int gre_hlen; 681 int gre_hlen;
682 u32 dst; 682 __be32 dst;
683 int mtu; 683 int mtu;
684 684
685 if (tunnel->recursion++) { 685 if (tunnel->recursion++) {
@@ -860,11 +860,11 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
860 iph->ttl = dst_metric(&rt->u.dst, RTAX_HOPLIMIT); 860 iph->ttl = dst_metric(&rt->u.dst, RTAX_HOPLIMIT);
861 } 861 }
862 862
863 ((u16*)(iph+1))[0] = tunnel->parms.o_flags; 863 ((__be16*)(iph+1))[0] = tunnel->parms.o_flags;
864 ((u16*)(iph+1))[1] = skb->protocol; 864 ((__be16*)(iph+1))[1] = skb->protocol;
865 865
866 if (tunnel->parms.o_flags&(GRE_KEY|GRE_CSUM|GRE_SEQ)) { 866 if (tunnel->parms.o_flags&(GRE_KEY|GRE_CSUM|GRE_SEQ)) {
867 u32 *ptr = (u32*)(((u8*)iph) + tunnel->hlen - 4); 867 __be32 *ptr = (__be32*)(((u8*)iph) + tunnel->hlen - 4);
868 868
869 if (tunnel->parms.o_flags&GRE_SEQ) { 869 if (tunnel->parms.o_flags&GRE_SEQ) {
870 ++tunnel->o_seqno; 870 ++tunnel->o_seqno;
@@ -877,7 +877,7 @@ static int ipgre_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
877 } 877 }
878 if (tunnel->parms.o_flags&GRE_CSUM) { 878 if (tunnel->parms.o_flags&GRE_CSUM) {
879 *ptr = 0; 879 *ptr = 0;
880 *(__u16*)ptr = ip_compute_csum((void*)(iph+1), skb->len - sizeof(struct iphdr)); 880 *(__be16*)ptr = ip_compute_csum((void*)(iph+1), skb->len - sizeof(struct iphdr));
881 } 881 }
882 } 882 }
883 883
@@ -1068,7 +1068,7 @@ static int ipgre_header(struct sk_buff *skb, struct net_device *dev, unsigned sh
1068{ 1068{
1069 struct ip_tunnel *t = netdev_priv(dev); 1069 struct ip_tunnel *t = netdev_priv(dev);
1070 struct iphdr *iph = (struct iphdr *)skb_push(skb, t->hlen); 1070 struct iphdr *iph = (struct iphdr *)skb_push(skb, t->hlen);
1071 u16 *p = (u16*)(iph+1); 1071 __be16 *p = (__be16*)(iph+1);
1072 1072
1073 memcpy(iph, &t->parms.iph, sizeof(struct iphdr)); 1073 memcpy(iph, &t->parms.iph, sizeof(struct iphdr));
1074 p[0] = t->parms.o_flags; 1074 p[0] = t->parms.o_flags;
diff --git a/net/ipv4/ipip.c b/net/ipv4/ipip.c
index 0c4556529228..9d719d664e5b 100644
--- a/net/ipv4/ipip.c
+++ b/net/ipv4/ipip.c
@@ -118,7 +118,7 @@
118#include <net/xfrm.h> 118#include <net/xfrm.h>
119 119
120#define HASH_SIZE 16 120#define HASH_SIZE 16
121#define HASH(addr) ((addr^(addr>>4))&0xF) 121#define HASH(addr) (((__force u32)addr^((__force u32)addr>>4))&0xF)
122 122
123static int ipip_fb_tunnel_init(struct net_device *dev); 123static int ipip_fb_tunnel_init(struct net_device *dev);
124static int ipip_tunnel_init(struct net_device *dev); 124static int ipip_tunnel_init(struct net_device *dev);
@@ -134,7 +134,7 @@ static struct ip_tunnel **tunnels[4] = { tunnels_wc, tunnels_l, tunnels_r, tunne
134 134
135static DEFINE_RWLOCK(ipip_lock); 135static DEFINE_RWLOCK(ipip_lock);
136 136
137static struct ip_tunnel * ipip_tunnel_lookup(u32 remote, u32 local) 137static struct ip_tunnel * ipip_tunnel_lookup(__be32 remote, __be32 local)
138{ 138{
139 unsigned h0 = HASH(remote); 139 unsigned h0 = HASH(remote);
140 unsigned h1 = HASH(local); 140 unsigned h1 = HASH(local);
@@ -160,8 +160,8 @@ static struct ip_tunnel * ipip_tunnel_lookup(u32 remote, u32 local)
160 160
161static struct ip_tunnel **ipip_bucket(struct ip_tunnel *t) 161static struct ip_tunnel **ipip_bucket(struct ip_tunnel *t)
162{ 162{
163 u32 remote = t->parms.iph.daddr; 163 __be32 remote = t->parms.iph.daddr;
164 u32 local = t->parms.iph.saddr; 164 __be32 local = t->parms.iph.saddr;
165 unsigned h = 0; 165 unsigned h = 0;
166 int prio = 0; 166 int prio = 0;
167 167
@@ -203,8 +203,8 @@ static void ipip_tunnel_link(struct ip_tunnel *t)
203 203
204static struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int create) 204static struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int create)
205{ 205{
206 u32 remote = parms->iph.daddr; 206 __be32 remote = parms->iph.daddr;
207 u32 local = parms->iph.saddr; 207 __be32 local = parms->iph.saddr;
208 struct ip_tunnel *t, **tp, *nt; 208 struct ip_tunnel *t, **tp, *nt;
209 struct net_device *dev; 209 struct net_device *dev;
210 unsigned h = 0; 210 unsigned h = 0;
@@ -519,13 +519,13 @@ static int ipip_tunnel_xmit(struct sk_buff *skb, struct net_device *dev)
519 struct net_device_stats *stats = &tunnel->stat; 519 struct net_device_stats *stats = &tunnel->stat;
520 struct iphdr *tiph = &tunnel->parms.iph; 520 struct iphdr *tiph = &tunnel->parms.iph;
521 u8 tos = tunnel->parms.iph.tos; 521 u8 tos = tunnel->parms.iph.tos;
522 u16 df = tiph->frag_off; 522 __be16 df = tiph->frag_off;
523 struct rtable *rt; /* Route to the other host */ 523 struct rtable *rt; /* Route to the other host */
524 struct net_device *tdev; /* Device to other host */ 524 struct net_device *tdev; /* Device to other host */
525 struct iphdr *old_iph = skb->nh.iph; 525 struct iphdr *old_iph = skb->nh.iph;
526 struct iphdr *iph; /* Our new IP header */ 526 struct iphdr *iph; /* Our new IP header */
527 int max_headroom; /* The extra header space needed */ 527 int max_headroom; /* The extra header space needed */
528 u32 dst = tiph->daddr; 528 __be32 dst = tiph->daddr;
529 int mtu; 529 int mtu;
530 530
531 if (tunnel->recursion++) { 531 if (tunnel->recursion++) {