[ovs-discuss] [* 1/2] vswitchd: Add bond hashes to /proc/net/bonding compatibility layer.

Ben Pfaff blp at nicira.com
Wed Jul 29 19:26:40 UTC 2009


The Citrix QA scripts require the bond hashes and their assigned devices
to be noted in /proc/net/bonding.  We weren't doing that, so this commit
adds them.

Bug NIC-16.
---
 vswitchd/bridge.c          |   16 ++++++++++++++++
 vswitchd/proc-net-compat.c |    6 ++++++
 vswitchd/proc-net-compat.h |    9 +++++++++
 3 files changed, 31 insertions(+), 0 deletions(-)

diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c
index b107320..be275a4 100644
--- a/vswitchd/bridge.c
+++ b/vswitchd/bridge.c
@@ -2879,6 +2879,7 @@ port_update_bonding(struct port *port)
 static void
 port_update_bond_compat(struct port *port)
 {
+    struct compat_bond_hash compat_hashes[BOND_MASK + 1];
     struct compat_bond bond;
     size_t i;
 
@@ -2889,6 +2890,20 @@ port_update_bond_compat(struct port *port)
     bond.up = false;
     bond.updelay = port->updelay;
     bond.downdelay = port->downdelay;
+
+    bond.n_hashes = 0;
+    bond.hashes = compat_hashes;
+    if (port->bond_hash) {
+        const struct bond_entry *e;
+        for (e = port->bond_hash; e <= &port->bond_hash[BOND_MASK]; e++) {
+            if (e->iface_idx >= 0 && e->iface_idx < port->n_ifaces) {
+                struct compat_bond_hash *cbh = &bond.hashes[bond.n_hashes++];
+                cbh->hash = e - port->bond_hash;
+                cbh->netdev_name = port->ifaces[e->iface_idx]->name;
+            }
+        }
+    }
+
     bond.n_slaves = port->n_ifaces;
     bond.slaves = xmalloc(port->n_ifaces * sizeof *bond.slaves);
     for (i = 0; i < port->n_ifaces; i++) {
@@ -2902,6 +2917,7 @@ port_update_bond_compat(struct port *port)
         }
         memcpy(slave->mac, iface->mac, ETH_ADDR_LEN);
     }
+
     proc_net_compat_update_bond(port->name, &bond);
     free(bond.slaves);
 }
diff --git a/vswitchd/proc-net-compat.c b/vswitchd/proc-net-compat.c
index 8e8dd23..7a59526 100644
--- a/vswitchd/proc-net-compat.c
+++ b/vswitchd/proc-net-compat.c
@@ -154,6 +154,12 @@ proc_net_compat_update_bond(const char *name, const struct compat_bond *bond)
         "\n"
         "Source load balancing info:\n",
         bond->up ? "up" : "down", bond->updelay, bond->downdelay);
+
+    for (i = 0; i < bond->n_hashes; i++) {
+        const struct compat_bond_hash *cbh = &bond->hashes[i];
+        ds_put_format(&ds, " [%03d] = %s\n", cbh->hash, cbh->netdev_name);
+    }
+
     for (i = 0; i < bond->n_slaves; i++) {
         const struct compat_bond_slave *slave = &bond->slaves[i];
         ds_put_format(
diff --git a/vswitchd/proc-net-compat.h b/vswitchd/proc-net-compat.h
index a5b3196..82d550f 100644
--- a/vswitchd/proc-net-compat.h
+++ b/vswitchd/proc-net-compat.h
@@ -22,10 +22,19 @@ struct compat_bond {
     bool up;
     int updelay;
     int downdelay;
+
+    int n_hashes;
+    struct compat_bond_hash *hashes;
+
     int n_slaves;
     struct compat_bond_slave *slaves;
 };
 
+struct compat_bond_hash {
+    int hash;
+    const char *netdev_name;
+};
+
 struct compat_bond_slave {
     const char *name;
     bool up;
-- 
1.6.3.3





More information about the discuss mailing list