All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 4/4] bonding: add sysfs files to display tlb and alb hash table contents
@ 2009-09-11 21:13 Andy Gospodarek
  2009-09-11 21:48 ` Jay Vosburgh
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Andy Gospodarek @ 2009-09-11 21:13 UTC (permalink / raw)
  To: netdev, fubar, bonding-devel


bonding: add sysfs files to display tlb and alb hash table contents

While debugging some problems with alb (mode 6) bonding I realized that
being able to output the contents of both hash tables would be helpful.
This is what the output looks like for the two files:

device  load
eth1    491
eth2    491
hash device   last device   tx bytes       load        next previous
2    eth1     eth1          2254           491         0    0
3    eth2     eth2          2744           491         0    0
6             eth2          0              488         0    0
8             eth2          0              461698      0    0
1b            eth2          0              249         0    0
eb            eth2          0              21          0    0
ff            eth2          0              22          0    0

hash ip_src          ip_dst          mac_dst           slave assign ntt
2    10.0.3.2        10.0.3.11       00:e0:81:71:ee:a9 eth1  1      0
3    10.0.3.2        10.0.3.10       00:e0:81:71:ee:a9 eth2  1      0
8    10.0.3.2        10.0.3.1        00:e0:81:71:ee:a9 eth2  1      0

These were a great help debugging the fixes I have just posted and they
might be helpful for others, so I decided to include them in my
patchset.

Signed-off-by: Andy Gospodarek <andy@greyhouse.net>

---
 drivers/net/bonding/bond_alb.c   |   61 ++++++++++++++++++++++++++++++++++++++
 drivers/net/bonding/bond_alb.h   |    2 +
 drivers/net/bonding/bond_sysfs.c |   40 +++++++++++++++++++++++++
 3 files changed, 103 insertions(+), 0 deletions(-)

diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 7db8835..4e930e3 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -778,6 +778,67 @@ static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)
 	return tx_slave;
 }
 
+int rlb_print_rx_hashtbl(struct bonding *bond, char *buf)
+{
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+	struct rlb_client_info *client_info;
+	u32 hash_index;
+	u32 count = 0;
+	
+	_lock_rx_hashtbl(bond);
+
+	count = sprintf(buf, "hash ip_src          ip_dst          mac_dst           slave assign ntt\n");
+	hash_index = bond_info->rx_hashtbl_head;
+	for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
+		client_info = &(bond_info->rx_hashtbl[hash_index]);
+		count += sprintf(buf + count,"%-4x %-15pi4 %-15pi4 %pM %-5s %-6d %d\n",
+				 hash_index,
+				 &client_info->ip_src,
+				 &client_info->ip_dst,
+				 client_info->mac_dst,
+				 client_info->slave->dev->name,
+				 client_info->assigned,
+				 client_info->ntt);
+	}
+
+	_unlock_rx_hashtbl(bond);
+	return count;
+}
+
+int tlb_print_tx_hashtbl(struct bonding *bond, char *buf)
+{
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+	u32 hash_index;
+	u32 count = 0;
+	struct slave *slave;
+	int i;
+	
+	_lock_tx_hashtbl(bond);
+
+	count += sprintf(buf, "device  load\n");
+	bond_for_each_slave(bond, slave, i) {
+		struct tlb_slave_info *slave_info = &(SLAVE_TLB_INFO(slave));
+		count += sprintf(buf + count,"%-7s %d\n",slave->dev->name,slave_info->load);
+	}
+	count += sprintf(buf + count, "hash device   last device   tx bytes       load        next previous\n");
+	for (hash_index = 0; hash_index < TLB_HASH_TABLE_SIZE; hash_index++) {
+		struct tlb_client_info *client_info = &(bond_info->tx_hashtbl[hash_index]);
+		if (client_info->tx_slave || client_info->last_slave) {
+			count += sprintf(buf + count,"%-4x %-8s %-13s %-14d %-11d %-4x %d\n",
+					 hash_index,
+					 (client_info->tx_slave) ? client_info->tx_slave->dev->name : "",
+					 (client_info->last_slave) ? client_info->last_slave->dev->name : "",
+					 client_info->tx_bytes,
+					 client_info->load_history,
+					 (client_info->next != TLB_NULL_INDEX) ? client_info->next : 0,
+					 (client_info->prev != TLB_NULL_INDEX) ? client_info->prev : 0);
+		}
+	}
+
+	_unlock_tx_hashtbl(bond);
+	return count;
+}
+
 /* Caller must hold rx_hashtbl lock */
 static void rlb_init_table_entry(struct rlb_client_info *entry)
 {
diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
index b65fd29..8543447 100644
--- a/drivers/net/bonding/bond_alb.h
+++ b/drivers/net/bonding/bond_alb.h
@@ -132,5 +132,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev);
 void bond_alb_monitor(struct work_struct *);
 int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr);
 void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id);
+int rlb_print_rx_hashtbl(struct bonding *bond, char *buf);
+int tlb_print_tx_hashtbl(struct bonding *bond, char *buf);
 #endif /* __BOND_ALB_H__ */
 
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 55bf34f..1123e1f 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -1480,6 +1480,44 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d,
 static DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL);
 
 
+/*
+ * Show current tlb/alb tx hash table.
+ */
+static ssize_t bonding_show_tlb_tx_hash(struct device *d,
+					   struct device_attribute *attr,
+					   char *buf)
+{
+	int count = 0;
+	struct bonding *bond = to_bond(d);
+
+	if (bond->params.mode == BOND_MODE_ALB ||
+	    bond->params.mode == BOND_MODE_TLB) {
+		count = tlb_print_tx_hashtbl(bond, buf);
+	}
+
+	return count;
+}
+static DEVICE_ATTR(tlb_tx_hash, S_IRUGO, bonding_show_tlb_tx_hash, NULL);
+
+
+/*
+ * Show current alb rx hash table.
+ */
+static ssize_t bonding_show_alb_rx_hash(struct device *d,
+					   struct device_attribute *attr,
+					   char *buf)
+{
+	int count = 0;
+	struct bonding *bond = to_bond(d);
+
+	if (bond->params.mode == BOND_MODE_ALB) {
+		count = rlb_print_rx_hashtbl(bond, buf);
+	}
+
+	return count;
+}
+static DEVICE_ATTR(alb_rx_hash, S_IRUGO, bonding_show_alb_rx_hash, NULL);
+
 
 static struct attribute *per_bond_attrs[] = {
 	&dev_attr_slaves.attr,
@@ -1505,6 +1543,8 @@ static struct attribute *per_bond_attrs[] = {
 	&dev_attr_ad_actor_key.attr,
 	&dev_attr_ad_partner_key.attr,
 	&dev_attr_ad_partner_mac.attr,
+	&dev_attr_alb_rx_hash.attr,
+	&dev_attr_tlb_tx_hash.attr,
 	NULL,
 };
 
-- 
1.5.5.6


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/4] bonding: add sysfs files to display tlb and alb hash table contents
  2009-09-11 21:13 [PATCH 4/4] bonding: add sysfs files to display tlb and alb hash table contents Andy Gospodarek
@ 2009-09-11 21:48 ` Jay Vosburgh
  2009-09-14 14:45   ` Andy Gospodarek
  2009-09-18 15:53 ` [PATCH 4/4 v2] " Andy Gospodarek
  2009-09-28 23:22 ` [Bonding-devel] [PATCH 4/4] " Stephen Hemminger
  2 siblings, 1 reply; 13+ messages in thread
From: Jay Vosburgh @ 2009-09-11 21:48 UTC (permalink / raw)
  To: Andy Gospodarek; +Cc: netdev, bonding-devel

Andy Gospodarek <andy@greyhouse.net> wrote:

>bonding: add sysfs files to display tlb and alb hash table contents

	Isn't it considered bad form to have sysfs files that kick out
large amounts of data like this?  Not that I think this is a bad
facility to have, just checking on the mechanism.

>While debugging some problems with alb (mode 6) bonding I realized that
>being able to output the contents of both hash tables would be helpful.
>This is what the output looks like for the two files:
>
>device  load
>eth1    491
>eth2    491
>hash device   last device   tx bytes       load        next previous
>2    eth1     eth1          2254           491         0    0
>3    eth2     eth2          2744           491         0    0
>6             eth2          0              488         0    0
>8             eth2          0              461698      0    0
>1b            eth2          0              249         0    0
>eb            eth2          0              21          0    0
>ff            eth2          0              22          0    0
>
>hash ip_src          ip_dst          mac_dst           slave assign ntt
>2    10.0.3.2        10.0.3.11       00:e0:81:71:ee:a9 eth1  1      0
>3    10.0.3.2        10.0.3.10       00:e0:81:71:ee:a9 eth2  1      0
>8    10.0.3.2        10.0.3.1        00:e0:81:71:ee:a9 eth2  1      0
>
>These were a great help debugging the fixes I have just posted and they
>might be helpful for others, so I decided to include them in my
>patchset.
>
>Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
>
>---
> drivers/net/bonding/bond_alb.c   |   61 ++++++++++++++++++++++++++++++++++++++
> drivers/net/bonding/bond_alb.h   |    2 +
> drivers/net/bonding/bond_sysfs.c |   40 +++++++++++++++++++++++++
> 3 files changed, 103 insertions(+), 0 deletions(-)
>
>diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
>index 7db8835..4e930e3 100644
>--- a/drivers/net/bonding/bond_alb.c
>+++ b/drivers/net/bonding/bond_alb.c
>@@ -778,6 +778,67 @@ static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)
> 	return tx_slave;
> }
>
>+int rlb_print_rx_hashtbl(struct bonding *bond, char *buf)
>+{
>+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
>+	struct rlb_client_info *client_info;
>+	u32 hash_index;
>+	u32 count = 0;
>+	
>+	_lock_rx_hashtbl(bond);
>+
>+	count = sprintf(buf, "hash ip_src          ip_dst          mac_dst           slave assign ntt\n");
>+	hash_index = bond_info->rx_hashtbl_head;
>+	for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
>+		client_info = &(bond_info->rx_hashtbl[hash_index]);
>+		count += sprintf(buf + count,"%-4x %-15pi4 %-15pi4 %pM %-5s %-6d %d\n",
>+				 hash_index,
>+				 &client_info->ip_src,
>+				 &client_info->ip_dst,
>+				 client_info->mac_dst,
>+				 client_info->slave->dev->name,
>+				 client_info->assigned,
>+				 client_info->ntt);
>+	}
>+
>+	_unlock_rx_hashtbl(bond);
>+	return count;
>+}
>+
>+int tlb_print_tx_hashtbl(struct bonding *bond, char *buf)
>+{
>+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
>+	u32 hash_index;
>+	u32 count = 0;
>+	struct slave *slave;
>+	int i;
>+	
>+	_lock_tx_hashtbl(bond);
>+
>+	count += sprintf(buf, "device  load\n");
>+	bond_for_each_slave(bond, slave, i) {
>+		struct tlb_slave_info *slave_info = &(SLAVE_TLB_INFO(slave));
>+		count += sprintf(buf + count,"%-7s %d\n",slave->dev->name,slave_info->load);
>+	}
>+	count += sprintf(buf + count, "hash device   last device   tx bytes       load        next previous\n");
>+	for (hash_index = 0; hash_index < TLB_HASH_TABLE_SIZE; hash_index++) {
>+		struct tlb_client_info *client_info = &(bond_info->tx_hashtbl[hash_index]);
>+		if (client_info->tx_slave || client_info->last_slave) {
>+			count += sprintf(buf + count,"%-4x %-8s %-13s %-14d %-11d %-4x %d\n",
>+					 hash_index,
>+					 (client_info->tx_slave) ? client_info->tx_slave->dev->name : "",
>+					 (client_info->last_slave) ? client_info->last_slave->dev->name : "",
>+					 client_info->tx_bytes,
>+					 client_info->load_history,
>+					 (client_info->next != TLB_NULL_INDEX) ? client_info->next : 0,
>+					 (client_info->prev != TLB_NULL_INDEX) ? client_info->prev : 0);
>+		}
>+	}
>+
>+	_unlock_tx_hashtbl(bond);
>+	return count;
>+}
>+
> /* Caller must hold rx_hashtbl lock */
> static void rlb_init_table_entry(struct rlb_client_info *entry)
> {
>diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
>index b65fd29..8543447 100644
>--- a/drivers/net/bonding/bond_alb.h
>+++ b/drivers/net/bonding/bond_alb.h
>@@ -132,5 +132,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev);
> void bond_alb_monitor(struct work_struct *);
> int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr);
> void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id);
>+int rlb_print_rx_hashtbl(struct bonding *bond, char *buf);
>+int tlb_print_tx_hashtbl(struct bonding *bond, char *buf);
> #endif /* __BOND_ALB_H__ */
>
>diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
>index 55bf34f..1123e1f 100644
>--- a/drivers/net/bonding/bond_sysfs.c
>+++ b/drivers/net/bonding/bond_sysfs.c
>@@ -1480,6 +1480,44 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d,
> static DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL);
>
>
>+/*
>+ * Show current tlb/alb tx hash table.
>+ */
>+static ssize_t bonding_show_tlb_tx_hash(struct device *d,
>+					   struct device_attribute *attr,
>+					   char *buf)
>+{
>+	int count = 0;
>+	struct bonding *bond = to_bond(d);
>+
>+	if (bond->params.mode == BOND_MODE_ALB ||
>+	    bond->params.mode == BOND_MODE_TLB) {
>+		count = tlb_print_tx_hashtbl(bond, buf);
>+	}
>+
>+	return count;
>+}
>+static DEVICE_ATTR(tlb_tx_hash, S_IRUGO, bonding_show_tlb_tx_hash, NULL);

	Should the mode here be S_IRUSR (0400, instead of 0444)?
Otherwise, a nefarious user could "while 1 cat /sys/.../tlb_tx_hash" and
keep the hash table lock fairly busy.  Since the lock is acquired for
every packet on tx, that's probably a bad thing.

>+
>+/*
>+ * Show current alb rx hash table.
>+ */
>+static ssize_t bonding_show_alb_rx_hash(struct device *d,
>+					   struct device_attribute *attr,
>+					   char *buf)
>+{
>+	int count = 0;
>+	struct bonding *bond = to_bond(d);
>+
>+	if (bond->params.mode == BOND_MODE_ALB) {
>+		count = rlb_print_rx_hashtbl(bond, buf);
>+	}
>+
>+	return count;
>+}
>+static DEVICE_ATTR(alb_rx_hash, S_IRUGO, bonding_show_alb_rx_hash, NULL);

	Same comment as for the mode of the tlb_tx_hash, although the rx
hash table lock is much more lightly used, so it might not be a real
problem.

>
> static struct attribute *per_bond_attrs[] = {
> 	&dev_attr_slaves.attr,
>@@ -1505,6 +1543,8 @@ static struct attribute *per_bond_attrs[] = {
> 	&dev_attr_ad_actor_key.attr,
> 	&dev_attr_ad_partner_key.attr,
> 	&dev_attr_ad_partner_mac.attr,
>+	&dev_attr_alb_rx_hash.attr,
>+	&dev_attr_tlb_tx_hash.attr,
> 	NULL,
> };
>
>-- 
>1.5.5.6
>

	-J

---
	-Jay Vosburgh, IBM Linux Technology Center, fubar@us.ibm.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/4] bonding: add sysfs files to display tlb and alb hash table contents
  2009-09-11 21:48 ` Jay Vosburgh
