[Ocfs2-commits] zab commits r1778 - trunk/cluster

svn-commits at oss.oracle.com svn-commits at oss.oracle.com
Mon Jan 17 13:31:07 CST 2005


Author: zab
Date: 2005-01-17 13:31:05 -0600 (Mon, 17 Jan 2005)
New Revision: 1778

Modified:
   trunk/cluster/tcp.c
Log:
- make sure we don't try to send too many payload bytes
- tx doesn't need to check that it could handle the type before sending


Modified: trunk/cluster/tcp.c
===================================================================
--- trunk/cluster/tcp.c	2005-01-15 05:51:03 UTC (rev 1777)
+++ trunk/cluster/tcp.c	2005-01-17 19:31:05 UTC (rev 1778)
@@ -55,17 +55,19 @@
  * but it really depends on what the semantics and messages are.
  *
  * XXX we should resolve these before release
- * 	- make sure max lens are enforced.. alloc max, don't send > max
  * 	- disable preemt before calling rx handler when debugging
  * 	- find explicit stack call to drain rx queue
- * 	- simplify rx thread exit path (completion, etc)
  * 	- goto out style exiting
- * 	- implement net_remove_handlers
- * 	- refcounting around sock against tx/teardown/etc
  * 	- get sin/iov/msg off the stack, per sock structures
  * 	- add trivial version trading message at the start of a conn
- * 	- tear down sockets on exit.. via removing their inodes?
- * 	- make sure ->net.page gets torn down with net_inode_private
+ * 	- go nuts adding static
+ * 	- properly life-cycle management is waiting on a more functional
+ * 	  setup and teardown facility:
+ * 		- implement net_remove_handlers
+ * 		- refcounting around sock against tx/teardown/etc
+ * 		- make sure ->net.page gets torn down with net_inode_private
+ * 		- tear down sockets on exit.. via removing their inodes?
+ * 		- simplify rx thread exit path (completion, etc)
  *
  * 	- move gsd into its own file
  * 	- move to userspace connection management?
@@ -585,6 +587,8 @@
 
 //////////////////////////////////////////////////////////////////////////////
 
+/* max_len is protection for the handler func.  incoming messages won't
+ * be given to the handler if their payload is longer than the max. */
 int net_register_handler(u32 msg_type, u32 key, int flags, u32 max_len, 
 			 net_msg_handler_func *func, void *data)
 {
@@ -829,7 +833,6 @@
 {
 	int ret, tmpret;
 	net_msg *msg = NULL;
-	net_msg_handler *handler = NULL;
 	net_status_ctxt nsc;
 	wait_queue_t sleep;
 	nm_node_inode_private *priv = NULL;
@@ -848,6 +851,15 @@
 		goto done;
 	}
 
+	for(i = 0; i < caller_iovlen; i++)
+		caller_bytes += caller_iov[i].iov_len;
+
+	if (caller_bytes > NET_MAX_PAYLOAD_BYTES) {
+		netprintk("total payload len %zu too large\n", caller_bytes);
+		ret = -EINVAL;
+		goto done;
+	}
+
 	priv = (nm_node_inode_private *)inode->u.generic_ip;
 	net = &priv->net;
 	spin_lock(&net->sock_lock); 
@@ -863,23 +875,6 @@
 	}
 	spin_unlock(&net->sock_lock); 
 	
-	handler = net_lookup_handler(msg_type, key);
-	if (!handler) {
-		netprintk("no such message type: %u/%u\n", msg_type, key);
-		ret = -EINVAL;
-		goto done;
-	}
-
-	for(i = 0; i < caller_iovlen; i++)
-		caller_bytes += caller_iov[i].iov_len;
-
-	if (!net_handler_msg_len_ok(handler, caller_bytes)) {
-		netprintk("len for message type %u incorrect: %zu, should be %u\n", 
-		       msg_type, caller_bytes, handler->max_len);
-		ret = -EINVAL;
-		goto done;
-	}
-
 	/* build up our iovec */
 	iovlen = caller_iovlen + 1;
 	iov = kmalloc(sizeof(struct iovec) * iovlen, GFP_KERNEL);
@@ -963,8 +958,6 @@
 	}
 
 done:
-	if (handler)
-		net_put_handler(handler);
 	if (iov)
 		kfree(iov);
 	if (msg)



More information about the Ocfs2-commits mailing list