Commit d5a0a1e3109339090769e40fdaa62482fcf2a717

Authored by Al Viro
Committed by David S. Miller
1 parent 4806126d78

[IPV4]: encapsulation annotations

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>

Showing 6 changed files with 44 additions and 44 deletions Side-by-side Diff

include/linux/if_tunnel.h
... ... @@ -19,10 +19,10 @@
19 19 {
20 20 char name[IFNAMSIZ];
21 21 int link;
22   - __u16 i_flags;
23   - __u16 o_flags;
24   - __u32 i_key;
25   - __u32 o_key;
  22 + __be16 i_flags;
  23 + __be16 o_flags;
  24 + __be32 i_key;
  25 + __be32 o_key;
26 26 struct iphdr iph;
27 27 };
28 28  
include/linux/xfrm.h
... ... @@ -211,8 +211,8 @@
211 211  
212 212 struct xfrm_encap_tmpl {
213 213 __u16 encap_type;
214   - __u16 encap_sport;
215   - __u16 encap_dport;
  214 + __be16 encap_sport;
  215 + __be16 encap_dport;
216 216 xfrm_address_t encap_oa;
217 217 };
218 218  
... ... @@ -14,7 +14,7 @@
14 14 * into IP header for icv calculation. Options are already checked
15 15 * for validity, so paranoia is not required. */
16 16  
17   -static int ip_clear_mutable_options(struct iphdr *iph, u32 *daddr)
  17 +static int ip_clear_mutable_options(struct iphdr *iph, __be32 *daddr)
