patch-2.1.89 linux/net/core/dst.c

Next file: linux/net/core/iovec.c
Previous file: linux/net/core/dev.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.1.88/linux/net/core/dst.c linux/net/core/dst.c
@@ -79,6 +79,11 @@
 void * dst_alloc(int size, struct dst_ops * ops)
 {
 	struct dst_entry * dst;
+
+	if (ops->gc && atomic_read(&ops->entries) > ops->gc_thresh) {
+		if (ops->gc())
+			return NULL;
+	}
 	dst = kmalloc(size, GFP_ATOMIC);
 	if (!dst)
 		return NULL;
@@ -89,6 +94,7 @@
 	dst->input = dst_discard;
 	dst->output = dst_blackhole;
 	atomic_inc(&dst_total);
+	atomic_inc(&ops->entries);
 	return dst;
 }
 
@@ -121,6 +127,8 @@
 		dst->neighbour = NULL;
 		neigh_release(neigh);
 	}
+
+	atomic_dec(&dst->ops->entries);
 
 	if (dst->ops->destroy)
 		dst->ops->destroy(dst);

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov