From: Ben Pfaff Date: Wed, 29 Jul 2009 00:10:10 +0000 (-0700) Subject: vswitchd: Add bond hashes to /proc/net/bonding compatibility layer. X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2aebae8397b7c698a627d5a1c7f4b931bf611516;p=openvswitch vswitchd: Add bond hashes to /proc/net/bonding compatibility layer. 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. --- diff --git a/vswitchd/bridge.c b/vswitchd/bridge.c index 057172e4..eaca1e75 100644 --- a/vswitchd/bridge.c +++ b/vswitchd/bridge.c @@ -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); } diff --git a/vswitchd/proc-net-compat.c b/vswitchd/proc-net-compat.c index 8e8dd237..7a595265 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 a5b31961..82d550f5 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;