@ 2009-09-14 14:45   ` Andy Gospodarek
  2009-09-14 19:37     ` [Bonding-devel] " Nicolas de Pesloüan
  0 siblings, 1 reply; 13+ messages in thread
From: Andy Gospodarek @ 2009-09-14 14:45 UTC (permalink / raw)
  To: Jay Vosburgh; +Cc: Andy Gospodarek, netdev, bonding-devel

On Fri, Sep 11, 2009 at 02:48:17PM -0700, Jay Vosburgh wrote:
> Andy Gospodarek <andy@greyhouse.net> wrote:
> 
> >bonding: add sysfs files to display tlb and alb hash table contents
> 
> 	Isn't it considered bad form to have sysfs files that kick out
> large amounts of data like this?  Not that I think this is a bad
> facility to have, just checking on the mechanism.
> 

I'm not aware of such a restriction -- though I'm sure at least one
person out there doesn't like it.

If that's the case, there are certainly a few files that should be
cleaned up:

# find -type f -exec wc -l {} 2> /dev/null \; | sort -r -n | head -10
1657 ./firmware/acpi/tables/SSDT
132 ./firmware/acpi/tables/dynamic/SSDT2
128 ./devices/pci0000:00/0000:00:1c.5/0000:3f:00.0/vpd
27 ./devices/system/node/node0/meminfo
24 ./devices/pnp0/00:08/options
24 ./devices/pnp0/00:07/options
12 ./devices/pci0000:00/0000:00:1e.0/resource
12 ./devices/pci0000:00/0000:00:1c.5/resource
12 ./devices/pci0000:00/0000:00:1c.4/resource
12 ./devices/pci0000:00/0000:00:1c.0/resource


