Release 4.7 drivers/net/bonding/bond_sysfs_slave.c
/* Sysfs attributes of bond slaves
*
* Copyright (c) 2014 Scott Feldman <sfeldma@cumulusnetworks.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version
* 2 of the License, or (at your option) any later version.
*/
#include <linux/capability.h>
#include <linux/kernel.h>
#include <linux/netdevice.h>
#include <net/bonding.h>
struct slave_attribute {
struct attribute attr;
ssize_t (*show)(struct slave *, char *);
};
#define SLAVE_ATTR(_name, _mode, _show) \
const struct slave_attribute slave_attr_##_name = { \
.attr = {.name = __stringify(_name), \
.mode = _mode }, \
.show = _show, \
};
#define SLAVE_ATTR_RO(_name) \
SLAVE_ATTR(_name, S_IRUGO, _name##_show)
static ssize_t state_show(struct slave *slave, char *buf)
{
switch (bond_slave_state(slave)) {
case BOND_STATE_ACTIVE:
return sprintf(buf, "active\n");
case BOND_STATE_BACKUP:
return sprintf(buf, "backup\n");
default:
return sprintf(buf, "UNKNOWN\n");
}
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
sfeldma at cumulusnetworks.com | sfeldma at cumulusnetworks.com | 54 | 98.18% | 1 | 50.00% |
masanari iida | masanari iida | 1 | 1.82% | 1 | 50.00% |
| Total | 55 | 100.00% | 2 | 100.00% |
static SLAVE_ATTR_RO(state);
static ssize_t mii_status_show(struct slave *slave, char *buf)
{
return sprintf(buf, "%s\n", bond_slave_link_status(slave->link));
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
sfeldma at cumulusnetworks.com | sfeldma at cumulusnetworks.com | 30 | 100.00% | 1 | 100.00% |
| Total | 30 | 100.00% | 1 | 100.00% |
static SLAVE_ATTR_RO(mii_status);
static ssize_t link_failure_count_show(struct slave *slave, char *buf)
{
return sprintf(buf, "%d\n", slave->link_failure_count);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
sfeldma at cumulusnetworks.com | sfeldma at cumulusnetworks.com | 27 | 100.00% | 1 | 100.00% |
| Total | 27 | 100.00% | 1 | 100.00% |
static SLAVE_ATTR_RO(link_failure_count);
static ssize_t perm_hwaddr_show(struct slave *slave, char *buf)
{
return sprintf(buf, "%pM\n", slave->perm_hwaddr);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
sfeldma at cumulusnetworks.com | sfeldma at cumulusnetworks.com | 27 | 100.00% | 1 | 100.00% |
| Total | 27 | 100.00% | 1 | 100.00% |
static SLAVE_ATTR_RO(perm_hwaddr);
static ssize_t queue_id_show(struct slave *slave, char *buf)
{
return sprintf(buf, "%d\n", slave->queue_id);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
sfeldma at cumulusnetworks.com | sfeldma at cumulusnetworks.com | 27 | 100.00% | 1 | 100.00% |
| Total | 27 | 100.00% | 1 | 100.00% |
static SLAVE_ATTR_RO(queue_id);
static ssize_t ad_aggregator_id_show(struct slave *slave, char *buf)
{
const struct aggregator *agg;
if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
agg = SLAVE_AD_INFO(slave)->port.aggregator;
if (agg)
return sprintf(buf, "%d\n",
agg->aggregator_identifier);
}
return sprintf(buf, "N/A\n");
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
sfeldma at cumulusnetworks.com | sfeldma at cumulusnetworks.com | 65 | 94.20% | 1 | 33.33% |
veaceslav falico | veaceslav falico | 3 | 4.35% | 1 | 33.33% |
ding tianhong | ding tianhong | 1 | 1.45% | 1 | 33.33% |
| Total | 69 | 100.00% | 3 | 100.00% |
static SLAVE_ATTR_RO(ad_aggregator_id);
static ssize_t ad_actor_oper_port_state_show(struct slave *slave, char *buf)
{
const struct port *ad_port;
if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
ad_port = &SLAVE_AD_INFO(slave)->port;
if (ad_port->aggregator)
return sprintf(buf, "%u\n",
ad_port->actor_oper_port_state);
}
return sprintf(buf, "N/A\n");
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nikolay aleksandrov | nikolay aleksandrov | 70 | 100.00% | 1 | 100.00% |
| Total | 70 | 100.00% | 1 | 100.00% |
static SLAVE_ATTR_RO(ad_actor_oper_port_state);
static ssize_t ad_partner_oper_port_state_show(struct slave *slave, char *buf)
{
const struct port *ad_port;
if (BOND_MODE(slave->bond) == BOND_MODE_8023AD) {
ad_port = &SLAVE_AD_INFO(slave)->port;
if (ad_port->aggregator)
return sprintf(buf, "%u\n",
ad_port->partner_oper.port_state);
}
return sprintf(buf, "N/A\n");
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
nikolay aleksandrov | nikolay aleksandrov | 72 | 100.00% | 1 | 100.00% |
| Total | 72 | 100.00% | 1 | 100.00% |
static SLAVE_ATTR_RO(ad_partner_oper_port_state);
static const struct slave_attribute *slave_attrs[] = {
&slave_attr_state,
&slave_attr_mii_status,
&slave_attr_link_failure_count,
&slave_attr_perm_hwaddr,
&slave_attr_queue_id,
&slave_attr_ad_aggregator_id,
&slave_attr_ad_actor_oper_port_state,
&slave_attr_ad_partner_oper_port_state,
NULL
};
#define to_slave_attr(_at) container_of(_at, struct slave_attribute, attr)
#define to_slave(obj) container_of(obj, struct slave, kobj)
static ssize_t slave_show(struct kobject *kobj,
struct attribute *attr, char *buf)
{
struct slave_attribute *slave_attr = to_slave_attr(attr);
struct slave *slave = to_slave(kobj);
return slave_attr->show(slave, buf);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
sfeldma at cumulusnetworks.com | sfeldma at cumulusnetworks.com | 50 | 100.00% | 1 | 100.00% |
| Total | 50 | 100.00% | 1 | 100.00% |
static const struct sysfs_ops slave_sysfs_ops = {
.show = slave_show,
};
static struct kobj_type slave_ktype = {
#ifdef CONFIG_SYSFS
.sysfs_ops = &slave_sysfs_ops,
#endif
};
int bond_sysfs_slave_add(struct slave *slave)
{
const struct slave_attribute **a;
int err;
err = kobject_init_and_add(&slave->kobj, &slave_ktype,
&(slave->dev->dev.kobj), "bonding_slave");
if (err)
return err;
for (a = slave_attrs; *a; ++a) {
err = sysfs_create_file(&slave->kobj, &((*a)->attr));
if (err) {
kobject_put(&slave->kobj);
return err;
}
}
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
sfeldma at cumulusnetworks.com | sfeldma at cumulusnetworks.com | 105 | 98.13% | 1 | 33.33% |
jiri pirko | jiri pirko | 1 | 0.93% | 1 | 33.33% |
veaceslav falico | veaceslav falico | 1 | 0.93% | 1 | 33.33% |
| Total | 107 | 100.00% | 3 | 100.00% |
void bond_sysfs_slave_del(struct slave *slave)
{
const struct slave_attribute **a;
for (a = slave_attrs; *a; ++a)
sysfs_remove_file(&slave->kobj, &((*a)->attr));
kobject_put(&slave->kobj);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
sfeldma at cumulusnetworks.com | sfeldma at cumulusnetworks.com | 54 | 98.18% | 1 | 50.00% |
veaceslav falico | veaceslav falico | 1 | 1.82% | 1 | 50.00% |
| Total | 55 | 100.00% | 2 | 100.00% |
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
sfeldma at cumulusnetworks.com | sfeldma at cumulusnetworks.com | 605 | 78.06% | 1 | 10.00% |
nikolay aleksandrov | nikolay aleksandrov | 160 | 20.65% | 2 | 20.00% |
veaceslav falico | veaceslav falico | 5 | 0.65% | 2 | 20.00% |
masanari iida | masanari iida | 1 | 0.13% | 1 | 10.00% |
stephen hemminger | stephen hemminger | 1 | 0.13% | 1 | 10.00% |
jiri pirko | jiri pirko | 1 | 0.13% | 1 | 10.00% |
david s. miller | david s. miller | 1 | 0.13% | 1 | 10.00% |
ding tianhong | ding tianhong | 1 | 0.13% | 1 | 10.00% |
| Total | 775 | 100.00% | 10 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.