Skip to contentSkip to conversation

backport neighbour cache redesign

PATCH In review Harald Welte 2 participants 6 messages Sep 30, 2004 – Oct 4, 2004

Subsystems (6)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 backport neighbour cache redesign

Hi Dave!

I've now finished the 2.4.x backport of the neighbour cache redesign. The patch applies to 2.4.28-pre3-bk5.

It compiles cleanly, and ipv4/ipv6 are working as expected. I don't have a decnet or atm test setup, so I leave testing to somebody else ;)

Let's hope I didn't introduce new bugs, the merging got a bit ugly since percpu is missing and (more important) 2.4.x networking didn't yet use seq_file. So in some cases like ATM, clip is now using seq_file, while everything else uses the old get_info() proc methods.

Cheers,
Harald

Signature · 3 lines
- Harald Welte <[email protected]>               http://www.gnumonks.org/
============================================================================
Programming is like sex: One mistake and you have to support it your lifetime
drivers/net/bonding/bond_main.c +0 -2
diff -Nru --exclude-from=/sunbeam/home/laforge/scripts/dontdiff linux-2.4.28-pre3-bk5-plain/drivers/net/bonding/bond_main.c linux-2.4.28-pre3-bk5-neigh/drivers/net/bonding/bond_main.c
@@ -3086,8 +3086,6 @@
 
 #ifdef CONFIG_PROC_FS
 
-#define SEQ_START_TOKEN ((void *)1)
-
 static void *bond_info_seq_start(struct seq_file *seq, loff_t *pos)
 {
 	struct bonding *bond = seq->private;
fs/proc/root.c +4 -1
diff -Nru --exclude-from=/sunbeam/home/laforge/scripts/dontdiff linux-2.4.28-pre3-bk5-plain/fs/proc/root.c linux-2.4.28-pre3-bk5-neigh/fs/proc/root.c
@@ -17,7 +17,7 @@
 #include <linux/module.h>
 #include <asm/bitops.h>
 
-struct proc_dir_entry *proc_net, *proc_bus, *proc_root_fs, *proc_root_driver;
+struct proc_dir_entry *proc_net, *proc_net_stat, *proc_bus, *proc_root_fs, *proc_root_driver;
 
 #ifdef CONFIG_SYSCTL
 struct proc_dir_entry *proc_sys_root;
@@ -38,6 +38,8 @@
 	}
 	proc_misc_init();
 	proc_net = proc_mkdir("net", 0);
+	proc_net_stat = proc_mkdir("net/stat", NULL);
+
 #ifdef CONFIG_SYSVIPC
 	proc_mkdir("sysvipc", 0);
 #endif
@@ -143,5 +145,6 @@
 EXPORT_SYMBOL(proc_root);
 EXPORT_SYMBOL(proc_root_fs);
 EXPORT_SYMBOL(proc_net);
+EXPORT_SYMBOL(proc_net_stat);
 EXPORT_SYMBOL(proc_bus);
 EXPORT_SYMBOL(proc_root_driver);
include/linux/proc_fs.h +11 -0
diff -Nru --exclude-from=/sunbeam/home/laforge/scripts/dontdiff linux-2.4.28-pre3-bk5-plain/include/linux/proc_fs.h linux-2.4.28-pre3-bk5-neigh/include/linux/proc_fs.h
@@ -79,6 +79,7 @@
 extern struct proc_dir_entry proc_root;
 extern struct proc_dir_entry *proc_root_fs;
 extern struct proc_dir_entry *proc_net;
+extern struct proc_dir_entry *proc_net_stat;
 extern struct proc_dir_entry *proc_bus;
 extern struct proc_dir_entry *proc_root_driver;
 extern struct proc_dir_entry *proc_root_kcore;
@@ -170,6 +171,16 @@
 	return create_proc_info_entry(name,mode,proc_net,get_info);
 }
 