> >While debugging some problems with alb (mode 6) bonding I realized that
> >being able to output the contents of both hash tables would be helpful.
> >This is what the output looks like for the two files:
> >
> >device  load
> >eth1    491
> >eth2    491
> >hash device   last device   tx bytes       load        next previous
> >2    eth1     eth1          2254           491         0    0
> >3    eth2     eth2          2744           491         0    0
> >6             eth2          0              488         0    0
> >8             eth2          0              461698      0    0
> >1b            eth2          0              249         0    0
> >eb            eth2          0              21          0    0
> >ff            eth2          0              22          0    0
> >
> >hash ip_src          ip_dst          mac_dst           slave assign ntt
> >2    10.0.3.2        10.0.3.11       00:e0:81:71:ee:a9 eth1  1      0
> >3    10.0.3.2        10.0.3.10       00:e0:81:71:ee:a9 eth2  1      0
> >8    10.0.3.2        10.0.3.1        00:e0:81:71:ee:a9 eth2  1      0
> >
> >These were a great help debugging the fixes I have just posted and they
> >might be helpful for others, so I decided to include them in my
> >patchset.
> >
> >Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
> >
> >---
> > drivers/net/bonding/bond_alb.c   |   61 ++++++++++++++++++++++++++++++++++++++
> > drivers/net/bonding/bond_alb.h   |    2 +
> > drivers/net/bonding/bond_sysfs.c |   40 +++++++++++++++++++++++++
> > 3 files changed, 103 insertions(+), 0 deletions(-)
> >
> >diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
> >index 7db8835..4e930e3 100644
> >--- a/drivers/net/bonding/bond_alb.c
> >+++ b/drivers/net/bonding/bond_alb.c
> >@@ -778,6 +778,67 @@ static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)
> > 	return tx_slave;
> > }
> >
> >+int rlb_print_rx_hashtbl(struct bonding *bond, char *buf)
> >+{
> >+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
> >+	struct rlb_client_info *client_info;
> >+	u32 hash_index;
> >+	u32 count = 0;
> >+	
> >+	_lock_rx_hashtbl(bond);
> >+
> >+	count = sprintf(buf, "hash ip_src          ip_dst          mac_dst           slave assign ntt\n");
> >+	hash_index = bond_info->rx_hashtbl_head;
> >+	for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
> >+		client_info = &(bond_info->rx_hashtbl[hash_index]);
> >+		count += sprintf(buf + count,"%-4x %-15pi4 %-15pi4 %pM %-5s %-6d %d\n",
> >+				 hash_index,
> >+				 &client_info->ip_src,
> >+				 &client_info->ip_dst,
> >+				 client_info->mac_dst,
> >+				 client_info->slave->dev->name,
> >+				 client_info->assigned,
> >+				 client_info->ntt);
> >+	}
> >+
> >+	_unlock_rx_hashtbl(bond);
> >+	return count;
> >+}
> >+
> >+int tlb_print_tx_hashtbl(struct bonding *bond, char *buf)
> >+{
> >+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
> >+	u32 hash_index;
> >+	u32 count = 0;
> >+	struct slave *slave;
> >+	int i;
> >+	
> >+	_lock_tx_hashtbl(bond);
> >+
> >+	count += sprintf(buf, "device  load\n");
> >+	bond_for_each_slave(bond, slave, i) {
> >+		struct tlb_slave_info *slave_info = &(SLAVE_TLB_INFO(slave));
> >+		count += sprintf(buf + count,"%-7s %d\n",slave->dev->name,slave_info->load);
> >+	}
> >+	count += sprintf(buf + count, "hash device   last device   tx bytes       load        next previous\n");
> >+	for (hash_index = 0; hash_index < TLB_HASH_TABLE_SIZE; hash_index++) {
> >+		struct tlb_client_info *client_info = &(bond_info->tx_hashtbl[hash_index]);
> >+		if (client_info->tx_slave || client_info->last_slave) {
> >+			count += sprintf(buf + count,"%-4x %-8s %-13s %-14d %-11d %-4x %d\n",
> >+					 hash_index,
> >+					 (client_info->tx_slave) ? client_info->tx_slave->dev->name : "",
> >+					 (client_info->last_slave) ? client_info->last_slave->dev->name : "",
> >+					 client_info->tx_bytes,
> >+					 client_info->load_history,
> >+					 (client_info->next != TLB_NULL_INDEX) ? client_info->next : 0,
> >+					 (client_info->prev != TLB_NULL_INDEX) ? client_info->prev : 0);
> >+		}
> >+	}
> >+
> >+	_unlock_tx_hashtbl(bond);
> >+	return count;
> >+}
> >+
> > /* Caller must hold rx_hashtbl lock */
> > static void rlb_init_table_entry(struct rlb_client_info *entry)
> > {
> >diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
> >index b65fd29..8543447 100644
> >--- a/drivers/net/bonding/bond_alb.h
> >+++ b/drivers/net/bonding/bond_alb.h
> >@@ -132,5 +132,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev);
> > void bond_alb_monitor(struct work_struct *);
> > int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr);
> > void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id);
> >+int rlb_print_rx_hashtbl(struct bonding *bond, char *buf);
> >+int tlb_print_tx_hashtbl(struct bonding *bond, char *buf);
> > #endif /* __BOND_ALB_H__ */
> >
> >diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
> >index 55bf34f..1123e1f 100644
> >--- a/drivers/net/bonding/bond_sysfs.c
> >+++ b/drivers/net/bonding/bond_sysfs.c
> >@@ -1480,6 +1480,44 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d,
> > static DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL);
> >
> >
> >+/*
> >+ * Show current tlb/alb tx hash table.
> >+ */
> >+static ssize_t bonding_show_tlb_tx_hash(struct device *d,
> >+					   struct device_attribute *attr,
> >+					   char *buf)
> >+{
> >+	int count = 0;
> >+	struct bonding *bond = to_bond(d);
> >+
> >+	if (bond->params.mode == BOND_MODE_ALB ||
> >+	    bond->params.mode == BOND_MODE_TLB) {
> >+		count = tlb_print_tx_hashtbl(bond, buf);
> >+	}
> >+
> >+	return count;
> >+}
> >+static DEVICE_ATTR(tlb_tx_hash, S_IRUGO, bonding_show_tlb_tx_hash, NULL);
> 
> 	Should the mode here be S_IRUSR (0400, instead of 0444)?
> Otherwise, a nefarious user could "while 1 cat /sys/.../tlb_tx_hash" and
> keep the hash table lock fairly busy.  Since the lock is acquired for
> every packet on tx, that's probably a bad thing.
> 
> >+
> >+/*
> >+ * Show current alb rx hash table.
> >+ */
> >+static ssize_t bonding_show_alb_rx_hash(struct device *d,
> >+					   struct device_attribute *attr,
> >+					   char *buf)
> >+{
> >+	int count = 0;
> >+	struct bonding *bond = to_bond(d);
> >+
> >+	if (bond->params.mode == BOND_MODE_ALB) {
> >+		count = rlb_print_rx_hashtbl(bond, buf);
> >+	}
> >+
> >+	return count;
> >+}
> >+static DEVICE_ATTR(alb_rx_hash, S_IRUGO, bonding_show_alb_rx_hash, NULL);
> 
> 	Same comment as for the mode of the tlb_tx_hash, although the rx
> hash table lock is much more lightly used, so it might not be a real
> problem.
> 
> >
> > static struct attribute *per_bond_attrs[] = {
> > 	&dev_attr_slaves.attr,
> >@@ -1505,6 +1543,8 @@ static struct attribute *per_bond_attrs[] = {
> > 	&dev_attr_ad_actor_key.attr,
> > 	&dev_attr_ad_partner_key.attr,
> > 	&dev_attr_ad_partner_mac.attr,
> >+	&dev_attr_alb_rx_hash.attr,
> >+	&dev_attr_tlb_tx_hash.attr,
> > 	NULL,
> > };
> >
> >-- 
> >1.5.5.6
> >
> 
> 	-J
> 
> ---
> 	-Jay Vosburgh, IBM Linux Technology Center, fubar@us.ibm.com
> --
> 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	[flat|nested] 13+ messages in thread

* Re: [Bonding-devel] [PATCH 4/4] bonding: add sysfs files to display tlb and alb hash table contents
  2009-09-14 14:45   ` Andy Gospodarek
@ 2009-09-14 19:37     ` Nicolas de Pesloüan
  0 siblings, 0 replies; 13+ messages in thread
From: Nicolas de Pesloüan @ 2009-09-14 19:37 UTC (permalink / raw)
  To: Andy Gospodarek; +Cc: Jay Vosburgh, netdev, bonding-devel

Andy Gospodarek wrote:
> On Fri, Sep 11, 2009 at 02:48:17PM -0700, Jay Vosburgh wrote:
>> Andy Gospodarek <andy@greyhouse.net> wrote:
>>
>>> bonding: add sysfs files to display tlb and alb hash table contents
>> 	Isn't it considered bad form to have sysfs files that kick out
>> large amounts of data like this?  Not that I think this is a bad
>> facility to have, just checking on the mechanism.
>>
> 
> I'm not aware of such a restriction -- though I'm sure at least one
> person out there doesn't like it.

In Documentation/filesystems/sysfs.txt:

"Attributes should be ASCII text files, preferably with only one value
per file. It is noted that it may not be efficient to contain only one
value per file, so it is socially acceptable to express an array of
values of the same type.

Mixing types, expressing multiple lines of data, and doing fancy
formatting of data is heavily frowned upon. Doing these things may get
you publically humiliated and your code rewritten without notice."

Apparently, thinks are becoming more relaxed these days.

	Nicolas.

> If that's the case, there are certainly a few files that should be
> cleaned up:
> 
> # find -type f -exec wc -l {} 2> /dev/null \; | sort -r -n | head -10
> 1657 ./firmware/acpi/tables/SSDT
> 132 ./firmware/acpi/tables/dynamic/SSDT2
> 128 ./devices/pci0000:00/0000:00:1c.5/0000:3f:00.0/vpd
> 27 ./devices/system/node/node0/meminfo
> 24 ./devices/pnp0/00:08/options
> 24 ./devices/pnp0/00:07/options
> 12 ./devices/pci0000:00/0000:00:1e.0/resource
> 12 ./devices/pci0000:00/0000:00:1c.5/resource
> 12 ./devices/pci0000:00/0000:00:1c.4/resource
> 12 ./devices/pci0000:00/0000:00:1c.0/resource


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/4 v2] bonding: add sysfs files to display tlb and alb hash table contents
  2009-09-11 21:13 [PATCH 4/4] bonding: add sysfs files to display tlb and alb hash table contents Andy Gospodarek
  2009-09-11 21:48 ` Jay Vosburgh
@ 2009-09-18 15:53 ` Andy Gospodarek
  2009-09-28 22:01   ` Andy Gospodarek
  2009-09-28 23:22 ` [Bonding-devel] [PATCH 4/4] " Stephen Hemminger
  2 siblings, 1 reply; 13+ messages in thread
