netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: James Morris <jmorris@intercode.com.au>
Cc: Chad Tindel <ctindel@users.sourceforge.net>,
	Jay Vosburgh <fubar@us.ibm.com>,
	"David S. Miller" <davem@redhat.com>,
	Jeff Garzik <jgarzik@pobox.com>,
	<bonding-devel@lists.sourceforge.net>, <netdev@oss.sgi.com>
Subject: [PATCH] change /proc/bond0/info to /proc/bonding/bond0
Date: Fri, 22 Aug 2003 13:03:17 -0700	[thread overview]
Message-ID: <20030822130317.06d130d9.shemminger@osdl.org> (raw)
In-Reply-To: <Mutt.LNX.4.44.0308221016320.993-100000@excalibur.intercode.com.au>

On Fri, 22 Aug 2003 10:17:07 +1000 (EST)
James Morris <jmorris@intercode.com.au> wrote:

> On Thu, 21 Aug 2003, Stephen Hemminger wrote:
> 
> > The name "/proc/net/bond0/info" is kind of unconventional, but now
> > changing that in a almost stable release would be bad.  Better choice
> > would be "/proc/net/bonding/bond0".
> 
> I'm not sure it's too late to do this.

Changes the name of the /proc entry on 2.6.0-test3 with my earlier
patch.  Also, documentation and comments are updated.

This version will work if the /proc creation fails; a warning is printed
but see no reason to prevent module from loading.

diff -Nru a/Documentation/networking/bonding.txt b/Documentation/networking/bonding.txt
--- a/Documentation/networking/bonding.txt	Fri Aug 22 13:00:24 2003
+++ b/Documentation/networking/bonding.txt	Fri Aug 22 13:00:24 2003
@@ -529,7 +529,7 @@
 ----------------------------
 The bonding driver information files reside in the /proc/net/bond* directories.
 
-Sample contents of /proc/net/bond0/info after the driver is loaded with 
+Sample contents of /proc/net/bonding/bond0 after the driver is loaded with 
 parameters of mode=0 and miimon=1000 is shown below.
  
         Bonding Mode: load balancing (round-robin)
diff -Nru a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
--- a/drivers/net/bonding/bond_main.c	Fri Aug 22 13:00:24 2003
+++ b/drivers/net/bonding/bond_main.c	Fri Aug 22 13:00:24 2003
@@ -119,7 +119,7 @@
  *
  * 2001/6/01 - Chad N. Tindel <ctindel at ieee dot org>
  *     - Added /proc support for getting bond and slave information.
- *       Information is in /proc/net/<bond device>/info. 
+ *       Information is in /proc/net/bonding/<bond device>
  *     - Changed the locking when calling bond_close to prevent deadlock.
  *
  * 2001/8/05 - Janice Girouard <girouard at us.ibm.com>
@@ -501,6 +501,7 @@
 };
 
 static LIST_HEAD(bond_dev_list);
+static struct proc_dir_entry *bond_proc_dir;
 
 MODULE_PARM(max_bonds, "i");
 MODULE_PARM_DESC(max_bonds, "Max number of bonded devices");
@@ -3607,27 +3608,21 @@
 	}
 
 #ifdef CONFIG_PROC_FS
-	bond->bond_proc_dir = proc_mkdir(dev->name, proc_net);
-	if (bond->bond_proc_dir == NULL) {
-		printk(KERN_ERR "%s: Cannot init /proc/net/%s/\n", 
-			dev->name, dev->name);
-		return -ENOMEM;
-	}
-	bond->bond_proc_dir->owner = THIS_MODULE;
-
-	bond->bond_proc_info_file = 
-		create_proc_entry("info", 0, bond->bond_proc_dir);
-	if (bond->bond_proc_info_file == NULL) {
-		printk(KERN_ERR "%s: Cannot init /proc/net/%s/info\n", 
-			dev->name, dev->name);
-		remove_proc_entry(dev->name, proc_net);
-		return -ENOMEM;
+	if (bond_proc_dir) {
+		bond->bond_proc_file = create_proc_entry(dev->name,
+							 S_IRUGO, 
+							 bond_proc_dir);
+		if (bond->bond_proc_file == NULL) {
+			printk(KERN_WARNING "%s: Cannot create "
+			       "/proc/net/bonding/%s\n", 
+			       dev->name, dev->name);
+		} else {
+			bond->bond_proc_file->data = bond;
+			bond->bond_proc_file->proc_fops = &bond_info_fops;
+		}
 	}
-	bond->bond_proc_info_file->data = bond;
-	bond->bond_proc_info_file->proc_fops = &bond_info_fops;
 #endif /* CONFIG_PROC_FS */
 
-
 	list_add_tail(&bond->bond_list, &bond_dev_list);
 	return 0;
 }
@@ -3908,6 +3903,15 @@
 
 	register_netdevice_notifier(&bond_netdev_notifier);
 
+#ifdef CONFIG_PROC_FS
+	bond_proc_dir = proc_mkdir("bonding", proc_net);
+	if (bond_proc_dir == NULL) 
+		printk(KERN_WARNING "bonding_init(): can not create "
+		       "/proc/net/bonding");
+	else 
+		bond_proc_dir->owner = THIS_MODULE;
+#endif
+
 	for (no = 0; no < max_bonds; no++) {
 		struct net_device *dev;
 		char name[IFNAMSIZ];
@@ -3943,13 +3947,15 @@
 		 
 	list_for_each_entry_safe(bond, nxt, &bond_dev_list, bond_list) {
 		struct net_device *dev = bond->device;
-#ifdef CONFIG_PROC_FS
-		remove_proc_entry("info", bond->bond_proc_dir);
-		remove_proc_entry(dev->name, proc_net);
-#endif
+
+		if (bond_proc_dir)
+			remove_proc_entry(dev->name, bond_proc_dir);
 		unregister_netdev(dev);
 		free_netdev(dev);
 	}
+
+	if (bond_proc_dir)
+		remove_proc_entry("bonding", proc_net);
 }
 
 module_init(bonding_init);
diff -Nru a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
--- a/drivers/net/bonding/bonding.h	Fri Aug 22 13:00:24 2003
+++ b/drivers/net/bonding/bonding.h	Fri Aug 22 13:00:24 2003
@@ -101,8 +101,7 @@
 	struct timer_list arp_timer;
 	struct net_device_stats *stats;
 #ifdef CONFIG_PROC_FS
-	struct proc_dir_entry *bond_proc_dir;
-	struct proc_dir_entry *bond_proc_info_file;
+	struct proc_dir_entry *bond_proc_file;
 #endif /* CONFIG_PROC_FS */
 	struct list_head bond_list;
 	struct net_device *device;

      parent reply	other threads:[~2003-08-22 20:03 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-21 23:52 [PATCH] convering bonding driver /proc interface to seq_file Stephen Hemminger
2003-08-22  0:17 ` James Morris
2003-08-22  0:27   ` Chad N. Tindel
2003-08-22 20:03   ` Stephen Hemminger [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030822130317.06d130d9.shemminger@osdl.org \
    --to=shemminger@osdl.org \
    --cc=bonding-devel@lists.sourceforge.net \
    --cc=ctindel@users.sourceforge.net \
    --cc=davem@redhat.com \
    --cc=fubar@us.ibm.com \
    --cc=jgarzik@pobox.com \
    --cc=jmorris@intercode.com.au \
    --cc=netdev@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).