Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[IPV6]: Assorted trivial endianness annotations.

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

authored by

Al Viro and committed by
David S. Miller
714e85be 252e3346

+50 -47
+8 -6
include/linux/inetdevice.h
··· 124 124 * Check if a mask is acceptable. 125 125 */ 126 126 127 - static __inline__ int bad_mask(u32 mask, u32 addr) 127 + static __inline__ int bad_mask(__be32 mask, __be32 addr) 128 128 { 129 + __u32 hmask; 129 130 if (addr & (mask = ~mask)) 130 131 return 1; 131 - mask = ntohl(mask); 132 - if (mask & (mask+1)) 132 + hmask = ntohl(mask); 133 + if (hmask & (hmask+1)) 133 134 return 1; 134 135 return 0; 135 136 } ··· 191 190 return 0; 192 191 } 193 192 194 - static __inline__ int inet_mask_len(__u32 mask) 193 + static __inline__ int inet_mask_len(__be32 mask) 195 194 { 196 - if (!(mask = ntohl(mask))) 195 + __u32 hmask = ntohl(mask); 196 + if (!hmask) 197 197 return 0; 198 - return 32 - ffz(~mask); 198 + return 32 - ffz(~hmask); 199 199 } 200 200 201 201
+1 -1
include/net/arp.h
··· 16 16 struct net_device *dev, __be32 src_ip, 17 17 unsigned char *dest_hw, unsigned char *src_hw, unsigned char *th); 18 18 extern int arp_bind_neighbour(struct dst_entry *dst); 19 - extern int arp_mc_map(u32 addr, u8 *haddr, struct net_device *dev, int dir); 19 + extern int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir); 20 20 extern void arp_ifdown(struct net_device *dev); 21 21 22 22 extern struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,
+6 -5
include/net/ip.h
··· 123 123 * multicast packets. 124 124 */ 125 125 126 - static inline void ip_tr_mc_map(u32 addr, char *buf) 126 + static inline void ip_tr_mc_map(__be32 addr, char *buf) 127 127 { 128 128 buf[0]=0xC0; 129 129 buf[1]=0x00; ··· 238 238 * Map a multicast IP onto multicast MAC for type ethernet. 239 239 */ 240 240 241 - static inline void ip_eth_mc_map(u32 addr, char *buf) 241 + static inline void ip_eth_mc_map(__be32 naddr, char *buf) 242 242 { 243 - addr=ntohl(addr); 243 + __u32 addr=ntohl(naddr); 244 244 buf[0]=0x01; 245 245 buf[1]=0x00; 246 246 buf[2]=0x5e; ··· 256 256 * Leave P_Key as 0 to be filled in by driver. 257 257 */ 258 258 259 - static inline void ip_ib_mc_map(u32 addr, char *buf) 259 + static inline void ip_ib_mc_map(__be32 naddr, char *buf) 260 260 { 261 + __u32 addr; 261 262 buf[0] = 0; /* Reserved */ 262 263 buf[1] = 0xff; /* Multicast QPN */ 263 264 buf[2] = 0xff; 264 265 buf[3] = 0xff; 265 - addr = ntohl(addr); 266 + addr = ntohl(naddr); 266 267 buf[4] = 0xff; 267 268 buf[5] = 0x12; /* link local scope */ 268 269 buf[6] = 0x40; /* IPv4 signature */
+3 -3
net/ipv4/af_inet.c
··· 644 644 sin->sin_port = inet->dport; 645 645 sin->sin_addr.s_addr = inet->daddr; 646 646 } else { 647 - __u32 addr = inet->rcv_saddr; 647 + __be32 addr = inet->rcv_saddr; 648 648 if (!addr) 649 649 addr = inet->saddr; 650 650 sin->sin_port = inet->sport; ··· 995 995 struct inet_sock *inet = inet_sk(sk); 996 996 int err; 997 997 struct rtable *rt; 998 - __u32 old_saddr = inet->saddr; 999 - __u32 new_saddr; 998 + __be32 old_saddr = inet->saddr; 999 + __be32 new_saddr; 1000 1000 __be32 daddr = inet->daddr; 1001 1001 1002 1002 if (inet->opt && inet->opt->srr)
+1 -1
net/ipv4/arp.c
··· 203 203 .gc_thresh3 = 1024, 204 204 }; 205 205 206 - int arp_mc_map(u32 addr, u8 *haddr, struct net_device *dev, int dir) 206 + int arp_mc_map(__be32 addr, u8 *haddr, struct net_device *dev, int dir) 207 207 { 208 208 switch (dev->type) { 209 209 case ARPHRD_ETHER:
+4 -4
net/ipv4/cipso_ipv4.c
··· 966 966 967 967 buf[0] = IPOPT_CIPSO; 968 968 buf[1] = CIPSO_V4_HDR_LEN + len; 969 - *(u32 *)&buf[2] = htonl(doi_def->doi); 969 + *(__be32 *)&buf[2] = htonl(doi_def->doi); 970 970 971 971 return 0; 972 972 } ··· 1140 1140 } 1141 1141 1142 1142 rcu_read_lock(); 1143 - doi_def = cipso_v4_doi_getdef(ntohl(*((u32 *)&opt[2]))); 1143 + doi_def = cipso_v4_doi_getdef(ntohl(*((__be32 *)&opt[2]))); 1144 1144 if (doi_def == NULL) { 1145 1145 err_offset = 2; 1146 1146 goto validate_return_locked; ··· 1370 1370 if (ret_val == 0) 1371 1371 return ret_val; 1372 1372 1373 - doi = ntohl(*(u32 *)&cipso_ptr[2]); 1373 + doi = ntohl(*(__be32 *)&cipso_ptr[2]); 1374 1374 rcu_read_lock(); 1375 1375 doi_def = cipso_v4_doi_getdef(doi); 1376 1376 if (doi_def == NULL) { ··· 1436 1436 if (cipso_v4_cache_check(cipso_ptr, cipso_ptr[1], secattr) == 0) 1437 1437 return 0; 1438 1438 1439 - doi = ntohl(*(u32 *)&cipso_ptr[2]); 1439 + doi = ntohl(*(__be32 *)&cipso_ptr[2]); 1440 1440 rcu_read_lock(); 1441 1441 doi_def = cipso_v4_doi_getdef(doi); 1442 1442 if (doi_def == NULL)
+5 -5
net/ipv4/devinet.c
··· 577 577 * Determine a default network mask, based on the IP address. 578 578 */ 579 579 580 - static __inline__ int inet_abc_len(u32 addr) 580 + static __inline__ int inet_abc_len(__be32 addr) 581 581 { 582 582 int rc = -1; /* Something else, probably a multicast. */ 583 583 584 584 if (ZERONET(addr)) 585 585 rc = 0; 586 586 else { 587 - addr = ntohl(addr); 587 + __u32 haddr = ntohl(addr); 588 588 589 - if (IN_CLASSA(addr)) 589 + if (IN_CLASSA(haddr)) 590 590 rc = 8; 591 - else if (IN_CLASSB(addr)) 591 + else if (IN_CLASSB(haddr)) 592 592 rc = 16; 593 - else if (IN_CLASSC(addr)) 593 + else if (IN_CLASSC(haddr)) 594 594 rc = 24; 595 595 } 596 596
+1 -1
net/ipv4/ip_output.c
··· 341 341 342 342 /* OK, we know where to send it, allocate and build IP header. */ 343 343 iph = (struct iphdr *) skb_push(skb, sizeof(struct iphdr) + (opt ? opt->optlen : 0)); 344 - *((__u16 *)iph) = htons((4 << 12) | (5 << 8) | (inet->tos & 0xff)); 344 + *((__be16 *)iph) = htons((4 << 12) | (5 << 8) | (inet->tos & 0xff)); 345 345 iph->tot_len = htons(skb->len); 346 346 if (ip_dont_fragment(sk, &rt->u.dst) && !ipfragok) 347 347 iph->frag_off = htons(IP_DF);
+1 -1
net/ipv4/ip_sockglue.c
··· 355 355 sin = (struct sockaddr_in *)msg->msg_name; 356 356 if (sin) { 357 357 sin->sin_family = AF_INET; 358 - sin->sin_addr.s_addr = *(u32*)(skb->nh.raw + serr->addr_offset); 358 + sin->sin_addr.s_addr = *(__be32*)(skb->nh.raw + serr->addr_offset); 359 359 sin->sin_port = serr->port; 360 360 memset(&sin->sin_zero, 0, sizeof(sin->sin_zero)); 361 361 }
+2 -2
net/ipv4/raw.c
··· 854 854 static __inline__ char *get_raw_sock(struct sock *sp, char *tmpbuf, int i) 855 855 { 856 856 struct inet_sock *inet = inet_sk(sp); 857 - unsigned int dest = inet->daddr, 858 - src = inet->rcv_saddr; 857 + __be32 dest = inet->daddr, 858 + src = inet->rcv_saddr; 859 859 __u16 destp = 0, 860 860 srcp = inet->num; 861 861
+2 -2
net/ipv4/route.c
··· 566 566 567 567 static inline int compare_keys(struct flowi *fl1, struct flowi *fl2) 568 568 { 569 - return ((fl1->nl_u.ip4_u.daddr ^ fl2->nl_u.ip4_u.daddr) | 570 - (fl1->nl_u.ip4_u.saddr ^ fl2->nl_u.ip4_u.saddr) | 569 + return ((__force u32)((fl1->nl_u.ip4_u.daddr ^ fl2->nl_u.ip4_u.daddr) | 570 + (fl1->nl_u.ip4_u.saddr ^ fl2->nl_u.ip4_u.saddr)) | 571 571 (fl1->mark ^ fl2->mark) | 572 572 (*(u16 *)&fl1->nl_u.ip4_u.tos ^ 573 573 *(u16 *)&fl2->nl_u.ip4_u.tos) |
+9 -9
net/ipv4/syncookies.c
··· 35 35 #define COOKIEBITS 24 /* Upper bits store count */ 36 36 #define COOKIEMASK (((__u32)1 << COOKIEBITS) - 1) 37 37 38 - static u32 cookie_hash(u32 saddr, u32 daddr, u32 sport, u32 dport, 38 + static u32 cookie_hash(__be32 saddr, __be32 daddr, __be16 sport, __be16 dport, 39 39 u32 count, int c) 40 40 { 41 41 __u32 tmp[16 + 5 + SHA_WORKSPACE_WORDS]; 42 42 43 43 memcpy(tmp + 3, syncookie_secret[c], sizeof(syncookie_secret[c])); 44 - tmp[0] = saddr; 45 - tmp[1] = daddr; 46 - tmp[2] = (sport << 16) + dport; 44 + tmp[0] = (__force u32)saddr; 45 + tmp[1] = (__force u32)daddr; 46 + tmp[2] = ((__force u32)sport << 16) + (__force u32)dport; 47 47 tmp[3] = count; 48 48 sha_transform(tmp + 16, (__u8 *)tmp, tmp + 16 + 5); 49 49 50 50 return tmp[17]; 51 51 } 52 52 53 - static __u32 secure_tcp_syn_cookie(__u32 saddr, __u32 daddr, __u16 sport, 54 - __u16 dport, __u32 sseq, __u32 count, 53 + static __u32 secure_tcp_syn_cookie(__be32 saddr, __be32 daddr, __be16 sport, 54 + __be16 dport, __u32 sseq, __u32 count, 55 55 __u32 data) 56 56 { 57 57 /* ··· 80 80 * "maxdiff" if the current (passed-in) "count". The return value 81 81 * is (__u32)-1 if this test fails. 82 82 */ 83 - static __u32 check_tcp_syn_cookie(__u32 cookie, __u32 saddr, __u32 daddr, 84 - __u16 sport, __u16 dport, __u32 sseq, 83 + static __u32 check_tcp_syn_cookie(__u32 cookie, __be32 saddr, __be32 daddr, 84 + __be16 sport, __be16 dport, __u32 sseq, 85 85 __u32 count, __u32 maxdiff) 86 86 { 87 87 __u32 diff; ··· 220 220 } 221 221 ireq = inet_rsk(req); 222 222 treq = tcp_rsk(req); 223 - treq->rcv_isn = htonl(skb->h.th->seq) - 1; 223 + treq->rcv_isn = ntohl(skb->h.th->seq) - 1; 224 224 treq->snt_isn = cookie; 225 225 req->mss = mss; 226 226 ireq->rmt_port = skb->h.th->source;
+5 -5
net/ipv4/tcp_ipv4.c
··· 542 542 struct { 543 543 struct tcphdr th; 544 544 #ifdef CONFIG_TCP_MD5SIG 545 - u32 opt[(TCPOLEN_MD5SIG_ALIGNED >> 2)]; 545 + __be32 opt[(TCPOLEN_MD5SIG_ALIGNED >> 2)]; 546 546 #endif 547 547 } rep; 548 548 struct ip_reply_arg arg; ··· 618 618 struct tcphdr *th = skb->h.th; 619 619 struct { 620 620 struct tcphdr th; 621 - u32 opt[(TCPOLEN_TSTAMP_ALIGNED >> 2) 621 + __be32 opt[(TCPOLEN_TSTAMP_ALIGNED >> 2) 622 622 #ifdef CONFIG_TCP_MD5SIG 623 - + (TCPOLEN_MD5SIG_ALIGNED >> 2) 623 + + (TCPOLEN_MD5SIG_ALIGNED >> 2) 624 624 #endif 625 625 ]; 626 626 } rep; ··· 2333 2333 struct tcp_sock *tp = tcp_sk(sp); 2334 2334 const struct inet_connection_sock *icsk = inet_csk(sp); 2335 2335 struct inet_sock *inet = inet_sk(sp); 2336 - unsigned int dest = inet->daddr; 2337 - unsigned int src = inet->rcv_saddr; 2336 + __be32 dest = inet->daddr; 2337 + __be32 src = inet->rcv_saddr; 2338 2338 __u16 destp = ntohs(inet->dport); 2339 2339 __u16 srcp = ntohs(inet->sport); 2340 2340
+1 -1
net/ipv4/tcp_minisocks.c
··· 493 493 struct request_sock **prev) 494 494 { 495 495 struct tcphdr *th = skb->h.th; 496 - u32 flg = tcp_flag_word(th) & (TCP_FLAG_RST|TCP_FLAG_SYN|TCP_FLAG_ACK); 496 + __be32 flg = tcp_flag_word(th) & (TCP_FLAG_RST|TCP_FLAG_SYN|TCP_FLAG_ACK); 497 497 int paws_reject = 0; 498 498 struct tcp_options_received tmp_opt; 499 499 struct sock *child;
+1 -1
net/ipv4/tcp_timer.c
··· 297 297 if (net_ratelimit()) { 298 298 struct inet_sock *inet = inet_sk(sk); 299 299 printk(KERN_DEBUG "TCP: Treason uncloaked! Peer %u.%u.%u.%u:%u/%u shrinks window %u:%u. Repaired.\n", 300 - NIPQUAD(inet->daddr), htons(inet->dport), 300 + NIPQUAD(inet->daddr), ntohs(inet->dport), 301 301 inet->num, tp->snd_una, tp->snd_nxt); 302 302 } 303 303 #endif