From: Andy Gospodarek @ 2009-09-18 15:53 UTC (permalink / raw)
  To: netdev, fubar, bonding-devel

On Fri, Sep 11, 2009 at 05:13:17PM -0400, Andy Gospodarek wrote:
> 
> bonding: add sysfs files to display tlb and alb hash table contents
> 
> While debugging some problems with alb (mode 6) bonding I realized that
> being able to output the contents of both hash tables would be helpful.
> This is what the output looks like for the two files:
> 
> device  load
> eth1    491
> eth2    491
> hash device   last device   tx bytes       load        next previous
> 2    eth1     eth1          2254           491         0    0
> 3    eth2     eth2          2744           491         0    0
> 6             eth2          0              488         0    0
> 8             eth2          0              461698      0    0
> 1b            eth2          0              249         0    0
> eb            eth2          0              21          0    0
> ff            eth2          0              22          0    0
> 
> hash ip_src          ip_dst          mac_dst           slave assign ntt
> 2    10.0.3.2        10.0.3.11       00:e0:81:71:ee:a9 eth1  1      0
> 3    10.0.3.2        10.0.3.10       00:e0:81:71:ee:a9 eth2  1      0
> 8    10.0.3.2        10.0.3.1        00:e0:81:71:ee:a9 eth2  1      0
> 
> These were a great help debugging the fixes I have just posted and they
> might be helpful for others, so I decided to include them in my
> patchset.
> 
> Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
> 

Needed to repost since patch 2/4 changed and first patch had whitespace
issues:

[PATCH v2] bonding: add sysfs files to display tlb and alb hash table contents

While debugging some problems with alb (mode 6) bonding I realized that
being able to output the contents of both hash tables would be helpful.
This is what the output looks like for the two files:

device  load
eth1    491
eth2    491
hash device   last device   tx bytes       load        next previous
2    eth1     eth1          2254           491         0    0
3    eth2     eth2          2744           491         0    0
6             eth2          0              488         0    0
8             eth2          0              461698      0    0
1b            eth2          0              249         0    0
eb            eth2          0              21          0    0
ff            eth2          0              22          0    0

hash ip_src          ip_dst          mac_dst           slave assign ntt
2    10.0.3.2        10.0.3.11       00:e0:81:71:ee:a9 eth1  1      0
3    10.0.3.2        10.0.3.10       00:e0:81:71:ee:a9 eth2  1      0
8    10.0.3.2        10.0.3.1        00:e0:81:71:ee:a9 eth2  1      0

These were a great help debugging the fixes I have just posted and they
might be helpful for others, so I decided to include them in my post.

Signed-off-by: Andy Gospodarek <andy@greyhouse.net>

---
 drivers/net/bonding/bond_alb.c   |   61 ++++++++++++++++++++++++++++++++++++++
 drivers/net/bonding/bond_alb.h   |    2 +
 drivers/net/bonding/bond_sysfs.c |   40 +++++++++++++++++++++++++
 3 files changed, 103 insertions(+), 0 deletions(-)

diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
index 5d51489..adc5acd 100644
--- a/drivers/net/bonding/bond_alb.c
+++ b/drivers/net/bonding/bond_alb.c
@@ -750,6 +750,67 @@ static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)
 	return tx_slave;
 }
 
+int rlb_print_rx_hashtbl(struct bonding *bond, char *buf)
+{
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+	struct rlb_client_info *client_info;
+	u32 hash_index;
+	u32 count = 0;
+
+	_lock_hashtbl(bond);
+
+	count = sprintf(buf, "hash ip_src          ip_dst          mac_dst           slave assign ntt\n");
+	hash_index = bond_info->rx_hashtbl_head;
+	for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
+		client_info = &(bond_info->rx_hashtbl[hash_index]);
+		count += sprintf(buf + count,"%-4x %-15pi4 %-15pi4 %pM %-5s %-6d %d\n",
+				 hash_index,
+				 &client_info->ip_src,
+				 &client_info->ip_dst,
+				 client_info->mac_dst,
+				 client_info->slave->dev->name,
+				 client_info->assigned,
+				 client_info->ntt);
+	}
+
+	_unlock_hashtbl(bond);
+	return count;
+}
+
+int tlb_print_tx_hashtbl(struct bonding *bond, char *buf)
+{
+	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
+	u32 hash_index;
+	u32 count = 0;
+	struct slave *slave;
+	int i;
+
+	_lock_hashtbl(bond);
+
+	count += sprintf(buf, "device  load\n");
+	bond_for_each_slave(bond, slave, i) {
+		struct tlb_slave_info *slave_info = &(SLAVE_TLB_INFO(slave));
+		count += sprintf(buf + count,"%-7s %d\n",slave->dev->name,slave_info->load);
+	}
+	count += sprintf(buf + count, "hash device   last device   tx bytes       load        next previous\n");
+	for (hash_index = 0; hash_index < TLB_HASH_TABLE_SIZE; hash_index++) {
+		struct tlb_client_info *client_info = &(bond_info->tx_hashtbl[hash_index]);
+		if (client_info->tx_slave || client_info->last_slave) {
+			count += sprintf(buf + count,"%-4x %-8s %-13s %-14d %-11d %-4x %d\n",
+					 hash_index,
+					 (client_info->tx_slave) ? client_info->tx_slave->dev->name : "",
+					 (client_info->last_slave) ? client_info->last_slave->dev->name : "",
+					 client_info->tx_bytes,
+					 client_info->load_history,
+					 (client_info->next != TLB_NULL_INDEX) ? client_info->next : 0,
+					 (client_info->prev != TLB_NULL_INDEX) ? client_info->prev : 0);
+		}
+	}
+
+	_unlock_hashtbl(bond);
+	return count;
+}
+
 /* Caller must hold rx_hashtbl lock */
 static void rlb_init_table_entry(struct rlb_client_info *entry)
 {
diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
index 09d755a..57e761b 100644
--- a/drivers/net/bonding/bond_alb.h
+++ b/drivers/net/bonding/bond_alb.h
@@ -131,5 +131,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev);
 void bond_alb_monitor(struct work_struct *);
 int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr);
 void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id);
+int rlb_print_rx_hashtbl(struct bonding *bond, char *buf);
+int tlb_print_tx_hashtbl(struct bonding *bond, char *buf);
 #endif /* __BOND_ALB_H__ */
 
diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
index 55bf34f..1123e1f 100644
--- a/drivers/net/bonding/bond_sysfs.c
+++ b/drivers/net/bonding/bond_sysfs.c
@@ -1480,6 +1480,44 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d,
 static DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL);
 
 
