[openib-general] [PATCHv6] SDP: Allow SDP to compile on 2.6.12-rc6

Tom Duffy tduffy at sun.com
Thu Jun 9 11:51:32 PDT 2005


This updates the 2.6.12 SDP patch against the state change patch Libor
checked into r2577.

It also fixes a bug I was seeing regarding freeing of resources when
tearing down a connection.

I am still trying to track down a bug with this patch that occurs when
you try to initiate an active connection and there is no passive
listener ready.  This can cause a panic on the passive side if ib_sdp is
loaded.

2.6.12 final should be out any day now, so please apply when that
happens.

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

Index: linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_rcvd.c
===================================================================
--- linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_rcvd.c	(revision 2577)
+++ linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_rcvd.c	(working copy)
@@ -91,8 +91,8 @@ static int sdp_rcvd_disconnect(struct sd
 	/*
 	 * async notification. POLL_HUP on full duplex close only.
 	 */
-	sdp_inet_wake_generic(conn->sk);
-	sk_wake_async(conn->sk, 1, band);
+	sdp_inet_wake_generic(sk_sdp(conn));
+	sk_wake_async(sk_sdp(conn), 1, band);
 
 	return 0;
 error:
@@ -1213,7 +1213,7 @@ int sdp_event_recv(struct sdp_opt *conn,
 			 * If data was consumed by the protocol, signal
 			 * the user.
 			 */
-			sdp_inet_wake_recv(conn->sk, conn->byte_strm);
+			sdp_inet_wake_recv(sk_sdp(conn), conn->byte_strm);
 	/*
 	 * It's possible that a new recv buffer advertisment opened up the 
 	 * recv window and we can flush buffered send data
Index: linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_inet.c
===================================================================
--- linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_inet.c	(revision 2577)
+++ linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_inet.c	(working copy)
@@ -129,9 +129,9 @@ MODULE_PARM_DESC(sdp_debug_level,
  */
 void sdp_inet_wake_send(struct sock *sk)
 {
-	struct sdp_opt *conn;
+	struct sdp_opt *conn = sdp_sk(sk);
 
-	if (!sk || !(conn = SDP_GET_CONN(sk)))
+	if (!sk)
 		return;
 
 	if (sk->sk_socket && test_bit(SOCK_NOSPACE, &sk->sk_socket->flags) &&
@@ -294,27 +294,22 @@ error:
 static int sdp_inet_release(struct socket *sock)
 {
 	struct sdp_opt *conn;
-	struct sock *sk;
+	struct sock *sk = sock->sk;
 	int  result;
 	long timeout;
 	u32  flags;
 
-	if (!sock->sk) {
+	if (!sk) {
 		sdp_dbg_warn(NULL, "release empty <%d:%d> flags <%08lx>",
 			     sock->type, sock->state, sock->flags);
 		return 0;
 	}
 
-	sk = sock->sk;
-	conn = SDP_GET_CONN(sk);
+	conn = sdp_sk(sk);
 
 	sdp_dbg_ctrl(conn, "RELEASE: linger <%d:%lu> data <%d:%d>",
 		     sock_flag(sk, SOCK_LINGER), sk->sk_lingertime,
 		     conn->byte_strm, conn->src_recv);
-	/*
-	 * clear out sock, so we only do this once.
-	 */
-	sock->sk = NULL;
 
 	sdp_conn_lock(conn);
 	conn->shutdown = SHUTDOWN_MASK;
@@ -412,6 +407,7 @@ done:
 	 * finally drop socket reference. (socket API reference)
 	 */
 	sock_orphan(sk);
+	sock->sk = NULL;
 	sdp_conn_unlock(conn);
 	sdp_conn_put(conn);
 
@@ -431,7 +427,7 @@ static int sdp_inet_bind(struct socket *
 	int result;
 
 	sk = sock->sk;
-	conn = SDP_GET_CONN(sk);
+	conn = sdp_sk(sk);
 
 	sdp_dbg_ctrl(conn, "BIND: family <%d> addr <%08x:%04x>",
 		     addr->sin_family, addr->sin_addr.s_addr, addr->sin_port);
@@ -522,7 +518,7 @@ static int sdp_inet_connect(struct socke
 	int result;
 
 	sk = sock->sk;
-	conn = SDP_GET_CONN(sk);
+	conn = sdp_sk(sk);
 
 	sdp_dbg_ctrl(conn, "CONNECT: family <%d> addr <%08x:%04x>",
 		     addr->sin_family, addr->sin_addr.s_addr, addr->sin_port);
@@ -684,7 +680,7 @@ static int sdp_inet_listen(struct socket
 	int result;
 
 	sk = sock->sk;
-	conn = SDP_GET_CONN(sk);
+	conn = sdp_sk(sk);
 
 	sdp_dbg_ctrl(conn, "LISTEN: addr <%08x:%04x> backlog <%04x>",
 		     conn->src_addr, conn->src_port, backlog);
@@ -745,7 +741,7 @@ static int sdp_inet_accept(struct socket
 	long timeout;
 
 	listen_sk = listen_sock->sk;
-	listen_conn = SDP_GET_CONN(listen_sk);
+	listen_conn = sdp_sk(listen_sk);
 
 	sdp_dbg_ctrl(listen_conn, "ACCEPT: addr <%08x:%04x>",
 		     listen_conn->src_addr, listen_conn->src_port);
@@ -801,7 +797,7 @@ static int sdp_inet_accept(struct socket
 				goto listen_done;
 			}
 		} else {
-			accept_sk = accept_conn->sk;
+			accept_sk = sk_sdp(accept_conn);
 
 			switch (accept_conn->state) {
 			case SDP_CONN_ST_REQ_RECV:
@@ -870,7 +866,7 @@ static int sdp_inet_getname(struct socke
 	struct sdp_opt *conn;
 
 	sk = sock->sk;
-	conn = SDP_GET_CONN(sk);
+	conn = sdp_sk(sk);
 
 	sdp_dbg_ctrl(conn, "GETNAME: src <%08x:%04x> dst <%08x:%04x>",
 		     conn->src_addr, conn->src_port, 
@@ -910,7 +906,7 @@ static unsigned int sdp_inet_poll(struct
 	 * recheck the falgs on being woken.
 	 */
 	sk = sock->sk;
-	conn = SDP_GET_CONN(sk);
+	conn = sdp_sk(sk);
 
 	sdp_dbg_data(conn, "POLL: socket flags <%08lx>", sock->flags);
 
@@ -997,7 +993,7 @@ static int sdp_inet_ioctl(struct socket 
 	int value;
 
 	sk = sock->sk;
-	conn = SDP_GET_CONN(sk);
+	conn = sdp_sk(sk);
 
 	sdp_dbg_ctrl(conn, "IOCTL: command <%d> argument <%08lx>", cmd, arg);
 	/*
@@ -1119,7 +1115,7 @@ static int sdp_inet_setopt(struct socket
 	int result = 0;
 
 	sk = sock->sk;
-	conn = SDP_GET_CONN(sk);
+	conn = sdp_sk(sk);
 
 	sdp_dbg_ctrl(conn, "SETSOCKOPT: level <%d> option <%d>", 
 		     level, optname);
@@ -1186,7 +1182,7 @@ static int sdp_inet_getopt(struct socket
 	int len;
 
 	sk = sock->sk;
-	conn = SDP_GET_CONN(sk);
+	conn = sdp_sk(sk);
 
 	sdp_dbg_ctrl(conn, "GETSOCKOPT: level <%d> option <%d>",
 		     level, optname);
@@ -1244,7 +1240,7 @@ static int sdp_inet_shutdown(struct sock
 	int result = 0;
 	struct sdp_opt *conn;
 
-	conn = SDP_GET_CONN(sock->sk);
+	conn = sdp_sk(sock->sk);
 
 	sdp_dbg_ctrl(conn, "SHUTDOWN: flag <%d>", flag);
 	/*
@@ -1352,7 +1348,7 @@ static int sdp_inet_create(struct socket
 	sock->ops = &lnx_stream_ops;
 	sock->state = SS_UNCONNECTED;
 
-	sock_graft(conn->sk, sock);
+	sock_graft(sk_sdp(conn), sock);
 
 	conn->pid = current->pid;
 
@@ -1379,6 +1375,11 @@ static struct net_proto_family sdp_proto
 /*
  * SDP host module load/unload functions
  */
+struct proto sdp_sk_proto = {
+	.name		= "SDP",
+	.owner		= THIS_MODULE,
+	.obj_size	= sizeof(struct sdp_opt),
+};
 
 /*
  * sdp_init - initialize the sdp host module
@@ -1389,6 +1390,12 @@ static int __init sdp_init(void)
 
 	sdp_dbg_init("SDP module load.");
 
+	result = proto_register(&sdp_sk_proto, 1);
+	if (result < 0) {
+		sdp_warn("INIT: Error <%d> registering sk proto,", result);
+		goto error_proto;
+	}
+
 	/*
 	 * proc entries
 	 */
@@ -1465,6 +1472,8 @@ error_link:
 error_advt:
 	sdp_main_proc_cleanup();
 error_proc:
+	proto_unregister(&sdp_sk_proto);
+error_proto:
 	return result;		/* success */
 }
 
@@ -1498,6 +1507,8 @@ static void __exit sdp_exit(void)
 	 * proc tables
 	 */
 	sdp_main_proc_cleanup();
+
+	proto_unregister(&sdp_sk_proto);
 }
 
 module_init(sdp_init);
Index: linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_read.c
===================================================================
--- linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_read.c	(revision 2577)
+++ linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_read.c	(working copy)
@@ -185,7 +185,7 @@ int sdp_event_read(struct sdp_opt *conn,
 			 */
 			conn->byte_strm += result;
 
-			sdp_inet_wake_recv(conn->sk, conn->byte_strm);
+			sdp_inet_wake_recv(sk_sdp(conn), conn->byte_strm);
 		} else {
 			if (result < 0)
 				sdp_dbg_warn(conn, "Error <%d> receiving buff",
@@ -229,7 +229,7 @@ int sdp_event_read(struct sdp_opt *conn,
 
 		iocb->flags &= ~(SDP_IOCB_F_ACTIVE | SDP_IOCB_F_RDMA_R);
 
-		if (conn->sk->sk_rcvlowat > iocb->post)
+		if (sk_sdp(conn)->sk_rcvlowat > iocb->post)
 			break;
 
 		iocb = sdp_iocb_q_get_head(&conn->r_pend);
Index: linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_send.c
===================================================================
--- linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_send.c	(revision 2577)
+++ linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_send.c	(working copy)
@@ -1783,7 +1783,7 @@ static int sdp_inet_write_cancel(struct 
 	/*
 	 * lock the socket while we operate.
 	 */
-	conn = SDP_GET_CONN(si->sock->sk);
+	conn = sdp_sk(si->sock->sk);
 	sdp_conn_lock(conn);
 
 	sdp_dbg_ctrl(conn, "Cancel Write IOCB. <%08x:%04x> <%08x:%04x>",
@@ -1993,7 +1993,7 @@ int sdp_send_flush(struct sdp_opt *conn)
 	/*
 	 * see if there is enough buffer to wake/notify writers
 	 */
-	sdp_inet_wake_send(conn->sk); /*  conn->sk->write_space(conn->sk); */
+	sdp_inet_wake_send(sk_sdp(conn)); /*  conn->sk->write_space(conn->sk); */
 
 	return 0;
 done:
@@ -2022,7 +2022,7 @@ int sdp_inet_send(struct kiocb *req, str
 	oob = (msg->msg_flags & MSG_OOB);
 
 	sk = sock->sk;
-	conn = SDP_GET_CONN(sk);
+	conn = sdp_sk(sk);
 
 	sdp_dbg_data(conn, "send state <%04x> size <%Zu> flags <%08x>",
 		     conn->state, size, msg->msg_flags);
Index: linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_actv.c
===================================================================
--- linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_actv.c	(revision 2577)
+++ linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_actv.c	(working copy)
@@ -40,6 +40,7 @@
 void sdp_cm_actv_error(struct sdp_opt *conn, int error)
 {
 	int result;
+	struct sock *sk;
 	/*
 	 * error value is positive error.
 	 *
@@ -92,11 +93,12 @@ void sdp_cm_actv_error(struct sdp_opt *c
 	conn->shutdown = SHUTDOWN_MASK;
 	conn->send_buf = 0;
 
-	if (conn->sk->sk_socket)
-		conn->sk->sk_socket->state = SS_UNCONNECTED;
+	sk = sk_sdp(conn);
+	if (sk->sk_socket)
+		sk->sk_socket->state = SS_UNCONNECTED;
 
 	sdp_iocb_q_cancel_all(conn, (0 - error));
-	sdp_inet_wake_error(conn->sk);
+	sdp_inet_wake_error(sk);
 }
 
 /*
@@ -113,7 +115,7 @@ static int sdp_cm_actv_establish(struct 
 		     conn->src_addr, conn->src_port,
 		     conn->dst_addr, conn->dst_port);
 
-	sk = conn->sk;
+	sk = sk_sdp(conn);
 
 	qp_attr = kmalloc(sizeof(*qp_attr), GFP_KERNEL);
 	if (!qp_attr)
@@ -541,7 +543,7 @@ int sdp_cm_connect(struct sdp_opt *conn)
 					  
 	result = sdp_link_path_lookup(htonl(conn->dst_addr),
 				      htonl(conn->src_addr),
-				      conn->sk->sk_bound_dev_if,
+				      sk_sdp(conn)->sk_bound_dev_if,
 				      sdp_cm_path_complete,
 				      conn,
 				      &conn->plid);
Index: linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_conn.c
===================================================================
--- linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_conn.c	(revision 2577)
+++ linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_conn.c	(working copy)
@@ -75,6 +75,8 @@ static u32 sdp_psn_generate(void)
 
 void sdp_conn_inet_error(struct sdp_opt *conn, int error)
 {
+	struct sock *sk;
+
 	sdp_dbg_ctrl(conn, "report connection error <%d>", error);
 	/*
 	 * the connection has failed, move to error, and notify anyone
@@ -88,11 +90,12 @@ void sdp_conn_inet_error(struct sdp_opt 
 	conn->shutdown = SHUTDOWN_MASK;
 	conn->send_buf = 0;
 
-	if (conn->sk->sk_socket)
-		conn->sk->sk_socket->state = SS_UNCONNECTED;
+	sk = sk_sdp(conn);
+	if (sk->sk_socket)
+		sk->sk_socket->state = SS_UNCONNECTED;
 
 	sdp_iocb_q_cancel_all(conn, -error);
-	sdp_inet_wake_error(conn->sk);
+	sdp_inet_wake_error(sk);
 }
 
 void sdp_conn_abort(struct sdp_opt *conn)
@@ -402,7 +405,7 @@ int sdp_inet_port_get(struct sdp_opt *co
 	static s32 rover = -1;
 	unsigned long flags;
 
-	sk = conn->sk;
+	sk = sk_sdp(conn);
 	/*
 	 * lock table
 	 */
@@ -413,7 +416,7 @@ int sdp_inet_port_get(struct sdp_opt *co
 	if (port > 0) {
 		for (look = dev_root_s.bind_list, port_ok = 1;
 		     look; look = look->bind_next) {
-			srch = look->sk;
+			srch = sk_sdp(look);
 			/*
 			 * 1) same port
 			 * 2) linux force reuse is off.
@@ -842,17 +845,8 @@ void sdp_conn_destruct(struct sdp_opt *c
 
 	if (dump)
 		sdp_conn_state_dump(conn);
-	/*
-	 * free the OS socket structure
-	 */
-	if (!conn->sk)
-		sdp_dbg_warn(conn, "destruct, no socket! continuing.");
-	else {
-		sk_free(conn->sk);
-		conn->sk = NULL;
-	}
 
-	kmem_cache_free(dev_root_s.conn_cache, conn);
+	sk_free(sk_sdp(conn));
 }
 
 /*
@@ -1197,6 +1191,8 @@ error_attr:
 	return result;
 }
 
+extern struct proto sdp_sk_proto;
+
 /*
  * sdp_conn_alloc - allocate a new socket, and init.
  */
@@ -1206,8 +1202,7 @@ struct sdp_opt *sdp_conn_alloc(int prior
 	struct sock *sk;
 	int result;
 
-	sk = sk_alloc(dev_root_s.proto, priority, 
-		      sizeof(struct inet_sock), dev_root_s.sock_cache);
+	sk = sk_alloc(dev_root_s.proto, priority, &sdp_sk_proto, 1);
 	if (!sk) {
 		sdp_dbg_warn(NULL, "socket alloc error for protocol. <%d:%d>",
 			     dev_root_s.proto, priority);
@@ -1230,23 +1225,8 @@ struct sdp_opt *sdp_conn_alloc(int prior
 	sk->sk_state_change = sdp_inet_wake_generic;
 	sk->sk_data_ready   = sdp_inet_wake_recv;
 	sk->sk_error_report = sdp_inet_wake_error;
-	/*
-	 * Allocate must be called from process context, since QP
-	 * create/modifies must be in that context.
-	 */
-	conn = kmem_cache_alloc(dev_root_s.conn_cache, priority);
-	if (!conn) {
-		sdp_dbg_warn(conn, "connection alloc error. <%d>", priority);
-		result = -ENOMEM;
-		goto error;
-	}
 
-	memset(conn, 0, sizeof(struct sdp_opt));
-	/*
-	 * The STRM interface specific data is map/cast over the TCP specific
-	 * area of the sock.
-	 */
-	SDP_SET_CONN(sk, conn);
+	conn = sdp_sk(sk);
 	SDP_CONN_ST_INIT(conn);
 
 	conn->cm_id       = NULL;
@@ -1263,7 +1243,6 @@ struct sdp_opt *sdp_conn_alloc(int prior
 	conn->parent      = NULL;
 
 	conn->pid       = 0;
-	conn->sk        = sk;
 	conn->hashent   = SDP_DEV_SK_INVALID;
 	conn->flags     = 0;
 	conn->shutdown  = 0;
@@ -1369,7 +1348,7 @@ struct sdp_opt *sdp_conn_alloc(int prior
 		sdp_dbg_warn(conn, "Error <%d> conn table insert <%d:%d>",
 			     result, dev_root_s.sk_entry,
 			     dev_root_s.sk_size);
-		goto error_conn;
+		goto error;
 	}
 	/*
 	 * set reference
@@ -1383,8 +1362,6 @@ struct sdp_opt *sdp_conn_alloc(int prior
 	 * done
 	 */
 	return conn;
-error_conn:
-	kmem_cache_free(dev_root_s.conn_cache, conn);
 error:
 	sk_free(sk);
 	return NULL;
@@ -1553,7 +1530,7 @@ int sdp_proc_dump_conn_data(char *buffer
 			continue;
 
 		conn = dev_root_s.sk_array[counter];
-		sk = conn->sk;
+		sk = sk_sdp(conn);
 
 		offset += sprintf((buffer + offset), SDP_PROC_CONN_DATA_FORM,
 				  conn->hashent,
@@ -2038,26 +2015,6 @@ int sdp_conn_table_init(int proto_family
 		goto error_iocb;
 	}
 
-	dev_root_s.conn_cache = kmem_cache_create("sdp_conn",
-						  sizeof(struct sdp_opt),
-						  0, SLAB_HWCACHE_ALIGN,
-						  NULL, NULL);
-	if (!dev_root_s.conn_cache) {
-		sdp_warn("Failed to initialize connection cache.");
-		result = -ENOMEM;
-		goto error_conn;
-	}
-
-        dev_root_s.sock_cache = kmem_cache_create("sdp_sock",
-						  sizeof(struct inet_sock), 
-						  0, SLAB_HWCACHE_ALIGN,
-						  NULL, NULL);
-        if (!dev_root_s.sock_cache) {
-		sdp_warn("Failed to initialize sock cache.");
-		result = -ENOMEM;
-		goto error_sock;
-        }
-
 	/*
 	 * start listening
 	 */
@@ -2066,7 +2023,7 @@ int sdp_conn_table_init(int proto_family
 	if (!dev_root_s.listen_id) {
 		sdp_warn("Failed to create listen connection identifier.");
 		result = -ENOMEM;
-		goto error_cm_id;
+		goto error_conn;
 	}
 
 	result = ib_cm_listen(dev_root_s.listen_id,
@@ -2083,10 +2040,6 @@ int sdp_conn_table_init(int proto_family
 	return 0;
 error_listen:
 	ib_destroy_cm_id(dev_root_s.listen_id);
-error_cm_id:
-	kmem_cache_destroy(dev_root_s.sock_cache);
-error_sock:
-	kmem_cache_destroy(dev_root_s.conn_cache);
 error_conn:
 	sdp_main_iocb_cleanup();
 error_iocb:
@@ -2128,14 +2081,6 @@ void sdp_conn_table_clear(void)
 	 */
 	sdp_main_iocb_cleanup();
 	/*
-	 * delete conn cache
-	 */
-	kmem_cache_destroy(dev_root_s.conn_cache);
-	/*
-	 * delete sock cache
-	 */
-	kmem_cache_destroy(dev_root_s.sock_cache);
-	/*
 	 * stop listening
 	 */
 	ib_destroy_cm_id(dev_root_s.listen_id);
Index: linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_recv.c
===================================================================
--- linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_recv.c	(revision 2577)
+++ linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_recv.c	(working copy)
@@ -786,7 +786,7 @@ static int sdp_recv_buff_iocb_pending(st
 	 */
 	if (!iocb->len ||
 	    (!conn->src_recv &&
-	     !(conn->sk->sk_rcvlowat > iocb->post))) {
+	     !(sk_sdp(conn)->sk_rcvlowat > iocb->post))) {
 		/*
 		 * complete IOCB
 		 */
@@ -840,7 +840,7 @@ int sdp_recv_buff(struct sdp_opt *conn, 
 	 */
 	if (buff->flags & SDP_BUFF_F_OOB_PEND) {
 		conn->rcv_urg_cnt++;
-		sdp_inet_wake_urg(conn->sk);
+		sdp_inet_wake_urg(sk_sdp(conn));
 	}
 	/*
 	 * loop while there are available IOCB's, break if there is no
@@ -938,7 +938,7 @@ static int sdp_inet_read_cancel(struct k
 	/*
 	 * lock the socket while we operate.
 	 */
-	conn = SDP_GET_CONN(si->sock->sk);
+	conn = sdp_sk(si->sock->sk);
 	sdp_conn_lock(conn);
 
 	sdp_dbg_ctrl(conn, "Cancel Read IOCB. <%08x:%04x> <%08x:%04x>",
@@ -1091,7 +1091,7 @@ static int sdp_inet_recv_urg(struct sock
 	int result = 0;
 	u8 value;
 
-	conn = SDP_GET_CONN(sk);
+	conn = sdp_sk(sk);
 
 	if (sock_flag(sk, SOCK_URGINLINE) || !conn->rcv_urg_cnt)
 		return -EINVAL;
@@ -1178,7 +1178,7 @@ int sdp_inet_recv(struct kiocb  *req, st
 	struct sdpc_buff_q peek_queue;
 
 	sk = sock->sk;
-	conn = SDP_GET_CONN(sk);
+	conn = sdp_sk(sk);
 
 	sdp_dbg_data(conn, "state <%08x> size <%Zu> pending <%d> falgs <%08x>",
 		     conn->state, size, conn->byte_strm, flags);
Index: linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_conn.h
===================================================================
--- linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_conn.h	(revision 2577)
+++ linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_conn.h	(working copy)
@@ -108,16 +108,18 @@ enum sdp_mode {
  */
 #define SDP_MSG_EVENT_TABLE_SIZE 0x20
 
-/*
- * connection handle within a socket.
- */
-#define SDP_GET_CONN(sk) \
-       (*((struct sdp_opt **)&(sk)->sk_protinfo))
-#define SDP_SET_CONN(sk, conn) \
-       (*((struct sdp_opt **)&(sk)->sk_protinfo) = (conn))
+static inline struct sdp_opt *sdp_sk(struct sock *sk)
+{
+	return (struct sdp_opt *)sk;
+}
+
+static inline struct sock *sk_sdp(struct sdp_opt *conn)
+{
+	return (struct sock *)conn;
+}
 
 #define SDP_CONN_SET_ERR(conn, val) \
-        ((conn)->error = (conn)->sk->sk_err = (val))
+        ((conn)->error = sk_sdp(conn)->sk_err = (val))
 #define SDP_CONN_GET_ERR(conn) \
         ((conn)->error)
 
@@ -179,10 +181,15 @@ struct sdp_conn_lock {
  * SDP Connection structure.
  */
 struct sdp_opt {
+	/*
+	 * inet_sock must be first member of sdp_opt
+	 * NOTE: this depends on inet_sock having struct sock as its
+	 * first member
+	 */
+	struct inet_sock in;
 	__s32 hashent;     /* connection ID/hash entry */
 	atomic_t refcnt;   /* connection reference count. */
 
-	struct sock *sk;
 	/*
 	 * SDP specific data
 	 */
@@ -493,7 +500,7 @@ static inline int sdp_conn_error(struct 
 	 * lock, however the linux socket error, needs to be xchg'd since the
 	 * SO_ERROR getsockopt happens outside of the connection lock.
 	 */
-	int error = xchg(&conn->sk->sk_err, 0);
+	int error = xchg(&sk_sdp(conn)->sk_err, 0);
 	SDP_CONN_SET_ERR(conn, 0);
 
 	return -error;
Index: linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_pass.c
===================================================================
--- linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_pass.c	(revision 2577)
+++ linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_pass.c	(working copy)
@@ -87,7 +87,7 @@ int sdp_cm_pass_establish(struct sdp_opt
 		goto error;
 	}
 
-	sdp_inet_wake_send(conn->sk);
+	sdp_inet_wake_send(sk_sdp(conn));
 
         kfree(qp_attr);
 	return 0;
@@ -271,8 +271,8 @@ static int sdp_cm_listen_lookup(struct s
 	/*
 	 * check backlog
 	 */
-	listen_sk = listen_conn->sk;
-	sk = conn->sk;
+	listen_sk = sk_sdp(listen_conn);
+	sk = sk_sdp(conn);
 
 	if (listen_conn->backlog_cnt > listen_conn->backlog_max) {
 		sdp_dbg_warn(listen_conn, 
@@ -305,13 +305,16 @@ static int sdp_cm_listen_lookup(struct s
 	 */
 	sk->sk_lingertime   = listen_sk->sk_lingertime;
 	sk->sk_rcvlowat     = listen_sk->sk_rcvlowat;
-	sk->sk_debug        = listen_sk->sk_debug;
-	sk->sk_localroute   = listen_sk->sk_localroute;
+	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);
 	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;
+	if (sock_flag(listen_sk, SOCK_RCVTSTAMP))
+		sock_set_flag(sk, SOCK_RCVTSTAMP);
 	sk->sk_rcvtimeo     = listen_sk->sk_rcvtimeo;
 	sk->sk_sndtimeo     = listen_sk->sk_sndtimeo;
 	sk->sk_reuse        = listen_sk->sk_reuse;
@@ -450,7 +453,7 @@ int sdp_cm_req_handler(struct ib_cm_id *
 		goto done;
 	}
 	/*
-	 * Lock the new connection before modifyingg it into any tables.
+	 * Lock the new connection before modifying it into any tables.
 	 */
 	sdp_conn_lock(conn);
 	/*
Index: linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_dev.h
===================================================================
--- linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_dev.h	(revision 2577)
+++ linux-2.6.12-rc6-openib/drivers/infiniband/ulp/sdp/sdp_dev.h	(working copy)
@@ -197,11 +197,6 @@ struct sdev_root {
 	 * SDP wide listen
 	 */
 	struct ib_cm_id *listen_id;      /* listen handle */
-	/*
-	 * cache's
-	 */
-	kmem_cache_t *conn_cache;
-	kmem_cache_t *sock_cache;
 };
 
 #endif /* _SDP_DEV_H */




More information about the general mailing list