public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH][1/3] IPoIB: set skb->mac.raw on receive
@ 2005-04-01  3:36 Roland Dreier
  2005-04-01  3:36 ` [PATCH][2/3] IPoIB: fix static rate calculation Roland Dreier
  2005-04-01  4:18 ` [PATCH][1/3] IPoIB: set skb->mac.raw on receive David S. Miller
  0 siblings, 2 replies; 6+ messages in thread
From: Roland Dreier @ 2005-04-01  3:36 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, openib-general

From: Hal Rosenstock <halr@voltaire.com>

Set skb->mac.raw on receive.  This fixes crashes when this is
dereferenced, for example by netfilter or when PF_PACKET is used.

Signed-off-by: Hal Rosenstock <halr@voltaire.com>
Signed-off-by: Roland Dreier <roland@topspin.com>

--- linux-export.orig/drivers/infiniband/ulp/ipoib/ipoib_ib.c	2005-03-31 19:07:06.912605203 -0800
+++ linux-export/drivers/infiniband/ulp/ipoib/ipoib_ib.c	2005-03-31 19:23:30.599053347 -0800
@@ -201,7 +201,7 @@
 			if (wc->slid != priv->local_lid ||
 			    wc->src_qp != priv->qp->qp_num) {
 				skb->protocol = ((struct ipoib_header *) skb->data)->proto;
-
+				skb->mac.raw = skb->data;
 				skb_pull(skb, IPOIB_ENCAP_LEN);
 
 				dev->last_rx = jiffies;


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH][2/3] IPoIB: fix static rate calculation
  2005-04-01  3:36 [PATCH][1/3] IPoIB: set skb->mac.raw on receive Roland Dreier
@ 2005-04-01  3:36 ` Roland Dreier
  2005-04-01  3:36   ` [PATCH][3/3] IPoIB: convert to debugfs Roland Dreier
  2005-04-01  4:18 ` [PATCH][1/3] IPoIB: set skb->mac.raw on receive David S. Miller
  1 sibling, 1 reply; 6+ messages in thread
From: Roland Dreier @ 2005-04-01  3:36 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, openib-general

Correct and simplify calculation of static rate.  We need to round up
the quotient of (local_rate - path_rate) / path_rate.  To round up we
add (path_rate - 1) to the numerator, so the quotient simplifies to
(local_rate - 1) / path_rate.

No idea how I came up with the old formula.

Signed-off-by: Roland Dreier <roland@topspin.com>

--- linux-export.orig/drivers/infiniband/ulp/ipoib/ipoib_main.c	2005-03-31 19:06:47.984714505 -0800
+++ linux-export/drivers/infiniband/ulp/ipoib/ipoib_main.c	2005-03-31 19:26:39.094134171 -0800
@@ -302,11 +302,10 @@
 			.sl 	       = pathrec->sl,
 			.port_num      = priv->port
 		};
+		int path_rate = ib_sa_rate_enum_to_int(pathrec->rate);
 
-		if (ib_sa_rate_enum_to_int(pathrec->rate) > 0)
-			av.static_rate = (2 * priv->local_rate -
-					  ib_sa_rate_enum_to_int(pathrec->rate) - 1) /
-				(priv->local_rate ? priv->local_rate : 1);
+		if (path_rate > 0 && priv->local_rate > path_rate)
+			av.static_rate = (priv->local_rate - 1) / path_rate;
 
 		ipoib_dbg(priv, "static_rate %d for local port %dX, path %dX\n",
 			  av.static_rate, priv->local_rate,
--- linux-export.orig/drivers/infiniband/ulp/ipoib/ipoib_multicast.c	2005-03-31 19:07:01.877698296 -0800
+++ linux-export/drivers/infiniband/ulp/ipoib/ipoib_multicast.c	2005-03-31 19:26:03.861782487 -0800
@@ -258,13 +258,12 @@
 				.traffic_class = mcast->mcmember.traffic_class
 			}
 		};
+		int path_rate = ib_sa_rate_enum_to_int(mcast->mcmember.rate);
 
 		av.grh.dgid = mcast->mcmember.mgid;
 
-		if (ib_sa_rate_enum_to_int(mcast->mcmember.rate) > 0)
-			av.static_rate = (2 * priv->local_rate -
-					  ib_sa_rate_enum_to_int(mcast->mcmember.rate) - 1) /
-				(priv->local_rate ? priv->local_rate : 1);
+		if (path_rate > 0 && priv->local_rate > path_rate)
+			av.static_rate = (priv->local_rate - 1) / path_rate;
 
 		ipoib_dbg_mcast(priv, "static_rate %d for local port %dX, mcmember %dX\n",
 				av.static_rate, priv->local_rate,


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH][3/3] IPoIB: convert to debugfs
  2005-04-01  3:36 ` [PATCH][2/3] IPoIB: fix static rate calculation Roland Dreier