+/*
+ * Show current tlb/alb tx hash table.
+ */
+static ssize_t bonding_show_tlb_tx_hash(struct device *d,
+					   struct device_attribute *attr,
+					   char *buf)
+{
+	int count = 0;
+	struct bonding *bond = to_bond(d);
+
+	if (bond->params.mode == BOND_MODE_ALB ||
+	    bond->params.mode == BOND_MODE_TLB) {
+		count = tlb_print_tx_hashtbl(bond, buf);
+	}
+
+	return count;
+}
+static DEVICE_ATTR(tlb_tx_hash, S_IRUGO, bonding_show_tlb_tx_hash, NULL);
+
+
+/*
+ * Show current alb rx hash table.
+ */
+static ssize_t bonding_show_alb_rx_hash(struct device *d,
+					   struct device_attribute *attr,
+					   char *buf)
+{
+	int count = 0;
+	struct bonding *bond = to_bond(d);
+
+	if (bond->params.mode == BOND_MODE_ALB) {
+		count = rlb_print_rx_hashtbl(bond, buf);
+	}
+
+	return count;
+}
+static DEVICE_ATTR(alb_rx_hash, S_IRUGO, bonding_show_alb_rx_hash, NULL);
+
 
 static struct attribute *per_bond_attrs[] = {
 	&dev_attr_slaves.attr,
@@ -1505,6 +1543,8 @@ static struct attribute *per_bond_attrs[] = {
 	&dev_attr_ad_actor_key.attr,
 	&dev_attr_ad_partner_key.attr,
 	&dev_attr_ad_partner_mac.attr,
+	&dev_attr_alb_rx_hash.attr,
+	&dev_attr_tlb_tx_hash.attr,
 	NULL,
 };
 
-- 
1.5.5.6


^ permalink raw reply related	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/4 v2] bonding: add sysfs files to display tlb and alb hash table contents
  2009-09-18 15:53 ` [PATCH 4/4 v2] " Andy Gospodarek
@ 2009-09-28 22:01   ` Andy Gospodarek
  2009-09-28 22:06     ` Jay Vosburgh
  0 siblings, 1 reply; 13+ messages in thread
From: Andy Gospodarek @ 2009-09-28 22:01 UTC (permalink / raw)
  To: netdev, fubar, bonding-devel

On Fri, Sep 18, 2009 at 11:53:11AM -0400, Andy Gospodarek wrote:
> On Fri, Sep 11, 2009 at 05:13:17PM -0400, Andy Gospodarek wrote:
> > 
> > bonding: add sysfs files to display tlb and alb hash table contents
> > 
> > While debugging some problems with alb (mode 6) bonding I realized that
> > being able to output the contents of both hash tables would be helpful.
> > This is what the output looks like for the two files:
> > 
> > device  load
> > eth1    491
> > eth2    491
> > hash device   last device   tx bytes       load        next previous
> > 2    eth1     eth1          2254           491         0    0
> > 3    eth2     eth2          2744           491         0    0
> > 6             eth2          0              488         0    0
> > 8             eth2          0              461698      0    0
> > 1b            eth2          0              249         0    0
> > eb            eth2          0              21          0    0
> > ff            eth2          0              22          0    0
> > 
> > hash ip_src          ip_dst          mac_dst           slave assign ntt
> > 2    10.0.3.2        10.0.3.11       00:e0:81:71:ee:a9 eth1  1      0
> > 3    10.0.3.2        10.0.3.10       00:e0:81:71:ee:a9 eth2  1      0
> > 8    10.0.3.2        10.0.3.1        00:e0:81:71:ee:a9 eth2  1      0
> > 
> > These were a great help debugging the fixes I have just posted and they
> > might be helpful for others, so I decided to include them in my
> > patchset.
> > 
> > Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
> > 
> 
> Needed to repost since patch 2/4 changed and first patch had whitespace
> issues:
> 
> [PATCH v2] bonding: add sysfs files to display tlb and alb hash table contents
> 
> While debugging some problems with alb (mode 6) bonding I realized that
> being able to output the contents of both hash tables would be helpful.
> This is what the output looks like for the two files:
> 
> device  load
> eth1    491
> eth2    491
> hash device   last device   tx bytes       load        next previous
> 2    eth1     eth1          2254           491         0    0
> 3    eth2     eth2          2744           491         0    0
> 6             eth2          0              488         0    0
> 8             eth2          0              461698      0    0
> 1b            eth2          0              249         0    0
> eb            eth2          0              21          0    0
> ff            eth2          0              22          0    0
> 
> hash ip_src          ip_dst          mac_dst           slave assign ntt
> 2    10.0.3.2        10.0.3.11       00:e0:81:71:ee:a9 eth1  1      0
> 3    10.0.3.2        10.0.3.10       00:e0:81:71:ee:a9 eth2  1      0
> 8    10.0.3.2        10.0.3.1        00:e0:81:71:ee:a9 eth2  1      0
> 
> These were a great help debugging the fixes I have just posted and they
> might be helpful for others, so I decided to include them in my post.
> 
> Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
> 
> ---
>  drivers/net/bonding/bond_alb.c   |   61 ++++++++++++++++++++++++++++++++++++++
>  drivers/net/bonding/bond_alb.h   |    2 +
>  drivers/net/bonding/bond_sysfs.c |   40 +++++++++++++++++++++++++
>  3 files changed, 103 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
> index 5d51489..adc5acd 100644
> --- a/drivers/net/bonding/bond_alb.c
> +++ b/drivers/net/bonding/bond_alb.c
> @@ -750,6 +750,67 @@ static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)
>  	return tx_slave;
>  }
>  
> +int rlb_print_rx_hashtbl(struct bonding *bond, char *buf)
> +{
> +	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
> +	struct rlb_client_info *client_info;
> +	u32 hash_index;
> +	u32 count = 0;
> +
> +	_lock_hashtbl(bond);
> +
> +	count = sprintf(buf, "hash ip_src          ip_dst          mac_dst           slave assign ntt\n");
> +	hash_index = bond_info->rx_hashtbl_head;
> +	for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
> +		client_info = &(bond_info->rx_hashtbl[hash_index]);
> +		count += sprintf(buf + count,"%-4x %-15pi4 %-15pi4 %pM %-5s %-6d %d\n",
> +				 hash_index,
> +				 &client_info->ip_src,
> +				 &client_info->ip_dst,
> +				 client_info->mac_dst,
> +				 client_info->slave->dev->name,
> +				 client_info->assigned,
> +				 client_info->ntt);
> +	}
> +
> +	_unlock_hashtbl(bond);
> +	return count;
> +}
> +
> +int tlb_print_tx_hashtbl(struct bonding *bond, char *buf)
> +{
> +	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
> +	u32 hash_index;
> +	u32 count = 0;
> +	struct slave *slave;
> +	int i;
> +
> +	_lock_hashtbl(bond);
> +
> +	count += sprintf(buf, "device  load\n");
> +	bond_for_each_slave(bond, slave, i) {
> +		struct tlb_slave_info *slave_info = &(SLAVE_TLB_INFO(slave));
> +		count += sprintf(buf + count,"%-7s %d\n",slave->dev->name,slave_info->load);
> +	}
> +	count += sprintf(buf + count, "hash device   last device   tx bytes       load        next previous\n");
> +	for (hash_index = 0; hash_index < TLB_HASH_TABLE_SIZE; hash_index++) {
> +		struct tlb_client_info *client_info = &(bond_info->tx_hashtbl[hash_index]);
> +		if (client_info->tx_slave || client_info->last_slave) {
> +			count += sprintf(buf + count,"%-4x %-8s %-13s %-14d %-11d %-4x %d\n",
> +					 hash_index,
> +					 (client_info->tx_slave) ? client_info->tx_slave->dev->name : "",
> +					 (client_info->last_slave) ? client_info->last_slave->dev->name : "",
> +					 client_info->tx_bytes,
> +					 client_info->load_history,
> +					 (client_info->next != TLB_NULL_INDEX) ? client_info->next : 0,
> +					 (client_info->prev != TLB_NULL_INDEX) ? client_info->prev : 0);
> +		}
> +	}
> +
> +	_unlock_hashtbl(bond);
> +	return count;
> +}
> +
>  /* Caller must hold rx_hashtbl lock */
>  static void rlb_init_table_entry(struct rlb_client_info *entry)
>  {
> diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
> index 09d755a..57e761b 100644
> --- a/drivers/net/bonding/bond_alb.h
> +++ b/drivers/net/bonding/bond_alb.h
> @@ -131,5 +131,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev);
>  void bond_alb_monitor(struct work_struct *);
>  int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr);
>  void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id);
> +int rlb_print_rx_hashtbl(struct bonding *bond, char *buf);
> +int tlb_print_tx_hashtbl(struct bonding *bond, char *buf);
>  #endif /* __BOND_ALB_H__ */
>  
> diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
> index 55bf34f..1123e1f 100644
> --- a/drivers/net/bonding/bond_sysfs.c
> +++ b/drivers/net/bonding/bond_sysfs.c
> @@ -1480,6 +1480,44 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d,
>  static DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL);
>  
>  
> +/*
> + * Show current tlb/alb tx hash table.
> + */
> +static ssize_t bonding_show_tlb_tx_hash(struct device *d,
> +					   struct device_attribute *attr,
> +					   char *buf)
> +{
> +	int count = 0;
> +	struct bonding *bond = to_bond(d);
> +
> +	if (bond->params.mode == BOND_MODE_ALB ||
> +	    bond->params.mode == BOND_MODE_TLB) {
> +		count = tlb_print_tx_hashtbl(bond, buf);
> +	}
> +
> +	return count;
> +}
> +static DEVICE_ATTR(tlb_tx_hash, S_IRUGO, bonding_show_tlb_tx_hash, NULL);
> +
> +
> +/*
> + * Show current alb rx hash table.
> + */
> +static ssize_t bonding_show_alb_rx_hash(struct device *d,
> +					   struct device_attribute *attr,
> +					   char *buf)
> +{
> +	int count = 0;
> +	struct bonding *bond = to_bond(d);
> +
> +	if (bond->params.mode == BOND_MODE_ALB) {
> +		count = rlb_print_rx_hashtbl(bond, buf);
> +	}
> +
> +	return count;
> +}
> +static DEVICE_ATTR(alb_rx_hash, S_IRUGO, bonding_show_alb_rx_hash, NULL);
> +
>  
>  static struct attribute *per_bond_attrs[] = {
>  	&dev_attr_slaves.attr,
> @@ -1505,6 +1543,8 @@ static struct attribute *per_bond_attrs[] = {
>  	&dev_attr_ad_actor_key.attr,
>  	&dev_attr_ad_partner_key.attr,
>  	&dev_attr_ad_partner_mac.attr,
> +	&dev_attr_alb_rx_hash.attr,
> +	&dev_attr_tlb_tx_hash.attr,
>  	NULL,
>  };
>  

Any thoughts on this one as well, Jay?


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [PATCH 4/4 v2] bonding: add sysfs files to display tlb and alb hash table contents
  2009-09-28 22:01   ` Andy Gospodarek
