projects
/
openvswitch
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
random: Get random seed from /dev/urandom.
[openvswitch]
/
datapath
/
dp_sysfs_if.c
diff --git
a/datapath/dp_sysfs_if.c
b/datapath/dp_sysfs_if.c
index f118818bd2b6daad4dded24f691de70c0c3227c0..8aa03a7672f993b8f5a618b544b2ed18f4e421b1 100644
(file)
--- a/
datapath/dp_sysfs_if.c
+++ b/
datapath/dp_sysfs_if.c
@@
-1,5
+1,5
@@
/*
/*
- * Copyright (c) 2009 Nicira Networks.
+ * Copyright (c) 2009
, 2010
Nicira Networks.
* Distributed under the terms of the GNU GPL version 2.
*
* Significant portions of this file may be copied from parts of the Linux
* Distributed under the terms of the GNU GPL version 2.
*
* Significant portions of this file may be copied from parts of the Linux
@@
-17,16
+17,17
@@
#include <linux/netdevice.h>
#include <linux/if_bridge.h>
#include <linux/rtnetlink.h>
#include <linux/netdevice.h>
#include <linux/if_bridge.h>
#include <linux/rtnetlink.h>
-#include <linux/spinlock.h>
-#include "dp_sysfs.h"
+
#include "datapath.h"
#include "datapath.h"
+#include "dp_sysfs.h"
+#include "vport.h"
-#ifdef
SUPPORT
_SYSFS
+#ifdef
CONFIG
_SYSFS
struct brport_attribute {
struct attribute attr;
struct brport_attribute {
struct attribute attr;
- ssize_t (*show)(struct
net_bridge
_port *, char *);
- ssize_t (*store)(struct
net_bridge
_port *, unsigned long);
+ ssize_t (*show)(struct
dp
_port *, char *);
+ ssize_t (*store)(struct
dp
_port *, unsigned long);
};
#define BRPORT_ATTR(_name,_mode,_show,_store) \
};
#define BRPORT_ATTR(_name,_mode,_show,_store) \
@@
-38,161
+39,101
@@
struct brport_attribute brport_attr_##_name = { \
.store = _store, \
};
.store = _store, \
};
-static ssize_t show_path_cost(struct
net_bridge
_port *p, char *buf)
+static ssize_t show_path_cost(struct
dp
_port *p, char *buf)
{
{
-#if 0
- return sprintf(buf, "%d\n", p->path_cost);
-#else
return sprintf(buf, "%d\n", 0);
return sprintf(buf, "%d\n", 0);
-#endif
}
}
-static ssize_t store_path_cost(struct
net_bridge
_port *p, unsigned long v)
+static ssize_t store_path_cost(struct
dp
_port *p, unsigned long v)
{
{
-#if 0
- br_stp_set_path_cost(p, v);
-#endif
return 0;
}
static BRPORT_ATTR(path_cost, S_IRUGO | S_IWUSR,
show_path_cost, store_path_cost);
return 0;
}
static BRPORT_ATTR(path_cost, S_IRUGO | S_IWUSR,
show_path_cost, store_path_cost);
-static ssize_t show_priority(struct
net_bridge
_port *p, char *buf)
+static ssize_t show_priority(struct
dp
_port *p, char *buf)
{
{
-#if 0
- return sprintf(buf, "%d\n", p->priority);
-#else
return sprintf(buf, "%d\n", 0);
return sprintf(buf, "%d\n", 0);
-#endif
}
}
-static ssize_t store_priority(struct
net_bridge
_port *p, unsigned long v)
+static ssize_t store_priority(struct
dp
_port *p, unsigned long v)
{
{
-#if 0
- if (v >= (1<<(16-BR_PORT_BITS)))
- return -ERANGE;
- br_stp_set_port_priority(p, v);
-#endif
return 0;
}
static BRPORT_ATTR(priority, S_IRUGO | S_IWUSR,
show_priority, store_priority);
return 0;
}
static BRPORT_ATTR(priority, S_IRUGO | S_IWUSR,
show_priority, store_priority);
-static ssize_t show_designated_root(struct
net_bridge
_port *p, char *buf)
+static ssize_t show_designated_root(struct
dp
_port *p, char *buf)
{
{
-#if 0
- return br_show_bridge_id(buf, &p->designated_root);
-#else
return sprintf(buf, "0000.010203040506\n");
return sprintf(buf, "0000.010203040506\n");
-#endif
}
static BRPORT_ATTR(designated_root, S_IRUGO, show_designated_root, NULL);
}
static BRPORT_ATTR(designated_root, S_IRUGO, show_designated_root, NULL);
-static ssize_t show_designated_bridge(struct
net_bridge
_port *p, char *buf)
+static ssize_t show_designated_bridge(struct
dp
_port *p, char *buf)
{
{
-#if 0
- return br_show_bridge_id(buf, &p->designated_bridge);
-#else
return sprintf(buf, "0000.060504030201\n");
return sprintf(buf, "0000.060504030201\n");
-#endif
}
static BRPORT_ATTR(designated_bridge, S_IRUGO, show_designated_bridge, NULL);
}
static BRPORT_ATTR(designated_bridge, S_IRUGO, show_designated_bridge, NULL);
-static ssize_t show_designated_port(struct
net_bridge
_port *p, char *buf)
+static ssize_t show_designated_port(struct
dp
_port *p, char *buf)
{
{
-#if 0
- return sprintf(buf, "%d\n", p->designated_port);
-#else
return sprintf(buf, "%d\n", 0);
return sprintf(buf, "%d\n", 0);
-#endif
}
static BRPORT_ATTR(designated_port, S_IRUGO, show_designated_port, NULL);
}
static BRPORT_ATTR(designated_port, S_IRUGO, show_designated_port, NULL);
-static ssize_t show_designated_cost(struct
net_bridge
_port *p, char *buf)
+static ssize_t show_designated_cost(struct
dp
_port *p, char *buf)
{
{
-#if 0
- return sprintf(buf, "%d\n", p->designated_cost);
-#else
return sprintf(buf, "%d\n", 0);
return sprintf(buf, "%d\n", 0);
-#endif
}
static BRPORT_ATTR(designated_cost, S_IRUGO, show_designated_cost, NULL);
}
static BRPORT_ATTR(designated_cost, S_IRUGO, show_designated_cost, NULL);
-static ssize_t show_port_id(struct
net_bridge
_port *p, char *buf)
+static ssize_t show_port_id(struct
dp
_port *p, char *buf)
{
{
-#if 0
- return sprintf(buf, "0x%x\n", p->port_id);
-#else
return sprintf(buf, "0x%x\n", 0);
return sprintf(buf, "0x%x\n", 0);
-#endif
}
static BRPORT_ATTR(port_id, S_IRUGO, show_port_id, NULL);
}
static BRPORT_ATTR(port_id, S_IRUGO, show_port_id, NULL);
-static ssize_t show_port_no(struct
net_bridge
_port *p, char *buf)
+static ssize_t show_port_no(struct
dp
_port *p, char *buf)
{
return sprintf(buf, "0x%x\n", p->port_no);
}
static BRPORT_ATTR(port_no, S_IRUGO, show_port_no, NULL);
{
return sprintf(buf, "0x%x\n", p->port_no);
}
static BRPORT_ATTR(port_no, S_IRUGO, show_port_no, NULL);
-static ssize_t show_change_ack(struct
net_bridge
_port *p, char *buf)
+static ssize_t show_change_ack(struct
dp
_port *p, char *buf)
{
{
-#if 0
- return sprintf(buf, "%d\n", p->topology_change_ack);
-#else
return sprintf(buf, "%d\n", 0);
return sprintf(buf, "%d\n", 0);
-#endif
}
static BRPORT_ATTR(change_ack, S_IRUGO, show_change_ack, NULL);
}
static BRPORT_ATTR(change_ack, S_IRUGO, show_change_ack, NULL);
-static ssize_t show_config_pending(struct
net_bridge
_port *p, char *buf)
+static ssize_t show_config_pending(struct
dp
_port *p, char *buf)
{
{
-#if 0
- return sprintf(buf, "%d\n", p->config_pending);
-#else
return sprintf(buf, "%d\n", 0);
return sprintf(buf, "%d\n", 0);
-#endif
}
static BRPORT_ATTR(config_pending, S_IRUGO, show_config_pending, NULL);
}
static BRPORT_ATTR(config_pending, S_IRUGO, show_config_pending, NULL);
-static ssize_t show_port_state(struct
net_bridge
_port *p, char *buf)
+static ssize_t show_port_state(struct
dp
_port *p, char *buf)
{
{
-#if 0
- return sprintf(buf, "%d\n", p->state);
-#else
return sprintf(buf, "%d\n", 0);
return sprintf(buf, "%d\n", 0);
-#endif
}
static BRPORT_ATTR(state, S_IRUGO, show_port_state, NULL);
}
static BRPORT_ATTR(state, S_IRUGO, show_port_state, NULL);
-static ssize_t show_message_age_timer(struct
net_bridge
_port *p,
+static ssize_t show_message_age_timer(struct
dp
_port *p,
char *buf)
{
char *buf)
{
-#if 0
- return sprintf(buf, "%ld\n", br_timer_value(&p->message_age_timer));
-#else
return sprintf(buf, "%d\n", 0);
return sprintf(buf, "%d\n", 0);
-#endif
}
static BRPORT_ATTR(message_age_timer, S_IRUGO, show_message_age_timer, NULL);
}
static BRPORT_ATTR(message_age_timer, S_IRUGO, show_message_age_timer, NULL);
-static ssize_t show_forward_delay_timer(struct
net_bridge
_port *p,
+static ssize_t show_forward_delay_timer(struct
dp
_port *p,
char *buf)
{
char *buf)
{
-#if 0
- return sprintf(buf, "%ld\n", br_timer_value(&p->forward_delay_timer));
-#else
return sprintf(buf, "%d\n", 0);
return sprintf(buf, "%d\n", 0);
-#endif
}
static BRPORT_ATTR(forward_delay_timer, S_IRUGO, show_forward_delay_timer, NULL);
}
static BRPORT_ATTR(forward_delay_timer, S_IRUGO, show_forward_delay_timer, NULL);
-static ssize_t show_hold_timer(struct
net_bridge
_port *p,
+static ssize_t show_hold_timer(struct
dp
_port *p,
char *buf)
{
char *buf)
{
-#if 0
- return sprintf(buf, "%ld\n", br_timer_value(&p->hold_timer));
-#else
return sprintf(buf, "%d\n", 0);
return sprintf(buf, "%d\n", 0);
-#endif
}
static BRPORT_ATTR(hold_timer, S_IRUGO, show_hold_timer, NULL);
}
static BRPORT_ATTR(hold_timer, S_IRUGO, show_hold_timer, NULL);
@@
-215,13
+156,13
@@
static struct brport_attribute *brport_attrs[] = {
};
#define to_brport_attr(_at) container_of(_at, struct brport_attribute, attr)
};
#define to_brport_attr(_at) container_of(_at, struct brport_attribute, attr)
-#define to_brport(obj) container_of(obj, struct
net_bridge
_port, kobj)
+#define to_brport(obj) container_of(obj, struct
dp
_port, kobj)
static ssize_t brport_show(struct kobject * kobj,
struct attribute * attr, char * buf)
{
struct brport_attribute * brport_attr = to_brport_attr(attr);
static ssize_t brport_show(struct kobject * kobj,
struct attribute * attr, char * buf)
{
struct brport_attribute * brport_attr = to_brport_attr(attr);
- struct
net_bridge
_port * p = to_brport(kobj);
+ struct
dp
_port * p = to_brport(kobj);
return brport_attr->show(p, buf);
}
return brport_attr->show(p, buf);
}
@@
-230,34
+171,15
@@
static ssize_t brport_store(struct kobject * kobj,
struct attribute * attr,
const char * buf, size_t count)
{
struct attribute * attr,
const char * buf, size_t count)
{
- struct net_bridge_port * p = to_brport(kobj);
-#if 0
- struct brport_attribute * brport_attr = to_brport_attr(attr);
- char *endp;
- unsigned long val;
-#endif
+ struct dp_port * p = to_brport(kobj);
ssize_t ret = -EINVAL;
if (!capable(CAP_NET_ADMIN))
return -EPERM;
ssize_t ret = -EINVAL;
if (!capable(CAP_NET_ADMIN))
return -EPERM;
-#if 0
- val = simple_strtoul(buf, &endp, 0);
- if (endp != buf) {
- rtnl_lock();
- if (p->dev && p->br && brport_attr->store) {
- spin_lock_bh(&p->br->lock);
- ret = brport_attr->store(p, val);
- spin_unlock_bh(&p->br->lock);
- if (ret == 0)
- ret = count;
- }
- rtnl_unlock();
- }
-#else
printk("%s: xxx writing port parms not supported yet!\n",
dp_name(p->dp));
printk("%s: xxx writing port parms not supported yet!\n",
dp_name(p->dp));
-#endif
+
return ret;
}
return ret;
}
@@
-266,44
+188,29
@@
struct sysfs_ops brport_sysfs_ops = {
.store = brport_store,
};
.store = brport_store,
};
-static void release_nbp(struct kobject *kobj)
-{
- struct net_bridge_port *p
- = container_of(kobj, struct net_bridge_port, kobj);
- kfree(p);
-}
-
-struct kobj_type brport_ktype = {
- .sysfs_ops = &brport_sysfs_ops,
- .release = release_nbp
-};
-
/*
* Add sysfs entries to ethernet device added to a bridge.
* Creates a brport subdirectory with bridge attributes.
* Puts symlink in bridge's brport subdirectory
*/
/*
* Add sysfs entries to ethernet device added to a bridge.
* Creates a brport subdirectory with bridge attributes.
* Puts symlink in bridge's brport subdirectory
*/
-int dp_sysfs_add_if(struct
net_bridge
_port *p)
+int dp_sysfs_add_if(struct
dp
_port *p)
{
{
+ struct kobject *kobj = vport_get_kobj(p->vport);
struct datapath *dp = p->dp;
struct brport_attribute **a;
int err;
/* Create /sys/class/net/<devname>/brport directory. */
struct datapath *dp = p->dp;
struct brport_attribute **a;
int err;
/* Create /sys/class/net/<devname>/brport directory. */
- kobject_init(&p->kobj);
- kobject_set_name(&p->kobj, SYSFS_BRIDGE_PORT_ATTR); /* "brport" */
- p->kobj.ktype = &brport_ktype;
- p->kobj.kset = NULL;
- p->kobj.parent = &(p->dev->class_dev.kobj);
+ if (!kobj)
+ return -ENOENT;
- err = kobject_add(&p->kobj);
+ err = kobject_add(&p->kobj
, kobj, SYSFS_BRIDGE_PORT_ATTR
);
if (err)
if (err)
- goto err
_put
;
+ goto err;
/* Create symlink from /sys/class/net/<devname>/brport/bridge to
* /sys/class/net/<bridgename>. */
/* Create symlink from /sys/class/net/<devname>/brport/bridge to
* /sys/class/net/<bridgename>. */
- err = sysfs_create_link(&p->kobj,
- &dp->ports[ODPP_LOCAL]->dev->class_dev.kobj,
+ err = sysfs_create_link(&p->kobj, vport_get_kobj(dp->ports[ODPP_LOCAL]->vport),
SYSFS_BRIDGE_PORT_LINK); /* "bridge" */
if (err)
goto err_del;
SYSFS_BRIDGE_PORT_LINK); /* "bridge" */
if (err)
goto err_del;
@@
-317,32
+224,30
@@
int dp_sysfs_add_if(struct net_bridge_port *p)
/* Create symlink from /sys/class/net/<bridgename>/brif/<devname> to
* /sys/class/net/<devname>/brport. */
/* Create symlink from /sys/class/net/<bridgename>/brif/<devname> to
* /sys/class/net/<devname>/brport. */
- err = sysfs_create_link(&dp->ifobj, &p->kobj,
p->dev->name
);
+ err = sysfs_create_link(&dp->ifobj, &p->kobj,
vport_get_name(p->vport)
);
if (err)
goto err_del;
if (err)
goto err_del;
+ strcpy(p->linkname, vport_get_name(p->vport));
kobject_uevent(&p->kobj, KOBJ_ADD);
kobject_uevent(&p->kobj, KOBJ_ADD);
- return
err
;
+ return
0
;
err_del:
kobject_del(&p->kobj);
err_del:
kobject_del(&p->kobj);
-err
_put
:
-
kobject_put(&p->kobj)
;
+err:
+
p->linkname[0] = 0
;
return err;
}
return err;
}
-int dp_sysfs_del_if(struct
net_bridge
_port *p)
+int dp_sysfs_del_if(struct
dp
_port *p)
{
{
- struct net_device *dev = p->dev;
-
- kobject_uevent(&p->kobj, KOBJ_REMOVE);
- kobject_del(&p->kobj);
-
- dev_put(dev);
-
- kobject_put(&p->kobj);
-
+ if (p->linkname[0]) {
+ sysfs_remove_link(&p->dp->ifobj, p->linkname);
+ kobject_uevent(&p->kobj, KOBJ_REMOVE);
+ kobject_del(&p->kobj);
+ p->linkname[0] = '\0';
+ }
return 0;
}
return 0;
}
-#endif /*
SUPPORT
_SYSFS */
+#endif /*
CONFIG
_SYSFS */