@ 2005-04-01  3:36   ` Roland Dreier
  2005-04-01 17:45     ` [PATCH][4/3] IPoIB: document conversion " Roland Dreier
  0 siblings, 1 reply; 6+ messages in thread
From: Roland Dreier @ 2005-04-01  3:36 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, openib-general

Convert IPoIB to use debugfs instead of its own custom debugging filesystem.

Signed-off-by: Roland Dreier <roland@topspin.com>

--- linux-export.orig/drivers/infiniband/ulp/ipoib/ipoib_fs.c	2005-03-31 19:07:14.463965782 -0800
+++ linux-export/drivers/infiniband/ulp/ipoib/ipoib_fs.c	2005-03-31 19:31:28.624283013 -0800
@@ -32,19 +32,16 @@
  * $Id: ipoib_fs.c 1389 2004-12-27 22:56:47Z roland $
  */
 
-#include <linux/pagemap.h>
+#include <linux/err.h>
 #include <linux/seq_file.h>
 
-#include "ipoib.h"
+struct file_operations;
 
-enum {
-	IPOIB_MAGIC = 0x49504942 /* "IPIB" */
-};
+#include <linux/debugfs.h>
+
+#include "ipoib.h"
 
-static DECLARE_MUTEX(ipoib_fs_mutex);
 static struct dentry *ipoib_root;
-static struct super_block *ipoib_sb;
-static LIST_HEAD(ipoib_device_list);
 
 static void *ipoib_mcg_seq_start(struct seq_file *file, loff_t *pos)
 {
@@ -145,143 +142,34 @@
 	.release = seq_release
 };
 
