[openib-general] [PATCHv3][SDP] Allow SDP to compile on 2.6.12-rc3

Tom Duffy tduffy at sun.com
Thu Apr 21 16:33:14 PDT 2005


On Thu, 2005-04-21 at 16:17 -0700, Libor Michalek wrote:
>   Is this a trick question? :) Because it's not a bool but an integer,
> which use to be a bool in the 2.4 kernel days. Here's the relevant
> code snip from net/core/sock.c:
> 
> 		if (zero_it) {
> 			memset(sk, 0,
> 			       zero_it == 1 ? sizeof(struct sock) : zero_it);
> 			sk->sk_family = family;
> 			sock_lock_init(sk);
> 		}

Sorry, I was looking at the new code where it is (used as) a bool again.
In fact, I fucked up and on my v2 patch, the *new* call to sk_alloc
should just be 1.  Here is v3.

Index: linux-2.6.12-rc3-openib/drivers/infiniband/ulp/sdp/sdp_conn.c
===================================================================
--- linux-2.6.12-rc3-openib/drivers/infiniband/ulp/sdp/sdp_conn.c	(revision 2207)
+++ linux-2.6.12-rc3-openib/drivers/infiniband/ulp/sdp/sdp_conn.c	(working copy)
@@ -1112,6 +1112,15 @@ error_attr:
 	return result;
 }
 
+/* XXX remove if/else (leave struct) once 2.6.12 is out */
+#if ( LINUX_VERSION_CODE > KERNEL_VERSION(2,6,11) )
+static struct proto sdp_proto = {
+	.name		= "sdp_sock",
+	.owner		= THIS_MODULE,
+	.obj_size	= sizeof(struct inet_sock),
+};
+#endif
+
 /*
  * sdp_conn_alloc - allocate a new socket, and init.
  */
@@ -1122,7 +1131,12 @@ struct sdp_opt *sdp_conn_alloc(int prior
 	int result;
 
 	sk = sk_alloc(dev_root_s.proto, priority, 
+/* XXX Remove once 2.6.12 is out */
+#if ( LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11) )
 		      sizeof(struct inet_sock), dev_root_s.sock_cache);
+#else
+		      &sdp_proto, 1);
+#endif
 	if (!sk) {
 		sdp_dbg_warn(NULL, "socket alloc error for protocol. <%d:%d>",
 			     dev_root_s.proto, priority);
@@ -1966,6 +1980,8 @@ int sdp_conn_table_init(int proto_family
 		goto error_conn;
 	}
 
+/* XXX Remove once 2.6.12 is out */
+#if ( LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11) )
         dev_root_s.sock_cache = kmem_cache_create("sdp_sock",
 						  sizeof(struct inet_sock), 
 						  0, SLAB_HWCACHE_ALIGN,
@@ -1975,6 +1991,13 @@ int sdp_conn_table_init(int proto_family
 		result = -ENOMEM;
 		goto error_sock;
         }
+#else
+	if (proto_register(&sdp_proto, 1) != 0) {
+		sdp_warn("Failed to register sdp proto.");
+		result = -ENOMEM;
+		goto error_sock;
+	}
+#endif
 
 	/*
 	 * start listening
@@ -2002,7 +2025,12 @@ int sdp_conn_table_init(int proto_family
 error_listen:
 	(void)ib_destroy_cm_id(dev_root_s.listen_id);
 error_cm_id:
+/* XXX Remove once 2.6.12 is out */
+#if ( LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11) )
 	kmem_cache_destroy(dev_root_s.sock_cache);
+#else
+	proto_unregister(&sdp_proto);
+#endif
 error_sock:
 	kmem_cache_destroy(dev_root_s.conn_cache);
 error_conn:
@@ -2049,10 +2077,15 @@ int sdp_conn_table_clear(void)
 	 * delete conn cache
 	 */
 	kmem_cache_destroy(dev_root_s.conn_cache);
+/* Remove once 2.6.12 is out */
+#if ( LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11) )
 	/*
 	 * delete sock cache
 	 */
 	kmem_cache_destroy(dev_root_s.sock_cache);
+#else
+	proto_unregister(&sdp_proto);
+#endif
 	/*
 	 * stop listening
 	 */
Index: linux-2.6.12-rc3-openib/drivers/infiniband/ulp/sdp/sdp_pass.c
===================================================================
--- linux-2.6.12-rc3-openib/drivers/infiniband/ulp/sdp/sdp_pass.c	(revision 2207)
+++ linux-2.6.12-rc3-openib/drivers/infiniband/ulp/sdp/sdp_pass.c	(working copy)
@@ -356,13 +356,23 @@ static int sdp_cm_listen_lookup(struct s
 	 */
 	sk->sk_lingertime   = listen_sk->sk_lingertime;
 	sk->sk_rcvlowat     = listen_sk->sk_rcvlowat;
+/* XXX Remove once 2.6.12 is released */
+#if ( LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11) )
 	sk->sk_debug        = listen_sk->sk_debug;
 	sk->sk_localroute   = listen_sk->sk_localroute;
+	sk->sk_rcvtstamp    = listen_sk->sk_rcvtstamp;
+#else
+	if (sock_flag(sk, SOCK_DBG))
+		sock_set_flag(listen_sk, SOCK_DBG);
+	if (sock_flag(sk, SOCK_LOCALROUTE))
+		sock_set_flag(listen_sk, SOCK_LOCALROUTE);
+	if (sock_flag(sk, SOCK_RCVTSTAMP))
+		sock_set_flag(listen_sk, SOCK_RCVTSTAMP);
+#endif
 	sk->sk_sndbuf       = listen_sk->sk_sndbuf;
 	sk->sk_rcvbuf       = listen_sk->sk_rcvbuf;
 	sk->sk_no_check     = listen_sk->sk_no_check;
 	sk->sk_priority     = listen_sk->sk_priority;
-	sk->sk_rcvtstamp    = listen_sk->sk_rcvtstamp;
 	sk->sk_rcvtimeo     = listen_sk->sk_rcvtimeo;
 	sk->sk_sndtimeo     = listen_sk->sk_sndtimeo;
 	sk->sk_reuse        = listen_sk->sk_reuse;
Index: linux-2.6.12-rc3-openib/drivers/infiniband/ulp/sdp/sdp_dev.h
===================================================================
--- linux-2.6.12-rc3-openib/drivers/infiniband/ulp/sdp/sdp_dev.h	(revision 2207)
+++ linux-2.6.12-rc3-openib/drivers/infiniband/ulp/sdp/sdp_dev.h	(working copy)
@@ -201,7 +201,10 @@ struct sdev_root {
 	 * cache's
 	 */
 	kmem_cache_t *conn_cache;
+/* XXX Remove once 2.6.12 is out */
+#if ( LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,11) )
 	kmem_cache_t *sock_cache;
+#endif
 };
 
 #endif /* _SDP_DEV_H */




More information about the general mailing list