aboutsummaryrefslogtreecommitdiffstats
path: root/net/decnet/af_decnet.c
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2006-11-07 18:09:17 -0500
committerDavid S. Miller <davem@sunset.davemloft.net>2006-11-07 18:10:17 -0500
commit375d9d71838970030c8e0bf0ac2abcc1a3487df8 (patch)
tree8c4cb7363852c41ed873fd245d44c155c2b2bed9 /net/decnet/af_decnet.c
parentaf2c6a4aaa2253f1e29df8fb59a3d92174d30a33 (diff)
[DECNET]: Endianess fixes (try #2)
Here are some fixes to endianess problems spotted by Al Viro. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/decnet/af_decnet.c')
-rw-r--r--net/decnet/af_decnet.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/net/decnet/af_decnet.c b/net/decnet/af_decnet.c
index 3456cd331835..21f20f21dd32 100644
--- a/net/decnet/af_decnet.c
+++ b/net/decnet/af_decnet.c
@@ -166,7 +166,7 @@ static struct hlist_head *dn_find_list(struct sock *sk)
166 if (scp->addr.sdn_flags & SDF_WILD) 166 if (scp->addr.sdn_flags & SDF_WILD)
167 return hlist_empty(&dn_wild_sk) ? &dn_wild_sk : NULL; 167 return hlist_empty(&dn_wild_sk) ? &dn_wild_sk : NULL;
168 168
169 return &dn_sk_hash[scp->addrloc & DN_SK_HASH_MASK]; 169 return &dn_sk_hash[dn_ntohs(scp->addrloc) & DN_SK_HASH_MASK];
170} 170}
171 171
172/* 172/*
@@ -180,7 +180,7 @@ static int check_port(__le16 port)
180 if (port == 0) 180 if (port == 0)
181 return -1; 181 return -1;
182 182
183 sk_for_each(sk, node, &dn_sk_hash[port & DN_SK_HASH_MASK]) { 183 sk_for_each(sk, node, &dn_sk_hash[dn_ntohs(port) & DN_SK_HASH_MASK]) {
184 struct dn_scp *scp = DN_SK(sk); 184 struct dn_scp *scp = DN_SK(sk);
185 if (scp->addrloc == port) 185 if (scp->addrloc == port)
186 return -1; 186 return -1;
@@ -194,12 +194,12 @@ static unsigned short port_alloc(struct sock *sk)
194static unsigned short port = 0x2000; 194static unsigned short port = 0x2000;
195 unsigned short i_port = port; 195 unsigned short i_port = port;
196 196
197 while(check_port(++port) != 0) { 197 while(check_port(dn_htons(++port)) != 0) {
198 if (port == i_port) 198 if (port == i_port)
199 return 0; 199 return 0;
200 } 200 }
201 201
202 scp->addrloc = port; 202 scp->addrloc = dn_htons(port);
203 203
204 return 1; 204 return 1;
205} 205}
@@ -418,7 +418,7 @@ struct sock *dn_find_by_skb(struct sk_buff *skb)
418 struct dn_scp *scp; 418 struct dn_scp *scp;
419 419
420 read_lock(&dn_hash_lock); 420 read_lock(&dn_hash_lock);
421 sk_for_each(sk, node, &dn_sk_hash[cb->dst_port & DN_SK_HASH_MASK]) { 421 sk_for_each(sk, node, &dn_sk_hash[dn_ntohs(cb->dst_port) & DN_SK_HASH_MASK]) {
422 scp = DN_SK(sk); 422 scp = DN_SK(sk);
423 if (cb->src != dn_saddr2dn(&scp->peer)) 423 if (cb->src != dn_saddr2dn(&scp->peer))
424 continue; 424 continue;
@@ -1016,13 +1016,14 @@ static void dn_access_copy(struct sk_buff *skb, struct accessdata_dn *acc)
1016 1016
1017static void dn_user_copy(struct sk_buff *skb, struct optdata_dn *opt) 1017static void dn_user_copy(struct sk_buff *skb, struct optdata_dn *opt)
1018{ 1018{
1019 unsigned char *ptr = skb->data; 1019 unsigned char *ptr = skb->data;
1020 1020 u16 len = *ptr++; /* yes, it's 8bit on the wire */
1021 opt->opt_optl = *ptr++; 1021
1022 opt->opt_status = 0; 1022 BUG_ON(len > 16); /* we've checked the contents earlier */
1023 memcpy(opt->opt_data, ptr, opt->opt_optl); 1023 opt->opt_optl = dn_htons(len);
1024 skb_pull(skb, dn_ntohs(opt->opt_optl) + 1); 1024 opt->opt_status = 0;
1025 1025 memcpy(opt->opt_data, ptr, len);
1026 skb_pull(skb, len + 1);
1026} 1027}
1027 1028
1028static struct sk_buff *dn_wait_for_connect(struct sock *sk, long *timeo) 1029static struct sk_buff *dn_wait_for_connect(struct sock *sk, long *timeo)