-static struct inode *ipoib_get_inode(void)
-{
-	struct inode *inode = new_inode(ipoib_sb);
-
-	if (inode) {
-		inode->i_mode 	 = S_IFREG | S_IRUGO;
-		inode->i_uid 	 = 0;
-		inode->i_gid 	 = 0;
-		inode->i_blksize = PAGE_CACHE_SIZE;
-		inode->i_blocks  = 0;
-		inode->i_atime 	 = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
-		inode->i_fop     = &ipoib_fops;
-	}
-
-	return inode;
-}
-
-static int __ipoib_create_debug_file(struct net_device *dev)
+int ipoib_create_debug_file(struct net_device *dev)
 {
 	struct ipoib_dev_priv *priv = netdev_priv(dev);
-	struct dentry *dentry;
-	struct inode *inode;
 	char name[IFNAMSIZ + sizeof "_mcg"];
 
 	snprintf(name, sizeof name, "%s_mcg", dev->name);
 
-	dentry = d_alloc_name(ipoib_root, name);
-	if (!dentry)
-		return -ENOMEM;
-
-	inode = ipoib_get_inode();
-	if (!inode) {
-		dput(dentry);
-		return -ENOMEM;
-	}
-
-	inode->u.generic_ip = dev;
-	priv->mcg_dentry = dentry;
-
-	d_add(dentry, inode);
-
-	return 0;
-}
-
-int ipoib_create_debug_file(struct net_device *dev)
-{
-	struct ipoib_dev_priv *priv = netdev_priv(dev);
-
-	down(&ipoib_fs_mutex);
-
-	list_add_tail(&priv->fs_list, &ipoib_device_list);
-
-	if (!ipoib_sb) {
-		up(&ipoib_fs_mutex);
-		return 0;
-	}
-
-	up(&ipoib_fs_mutex);
+	priv->mcg_dentry = debugfs_create_file(name, S_IFREG | S_IRUGO,
+					       ipoib_root, dev, &ipoib_fops);
 
-	return __ipoib_create_debug_file(dev);
+	return priv->mcg_dentry ? 0 : -ENOMEM;
 }
 
 void ipoib_delete_debug_file(struct net_device *dev)
 {
 	struct ipoib_dev_priv *priv = netdev_priv(dev);
 
-	down(&ipoib_fs_mutex);
-	list_del(&priv->fs_list);
-	if (!ipoib_sb) {
-		up(&ipoib_fs_mutex);
-		return;
-	}
-	up(&ipoib_fs_mutex);
-
-	if (priv->mcg_dentry) {
-		d_drop(priv->mcg_dentry);
-		simple_unlink(ipoib_root->d_inode, priv->mcg_dentry);
-	}
-}
-
-static int ipoib_fill_super(struct super_block *sb, void *data, int silent)
-{
-	static struct tree_descr ipoib_files[] = {
-		{ "" }
-	};
-	struct ipoib_dev_priv *priv;
-	int ret;
-
-	ret = simple_fill_super(sb, IPOIB_MAGIC, ipoib_files);
-	if (ret)
-		return ret;
-
-	ipoib_root = sb->s_root;
-
-	down(&ipoib_fs_mutex);
-
-	ipoib_sb = sb;
-
-	list_for_each_entry(priv, &ipoib_device_list, fs_list) {
-		ret = __ipoib_create_debug_file(priv->dev);
-		if (ret)
-			break;
-	}
-
-	up(&ipoib_fs_mutex);
-
-	return ret;
-}
-
-static struct super_block *ipoib_get_sb(struct file_system_type *fs_type,
-	int flags, const char *dev_name, void *data)
-{
-	return get_sb_single(fs_type, flags, data, ipoib_fill_super);
+	if (priv->mcg_dentry)
+		debugfs_remove(priv->mcg_dentry);
 }
 
-static void ipoib_kill_sb(struct super_block *sb)
-{
-	down(&ipoib_fs_mutex);
-	ipoib_sb = NULL;
-	up(&ipoib_fs_mutex);
-
-	kill_litter_super(sb);
-}
-
-static struct file_system_type ipoib_fs_type = {
-	.owner		= THIS_MODULE,
-	.name		= "ipoib_debugfs",
-	.get_sb		= ipoib_get_sb,
-	.kill_sb	= ipoib_kill_sb,
-};
-
 int ipoib_register_debugfs(void)
 {
-	return register_filesystem(&ipoib_fs_type);
+	ipoib_root = debugfs_create_dir("ipoib", NULL);
+	return ipoib_root ? 0 : -ENOMEM;
 }
 
 void ipoib_unregister_debugfs(void)
 {
-	unregister_filesystem(&ipoib_fs_type);
+	debugfs_remove(ipoib_root);
 }
--- linux-export.orig/drivers/infiniband/ulp/ipoib/ipoib_main.c	2005-03-31 19:26:39.094134171 -0800
+++ linux-export/drivers/infiniband/ulp/ipoib/ipoib_main.c	2005-03-31 19:30:51.117424929 -0800
@@ -1082,19 +1082,19 @@
 
 	return 0;
 
-err_fs:
-	ipoib_unregister_debugfs();
-
 err_wq:
 	destroy_workqueue(ipoib_workqueue);
 
