vswitchd: Add bond hashes to /proc/net/bonding compatibility layer.
authorBen Pfaff <blp@nicira.com>
Wed, 29 Jul 2009 00:10:10 +0000 (17:10 -0700)
committerBen Pfaff <blp@nicira.com>
Thu, 30 Jul 2009 16:31:01 +0000 (09:31 -0700)
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
vswitchd/proc-net-compat.c
vswitchd/proc-net-compat.h

index 057172e..eaca1e7 100644 (file)
@@ -2903,6 +2903,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;
 
@@ -2913,6 +2914,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++) {
@@ -2926,6 +2941,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);
 }
index 8e8dd23..7a59526 100644 (file)
@@ -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(
index a5b3196..82d550f 100644 (file)
@@ -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;