* [PATCH 4/6] sysfs: Add support for tagged directories with untagged members.
From: Eric W. Biederman @ 2010-03-30 18:31 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Kay Sievers, linux-kernel, Tejun Heo, Cornelia Huck,
linux-fsdevel, Eric Dumazet, Benjamin LaHaise, Serge Hallyn,
netdev, Eric W. Biederman, Eric W. Biederman
In-Reply-To: <m1fx3hk6gw.fsf@fess.ebiederm.org>
From: Eric W. Biederman <ebiederm@maxwell.aristanetworks.com>
I had hopped to avoid this but the bonding driver adds a file
to /sys/class/net/ and the easiest way to handle that file is
to make it untagged and to register it only once.
So relax the rules on tagged directories, and make bonding work.
Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
---
fs/sysfs/dir.c | 12 +++---------
fs/sysfs/inode.c | 2 ++
2 files changed, 5 insertions(+), 9 deletions(-)
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index b0e7911..d3dd097 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -383,12 +383,6 @@ int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
if (sysfs_find_dirent(acxt->parent_sd, sd->s_ns, sd->s_name))
return -EEXIST;
- if (sysfs_ns_type(acxt->parent_sd) && !sd->s_ns) {
- WARN(1, KERN_WARNING "sysfs: ns required in '%s' for '%s'\n",
- acxt->parent_sd->s_name, sd->s_name);
- return -EINVAL;
- }
-
sd->s_parent = sysfs_get(acxt->parent_sd);
sysfs_link_sibling(sd);
@@ -545,7 +539,7 @@ struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd,
struct sysfs_dirent *sd;
for (sd = parent_sd->s_dir.children; sd; sd = sd->s_sibling) {
- if (sd->s_ns != ns)
+ if (ns && sd->s_ns && (sd->s_ns != ns))
continue;
if (!strcmp(sd->s_name, name))
return sd;
@@ -879,7 +873,7 @@ static struct sysfs_dirent *sysfs_dir_pos(const void *ns,
while (pos && (ino > pos->s_ino))
pos = pos->s_sibling;
}
- while (pos && pos->s_ns != ns)
+ while (pos && pos->s_ns && pos->s_ns != ns)
pos = pos->s_sibling;
return pos;
}
@@ -890,7 +884,7 @@ static struct sysfs_dirent *sysfs_dir_next_pos(const void *ns,
pos = sysfs_dir_pos(ns, parent_sd, ino, pos);
if (pos)
pos = pos->s_sibling;
- while (pos && pos->s_ns != ns)
+ while (pos && pos->s_ns && pos->s_ns != ns)
pos = pos->s_sibling;
return pos;
}
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 90a899e..6c962ca 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -334,6 +334,8 @@ int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const void *ns, const cha
sysfs_addrm_start(&acxt, dir_sd);
sd = sysfs_find_dirent(dir_sd, ns, name);
+ if (sd && (sd->s_ns != ns))
+ sd = NULL;
if (sd)
sysfs_remove_one(&acxt, sd);
--
1.6.5.2.143.g8cc62
^ permalink raw reply related
* [PATCH 3/6] sysfs: Implement sysfs tagged directory support.
From: Eric W. Biederman @ 2010-03-30 18:31 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Kay Sievers, linux-kernel, Tejun Heo, Cornelia Huck,
linux-fsdevel, Eric Dumazet, Benjamin LaHaise, Serge Hallyn,
netdev, Eric W. Biederman, Benjamin Thery
In-Reply-To: <m1fx3hk6gw.fsf@fess.ebiederm.org>
From: Eric W. Biederman <ebiederm@xmission.com>
The problem. When implementing a network namespace I need to be able
to have multiple network devices with the same name. Currently this
is a problem for /sys/class/net/*, /sys/devices/virtual/net/*, and
potentially a few other directories of the form /sys/ ... /net/*.
What this patch does is to add an additional tag field to the
sysfs dirent structure. For directories that should show different
contents depending on the context such as /sys/class/net/, and
/sys/devices/virtual/net/ this tag field is used to specify the
context in which those directories should be visible. Effectively
this is the same as creating multiple distinct directories with
the same name but internally to sysfs the result is nicer.
I am calling the concept of a single directory that looks like multiple
directories all at the same path in the filesystem tagged directories.
For the networking namespace the set of directories whose contents I need
to filter with tags can depend on the presence or absence of hotplug
hardware or which modules are currently loaded. Which means I need
a simple race free way to setup those directories as tagged.
To achieve a reace free design all tagged directories are created
and managed by sysfs itself.
Users of this interface:
- define a type in the sysfs_tag_type enumeration.
- call sysfs_register_ns_types with the type and it's operations
- sysfs_exit_ns when an individual tag is no longer valid
- Implement mount_ns() which returns the ns of the calling process
so we can attach it to a sysfs superblock.
- Implement ktype.namespace() which returns the ns of a syfs kobject.
Everything else is left up to sysfs and the driver layer.
For the network namespace mount_ns and namespace() are essentially
one line functions, and look to remain that.
Tags are currently represented a const void * pointers as that is
both generic, prevides enough information for equality comparisons,
and is trivial to create for current users, as it is just the
existing namespace pointer.
The work needed in sysfs is more extensive. At each directory
or symlink creating I need to check if the directory it is being
created in is a tagged directory and if so generate the appropriate
tag to place on the sysfs_dirent. Likewise at each symlink or
directory removal I need to check if the sysfs directory it is
being removed from is a tagged directory and if so figure out
which tag goes along with the name I am deleting.
Currently only directories which hold kobjects, and
symlinks are supported. There is not enough information
in the current file attribute interfaces to give us anything
to discriminate on which makes it useless, and there are
no potential users which makes it an uninteresting problem
to solve.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Benjamin Thery <benjamin.thery@bull.net>
---
drivers/gpio/gpiolib.c | 2 +-
drivers/md/bitmap.c | 4 +-
drivers/md/md.c | 6 +-
fs/sysfs/bin.c | 2 +-
fs/sysfs/dir.c | 112 +++++++++++++++++++++++++++++++++++++----------
fs/sysfs/file.c | 17 ++++---
fs/sysfs/group.c | 6 +-
fs/sysfs/inode.c | 4 +-
fs/sysfs/mount.c | 33 ++++++++++++++-
fs/sysfs/symlink.c | 15 +++++-
fs/sysfs/sysfs.h | 20 +++++++--
include/linux/sysfs.h | 10 ++++
lib/kobject.c | 1 +
13 files changed, 181 insertions(+), 51 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 6d1b866..6c388db 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -398,7 +398,7 @@ static int gpio_setup_irq(struct gpio_desc *desc, struct device *dev,
goto free_id;
}
- pdesc->value_sd = sysfs_get_dirent(dev->kobj.sd, "value");
+ pdesc->value_sd = sysfs_get_dirent(dev->kobj.sd, NULL, "value");
if (!pdesc->value_sd) {
ret = -ENODEV;
goto free_id;
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 26ac8aa..f084249 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1678,9 +1678,9 @@ int bitmap_create(mddev_t *mddev)
bitmap->mddev = mddev;
- bm = sysfs_get_dirent(mddev->kobj.sd, "bitmap");
+ bm = sysfs_get_dirent(mddev->kobj.sd, NULL, "bitmap");
if (bm) {
- bitmap->sysfs_can_clear = sysfs_get_dirent(bm, "can_clear");
+ bitmap->sysfs_can_clear = sysfs_get_dirent(bm, NULL, "can_clear");
sysfs_put(bm);
} else
bitmap->sysfs_can_clear = NULL;
diff --git a/drivers/md/md.c b/drivers/md/md.c
index fdc1890..ed6ca8c 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -1765,7 +1765,7 @@ static int bind_rdev_to_array(mdk_rdev_t * rdev, mddev_t * mddev)
kobject_del(&rdev->kobj);
goto fail;
}
- rdev->sysfs_state = sysfs_get_dirent(rdev->kobj.sd, "state");
+ rdev->sysfs_state = sysfs_get_dirent(rdev->kobj.sd, NULL, "state");
list_add_rcu(&rdev->same_set, &mddev->disks);
bd_claim_by_disk(rdev->bdev, rdev->bdev->bd_holder, mddev->gendisk);
@@ -4182,7 +4182,7 @@ static int md_alloc(dev_t dev, char *name)
mutex_unlock(&disks_mutex);
if (!error) {
kobject_uevent(&mddev->kobj, KOBJ_ADD);
- mddev->sysfs_state = sysfs_get_dirent(mddev->kobj.sd, "array_state");
+ mddev->sysfs_state = sysfs_get_dirent(mddev->kobj.sd, NULL, "array_state");
}
mddev_put(mddev);
return error;
@@ -4391,7 +4391,7 @@ static int do_md_run(mddev_t * mddev)
printk(KERN_WARNING
"md: cannot register extra attributes for %s\n",
mdname(mddev));
- mddev->sysfs_action = sysfs_get_dirent(mddev->kobj.sd, "sync_action");
+ mddev->sysfs_action = sysfs_get_dirent(mddev->kobj.sd, NULL, "sync_action");
} else if (mddev->ro == 2) /* auto-readonly not meaningful */
mddev->ro = 0;
diff --git a/fs/sysfs/bin.c b/fs/sysfs/bin.c
index e9d2935..806b277 100644
--- a/fs/sysfs/bin.c
+++ b/fs/sysfs/bin.c
@@ -501,7 +501,7 @@ int sysfs_create_bin_file(struct kobject *kobj,
void sysfs_remove_bin_file(struct kobject *kobj,
const struct bin_attribute *attr)
{
- sysfs_hash_and_remove(kobj->sd, attr->attr.name);
+ sysfs_hash_and_remove(kobj->sd, NULL, attr->attr.name);
}
EXPORT_SYMBOL_GPL(sysfs_create_bin_file);
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index 5907178..b0e7911 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -380,9 +380,15 @@ int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd)
{
struct sysfs_inode_attrs *ps_iattr;
- if (sysfs_find_dirent(acxt->parent_sd, sd->s_name))
+ if (sysfs_find_dirent(acxt->parent_sd, sd->s_ns, sd->s_name))
return -EEXIST;
+ if (sysfs_ns_type(acxt->parent_sd) && !sd->s_ns) {
+ WARN(1, KERN_WARNING "sysfs: ns required in '%s' for '%s'\n",
+ acxt->parent_sd->s_name, sd->s_name);
+ return -EINVAL;
+ }
+
sd->s_parent = sysfs_get(acxt->parent_sd);
sysfs_link_sibling(sd);
@@ -533,13 +539,17 @@ void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt)
* Pointer to sysfs_dirent if found, NULL if not.
*/
struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd,
+ const void *ns,
const unsigned char *name)
{
struct sysfs_dirent *sd;
- for (sd = parent_sd->s_dir.children; sd; sd = sd->s_sibling)
+ for (sd = parent_sd->s_dir.children; sd; sd = sd->s_sibling) {
+ if (sd->s_ns != ns)
+ continue;
if (!strcmp(sd->s_name, name))
return sd;
+ }
return NULL;
}
@@ -558,12 +568,13 @@ struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd,
* Pointer to sysfs_dirent if found, NULL if not.
*/
struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
+ const void *ns,
const unsigned char *name)
{
struct sysfs_dirent *sd;
mutex_lock(&sysfs_mutex);
- sd = sysfs_find_dirent(parent_sd, name);
+ sd = sysfs_find_dirent(parent_sd, ns, name);
sysfs_get(sd);
mutex_unlock(&sysfs_mutex);
@@ -572,7 +583,8 @@ struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
EXPORT_SYMBOL_GPL(sysfs_get_dirent);
static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
- const char *name, struct sysfs_dirent **p_sd)
+ enum kobj_ns_type type, const void *ns, const char *name,
+ struct sysfs_dirent **p_sd)
{
umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO;
struct sysfs_addrm_cxt acxt;
@@ -583,6 +595,9 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
sd = sysfs_new_dirent(name, mode, SYSFS_DIR);
if (!sd)
return -ENOMEM;
+
+ sd->s_flags |= (type << SYSFS_NS_TYPE_SHIFT);
+ sd->s_ns = ns;
sd->s_dir.kobj = kobj;
/* link in */
@@ -601,7 +616,25 @@ static int create_dir(struct kobject *kobj, struct sysfs_dirent *parent_sd,
int sysfs_create_subdir(struct kobject *kobj, const char *name,
struct sysfs_dirent **p_sd)
{
- return create_dir(kobj, kobj->sd, name, p_sd);
+ return create_dir(kobj, kobj->sd,
+ KOBJ_NS_TYPE_NONE, NULL, name, p_sd);
+}
+
+static enum kobj_ns_type sysfs_read_ns_type(struct kobject *kobj)
+{
+ const struct kobj_ns_type_operations *ops;
+ enum kobj_ns_type type;
+
+ ops = kobj_child_ns_ops(kobj);
+ if (!ops)
+ return KOBJ_NS_TYPE_NONE;
+
+ type = ops->type;
+ BUG_ON(type <= KOBJ_NS_TYPE_NONE);
+ BUG_ON(type >= KOBJ_NS_TYPES);
+ BUG_ON(!kobj_ns_type_registered(type));
+
+ return type;
}
/**
@@ -610,7 +643,9 @@ int sysfs_create_subdir(struct kobject *kobj, const char *name,
*/
int sysfs_create_dir(struct kobject * kobj)
{
+ enum kobj_ns_type type;
struct sysfs_dirent *parent_sd, *sd;
+ const void *ns = NULL;
int error = 0;
BUG_ON(!kobj);
@@ -620,7 +655,11 @@ int sysfs_create_dir(struct kobject * kobj)
else
parent_sd = &sysfs_root;
- error = create_dir(kobj, parent_sd, kobject_name(kobj), &sd);
+ if (sysfs_ns_type(parent_sd))
+ ns = kobj->ktype->namespace(kobj);
+ type = sysfs_read_ns_type(kobj);
+
+ error = create_dir(kobj, parent_sd, type, ns, kobject_name(kobj), &sd);
if (!error)
kobj->sd = sd;
return error;
@@ -630,13 +669,19 @@ static struct dentry * sysfs_lookup(struct inode *dir, struct dentry *dentry,
struct nameidata *nd)
{
struct dentry *ret = NULL;
- struct sysfs_dirent *parent_sd = dentry->d_parent->d_fsdata;
+ struct dentry *parent = dentry->d_parent;
+ struct sysfs_dirent *parent_sd = parent->d_fsdata;
struct sysfs_dirent *sd;
struct inode *inode;
+ enum kobj_ns_type type;
+ const void *ns;
mutex_lock(&sysfs_mutex);
- sd = sysfs_find_dirent(parent_sd, dentry->d_name.name);
+ type = sysfs_ns_type(parent_sd);
+ ns = sysfs_info(dir->i_sb)->ns[type];
+
+ sd = sysfs_find_dirent(parent_sd, ns, dentry->d_name.name);
/* no such entry */
if (!sd) {
@@ -735,7 +780,8 @@ void sysfs_remove_dir(struct kobject * kobj)
}
int sysfs_rename(struct sysfs_dirent *sd,
- struct sysfs_dirent *new_parent_sd, const char *new_name)
+ struct sysfs_dirent *new_parent_sd, const void *new_ns,
+ const char *new_name)
{
const char *dup_name = NULL;
int error;
@@ -743,12 +789,12 @@ int sysfs_rename(struct sysfs_dirent *sd,
mutex_lock(&sysfs_mutex);
error = 0;
- if ((sd->s_parent == new_parent_sd) &&
+ if ((sd->s_parent == new_parent_sd) && (sd->s_ns == new_ns) &&
(strcmp(sd->s_name, new_name) == 0))
goto out; /* nothing to rename */
error = -EEXIST;
- if (sysfs_find_dirent(new_parent_sd, new_name))
+ if (sysfs_find_dirent(new_parent_sd, new_ns, new_name))
goto out;
/* rename sysfs_dirent */
@@ -770,6 +816,7 @@ int sysfs_rename(struct sysfs_dirent *sd,
sd->s_parent = new_parent_sd;
sysfs_link_sibling(sd);
}
+ sd->s_ns = new_ns;
error = 0;
out:
@@ -780,19 +827,28 @@ int sysfs_rename(struct sysfs_dirent *sd,
int sysfs_rename_dir(struct kobject *kobj, const char *new_name)
{
- return sysfs_rename(kobj->sd, kobj->sd->s_parent, new_name);
+ struct sysfs_dirent *parent_sd = kobj->sd->s_parent;
+ const void *new_ns = NULL;
+
+ if (sysfs_ns_type(parent_sd))
+ new_ns = kobj->ktype->namespace(kobj);
+
+ return sysfs_rename(kobj->sd, parent_sd, new_ns, new_name);
}
int sysfs_move_dir(struct kobject *kobj, struct kobject *new_parent_kobj)
{
struct sysfs_dirent *sd = kobj->sd;
struct sysfs_dirent *new_parent_sd;
+ const void *new_ns = NULL;
BUG_ON(!sd->s_parent);
+ if (sysfs_ns_type(sd->s_parent))
+ new_ns = kobj->ktype->namespace(kobj);
new_parent_sd = new_parent_kobj && new_parent_kobj->sd ?
new_parent_kobj->sd : &sysfs_root;
- return sysfs_rename(sd, new_parent_sd, sd->s_name);
+ return sysfs_rename(sd, new_parent_sd, new_ns, sd->s_name);
}
/* Relationship between s_mode and the DT_xxx types */
@@ -807,32 +863,35 @@ static int sysfs_dir_release(struct inode *inode, struct file *filp)
return 0;
}
-static struct sysfs_dirent *sysfs_dir_pos(struct sysfs_dirent *parent_sd,
- ino_t ino, struct sysfs_dirent *pos)
+static struct sysfs_dirent *sysfs_dir_pos(const void *ns,
+ struct sysfs_dirent *parent_sd, ino_t ino, struct sysfs_dirent *pos)
{
if (pos) {
int valid = !(pos->s_flags & SYSFS_FLAG_REMOVED) &&
pos->s_parent == parent_sd &&
ino == pos->s_ino;
sysfs_put(pos);
- if (valid)
- return pos;
+ if (!valid)
+ pos = NULL;
}
- pos = NULL;
- if ((ino > 1) && (ino < INT_MAX)) {
+ if (!pos && (ino > 1) && (ino < INT_MAX)) {
pos = parent_sd->s_dir.children;
while (pos && (ino > pos->s_ino))
pos = pos->s_sibling;
}
+ while (pos && pos->s_ns != ns)
+ pos = pos->s_sibling;
return pos;
}
-static struct sysfs_dirent *sysfs_dir_next_pos(struct sysfs_dirent *parent_sd,
- ino_t ino, struct sysfs_dirent *pos)
+static struct sysfs_dirent *sysfs_dir_next_pos(const void *ns,
+ struct sysfs_dirent *parent_sd, ino_t ino, struct sysfs_dirent *pos)
{
- pos = sysfs_dir_pos(parent_sd, ino, pos);
+ pos = sysfs_dir_pos(ns, parent_sd, ino, pos);
if (pos)
pos = pos->s_sibling;
+ while (pos && pos->s_ns != ns)
+ pos = pos->s_sibling;
return pos;
}
@@ -841,8 +900,13 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
struct dentry *dentry = filp->f_path.dentry;
struct sysfs_dirent * parent_sd = dentry->d_fsdata;
struct sysfs_dirent *pos = filp->private_data;
+ enum kobj_ns_type type;
+ const void *ns;
ino_t ino;
+ type = sysfs_ns_type(parent_sd);
+ ns = sysfs_info(dentry->d_sb)->ns[type];
+
if (filp->f_pos == 0) {
ino = parent_sd->s_ino;
if (filldir(dirent, ".", 1, filp->f_pos, ino, DT_DIR) == 0)
@@ -857,9 +921,9 @@ static int sysfs_readdir(struct file * filp, void * dirent, filldir_t filldir)
filp->f_pos++;
}
mutex_lock(&sysfs_mutex);
- for (pos = sysfs_dir_pos(parent_sd, filp->f_pos, pos);
+ for (pos = sysfs_dir_pos(ns, parent_sd, filp->f_pos, pos);
pos;
- pos = sysfs_dir_next_pos(parent_sd, filp->f_pos, pos)) {
+ pos = sysfs_dir_next_pos(ns, parent_sd, filp->f_pos, pos)) {
const char * name;
unsigned int type;
int len, ret;
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
index e222b25..1beaa73 100644
--- a/fs/sysfs/file.c
+++ b/fs/sysfs/file.c
@@ -478,9 +478,12 @@ void sysfs_notify(struct kobject *k, const char *dir, const char *attr)
mutex_lock(&sysfs_mutex);
if (sd && dir)
- sd = sysfs_find_dirent(sd, dir);
+ /* Only directories are tagged, so no need to pass
+ * a tag explicitly.
+ */
+ sd = sysfs_find_dirent(sd, NULL, dir);
if (sd && attr)
- sd = sysfs_find_dirent(sd, attr);
+ sd = sysfs_find_dirent(sd, NULL, attr);
if (sd)
sysfs_notify_dirent(sd);
@@ -569,7 +572,7 @@ int sysfs_add_file_to_group(struct kobject *kobj,
int error;
if (group)
- dir_sd = sysfs_get_dirent(kobj->sd, group);
+ dir_sd = sysfs_get_dirent(kobj->sd, NULL, group);
else
dir_sd = sysfs_get(kobj->sd);
@@ -599,7 +602,7 @@ int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode)
mutex_lock(&sysfs_mutex);
rc = -ENOENT;
- sd = sysfs_find_dirent(kobj->sd, attr->name);
+ sd = sysfs_find_dirent(kobj->sd, NULL, attr->name);
if (!sd)
goto out;
@@ -624,7 +627,7 @@ EXPORT_SYMBOL_GPL(sysfs_chmod_file);
void sysfs_remove_file(struct kobject * kobj, const struct attribute * attr)
{
- sysfs_hash_and_remove(kobj->sd, attr->name);
+ sysfs_hash_and_remove(kobj->sd, NULL, attr->name);
}
void sysfs_remove_files(struct kobject * kobj, const struct attribute **ptr)
@@ -646,11 +649,11 @@ void sysfs_remove_file_from_group(struct kobject *kobj,
struct sysfs_dirent *dir_sd;
if (group)
- dir_sd = sysfs_get_dirent(kobj->sd, group);
+ dir_sd = sysfs_get_dirent(kobj->sd, NULL, group);
else
dir_sd = sysfs_get(kobj->sd);
if (dir_sd) {
- sysfs_hash_and_remove(dir_sd, attr->name);
+ sysfs_hash_and_remove(dir_sd, NULL, attr->name);
sysfs_put(dir_sd);
}
}
diff --git a/fs/sysfs/group.c b/fs/sysfs/group.c
index fe61194..23c1e59 100644
--- a/fs/sysfs/group.c
+++ b/fs/sysfs/group.c
@@ -23,7 +23,7 @@ static void remove_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
int i;
for (i = 0, attr = grp->attrs; *attr; i++, attr++)
- sysfs_hash_and_remove(dir_sd, (*attr)->name);
+ sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name);
}
static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
@@ -39,7 +39,7 @@ static int create_files(struct sysfs_dirent *dir_sd, struct kobject *kobj,
* visibility. Do this by first removing then
* re-adding (if required) the file */
if (update)
- sysfs_hash_and_remove(dir_sd, (*attr)->name);
+ sysfs_hash_and_remove(dir_sd, NULL, (*attr)->name);
if (grp->is_visible) {
mode = grp->is_visible(kobj, *attr, i);
if (!mode)
@@ -132,7 +132,7 @@ void sysfs_remove_group(struct kobject * kobj,
struct sysfs_dirent *sd;
if (grp->name) {
- sd = sysfs_get_dirent(dir_sd, grp->name);
+ sd = sysfs_get_dirent(dir_sd, NULL, grp->name);
if (!sd) {
WARN(!sd, KERN_WARNING "sysfs group %p not found for "
"kobject '%s'\n", grp, kobject_name(kobj));
diff --git a/fs/sysfs/inode.c b/fs/sysfs/inode.c
index 082daae..90a899e 100644
--- a/fs/sysfs/inode.c
+++ b/fs/sysfs/inode.c
@@ -323,7 +323,7 @@ void sysfs_delete_inode(struct inode *inode)
sysfs_put(sd);
}
-int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name)
+int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const void *ns, const char *name)
{
struct sysfs_addrm_cxt acxt;
struct sysfs_dirent *sd;
@@ -333,7 +333,7 @@ int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name)
sysfs_addrm_start(&acxt, dir_sd);
- sd = sysfs_find_dirent(dir_sd, name);
+ sd = sysfs_find_dirent(dir_sd, ns, name);
if (sd)
sysfs_remove_one(&acxt, sd);
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 6a433ac..c722471 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -34,7 +34,7 @@ static const struct super_operations sysfs_ops = {
struct sysfs_dirent sysfs_root = {
.s_name = "",
.s_count = ATOMIC_INIT(1),
- .s_flags = SYSFS_DIR,
+ .s_flags = SYSFS_DIR | (KOBJ_NS_TYPE_NONE << SYSFS_NS_TYPE_SHIFT),
.s_mode = S_IFDIR | S_IRWXU | S_IRUGO | S_IXUGO,
.s_ino = 1,
};
@@ -75,7 +75,13 @@ static int sysfs_test_super(struct super_block *sb, void *data)
{
struct sysfs_super_info *sb_info = sysfs_info(sb);
struct sysfs_super_info *info = data;
+ enum kobj_ns_type type;
int found = 1;
+
+ for (type = KOBJ_NS_TYPE_NONE; type < KOBJ_NS_TYPES; type++) {
+ if (sb_info->ns[type] != info->ns[type])
+ found = 0;
+ }
return found;
}
@@ -92,6 +98,7 @@ static int sysfs_get_sb(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data, struct vfsmount *mnt)
{
struct sysfs_super_info *info;
+ enum kobj_ns_type type;
struct super_block *sb;
int error;
@@ -99,6 +106,10 @@ static int sysfs_get_sb(struct file_system_type *fs_type,
info = kzalloc(sizeof(*info), GFP_KERNEL);
if (!info)
goto out;
+
+ for (type = KOBJ_NS_TYPE_NONE; type < KOBJ_NS_TYPES; type++)
+ info->ns[type] = kobj_ns_current(type);
+
sb = sget(fs_type, sysfs_test_super, sysfs_set_super, info);
if (IS_ERR(sb) || sb->s_fs_info != info)
kfree(info);
@@ -137,6 +148,26 @@ static struct file_system_type sysfs_fs_type = {
.kill_sb = sysfs_kill_sb,
};
+void sysfs_exit_ns(enum kobj_ns_type type, const void *ns)
+{
+ struct super_block *sb;
+
+ mutex_lock(&sysfs_mutex);
+ spin_lock(&sb_lock);
+ list_for_each_entry(sb, &sysfs_fs_type.fs_supers, s_instances) {
+ struct sysfs_super_info *info = sysfs_info(sb);
+ /* Ignore superblocks that are in the process of unmounting */
+ if (sb->s_count <= S_BIAS)
+ continue;
+ /* Ignore superblocks with the wrong ns */
+ if (info->ns[type] != ns)
+ continue;
+ info->ns[type] = NULL;
+ }
+ spin_unlock(&sb_lock);
+ mutex_unlock(&sysfs_mutex);
+}
+
int __init sysfs_init(void)
{
int err = -ENOMEM;
diff --git a/fs/sysfs/symlink.c b/fs/sysfs/symlink.c
index 1b9a3a1..56ccdc6 100644
--- a/fs/sysfs/symlink.c
+++ b/fs/sysfs/symlink.c
@@ -57,6 +57,8 @@ static int sysfs_do_create_link(struct kobject *kobj, struct kobject *target,
if (!sd)
goto out_put;
+ if (sysfs_ns_type(parent_sd))
+ sd->s_ns = target->ktype->namespace(target);
sd->s_symlink.target_sd = target_sd;
target_sd = NULL; /* reference is now owned by the symlink */
@@ -120,7 +122,7 @@ void sysfs_remove_link(struct kobject * kobj, const char * name)
else
parent_sd = kobj->sd;
- sysfs_hash_and_remove(parent_sd, name);
+ sysfs_hash_and_remove(parent_sd, NULL, name);
}
/**
@@ -136,6 +138,7 @@ int sysfs_rename_link(struct kobject *kobj, struct kobject *targ,
const char *old, const char *new)
{
struct sysfs_dirent *parent_sd, *sd = NULL;
+ const void *old_ns = NULL, *new_ns = NULL;
int result;
if (!kobj)
@@ -143,8 +146,11 @@ int sysfs_rename_link(struct kobject *kobj, struct kobject *targ,
else
parent_sd = kobj->sd;
+ if (targ->sd)
+ old_ns = targ->sd->s_ns;
+
result = -ENOENT;
- sd = sysfs_get_dirent(parent_sd, old);
+ sd = sysfs_get_dirent(parent_sd, old_ns, old);
if (!sd)
goto out;
@@ -154,7 +160,10 @@ int sysfs_rename_link(struct kobject *kobj, struct kobject *targ,
if (sd->s_symlink.target_sd->s_dir.kobj != targ)
goto out;
- result = sysfs_rename(sd, parent_sd, new);
+ if (sysfs_ns_type(parent_sd))
+ new_ns = targ->ktype->namespace(targ);
+
+ result = sysfs_rename(sd, parent_sd, new_ns, new);
out:
sysfs_put(sd);
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 030a39d..93847d5 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -58,6 +58,7 @@ struct sysfs_dirent {
struct sysfs_dirent *s_sibling;
const char *s_name;
+ const void *s_ns;
union {
struct sysfs_elem_dir s_dir;
struct sysfs_elem_symlink s_symlink;
@@ -81,14 +82,22 @@ struct sysfs_dirent {
#define SYSFS_COPY_NAME (SYSFS_DIR | SYSFS_KOBJ_LINK)
#define SYSFS_ACTIVE_REF (SYSFS_KOBJ_ATTR | SYSFS_KOBJ_BIN_ATTR)
-#define SYSFS_FLAG_MASK ~SYSFS_TYPE_MASK
-#define SYSFS_FLAG_REMOVED 0x0200
+#define SYSFS_NS_TYPE_MASK 0xff00
+#define SYSFS_NS_TYPE_SHIFT 8
+
+#define SYSFS_FLAG_MASK ~(SYSFS_NS_TYPE_MASK|SYSFS_TYPE_MASK)
+#define SYSFS_FLAG_REMOVED 0x020000
static inline unsigned int sysfs_type(struct sysfs_dirent *sd)
{
return sd->s_flags & SYSFS_TYPE_MASK;
}
+static inline enum kobj_ns_type sysfs_ns_type(struct sysfs_dirent *sd)
+{
+ return (sd->s_flags & SYSFS_NS_TYPE_MASK) >> SYSFS_NS_TYPE_SHIFT;
+}
+
#ifdef CONFIG_DEBUG_LOCK_ALLOC
#define sysfs_dirent_init_lockdep(sd) \
do { \
@@ -115,6 +124,7 @@ struct sysfs_addrm_cxt {
* mount.c
*/
struct sysfs_super_info {
+ const void *ns[KOBJ_NS_TYPES];
};
#define sysfs_info(SB) ((struct sysfs_super_info *)(SB->s_fs_info))
extern struct sysfs_dirent sysfs_root;
@@ -140,8 +150,10 @@ void sysfs_remove_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd);
void sysfs_addrm_finish(struct sysfs_addrm_cxt *acxt);
struct sysfs_dirent *sysfs_find_dirent(struct sysfs_dirent *parent_sd,
+ const void *ns,
const unsigned char *name);
struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
+ const void *ns,
const unsigned char *name);
struct sysfs_dirent *sysfs_new_dirent(const char *name, umode_t mode, int type);
@@ -152,7 +164,7 @@ int sysfs_create_subdir(struct kobject *kobj, const char *name,
void sysfs_remove_subdir(struct sysfs_dirent *sd);
int sysfs_rename(struct sysfs_dirent *sd,
- struct sysfs_dirent *new_parent_sd, const char *new_name);
+ struct sysfs_dirent *new_parent_sd, const void *ns, const char *new_name);
static inline struct sysfs_dirent *__sysfs_get(struct sysfs_dirent *sd)
{
@@ -182,7 +194,7 @@ int sysfs_setattr(struct dentry *dentry, struct iattr *iattr);
int sysfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat);
int sysfs_setxattr(struct dentry *dentry, const char *name, const void *value,
size_t size, int flags);
-int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const char *name);
+int sysfs_hash_and_remove(struct sysfs_dirent *dir_sd, const void *ns, const char *name);
int sysfs_inode_init(void);
/*
diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h
index f0496b3..1885d21 100644
--- a/include/linux/sysfs.h
+++ b/include/linux/sysfs.h
@@ -20,6 +20,7 @@
struct kobject;
struct module;
+enum kobj_ns_type;
/* FIXME
* The *owner field is no longer used.
@@ -168,10 +169,14 @@ void sysfs_remove_file_from_group(struct kobject *kobj,
void sysfs_notify(struct kobject *kobj, const char *dir, const char *attr);
void sysfs_notify_dirent(struct sysfs_dirent *sd);
struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
+ const void *ns,
const unsigned char *name);
struct sysfs_dirent *sysfs_get(struct sysfs_dirent *sd);
void sysfs_put(struct sysfs_dirent *sd);
void sysfs_printk_last_file(void);
+
+void sysfs_exit_ns(enum kobj_ns_type type, const void *tag);
+
int __must_check sysfs_init(void);
#else /* CONFIG_SYSFS */
@@ -301,6 +306,7 @@ static inline void sysfs_notify_dirent(struct sysfs_dirent *sd)
}
static inline
struct sysfs_dirent *sysfs_get_dirent(struct sysfs_dirent *parent_sd,
+ const void *ns,
const unsigned char *name)
{
return NULL;
@@ -313,6 +319,10 @@ static inline void sysfs_put(struct sysfs_dirent *sd)
{
}
+static inline void sysfs_exit_ns(enum kobj_ns_type type, const void *tag)
+{
+}
+
static inline int __must_check sysfs_init(void)
{
return 0;
diff --git a/lib/kobject.c b/lib/kobject.c
index bbb2bb4..b2c6d1f 100644
--- a/lib/kobject.c
+++ b/lib/kobject.c
@@ -950,6 +950,7 @@ const void *kobj_ns_initial(enum kobj_ns_type type)
void kobj_ns_exit(enum kobj_ns_type type, const void *ns)
{
+ sysfs_exit_ns(type, ns);
}
--
1.6.5.2.143.g8cc62
^ permalink raw reply related
* [PATCH 1/6] sysfs: Basic support for multiple super blocks
From: Eric W. Biederman @ 2010-03-30 18:31 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Kay Sievers, linux-kernel, Tejun Heo, Cornelia Huck,
linux-fsdevel, Eric Dumazet, Benjamin LaHaise, Serge Hallyn,
netdev, Eric W. Biederman
In-Reply-To: <m1fx3hk6gw.fsf@fess.ebiederm.org>
From: Eric W. Biederman <ebiederm@xmission.com>
Add all of the necessary bioler plate to support
multiple superblocks in sysfs.
Signed-off-by: Eric W. Biederman <ebiederm@xmission.com>
---
fs/sysfs/mount.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
fs/sysfs/sysfs.h | 3 ++
2 files changed, 59 insertions(+), 2 deletions(-)
diff --git a/fs/sysfs/mount.c b/fs/sysfs/mount.c
index 0cb1088..6a433ac 100644
--- a/fs/sysfs/mount.c
+++ b/fs/sysfs/mount.c
@@ -71,16 +71,70 @@ static int sysfs_fill_super(struct super_block *sb, void *data, int silent)
return 0;
}
+static int sysfs_test_super(struct super_block *sb, void *data)
+{
+ struct sysfs_super_info *sb_info = sysfs_info(sb);
+ struct sysfs_super_info *info = data;
+ int found = 1;
+ return found;
+}
+
+static int sysfs_set_super(struct super_block *sb, void *data)
+{
+ int error;
+ error = set_anon_super(sb, data);
+ if (!error)
+ sb->s_fs_info = data;
+ return error;
+}
+
static int sysfs_get_sb(struct file_system_type *fs_type,
int flags, const char *dev_name, void *data, struct vfsmount *mnt)
{
- return get_sb_single(fs_type, flags, data, sysfs_fill_super, mnt);
+ struct sysfs_super_info *info;
+ struct super_block *sb;
+ int error;
+
+ error = -ENOMEM;
+ info = kzalloc(sizeof(*info), GFP_KERNEL);
+ if (!info)
+ goto out;
+ sb = sget(fs_type, sysfs_test_super, sysfs_set_super, info);
+ if (IS_ERR(sb) || sb->s_fs_info != info)
+ kfree(info);
+ if (IS_ERR(sb)) {
+ kfree(info);
+ error = PTR_ERR(sb);
+ goto out;
+ }
+ if (!sb->s_root) {
+ sb->s_flags = flags;
+ error = sysfs_fill_super(sb, data, flags & MS_SILENT ? 1 : 0);
+ if (error) {
+ deactivate_locked_super(sb);
+ goto out;
+ }
+ sb->s_flags |= MS_ACTIVE;
+ }
+
+ simple_set_mnt(mnt, sb);
+ error = 0;
+out:
+ return error;
+}
+
+static void sysfs_kill_sb(struct super_block *sb)
+{
+ struct sysfs_super_info *info = sysfs_info(sb);
+
+ kill_anon_super(sb);
+ kfree(info);
}
static struct file_system_type sysfs_fs_type = {
.name = "sysfs",
.get_sb = sysfs_get_sb,
- .kill_sb = kill_anon_super,
+ .kill_sb = sysfs_kill_sb,
};
int __init sysfs_init(void)
diff --git a/fs/sysfs/sysfs.h b/fs/sysfs/sysfs.h
index 30f5a44..030a39d 100644
--- a/fs/sysfs/sysfs.h
+++ b/fs/sysfs/sysfs.h
@@ -114,6 +114,9 @@ struct sysfs_addrm_cxt {
/*
* mount.c
*/
+struct sysfs_super_info {
+};
+#define sysfs_info(SB) ((struct sysfs_super_info *)(SB->s_fs_info))
extern struct sysfs_dirent sysfs_root;
extern struct kmem_cache *sysfs_dir_cachep;
--
1.6.5.2.143.g8cc62
^ permalink raw reply related
* [PATCH 0/6] tagged sysfs support
From: Eric W. Biederman @ 2010-03-30 18:30 UTC (permalink / raw)
To: Greg Kroah-Hartman
Cc: Kay Sievers, Greg KH, linux-kernel, Tejun Heo, Cornelia Huck,
linux-fsdevel, Eric Dumazet, Benjamin LaHaise, Serge Hallyn,
netdev
The main short coming of using multiple network namespaces today
is that only network devices for the primary network namespaces
can be put in the kobject layer and sysfs.
This is essentially the earlier version of this patchset that was
reviewed before, just now on top of a version of sysfs that doesn't
need cleanup patches to support it.
I have been running these patches in some form for well over a
year so the basics should at least be solid.
This patchset is currently against 2.6.34-rc1.
This patchset is just the basic infrastructure a couple of more pretty
trivial patches are needed to actually enable network namespaces to use this.
My current plan is to send those after these patches have made it through
review.
drivers/base/class.c | 9 ++++
drivers/base/core.c | 98 +++++++++++++++++++++++++++++++++----------
drivers/gpio/gpiolib.c | 2 +-
drivers/md/bitmap.c | 4 +-
drivers/md/md.c | 6 +-
fs/sysfs/bin.c | 2 +-
fs/sysfs/dir.c | 106 ++++++++++++++++++++++++++++++++++++-----------
fs/sysfs/file.c | 17 ++++---
fs/sysfs/group.c | 6 +-
fs/sysfs/inode.c | 6 ++-
fs/sysfs/mount.c | 91 +++++++++++++++++++++++++++++++++++++++-
fs/sysfs/symlink.c | 35 ++++++++++++++-
fs/sysfs/sysfs.h | 23 ++++++++--
include/linux/device.h | 3 +
include/linux/kobject.h | 26 +++++++++++
include/linux/sysfs.h | 18 ++++++++
lib/kobject.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++
17 files changed, 480 insertions(+), 76 deletions(-)
Eric
^ permalink raw reply
* Re: [PATCH -next] x86, fs: add sys_compat_write for net/socket.c
From: Florian Westphal @ 2010-03-30 18:17 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Florian Westphal, linux-fsdevel, Al Viro, David S. Miller,
Thomas Gleixner, Ingo Molnar, x86, netdev, linux-kernel
In-Reply-To: <4BB23B35.7060401@zytor.com>
H. Peter Anvin <hpa@zytor.com> wrote:
> > On some configurations, e.g. x86_64 with 32bit userspace, netlink/xfrm
> > misinterprets messages from userspace due to different structure
> > layout (u64 has different alignment requirements on x86 vs. x86_64).
[..]
> > As long as messages are sent via sendmsg(), this could be handled via
> > net/compat.c; it will set the CMSG_MSG_COMPAT flag in struct msghdr
> > for compat tasks, which would allow to the xfrm_user code to detect
> > when messages need compat fixups.
> >
> > Unfortunately, some programs (e.g. pluto ike daemon), send netlink data
> > to the kernel using write().
> >
> > Thus, introduce f_ops->compat_aio_write and compat_sys_write to treat
> > writes on sockets specially.
> >
> > This only wires up compat_sys_write for x86/x86_64 -- at the moment this
> > is only required to parse xfrm netlink messages, which happen to only
> > need special treatment in case of COMPAT_FOR_U64_ALIGNMENT=y.
> >
> > Setting CMSG_MSG_COMPAT depending on plain is_compat_task() in net/socket.c
> > was not done due to concerns regarding the kernel doing socket
> > writes in response to a user event (which might set MSG_COMPAT erronously).
> >
>
> OK... I have to ask the question:
>
> This only applies if you're using unpacked structures with
> non-naturally-aligned objects in them. Where to we have those, and can
> we shoot the authors?
Fair enough.
This happens e.g. when trying to add xfrm policies or SAs from 32bit x86
userspace on x86_64 kernels, e.g. commands like "ip xfrm pol add dir in"
fail due to user/kernelspace structure size mismatch.
One structure that has this problem is struct xfrm_userpolicy_info, but
there are more.
Now, I realize that adding a write compat syscall is borderline
insanity, and I am open to suggestions.
In fact, I would even accept a "userspace must use sendmsg() when dealing
with xfrm netlink"; the only problem is that my pending xfrm compat patches
depend on this patch being accepted [ or, rather, they depend
on the MSG_COMPAT flag being set; which is currently only done when userspace
uses sendmsg().
In fact, "ip xfrm .. " even works with the xfrm compat patch set applied
because ip xfrm ... happens to use sendmsg(). But not all userspace apps do this ].
Thanks, Florian
^ permalink raw reply
* Re: Add PGM protocol support to the IP stack
From: Christoph Lameter @ 2010-03-30 18:12 UTC (permalink / raw)
To: H. Peter Anvin; +Cc: Andi Kleen, David Miller, netdev, linux-kernel
In-Reply-To: <4BB13133.6030500@zytor.com>
On Mon, 29 Mar 2010, H. Peter Anvin wrote:
> On 03/22/2010 11:53 AM, Andi Kleen wrote:
> >
> > There's just no portable atomic64_t. Ok maybe you can use the socket lock
> > to synchronize all the counts if they are only per socket.
> >
>
> In 2.6.34 there is (although some arches which could support it natively
> don't as of yet... but that's fixable.) See lib/atomic64.c.
There are also the 64bit thiscpu operations that were merged in 2.6.33.
They do the right thing if the arch does not provide operations.
^ permalink raw reply
* Re: [PATCH -next] x86, fs: add sys_compat_write for net/socket.c
From: H. Peter Anvin @ 2010-03-30 17:56 UTC (permalink / raw)
To: Florian Westphal
Cc: linux-fsdevel, Al Viro, David S. Miller, Thomas Gleixner,
Ingo Molnar, x86, netdev, linux-kernel
In-Reply-To: <1269971469-1254-1-git-send-email-fw@strlen.de>
On 03/30/2010 10:51 AM, Florian Westphal wrote:
> On some configurations, e.g. x86_64 with 32bit userspace, netlink/xfrm
> misinterprets messages from userspace due to different structure
> layout (u64 has different alignment requirements on x86 vs. x86_64).
>
> As long as messages are sent via sendmsg(), this could be handled via
> net/compat.c; it will set the CMSG_MSG_COMPAT flag in struct msghdr
> for compat tasks, which would allow to the xfrm_user code to detect
> when messages need compat fixups.
>
> Unfortunately, some programs (e.g. pluto ike daemon), send netlink data
> to the kernel using write().
>
> Thus, introduce f_ops->compat_aio_write and compat_sys_write to treat
> writes on sockets specially.
>
> This only wires up compat_sys_write for x86/x86_64 -- at the moment this
> is only required to parse xfrm netlink messages, which happen to only
> need special treatment in case of COMPAT_FOR_U64_ALIGNMENT=y.
>
> Setting CMSG_MSG_COMPAT depending on plain is_compat_task() in net/socket.c
> was not done due to concerns regarding the kernel doing socket
> writes in response to a user event (which might set MSG_COMPAT erronously).
>
OK... I have to ask the question:
This only applies if you're using unpacked structures with
non-naturally-aligned objects in them. Where to we have those, and can
we shoot the authors?
-hpa
^ permalink raw reply
* Re: Tiny patch (w/ discussion) to provide the peer information on unix domain sockets
From: Erkki Seppala @ 2010-03-30 17:39 UTC (permalink / raw)
To: netdev
In-Reply-To: <1269961013.2012.61.camel@edumazet-laptop>
Hi Eric,
On Tue, Mar 30, 2010 at 04:56:53PM +0200, Eric Dumazet wrote:
> Such patches should be sent to netdev
Oops! Thanks for the pointer!
> I believe you missed some necessary locking.
I don't think so, because I don't actually dereference the other unix
address, I just print the its address.
> Prior art from Kenan Kalajdzic :
>
> http://patchwork.ozlabs.org/patch/46561/
Perhaps this would be a more decent solution (using the more
user-space compatible concept of inodes), although I think don't that
the backwards compatiblity for this kind of rarely used feature is
that critical, given the impact of the breakage seems to be quite low
as well.
I think the way forward in general should be that user space
applications actually look what columns are available and provide
future compatibility in that fashion. And empty fields should have
have some filler :).
--
_____________________________________________________________________
/ __// /__ ____ __ http://www.modeemi.fi/~flux/\ \
/ /_ / // // /\ \/ / \ /
/_/ /_/ \___/ /_/\_\@modeemi.fi \/
^ permalink raw reply
* Re: [PATCH 2/2] ethtool: RXHASH flag support
From: Jeff Garzik @ 2010-03-30 17:37 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
In-Reply-To: <20100330103207.7fc5681a@nehalam>
On 03/30/2010 01:32 PM, Stephen Hemminger wrote:
> On Tue, 30 Mar 2010 13:29:01 -0400
> Jeff Garzik<jeff@garzik.org> wrote:
>
>> By blindly sync'ing the ethtool.h header, ETHTOOL_MAX_NTUPLE_LIST_ENTRY
>> and its sibling ETHTOOL_MAX_NTUPLE_STRING_PER_ENTRY were removed,
>> breaking the ethtool build.
>
> In the patch I moved it to ethtool.c to have local entries.
>
> I believe that all cloned headers should only come from the result
> of kernel "make install_headers". Not locally different vrsions.
There is nothing locally different about ethtool-copy.h.
Jeff
^ permalink raw reply
* Re: [PATCH 2/2] ethtool: RXHASH flag support
From: Stephen Hemminger @ 2010-03-30 17:32 UTC (permalink / raw)
To: Jeff Garzik; +Cc: David Miller, netdev
In-Reply-To: <4BB234DD.9040800@garzik.org>
On Tue, 30 Mar 2010 13:29:01 -0400
Jeff Garzik <jeff@garzik.org> wrote:
> By blindly sync'ing the ethtool.h header, ETHTOOL_MAX_NTUPLE_LIST_ENTRY
> and its sibling ETHTOOL_MAX_NTUPLE_STRING_PER_ENTRY were removed,
> breaking the ethtool build.
In the patch I moved it to ethtool.c to have local entries.
I believe that all cloned headers should only come from the result
of kernel "make install_headers". Not locally different vrsions.
--
^ permalink raw reply
* Re: [PATCH 2/2] ethtool: RXHASH flag support
From: Jeff Garzik @ 2010-03-30 17:29 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
In-Reply-To: <20100329175352.38008e05@nehalam>
On 03/29/2010 08:53 PM, Stephen Hemminger wrote:
> Add support for RXHASH flag in ethtool offload.
> Update to current net-next sanitized version of ethtool.h
>
> Signed-off-by: Stephen Hemminger<shemminger@vyatta.com>
> ---
> ethtool-copy.h | 32 +++++++++++++++++++++++++-------
> ethtool.8 | 4 ++++
> ethtool.c | 42 +++++++++++++++++++++++++++++++++++++-----
> 3 files changed, 66 insertions(+), 12 deletions(-)
>
> diff --git a/ethtool-copy.h b/ethtool-copy.h
> index 8681f5e..0cf8f33 100644
> --- a/ethtool-copy.h
> +++ b/ethtool-copy.h
> @@ -36,7 +36,7 @@ struct ethtool_cmd {
> __u32 reserved[2];
> };
>
> -static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
> +static __inline__ void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
> __u32 speed)
> {
>
> @@ -44,7 +44,7 @@ static inline void ethtool_cmd_speed_set(struct ethtool_cmd *ep,
> ep->speed_hi = (__u16)(speed>> 16);
> }
>
> -static inline __u32 ethtool_cmd_speed(struct ethtool_cmd *ep)
> +static __inline__ __u32 ethtool_cmd_speed(struct ethtool_cmd *ep)
> {
> return (ep->speed_hi<< 16) | ep->speed;
> }
> @@ -61,6 +61,13 @@ struct ethtool_drvinfo {
> /* For PCI devices, use pci_name(pci_dev). */
> char reserved1[32];
> char reserved2[12];
> + /*
> + * Some struct members below are filled in
> + * using ops->get_sset_count(). Obtaining
> + * this info from ethtool_drvinfo is now
> + * deprecated; Use ETHTOOL_GSSET_INFO
> + * instead.
> + */
> __u32 n_priv_flags; /* number of flags valid in ETHTOOL_GPFLAGS */
> __u32 n_stats; /* number of u64's from ETHTOOL_GSTATS */
> __u32 testinfo_len;
> @@ -253,6 +260,17 @@ struct ethtool_gstrings {
> __u8 data[0];
> };
>
> +struct ethtool_sset_info {
> + __u32 cmd; /* ETHTOOL_GSSET_INFO */
> + __u32 reserved;
> + __u64 sset_mask; /* input: each bit selects an sset to query */
> + /* output: each bit a returned sset */
> + __u32 data[0]; /* ETH_SS_xxx count, in order, based on bits
> + in sset_mask. One bit implies one
> + __u32, two bits implies two
> + __u32's, etc. */
> +};
> +
> enum ethtool_test_flags {
> ETH_TEST_FL_OFFLINE = (1<< 0), /* online / offline */
> ETH_TEST_FL_FAILED = (1<< 1), /* test passed / failed */
> @@ -292,6 +310,7 @@ struct ethtool_perm_addr {
> enum ethtool_flags {
> ETH_FLAG_LRO = (1<< 15), /* LRO is enabled */
> ETH_FLAG_NTUPLE = (1<< 27), /* N-tuple filters enabled */
> + ETH_FLAG_RXHASH = (1<< 28),
> };
>
> /* The following structures are for supporting RX network flow
> @@ -389,8 +408,6 @@ struct ethtool_rx_ntuple_flow_spec {
> #define ETHTOOL_RXNTUPLE_ACTION_DROP -1
> };
>
> -#define ETHTOOL_MAX_NTUPLE_LIST_ENTRY 1024
> -#define ETHTOOL_MAX_NTUPLE_STRING_PER_ENTRY 14
> struct ethtool_rx_ntuple {
> __u32 cmd;
> struct ethtool_rx_ntuple_flow_spec fs;
> @@ -408,6 +425,7 @@ struct ethtool_flash {
> char data[ETHTOOL_FLASH_MAX_FILENAME];
> };
>
> +
> /* CMDs currently supported */
> #define ETHTOOL_GSET 0x00000001 /* Get settings. */
> #define ETHTOOL_SSET 0x00000002 /* Set settings. */
> @@ -463,9 +481,9 @@ struct ethtool_flash {
> #define ETHTOOL_SRXCLSRLINS 0x00000032 /* Insert RX classification rule */
> #define ETHTOOL_FLASHDEV 0x00000033 /* Flash firmware to device */
> #define ETHTOOL_RESET 0x00000034 /* Reset hardware */
> -
> -#define ETHTOOL_SRXNTUPLE 0x00000035 /* Add an n-tuple filter to device */
> -#define ETHTOOL_GRXNTUPLE 0x00000036 /* Get n-tuple filters from device */
> +#define ETHTOOL_SRXNTUPLE 0x00000035 /* Add an n-tuple filter to device */
> +#define ETHTOOL_GRXNTUPLE 0x00000036 /* Get n-tuple filters from device */
> +#define ETHTOOL_GSSET_INFO 0x00000037 /* Get string set info */
>
NAK - you broke the build. You should also know not to combine patches
like this. Linux 101: separate changes, separate patches.
By blindly sync'ing the ethtool.h header, ETHTOOL_MAX_NTUPLE_LIST_ENTRY
and its sibling ETHTOOL_MAX_NTUPLE_STRING_PER_ENTRY were removed,
breaking the ethtool build.
Furthermore, I just pulled net-next and did my own sync, and those
s/inline/__inline__/ substitutions are not present.
I went ahead and made sure everything is sync'd correctly and building
correctly, in the ethtool git repo. Please resubmit a patch DIRECTLY
and ONLY related to RXHASH flag support. If you decide to do any other
work, that belongs in a separate patch.
Jeff
^ permalink raw reply
* Re: [PATCH v3 04/12] l2tp: Add ppp device name to L2TP ppp session data
From: Stephen Hemminger @ 2010-03-30 16:29 UTC (permalink / raw)
To: James Chapman; +Cc: netdev
In-Reply-To: <20100330161746.9628.40723.stgit@bert.katalix.com>
On Tue, 30 Mar 2010 17:17:46 +0100
James Chapman <jchapman@katalix.com> wrote:
> When dumping L2TP PPP sessions using /proc/net/l2tp, get
> the assigned PPP device name from PPP using ppp_dev_name().
>
> Signed-off-by: James Chapman <jchapman@katalix.com>
> Reviewed-by: Randy Dunlap <randy.dunlap@oracle.com>
>
Why is this a necessary API?
Why not put it in debugfs if just a debugging tool?
^ permalink raw reply
* Re: [PATCH v3 10/12] l2tp: Add L2TP ethernet pseudowire support
From: Stephen Hemminger @ 2010-03-30 16:32 UTC (permalink / raw)
To: James Chapman; +Cc: netdev
In-Reply-To: <20100330161819.9628.10853.stgit@bert.katalix.com>
On Tue, 30 Mar 2010 17:18:19 +0100
James Chapman <jchapman@katalix.com> wrote:
> +struct l2tp_eth_net {
> + struct list_head l2tp_eth_dev_list;
> + rwlock_t l2tp_eth_lock;
> +};
Reader/write locks are discouraged because they are slower than
spin locks. If you have lots of readers use RCU, if reading
is infrequent just use a spin lock.
--
^ permalink raw reply
* Re: [PATCH v3 10/12] l2tp: Add L2TP ethernet pseudowire support
From: Stephen Hemminger @ 2010-03-30 16:30 UTC (permalink / raw)
To: James Chapman; +Cc: netdev
In-Reply-To: <20100330161819.9628.10853.stgit@bert.katalix.com>
On Tue, 30 Mar 2010 17:18:19 +0100
James Chapman <jchapman@katalix.com> wrote:
> +
> + /* Derive a MAC address for the new interface. We use the L2TP
> + * session's session-id to guarantee a system-wide unique
> + * address. This MAC is only visible within the L2TP session.
> + */
> + dev->dev_addr[0] = 0x02; /* IEEE 802 local */
> + dev->dev_addr[1] = 'L';
> + memcpy(&dev->dev_addr[2], &sid, 4);
Why not random ether address?
--
^ permalink raw reply
* Re: [PATCH v3 10/12] l2tp: Add L2TP ethernet pseudowire support
From: Stephen Hemminger @ 2010-03-30 16:30 UTC (permalink / raw)
To: James Chapman; +Cc: netdev
In-Reply-To: <20100330161819.9628.10853.stgit@bert.katalix.com>
On Tue, 30 Mar 2010 17:18:19 +0100
James Chapman <jchapman@katalix.com> wrote:
> static inline struct l2tp_eth_net *l2tp_eth_pernet(struct net *net)
> +{
> + BUG_ON(!net);
> +
> + return net_generic(net, l2tp_eth_net_id);
> +}
Don't test for NULL with BUG_ON. It is redundant, the null
dereference will cause the same kind of backtrace failure.
--
^ permalink raw reply
* Re: [PATCH 1/2] netdev: ethtool RXHASH flag
From: Jeff Garzik @ 2010-03-30 17:19 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: David Miller, netdev
In-Reply-To: <20100329174727.4654e19c@nehalam>
On 03/29/2010 08:47 PM, Stephen Hemminger wrote:
> This adds ethtool and device feature flag to allow control
> of receive hashing offload.
>
> Signed-off-by: Stephen Hemminger<shemminger@vyatta.com>
Acked-by: Jeff Garzik <jgarzik@redhat.com>
^ permalink raw reply
* Re: [PATCH] net/pcmcia 3com: replacements of printk() with dev_info() and friends (fwd)
From: Joe Perches @ 2010-03-30 17:22 UTC (permalink / raw)
To: Alexander Kurz
Cc: David S. Miller, Ken Kawasaki, Dominik Brodowski, Magnus Damm,
Ben Hutchings, netdev, linux-kernel
In-Reply-To: <alpine.DEB.1.10.1003302019200.11637@blala.de>
On Tue, 2010-03-30 at 21:01 +0400, Alexander Kurz wrote:
> I wrote a patch as suggested by kernel-janitors.
> It is my first patch, so I highly welcome comments and hints,
> thanks, Alexander Kurz
As this is a network driver, you could use netdev_<level>
for most of this. Also, you could coalesce the format
strings to go beyond 80 columns. It makes grepping
a bit easier.
> - printk(KERN_INFO "%s: %s at io %#3lx, irq %d, "
> + dev_info(&dev->dev, "%s: %s at io %#3lx, irq %d, "
> "hw_addr %pM.\n",
This could become:
netdev_info(dev, "%s at io %#3lx, irq %d, hw_addr %pM\n"
cardname, dev->base_addr, dev->irq, dev->dev_addr);
etc.
^ permalink raw reply
* Re: [PATCH] net/wireless/libertas: do not call wiphy_unregister() w/o wiphy_register()
From: John W. Linville @ 2010-03-30 17:20 UTC (permalink / raw)
To: Dan Williams
Cc: Holger Schurig, Daniel Mack, libertas-dev, netdev, linux-wireless,
linux-kernel
In-Reply-To: <1269968673.3019.37.camel@localhost.localdomain>
On Tue, Mar 30, 2010 at 10:04:33AM -0700, Dan Williams wrote:
> On Tue, 2010-03-30 at 12:59 +0200, Holger Schurig wrote:
> > > I don't get your point. The patch I submitted fixes an Ooops in the
> > > driver, due to wrong handling of an API. What does that have to do with
> > > principle discussions about the frameworks in use?
> >
> > I asked if there is a better method, and you said that you would test a better
> > solution. That means that someone else should make a better solution.
> >
> > I just pointed out that I won't be the one who creates the better solution,
> > because for fundamental reasons I don't see the libertas+cfg80211 approach
> > going forward. That issue has nothing to do with you or your patch, so please
> > don't feel offended or confused.
>
> Fine; just rip out the mesh code and do the vanilla cfg80211 conversion
> for infra & adhoc, and we'll add the mesh code back later. I don't have
> time to do the cfg80211 bits, neither do the OLPC guys (AFAIK), so lets
> take advantage of your willingness to do this and just move the driver
> forward.
Someone post a feature removal patch, please?
John
--
John W. Linville Someday the world will need a hero, and you
linville@tuxdriver.com might be all we have. Be ready.
^ permalink raw reply
* Re: [ethtool PATCH v4] ethtool: Correctly pull n-tuple string length for get_rx_ntuple
From: Jeff Garzik @ 2010-03-30 17:11 UTC (permalink / raw)
To: Jeff Kirsher; +Cc: netdev, gospo
In-Reply-To: <20100304085328.4510.9284.stgit@localhost.localdomain>
On 03/04/2010 03:53 AM, Jeff Kirsher wrote:
> From: Peter Waskiewicz<peter.p.waskiewicz.jr@intel.com>
>
> This patch fixes inconsistencies with the kernel header files, while
> correctly gets the variable length string counts for the get_rx_ntuple
> return value. It does this by using the new GSSET_INFO ioctl.
>
> Signed-off-by: Peter P Waskiewicz Jr<peter.p.waskiewicz.jr@intel.com>
> Signed-off-by: Jeff Kirsher<jeffrey.t.kirsher@intel.com>
> ---
>
> ethtool-copy.h | 14 ++++++++++++--
> ethtool.c | 19 ++++++++++++++++---
> 2 files changed, 28 insertions(+), 5 deletions(-)
applied
^ permalink raw reply
* Re: [PATCH 2/2] ath: fix code readability in regd.c
From: Luis de Bethencourt @ 2010-03-30 17:08 UTC (permalink / raw)
To: Luis R. Rodriguez
Cc: linville@tuxdriver.com, Luis Rodriguez,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
In-Reply-To: <20100330165645.GB25095@tux>
On Tue, Mar 30, 2010 at 5:56 PM, Luis R. Rodriguez
<lrodriguez@atheros.com> wrote:
> On Tue, Mar 30, 2010 at 08:44:33AM -0700, Luis de Bethencourt wrote:
>> This is a patch to the ath/regd.c file that fixes two code
>> readability issues. A space between to separate two defines
>> and the indentation inside the ath_redg_is_eeprom_valid
>> function.
>
> Acked-by: Luis R. Rodriguez <lrodriguez@atheros.com>
>
> You can drop netdev and linux-kernel from future linux-wireless e-mails
> like this one.
>
> Luis
>
OK. Will do.
Luis
^ permalink raw reply
* Re: [PATCH] net/wireless/libertas: do not call wiphy_unregister() w/o wiphy_register()
From: Dan Williams @ 2010-03-30 17:04 UTC (permalink / raw)
To: Holger Schurig
Cc: Daniel Mack, libertas-dev-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
netdev-u79uwXL29TY76Z2rM5mHXA,
linux-wireless-u79uwXL29TY76Z2rM5mHXA,
linux-kernel-u79uwXL29TY76Z2rM5mHXA, John W. Linville
In-Reply-To: <201003301259.23973.hs4233-x6+DxXLjN1AJvtFkdXX2Hg4jNU5vUVPG@public.gmane.org>
On Tue, 2010-03-30 at 12:59 +0200, Holger Schurig wrote:
> > I don't get your point. The patch I submitted fixes an Ooops in the
> > driver, due to wrong handling of an API. What does that have to do with
> > principle discussions about the frameworks in use?
>
> I asked if there is a better method, and you said that you would test a better
> solution. That means that someone else should make a better solution.
>
> I just pointed out that I won't be the one who creates the better solution,
> because for fundamental reasons I don't see the libertas+cfg80211 approach
> going forward. That issue has nothing to do with you or your patch, so please
> don't feel offended or confused.
Fine; just rip out the mesh code and do the vanilla cfg80211 conversion
for infra & adhoc, and we'll add the mesh code back later. I don't have
time to do the cfg80211 bits, neither do the OLPC guys (AFAIK), so lets
take advantage of your willingness to do this and just move the driver
forward.
Dan
>
> Basically, I neither ack nor nak you patch. Given that it fixes an oops the
> patch should go in, and probably to stable at well. I just gave a hint, to
> make you think if you could come up with something better.
>
>
>
> BTW, testing/fixing of failure paths in libertas as well as simplifying the
> call sequence of functions during initialisation could be quite useful.
>
> _______________________________________________
> libertas-dev mailing list
> libertas-dev-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> http://lists.infradead.org/mailman/listinfo/libertas-dev
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* [PATCH] net/pcmcia 3com: replacements of printk() with dev_info() and friends (fwd)
From: Alexander Kurz @ 2010-03-30 17:01 UTC (permalink / raw)
To: David S. Miller, Ken Kawasaki, Dominik Brodowski, Magnus Damm,
Ben
Cc: netdev, linux-kernel
Hi,
I wrote a patch as suggested by kernel-janitors.
It is my first patch, so I highly welcome comments and hints,
thanks, Alexander Kurz
---------- Forwarded message ----------
Date: Tue, 30 Mar 2010 18:55:33 +0400 (MSD)
From: Alexander Kurz <akurz@blala.de>
To: kernel-janitors@vger.kernel.org
Subject: [PATCH] net/pcmcia 3com: replacements of printk() with dev_info() and
friends
Hello List,
I wrote a patch replacing some printk() with dev_info() and friends
for 3com 16-bit PCMCIA cards.
As this is my first linux patch, comments are welcome,
thanks, Alexander Kurz
---------- Forwarded message ----------
Date: Tue, 30 Mar 2010 18:51:43 +0400
From: Alexander Kurz <akurz@blala.de>
To: akurz@blala.de
> From 84616314b126b730528ca10e704d80eabad96ff8 Mon Sep 17 00:00:00 2001
From: Alexander Kurz <akurz@kbdbabel.org>
Date: Tue, 30 Mar 2010 12:08:54 +0200
Subject: [PATCH] net/pcmcia 3com: replacements of printk() with dev_info() and
friends
as suggested by kernel-janitors for 3com 16-bit PCMCIA cards
---
drivers/net/pcmcia/3c574_cs.c | 37 +++++++++++++++++--------------------
drivers/net/pcmcia/3c589_cs.c | 41 +++++++++++++++++++----------------------
2 files changed, 36 insertions(+), 42 deletions(-)
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c
index 3d1d3a7..639cd21 100644
--- a/drivers/net/pcmcia/3c574_cs.c
+++ b/drivers/net/pcmcia/3c574_cs.c
@@ -396,7 +396,7 @@ static int tc574_config(struct pcmcia_device *link)
outw(2<<11, ioaddr + RunnerRdCtrl);
mcr = inb(ioaddr + 2);
outw(0<<11, ioaddr + RunnerRdCtrl);
- printk(KERN_INFO " ASIC rev %d,", mcr>>3);
+ dev_info(&dev->dev, " ASIC rev %d,", mcr>>3);
EL3WINDOW(3);
config = inl(ioaddr + Wn3_Config);
lp->default_media = (config & Xcvr) >> Xcvr_shift;
@@ -457,11 +457,11 @@ static int tc574_config(struct pcmcia_device *link)
strcpy(lp->node.dev_name, dev->name);
- printk(KERN_INFO "%s: %s at io %#3lx, irq %d, "
+ dev_info(&dev->dev, "%s: %s at io %#3lx, irq %d, "
"hw_addr %pM.\n",
dev->name, cardname, dev->base_addr, dev->irq,
dev->dev_addr);
- printk(" %dK FIFO split %s Rx:Tx, %sMII interface.\n",
+ dev_info(&dev->dev, " %dK FIFO split %s Rx:Tx, %sMII interface.\n",
8 << config & Ram_size,
ram_split[(config & Ram_split) >> Ram_split_shift],
config & Autoselect ? "autoselect " : "");
@@ -511,12 +511,12 @@ static void dump_status(struct net_device *dev)
{
unsigned int ioaddr = dev->base_addr;
EL3WINDOW(1);
- printk(KERN_INFO " irq status %04x, rx status %04x, tx status "
+ dev_info(&dev->dev, " irq status %04x, rx status %04x, tx status "
"%02x, tx free %04x\n", inw(ioaddr+EL3_STATUS),
inw(ioaddr+RxStatus), inb(ioaddr+TxStatus),
inw(ioaddr+TxFree));
EL3WINDOW(4);
- printk(KERN_INFO " diagnostics: fifo %04x net %04x ethernet %04x"
+ dev_info(&dev->dev, " diagnostics: fifo %04x net %04x ethernet %04x"
" media %04x\n", inw(ioaddr+0x04), inw(ioaddr+0x06),
inw(ioaddr+0x08), inw(ioaddr+0x0a));
EL3WINDOW(1);
@@ -532,7 +532,7 @@ static void tc574_wait_for_completion(struct net_device
*dev, int cmd)
while (--i > 0)
if (!(inw(dev->base_addr + EL3_STATUS) & 0x1000)) break;
if (i == 0)
- printk(KERN_NOTICE "%s: command 0x%04x did not complete!\n",
dev->name, cmd);
+ dev_notice(&dev->dev, "command 0x%04x did not complete!\n",
cmd);
}
/* Read a word from the EEPROM using the regular EEPROM access register.
@@ -736,7 +736,7 @@ static void el3_tx_timeout(struct net_device *dev)
{
unsigned int ioaddr = dev->base_addr;
- printk(KERN_NOTICE "%s: Transmit timed out!\n", dev->name);
+ dev_notice(&dev->dev, "Transmit timed out!\n");
dump_status(dev);
dev->stats.tx_errors++;
dev->trans_start = jiffies;
@@ -856,8 +856,8 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id)
EL3WINDOW(4);
fifo_diag = inw(ioaddr + Wn4_FIFODiag);
EL3WINDOW(1);
- printk(KERN_NOTICE "%s: adapter failure, FIFO
diagnostic"
- " register %04x.\n", dev->name,
fifo_diag);
+ dev_notice(&dev->dev, "adapter failure, FIFO
diagnostic"
+ " register %04x.\n", fifo_diag);
if (fifo_diag & 0x0400) {
/* Tx overrun */
tc574_wait_for_completion(dev,
TxReset);
@@ -911,7 +911,7 @@ static void media_check(unsigned long arg)
this, we can limp along even if the interrupt is blocked */
if ((inw(ioaddr + EL3_STATUS) & IntLatch) && (inb(ioaddr + Timer) ==
0xff)) {
if (!lp->fast_poll)
- printk(KERN_INFO "%s: interrupt(s) dropped!\n",
dev->name);
+ dev_info(&dev->dev, "interrupt(s) dropped!\n");
local_irq_save(flags);
el3_interrupt(dev->irq, dev);
@@ -934,23 +934,21 @@ static void media_check(unsigned long arg)
if (media != lp->media_status) {
if ((media ^ lp->media_status) & 0x0004)
- printk(KERN_INFO "%s: %s link beat\n", dev->name,
+ dev_info(&dev->dev, "%s link beat\n",
(lp->media_status & 0x0004) ? "lost" :
"found");
if ((media ^ lp->media_status) & 0x0020) {
lp->partner = 0;
if (lp->media_status & 0x0020) {
- printk(KERN_INFO "%s: autonegotiation
restarted\n",
- dev->name);
+ dev_info(&dev->dev, "autonegotiation
restarted\n");
} else if (partner) {
partner &= lp->advertising;
lp->partner = partner;
- printk(KERN_INFO "%s: autonegotiation complete:
"
- "%sbaseT-%cD selected\n", dev->name,
+ dev_info(&dev->dev, "autonegotiation complete:
"
+ "%sbaseT-%cD selected\n",
((partner & 0x0180) ? "100" : "10"),
((partner & 0x0140) ? 'F' : 'H'));
} else {
- printk(KERN_INFO "%s: link partner did not
autonegotiate\n",
- dev->name);
+ dev_info(&dev->dev, "link partner did not
autonegotiate\n");
}
EL3WINDOW(3);
@@ -960,10 +958,9 @@ static void media_check(unsigned long arg)
}
if (media & 0x0010)
- printk(KERN_INFO "%s: remote fault detected\n",
- dev->name);
+ dev_info(&dev->dev, "remote fault detected\n");
if (media & 0x0002)
- printk(KERN_INFO "%s: jabber detected\n", dev->name);
+ dev_info(&dev->dev, "jabber detected\n");
lp->media_status = media;
}
spin_unlock_irqrestore(&lp->window_lock, flags);
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c
index 091e0b0..9f6736b 100644
--- a/drivers/net/pcmcia/3c589_cs.c
+++ b/drivers/net/pcmcia/3c589_cs.c
@@ -324,11 +324,11 @@ static int tc589_config(struct pcmcia_device *link)
strcpy(lp->node.dev_name, dev->name);
- printk(KERN_INFO "%s: 3Com 3c%s, io %#3lx, irq %d, "
+ dev_info(&dev->dev, "3Com 3c%s, io %#3lx, irq %d, "
"hw_addr %pM\n",
- dev->name, (multi ? "562" : "589"), dev->base_addr, dev->irq,
+ (multi ? "562" : "589"), dev->base_addr, dev->irq,
dev->dev_addr);
- printk(KERN_INFO " %dK FIFO split %s Rx:Tx, %s xcvr\n",
+ dev_info(&dev->dev, " %dK FIFO split %s Rx:Tx, %s xcvr\n",
(fifo & 7) ? 32 : 8, ram_split[(fifo >> 16) & 3],
if_names[dev->if_port]);
return 0;
@@ -385,8 +385,7 @@ static void tc589_wait_for_completion(struct net_device
*dev, int cmd)
while (--i > 0)
if (!(inw(dev->base_addr + EL3_STATUS) & 0x1000)) break;
if (i == 0)
- printk(KERN_WARNING "%s: command 0x%04x did not complete!\n",
- dev->name, cmd);
+ dev_warn(&dev->dev, "command 0x%04x did not complete!\n", cmd);
}
/*
@@ -435,12 +434,12 @@ static void dump_status(struct net_device *dev)
{
unsigned int ioaddr = dev->base_addr;
EL3WINDOW(1);
- printk(KERN_INFO " irq status %04x, rx status %04x, tx status "
+ dev_info(&dev->dev, " irq status %04x, rx status %04x, tx status "
"%02x tx free %04x\n", inw(ioaddr+EL3_STATUS),
inw(ioaddr+RX_STATUS), inb(ioaddr+TX_STATUS),
inw(ioaddr+TX_FREE));
EL3WINDOW(4);
- printk(KERN_INFO " diagnostics: fifo %04x net %04x ethernet %04x"
+ dev_info(&dev->dev, " diagnostics: fifo %04x net %04x ethernet %04x"
" media %04x\n", inw(ioaddr+0x04), inw(ioaddr+0x06),
inw(ioaddr+0x08), inw(ioaddr+0x0a));
EL3WINDOW(1);
@@ -504,8 +503,8 @@ static int el3_config(struct net_device *dev, struct ifmap
*map)
if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) {
if (map->port <= 3) {
dev->if_port = map->port;
- printk(KERN_INFO "%s: switched to %s port\n",
- dev->name, if_names[dev->if_port]);
+ dev_info(&dev->dev, "switched to %s port\n",
+ if_names[dev->if_port]);
tc589_set_xcvr(dev, dev->if_port);
} else
return -EINVAL;
@@ -541,7 +540,7 @@ static void el3_tx_timeout(struct net_device *dev)
{
unsigned int ioaddr = dev->base_addr;
- printk(KERN_WARNING "%s: Transmit timed out!\n", dev->name);
+ dev_warn(&dev->dev, "Transmit timed out!\n");
dump_status(dev);
dev->stats.tx_errors++;
dev->trans_start = jiffies;
@@ -660,8 +659,8 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id)
EL3WINDOW(4);
fifo_diag = inw(ioaddr + 4);
EL3WINDOW(1);
- printk(KERN_WARNING "%s: adapter failure, FIFO diagnostic"
- " register %04x.\n", dev->name, fifo_diag);
+ dev_warn(&dev->dev, "adapter failure, FIFO diagnostic"
+ " register %04x.\n", fifo_diag);
if (fifo_diag & 0x0400) {
/* Tx overrun */
tc589_wait_for_completion(dev, TxReset);
@@ -678,8 +677,8 @@ static irqreturn_t el3_interrupt(int irq, void *dev_id)
}
if (++i > 10) {
- printk(KERN_ERR "%s: infinite loop in interrupt, "
- "status %4.4x.\n", dev->name, status);
+ dev_err(&dev->dev, "infinite loop in interrupt, "
+ "status %4.4x.\n", status);
/* Clear all interrupts */
outw(AckIntr | 0xFF, ioaddr + EL3_CMD);
break;
@@ -710,7 +709,7 @@ static void media_check(unsigned long arg)
if ((inw(ioaddr + EL3_STATUS) & IntLatch) &&
(inb(ioaddr + EL3_TIMER) == 0xff)) {
if (!lp->fast_poll)
- printk(KERN_WARNING "%s: interrupt(s) dropped!\n", dev->name);
+ dev_warn(&dev->dev, "interrupt(s) dropped!\n");
local_irq_save(flags);
el3_interrupt(dev->irq, dev);
@@ -747,25 +746,23 @@ static void media_check(unsigned long arg)
if (media != lp->media_status) {
if ((media & lp->media_status & 0x8000) &&
((lp->media_status ^ media) & 0x0800))
- printk(KERN_INFO "%s: %s link beat\n", dev->name,
+ dev_info(&dev->dev, "%s link beat\n",
(lp->media_status & 0x0800 ? "lost" : "found"));
else if ((media & lp->media_status & 0x4000) &&
((lp->media_status ^ media) & 0x0010))
- printk(KERN_INFO "%s: coax cable %s\n", dev->name,
+ dev_info(&dev->dev, "coax cable %s\n",
(lp->media_status & 0x0010 ? "ok" : "problem"));
if (dev->if_port == 0) {
if (media & 0x8000) {
if (media & 0x0800)
- printk(KERN_INFO "%s: flipped to 10baseT\n",
- dev->name);
+ dev_info(&dev->dev, "flipped to 10baseT\n");
else
tc589_set_xcvr(dev, 2);
} else if (media & 0x4000) {
if (media & 0x0010)
tc589_set_xcvr(dev, 1);
else
- printk(KERN_INFO "%s: flipped to 10base2\n",
- dev->name);
+ dev_info(&dev->dev, "flipped to 10base2\n");
}
}
lp->media_status = media;
@@ -875,7 +872,7 @@ static int el3_rx(struct net_device *dev)
tc589_wait_for_completion(dev, RxDiscard);
}
if (worklimit == 0)
- printk(KERN_WARNING "%s: too much work in el3_rx!\n", dev->name);
+ dev_warn(&dev->dev, "too much work in el3_rx!\n");
return 0;
}
--
1.7.0
^ permalink raw reply related
* Re: [PATCH 2/2] ath: fix code readability in regd.c
From: Luis R. Rodriguez @ 2010-03-30 16:56 UTC (permalink / raw)
To: Luis de Bethencourt
Cc: linville@tuxdriver.com, Luis Rodriguez,
linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org
In-Reply-To: <1269963873-2070-1-git-send-email-luisbg@ubuntu.com>
On Tue, Mar 30, 2010 at 08:44:33AM -0700, Luis de Bethencourt wrote:
> This is a patch to the ath/regd.c file that fixes two code
> readability issues. A space between to separate two defines
> and the indentation inside the ath_redg_is_eeprom_valid
> function.
Acked-by: Luis R. Rodriguez <lrodriguez@atheros.com>
You can drop netdev and linux-kernel from future linux-wireless e-mails
like this one.
Luis
^ permalink raw reply
* Re: [PATCH] gianfar: Fix a memory leak in gianfar close code
From: Laurent Chavey @ 2010-03-30 16:50 UTC (permalink / raw)
To: Andy Fleming; +Cc: davem, netdev, eric.dumazet, Sandeep.Kumar
In-Reply-To: <1269913343-6566-1-git-send-email-afleming@freescale.com>
since free_skb_[rx | tx]_queue() expects rx_queue->rx_skbuff to not be NULL
what about moving the conditional if(rx_queue->rx_skbuff)
in free_skb_rx_queue() and if(tx_queue->tx_skbuff) in free_skb_tx_queue()
OR put an assertion for not NULL in those functions ?
On Mon, Mar 29, 2010 at 6:42 PM, Andy Fleming <afleming@freescale.com> wrote:
> gianfar needed to ensure existence of the *skbuff arrays before
> freeing the skbs in them, rather than ensuring their nonexistence.
>
> Signed-off-by: Andy Fleming <afleming@freescale.com>
> ---
> drivers/net/gianfar.c | 4 ++--
> 1 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c
> index b671555..ad59608 100644
> --- a/drivers/net/gianfar.c
> +++ b/drivers/net/gianfar.c
> @@ -1638,13 +1638,13 @@ static void free_skb_resources(struct gfar_private *priv)
> /* Go through all the buffer descriptors and free their data buffers */
> for (i = 0; i < priv->num_tx_queues; i++) {
> tx_queue = priv->tx_queue[i];
> - if(!tx_queue->tx_skbuff)
> + if(tx_queue->tx_skbuff)
> free_skb_tx_queue(tx_queue);
> }
>
> for (i = 0; i < priv->num_rx_queues; i++) {
> rx_queue = priv->rx_queue[i];
> - if(!rx_queue->rx_skbuff)
> + if(rx_queue->rx_skbuff)
> free_skb_rx_queue(rx_queue);
> }
>
> --
> 1.6.5.2.g6ff9a
>
> --
> To unsubscribe from this list: send the line "unsubscribe netdev" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply
* RE: UDP path MTU discovery
From: Templin, Fred L @ 2010-03-30 15:58 UTC (permalink / raw)
To: Andi Kleen, Edgar E. Iglesias
Cc: Eric Dumazet, Rick Jones, Glen Turner, netdev@vger.kernel.org
In-Reply-To: <20100330061952.GO20695@one.firstfloor.org>
> -----Original Message-----
> From: Andi Kleen [mailto:andi@firstfloor.org]
> Sent: Monday, March 29, 2010 11:20 PM
> To: Edgar E. Iglesias
> Cc: Andi Kleen; Templin, Fred L; Eric Dumazet; Rick Jones; Glen Turner; netdev@vger.kernel.org
> Subject: Re: UDP path MTU discovery
>
> > If you don't want to hassle with all of that, the app can stick to
> > 1280 (or I guess for the extreme/lazy cases turn on fragmentation)..
>
> See the early mails in this thread. This is about apps who can't
> limit themselves to 1280, but still don't want full blown PMTU.
> [They probably should, but it can be a lot of work]
Right. Some apps may need to send isolated packets that
are larger than the path MTU without invoking path MTU
discovery.
> The MTU would allow to force fragmentation on the sending host
> as a workaround similar to IPv4.
Right again. Unlike IPv4, however, IPv6 does not allow
in-the-network fragmentation. So when in doubt, apps
that need to send isolated packets that may violate the
path MTU should really perform host-based fragmentation
with a maximum fragment size of 1280. Isn't there a
socket option "IPV6_USE_MIN_MTU" that apps can use to
force fragmentation on large packets (RFC3542)?
Caveat - the app may have no way of knowing whether
the destination is capable of reassembling fragmented
packets larger than 1500...
Fred
fred.l.templin@boeing.com
> -Andi
> --
> ak@linux.intel.com -- Speaking for myself only.
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox