Skip to content

Commit 714e85b

Browse files
Al ViroDavid S. Miller
authored andcommitted
[IPV6]: Assorted trivial endianness annotations.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 252e334 commit 714e85b

15 files changed

Lines changed: 50 additions & 47 deletions

File tree

‎include/linux/inetdevice.h‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,12 +124,13 @@ static __inline__ int inet_ifa_match(__be32 addr, struct in_ifaddr *ifa)
124124
* Check if a mask is acceptable.
125125
*/
126126

127-
static __inline__ int bad_mask(u32 mask, u32 addr)
127+
static __inline__ int bad_mask(__be32 mask, __be32 addr)
128128
{
129+
__u32 hmask;
129130
if (addr & (mask = ~mask))
130131
return 1;
131-
mask = ntohl(mask);
132-
if (mask & (mask+1))
132+
hmask = ntohl(mask);
133+
if (hmask & (hmask+1))
133134
return 1;
134135
return 0;
135136
}
@@ -190,11 +191,12 @@ static __inline__ __be32 inet_make_mask(int logmask)
190191
return 0;
191192
}
192193

193-
static __inline__ int inet_mask_len(__u32 mask)
194+
static __inline__ int inet_mask_len(__be32 mask)
194195
{
195-
if (!(mask = ntohl(mask)))
196+
__u32 hmask = ntohl(mask);
197+
if (!hmask)
196198
return 0;
197-
return 32 - ffz(~mask);
199+
return 32 - ffz(~hmask);
198200
}
199201

200202

‎include/net/arp.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ extern void arp_send(int type, int ptype, __be32 dest_ip,
1616
struct net_device *dev, __be32 src_ip,
1717
unsigned char *dest_hw, unsigned char *src_hw, unsigned char *th);
1818
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);
2020
extern void arp_ifdown(struct net_device *dev);
2121

2222
extern struct sk_buff *arp_create(int type, int ptype, __be32 dest_ip,

‎include/net/ip.h‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ extern int ip4_datagram_connect(struct sock *sk,
123123
* multicast packets.
124124
*/
125125

126-
static inline void ip_tr_mc_map(u32 addr, char *buf)
126+
static inline void ip_tr_mc_map(__be32 addr, char *buf)
127127
{
128128
buf[0]=0xC0;
129129
buf[1]=0x00;
@@ -238,9 +238,9 @@ static inline void ip_select_ident_more(struct iphdr *iph, struct dst_entry *dst
238238
* Map a multicast IP onto multicast MAC for type ethernet.
239239
*/
240240

241-
static inline void ip_eth_mc_map(u32 addr, char *buf)
241+
static inline void ip_eth_mc_map(__be32 naddr, char *buf)
242242
{
243-
addr=ntohl(addr);
243+
__u32 addr=ntohl(naddr);
244244
buf[0]=0x01;
245245
buf[1]=0x00;
246246
buf[2]=0x5e;
@@ -256,13 +256,14 @@ static inline void ip_eth_mc_map(u32 addr, char *buf)
256256
* Leave P_Key as 0 to be filled in by driver.
257257
*/
258258

259-
static inline void ip_ib_mc_map(u32 addr, char *buf)
259+
static inline void ip_ib_mc_map(__be32 naddr, char *buf)
260260
{
261+
__u32 addr;
261262
buf[0] = 0; /* Reserved */
262263
buf[1] = 0xff; /* Multicast QPN */
263264
buf[2] = 0xff;
264265
buf[3] = 0xff;
265-
addr = ntohl(addr);
266+
addr = ntohl(naddr);
266267
buf[4] = 0xff;
267268
buf[5] = 0x12; /* link local scope */
268269
buf[6] = 0x40; /* IPv4 signature */

‎net/ipv4/af_inet.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,7 @@ int inet_getname(struct socket *sock, struct sockaddr *uaddr,
644644
sin->sin_port = inet->dport;
645645
sin->sin_addr.s_addr = inet->daddr;
646646
} else {
647-
__u32 addr = inet->rcv_saddr;
647+
__be32 addr = inet->rcv_saddr;
648648
if (!addr)
649649
addr = inet->saddr;
650650
sin->sin_port = inet->sport;
@@ -995,8 +995,8 @@ static int inet_sk_reselect_saddr(struct sock *sk)
995995
struct inet_sock *inet = inet_sk(sk);
996996
int err;
997997
struct rtable *rt;
998-
__u32 old_saddr = inet->saddr;
999-
__u32 new_saddr;
998+
__be32 old_saddr = inet->saddr;
999+
__be32 new_saddr;
10001000
__be32 daddr = inet->daddr;
10011001

10021002
if (inet->opt && inet->opt->srr)

‎net/ipv4/arp.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ struct neigh_table arp_tbl = {
203203
.gc_thresh3 = 1024,
204204
};
205205

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)
207207
{
208208
switch (dev->type) {
209209
case ARPHRD_ETHER:

‎net/ipv4/cipso_ipv4.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ static int cipso_v4_gentag_hdr(const struct cipso_v4_doi *doi_def,
966966

967967
buf[0] = IPOPT_CIPSO;
968968
buf[1] = CIPSO_V4_HDR_LEN + len;
969-
*(u32 *)&buf[2] = htonl(doi_def->doi);
969+
*(__be32 *)&buf[2] = htonl(doi_def->doi);
970970

971971
return 0;
972972
}
@@ -1140,7 +1140,7 @@ int cipso_v4_validate(unsigned char **option)
11401140
}
11411141

11421142
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])));
11441144
if (doi_def == NULL) {
11451145
err_offset = 2;
11461146
goto validate_return_locked;
@@ -1370,7 +1370,7 @@ int cipso_v4_sock_getattr(struct sock *sk, struct netlbl_lsm_secattr *secattr)
13701370
if (ret_val == 0)
13711371
return ret_val;
13721372

1373-
doi = ntohl(*(u32 *)&cipso_ptr[2]);
1373+
doi = ntohl(*(__be32 *)&cipso_ptr[2]);
13741374
rcu_read_lock();
13751375
doi_def = cipso_v4_doi_getdef(doi);
13761376
if (doi_def == NULL) {
@@ -1436,7 +1436,7 @@ int cipso_v4_skbuff_getattr(const struct sk_buff *skb,
14361436
if (cipso_v4_cache_check(cipso_ptr, cipso_ptr[1], secattr) == 0)
14371437
return 0;
14381438

1439-
doi = ntohl(*(u32 *)&cipso_ptr[2]);
1439+
doi = ntohl(*(__be32 *)&cipso_ptr[2]);
14401440
rcu_read_lock();
14411441
doi_def = cipso_v4_doi_getdef(doi);
14421442
if (doi_def == NULL)

‎net/ipv4/devinet.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -577,20 +577,20 @@ static int inet_rtm_newaddr(struct sk_buff *skb, struct nlmsghdr *nlh, void *arg
577577
* Determine a default network mask, based on the IP address.
578578
*/
579579

580-
static __inline__ int inet_abc_len(u32 addr)
580+
static __inline__ int inet_abc_len(__be32 addr)
581581
{
582582
int rc = -1; /* Something else, probably a multicast. */
583583

584584
if (ZERONET(addr))
585585
rc = 0;
586586
else {
587-
addr = ntohl(addr);
587+
__u32 haddr = ntohl(addr);
588588

589-
if (IN_CLASSA(addr))
589+
if (IN_CLASSA(haddr))
590590
rc = 8;
591-
else if (IN_CLASSB(addr))
591+
else if (IN_CLASSB(haddr))
592592
rc = 16;
593-
else if (IN_CLASSC(addr))
593+
else if (IN_CLASSC(haddr))
594594
rc = 24;
595595
}
596596

‎net/ipv4/ip_output.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ int ip_queue_xmit(struct sk_buff *skb, struct sock *sk, int ipfragok)
341341

342342
/* OK, we know where to send it, allocate and build IP header. */
343343
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));
345345
iph->tot_len = htons(skb->len);
346346
if (ip_dont_fragment(sk, &rt->u.dst) && !ipfragok)
347347
iph->frag_off = htons(IP_DF);

‎net/ipv4/ip_sockglue.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ int ip_recv_error(struct sock *sk, struct msghdr *msg, int len)
355355
sin = (struct sockaddr_in *)msg->msg_name;
356356
if (sin) {
357357
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);
359359
sin->sin_port = serr->port;
360360
memset(&sin->sin_zero, 0, sizeof(sin->sin_zero));
361361
}

‎net/ipv4/raw.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -854,8 +854,8 @@ static void raw_seq_stop(struct seq_file *seq, void *v)
854854
static __inline__ char *get_raw_sock(struct sock *sp, char *tmpbuf, int i)
855855
{
856856
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;
859859
__u16 destp = 0,
860860
srcp = inet->num;
861861

0 commit comments

Comments
 (0)