[openib-general] [PATCH] SDP: fix oops with port reuse

Tom Duffy tduffy at sun.com
Mon Jul 25 13:45:27 PDT 2005


On Mon, 2005-07-25 at 12:20 -0700, Libor Michalek wrote:
>   The original code at the begining of sdp_inet_port_put() was checking
> to see if the connection was already in the bind list, and returning an
> error if it was not in the list. The error check that's there now is
> doing something different, and we return success if the connection
> is not in the bind list and has a put() done on it.
> 
>   If we are regularly doing a put on a socket not in the bind list,
> the function should be made void, and the check for list membership
> not generate an error...

Something like this?

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

Index: linux-2.6.13-rc3-openib/drivers/infiniband/ulp/sdp/sdp_inet.c
===================================================================
--- linux-2.6.13-rc3-openib/drivers/infiniband/ulp/sdp/sdp_inet.c	(revision 2909)
+++ linux-2.6.13-rc3-openib/drivers/infiniband/ulp/sdp/sdp_inet.c	(working copy)
@@ -1100,7 +1100,7 @@ static int sdp_inet_setopt(struct socket
 							SDP_MSG_HDR_SIZE));
 		break;
 	case SDP_UNBIND:
-		result = sdp_inet_port_put(conn);
+		sdp_inet_port_put(conn);
 		break;
 	default:
 		sdp_warn("SETSOCKOPT unimplemented option <%d:%d> conn <%d>.",
Index: linux-2.6.13-rc3-openib/drivers/infiniband/ulp/sdp/sdp_proto.h
===================================================================
--- linux-2.6.13-rc3-openib/drivers/infiniband/ulp/sdp/sdp_proto.h	(revision 2909)
+++ linux-2.6.13-rc3-openib/drivers/infiniband/ulp/sdp/sdp_proto.h	(working copy)
@@ -287,7 +287,7 @@ struct sdp_sock *sdp_inet_listen_lookup(
 
 int sdp_inet_port_get(struct sdp_sock *conn, u16 port);
 
-int sdp_inet_port_put(struct sdp_sock *conn);
+void sdp_inet_port_put(struct sdp_sock *conn);
 
 void sdp_inet_port_inherit(struct sdp_sock *parent, struct sdp_sock *child);
 
Index: linux-2.6.13-rc3-openib/drivers/infiniband/ulp/sdp/sdp_conn.c
===================================================================
--- linux-2.6.13-rc3-openib/drivers/infiniband/ulp/sdp/sdp_conn.c	(revision 2909)
+++ linux-2.6.13-rc3-openib/drivers/infiniband/ulp/sdp/sdp_conn.c	(working copy)
@@ -490,19 +490,17 @@ done:
 /*
  * sdp_inet_port_put - unbind a socket from a port.
  */
-int sdp_inet_port_put(struct sdp_sock *conn)
+void sdp_inet_port_put(struct sdp_sock *conn)
 {
 	unsigned long flags;
-
-	if (list_empty(&dev_root_s.bind_list))
-		return -EADDRNOTAVAIL;
+	struct sdp_sock *i, *j;
 
 	spin_lock_irqsave(&dev_root_s.bind_lock, flags);
-	list_del(&conn->bind_next);
+	list_for_each_entry_safe(i, j, &dev_root_s.bind_list, bind_next)
+		if (conn == i)
+			list_del(&conn->bind_next);
 	conn->src_port = 0;
 	spin_unlock_irqrestore(&dev_root_s.bind_lock, flags);
-
-	return 0;
 }
 
 /*
@@ -694,7 +692,7 @@ void sdp_conn_put(struct sdp_sock *conn)
 	/*
 	 * If the socket is bound, return the port
 	 */
-	(void)sdp_inet_port_put(conn);
+	sdp_inet_port_put(conn);
 
 	sdp_conn_stat_dump(conn);
 	/*




More information about the general mailing list