+err_fs:
+	ipoib_unregister_debugfs();
+
 	return ret;
 }
 
 static void __exit ipoib_cleanup_module(void)
 {
-	ipoib_unregister_debugfs();
 	ib_unregister_client(&ipoib_client);
+	ipoib_unregister_debugfs();
 	destroy_workqueue(ipoib_workqueue);
 }
 


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][1/3] IPoIB: set skb->mac.raw on receive
  2005-04-01  3:36 [PATCH][1/3] IPoIB: set skb->mac.raw on receive Roland Dreier
  2005-04-01  3:36 ` [PATCH][2/3] IPoIB: fix static rate calculation Roland Dreier
@ 2005-04-01  4:18 ` David S. Miller
  2005-04-01  4:24   ` Roland Dreier
  1 sibling, 1 reply; 6+ messages in thread
From: David S. Miller @ 2005-04-01  4:18 UTC (permalink / raw)
  To: Roland Dreier; +Cc: akpm, linux-kernel, openib-general


Roland, netdev@oss.sgi.com CC:'ing either Jeff Garzik and
myself, please.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH][1/3] IPoIB: set skb->mac.raw on receive
  2005-04-01  4:18 ` [PATCH][1/3] IPoIB: set skb->mac.raw on receive David S. Miller
@ 2005-04-01  4:24   ` Roland Dreier
  0 siblings, 0 replies; 6+ messages in thread
From: Roland Dreier @ 2005-04-01  4:24 UTC (permalink / raw)
  To: David S. Miller; +Cc: akpm, linux-kernel, openib-general

    David> Roland, netdev@oss.sgi.com CC:'ing either Jeff Garzik and
    David> myself, please.

Sorry, will do next time around, unless you'd like me to resend this
batch as well.  All 3 patches are pretty trivial, though.  The biggest
one is just deleting a lot of code by switching to debugfs.

 - R.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH][4/3] IPoIB: document conversion to debugfs
  2005-04-01  3:36   ` [PATCH][3/3] IPoIB: convert to debugfs Roland Dreier
@ 2005-04-01 17:45     ` Roland Dreier
  0 siblings, 0 replies; 6+ messages in thread
From: Roland Dreier @ 2005-04-01 17:45 UTC (permalink / raw)
  To: akpm; +Cc: linux-kernel, openib-general, netdev, davem

Update IPoIB documentation now that multicast debugging files have
moved from ipoibdebugfs to debugfs.

Signed-off-by: Roland Dreier <roland@topspin.com>

--- linux-export.orig/Documentation/infiniband/ipoib.txt	2005-03-31 19:07:01.000000000 -0800
+++ linux-export/Documentation/infiniband/ipoib.txt	2005-04-01 09:43:27.122520190 -0800
@@ -32,14 +32,13 @@
   mcast_debug_level to 1.  These parameters can be controlled at
   runtime through files in /sys/module/ib_ipoib/.
 
-  CONFIG_INFINIBAND_IPOIB_DEBUG also enables the "ipoib_debugfs"
+  CONFIG_INFINIBAND_IPOIB_DEBUG also enables files in the debugfs
   virtual filesystem.  By mounting this filesystem, for example with
 
-    mkdir -p /ipoib_debugfs
-    mount -t ipoib_debugfs none /ipoib_debufs
+    mount -t debugfs none /sys/kernel/debug
 
-  it is possible to get statistics about multicast groups from the
-  files /ipoib_debugfs/ib0_mcg and so on.
+  it is possible to get statistics about munlticast groups from the
+  files /sys/kernel/debug/ipoib/ib0_mcg and so on.
 
   The performance impact of this option is negligible, so it
   is safe to enable this option with debug_level set to 0 for normal

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2005-04-01 17:53 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-04-01  3:36 [PATCH][1/3] IPoIB: set skb->mac.raw on receive Roland Dreier
2005-04-01  3:36 ` [PATCH][2/3] IPoIB: fix static rate calculation Roland Dreier
2005-04-01  3:36   ` [PATCH][3/3] IPoIB: convert to debugfs Roland Dreier
2005-04-01 17:45     ` [PATCH][4/3] IPoIB: document conversion " Roland Dreier
2005-04-01  4:18 ` [PATCH][1/3] IPoIB: set skb->mac.raw on receive David S. Miller
2005-04-01  4:24   ` Roland Dreier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox