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

Tom Duffy tduffy at sun.com
Thu Apr 21 16:37:54 PDT 2005


On Thu, 2005-04-21 at 16:31 -0700, Fab Tillier wrote:
> Isn't the above change backwards?  The original code was copying settings
> from listen_sk to sk, and the new code seems to be checking flags in sk to
> determine whether to set them in listen_sk.

You are so right.  My brain ain't on today or something.

Signed-off-by: Tom Duffy <tduffy at sun.com>

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(listen_sk, SOCK_DBG))
+		sock_set_flag(sk, SOCK_DBG);
+	if (sock_flag(listen_sk, SOCK_LOCALROUTE))
+		sock_set_flag(sk, SOCK_LOCALROUTE);
+	if (sock_flag(listen_sk, SOCK_RCVTSTAMP))
+		sock_set_flag(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