@ 2009-09-28 22:06     ` Jay Vosburgh
  0 siblings, 0 replies; 13+ messages in thread
From: Jay Vosburgh @ 2009-09-28 22:06 UTC (permalink / raw)
  To: Andy Gospodarek; +Cc: netdev, bonding-devel

Andy Gospodarek <andy@greyhouse.net> wrote:

>On Fri, Sep 18, 2009 at 11:53:11AM -0400, Andy Gospodarek wrote:
>> On Fri, Sep 11, 2009 at 05:13:17PM -0400, Andy Gospodarek wrote:
>> > 
>> > bonding: add sysfs files to display tlb and alb hash table contents
>> > 
>> > While debugging some problems with alb (mode 6) bonding I realized that
>> > being able to output the contents of both hash tables would be helpful.
>> > This is what the output looks like for the two files:
>> > 
>> > device  load
>> > eth1    491
>> > eth2    491
>> > hash device   last device   tx bytes       load        next previous
>> > 2    eth1     eth1          2254           491         0    0
>> > 3    eth2     eth2          2744           491         0    0
>> > 6             eth2          0              488         0    0
>> > 8             eth2          0              461698      0    0
>> > 1b            eth2          0              249         0    0
>> > eb            eth2          0              21          0    0
>> > ff            eth2          0              22          0    0
>> > 
>> > hash ip_src          ip_dst          mac_dst           slave assign ntt
>> > 2    10.0.3.2        10.0.3.11       00:e0:81:71:ee:a9 eth1  1      0
>> > 3    10.0.3.2        10.0.3.10       00:e0:81:71:ee:a9 eth2  1      0
>> > 8    10.0.3.2        10.0.3.1        00:e0:81:71:ee:a9 eth2  1      0
>> > 
>> > These were a great help debugging the fixes I have just posted and they
>> > might be helpful for others, so I decided to include them in my
>> > patchset.
>> > 
>> > Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
>> > 
>> 
>> Needed to repost since patch 2/4 changed and first patch had whitespace
>> issues:
>> 
>> [PATCH v2] bonding: add sysfs files to display tlb and alb hash table contents
>> 
>> While debugging some problems with alb (mode 6) bonding I realized that
>> being able to output the contents of both hash tables would be helpful.
>> This is what the output looks like for the two files:
>> 
>> device  load
>> eth1    491
>> eth2    491
>> hash device   last device   tx bytes       load        next previous
>> 2    eth1     eth1          2254           491         0    0
>> 3    eth2     eth2          2744           491         0    0
>> 6             eth2          0              488         0    0
>> 8             eth2          0              461698      0    0
>> 1b            eth2          0              249         0    0
>> eb            eth2          0              21          0    0
>> ff            eth2          0              22          0    0
>> 
>> hash ip_src          ip_dst          mac_dst           slave assign ntt
>> 2    10.0.3.2        10.0.3.11       00:e0:81:71:ee:a9 eth1  1      0
>> 3    10.0.3.2        10.0.3.10       00:e0:81:71:ee:a9 eth2  1      0
>> 8    10.0.3.2        10.0.3.1        00:e0:81:71:ee:a9 eth2  1      0
>> 
>> These were a great help debugging the fixes I have just posted and they
>> might be helpful for others, so I decided to include them in my post.
>> 
>> Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
>> 
>> ---
>>  drivers/net/bonding/bond_alb.c   |   61 ++++++++++++++++++++++++++++++++++++++
>>  drivers/net/bonding/bond_alb.h   |    2 +
>>  drivers/net/bonding/bond_sysfs.c |   40 +++++++++++++++++++++++++
>>  3 files changed, 103 insertions(+), 0 deletions(-)
>> 
>> diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c
>> index 5d51489..adc5acd 100644
>> --- a/drivers/net/bonding/bond_alb.c
>> +++ b/drivers/net/bonding/bond_alb.c
>> @@ -750,6 +750,67 @@ static struct slave *rlb_arp_xmit(struct sk_buff *skb, struct bonding *bond)
>>  	return tx_slave;
>>  }
>>  
>> +int rlb_print_rx_hashtbl(struct bonding *bond, char *buf)
>> +{
>> +	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
>> +	struct rlb_client_info *client_info;
>> +	u32 hash_index;
>> +	u32 count = 0;
>> +
>> +	_lock_hashtbl(bond);
>> +
>> +	count = sprintf(buf, "hash ip_src          ip_dst          mac_dst           slave assign ntt\n");
>> +	hash_index = bond_info->rx_hashtbl_head;
>> +	for (; hash_index != RLB_NULL_INDEX; hash_index = client_info->next) {
>> +		client_info = &(bond_info->rx_hashtbl[hash_index]);
>> +		count += sprintf(buf + count,"%-4x %-15pi4 %-15pi4 %pM %-5s %-6d %d\n",
>> +				 hash_index,
>> +				 &client_info->ip_src,
>> +				 &client_info->ip_dst,
>> +				 client_info->mac_dst,
>> +				 client_info->slave->dev->name,
>> +				 client_info->assigned,
>> +				 client_info->ntt);
>> +	}
>> +
>> +	_unlock_hashtbl(bond);
>> +	return count;
>> +}
>> +
>> +int tlb_print_tx_hashtbl(struct bonding *bond, char *buf)
>> +{
>> +	struct alb_bond_info *bond_info = &(BOND_ALB_INFO(bond));
>> +	u32 hash_index;
>> +	u32 count = 0;
>> +	struct slave *slave;
>> +	int i;
>> +
>> +	_lock_hashtbl(bond);
>> +
>> +	count += sprintf(buf, "device  load\n");
>> +	bond_for_each_slave(bond, slave, i) {
>> +		struct tlb_slave_info *slave_info = &(SLAVE_TLB_INFO(slave));
>> +		count += sprintf(buf + count,"%-7s %d\n",slave->dev->name,slave_info->load);
>> +	}
>> +	count += sprintf(buf + count, "hash device   last device   tx bytes       load        next previous\n");
>> +	for (hash_index = 0; hash_index < TLB_HASH_TABLE_SIZE; hash_index++) {
>> +		struct tlb_client_info *client_info = &(bond_info->tx_hashtbl[hash_index]);
>> +		if (client_info->tx_slave || client_info->last_slave) {
>> +			count += sprintf(buf + count,"%-4x %-8s %-13s %-14d %-11d %-4x %d\n",
>> +					 hash_index,
>> +					 (client_info->tx_slave) ? client_info->tx_slave->dev->name : "",
>> +					 (client_info->last_slave) ? client_info->last_slave->dev->name : "",
>> +					 client_info->tx_bytes,
>> +					 client_info->load_history,
>> +					 (client_info->next != TLB_NULL_INDEX) ? client_info->next : 0,
>> +					 (client_info->prev != TLB_NULL_INDEX) ? client_info->prev : 0);
>> +		}
>> +	}
>> +
>> +	_unlock_hashtbl(bond);
>> +	return count;
>> +}
>> +
>>  /* Caller must hold rx_hashtbl lock */
>>  static void rlb_init_table_entry(struct rlb_client_info *entry)
>>  {
>> diff --git a/drivers/net/bonding/bond_alb.h b/drivers/net/bonding/bond_alb.h
>> index 09d755a..57e761b 100644
>> --- a/drivers/net/bonding/bond_alb.h
>> +++ b/drivers/net/bonding/bond_alb.h
>> @@ -131,5 +131,7 @@ int bond_alb_xmit(struct sk_buff *skb, struct net_device *bond_dev);
>>  void bond_alb_monitor(struct work_struct *);
>>  int bond_alb_set_mac_address(struct net_device *bond_dev, void *addr);
>>  void bond_alb_clear_vlan(struct bonding *bond, unsigned short vlan_id);
>> +int rlb_print_rx_hashtbl(struct bonding *bond, char *buf);
>> +int tlb_print_tx_hashtbl(struct bonding *bond, char *buf);
>>  #endif /* __BOND_ALB_H__ */
>>  
>> diff --git a/drivers/net/bonding/bond_sysfs.c b/drivers/net/bonding/bond_sysfs.c
>> index 55bf34f..1123e1f 100644
>> --- a/drivers/net/bonding/bond_sysfs.c
>> +++ b/drivers/net/bonding/bond_sysfs.c
>> @@ -1480,6 +1480,44 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d,
>>  static DEVICE_ATTR(ad_partner_mac, S_IRUGO, bonding_show_ad_partner_mac, NULL);
>>  
>>  
>> +/*
>> + * Show current tlb/alb tx hash table.
>> + */
>> +static ssize_t bonding_show_tlb_tx_hash(struct device *d,
>> +					   struct device_attribute *attr,
>> +					   char *buf)
>> +{
>> +	int count = 0;
>> +	struct bonding *bond = to_bond(d);
>> +
>> +	if (bond->params.mode == BOND_MODE_ALB ||
>> +	    bond->params.mode == BOND_MODE_TLB) {
>> +		count = tlb_print_tx_hashtbl(bond, buf);
>> +	}
>> +
>> +	return count;
>> +}
>> +static DEVICE_ATTR(tlb_tx_hash, S_IRUGO, bonding_show_tlb_tx_hash, NULL);
>> +
>> +
>> +/*
>> + * Show current alb rx hash table.
>> + */
>> +static ssize_t bonding_show_alb_rx_hash(struct device *d,
>> +					   struct device_attribute *attr,
>> +					   char *buf)
>> +{
>> +	int count = 0;
>> +	struct bonding *bond = to_bond(d);
>> +
>> +	if (bond->params.mode == BOND_MODE_ALB) {
>> +		count = rlb_print_rx_hashtbl(bond, buf);
>> +	}
>> +
>> +	return count;
>> +}
>> +static DEVICE_ATTR(alb_rx_hash, S_IRUGO, bonding_show_alb_rx_hash, NULL);
>> +
>>  
>>  static struct attribute *per_bond_attrs[] = {
>>  	&dev_attr_slaves.attr,
>> @@ -1505,6 +1543,8 @@ static struct attribute *per_bond_attrs[] = {
>>  	&dev_attr_ad_actor_key.attr,
>>  	&dev_attr_ad_partner_key.attr,
>>  	&dev_attr_ad_partner_mac.attr,
>> +	&dev_attr_alb_rx_hash.attr,
>> +	&dev_attr_tlb_tx_hash.attr,
>>  	NULL,
>>  };
>>  
>
>Any thoughts on this one as well, Jay?
>

	I've been testing with them last Friday and today.  Seem to work
ok so far.  I've made a couple of minor changes (removed some remaining
vestiges of the rlb rebalance code, changed the mode of the sysfs hash
table files to 0400 after some testing with ping and concurrent "while 1
cat > /dev/null" loops).

	Unless something awful comes up, I'll post them with my changes
later today or tomorrow.

	-J

---
	-Jay Vosburgh, IBM Linux Technology Center, fubar@us.ibm.com

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Bonding-devel] [PATCH 4/4] bonding: add sysfs files to display tlb and alb hash table contents
  2009-09-11 21:13 [PATCH 4/4] bonding: add sysfs files to display tlb and alb hash table contents Andy Gospodarek
  2009-09-11 21:48 ` Jay Vosburgh
  2009-09-18 15:53 ` [PATCH 4/4 v2] " Andy Gospodarek
@ 2009-09-28 23:22 ` Stephen Hemminger
  2009-09-29  0:12   ` Andy Gospodarek
  2 siblings, 1 reply; 13+ messages in thread
From: Stephen Hemminger @ 2009-09-28 23:22 UTC (permalink / raw)
  To: Andy Gospodarek; +Cc: netdev, fubar, bonding-devel

On Fri, 11 Sep 2009 17:13:17 -0400
Andy Gospodarek <andy@greyhouse.net> wrote:

> 
> bonding: add sysfs files to display tlb and alb hash table contents
> 
> While debugging some problems with alb (mode 6) bonding I realized that
> being able to output the contents of both hash tables would be helpful.
> This is what the output looks like for the two files:
> 
> device  load
> eth1    491
> eth2    491
> hash device   last device   tx bytes       load        next previous
> 2    eth1     eth1          2254           491         0    0
> 3    eth2     eth2          2744           491         0    0
> 6             eth2          0              488         0    0
> 8             eth2          0              461698      0    0
> 1b            eth2          0              249         0    0
> eb            eth2          0              21          0    0
> ff            eth2          0              22          0    0
> 
> hash ip_src          ip_dst          mac_dst           slave assign ntt
> 2    10.0.3.2        10.0.3.11       00:e0:81:71:ee:a9 eth1  1      0
> 3    10.0.3.2        10.0.3.10       00:e0:81:71:ee:a9 eth2  1      0
> 8    10.0.3.2        10.0.3.1        00:e0:81:71:ee:a9 eth2  1      0
> 
> These were a great help debugging the fixes I have just posted and they
> might be helpful for others, so I decided to include them in my
> patchset.
> 
> Signed-off-by: Andy Gospodarek <andy@greyhouse.net>

No.

Please don't put formatted output in sysfs, it is not meant to be
used like proc, there is supposed to be only one value per file.

Maybe put it on the end of the /proc/net/bonding/bond0 output or
use debugfs

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Bonding-devel] [PATCH 4/4] bonding: add sysfs files to display tlb and alb hash table contents
  2009-09-28 23:22 ` [Bonding-devel] [PATCH 4/4] " Stephen Hemminger
