From: Amir Noam <amir.noam@intel.com>
To: bonding-devel@lists.sourceforge.net, netdev@oss.sgi.com
Subject: [PATCH 7/10] [bonding 2.6] Consolidate /proc code, add CHANGENAME handler
Date: Thu, 11 Sep 2003 17:41:49 +0300 [thread overview]
Message-ID: <200309111741.49076.amir.noam@intel.com> (raw)
diff -Nuarp a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
--- a/drivers/net/bonding/bond_main.c Thu Sep 11 16:48:33 2003
+++ b/drivers/net/bonding/bond_main.c Thu Sep 11 16:48:34 2003
@@ -3466,6 +3466,45 @@ static int bond_read_proc(char *buf, cha
#endif /* CONFIG_PROC_FS */
+static int bond_create_proc_info(struct bonding *bond)
+{
+#ifdef CONFIG_PROC_FS
+ struct net_device *dev = bond->device;
+
+ 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_read_entry("info", 0, bond->bond_proc_dir,
+ bond_read_proc, bond);
+ 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;
+ }
+ bond->bond_proc_info_file->owner = THIS_MODULE;
+
+ memcpy(bond->procdir_name, dev->name, IFNAMSIZ);
+#endif /* CONFIG_PROC_FS */
+ return 0;
+}
+
+static void bond_destroy_proc_info(struct bonding *bond)
+{
+#ifdef CONFIG_PROC_FS
+ remove_proc_entry("info", bond->bond_proc_dir);
+ remove_proc_entry(bond->procdir_name, proc_net);
+ memset(bond->procdir_name, 0, IFNAMSIZ);
+ bond->bond_proc_dir = NULL;
+#endif /* CONFIG_PROC_FS */
+}
+
/*
* Change HW address
*
@@ -3614,10 +3653,7 @@ static void bond_deinit(struct net_devic
list_del(&bond->bond_list);
-#ifdef CONFIG_PROC_FS
- remove_proc_entry("info", bond->bond_proc_dir);
- remove_proc_entry(dev->name, proc_net);
-#endif
+ bond_destroy_proc_info(bond);
}
static void bond_free_all(void)
@@ -3633,10 +3669,15 @@ static void bond_free_all(void)
}
}
+/*
+ * Does not allocate but creates a /proc entry.
+ * Allowed to fail.
+ */
static int __init bond_init(struct net_device *dev)
{
struct bonding *bond;
int count;
+ int err = 0;
#ifdef BONDING_DEBUG
printk (KERN_INFO "Begin bond_init for %s\n", dev->name);
@@ -3715,30 +3756,26 @@ static int __init bond_init(struct net_d
printk("out ARP monitoring\n");
}
-#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;
+ err = bond_create_proc_info(bond);
+ if (err) {
+ printk(KERN_ERR "%s: Failed to create proc entry\n",
+ dev->name);
+ return err;
}
- bond->bond_proc_dir->owner = THIS_MODULE;
- bond->bond_proc_info_file =
- create_proc_read_entry("info", 0, bond->bond_proc_dir,
- bond_read_proc, bond);
- 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;
- }
- bond->bond_proc_info_file->owner = THIS_MODULE;
-#endif /* CONFIG_PROC_FS */
+ /* Future:
+ * If anything fails beyond this point
+ * make sure to destroy the proc entry
+ */
list_add_tail(&bond->bond_list, &bond_dev_list);
return 0;
+/*
+err_out:
+ bond_destroy_proc_info(bond);
+ return err;
+*/
}
/*
diff -Nuarp a/drivers/net/bonding/bonding.h b/drivers/net/bonding/bonding.h
--- a/drivers/net/bonding/bonding.h Thu Sep 11 16:48:33 2003
+++ b/drivers/net/bonding/bonding.h Thu Sep 11 16:48:34 2003
@@ -103,6 +103,7 @@ typedef struct bonding {
#ifdef CONFIG_PROC_FS
struct proc_dir_entry *bond_proc_dir;
struct proc_dir_entry *bond_proc_info_file;
+ char procdir_name[IFNAMSIZ];
#endif /* CONFIG_PROC_FS */
struct list_head bond_list;
struct net_device *device;
reply other threads:[~2003-09-11 14:41 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=200309111741.49076.amir.noam@intel.com \
--to=amir.noam@intel.com \
--cc=bonding-devel@lists.sourceforge.net \
--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).