David,
While debugging possible changes to dev refcounting, discovered
a couple of places in IPV4 that were directly incrementing rather
than using the inline dev_hold. Let's hide the implementation of
net device ref counting so future module ref count fixes will be easier.
diff -urN -X dontdiff linux-2.5/net/ipv4/fib_frontend.c
linux-2.5-dev/net/ipv4/fib_frontend.c
--- linux-2.5/net/ipv4/fib_frontend.c 2003-04-14 13:32:26.000000000 -0700
+++ linux-2.5-dev/net/ipv4/fib_frontend.c 2003-05-06 15:16:03.000000000
-0700
@@ -115,9 +115,9 @@
if (res.type != RTN_LOCAL)
goto out;
dev = FIB_RES_DEV(res);
- if (dev)
- atomic_inc(&dev->refcnt);
+ if (dev)
+ dev_hold(dev);
out:
fib_res_put(&res);
return dev;
diff -urN -X dontdiff linux-2.5/net/ipv4/fib_semantics.c
linux-2.5-dev/net/ipv4/fib_semantics.c
--- linux-2.5/net/ipv4/fib_semantics.c 2003-04-29 09:57:41.000000000 -0700
+++ linux-2.5-dev/net/ipv4/fib_semantics.c 2003-05-06 15:10:40.000000000
-0700
@@ -406,7 +406,7 @@
if (!(dev->flags&IFF_UP))
return -ENETDOWN;
nh->nh_dev = dev;
- atomic_inc(&dev->refcnt);
+ dev_hold(dev);
nh->nh_scope = RT_SCOPE_LINK;
return 0;
}
@@ -429,7 +429,7 @@
nh->nh_oif = FIB_RES_OIF(res);
if ((nh->nh_dev = FIB_RES_DEV(res)) == NULL)
goto out;
- atomic_inc(&nh->nh_dev->refcnt);
+ dev_hold(nh->nh_dev);
err = -ENETDOWN;
if (!(nh->nh_dev->flags & IFF_UP))
goto out;
@@ -451,7 +451,7 @@
return -ENETDOWN;
}
nh->nh_dev = in_dev->dev;
- atomic_inc(&nh->nh_dev->refcnt);
+ dev_hold(nh->nh_dev);
nh->nh_scope = RT_SCOPE_HOST;
in_dev_put(in_dev);
}
|