@ 2009-09-29  0:12   ` Andy Gospodarek
  2009-09-29  0:34     ` Stephen Hemminger
  2009-09-29  0:44     ` David Miller
  0 siblings, 2 replies; 13+ messages in thread
From: Andy Gospodarek @ 2009-09-29  0:12 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Andy Gospodarek, netdev, fubar, bonding-devel

On Mon, Sep 28, 2009 at 04:22:37PM -0700, Stephen Hemminger wrote:
> On Fri, 11 Sep 2009 17:13:17 -0400
> Andy Gospodarek <andy@greyhouse.net> wrote:
> 
> > 
> > bonding: add sysfs files to display tlb and alb hash table contents
> > 
> > While debugging some problems with alb (mode 6) bonding I realized that
> > being able to output the contents of both hash tables would be helpful.
> > This is what the output looks like for the two files:
> > 
> > device  load
> > eth1    491
> > eth2    491
> > hash device   last device   tx bytes       load        next previous
> > 2    eth1     eth1          2254           491         0    0
> > 3    eth2     eth2          2744           491         0    0
> > 6             eth2          0              488         0    0
> > 8             eth2          0              461698      0    0
> > 1b            eth2          0              249         0    0
> > eb            eth2          0              21          0    0
> > ff            eth2          0              22          0    0
> > 
> > hash ip_src          ip_dst          mac_dst           slave assign ntt
> > 2    10.0.3.2        10.0.3.11       00:e0:81:71:ee:a9 eth1  1      0
> > 3    10.0.3.2        10.0.3.10       00:e0:81:71:ee:a9 eth2  1      0
> > 8    10.0.3.2        10.0.3.1        00:e0:81:71:ee:a9 eth2  1      0
> > 
> > These were a great help debugging the fixes I have just posted and they
> > might be helpful for others, so I decided to include them in my
> > patchset.
> > 
> > Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
> 
> No.
> 
> Please don't put formatted output in sysfs, it is not meant to be
> used like proc, there is supposed to be only one value per file.

Then based on the over 300 files in /sys/ that are more than 1 line on
my currently running kernel, it seems there is significant work to do.

Seemingly arbitrary requests like this are extremely annoying when the
current kernel violates them all over the place.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Bonding-devel] [PATCH 4/4] bonding: add sysfs files to display tlb and alb hash table contents
  2009-09-29  0:12   ` Andy Gospodarek
@ 2009-09-29  0:34     ` Stephen Hemminger
  2009-09-29  1:37       ` Andy Gospodarek
  2009-09-29  0:44     ` David Miller
  1 sibling, 1 reply; 13+ messages in thread
From: Stephen Hemminger @ 2009-09-29  0:34 UTC (permalink / raw)
  To: Andy Gospodarek; +Cc: Andy Gospodarek, netdev, fubar, bonding-devel

On Mon, 28 Sep 2009 20:12:03 -0400
Andy Gospodarek <andy@greyhouse.net> wrote:

> On Mon, Sep 28, 2009 at 04:22:37PM -0700, Stephen Hemminger wrote:
> > On Fri, 11 Sep 2009 17:13:17 -0400
> > Andy Gospodarek <andy@greyhouse.net> wrote:
> > 
> > > 
> > > bonding: add sysfs files to display tlb and alb hash table contents
> > > 
> > > While debugging some problems with alb (mode 6) bonding I realized that
> > > being able to output the contents of both hash tables would be helpful.
> > > This is what the output looks like for the two files:
> > > 
> > > device  load
> > > eth1    491
> > > eth2    491
> > > hash device   last device   tx bytes       load        next previous
> > > 2    eth1     eth1          2254           491         0    0
> > > 3    eth2     eth2          2744           491         0    0
> > > 6             eth2          0              488         0    0
> > > 8             eth2          0              461698      0    0
> > > 1b            eth2          0              249         0    0
> > > eb            eth2          0              21          0    0
> > > ff            eth2          0              22          0    0
> > > 
> > > hash ip_src          ip_dst          mac_dst           slave assign ntt
> > > 2    10.0.3.2        10.0.3.11       00:e0:81:71:ee:a9 eth1  1      0
> > > 3    10.0.3.2        10.0.3.10       00:e0:81:71:ee:a9 eth2  1      0
> > > 8    10.0.3.2        10.0.3.1        00:e0:81:71:ee:a9 eth2  1      0
> > > 
> > > These were a great help debugging the fixes I have just posted and they
> > > might be helpful for others, so I decided to include them in my
> > > patchset.
> > > 
> > > Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
> > 
> > No.
> > 
> > Please don't put formatted output in sysfs, it is not meant to be
> > used like proc, there is supposed to be only one value per file.
> 
> Then based on the over 300 files in /sys/ that are more than 1 line on
> my currently running kernel, it seems there is significant work to do.
> 
> Seemingly arbitrary requests like this are extremely annoying when the
> current kernel violates them all over the place.
> 

The rules are documented in Documentation/sysfs-rules.txt. If you want
to change the rules, submit a change to the rules.

-- 

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Bonding-devel] [PATCH 4/4] bonding: add sysfs files to display tlb and alb hash table contents
  2009-09-29  0:12   ` Andy Gospodarek
  2009-09-29  0:34     ` Stephen Hemminger
@ 2009-09-29  0:44     ` David Miller
  1 sibling, 0 replies; 13+ messages in thread
