Skip to contentSkip to conversation

convert ip6_tunnel to per-cpu data

PATCH In review Christoph Hellwig 3 participants 3 messages Aug 31, 2003

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

PATCH 1/1 convert ip6_tunnel to per-cpu data

Code looks like copy & pasted from icmpv6 :)

net/ipv6/ip6_tunnel.c +8 -8
@@ -64,8 +64,8 @@
 #define IPV6_TCLASS_MASK (IPV6_FLOWINFO_MASK & ~IPV6_FLOWLABEL_MASK)
 
 /* socket(s) used by ip6ip6_tnl_xmit() for resending packets */
-static struct socket *__ip6_socket[NR_CPUS];
-#define ip6_socket __ip6_socket[smp_processor_id()]
+static DEFINE_PER_CPU(struct socket *, __ip6_socket) = NULL;
+#define ip6_socket	__get_cpu_var(__ip6_socket)
 
 static void ip6_xmit_lock(void)
 {
@@ -1168,7 +1168,7 @@
 			continue;
 
 		err = sock_create(PF_INET6, SOCK_RAW, IPPROTO_IPV6, 
-				  &__ip6_socket[i]);
+				  &per_cpu(__ip6_socket, i));
 		if (err < 0) {
 			printk(KERN_ERR 
 			       "Failed to create the IPv6 tunnel socket "
@@ -1176,7 +1176,7 @@
 			       err);
 			goto fail;
 		}
-		sk = __ip6_socket[i]->sk;
+		sk = per_cpu(__ip6_socket, i)->sk;
 		sk->sk_allocation = GFP_ATOMIC;
 
 		np = inet6_sk(sk);
@@ -1211,8 +1211,8 @@
 	for (j = 0; j < i; j++) {
 		if (!cpu_possible(j))
 			continue;
-		sock_release(__ip6_socket[j]);
-		__ip6_socket[j] = NULL;
+		sock_release(per_cpu(__ip6_socket, j));
+		per_cpu(__ip6_socket, j) = NULL;
 	}
 	return err;
 }
@@ -1232,8 +1232,8 @@
 	for (i = 0; i < NR_CPUS; i++) {
 		if (!cpu_possible(i))
 			continue;
-		sock_release(__ip6_socket[i]);
-		__ip6_socket[i] = NULL;
+		sock_release(per_cpu(__ip6_socket, i));
+		per_cpu(__ip6_socket, i) = NULL;
 	}
 }
 
#1 lore raw
Quoted 1 line · On Sun, 31 Aug 2003 12:06:21 +0200 Christoph Hellwig <[email protected]> wrote:

Code looks like copy & pasted from icmpv6 :)

Hold on this one, we're in the process of killing
the sockets from this code.

#2 lore raw
Quoted 7 lines · David S. Miller
Quoted 1 line · On Sun, 31 Aug 2003 12:06:21 +0200 Christoph Hellwig <[email protected]> wrote:

Code looks like copy & pasted from icmpv6 :)

Hold on this one, we're in the process of killing
the sockets from this code.

Yes, I've been running socketless tunnels for a couple of days now and everything seems to work all right. I'll send the patch shortly...

Ville
--
Ville Nuorvala
Research Assistant, Institute of Digital Communications, Helsinki University of Technology
email: [email protected], phone: +358 (0)9 451 5257