Skip to contentSkip to conversation

IPv6 SMP fix

PATCH New Andras Kis-Szabo 1 participant 1 message Oct 3, 2002

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

PATCH 1/1 IPv6 SMP fix

Hi,

- fixed TABLE_OFFSET macro
- set the owner of the proc entry

The original problem (bad counter values at Sparc64) remained: this problem exists in IPv4, too!

kisza

Signature · 3 lines
    Andras Kis-Szabo       Security Development, Design and Audit
-------------------------/        Zorp, NetFilter and IPv6
 [email protected] /------------------------------------------->
net/ipv6/netfilter/ip6_tables.c renamed from net/ipv6/netfilter/ip6_tables.c.old +15 -5
@@ -111,7 +111,7 @@
 #define ADD_COUNTER(c,b,p) do { (c).bcnt += (b); (c).pcnt += (p); } while(0)
 
 #ifdef CONFIG_SMP
-#define TABLE_OFFSET(t,p) (SMP_ALIGN((t)->size)*cpu_number_map(p))
+#define TABLE_OFFSET(t,p) (SMP_ALIGN((t)->size)*(p))
 #else
 #define TABLE_OFFSET(t,p) 0
 #endif
@@ -358,7 +358,8 @@
 	read_lock_bh(&table->lock);
 	IP_NF_ASSERT(table->valid_hooks & (1 << hook));
 	table_base = (void *)table->private->entries
-		+ TABLE_OFFSET(table->private, smp_processor_id());
+		+ TABLE_OFFSET(table->private, 
+				cpu_number_map(smp_processor_id()));
 	e = get_entry(table_base, table->private->hook_entry[hook]);
 
 #ifdef CONFIG_NETFILTER_DEBUG
@@ -589,7 +590,7 @@
 				= (void *)ip6t_get_target(e);
 
 			if (e->comefrom & (1 << NF_IP6_NUMHOOKS)) {
-				printk("iptables: loop hook %u pos %u %08X.\n",
+				printk("ip6tables: loop hook %u pos %u %08X.\n",
 				       hook, pos, e->comefrom);
 				return 0;
 			}
@@ -936,7 +937,7 @@
 
 	/* And one copy for every other CPU */
 	for (i = 1; i < smp_num_cpus; i++) {
-		memcpy(newinfo->entries + SMP_ALIGN(newinfo->size*i),
+		memcpy(newinfo->entries + SMP_ALIGN(newinfo->size)*i,
 		       newinfo->entries,
 		       SMP_ALIGN(newinfo->size));
 	}
@@ -1491,6 +1492,9 @@
 	duprintf("table->private->number = %u\n",
 		 table->private->number);
 
+	/* save number of initial entries */
+	table->private->initial_entries = table->private->number;
+
 	table->lock = RW_LOCK_UNLOCKED;
 	list_prepend(&ip6t_tables, table);
 
@@ -1818,9 +1822,15 @@
 	}
 
 #ifdef CONFIG_PROC_FS
-	if (!proc_net_create("ip6_tables_names", 0, ip6t_get_tables)) {
+	{
+	struct proc_dir_entry *proc;
+
+	proc = proc_net_create("ip6_tables_names", 0, ip6t_get_tables);
+	if (!proc) {
 		nf_unregister_sockopt(&ip6t_sockopts);
 		return -ENOMEM;
+	}
+	proc->owner = THIS_MODULE;
 	}
 #endif