18 18 {
19 19 unsigned char * optptr = (unsigned char*)(iph+1);
20 20 int l = iph->ihl*4 - sizeof(struct iphdr);
... ... @@ -162,7 +162,7 @@
162 162 iph->frag_off = 0;
163 163 iph->check = 0;
164 164 if (ihl > sizeof(*iph)) {
165   - u32 dummy;
  165 + __be32 dummy;
166 166 if (ip_clear_mutable_options(iph, &dummy))
167 167 goto out;
168 168 }
... ... @@ -67,7 +67,7 @@
67 67 if (x->encap) {
68 68 struct xfrm_encap_tmpl *encap = x->encap;
69 69 struct udphdr *uh;
70   - u32 *udpdata32;
  70 + __be32 *udpdata32;
71 71  
72 72 uh = (struct udphdr *)esph;
73 73 uh->source = encap->encap_sport;
... ... @@ -81,7 +81,7 @@
81 81 esph = (struct ip_esp_hdr *)(uh + 1);
82 82 break;
83 83 case UDP_ENCAP_ESPINUDP_NON_IKE:
84   - udpdata32 = (u32 *)(uh + 1);
  84 + udpdata32 = (__be32 *)(uh + 1);
85 85 udpdata32[0] = udpdata32[1] = 0;
86 86 esph = (struct ip_esp_hdr *)(udpdata32 + 2);
87 87 break;
... ... @@ -144,7 +144,7 @@
144 144 */
145 145  
146 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  
149 149 static struct ip_tunnel *tunnels[4][HASH_SIZE];
150 150  
... ... @@ -157,7 +157,7 @@
157 157  
158 158 /* Given src, dst and key, find appropriate for input tunnel. */
159 159  
160   -static struct ip_tunnel * ipgre_tunnel_lookup(u32 remote, u32 local, u32 key)
  160 +static struct ip_tunnel * ipgre_tunnel_lookup(__be32 remote, __be32 local, __be32 key)
161 161 {
162 162 unsigned h0 = HASH(remote);
163 163 unsigned h1 = HASH(key);
... ... @@ -194,9 +194,9 @@
194 194  
195 195 static struct ip_tunnel **ipgre_bucket(struct ip_tunnel *t)
196 196 {
197   - u32 remote = t->parms.iph.daddr;
198   - u32 local = t->parms.iph.saddr;
199   - u32 key = t->parms.i_key;
  197 + __be32 remote = t->parms.iph.daddr;
  198 + __be32 local = t->parms.iph.saddr;
  199 + __be32 key = t->parms.i_key;
200 200 unsigned h = HASH(key);
201 201 int prio = 0;
202 202  
... ... @@ -236,9 +236,9 @@
236 236  
237 237 static struct ip_tunnel * ipgre_tunnel_locate(struct ip_tunnel_parm *parms, int create)
238 238 {
239   - u32 remote = parms->iph.daddr;
240   - u32 local = parms->iph.saddr;
241   - u32 key = parms->i_key;
  239 + __be32 remote = parms->iph.daddr;
  240 + __be32 local = parms->iph.saddr;
  241 + __be32 key = parms->i_key;
242 242 struct ip_tunnel *t, **tp, *nt;
243 243 struct net_device *dev;
244 244 unsigned h = HASH(key);
245 245  
... ... @@ -319,12 +319,12 @@
319 319 */
320 320  
321 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 323 int grehlen = (iph->ihl<<2) + 4;
324 324 int type = skb->h.icmph->type;
325 325 int code = skb->h.icmph->code;
326 326 struct ip_tunnel *t;
327   - u16 flags;
  327 + __be16 flags;
328 328  
329 329 flags = p[0];
330 330 if (flags&(GRE_CSUM|GRE_KEY|GRE_SEQ|GRE_ROUTING|GRE_VERSION)) {
... ... @@ -370,7 +370,7 @@
370 370 }
371 371  
372 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 374 if (t == NULL || t->parms.iph.daddr == 0 || MULTICAST(t->parms.iph.daddr))
375 375 goto out;
376 376  
377 377  
... ... @@ -388,14 +388,14 @@
388 388 #else
389 389 struct iphdr *iph = (struct iphdr*)dp;
390 390 struct iphdr *eiph;
391   - u16 *p = (u16*)(dp+(iph->ihl<<2));
  391 + __be16 *p = (__be16*)(dp+(iph->ihl<<2));
392 392 int type = skb->h.icmph->type;
393 393 int code = skb->h.icmph->code;
394 394 int rel_type = 0;
395 395 int rel_code = 0;
396 396 __be32 rel_info = 0;
397 397 __u32 n = 0;
398   - u16 flags;
  398 + __be16 flags;
399 399 int grehlen = (iph->ihl<<2) + 4;
400 400 struct sk_buff *skb2;
401 401 struct flowi fl;
402 402  
... ... @@ -556,9 +556,9 @@
556 556 {
557 557 struct iphdr *iph;
558 558 u8 *h;
559   - u16 flags;
  559 + __be16 flags;
560 560 u16 csum = 0;
561   - u32 key = 0;
  561 + __be32 key = 0;
562 562 u32 seqno = 0;
563 563 struct ip_tunnel *tunnel;
564 564 int offset = 4;
... ... @@ -568,7 +568,7 @@
568 568  
569 569 iph = skb->nh.iph;
570 570 h = skb->data;
571   - flags = *(u16*)h;
  571 + flags = *(__be16*)h;
572 572  
573 573 if (flags&(GRE_CSUM|GRE_KEY|GRE_ROUTING|GRE_SEQ|GRE_VERSION)) {
574 574 /* - Version must be 0.
575 575  
... ... @@ -592,11 +592,11 @@
592 592 offset += 4;
593 593 }
594 594 if (flags&GRE_KEY) {
595   - key = *(u32*)(h + offset);
  595 + key = *(__be32*)(h + offset);
596 596 offset += 4;
597 597 }
598 598 if (flags&GRE_SEQ) {
599   - seqno = ntohl(*(u32*)(h + offset));
  599 + seqno = ntohl(*(__be32*)(h + offset));
600 600 offset += 4;
601 601 }
602 602 }
... ... @@ -605,7 +605,7 @@
605 605 if ((tunnel = ipgre_tunnel_lookup(iph->saddr, iph->daddr, key)) != NULL) {
606 606 secpath_reset(skb);
607 607  
608   - skb->protocol = *(u16*)(h + 2);
  608 + skb->protocol = *(__be16*)(h + 2);
609 609 /* WCCP version 1 and 2 protocol decoding.
610 610 * - Change protocol to IP
611 611 * - When dealing with WCCPv2, Skip extra 4 bytes in GRE header
612 612  
... ... @@ -673,13 +673,13 @@
673 673 struct iphdr *old_iph = skb->nh.iph;
674 674 struct iphdr *tiph;
675 675 u8 tos;
676   - u16 df;
  676 + __be16 df;
677 677 struct rtable *rt; /* Route to the other host */
678 678 struct net_device *tdev; /* Device to other host */
679 679 struct iphdr *iph; /* Our new IP header */
680 680 int max_headroom; /* The extra header space needed */
681 681 int gre_hlen;
682   - u32 dst;
  682 + __be32 dst;
683 683 int mtu;
684 684  
685 685 if (tunnel->recursion++) {
686 686  
... ... @@ -860,11 +860,11 @@
860 860 iph->ttl = dst_metric(&rt->u.dst, RTAX_HOPLIMIT);
861 861 }
862 862  
863   - ((u16*)(iph+1))[0] = tunnel->parms.o_flags;
864   - ((u16*)(iph+1))[1] = skb->protocol;
  863 + ((__be16*)(iph+1))[0] = tunnel->parms.o_flags;
  864 + ((__be16*)(iph+1))[1] = skb->protocol;
865 865  
866 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 869 if (tunnel->parms.o_flags&GRE_SEQ) {
870 870 ++tunnel->o_seqno;
... ... @@ -877,7 +877,7 @@
877 877 }
878 878 if (tunnel->parms.o_flags&GRE_CSUM) {
879 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 @@
1068 1068 {
1069 1069 struct ip_tunnel *t = netdev_priv(dev);
1070 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 1073 memcpy(iph, &t->parms.iph, sizeof(struct iphdr));
1074 1074 p[0] = t->parms.o_flags;
... ... @@ -118,7 +118,7 @@
118 118 #include <net/xfrm.h>
119 119  
120 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  
123 123 static int ipip_fb_tunnel_init(struct net_device *dev);
124 124 static int ipip_tunnel_init(struct net_device *dev);
... ... @@ -134,7 +134,7 @@
134 134  
135 135 static DEFINE_RWLOCK(ipip_lock);
136 136  
137   -static struct ip_tunnel * ipip_tunnel_lookup(u32 remote, u32 local)
  137 +static struct ip_tunnel * ipip_tunnel_lookup(__be32 remote, __be32 local)
138 138 {
139 139 unsigned h0 = HASH(remote);
140 140 unsigned h1 = HASH(local);
... ... @@ -160,8 +160,8 @@
160 160  
161 161 static struct ip_tunnel **ipip_bucket(struct ip_tunnel *t)
162 162 {
163   - u32 remote = t->parms.iph.daddr;
164   - u32 local = t->parms.iph.saddr;
  163 + __be32 remote = t->parms.iph.daddr;
  164 + __be32 local = t->parms.iph.saddr;
165 165 unsigned h = 0;
166 166 int prio = 0;
167 167  
... ... @@ -203,8 +203,8 @@
203 203  
204 204 static struct ip_tunnel * ipip_tunnel_locate(struct ip_tunnel_parm *parms, int create)
205 205 {
206   - u32 remote = parms->iph.daddr;
207   - u32 local = parms->iph.saddr;
  206 + __be32 remote = parms->iph.daddr;
  207 + __be32 local = parms->iph.saddr;
208 208 struct ip_tunnel *t, **tp, *nt;
209 209 struct net_device *dev;
210 210 unsigned h = 0;
211 211  
... ... @@ -519,13 +519,13 @@
519 519 struct net_device_stats *stats = &tunnel->stat;
520 520 struct iphdr *tiph = &tunnel->parms.iph;
521 521 u8 tos = tunnel->parms.iph.tos;
522   - u16 df = tiph->frag_off;
  522 + __be16 df = tiph->frag_off;
523 523 struct rtable *rt; /* Route to the other host */
524 524 struct net_device *tdev; /* Device to other host */
525 525 struct iphdr *old_iph = skb->nh.iph;
526 526 struct iphdr *iph; /* Our new IP header */
527 527 int max_headroom; /* The extra header space needed */
528   - u32 dst = tiph->daddr;
  528 + __be32 dst = tiph->daddr;
529 529 int mtu;
530 530  
531 531 if (tunnel->recursion++) {