+static inline struct proc_dir_entry *proc_net_fops_create(const char *name,
+	mode_t mode, struct file_operations *fops)
+{
+	struct proc_dir_entry *res = create_proc_entry(name, mode, proc_net);
+
+	if (res)
+		res->proc_fops = fops;
+	return res;
+}
+
 static inline void proc_net_remove(const char *name)
 {
 	remove_proc_entry(name,proc_net);
include/linux/seq_file.h +3 -0
diff -Nru --exclude-from=/sunbeam/home/laforge/scripts/dontdiff linux-2.4.28-pre3-bk5-plain/include/linux/seq_file.h linux-2.4.28-pre3-bk5-neigh/include/linux/seq_file.h
@@ -65,5 +65,8 @@
 int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
 int single_release(struct inode *, struct file *);
 int seq_release_private(struct inode *, struct file *);
+
+#define SEQ_START_TOKEN ((void *)1)
+
 #endif
 #endif
include/net/dn_neigh.h +0 -1
diff -Nru --exclude-from=/sunbeam/home/laforge/scripts/dontdiff linux-2.4.28-pre3-bk5-plain/include/net/dn_neigh.h linux-2.4.28-pre3-bk5-neigh/include/net/dn_neigh.h
@@ -18,7 +18,6 @@
 
 extern void dn_neigh_init(void);
 extern void dn_neigh_cleanup(void);
-extern struct neighbour *dn_neigh_lookup(struct neigh_table *tbl, void *ptr);
 extern int dn_neigh_router_hello(struct sk_buff *skb);
 extern int dn_neigh_endnode_hello(struct sk_buff *skb);
 extern void dn_neigh_pointopoint_hello(struct sk_buff *skb);
include/net/neighbour.h +52 -10

106 lines not on this page · raw message

net/atm/clip.c +41 -59

132 lines not on this page · raw message

net/atm/proc.c +182 -49

275 lines not on this page · raw message

net/core/neighbour.c +541 -57

783 lines not on this page · raw message

net/decnet/dn_neigh.c +118 -115

289 lines not on this page · raw message

net/decnet/dn_route.c +1 -1
diff -Nru --exclude-from=/sunbeam/home/laforge/scripts/dontdiff linux-2.4.28-pre3-bk5-plain/net/decnet/dn_route.c linux-2.4.28-pre3-bk5-neigh/net/decnet/dn_route.c
@@ -761,7 +761,7 @@
 
 	/* Look in On-Ethernet cache first */
 	if (!(flags & MSG_TRYHARD)) {
-		if ((neigh = dn_neigh_lookup(&dn_neigh_table, &dst)) != NULL)
+		if ((neigh = neigh_lookup_nodev(&dn_neigh_table, &dst)) != NULL)
 			goto got_route;
 	}
 
net/ipv4/arp.c +136 -150

339 lines not on this page · raw message

net/ipv4/route.c +3 -1
diff -Nru --exclude-from=/sunbeam/home/laforge/scripts/dontdiff linux-2.4.28-pre3-bk5-plain/net/ipv4/route.c linux-2.4.28-pre3-bk5-neigh/net/ipv4/route.c
@@ -284,6 +284,7 @@
 	int i, lcpu;
 	int len = 0;
 
+ 	len += sprintf(buffer+len, "entries  in_hit in_slow_tot in_slow_mc in_no_route in_brd in_martian_dst in_martian_src  out_hit out_slow_tot out_slow_mc  gc_total gc_ignored gc_goal_miss gc_dst_overflow in_hlist_search out_hlist_search\n");
         for (lcpu = 0; lcpu < smp_num_cpus; lcpu++) {
                 i = cpu_logical_map(lcpu);
 
@@ -2625,7 +2626,8 @@
 	add_timer(&rt_secret_timer);
 
 	proc_net_create ("rt_cache", 0, rt_cache_get_info);
-	proc_net_create ("rt_cache_stat", 0, rt_cache_stat_get_info);
+	create_proc_info_entry ("rt_cache", 0, proc_net_stat, 
+				rt_cache_stat_get_info);
 #ifdef CONFIG_NET_CLS_ROUTE
 	create_proc_read_entry("net/rt_acct", 0, 0, ip_rt_acct_read, NULL);
 #endif
net/ipv6/ndisc.c +15 -13
diff -Nru --exclude-from=/sunbeam/home/laforge/scripts/dontdiff linux-2.4.28-pre3-bk5-plain/net/ipv6/ndisc.c linux-2.4.28-pre3-bk5-neigh/net/ipv6/ndisc.c
@@ -60,6 +60,7 @@
 #include <linux/if_arp.h>
 #include <linux/ipv6.h>
 #include <linux/icmpv6.h>
+#include <linux/jhash.h>
 
 #include <net/sock.h>
 #include <net/snmp.h>
@@ -240,15 +241,14 @@
 
 static u32 ndisc_hash(const void *pkey, const struct net_device *dev)
 {
-	u32 hash_val;
+	const u32 *p32 = pkey;
+	u32 addr_hash, i;
 
-	hash_val = *(u32*)(pkey + sizeof(struct in6_addr) - 4);
-	hash_val ^= (hash_val>>16);
-	hash_val ^= hash_val>>8;
-	hash_val ^= hash_val>>3;
-	hash_val = (hash_val^dev->ifindex)&NEIGH_HASHMASK;
+	addr_hash = 0;
+	for (i = 0; i < (sizeof(struct in6_addr) / sizeof(u32)); i++)
+		addr_hash ^= *p32++;
 
-	return hash_val;
+	return jhash_2words(addr_hash, dev->ifindex, nd_tbl.hash_rnd);
 }
 
 static int ndisc_constructor(struct neighbour *neigh)
@@ -696,9 +696,9 @@
 			int inc = ipv6_addr_type(daddr)&IPV6_ADDR_MULTICAST;
 
 			if (inc)
-				nd_tbl.stats.rcv_probes_mcast++;
+				NEIGH_CACHE_STAT_INC(&nd_tbl, rcv_probes_mcast);
 			else
-				nd_tbl.stats.rcv_probes_ucast++;
+				NEIGH_CACHE_STAT_INC(&nd_tbl, rcv_probes_ucast);
 
 			/* 
 			 *	update / create cache entry
@@ -741,9 +741,9 @@
 		if (addr_type & IPV6_ADDR_UNICAST) {
 			int inc = ipv6_addr_type(daddr)&IPV6_ADDR_MULTICAST;
 			if (inc)  
-				nd_tbl.stats.rcv_probes_mcast++;
+				NEIGH_CACHE_STAT_INC(&nd_tbl, rcv_probes_mcast);
  			else
-				nd_tbl.stats.rcv_probes_ucast++;
+				NEIGH_CACHE_STAT_INC(&nd_tbl, rcv_probes_ucast);
 
 			/*
 			 *   update / create cache entry
@@ -775,9 +775,11 @@
 			    inc == 0 ||
 			    in6_dev->nd_parms->proxy_delay == 0) {
 				if (inc)
-					nd_tbl.stats.rcv_probes_mcast++;
+					NEIGH_CACHE_STAT_INC(&nd_tbl, 
+							rcv_probes_mcast);
 				else
-					nd_tbl.stats.rcv_probes_ucast++;
+					NEIGH_CACHE_STAT_INC(&nd_tbl, 
+							rcv_probes_ucast);
 					
 				neigh = neigh_event_ns(&nd_tbl, lladdr, saddr, dev);
 
maintainer
#1 lore raw

Ok I started playing with this, here is what I have currently. Changes:

1) Merge in missing fixes from 2.6.x port. In particular:
- missing "recalculate hash rand on hash grow"
- missing ARP clip fixes (was initializing neigh table by hand, needed to use net/core/neighbour.c interfaces for that). This one wasn't Harald's fault as this fix was made after he created this 2.4.x backport
2) Missing symbol exports for the new interfaces modules can use, namely:
neigh_lookup_nodev
neigh_seq_start
neigh_seq_next
neigh_seq_stop
3) Delete instead of "#if 0" out the now totally unused code inside of net/atm/clip.c

We need to test and verify this patch a lot before I can toss such a big thing over to Marcelo, but I definitely intend to send this to him.

===== drivers/net/bonding/bond_main.c 1.86 vs edited =====

drivers/net/bonding/bond_main.c +0 -2
@@ -3086,8 +3086,6 @@ out:
 
 #ifdef CONFIG_PROC_FS
 
-#define SEQ_START_TOKEN ((void *)1)
-
 static void *bond_info_seq_start(struct seq_file *seq, loff_t *pos)
 {
 	struct bonding *bond = seq->private;

===== fs/proc/root.c 1.8 vs edited =====

fs/proc/root.c +4 -1
@@ -17,7 +17,7 @@
 #include <linux/module.h>
 #include <asm/bitops.h>
 
-struct proc_dir_entry *proc_net, *proc_bus, *proc_root_fs, *proc_root_driver;
+struct proc_dir_entry *proc_net, *proc_net_stat, *proc_bus, *proc_root_fs, *proc_root_driver;
 
 #ifdef CONFIG_SYSCTL
 struct proc_dir_entry *proc_sys_root;
@@ -38,6 +38,8 @@ void __init proc_root_init(void)
 	}
 	proc_misc_init();
 	proc_net = proc_mkdir("net", 0);
+	proc_net_stat = proc_mkdir("net/stat", NULL);
+
 #ifdef CONFIG_SYSVIPC
 	proc_mkdir("sysvipc", 0);
 #endif
@@ -143,5 +145,6 @@ EXPORT_SYMBOL(remove_proc_entry);
 EXPORT_SYMBOL(proc_root);
 EXPORT_SYMBOL(proc_root_fs);
 EXPORT_SYMBOL(proc_net);
+EXPORT_SYMBOL(proc_net_stat);
 EXPORT_SYMBOL(proc_bus);
 EXPORT_SYMBOL(proc_root_driver);

===== include/linux/proc_fs.h 1.9 vs edited =====

include/linux/proc_fs.h +11 -0
@@ -79,6 +79,7 @@ struct proc_dir_entry {
 extern struct proc_dir_entry proc_root;
 extern struct proc_dir_entry *proc_root_fs;
 extern struct proc_dir_entry *proc_net;
+extern struct proc_dir_entry *proc_net_stat;
 extern struct proc_dir_entry *proc_bus;
 extern struct proc_dir_entry *proc_root_driver;
 extern struct proc_dir_entry *proc_root_kcore;
@@ -168,6 +169,16 @@ static inline struct proc_dir_entry *pro
 	mode_t mode, get_info_t *get_info)
 {
 	return create_proc_info_entry(name,mode,proc_net,get_info);
+}
+
+static inline struct proc_dir_entry *proc_net_fops_create(const char *name,
+	mode_t mode, struct file_operations *fops)
+{
+	struct proc_dir_entry *res = create_proc_entry(name, mode, proc_net);
+
+	if (res)
+		res->proc_fops = fops;
+	return res;
 }
 
 static inline void proc_net_remove(const char *name)

===== include/linux/seq_file.h 1.3 vs edited =====

include/linux/seq_file.h +3 -0
@@ -65,5 +65,8 @@ int seq_path(struct seq_file *, struct v
 int single_open(struct file *, int (*)(struct seq_file *, void *), void *);
 int single_release(struct inode *, struct file *);
 int seq_release_private(struct inode *, struct file *);
+
+#define SEQ_START_TOKEN ((void *)1)
+
 #endif
 #endif

===== include/net/dn_neigh.h 1.1 vs edited =====

include/net/dn_neigh.h +0 -1
@@ -18,7 +18,6 @@ struct dn_neigh {
 
 extern void dn_neigh_init(void);
 extern void dn_neigh_cleanup(void);
-extern struct neighbour *dn_neigh_lookup(struct neigh_table *tbl, void *ptr);
 extern int dn_neigh_router_hello(struct sk_buff *skb);
 extern int dn_neigh_endnode_hello(struct sk_buff *skb);
 extern void dn_neigh_pointopoint_hello(struct sk_buff *skb);

===== include/net/neighbour.h 1.3 vs edited =====

include/net/neighbour.h +52 -10

106 lines not on this page · raw message

===== net/netsyms.c 1.49 vs edited =====

net/netsyms.c +4 -0
@@ -179,9 +179,13 @@ EXPORT_SYMBOL(neigh_connected_output);
 EXPORT_SYMBOL(neigh_update);
 EXPORT_SYMBOL(neigh_create);
 EXPORT_SYMBOL(neigh_lookup);
+EXPORT_SYMBOL(neigh_lookup_nodev);
 EXPORT_SYMBOL(__neigh_event_send);
 EXPORT_SYMBOL(neigh_event_ns);
 EXPORT_SYMBOL(neigh_ifdown);
+EXPORT_SYMBOL(neigh_seq_start);
+EXPORT_SYMBOL(neigh_seq_next);
+EXPORT_SYMBOL(neigh_seq_stop);
 #ifdef CONFIG_ARPD
 EXPORT_SYMBOL(neigh_app_ns);
 #endif

===== net/atm/clip.c 1.13 vs edited =====

net/atm/clip.c +55 -74

181 lines not on this page · raw message

===== net/atm/proc.c 1.11 vs edited =====

net/atm/proc.c +181 -229

459 lines not on this page · raw message

===== net/core/neighbour.c 1.12 vs edited =====

net/core/neighbour.c +538 -57

776 lines not on this page · raw message

===== net/decnet/dn_neigh.c 1.3 vs edited =====

net/decnet/dn_neigh.c +118 -115

289 lines not on this page · raw message

===== net/decnet/dn_route.c 1.6 vs edited =====

net/decnet/dn_route.c +1 -1
@@ -761,7 +761,7 @@ static int dn_route_output_slow(struct d
 
 	/* Look in On-Ethernet cache first */
 	if (!(flags & MSG_TRYHARD)) {
-		if ((neigh = dn_neigh_lookup(&dn_neigh_table, &dst)) != NULL)
+		if ((neigh = neigh_lookup_nodev(&dn_neigh_table, &dst)) != NULL)
 			goto got_route;
 	}
 

===== net/ipv4/arp.c 1.16 vs edited =====

net/ipv4/arp.c +136 -150

339 lines not on this page · raw message

===== net/ipv4/route.c 1.24 vs edited =====

net/ipv4/route.c +3 -1
@@ -284,6 +284,7 @@ static int rt_cache_stat_get_info(char *
 	int i, lcpu;
 	int len = 0;
 
+ 	len += sprintf(buffer+len, "entries  in_hit in_slow_tot in_slow_mc in_no_route in_brd in_martian_dst in_martian_src  out_hit out_slow_tot out_slow_mc  gc_total gc_ignored gc_goal_miss gc_dst_overflow in_hlist_search out_hlist_search\n");
         for (lcpu = 0; lcpu < smp_num_cpus; lcpu++) {
                 i = cpu_logical_map(lcpu);
 
@@ -2625,7 +2626,8 @@ void __init ip_rt_init(void)
 	add_timer(&rt_secret_timer);
 
 	proc_net_create ("rt_cache", 0, rt_cache_get_info);
-	proc_net_create ("rt_cache_stat", 0, rt_cache_stat_get_info);
+	create_proc_info_entry ("rt_cache", 0, proc_net_stat, 
+				rt_cache_stat_get_info);
 #ifdef CONFIG_NET_CLS_ROUTE
 	create_proc_read_entry("net/rt_acct", 0, 0, ip_rt_acct_read, NULL);
 #endif

===== net/ipv6/ndisc.c 1.26 vs edited =====

net/ipv6/ndisc.c +15 -13
@@ -60,6 +60,7 @@
 #include <linux/if_arp.h>
 #include <linux/ipv6.h>
 #include <linux/icmpv6.h>
+#include <linux/jhash.h>
 
 #include <net/sock.h>
 #include <net/snmp.h>
@@ -240,15 +241,14 @@ int ndisc_mc_map(struct in6_addr *addr, 
 
 static u32 ndisc_hash(const void *pkey, const struct net_device *dev)
 {
-	u32 hash_val;
+	const u32 *p32 = pkey;
+	u32 addr_hash, i;
 
-	hash_val = *(u32*)(pkey + sizeof(struct in6_addr) - 4);
-	hash_val ^= (hash_val>>16);
-	hash_val ^= hash_val>>8;
-	hash_val ^= hash_val>>3;
-	hash_val = (hash_val^dev->ifindex)&NEIGH_HASHMASK;
+	addr_hash = 0;
+	for (i = 0; i < (sizeof(struct in6_addr) / sizeof(u32)); i++)
+		addr_hash ^= *p32++;
 
-	return hash_val;
+	return jhash_2words(addr_hash, dev->ifindex, nd_tbl.hash_rnd);
 }
 
 static int ndisc_constructor(struct neighbour *neigh)
@@ -696,9 +696,9 @@ void ndisc_recv_ns(struct sk_buff *skb)
 			int inc = ipv6_addr_type(daddr)&IPV6_ADDR_MULTICAST;
 
 			if (inc)
-				nd_tbl.stats.rcv_probes_mcast++;
+				NEIGH_CACHE_STAT_INC(&nd_tbl, rcv_probes_mcast);
 			else
-				nd_tbl.stats.rcv_probes_ucast++;
+				NEIGH_CACHE_STAT_INC(&nd_tbl, rcv_probes_ucast);
 
 			/* 
 			 *	update / create cache entry
@@ -741,9 +741,9 @@ void ndisc_recv_ns(struct sk_buff *skb)
 		if (addr_type & IPV6_ADDR_UNICAST) {
 			int inc = ipv6_addr_type(daddr)&IPV6_ADDR_MULTICAST;
 			if (inc)  
-				nd_tbl.stats.rcv_probes_mcast++;
+				NEIGH_CACHE_STAT_INC(&nd_tbl, rcv_probes_mcast);
  			else
-				nd_tbl.stats.rcv_probes_ucast++;
+				NEIGH_CACHE_STAT_INC(&nd_tbl, rcv_probes_ucast);
 
 			/*
 			 *   update / create cache entry
@@ -775,9 +775,11 @@ void ndisc_recv_ns(struct sk_buff *skb)
 			    inc == 0 ||
 			    in6_dev->nd_parms->proxy_delay == 0) {
 				if (inc)
-					nd_tbl.stats.rcv_probes_mcast++;
+					NEIGH_CACHE_STAT_INC(&nd_tbl, 
+							rcv_probes_mcast);
 				else
-					nd_tbl.stats.rcv_probes_ucast++;
+					NEIGH_CACHE_STAT_INC(&nd_tbl, 
+							rcv_probes_ucast);
 					
 				neigh = neigh_event_ns(&nd_tbl, lladdr, saddr, dev);
 
#2 lore raw
Quoted 10 lines · David S. Miller

Ok I started playing with this, here is what I have currently. Changes:

2) Missing symbol exports for the new interfaces modules can use, namely:
neigh_lookup_nodev
neigh_seq_start
neigh_seq_next
neigh_seq_stop

oh, sorry. I just linked atm,decnet and ipv6 static so far :(

Quoted 2 lines

3) Delete instead of "#if 0" out the now totally unused code inside of net/atm/clip.c

oops, that slipped through. embarrassing.

Quoted 3 lines

We need to test and verify this patch a lot before I can toss such a big thing over to Marcelo, but I definitely intend to send this to him.

sure, I am well aware of that. If it helps, at least the IPv4 part will see some serious deployment after it has passed the Astaro QA :)

I'll keep you posted about that.

One additional note:

If we go back to the initial reason for all those modifications, it was deployment in large networks. The gc_thresh3 default of 1k is very small, even if you have only 4 interfaces with /24, you will already max out this default.

Now that the hash distribution is better, and the table resized dynamically, we scale better with large neighbour caches.

I was thinking of registering with some notifiers and tuning gc_thresh3 automatically to be at least as large as the theoretical number of immediate neigbhours. At least for multiple /24 and /16 I think this is still reasonable.

As soon as we go further up (/8 or ipv6) the limit basically becomes 'unlimited', since we won't be able to receive 2^24 arp-causing packets per second anyway.

Or be even less conservative and say: there is no limit for neighbour cache entries? You mentioned that *BSD didn't have a limit, IIRC.

Signature · 3 lines
- Harald Welte <[email protected]>               http://www.gnumonks.org/
============================================================================
Programming is like sex: One mistake and you have to support it your lifetime
maintainer
#3 lore raw
Quoted 13 lines · On Mon, 4 Oct 2004 22:15:25 +0200 Harald Welte <[email protected]> wrote:

If we go back to the initial reason for all those modifications, it was deployment in large networks. The gc_thresh3 default of 1k is very small, even if you have only 4 interfaces with /24, you will already max out this default.

Now that the hash distribution is better, and the table resized dynamically, we scale better with large neighbour caches.

I was thinking of registering with some notifiers and tuning gc_thresh3 automatically to be at least as large as the theoretical number of immediate neigbhours. At least for multiple /24 and /16 I think this is still reasonable.

Quoted 6 lines

As soon as we go further up (/8 or ipv6) the limit basically becomes 'unlimited', since we won't be able to receive 2^24 arp-causing packets per second anyway.

Or be even less conservative and say: there is no limit for neighbour cache entries? You mentioned that *BSD didn't have a limit, IIRC.

I think tieing it to the subnet size is wrong, because the real cap is the routing cache size. Remember the email where I was talking about that?

I'm nearly ambivalent about a bound-less neighbour cache. I hate to think about having tons of crap sitting in the neighbour cache unused and sucking up memory. BSD's scheme works because when routing entries die so do the neighbour entries they point to, so they have no need for garbage collection like we do.

So right now I think a better idea is to have the routing cache tell the neigh table how big it could get, or something like that. It is a thorny issue, since usually routing cache --> neighbour cache assosciations are VERY many to one except in these weird odd cases.

#4 lore raw
Quoted 3 lines · David S. Miller

I think tieing it to the subnet size is wrong, because the real cap is the routing cache size. Remember the email where I was talking about that?

yes, I remember that email. I didn't think further about it, since I got the feeling that there is significant movement to get rid of the neighbour cache at some point (if/when there is some fast lookup algorithm implemented) - and if we look at ipv6, there is no routing cache.

Quoted 5 lines

I'm nearly ambivalent about a bound-less neighbour cache. I hate to think about having tons of crap sitting in the neighbour cache unused and sucking up memory. BSD's scheme works because when routing entries die so do the neighbour entries they point to, so they have no need for garbage collection like we do.

mh, I see. I understood your email related to that subject that you actually think this is not that stupid a thing to do...

anyway, I'll drop my prefix-based sizing idea. And I have to admit that I also dislike the 'routing cache tell neighbour cache' approach (since it's only applicable to ipv4)... so as for me, we'll just stick with that hard limit. No more fiddling with that code, I'll get back to flow accounting and pkttables for some time ;)

Signature · 3 lines
- Harald Welte <[email protected]>               http://www.gnumonks.org/
============================================================================
Programming is like sex: One mistake and you have to support it your lifetime
maintainer
#5 lore raw
Quoted 5 lines · On Mon, 4 Oct 2004 23:11:58 +0200 Harald Welte <[email protected]> wrote:

yes, I remember that email. I didn't think further about it, since I got the feeling that there is significant movement to get rid of the neighbour cache at some point (if/when there is some fast lookup algorithm implemented) - and if we look at ipv6, there is no routing cache.

Another idea is to dynamically grow the thresholds based upon usage just as we do for the hash tables. For example, if we find say %90 of neighbour entries in-use at forced GC time, we increment the thresholds by some factor.

Note that the "in-use" part is very important, it prevents a DoS spam from growing the neighbour cache since such traffic causes neighbour entries to quickly become unused.