From: David Miller @ 2009-09-29  0:44 UTC (permalink / raw)
  To: andy; +Cc: shemminger, netdev, fubar, bonding-devel

From: Andy Gospodarek <andy@greyhouse.net>
Date: Mon, 28 Sep 2009 20:12:03 -0400

> Seemingly arbitrary requests like this are extremely annoying when the
> current kernel violates them all over the place.

And two wrongs don't make a right.

Just because things are not enforced properly elsewhere doesn't
mean we can be knowingly oblivious to the issue on new stuff.

Please adhere to Stephen's request, it's legitimate.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Bonding-devel] [PATCH 4/4] bonding: add sysfs files to display tlb and alb hash table contents
  2009-09-29  0:34     ` Stephen Hemminger
@ 2009-09-29  1:37       ` Andy Gospodarek
  2009-09-29  3:00         ` Stephen Hemminger
  0 siblings, 1 reply; 13+ messages in thread
From: Andy Gospodarek @ 2009-09-29  1:37 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: Andy Gospodarek, netdev, fubar, bonding-devel

On Mon, Sep 28, 2009 at 05:34:20PM -0700, Stephen Hemminger wrote:
> On Mon, 28 Sep 2009 20:12:03 -0400
> Andy Gospodarek <andy@greyhouse.net> wrote:
> 
> > On Mon, Sep 28, 2009 at 04:22:37PM -0700, Stephen Hemminger wrote:
> > > On Fri, 11 Sep 2009 17:13:17 -0400
> > > Andy Gospodarek <andy@greyhouse.net> wrote:
> > > 
> > > > 
> > > > bonding: add sysfs files to display tlb and alb hash table contents
> > > > 
> > > > While debugging some problems with alb (mode 6) bonding I realized that
> > > > being able to output the contents of both hash tables would be helpful.
> > > > This is what the output looks like for the two files:
> > > > 
> > > > device  load
> > > > eth1    491
> > > > eth2    491
> > > > hash device   last device   tx bytes       load        next previous
> > > > 2    eth1     eth1          2254           491         0    0
> > > > 3    eth2     eth2          2744           491         0    0
> > > > 6             eth2          0              488         0    0
> > > > 8             eth2          0              461698      0    0
> > > > 1b            eth2          0              249         0    0
> > > > eb            eth2          0              21          0    0
> > > > ff            eth2          0              22          0    0
> > > > 
> > > > hash ip_src          ip_dst          mac_dst           slave assign ntt
> > > > 2    10.0.3.2        10.0.3.11       00:e0:81:71:ee:a9 eth1  1      0
> > > > 3    10.0.3.2        10.0.3.10       00:e0:81:71:ee:a9 eth2  1      0
> > > > 8    10.0.3.2        10.0.3.1        00:e0:81:71:ee:a9 eth2  1      0
> > > > 
> > > > These were a great help debugging the fixes I have just posted and they
> > > > might be helpful for others, so I decided to include them in my
> > > > patchset.
> > > > 
> > > > Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
> > > 
> > > No.
> > > 
> > > Please don't put formatted output in sysfs, it is not meant to be
> > > used like proc, there is supposed to be only one value per file.
> > 
> > Then based on the over 300 files in /sys/ that are more than 1 line on
> > my currently running kernel, it seems there is significant work to do.
> > 
> > Seemingly arbitrary requests like this are extremely annoying when the
> > current kernel violates them all over the place.
> > 
> 
> The rules are documented in Documentation/sysfs-rules.txt. If you want
> to change the rules, submit a change to the rules.
> 

That specific request is actually in filesystems/sysfs.txt in the
'Attributes' section, but the fact that it's actually outlined somewhere
makes the request seem less 'arbitrary.'  ;-)


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: [Bonding-devel] [PATCH 4/4] bonding: add sysfs files to display tlb and alb hash table contents
  2009-09-29  1:37       ` Andy Gospodarek
@ 2009-09-29  3:00         ` Stephen Hemminger
  0 siblings, 0 replies; 13+ messages in thread
From: Stephen Hemminger @ 2009-09-29  3:00 UTC (permalink / raw)
  To: Andy Gospodarek; +Cc: Andy Gospodarek, netdev, fubar, bonding-devel

On Mon, 28 Sep 2009 21:37:13 -0400
Andy Gospodarek <andy@greyhouse.net> wrote:

> On Mon, Sep 28, 2009 at 05:34:20PM -0700, Stephen Hemminger wrote:
> > On Mon, 28 Sep 2009 20:12:03 -0400
> > Andy Gospodarek <andy@greyhouse.net> wrote:
> > 
> > > On Mon, Sep 28, 2009 at 04:22:37PM -0700, Stephen Hemminger wrote:
> > > > On Fri, 11 Sep 2009 17:13:17 -0400
> > > > Andy Gospodarek <andy@greyhouse.net> wrote:
> > > > 
> > > > > 
> > > > > bonding: add sysfs files to display tlb and alb hash table contents
> > > > > 
> > > > > While debugging some problems with alb (mode 6) bonding I realized that
> > > > > being able to output the contents of both hash tables would be helpful.
> > > > > This is what the output looks like for the two files:
> > > > > 
> > > > > device  load
> > > > > eth1    491
> > > > > eth2    491
> > > > > hash device   last device   tx bytes       load        next previous
> > > > > 2    eth1     eth1          2254           491         0    0
> > > > > 3    eth2     eth2          2744           491         0    0
> > > > > 6             eth2          0              488         0    0
> > > > > 8             eth2          0              461698      0    0
> > > > > 1b            eth2          0              249         0    0
> > > > > eb            eth2          0              21          0    0
> > > > > ff            eth2          0              22          0    0
> > > > > 
> > > > > hash ip_src          ip_dst          mac_dst           slave assign ntt
> > > > > 2    10.0.3.2        10.0.3.11       00:e0:81:71:ee:a9 eth1  1      0
> > > > > 3    10.0.3.2        10.0.3.10       00:e0:81:71:ee:a9 eth2  1      0
> > > > > 8    10.0.3.2        10.0.3.1        00:e0:81:71:ee:a9 eth2  1      0
> > > > > 
> > > > > These were a great help debugging the fixes I have just posted and they
> > > > > might be helpful for others, so I decided to include them in my
> > > > > patchset.
> > > > > 
> > > > > Signed-off-by: Andy Gospodarek <andy@greyhouse.net>
> > > > 
> > > > No.
> > > > 
> > > > Please don't put formatted output in sysfs, it is not meant to be
> > > > used like proc, there is supposed to be only one value per file.
> > > 
> > > Then based on the over 300 files in /sys/ that are more than 1 line on
> > > my currently running kernel, it seems there is significant work to do.
> > > 
> > > Seemingly arbitrary requests like this are extremely annoying when the
> > > current kernel violates them all over the place.
> > > 
> > 
> > The rules are documented in Documentation/sysfs-rules.txt. If you want
> > to change the rules, submit a change to the rules.
> > 
> 
> That specific request is actually in filesystems/sysfs.txt in the
> 'Attributes' section, but the fact that it's actually outlined somewhere
> makes the request seem less 'arbitrary.'  ;-)
> 

Ah, that is where the note is:
----------------------

Attributes
~~~~~~~~~~

Attributes can be exported for kobjects in the form of regular files in
the filesystem. Sysfs forwards file I/O operations to methods defined
for the attributes, providing a means to read and write kernel
attributes.

Attributes should be ASCII text files, preferably with only one value
per file. It is noted that it may not be efficient to contain only one
value per file, so it is socially acceptable to express an array of
values of the same type. 

Mixing types, expressing multiple lines of data, and doing fancy
formatting of data is heavily frowned upon. Doing these things may get
you publically humiliated and your code rewritten without notice.

-- 

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2009-09-29  3:00 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-11 21:13 [PATCH 4/4] bonding: add sysfs files to display tlb and alb hash table contents Andy Gospodarek
2009-09-11 21:48 ` Jay Vosburgh
2009-09-14 14:45   ` Andy Gospodarek
2009-09-14 19:37     ` [Bonding-devel] " Nicolas de Pesloüan
2009-09-18 15:53 ` [PATCH 4/4 v2] " Andy Gospodarek
2009-09-28 22:01   ` Andy Gospodarek
2009-09-28 22:06     ` Jay Vosburgh
2009-09-28 23:22 ` [Bonding-devel] [PATCH 4/4] " Stephen Hemminger
2009-09-29  0:12   ` Andy Gospodarek
2009-09-29  0:34     ` Stephen Hemminger
2009-09-29  1:37       ` Andy Gospodarek
2009-09-29  3:00         ` Stephen Hemminger
2009-09-29  0:44     ` David Miller

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.