[Linux-decnet-user] Re: Latest DECnet bug fixes
Brought to you by:
chrissie_c,
ph3-der-loewe
|
From: Steve W. <st...@gw...> - 2000-06-19 16:45:27
|
Hi,
a new version of the patch is appended...
>
> From: Steve Whitehouse <st...@gw...>
> Date: Mon, 19 Jun 2000 15:28:25 +0100 (BST)
>
> Dave: Please queue this for inclusion in the next kernel patch
>
> Before I apply this I would like to make a cleanup request.
>
> Why all the nasty (unsigned short) etc. casts all over the place?
> That looks ugly, so why not hide the ugly casts in the byte swapping
> macros, ok?
>
It was a belt and braces approach to make sure that byte sized objects
were always made into unsigned short sized objects before the byteswap.
I added that bit last night after reading one of Patrick's comments about
something that he'd found, but thinking about it now, its probably not
required; putting the casts in the macros is fine and then I'm 100% sure of
whats going on.
> I probably would have normally let something small like this
> go since we're so close to 2.4.x final, but this just stood
> out like a wart and I'm just saving us both time by telling
> you to clean it up now instead of Linus saying to me the
> same and then I relay the message back to you :-)
>
> Later,
> David S. Miller
> da...@re...
>
thats fine, don't worry about it. I'm always happy to accept comment and
criticism :-) If you spot anything else which looks like it needs sorting out
in the DECnet code, just let me know and I'll add it to my TODO list,
Steve.
------------------------------------------------------------------------------
diff -r -u linux-2.4.0test1-ac21/include/net/dn.h linux/include/net/dn.h
--- linux-2.4.0test1-ac21/include/net/dn.h Mon May 1 11:20:00 2000
+++ linux/include/net/dn.h Mon Jun 19 16:56:31 2000
@@ -6,8 +6,8 @@
typedef unsigned short dn_address;
-#define dn_ntohs(x) le16_to_cpu(x)
-#define dn_htons(x) cpu_to_le16(x)
+#define dn_ntohs(x) le16_to_cpu((unsigned short)(x))
+#define dn_htons(x) cpu_to_le16((unsigned short)(x))
struct dn_scp /* Session Control Port */
{
diff -r -u linux-2.4.0test1-ac21/net/decnet/af_decnet.c linux/net/decnet/af_decnet.c
--- linux-2.4.0test1-ac21/net/decnet/af_decnet.c Mon May 1 11:20:06 2000
+++ linux/net/decnet/af_decnet.c Mon Jun 19 16:49:40 2000
@@ -285,7 +285,7 @@
switch(*fmt) {
case 0:
- sdn->sdn_objnum = dn_htons(type);
+ sdn->sdn_objnum = type;
return 2;
case 1:
namel = 16;
@@ -526,10 +526,6 @@
{
struct dn_scp *scp = &sk->protinfo.dn;
- if (sk->dead)
- return;
-
- sk->dead = 1;
scp->nsp_rxtshift = 0; /* reset back off */
if (sk->socket) {
@@ -661,11 +657,12 @@
struct sock *sk = sock->sk;
if (sk) {
+ sock_orphan(sk);
+ sock_hold(sk);
lock_sock(sk);
- sock->sk = NULL;
- sk->socket = NULL;
dn_destroy_sock(sk);
release_sock(sk);
+ sock_put(sk);
}
return 0;
diff -r -u linux-2.4.0test1-ac21/net/decnet/dn_neigh.c linux/net/decnet/dn_neigh.c
--- linux-2.4.0test1-ac21/net/decnet/dn_neigh.c Fri Mar 3 11:02:06 2000
+++ linux/net/decnet/dn_neigh.c Sun Jun 18 19:16:03 2000
@@ -441,7 +441,7 @@
struct dn_dev *dn_db;
dn_address src;
- src = dn_eth2dn(msg->id);
+ src = dn_htons(dn_eth2dn(msg->id));
neigh = __neigh_lookup(&dn_neigh_table, &src, skb->dev, 1);
@@ -498,7 +498,7 @@
struct dn_neigh *dn;
dn_address src;
- src = dn_eth2dn(msg->id);
+ src = dn_htons(dn_eth2dn(msg->id));
neigh = __neigh_lookup(&dn_neigh_table, &src, skb->dev, 1);
diff -r -u linux-2.4.0test1-ac21/net/decnet/dn_route.c linux/net/decnet/dn_route.c
--- linux-2.4.0test1-ac21/net/decnet/dn_route.c Fri May 12 10:07:22 2000
+++ linux/net/decnet/dn_route.c Mon Jun 19 16:54:00 2000
@@ -131,7 +131,7 @@
return dn_rt_hash_mask & (unsigned)tmp;
}
-static void dn_dst_check_expire(unsigned long dummy)
+static void SMP_TIMER_NAME(dn_dst_check_expire)(unsigned long dummy)
{
int i;
struct dn_route *rt, **rtp;
@@ -142,10 +142,12 @@
rtp = &dn_rt_hash_table[i].chain;
write_lock(&dn_rt_hash_table[i].lock);
- for(;(rt=*rtp); rtp = &rt->u.rt_next) {
+ while((rt=*rtp) != NULL) {
if (atomic_read(&rt->u.dst.__refcnt) ||
- (now - rt->u.dst.lastuse) < expire)
+ (now - rt->u.dst.lastuse) < expire) {
+ rtp = &rt->u.rt_next;
continue;
+ }
*rtp = rt->u.rt_next;
rt->u.rt_next = NULL;
dst_free(&rt->u.dst);
@@ -156,10 +158,11 @@
break;
}
- dn_route_timer.expires = now + decnet_dst_gc_interval * HZ;
- add_timer(&dn_route_timer);
+ mod_timer(&dn_route_timer, now + decnet_dst_gc_interval * HZ);
}
+SMP_TIMER_DEFINE(dn_dst_check_expire, dn_dst_task);
+
static int dn_dst_gc(void)
{
struct dn_route *rt, **rtp;
@@ -172,10 +175,12 @@
write_lock_bh(&dn_rt_hash_table[i].lock);
rtp = &dn_rt_hash_table[i].chain;
- for(; (rt=*rtp); rtp = &rt->u.rt_next) {
+ while((rt=*rtp) != NULL) {
if (atomic_read(&rt->u.dst.__refcnt) ||
- (now - rt->u.dst.lastuse) < expire)
+ (now - rt->u.dst.lastuse) < expire) {
+ rtp = &rt->u.rt_next;
continue;
+ }
*rtp = rt->u.rt_next;
rt->u.rt_next = NULL;
dst_free(&rt->u.dst);
@@ -229,7 +234,7 @@
write_unlock_bh(&dn_rt_hash_table[hash].lock);
}
-void dn_run_flush(unsigned long dummy)
+void SMP_TIMER_NAME(dn_run_flush)(unsigned long dummy)
{
int i;
struct dn_route *rt, *next;
@@ -250,6 +255,8 @@
write_unlock_bh(&dn_rt_hash_table[i].lock);
}
}
+
+SMP_TIMER_DEFINE(dn_run_flush, dn_flush_task);
static spinlock_t dn_rt_flush_lock = SPIN_LOCK_UNLOCKED;
|